/* * * sce.cpp Source * * * Note: that the dirent.h and any directory associated functions * are all originally written in C since C++ doesn't have * directory manipulating functions. */ #include #include "SmApiBlocking.h" #include #include #include #include #include #include #include using namespace std; //function prototype for wait (at the bottom) void wait(int); int main(int argc, int argv[]){ SmApiBlocking bapi; ReturnCode* ret; int i=0,j=0, numfiles=0; char adel[2],name[50], ip[50], package[50]; string files[50], temp[50], tempfile, line; DIR *pDIR; struct dirent *pDirEnt; //open the directory "." means same directory as code, will probably need to change if( (pDIR = opendir("/data/logs")) == NULL ){ cout << "Directory not found.\n"; exit(1); } pDirEnt = readdir( pDIR ); while(1){ //init w/ defaultparameters bapi.connect((char*)"10.0.0.132"); bapi.init(); //check if any files exist if not wait 2 minutes then should restart other wise keep going if( pDirEnt == NULL ){ wait(120); } else { while ( pDirEnt != NULL ) { tempfile = pDirEnt->d_name; //skip over "." and ".." since readdir picks those up if( tempfile[0] == '.' ){ pDirEnt = readdir( pDIR ); } temp[i] = pDirEnt->d_name; i++; pDirEnt = readdir( pDIR ); } closedir( pDIR ); //close the directory /* Clean up the last ".." that readdir picks up */ for(j=0;j