"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "static/c-ify.c" between
darkstat-3.0.719.tar.gz and darkstat-3.0.721.tar.gz

About: darkstat is a network traffic analyzer (reports over HTTP).

c-ify.c  (darkstat-3.0.719):c-ify.c  (darkstat-3.0.721)
/* DON'T LOOK AT MY FACE! MY HIDEOUS FACE! */ /* Converts a textfile to a const char array with characters escaped. */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int c, eol; int c, eol;
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "usage: %s name <infile >outfile.h\n", fprintf(stderr, "usage: %s name <infile >outfile.h\n",
argv[0]); argv[0]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
printf("/* this file was automatically generated */\n" printf("/* this file was automatically generated with c-ify */\n"
"static char %s[] =", argv[1]); "static const char %s[] =", argv[1]);
eol = 1; eol = 1;
while ((c = getchar()) != EOF) { while ((c = getchar()) != EOF) {
if (eol) { if (eol) {
printf("\n\""); printf("\n\"");
eol = 0; eol = 0;
} }
switch (c) { switch (c) {
case '\n': printf("\\n\""); eol = 1; break; case '\n': printf("\\n\""); eol = 1; break;
case '"': printf("\\\""); break; case '"': printf("\\\""); break;
case '\\': printf("\\\\"); break; case '\\': printf("\\\\"); break;
 End of changes. 3 change blocks. 
3 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)