[BACK]Return to oxgentexi.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / util

Annotation of OpenXM/src/util/oxgentexi.c, Revision 1.5

1.5     ! takayama    1: /*  $OpenXM: OpenXM/src/util/oxgentexi.c,v 1.4 2005/04/05 13:12:06 takayama Exp $ */
1.1       takayama    2:
                      3: #include <stdio.h>
                      4: int Debug = 0;
                      5: #define VMAX 20
1.2       takayama    6: #define LIMIT   65536
1.1       takayama    7: #define ITEMMAX 1024
                      8: struct item {
                      9:   char *category;  /* base */
                     10:   char *category2;  /* taka_base */
                     11:   char *name;      /* base_replace */
                     12:   int argc;
                     13:   char *argv[VMAX];  /* A and Rule of base_replace(A,Rule) */
                     14:   int optc;
                     15:   char *optv[VMAX];
                     16:   char *shortDescription;
                     17:   char *description;
                     18:   char *algorithm;
                     19:   char *examplev[VMAX];
                     20:   char *exampleDescv[VMAX];
                     21:   int examplec;
                     22:   int refc;
                     23:   char *refv[VMAX];
                     24:   char *author;
1.2       takayama   25:   char *sortKey;
                     26:   int type;
1.1       takayama   27: };
                     28: struct item *getItem(void);
                     29: char *str(char *key);
                     30: char *str2(char *key,int size);
                     31: int cmpItem(struct item *it,struct item *it2);
                     32:
                     33: char *S;
                     34: int Ssize = 256;
                     35: int Sp = 0;
                     36: char *Upnode;
                     37: char *Category=NULL;
                     38: char *Lang="en";
                     39: int Include = 0;
                     40: int GenExample = 0;
1.2       takayama   41: int DebugItem = 0;
1.3       takayama   42: char *Title = NULL;
                     43: char *Author = NULL;
1.4       takayama   44: int NoSorting = 0;
1.1       takayama   45:
                     46: main(int argc,char *argv[]) {
                     47:   char *t;
                     48:   int p,c,n,i;
                     49:   struct item *tt;
                     50:   struct item *items[ITEMMAX];
                     51:
                     52:   Upnode = str("UNKNOWN");
                     53:   for (i=1; i<argc; i++) {
                     54:     if (strcmp(argv[i],"--upnode") == 0) {
                     55:       i++; if (i >= argc) { fprintf(stderr,"--upnode node-name\n"); exit(1);}
                     56:       Upnode = str(argv[i]);
                     57:     }else if (strcmp(argv[i],"--category") == 0) {
                     58:       i++; if (i >= argc) { fprintf(stderr,"--category category-name\n"); exit(1);}
                     59:       Category = str(argv[i]);
                     60:     }else if (strcmp(argv[i],"--en") == 0) {
                     61:       Lang = "en";
                     62:     }else if (strcmp(argv[i],"--ja") == 0) {
                     63:       Lang = "ja";
                     64:     }else if (strcmp(argv[i],"--include") == 0) {
                     65:       Include = 1;
                     66:     }else if (strcmp(argv[i],"--example") == 0) {
                     67:       GenExample = 1;
                     68:     }else if (strcmp(argv[i],"--debug") == 0) {
                     69:       Debug = 1;
1.2       takayama   70:     }else if (strcmp(argv[i],"--debugItem") == 0) {
                     71:       DebugItem = 1;
1.3       takayama   72:     }else if (strcmp(argv[i],"--title") == 0) {
                     73:       i++; Title = str(argv[i]);
                     74:     }else if (strcmp(argv[i],"--author") == 0) {
                     75:       i++; Author = str(argv[i]);
1.4       takayama   76:     }else if (strcmp(argv[i],"--noSorting") == 0) {
                     77:       NoSorting = 1;
1.1       takayama   78:     }else {
                     79:       fprintf(stderr,"Unknown option\n"); exit(1);
                     80:     }
                     81:   }
                     82:   S = (char *)malloc(Ssize);
                     83:   /* Read data from stdin to the string buffer S */
                     84:   while ((c=getchar()) != EOF) {
                     85:     S[Sp++] = c; S[Sp] = 0;
                     86:     if (Sp >= Ssize-3) {
                     87:       Ssize = 2*Ssize;
                     88:       t = S;
                     89:       S = (char *)malloc(Ssize);
                     90:       if (S == NULL) {
                     91:         fprintf(stderr,"No more memory to allocate S.\n");
                     92:         exit(20);
                     93:       }
                     94:       strcpy(S,t);
                     95:     }
                     96:   }
                     97:
                     98:   /* Read items */
                     99:   n = 0;
                    100:   while ((tt = getItem()) != NULL) {
                    101:     if (Debug) printItem(tt);
                    102:     if (n >= ITEMMAX) {
                    103:       fprintf(stderr,"Too many entries.\n"); exit(1);
                    104:     }
                    105:     if (Category != NULL) {
                    106:       if (strcmp(Category,tt->category) == 0 ||
                    107:           strcmp(Category,tt->category2) == 0) {
                    108:         items[n++] = tt;
                    109:       }
                    110:     }else{
                    111:       items[n++] = tt;
                    112:     }
                    113:   }
1.4       takayama  114:
                    115:   if (!NoSorting) {
                    116:     if (Debug) fprintf(stderr,"Sorting...\n");
                    117:     shell(items,n);
                    118:     if (Debug) fprintf(stderr,"Done.\n");
                    119:   }
1.2       takayama  120:
                    121:   if (DebugItem) {
                    122:        for (i=0; i<n; i++) {
                    123:          printItem(items[i]);
                    124:        }
                    125:        exit(0);
                    126:   }
                    127:
1.3       takayama  128:   if (Title) printTitlePage(Title,Author);
                    129:
1.1       takayama  130:   printMenu(stdout,items,n);
                    131:
                    132:   for (i=0; i<n; i++) {
                    133:     printTexi(stdout,items[i]);
                    134:   }
1.3       takayama  135:
                    136:   if (Title) printBye();
1.1       takayama  137:   exit(0);
                    138: }
                    139:
                    140: genInclude(char *name) {
                    141:   char fname[4098];
                    142:   FILE *fp;
                    143:   int c;
                    144:
                    145:   sprintf(fname,"tmp/%s-auto-%s.texi",name,Lang);
                    146:   fp = fopen(fname,"r");
                    147:   if (fp == NULL) {
                    148:     /* fprintf(stderr,"No file %s\n",fname); */
                    149:     return 0;
                    150:   }
                    151:   while ((c=fgetc(fp)) != EOF) {
                    152:     putchar(c);
                    153:   }
                    154:   putchar('\n');
                    155:   fclose(fp);
                    156:   return 0;
                    157: }
                    158:
                    159: cmpItem(struct item *it,struct item *it2) {
1.2       takayama  160:   return strcmp(it->sortKey,it2->sortKey);
1.1       takayama  161: }
                    162: struct item * newItem(){
                    163:   struct item *a;
                    164:   a = (struct item *)malloc(sizeof(struct item));
                    165:   if (a == NULL) {
                    166:     fprintf(stderr,"newItem: No more memory.\n");
                    167:     exit(20);
                    168:   }
                    169:   a->argc = 0; a->optc = 0; a->refc=0; a->examplec = 0;
1.2       takayama  170:   a->type=0;
1.1       takayama  171:   a->category = a->category2 = a->name = a->shortDescription
1.2       takayama  172:     = a->description = a->author = a->algorithm = a->sortKey = NULL;
1.1       takayama  173:   return a;
                    174: }
                    175:
                    176: nextToken(char *key,int n) {
                    177:   static int pos = 0;
                    178:   int i = 0;
                    179:   if (pos >= Ssize) return -1;
                    180:   while (S[pos] <= ' ') {
                    181:     pos++;
                    182:     if (pos >= Ssize) return -1;
                    183:   }
                    184:   while (S[pos] > ' ') {
                    185:     key[i++] = S[pos++]; key[i] = 0;
                    186:     if (i >= n-1) {
                    187:       fprintf(stderr,"Too big key word.\n");
                    188:       fprintf(stderr,"key=%s\n",key);
                    189:       exit(10);
                    190:     }
                    191:     if (S[pos-1] == '(' ||
                    192:         S[pos-1] == ')' ||
                    193:         S[pos-1] == ',' ||
                    194:         S[pos-1] == '{' ||
                    195:         S[pos-1] == '}' ||
                    196:         S[pos-1] == '|' ) {
                    197:       return pos;
                    198:     }
                    199:     if (S[pos] == '(' ||
                    200:         S[pos] == ')' ||
                    201:         S[pos] == ',' ||
                    202:         S[pos] == '{' ||
                    203:         S[pos] == '}' ||
                    204:         S[pos] == '|' ) {
                    205:       return pos;
                    206:     }
                    207:
                    208:   }
                    209:   if (Debug) fprintf(stderr,"token=%s\n",key);
                    210:   return pos;
                    211: }
                    212:
                    213: printItem(struct item *it) {
                    214:   int i;
                    215:   if (it == NULL) return;
                    216:   if (it->category != NULL)
                    217:     printf("category=%s\n",it->category);
                    218:   if (it->category2 != NULL)
                    219:     printf("category2=%s\n",it->category2);
                    220:   if (it->name != NULL)
                    221:     printf("name=%s\n",it->name);
                    222:   for (i=0; i<it->argc; i++)
                    223:     printf("  argv[%d]=%s\n",i,it->argv[i]);
                    224:   for (i=0; i<it->optc; i++)
                    225:     printf("  optv[%d]=%s\n",i,it->optv[i]);
                    226:   if (it->shortDescription != NULL)
                    227:     printf("shortDescription=%s\n",it->shortDescription);
                    228:   if (it->description != NULL)
                    229:     printf("description=%s\n",it->description);
                    230:   if (it->algorithm != NULL)
                    231:     printf("algorithm=%s\n",it->algorithm);
                    232:   for (i=0; i <it->examplec; i++)
                    233:     printf("examplev[%d]=%s\n",i,it->examplev[i]);
                    234:   for (i=0; i <it->examplec; i++)
                    235:     printf("exampleDescv[%d]=%s\n",i,it->exampleDescv[i]);
                    236:   for (i=0; i<it->refc; i++)
                    237:     printf("  refv[%d]=%s\n",i,it->refv[i]);
                    238:   if (it->author != NULL)
                    239:     printf("author=%s\n",it->author);
1.2       takayama  240:   if (it->sortKey != NULL)
                    241:     printf("sortKey=%s\n",it->sortKey);
1.1       takayama  242:   printf("\n");
                    243: }
                    244:
                    245: char *str(char *key) {
                    246:   char *s;
                    247:   s = (char *)malloc(strlen(key)+1);
                    248:   if (s == NULL) {
                    249:     fprintf(stderr,"str: No more memory.\n");
                    250:     exit(20);
                    251:   }
                    252:   strcpy(s,key);
                    253:   return s;
                    254: }
                    255: char *str2(char *key,int size) {
                    256:   char *s;
                    257:   int i;
                    258:   s = (char *)malloc(size+1);
                    259:   if (s == NULL) {
                    260:     fprintf(stderr,"str2: No more memory.\n");
                    261:     exit(20);
                    262:   }
                    263:   for (i=0; i<size; i++) {
                    264:     s[i] = key[i]; s[i+1] = 0;
                    265:   }
                    266:   return s;
                    267: }
                    268: char *getCategory(char *key) {
                    269:   int i,n;
                    270:   char *s;
                    271:   s = str(key);
                    272:   for (i=0; i<strlen(s); i++) {
                    273:     if ((s[i] == '_') || s[i] == '.') {
                    274:       s[i] = 0;
                    275:       return s;
                    276:     }
                    277:   }
                    278:   return s;
                    279: }
                    280: char *getCategory2(char *key) {
                    281:   int i,n;
                    282:   char *s;
                    283:   int count;
                    284:   s = str(key);
                    285:   for (i=0; i<strlen(s); i++) {
                    286:     if ((s[i] == '_') || (s[i] == '.')) count++;
                    287:     if (count == 2) {
                    288:       s[i] = 0; return s;
                    289:     }
                    290:   }
                    291:   return s;
                    292: }
                    293:
                    294:
                    295: struct item *getItem() {
                    296:   char key[LIMIT];
                    297:   char key2[LIMIT];
                    298:   struct item *it;
                    299:   int p;
                    300:   int pp,pOld;
                    301:   int argc;
                    302:   int examplec = 0;
                    303:   it = newItem();
                    304:   do {
                    305:     p = nextToken(key,LIMIT);
                    306:     /* printf("%s\n",key); */
                    307:     if (strcmp(key,"begin:") == 0) break;
                    308:   }while (p >= 0);
                    309:   if (p < 0) {
                    310:     /* fprintf(stderr,"gentexi: End of input file.\n"); */
                    311:     return NULL;
                    312:   }
                    313:   p = nextToken(key,LIMIT);
1.2       takayama  314:   it->name = it->sortKey = str(key);
1.1       takayama  315:   it->category = getCategory(key);
                    316:   it->category2 = getCategory2(key);
                    317:   nextToken(key,LIMIT);
                    318:   if (strcmp(key,"(") != 0) {
1.2       takayama  319:     pp = p+1;
                    320:     it->type = 1; /* For non-functions */
1.3       takayama  321:     goto LL ;
1.2       takayama  322:   }else{
                    323:     it->type = 0; /* For functions */
                    324:     argc = 0;
                    325:     while ((pp=nextToken(key,LIMIT)) >= 0) {
                    326:       if (strcmp(key,"|") == 0) {
                    327:         /* options */
                    328:         argc = 0;
                    329:         while ((pp=nextToken(key,LIMIT)) >= 0) {
                    330:           if (strcmp(key,")") == 0) {
                    331:             break;
                    332:           }
                    333:           if (strcmp(key,",") != 0) {
                    334:             it->optv[argc] = str(key);
                    335:             argc++; it->optc = argc;
                    336:           }
                    337:           if (argc >+ VMAX -1) {
                    338:             fprintf(stderr,"Too many opt args at %s\n",it->name);
                    339:             exit(10);
                    340:           }
1.1       takayama  341:         }
                    342:       }
1.2       takayama  343:       if (strcmp(key,")") == 0) {
                    344:         break;
                    345:       }else if (strcmp(key,",") != 0) {
                    346:         it->argv[argc] = str(key);
                    347:         argc++; it->argc=argc;
                    348:       }
                    349:       if (argc >= VMAX-1) {
                    350:         fprintf(stderr,"Too many args at %s\n",it->name);
                    351:         exit(10);
                    352:       }
1.1       takayama  353:     }
                    354:   }
                    355:
                    356:   /* Getting the short Description */
                    357:   p = pp;
                    358:   do {
                    359:     pOld = p;
                    360:     p = nextToken(key,LIMIT);
                    361:     /* printf("%s\n",key); */
                    362:     if (key[strlen(key)-1] == ':') break; /* Next keyword. */
                    363:   }while (p >= 0);
                    364:   it->shortDescription = str2(&(S[pp]),pOld-pp);
                    365:
1.3       takayama  366:  LL: ;
                    367:   if (it->type == 1 ) {strcpy(key,"description:"); p++; }
1.1       takayama  368:   do {
                    369:     /* Get Description or Examples */
                    370:     if (strcmp(key,"end:") == 0) break;
                    371:     if (strcmp(key,"description:") == 0 ||
                    372:         strcmp(key,"algorithm:") == 0 ||
                    373:         strcmp(key,"author:") == 0 ||
1.2       takayama  374:         strcmp(key,"sortKey:") == 0 ||
1.1       takayama  375:         strcmp(key,"example:") == 0 ||
1.2       takayama  376:         strcmp(key,"example_description:") ==0 ) {
1.1       takayama  377:       pp = p;
                    378:       strcpy(key2,key);
                    379:       do {
                    380:         pOld = p;
                    381:         p = nextToken(key,LIMIT);
1.5     ! takayama  382:         /* printf("key=%s\n",key); */
        !           383:         if (key[strlen(key)-1] == ':') {
        !           384:           pOld = p-strlen(key);
        !           385:           break; /* Next keyword. */
        !           386:         }
1.1       takayama  387:       }while (p >= 0);
                    388:       if (strcmp(key2,"description:") == 0) {
                    389:         it->description = str2(&(S[pp]),pOld-pp);
                    390:       }
                    391:       if (strcmp(key2,"example:") == 0) {
                    392:         it->examplev[examplec++] = str2(&(S[pp]),pOld-pp);
                    393:         it->exampleDescv[examplec-1] = "";
                    394:         it->examplec = examplec;
                    395:         if (examplec > VMAX-1) {
                    396:           fprintf(stderr,"Too many examples. \n");
                    397:           exit(20);
                    398:         }
                    399:       }
                    400:       if (strcmp(key2,"example_description:") == 0) {
                    401:         it->exampleDescv[examplec-1] = str2(&(S[pp]),pOld-pp);
                    402:       }
                    403:       if (strcmp(key2,"author:") == 0) {
                    404:         it->author = str2(&(S[pp]),pOld-pp);
                    405:       }
1.2       takayama  406:       if (strcmp(key2,"sortKey:") == 0) {
                    407:                while (S[pp] <= ' ') pp++;
                    408:         it->sortKey = str2(&(S[pp]),pOld-pp);
                    409:       }
1.1       takayama  410:       if (strcmp(key2,"algorithm:") == 0) {
                    411:         it->algorithm = str2(&(S[pp]),pOld-pp);
                    412:       }
                    413:     }else if (strcmp(key,"ref:") == 0) {
                    414:       argc = 0;
                    415:       while ((pp=nextToken(key,LIMIT)) >= 0) {
                    416:         p = pp;
                    417:         if (key[strlen(key)-1] == ':') break;
                    418:         if (strcmp(key,",") != 0) {
                    419:           it->refv[argc] = str(key);
                    420:           argc++; it->refc = argc;
                    421:         }
                    422:         if (argc >= VMAX-1) {
                    423:           fprintf(stderr,"Too many args for Ref at %s\n",it->name);
                    424:           exit(10);
                    425:         }
                    426:       }
                    427:     }else{
                    428:       fprintf(stderr,"Warning: unknown keyword << %s >> at %s. Ignored.\n",key, it->name);
                    429:       p = nextToken(key,LIMIT);
                    430:     }
                    431:   }while (p >= 0);
                    432:
                    433:   return it;
                    434: }
                    435:
                    436: shell(struct item *v[],int n) {
                    437:   int gap,i,j;
                    438:   struct item *temp;
                    439:
                    440:   for (gap = n/2; gap > 0; gap /= 2) {
                    441:     for (i = gap; i<n; i++) {
                    442:       for (j=i-gap ; j>=0 && cmpItem(v[j],v[j+gap])>0 ; j -= gap) {
                    443:         temp = v[j];
                    444:         v[j] = v[j+gap];
                    445:         v[j+gap] = temp;
                    446:       }
                    447:     }
                    448:   }
                    449: }
                    450:
                    451: printMenu(FILE *fp, struct item **it, int n) {
1.2       takayama  452:   int i,m;
1.1       takayama  453:
1.2       takayama  454:   m = 0;
1.1       takayama  455:   for ( i = 0; i < n; i++ )
1.2       takayama  456:     if (it[i]->type != 1) m++;
                    457:   if (m != 0) {
                    458:     fprintf(fp,"@menu\n");
                    459:     for ( i = 0; i < n; i++ )
                    460:       if (it[i]->type != 1) fprintf(fp,"* %s::\n",it[i]->name);
                    461:     fprintf(fp,"@end menu\n");
                    462:   }
1.1       takayama  463: }
                    464:
                    465: printTexi(FILE *fp, struct item *it) {
                    466:   int i;
1.2       takayama  467:   if (it->type == 1) return printTexi1(fp,it);
                    468:   else return printTexi0(fp,it);
                    469: }
                    470:
                    471: printTexi_common(FILE *fp,struct item *it) {
                    472:   int i;
                    473:   if (it->description != NULL) {
                    474:     fprintf(fp,"%s\n\n",it->description);
                    475:   }
                    476:
                    477:   if (it->algorithm != NULL) {
                    478:     fprintf(fp,"\n\n@noindent\nAlgorithm: \n");
                    479:     fprintf(fp,"%s\n\n",it->algorithm);
                    480:   }
                    481:
                    482:   if (it->examplec > 0) {
                    483:     for (i=0; i<it->examplec; i++) {
                    484:       if (it->examplec == 1) {
                    485:         fprintf(fp,"Example:\n");
                    486:       }else{
                    487:         fprintf(fp,"Example %d:\n",i);
                    488:       }
                    489:       fprintf(fp,"@example\n");
1.3       takayama  490:       outputExample(fp,it->examplev[i]);
1.2       takayama  491:       if (GenExample) {
                    492:         outputOfExample(it->examplev[i]);
                    493:       }
                    494:       fprintf(fp,"@end example\n");
                    495:       if (it->exampleDescv[i] != NULL && strlen(it->exampleDescv[i]) > 0) {
                    496:         fprintf(fp,"%s\n\n",it->exampleDescv[i]);
                    497:       }
                    498:     }
                    499:   }
                    500:   if (it->author != NULL) {
                    501:     fprintf(fp,"Author : %s\n\n",it->author);
                    502:   }
                    503:   if (it->refc > 0) {
                    504:     fprintf(fp,"@table @t\n");
                    505:     fprintf(fp,"@item References\n");
                    506:     for (i=0; i <it->refc; i++) {
                    507:       fprintf(fp,"@code{%s} ",it->refv[i]);
                    508:       if (i != it->refc-1) fprintf(fp,", ");
                    509:     }
                    510:     fprintf(fp,"\n@end table\n");
                    511:   }
                    512:   fprintf(fp,"\n");
                    513: }
                    514:
                    515: printTexi0(FILE *fp, struct item *it) {
                    516:   int i;
                    517:
1.5     ! takayama  518:   fprintf(fp,"@c DO NOT EDIT THIS FILE. Generated by gentexi for asir function item.\n");
1.1       takayama  519:   if (it == NULL) {
                    520:     fprintf(fp,"@c item is NULL.\n");
                    521:     return ;
                    522:   }
1.3       takayama  523:   fprintf(fp,"@c sortKey: %s\n",it->sortKey);
1.1       takayama  524:   if (it->name == NULL) {
                    525:     fprintf(fp,"@c item name is missing.\n");
                    526:     return ;
                    527:   }
                    528:
                    529: #if 0
                    530:   fprintf(fp,"@menu\n");
                    531:   fprintf(fp,"* %s::\n",it->name);
                    532:   fprintf(fp,"@end menu\n");
                    533: #endif
                    534:   fprintf(fp,"@node %s,,, %s\n",it->name,Upnode);
                    535:   fprintf(fp,"@subsection @code{%s}\n",it->name);
                    536:   fprintf(fp,"@findex %s\n",it->name);
                    537:   fprintf(fp,"@table @t\n");
                    538:   fprintf(fp,"@item %s(",it->name);
                    539:   for (i=0; i<it->argc; i++) {
                    540:     fprintf(fp,"@var{%s}",it->argv[i]);
                    541:     if (i != it->argc-1) fprintf(fp,",");
                    542:   }
                    543:   fprintf(fp,")\n");
                    544:   if (it->shortDescription != NULL) {
                    545:     fprintf(fp,": ");
                    546:     for (i=0; i<strlen(it->shortDescription); i++) {
                    547:       if (it->shortDescription[i] == '{') {
                    548:         fprintf(fp,"@var{");
                    549:       }else {
                    550:         fprintf(fp,"%c",it->shortDescription[i]);
                    551:       }
                    552:     }
                    553:     fprintf(fp," \n");
                    554:   }
                    555:   if (it->optc > 0) {
                    556:     fprintf(fp,"@item %s(",it->name);
                    557:     for (i=0; i<it->argc; i++) {
                    558:       fprintf(fp,"@var{%s}",it->argv[i]);
                    559:       if (i != it->argc-1) fprintf(fp,",");
                    560:     }
                    561:     fprintf(fp," | ");
                    562:     for (i=0; i<it->optc; i++) {
                    563:       fprintf(fp,"@var{%s}=key%d",it->optv[i],i);
                    564:       if (i != it->optc-1) fprintf(fp,",");
                    565:     }
                    566:     fprintf(fp,")\n");
                    567:     fprintf(fp,": This function allows optional variables \n  ");
                    568:     for (i=0; i<it->optc; i++) {
                    569:       fprintf(fp,"@var{%s}",it->optv[i]);
                    570:       if (i != it->optc-1) fprintf(fp,", ");
                    571:     }
                    572:     fprintf(fp,"\n");
                    573:   }
                    574:   fprintf(fp,"@end table\n");
                    575:
                    576:   /* include file */
                    577:   if (Include) {
                    578:     if (genInclude(it->name))
                    579:       fprintf(fp,"@c @include tmp/%s-auto-en.texi\n",it->name);
                    580:   }
                    581:   fprintf(fp,"@c @itemize @bullet \n");
                    582:   fprintf(fp,"@c @item \n");
                    583:   fprintf(fp,"@c @end itemize\n");
                    584:
1.2       takayama  585:   printTexi_common(fp,it);
                    586: }
                    587:
                    588: printTexi1(FILE *fp, struct item *it) {
                    589:   int i;
                    590:   /* For  it->type == 1 */
                    591:
1.5     ! takayama  592:   fprintf(fp,"@c DO NOT EDIT THIS FILE. Generated by gentexi for verbose item.\n");
1.2       takayama  593:   if (it == NULL) {
                    594:     fprintf(fp,"@c item is NULL.\n");
                    595:     return ;
1.1       takayama  596:   }
1.3       takayama  597:   fprintf(fp,"@c sortKey: %s\n",it->sortKey);
1.1       takayama  598:
1.2       takayama  599:   if (it->shortDescription != NULL) {
                    600:     for (i=0; i<strlen(it->shortDescription); i++) {
                    601:       fprintf(fp,"%c",it->shortDescription[i]);
1.1       takayama  602:     }
1.2       takayama  603:     fprintf(fp," \n");
1.1       takayama  604:   }
1.2       takayama  605:
                    606:   /* include file */
                    607:   if (Include) {
                    608:     if (genInclude(it->name))
                    609:       fprintf(fp,"@c @include tmp/%s-auto-en.texi\n",it->name);
1.1       takayama  610:   }
1.2       takayama  611:
                    612:   printTexi_common(fp,it);
1.1       takayama  613: }
                    614:
1.3       takayama  615: outputExample(FILE *fp,char *s) {
                    616:   int i;
                    617:   for (i=0; s[i] != 0; i++) {
1.4       takayama  618:        if (s[i] == '@') {
                    619:          if (s[i+1] == '{') {fprintf(fp,"%s","@{"); i += 1;}
                    620:          else if (s[i+1] == '}') {fprintf(fp,"%s","@}"); i += 1;}
                    621:          else if (s[i+1] == '@') {fprintf(fp,"%s","@@"); i += 1;}
                    622:          else if (strncmp(&(s[i+1]),"colon",5)==0) {
                    623:                fprintf(fp,":"); i += 5;
                    624:          }else fprintf(fp,"@@");
                    625:     }else{
                    626:          fputc(s[i],fp);
                    627:     }
1.3       takayama  628:   }
                    629: }
                    630:
1.1       takayama  631: outputOfExample(char *com) {
                    632:   FILE *fp2;
                    633:   int c;
                    634:   fp2 = fopen("gentexi-in.tmp","w");
                    635:   if (fp2 == NULL) {
                    636:     fprintf(stderr,"Cannot open tentexi-in.tmp\n");
                    637:     exit(10);
                    638:   }
                    639:   system("rm -f gentexi-out.tmp");
                    640:   fprintf(fp2,"output(\"gentexi-out.tmp\")$\n");
                    641:   fprintf(fp2,"%s\n",com);
                    642:   fprintf(fp2,"output()$\n");
                    643:   fprintf(fp2,"quit;");
                    644:   fclose(fp2);
                    645:   system("asir <gentexi-in.tmp >/dev/null");
                    646:
                    647:   fp2 = fopen("gentexi-out.tmp","r");
                    648:   if (fp2 == NULL) {
                    649:     fprintf(stderr,"Cannot open tentexi-in.tmp\n");
                    650:     exit(10);
                    651:   }
                    652:   while ((c=fgetc(fp2)) != EOF) {
                    653:     putchar(c);
                    654:   }
                    655:   putchar('\n');
                    656: }
                    657:
1.3       takayama  658: printTitlePage(char *title, char *author) {
                    659:   printf("\\input texinfo\n");
                    660:   printf("@def@colon{:}\n\n");
                    661:   printf("@iftex\n");
                    662:   printf("@catcode`@#=6\n");
                    663:   printf("@def@b#1{{@bf@gt #1}}\n");
                    664:   printf("@catcode`@#=@other\n");
                    665:   printf("@end iftex\n");
                    666:   printf("@overfullrule=0pt\n");
                    667:
                    668:   printf("@setfilename %s\n",Title);
                    669:   printf("@settitle %s\n",Title);
                    670:
                    671:   printf("@titlepage\n");
                    672:   printf("@title %s\n",Title);
                    673:   printf("@subtitle Edition : auto generated by oxgentexi on @today{}\n");
                    674:   if (author != NULL) printf("@author %s\n",author);
                    675:   printf("@end titlepage\n\n");
                    676:   printf("@synindex vr fn\n");
                    677:   printf("@node Top,, (dir), (dir)\n\n");
                    678: }
                    679:
                    680: printBye() {
                    681:   printf("\n@bye\n");
                    682: }
1.1       takayama  683: /* Old file was OpenXM/src/asir-contrib/packages/doc/gentexi.c */

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