File: createH.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 (40 lines) | stat: -rw-r--r-- 873 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
#include<stdlib.h>
#include<stdio.h>
#include<string.h>

/**********************************************/
int main(int argc,char* argv[])
{
	FILE* p1;
	FILE* p2;
	char* filename = NULL;
	char* p1name = "p1";
	char* p2name = "p2";
	int i;
	if(argc<2)
	{
	 	printf("vous devez fournir un nom de fichier\n");
		return 1;
	}
	else filename = strdup(argv[1]);
	for(i=0;i<strlen(filename);i++)
		filename[i] = toupper(filename[i]);
	for(i=0;i<strlen(filename);i++)
		if(filename[i]=='.')filename[i]='_';

	printf("Header name %s\n",filename);

	p1 = fopen(p1name,"w");
	p2 = fopen(p2name,"w");
	if(!p1 || !p2)
	{
		printf("I can not open %s or %s\n",p1name, p2name);
		return 1;
	}
	fprintf(p1,"#ifndef __GABEDIT_%s__\n", filename);
	fprintf(p1,"#define __GABEDIT_%s__\n", filename);
	fprintf(p2,"#endif /* __GABEDIT_%s__ */\n", filename);
	fclose(p1);
	fclose(p2);
	return 0;
}