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