Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / libpcap / msdos / bin2c.c
blobd82056e17a949f0a5712b9e3110bd1dc89a734db
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdarg.h>
4 #include <time.h>
6 static void Abort (char *fmt,...)
8 va_list args;
9 va_start (args, fmt);
10 vfprintf (stderr, fmt, args);
11 va_end (args);
12 exit (1);
15 int main (int argc, char **argv)
17 FILE *inFile;
18 FILE *outFile = stdout;
19 time_t now = time (NULL);
20 int ch, i;
22 if (argc != 2)
23 Abort ("Usage: %s bin-file [> result]", argv[0]);
25 if ((inFile = fopen(argv[1],"rb")) == NULL)
26 Abort ("Cannot open %s\n", argv[1]);
28 fprintf (outFile,
29 "/* data statements for file %s at %.24s */\n"
30 "/* Generated by BIN2C, G.Vanem 1995 */\n",
31 argv[1], ctime(&now));
33 i = 0;
34 while ((ch = fgetc(inFile)) != EOF)
36 if (i++ % 12 == 0)
37 fputs ("\n ", outFile);
38 fprintf (outFile, "0x%02X,", ch);
40 fputc ('\n', outFile);
41 fclose (inFile);
42 return (0);