File::~File() { if (mFd != FILEHDEFAULT) FILECLOSE(mFd); delete [] mBuf; }
int Gen_ClisfileI(int argc, char **argv) { int line,n,pb,com; char bufS[DEF_BS],inS[NSIZE],outS[NSIZE],extS[NSIZE]; FILE *inPF, *outPF; sprintf(inS,"%s",INFILE_S); sprintf(extS,"%s",DEF_EXT_S); if(!ParseArgsI(argc,argv, "-i S -ext S", inS,extS, (int *)NULL)) { Gen_ClisUse(); return(FALSE); } if(!(inPF = OpenUFilePF(inS,"r",NULL))) { return(FALSE); } outPF = NULL; pb = TRUE; com = FALSE; line = n = 0; while(fgets(bufS,LINEGRAB,inPF) != NULL) { line++; if( (!com) && strstr(bufS,"/*") ) com = TRUE; if( (com) && strstr(bufS,"*/") ) com = FALSE; if(com) continue; if((pb) && (bufS[0] == '#')) { INIT_S(outS); sscanf(bufS,"# %s",outS); if(NO_S(outS)) { printf("Error on line %d\n",line); printf("Need name to follow '#'\n"); printf("ABORTING\n"); break; } strcat(outS,"."); strcat(outS,extS); if(!(outPF = OpenUFilePF(outS,"w",NULL))) { printf("ABORTING\n"); break; } GetFilePartsI(outS,NULL,bufS,NULL); fprintf(outPF,"# Source listing for %s\n",bufS); fprintf(outPF,"# Generated by gen_clis\n"); FillDateString(bufS); fprintf(outPF,"# %s\n",bufS); pb = FALSE; n++; continue; } if(!outPF) { continue; } if((!isgraph(INT(bufS[0]))) || (strstr(bufS,"break"))) { pb = TRUE; if(outPF) { FILECLOSE(outPF); printf("NEW FILE: %s\n",outS); } continue; } pb = FALSE; fputs(bufS,outPF); } if(outPF) { FILECLOSE(outPF); printf("NEW FILE: %s\n",outS); } FILECLOSE(inPF); return(TRUE); }