[BACK]Return to cmotagToName.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / plugin

Annotation of OpenXM/src/kan96xx/plugin/cmotagToName.c, Revision 1.2

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>