aboutsummaryrefslogtreecommitdiff
path: root/bin2c.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2006-01-27 12:49:14 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2006-01-27 12:49:14 +0000
commit1cb9aba6ea86e27bf349a7658b36c0daa4a70908 (patch)
tree387f40289b74940078ffc2f4055295e9def15711 /bin2c.c
parent3883b4eb0cedb3d628a1267aa97f023cb0a2b9bd (diff)
downloadsshfs-1cb9aba6ea86e27bf349a7658b36c0daa4a70908.tar
sshfs-1cb9aba6ea86e27bf349a7658b36c0daa4a70908.tar.gz
sshfs-1cb9aba6ea86e27bf349a7658b36c0daa4a70908.tar.bz2
sshfs-1cb9aba6ea86e27bf349a7658b36c0daa4a70908.zip
fix
Diffstat (limited to 'bin2c.c')
-rw-r--r--bin2c.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin2c.c b/bin2c.c
new file mode 100644
index 0000000..96dd2bc
--- /dev/null
+++ b/bin2c.c
@@ -0,0 +1,36 @@
+/*
+ * Unloved program to convert a binary on stdin to a C include on stdout
+ *
+ * Jan 1999 Matt Mackall <mpm@selenic.com>
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ */
+
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ int ch, total=0;
+
+ if (argc > 1)
+ printf("const char %s[] %s=\n",
+ argv[1], argc > 2 ? argv[2] : "");
+
+ do {
+ printf("\t\"");
+ while ((ch = getchar()) != EOF)
+ {
+ total++;
+ printf("\\x%02x",ch);
+ if (total % 16 == 0)
+ break;
+ }
+ printf("\"\n");
+ } while (ch != EOF);
+
+ if (argc > 1)
+ printf("\t;\n\nconst int %s_size = %d;\n", argv[1], total);
+
+ return 0;
+}