/* ******************************************************************* * * * Copyright (c) L-DGO/MIT/JGOFS * * * * * * File : list.c * * * * Purpose : * * * * Version Number : 1.1a October 8, 1996 * * Version Number : 1.1 * * * * Revision History : * * * * Date Developer * * ---- --------- * * * * Oct. 8, 1996 Warren Sass * * Change number of char per flatfile output line before new line * * is inserted from 255 to 511 * * Sat Oct 17 1992 10.00 Glenn Flierl * * * * * ******************************************************************* */ #if HP || IBM #define jdbopen_ jdbopen #define jdbreada_ jdbreada #define jdbread_ jdbread #define jdbclose_ jdbclose #define jdbcomments_ jdbcomments #define jdblevel_ jdblevel #define jdbattributes_ jdbattributes #endif #include #ifndef PC #include #define CR 10 #else #define CR 13 #endif #define NVALS 250 #define TOKEN 256 #define ATTRLEN 256 #define VALSIZE 80 char names[NVALS][TOKEN], vals[NVALS][VALSIZE]; int levels[NVALS]; char outline[2048]; int outcount; char blanks[]=" "; int unit,maxlevel,firstpass,num,level; int token=TOKEN; int valsize=VALSIZE; int nflag=1; int fflag=0; int hflag=1; int cflag=1; int fillsize=7; int olen=79; char osep[]=","; FILE *ofile; #ifndef PC void rst_term(); #endif writemln(outline) char *outline; { char ccc; if(outline[strlen(outline)-1] == osep[0])outline[strlen(outline)-1]='\0'; fprintf(ofile,"%s\n",outline); outcount++; if (outcount >= 23 && nflag){ printf("--More--"); #ifdef PC ccc=getch(); #else ccc=getchar(); #endif switch(ccc){ case ' ':printf("\n");outcount=0;break; case CR: #ifdef PC printf("\n"); #endif outcount=22;break; default:printf("\n"); jdbclose_(&unit); #if SUN || ULTRIX if(nflag)system("/bin/stty -cbreak"); #endif #if IRIX || IBM || OSF || SOL || HP if(nflag)system("/bin/stty icanon"); #endif exit(1); }; }; } char *prettyprint(s,ifmt) char *s; int ifmt; { char tmp[81]; if (strlen(s)olen){ writemln(outline); outline[0]='\0'; }; strcat(outline,s); strcat(outline,osep); } outflush() { if(outline[0])writemln(outline); outline[0]='\0'; } writevar(level) int level; { int i,j; char tmp[1024],msg[81]; if(fflag){ if(firstpass){ if(cflag) while(jdbcomments_(&unit,msg)){ strcpy(tmp,"# "); strcat(tmp,msg); strcat(tmp," "); writemln(tmp); }; if(hflag) { for(i=0;i=argc){ printf ("Usage: %s [-n] [-s] [-t] [-f] [-b] [-c] [-z] object [outfile]\n", argv[0]); printf("Options: \n -n nonstop\n -s space-separated\n"); printf(" -t tab-separated\n -f flat file output\n"); printf(" -b brief flat file\n -c no comments\n"); printf(" -z delete extra spaces\n"); exit(1); }; ofile=stdout; while(argv[i][0]=='-') switch(argv[i++][1]){ case 'f': fflag=1; olen=511;break; case 'n': nflag=0; break; case 's': osep[0]=' '; break; case 't': osep[0]='\t'; break; case 'b': fflag=1;hflag=0;cflag=0; olen=511;break; case 'c': cflag=0;break; case 'z': fillsize=0;break; }; strcpy(outline,argv[i]); if(++i < argc){ofile=fopen(argv[i],"w");nflag=0;}; unit=1; num= -NVALS; maxlevel=jdbopen_(&unit,outline,names,&token,&num); if(maxlevel<0){printf("Object not found\n");exit(1);}; /* do levels, attributes & cleanup names*/ for(i=0;i=0) { for(i=0;i