From 9e9e7609c4664ca0754e49dd83f341a20b95d027 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Sep 2024 15:38:54 +0200 Subject: [PATCH] actual jsonlio and cborio from idm_mon imported --- lib/cborio.rb | 129 +++++++++++++++++++++++++++++++------------------ lib/jsonlio.rb | 90 ++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 47 deletions(-) create mode 100644 lib/jsonlio.rb diff --git a/lib/cborio.rb b/lib/cborio.rb index 0354c4f..7eb5402 100644 --- a/lib/cborio.rb +++ b/lib/cborio.rb @@ -1,54 +1,89 @@ +# vim: set noet sw=2 ts=2 sts=2: + require 'cbor' +require 'socket' -class CBORIO - include Enumerable - def orig_io() @io end - def unpacker() @un end - def close() @io.close end - def write( obj) @io.write CBOR.pack( obj) end - def sync() @io.sync end - def sync( v) @io.sync = v end - def self.pipe() IO.pipe.map &self.method(:new) end - def self.popen &exe - rd, wr = self.pipe - pid = - fork do - rd.close - yield wr - exit 0 - end - wr.close - [pid, rd] - end +class CBORIO " end - def initialize io - @io, @un = io, CBOR::Unpacker.new - @io.sync = true - end + class <" end + def initialize( io) @io = io end + + class <