int main(int argc, char **argv) { param params; int command=0; char tmpfileNm[80]; inFile = stdin; outFile = stdout; tmpnam(tmpfileNm); outFile = fopen(tmpfileNm,"w"); if (argc > 1) { inFile = fopen(argv[1],"r"); if (inFile == NULL) { fprintf(stderr,"Couldn't open input file %s\n",argv[1]); exit(0); } } line[0]=0; fgets(line,LineLen,inFile); InputLine++; fprintf(outFile,"%% picture environment flowchart generated by flow "); fprintf(outFile,"%s\n",VERSION); while (command != -1) { command = getCommand(line,params); if (command != -1) if (!doCommand(command, params)) return 10; } fclose(inFile); fclose(outFile); outFile = stdout; if (argc > 2) { outFile = fopen(argv[2],"w"); if (outFile == NULL) { fprintf(stderr,"Couldn't open output file %s\n",argv[2]); fclose(inFile); exit(0); } } inFile = fopen(tmpfileNm,"r"); applyPicWrapper(inFile,outFile); if (outFile != stdout) fclose(outFile); fclose(inFile); remove(tmpfileNm); exit(0); return 0; /* just to suppress the warning */ }
void apply_tempfile ( BoundingBox pic, char *outName ) { FILE *ifp; FILE *ofp; if ( ( ifp = fopen ( tmpfileName, "r" ) ) == NULL ) { errout ( E_OPEN_TEMPFILE, tmpfileName ); } if ( outName == NULL ) { ofp = stdout; } else if ( ( ofp = fopen ( outName, "w" ) ) == NULL ) { errout ( E_OPEN_OUTPUT, outName ); } applyPicWrapper ( ifp, ofp, pic ); if ( ofp != stdout ) { fclose ( ofp ); } fclose ( ifp ); }