[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.4

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

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