initial load of upstream version 1.06.32
[xmlrpc-c] / tools / binmode-rpc-kit / oct2bin
diff --git a/tools/binmode-rpc-kit/oct2bin b/tools/binmode-rpc-kit/oct2bin
new file mode 100755 (executable)
index 0000000..8fea23f
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+# Turn C-style octal escapes into binary.
+# Call as "echo -n 'ab\0\001cd' | oct2bin > out.binmode".
+
+binmode STDOUT;
+
+while (<>) {
+    s/\\(\d\d\d)/chr(oct($1))/ge;
+    s/\\0/chr(0)/ge;
+    s/\\\\/\\/g;
+    print $_;
+}