/* Classic Ladder Project */ /* Copyright (C) 2001-2008 Marc Le Douarain */ /* http://membres.lycos.fr/mavati/classicladder/ */ /* http://www.sourceforge.net/projects/classicladder */ /* February 2001 */ /* -------------------------------------------------------------------------------------------- */ /* Load/Save Rungs, Timers, Monostables, Counters, Arithmetic expressions & Sections parameters */ /* -------------------------------------------------------------------------------------------- */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* You should have received a copy of the GNU Lesser General Public */ /* License along with this library; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include // for mkdir( ) Linux #if !defined(__WIN32__) #include #include #include #else #include #endif #include "classicladder.h" #include "global.h" #include "calc.h" #include "calc_sequential.h" #include "files_sequential.h" #include "files.h" #include "vars_access.h" #include "protocol_modbus_master.h" #include "emc_mods.h" #ifdef debug #define dbg_printf printf #else static inline int dbg_printf(char *f, ...) {return 0;} #endif StrDatasForBase CorresDatasForBase[3] = { {BASE_MINS , TIME_BASE_MINS , "%.1fmn" , "Mins" } , {BASE_SECS , TIME_BASE_SECS , "%.1fs" , "Secs" } , {BASE_100MS , TIME_BASE_100MS , "%.0f00ms" , "100msecs" } }; char * TimersModesStrings[ NBR_TIMERSMODES ] = { "TON", "TOF", "TP" }; char TmpDirectory[ 400 ] = ""; char *cl_fgets(char *s, int size, FILE *stream) { char * res; s[0] = '\0'; res = fgets( s, size, stream ); // While last character in string is either CR or LF, remove. while (strlen(s)>=1 && ((s[strlen(s)-1]=='\r') || (s[strlen(s)-1]=='\n'))) s[strlen(s)-1] = '\0'; if ( strlen( S_LINE )>0 && strlen(s)>strlen( S_LINE )+strlen( E_LINE ) ) { strcpy( s, s+strlen( S_LINE ) ); s[ strlen(s)-strlen(E_LINE) ] = '\0'; } return res; } char ConvRawLineOfElements(char * RawLine,int y,StrRung * StorageRung) { char * StartOfValue; char * EndOfValue; int x = 0; char EndOfLine; StartOfValue = RawLine; EndOfValue = RawLine; do { /* Extract Element Type */ StartOfValue = EndOfValue; do { EndOfValue++; } while(*EndOfValue!='-'); *EndOfValue++ = '\0'; StorageRung->Element[x][y].Type = atoi(StartOfValue); /* Extract ConnectedWithTop */ StartOfValue = EndOfValue; do { EndOfValue++; } while(*EndOfValue!='-'); *EndOfValue++ = '\0'; StorageRung->Element[x][y].ConnectedWithTop = atoi(StartOfValue); /* Extract Var Type */ StartOfValue = EndOfValue; do { EndOfValue++; } while(*EndOfValue!='/'); *EndOfValue++ = '\0'; StorageRung->Element[x][y].VarType = atoi(StartOfValue); /* Extract Var Offset in the type table */ StartOfValue = EndOfValue; do { EndOfValue++; } while( (*EndOfValue!=',') && (*EndOfValue!=10) && (*EndOfValue!='\0') ); EndOfLine = TRUE; if (*EndOfValue==',') EndOfLine = FALSE; *EndOfValue++ = '\0'; StorageRung->Element[x][y].VarNum = atoi(StartOfValue); /* Next Element */ x++; } while(!EndOfLine); return (x); } /*void RemoveEndLine( char * line ) { if (strlen( line )>0 && line[ strlen(line)-1 ]=='\n') line[ strlen(line)-1 ]='\0'; if (strlen( line )>0 && line[ strlen(line)-1 ]=='\r') line[ strlen(line)-1 ]='\0'; if (strlen( line )>0 && line[ strlen(line)-1 ]=='\r') line[ strlen(line)-1 ]='\0'; }*/ char LoadRung(char * FileName,StrRung * BufRung) { FILE * File; char Okay = FALSE; char Line[300]; char * LineOk; int y = 0; File = fopen(FileName,"rt"); if (File) { do { LineOk = cl_fgets(Line,300,File); if (LineOk) { switch(Line[0]) { case ';': break; case '#': if(strncmp(&Line[1],"VER=",4)==0) { if (atoi(&Line[5])>2) { printf("Rung version not supported...\n"); LineOk = FALSE; } } if(strncmp(&Line[1],"LABEL=",6)==0) { strcpy(BufRung->Label,&Line[7]); //WIN32PORT // RemoveEndLine( BufRung->Label ); } if(strncmp(&Line[1],"COMMENT=",8)==0) { strcpy(BufRung->Comment,&Line[9]); //WIN32PORT // RemoveEndLine( BufRung->Comment ); } if(strncmp(&Line[1],"PREVRUNG=",9)==0) BufRung->PrevRung = atoi( &Line[10] ); if(strncmp(&Line[1],"NEXTRUNG=",9)==0) BufRung->NextRung = atoi( &Line[10] ); break; default: ConvRawLineOfElements(Line,y,BufRung); y++; } } } while(LineOk); fclose(File); Okay = TRUE; } return (Okay); } char SaveRung(char * FileName,StrRung * BufRung) { FILE * File; char Okay = FALSE; int x,y; File = fopen(FileName,"wt"); if (File) { // fprintf(File,"; Rung :\n"); // fprintf(File,"; all the blocks with the following format :\n"); // fprintf(File,"; type (see classicladder.h) - ConnectedWithTop - VarType (see classicladder.h) / VarOffset\n"); fprintf(File,S_LINE "#VER=2.0" E_LINE "\n"); fprintf(File,S_LINE "#LABEL=%s" E_LINE "\n",BufRung->Label); fprintf(File,S_LINE "#COMMENT=%s" E_LINE "\n",BufRung->Comment); fprintf(File,S_LINE "#PREVRUNG=%d" E_LINE "\n",BufRung->PrevRung); fprintf(File,S_LINE "#NEXTRUNG=%d" E_LINE "\n",BufRung->NextRung); for (y=0;yElement[x][y].Type, BufRung->Element[x][y].ConnectedWithTop , BufRung->Element[x][y].VarType , BufRung->Element[x][y].VarNum); if (xNextRung = NumRung; } Rungs->Used = TRUE; Rungs->PrevRung = PrevNumRung; *TheLast = NumRung; PrevNumRung = NumRung; PrevRung = Rungs; dbg_printf(" - ok.\n"); } else dbg_printf(" - not found.\n"); //DumpRung(Rungs); Rungs++; } /* no rungs loaded ? */ /* we must keep at least one empty ! */ if (*TheFirst<0) { *TheFirst = 0; *TheCurrent = 0; } } void LoadAllRungs(char * BaseName,StrRung * Rungs) { int NumRung; for(NumRung=0; NumRungUsed = TRUE; dbg_printf(" - ok.\n"); } else dbg_printf(" - not found.\n"); //DumpRung(Rungs); Rungs++; } } void SaveAllRungs(char * BaseName) { int NumRung; char RungFile[400]; /* delete all before */ for(NumRung=0;NumRungUsed); for (y=0;yElement[x][y].Type,TheRung->Element[x][y].ConnectedWithTop,TheRung->Element[x][y].VarNum,TheRung->Element[x][y].DynamicOutput); } printf("\n"); } } char * ConvRawLineOfNumbers(char * RawLine,char NbrParams,int * ValuesFnd) { char * StartOfValue; char * EndOfValue; char Num = 0; char EndOfLine; StartOfValue = RawLine; EndOfValue = RawLine; EndOfLine = FALSE; do { /* Extract Value */ StartOfValue = EndOfValue; do { EndOfValue++; } while( (*EndOfValue!=',') && (*EndOfValue!=10) && (*EndOfValue!='\0') ); if (*EndOfValue==10 || *EndOfValue=='\0') EndOfLine = TRUE; *EndOfValue++ = '\0'; *ValuesFnd++ = atoi(StartOfValue); Num++; StartOfValue = EndOfValue; } while( (!EndOfLine) && (Num0) ); return EndOfValue; } #ifdef OLD_TIMERS_MONOS_SUPPORT char LoadTimersParams(char * FileName,StrTimer * BufTimers) { FILE * File; char Okay = FALSE; char Line[300]; char * LineOk; int Params[3]; File = fopen(FileName,"rt"); if (File) { do { LineOk = cl_fgets(Line,300,File); if (LineOk) { if (Line[0]!=';') { ConvRawLineOfNumbers(Line,2,Params); switch(Params[0]) { case BASE_MINS: case BASE_SECS: case BASE_100MS: BufTimers->Base = CorresDatasForBase[Params[0]].ValueInMS; BufTimers->Preset = Params[1] * BufTimers->Base; strcpy(BufTimers->DisplayFormat,CorresDatasForBase[Params[0]].DisplayFormat); break; default: BufTimers->Base = 1; BufTimers->Preset = 10; strcpy(BufTimers->DisplayFormat,"%f?"); printf("!!! Error loading parameter base in %s\n",FileName); break; } dbg_printf("Timer => Base = %d , Preset = %d\n",BufTimers->Base,BufTimers->Preset); BufTimers++; } } } while(LineOk); fclose(File); Okay = TRUE; } return (Okay); } char SaveTimersParams(char * FileName,StrTimer * BufTimers) { FILE * File; char Okay = FALSE; int NumTimer = 0; File = fopen(FileName,"wt"); if (File) { // fprintf(File,"; Timers :\n"); // fprintf(File,"; Base(see classicladder.h),Preset\n"); do { fprintf(File,S_LINE "%d,%d" E_LINE "\n",ConvBaseInMilliSecsToId(BufTimers->Base),BufTimers->Preset/BufTimers->Base); BufTimers++; NumTimer++; } while(NumTimerBase = CorresDatasForBase[Params[0]].ValueInMS; BufMonostables->Preset = Params[1] * BufMonostables->Base; strcpy(BufMonostables->DisplayFormat,CorresDatasForBase[Params[0]].DisplayFormat); break; default: BufMonostables->Base = 1; BufMonostables->Preset = 10; strcpy(BufMonostables->DisplayFormat,"%f?"); printf("!!! Error loading parameter base in %s\n",FileName); break; } dbg_printf("Monostable => Base = %d , Preset = %d\n",BufMonostables->Base,BufMonostables->Preset); BufMonostables++; } } } while(LineOk); fclose(File); Okay = TRUE; } return (Okay); } char SaveMonostablesParams(char * FileName,StrMonostable * BufMonostables) { FILE * File; char Okay = FALSE; int NumMonostable = 0; File = fopen(FileName,"wt"); if (File) { // fprintf(File,"; Monostables :\n"); // fprintf(File,"; Base(see classicladder.h),Preset\n"); do { fprintf(File,S_LINE "%d,%d" E_LINE "\n",ConvBaseInMilliSecsToId(BufMonostables->Base),BufMonostables->Preset/BufMonostables->Base); BufMonostables++; NumMonostable++; } while(NumMonostableBase = CorresDatasForBase[Params[0]].ValueInMS; WriteVar( VAR_TIMER_IEC_PRESET, ScanTimerIEC, Params[1] ); strcpy(TimerIEC->DisplayFormat,CorresDatasForBase[Params[0]].DisplayFormat); break; default: TimerIEC->Base = 1; WriteVar( VAR_TIMER_IEC_PRESET, ScanTimerIEC, 10 ); strcpy(TimerIEC->DisplayFormat,"%f?"); printf("!!! Error loading parameter base in %s\n",FileName); break; } TimerIEC->TimerMode = (char)Params[2]; ScanTimerIEC++; } } } while(LineOk); fclose(File); Okay = TRUE; } return (Okay); } char SaveNewTimersParams(char * FileName) { FILE * File; char Okay = FALSE; int NumTimerIEC = 0; File = fopen(FileName,"wt"); if (File) { // fprintf(File,"; Timers IEC :\n"); // fprintf(File,"; Base(see classicladder.h),Preset,TimerMode(see classicladder.h)\n"); do { StrTimerIEC * TimerIEC = &NewTimerArray[ NumTimerIEC ]; fprintf(File,S_LINE "%d,%d,%d" E_LINE "\n",ConvBaseInMilliSecsToId(TimerIEC->Base),TimerIEC->Preset,TimerIEC->TimerMode); NumTimerIEC++; } while(NumTimerIEC='0' && Line[0]<='9' ) { NumExpr = atoi(Line); strcpy(ArithmExpr[NumExpr].Expr,Line+strlen("xxxx,")); } else { strcpy(ArithmExpr[NumExpr].Expr,Line); NumExpr++; } } } } while(LineOk); fclose(File); Okay = TRUE; } return (Okay); } char SaveArithmeticExpr(char * FileName) { FILE * File; char Okay = FALSE; int NumExpr; File = fopen(FileName,"wt"); if (File) { // fprintf(File,"; Arithmetic expressions :\n"); // fprintf(File,"; Compare or Operate ones\n"); fprintf(File,S_LINE "#VER=2.0" E_LINE "\n"); for(NumExpr=0; NumExprUsed = TRUE; pSection->Language = Params[ 1 ]; pSection->SubRoutineNumber = Params[ 2 ]; pSection->FirstRung = Params[ 3 ]; pSection->LastRung = Params[ 4 ]; pSection->SequentialPage = Params[ 5 ]; dbg_printf("Section %d => Name=%s, Language=%d, SRnbr=%d, FirstRung=%d, LastRung=%d, SequentialPage=%d\n", NumSection, pSection->Name, pSection->Language, pSection->SubRoutineNumber, pSection->FirstRung, pSection->LastRung, pSection->SequentialPage); break; } } } while(LineOk); fclose(File); Okay = TRUE; } return (Okay); } char SaveSectionsParams(char * FileName) { FILE * File; char Okay = FALSE; int NumSection; StrSection * pSection; File = fopen(FileName,"wt"); if (File) { // fprintf(File,"; Sections\n"); fprintf(File,S_LINE "#VER=1.0" E_LINE "\n"); NumSection = 0; do { pSection = &SectionArray[ NumSection ]; if ( pSection->Used ) fprintf(File,S_LINE "#NAME%03d=%s" E_LINE "\n", NumSection, pSection->Name); NumSection++; } while(NumSectionUsed ) fprintf(File,S_LINE "%03d,%d,%d,%d,%d,%d" E_LINE "\n", NumSection, pSection->Language, pSection->SubRoutineNumber, pSection->FirstRung, pSection->LastRung, pSection->SequentialPage ); NumSection++; } while(NumSectionInputsConf[ 0 ]; StrIOConf * pConfOutput = &InfosGene->OutputsConf[ 0 ]; File = fopen(FileName,"rt"); if (File) { do { LineOk = cl_fgets(Line,300,File); if (LineOk) { if (Line[0]!=';' && Line[0]!='#') { /* input/output depending of the first caracter */ if ( Line[0]=='0' ) ConvRawLineOfNumbers(Line+2,6,(int*)pConfInput++); if ( Line[0]=='1' ) ConvRawLineOfNumbers(Line+2,6,(int*)pConfOutput++); } } } while(LineOk); fclose(File); Okay = TRUE; } return (Okay); } char SaveIOConfParams(char * FileName) { FILE * File; char Okay = FALSE; int NumConf; int NbrConf; int Pass; StrIOConf * pConf; File = fopen(FileName,"wt"); if (File) { // fprintf(File,"; I/O Configuration\n"); fprintf(File,S_LINE "#VER=1.0" E_LINE "\n"); for( Pass=0; Pass<2; Pass++) { NbrConf = (Pass==0)?NBR_INPUTS_CONF:NBR_OUTPUTS_CONF; for( NumConf=0; NumConfInputsConf[ NumConf ]:&InfosGene->OutputsConf[ NumConf ]; /* valid mapping ? */ if ( pConf->FirstClassicLadderIO!=-1 ) { fprintf(File,S_LINE "%d,%d,%d,%d,%d,%d,%d" E_LINE "\n", Pass, pConf->FirstClassicLadderIO, pConf->DeviceType, pConf->SubDevOrAdr, pConf->FirstChannel, pConf->NbrConsecutivesChannels, pConf->FlagInverted ); } } } fclose(File); Okay = TRUE; } return (Okay); } #ifdef MODBUS_IO_MASTER char LoadModbusIOConfParams(char * FileName) { FILE * File; char Okay = FALSE; char Line[300]; int IntDatas[ 6 ]; char * LineOk; StrModbusMasterReq * pConf = &ModbusMasterReq[ 0 ]; File = fopen(FileName,"rt"); if (File) { do { LineOk = cl_fgets(Line,300,File); if (LineOk) { if (Line[0]!=';' && Line[0]!='#') { // if dotted IP address is used, special first field if ( strchr( Line, '.' ) ) { char * EndFirstField = strchr( Line, ',' ); // search end of the first field if ( EndFirstField ) { ConvRawLineOfNumbers( EndFirstField+1, 5, &IntDatas[1] ); *EndFirstField = '\0'; strcpy( pConf->SlaveAdr, Line ); } else { LineOk = FALSE; } } else { ConvRawLineOfNumbers( Line, 6, IntDatas ); sprintf( pConf->SlaveAdr, "%d", IntDatas[0] ); } if ( LineOk ) { pConf->TypeReq = (char)IntDatas[ 1 ]; pConf->FirstModbusElement = IntDatas[ 2 ]; pConf->NbrModbusElements = IntDatas[ 3 ]; pConf->LogicInverted = (char)IntDatas[ 4 ]; pConf->OffsetVarMapped = IntDatas[ 5 ]; pConf++; } } } } while(LineOk); fclose(File); Okay = TRUE; } return (Okay); } char SaveModbusIOConfParams(char * FileName) { FILE * File; char Okay = FALSE; int NumLine; StrModbusMasterReq * pConf; File = fopen(FileName,"wt"); if (File) { // fprintf(File,"; Modbus Distributed I/O Configuration\n"); fprintf(File,S_LINE "#VER=1.0" E_LINE "\n"); for (NumLine=0; NumLineSlaveAdr[0]!='\0' ) { fprintf(File,S_LINE "%s,%d,%d,%d,%d,%d" E_LINE "\n", pConf->SlaveAdr, pConf->TypeReq, pConf->FirstModbusElement, pConf->NbrModbusElements, pConf->LogicInverted, pConf->OffsetVarMapped ); } } fclose(File); Okay = TRUE; } return (Okay); } #endif char LoadSymbols(char * FileName) { FILE * File; char Okay = FALSE; char Line[300]; char * LineOk; int NumSymbol = 0; char *PtrStrings[ 4 ]; int LgtMaxStrings[ 4 ]; StrSymbol * pSymbol; File = fopen(FileName,"rt"); if (File) { do { LineOk = cl_fgets(Line,300,File); if (LineOk) { switch(Line[0]) { case ';': break; case '#': if(strncmp(&Line[1],"VER=",4)==0) { if (atoi(&Line[5])>1) { printf("Symbols file version not supported...\n"); LineOk = FALSE; } } break; default: pSymbol = &SymbolArray[ NumSymbol ]; PtrStrings[ 0 ] = pSymbol->VarName; LgtMaxStrings[ 0 ] = LGT_VAR_NAME; PtrStrings[ 1 ] = pSymbol->Symbol; LgtMaxStrings[ 1 ] = LGT_SYMBOL_STRING; PtrStrings[ 2 ] = pSymbol->Comment; LgtMaxStrings[ 2 ] = LGT_SYMBOL_COMMENT; PtrStrings[ 3 ] = NULL; LgtMaxStrings[ 3 ] = 0; ConvRawLineOfStrings( Line, LgtMaxStrings, PtrStrings ); // RemoveEndLine( pSymbol->Comment ); dbg_printf("Symbol: %s - %s - %s\n", pSymbol->VarName, pSymbol->Symbol, pSymbol->Comment); NumSymbol++; break; } } } while(LineOk); fclose(File); Okay = TRUE; } SymbolsAutoAssign(); return (Okay); } char SaveSymbols(char * FileName) { FILE * File; char Okay = FALSE; int NumSymbol = 0; StrSymbol * pSymbol; File = fopen(FileName,"wt"); if (File) { // fprintf(File,"; Symbols\n"); fprintf(File,S_LINE "#VER=1.0" E_LINE "\n"); do { pSymbol = &SymbolArray[ NumSymbol ]; if ( pSymbol->VarName[0]!='\0') fprintf(File,S_LINE "%s,%s,%s" E_LINE "\n", pSymbol->VarName, pSymbol->Symbol, pSymbol->Comment ); NumSymbol++; } while(NumSymbolFirstRung,&InfosGene->LastRung,&InfosGene->CurrentRung); // if we load old format files, sections wasn't created, so we must write theses infos... SectionArray[ 0 ].FirstRung = InfosGene->FirstRung; SectionArray[ 0 ].LastRung = InfosGene->LastRung; } #ifdef SEQUENTIAL_SUPPORT sprintf(FileName,"%s/"FILE_PREFIX"sequential.csv",DatasDirectory); // printf("Loading sequential datas from %s\n",FileName); LoadSequential( FileName ); #endif sprintf(FileName,"%s/"FILE_PREFIX"ioconf.csv",DatasDirectory); // printf("Loading I/O configuration datas from %s\n",FileName); LoadIOConfParams( FileName ); #ifdef MODBUS_IO_MASTER sprintf(FileName,"%s/"FILE_PREFIX"modbusioconf.csv",DatasDirectory); // printf("Loading modbus distributed I/O configuration datas from %s\n",FileName); LoadModbusIOConfParams( FileName ); if (modmaster) { PrepareModbusMaster( ); } #endif sprintf(FileName,"%s/"FILE_PREFIX"symbols.csv",DatasDirectory); // printf("Loading symbols datas from %s\n",FileName); LoadSymbols(FileName); //printf("Prepare all datas before run...\n"); PrepareAllDatasBeforeRun( ); } void SaveAllLadderDatas(char * DatasDirectory) { CleanTmpLadderDirectory( FALSE/*DestroyDir*/ ); sprintf(FileName,"%s/"FILE_PREFIX"general.txt",DatasDirectory); SaveGeneralParameters( FileName ); sprintf(FileName,"%s/"FILE_PREFIX"com_params.txt",DatasDirectory); SaveComParameters( FileName ); #ifdef OLD_TIMERS_MONOS_SUPPORT sprintf(FileName,"%s/"FILE_PREFIX"timers.csv",DatasDirectory); SaveTimersParams(FileName,TimerArray); sprintf(FileName,"%s/"FILE_PREFIX"monostables.csv",DatasDirectory); SaveMonostablesParams(FileName,MonostableArray); #endif sprintf(FileName,"%s/"FILE_PREFIX"counters.csv",DatasDirectory); SaveCountersParams(FileName); sprintf(FileName,"%s/"FILE_PREFIX"timers_iec.csv",DatasDirectory); SaveNewTimersParams(FileName); sprintf(FileName,"%s/"FILE_PREFIX"arithmetic_expressions.csv",DatasDirectory); SaveArithmeticExpr(FileName); sprintf(FileName,"%s/"FILE_PREFIX"rung_",DatasDirectory); SaveAllRungs(FileName); sprintf(FileName,"%s/"FILE_PREFIX"sections.csv",DatasDirectory); SaveSectionsParams( FileName ); #ifdef SEQUENTIAL_SUPPORT sprintf(FileName,"%s/"FILE_PREFIX"sequential.csv",DatasDirectory); SaveSequential( FileName ); #endif sprintf(FileName,"%s/"FILE_PREFIX"ioconf.csv",DatasDirectory); SaveIOConfParams( FileName ); #ifdef MODBUS_IO_MASTER sprintf(FileName,"%s/"FILE_PREFIX"modbusioconf.csv",DatasDirectory); SaveModbusIOConfParams( FileName ); #endif sprintf(FileName,"%s/"FILE_PREFIX"symbols.csv",DatasDirectory); SaveSymbols( FileName ); InfosGene->AskConfirmationToQuit = FALSE; } /* clean the tmp directory of the parameters files */ void CleanTmpLadderDirectory( char DestroyDir ) { DIR *pDir; struct dirent *pEnt; char Buff[400]; if (TmpDirectory[0]!='\0') { pDir = opendir(TmpDirectory); if (pDir) { while ((pEnt = readdir(pDir)) != NULL) { if ( strcmp(pEnt->d_name,".") && strcmp(pEnt->d_name,"..") ) { char cRemoveIt = TRUE; // if a file prefix defined, only remove the classicladder files... if ( strlen(FILE_PREFIX)>0 ) { if ( strncmp( pEnt->d_name, FILE_PREFIX, strlen(FILE_PREFIX) )!=0 ) cRemoveIt = FALSE; } if ( cRemoveIt ) { sprintf(Buff, "%s/%s", TmpDirectory,pEnt->d_name); remove(Buff); } } } closedir(pDir); } /* delete the temp directory if wanted */ #ifndef __WIN32__ if ( DestroyDir ) rmdir(TmpDirectory); #else if ( DestroyDir ) _rmdir(TmpDirectory); #endif } }