1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 /**********************************************/
str_delete_n(char * str)6 void str_delete_n(char* str)
7 {
8 char *s;
9
10 if(str == NULL)
11 return;
12
13 if (!*str)
14 return;
15 for (s = str + strlen (str) - 1; s >= str && ((unsigned char)*s)=='\n'; s--)
16 *s = '\0';
17 }
18 #define BSIZE 1024
19 /**********************************************/
main(int argc,char * argv[])20 int main(int argc,char* argv[])
21 {
22 FILE* fin;
23 FILE* fout;
24 char t[BSIZE];
25 char* filename = NULL;
26 if(argc<2)
27 filename = strdup("p");
28 else
29 filename = strdup(argv[1]);
30
31 printf("Input file = %s\n",filename);
32 printf("Output file = %s\n","p.c");
33
34 fin = fopen(filename,"r");
35 if(!fin)
36 {
37 printf("I can not open %s\n",filename);
38 return 1;
39 }
40 fout = fopen("p.c","w");
41 if(!fout)
42 {
43 printf("I can not open Fragment.c\n");
44 return 1;
45 }
46 while(!feof(fin))
47 {
48 if(!fgets(t,BSIZE,fin)) break;
49 str_delete_n(t);
50 fprintf(fout,"#include \"../../pixmaps/%s\"\n",t);
51 }
52 fclose(fin);
53 fclose(fout);
54 return 0;
55 }
56