about summary refs log tree commit diff
path: root/src/nix-instantiate/bin2c.c
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-11-18T11·38+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-11-18T11·38+0000
commitb1117ef29d35822647bda32f8cd3887f4f6eaede (patch)
tree1635a7fd961930104c56aef2fa20ecb3e29d9798 /src/nix-instantiate/bin2c.c
parentce92d1bf1434562f5b80320c503768c4d06f1f8d (diff)
* nix -> nix-store, fix -> nix-instantiate.
Diffstat (limited to 'src/nix-instantiate/bin2c.c')
-rw-r--r--src/nix-instantiate/bin2c.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/nix-instantiate/bin2c.c b/src/nix-instantiate/bin2c.c
new file mode 100644
index 000000000000..18bf81d69e25
--- /dev/null
+++ b/src/nix-instantiate/bin2c.c
@@ -0,0 +1,23 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+void print(const char *format, ...)
+{
+    va_list ap;
+    va_start(ap, format);
+    if (vprintf(format, ap) < 0) abort();
+    va_end(ap);
+}
+
+int main(int argc, char * * argv)
+{
+    int c;
+    if (argc != 2) abort();
+    print("static unsigned char %s[] = {", argv[1]);
+    while ((c = getchar()) != EOF) {
+        print("0x%02x, ", (unsigned char) c);
+    }
+    print("};\n");
+    return 0;
+}