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