Annotation of OpenXM/src/kan96xx/plugin/cmotagToName.c, Revision 1.1.1.1
1.1 maekawa 1: #include <stdio.h>
2: #include "cmotag.h"
3: #define BSIZE 1024
4:
5: main() {
6: FILE *fp;
7: char s[BSIZE];
8: int i, start;
9: char *a;
10: fp = fopen("cmotag.h","r");
11: if (fp == NULL) {
12: fprintf(stderr,"Inputfile cmotag.h could be found.\n");
13: exit(10);
14: }
15:
16: fprintf(stderr,"cmotagToName.c is generating the function cmotagToName.\n");
17: printf("/* This is automatically generated by cmotagToName.c. DO NOT EDIT.*/\n");
18: printf("static char *cmotagToName(int p) {\n");
19: printf("if (0) { ; \n");
20: while (fgets(s,BSIZE-11,fp) != NULL) {
21: for (i=start=0; i<BSIZE-10; i++) {
22: if (s[i] == '\0') goto aa ;
23: if (s[i] == '#') {
24: s[i+7] = '\0';
25: if (strcmp(&(s[i+1]),"define") != 0) goto aa ;
26: start = i+8;
27: break;
28: }
29: }
30: i = start;
31: while (s[i] <= ' ') {
32: if (s[i] == '\0') goto aa ;
33: i++;
34: }
35: start = i;
36: while (s[i] > ' ') {
37: i++;
38: }
39: s[i] = '\0';
40: /* CMO_XXXX is stored in s[start], ..., s[i]='\0' */
41: a = &(s[start]);
42: /* printf("%s\n",a); */
43: printf("} else if (p == %s) {\n",a);
44: printf(" return(\"%s\");\n",a);
45:
46: aa: ;
47: }
48: printf("} else { return(\"Unknown tag\"); }\n");
49: printf("}\n");
50: exit(0);
51: }
52:
53:
54:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>