1 # A simple IPC server executing arbitrary Ruby program.
3 # The protocol is based on Assuan protocol of GnuPG.
4 # http://www.gnupg.org/(en)/related_software/libassuan/index.html
22 d = "dispatch_#{c.downcase}"
23 if respond_to?(d, true)
28 puts("ERR 103 Unknown command\r\n")
33 def dispatch_cancel(c, r)
34 puts("ERR 100 Not implemented\r\n")
37 def dispatch_bye(c, r)
38 puts("ERR 100 Not implemented\r\n")
41 def dispatch_auth(c, r)
42 puts("ERR 100 Not implemented\r\n")
45 def dispatch_reset(c, r)
46 puts("ERR 100 Not implemented\r\n")
49 def dispatch_end(c, r)
53 def dispatch_help(c, r)
54 puts("ERR 100 Not implemented\r\n")
57 def dispatch_quit(c, r)
58 puts("ERR 100 Not implemented\r\n")
61 def dispatch_eval(c, r)
62 r = deq_data if r.empty?
71 puts("ERR #{$?.exitstatus}\r\n")
81 s.gsub(/[%\r\n]/) {|m| '%%%02X' % m[0]}
85 s.gsub(/%([0-9A-Z][0-9A-Z])/, ['\1'].pack('H*'))
91 len = [d.length, 998].min # 998 = 1000 - "D "
92 puts("D #{d[0 ... len]}\r\n")