diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-18 12:06:07 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-18 12:06:07 +0000 |
commit | dfc9c64ead7f24d51ed1a232e4b3ecafa8384f2e (patch) | |
tree | ab0d5b381eb01bec46a66174b3b09b60ea439bb7 /src/bin2c/bin2c.c | |
parent | b1117ef29d35822647bda32f8cd3887f4f6eaede (diff) | |
download | guix-dfc9c64ead7f24d51ed1a232e4b3ecafa8384f2e.tar.gz |
* "Fix expression" -> "Nix expression".
* More refactoring.
Diffstat (limited to 'src/bin2c/bin2c.c')
-rw-r--r-- | src/bin2c/bin2c.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/bin2c/bin2c.c b/src/bin2c/bin2c.c new file mode 100644 index 0000000000..18bf81d69e --- /dev/null +++ b/src/bin2c/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; +} |