version 1.2, 2002/01/27 08:18:52 |
version 1.5, 2002/08/23 03:26:16 |
|
|
/* $OpenXM: OpenXM/src/asir-contrib/packages/doc/gentexi.c,v 1.1 2002/01/27 07:13:28 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/asir-contrib/packages/doc/gentexi.c,v 1.4 2002/08/08 08:56:32 takayama Exp $ */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
int Debug = 0; |
int Debug = 0; |
|
|
char *optv[VMAX]; |
char *optv[VMAX]; |
char *shortDescription; |
char *shortDescription; |
char *description; |
char *description; |
|
char *algorithm; |
char *examplev[VMAX]; |
char *examplev[VMAX]; |
|
char *exampleDescv[VMAX]; |
int examplec; |
int examplec; |
int refc; |
int refc; |
char *refv[VMAX]; |
char *refv[VMAX]; |
|
char *author; |
}; |
}; |
struct item *getItem(void); |
struct item *getItem(void); |
char *str(char *key); |
char *str(char *key); |
Line 98 main(int argc,char *argv[]) { |
|
Line 101 main(int argc,char *argv[]) { |
|
shell(items,n); |
shell(items,n); |
if (Debug) fprintf(stderr,"Done.\n"); |
if (Debug) fprintf(stderr,"Done.\n"); |
|
|
|
printMenu(stdout,items,n); |
|
|
for (i=0; i<n; i++) { |
for (i=0; i<n; i++) { |
printTexi(stdout,items[i]); |
printTexi(stdout,items[i]); |
} |
} |
Line 135 struct item * newItem(){ |
|
Line 140 struct item * newItem(){ |
|
} |
} |
a->argc = 0; a->optc = 0; a->refc=0; a->examplec = 0; |
a->argc = 0; a->optc = 0; a->refc=0; a->examplec = 0; |
a->category = a->category2 = a->name = a->shortDescription |
a->category = a->category2 = a->name = a->shortDescription |
= a->description = NULL; |
= a->description = a->author = a->algorithm = NULL; |
return a; |
return a; |
} |
} |
|
|
Line 193 printItem(struct item *it) { |
|
Line 198 printItem(struct item *it) { |
|
printf("shortDescription=%s\n",it->shortDescription); |
printf("shortDescription=%s\n",it->shortDescription); |
if (it->description != NULL) |
if (it->description != NULL) |
printf("description=%s\n",it->description); |
printf("description=%s\n",it->description); |
|
if (it->algorithm != NULL) |
|
printf("algorithm=%s\n",it->algorithm); |
for (i=0; i <it->examplec; i++) |
for (i=0; i <it->examplec; i++) |
printf("examplev[%d]=%s\n",i,it->examplev[i]); |
printf("examplev[%d]=%s\n",i,it->examplev[i]); |
|
for (i=0; i <it->examplec; i++) |
|
printf("exampleDescv[%d]=%s\n",i,it->exampleDescv[i]); |
for (i=0; i<it->refc; i++) |
for (i=0; i<it->refc; i++) |
printf(" refv[%d]=%s\n",i,it->refv[i]); |
printf(" refv[%d]=%s\n",i,it->refv[i]); |
|
if (it->author != NULL) |
|
printf("author=%s\n",it->author); |
printf("\n"); |
printf("\n"); |
} |
} |
|
|
Line 323 struct item *getItem() { |
|
Line 334 struct item *getItem() { |
|
/* Get Description or Examples */ |
/* Get Description or Examples */ |
if (strcmp(key,"end:") == 0) break; |
if (strcmp(key,"end:") == 0) break; |
if (strcmp(key,"description:") == 0 || |
if (strcmp(key,"description:") == 0 || |
strcmp(key,"example:") == 0) { |
strcmp(key,"algorithm:") == 0 || |
|
strcmp(key,"author:") == 0 || |
|
strcmp(key,"example:") == 0 || |
|
strcmp(key,"example_description:") ==0 ) { |
pp = p; |
pp = p; |
strcpy(key2,key); |
strcpy(key2,key); |
do { |
do { |
Line 337 struct item *getItem() { |
|
Line 351 struct item *getItem() { |
|
} |
} |
if (strcmp(key2,"example:") == 0) { |
if (strcmp(key2,"example:") == 0) { |
it->examplev[examplec++] = str2(&(S[pp]),pOld-pp); |
it->examplev[examplec++] = str2(&(S[pp]),pOld-pp); |
|
it->exampleDescv[examplec-1] = ""; |
it->examplec = examplec; |
it->examplec = examplec; |
if (examplec > VMAX-1) { |
if (examplec > VMAX-1) { |
fprintf(stderr,"Too many examples. \n"); |
fprintf(stderr,"Too many examples. \n"); |
exit(20); |
exit(20); |
} |
} |
} |
} |
|
if (strcmp(key2,"example_description:") == 0) { |
|
it->exampleDescv[examplec-1] = str2(&(S[pp]),pOld-pp); |
|
} |
|
if (strcmp(key2,"author:") == 0) { |
|
it->author = str2(&(S[pp]),pOld-pp); |
|
} |
|
if (strcmp(key2,"algorithm:") == 0) { |
|
it->algorithm = str2(&(S[pp]),pOld-pp); |
|
} |
}else if (strcmp(key,"ref:") == 0) { |
}else if (strcmp(key,"ref:") == 0) { |
argc = 0; |
argc = 0; |
while ((pp=nextToken(key,LIMIT)) >= 0) { |
while ((pp=nextToken(key,LIMIT)) >= 0) { |
Line 358 struct item *getItem() { |
|
Line 382 struct item *getItem() { |
|
} |
} |
} |
} |
}else{ |
}else{ |
fprintf(stderr,"Unknown keyword at %s\n",it->name); |
fprintf(stderr,"Unknown keyword << %s >> at %s\n",key, it->name); |
exit(10); |
exit(10); |
} |
} |
}while (p >= 0); |
}while (p >= 0); |
Line 381 shell(struct item *v[],int n) { |
|
Line 405 shell(struct item *v[],int n) { |
|
} |
} |
} |
} |
|
|
|
printMenu(FILE *fp, struct item **it, int n) { |
|
int i; |
|
|
|
fprintf(fp,"@menu\n"); |
|
for ( i = 0; i < n; i++ ) |
|
fprintf(fp,"* %s::\n",it[i]->name); |
|
fprintf(fp,"@end menu\n"); |
|
} |
|
|
printTexi(FILE *fp, struct item *it) { |
printTexi(FILE *fp, struct item *it) { |
int i; |
int i; |
fprintf(fp,"@c DO NOT EDIT THIS FILE. Generated by gentexi.\n"); |
fprintf(fp,"@c DO NOT EDIT THIS FILE. Generated by gentexi.\n"); |
Line 393 printTexi(FILE *fp, struct item *it) { |
|
Line 426 printTexi(FILE *fp, struct item *it) { |
|
return ; |
return ; |
} |
} |
|
|
|
#if 0 |
fprintf(fp,"@menu\n"); |
fprintf(fp,"@menu\n"); |
fprintf(fp,"* %s\n",it->name); |
fprintf(fp,"* %s::\n",it->name); |
fprintf(fp,"@end menu\n"); |
fprintf(fp,"@end menu\n"); |
|
#endif |
fprintf(fp,"@node %s,,, %s\n",it->name,Upnode); |
fprintf(fp,"@node %s,,, %s\n",it->name,Upnode); |
fprintf(fp,"@subsection @code{%s}\n",it->name); |
fprintf(fp,"@subsection @code{%s}\n",it->name); |
fprintf(fp,"@findex %s\n",it->name); |
fprintf(fp,"@findex %s\n",it->name); |
Line 447 printTexi(FILE *fp, struct item *it) { |
|
Line 482 printTexi(FILE *fp, struct item *it) { |
|
fprintf(fp,"@c @item \n"); |
fprintf(fp,"@c @item \n"); |
fprintf(fp,"@c @end itemize\n"); |
fprintf(fp,"@c @end itemize\n"); |
|
|
|
if (it->description != NULL) { |
|
fprintf(fp,"%s\n\n",it->description); |
|
} |
|
|
|
if (it->algorithm != NULL) { |
|
fprintf(fp,"\n\n@noindent\nAlgorithm: \n"); |
|
fprintf(fp,"%s\n\n",it->algorithm); |
|
} |
|
|
if (it->examplec > 0) { |
if (it->examplec > 0) { |
for (i=0; i<it->examplec; i++) { |
for (i=0; i<it->examplec; i++) { |
|
if (it->examplec == 1) { |
|
fprintf(fp,"Example:\n"); |
|
}else{ |
|
fprintf(fp,"Example %d:\n",i); |
|
} |
fprintf(fp,"@example\n"); |
fprintf(fp,"@example\n"); |
fprintf(fp,"%s\n",it->examplev[i]); |
fprintf(fp,"%s\n",it->examplev[i]); |
if (GenExample) { |
if (GenExample) { |
outputOfExample(it->examplev[i]); |
outputOfExample(it->examplev[i]); |
} |
} |
fprintf(fp,"@end example\n"); |
fprintf(fp,"@end example\n"); |
|
if (it->exampleDescv[i] != NULL && strlen(it->exampleDescv[i]) > 0) { |
|
fprintf(fp,"%s\n\n",it->exampleDescv[i]); |
|
} |
} |
} |
|
} |
|
if (it->author != NULL) { |
|
fprintf(fp,"Author : %s\n\n",it->author); |
} |
} |
if (it->refc > 0) { |
if (it->refc > 0) { |
fprintf(fp,"@table @t\n"); |
fprintf(fp,"@table @t\n"); |