diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2006-01-27 12:49:14 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2006-01-27 12:49:14 +0000 |
commit | 1cb9aba6ea86e27bf349a7658b36c0daa4a70908 (patch) | |
tree | 387f40289b74940078ffc2f4055295e9def15711 /bin2c.c | |
parent | 3883b4eb0cedb3d628a1267aa97f023cb0a2b9bd (diff) | |
download | sshfs-1cb9aba6ea86e27bf349a7658b36c0daa4a70908.tar sshfs-1cb9aba6ea86e27bf349a7658b36c0daa4a70908.tar.gz sshfs-1cb9aba6ea86e27bf349a7658b36c0daa4a70908.tar.bz2 sshfs-1cb9aba6ea86e27bf349a7658b36c0daa4a70908.zip |
fix
Diffstat (limited to 'bin2c.c')
-rw-r--r-- | bin2c.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -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; +} |