File: mkfuncno.c

package info (click to toggle)
fdclone 3.01b-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 4,772 kB
  • ctags: 8,674
  • sloc: ansic: 100,552; makefile: 4,497; sh: 1,480; sed: 224
file content (52 lines) | stat: -rw-r--r-- 1,069 bytes parent folder | download | duplicates (2)
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
/*
 *	mkfuncno.c
 *
 *	preprocesser for "funcno.h"
 */

#define	__FD_PRIMAL__
#include "fd.h"
#include "types.h"
#ifdef	_NOCATALOG
#define	_TBL_(fn, id, hl, fl)	{NULL, id, NULL, 0}
#else
#define	_TBL_(fn, id, hl, fl)	{NULL, id, 0, 0}
#endif
#include "functabl.h"

int main __P_((int, char *CONST []));


/*ARGSUSED*/
int main(argc, argv)
int argc;
char *CONST argv[];
{
	FILE *fp;
	int i, len;

	if (!strcmp(argv[1], "-")) fp = stdout;
	else if (!(fp = fopen(argv[1], "w"))) {
		fprintf(stderr, "%s: Cannot open.\n", argv[1]);
		return(1);
	}

	fprintf(fp, "/*\n");
	fprintf(fp, " *\t%s\n", (fp != stdout) ? argv[1] : "STDOUT");
	fprintf(fp, " *\n");
	fprintf(fp, " *\tfunction No. table\n");
	fprintf(fp, " */\n");
	fprintf(fp, "\n");

	for (i = 0; i < (int)sizeof(funclist) / sizeof(functable); i++) {
		fprintf(fp, "#define\t%s\t", funclist[i].ident);
		len = strlen(funclist[i].ident);
		while ((len += 8) < 16) fputc('\t', fp);
		fprintf(fp, "\t%d\n", i);
	}
	fprintf(fp, "\n#define\tFUNCLISTSIZ\t\t%d\n", i);

	if (fp != stdout) VOID_C fclose(fp);

	return(0);
}