File: addInclude.c

package info (click to toggle)
gabedit 2.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 17,236 kB
  • sloc: ansic: 294,923; cpp: 2,081; sh: 1,111; makefile: 507; csh: 181
file content (55 lines) | stat: -rw-r--r-- 981 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

/**********************************************/
void str_delete_n(char* str)
{
	char *s;

	if(str == NULL)
		return;

	if (!*str)
		return;
	for (s = str + strlen (str) - 1; s >= str && ((unsigned char)*s)=='\n'; s--)
		*s = '\0';
}
#define BSIZE 1024
/**********************************************/
int main(int argc,char* argv[])
{
	FILE* fin;
	FILE* fout;
	char t[BSIZE];
	char* filename = NULL;
	if(argc<2)
	 	filename = strdup("p");
	else
		filename = strdup(argv[1]);

	printf("Input file = %s\n",filename);
	printf("Output file = %s\n","p.c");

	fin = fopen(filename,"r");
	if(!fin)
	{
		printf("I can not open %s\n",filename);
		return 1;
	}
	fout = fopen("p.c","w");
	if(!fout)
	{
		printf("I can not open Fragment.c\n");
		return 1;
	}
	while(!feof(fin))
	{
		if(!fgets(t,BSIZE,fin)) break;
		str_delete_n(t);
 		fprintf(fout,"#include \"../../pixmaps/%s\"\n",t);
	}
	fclose(fin);
	fclose(fout);
	return 0;
}