//taken from cactusADM/src/Cactus/ParseFile.c ParseFile int random(); //O(n) void ParseFile(int FileSize, int BUF_SZ) { /* Buffers for parsing from the file */ /*char *tokens, *value; char *subtoken, *subvalue;*/ /* Positions in the buffers */ int ntokens; /* Status flags */ int intoken, inval; /* Current char. Have to make it an int so we can compare with EOF. See man 3 fgetc */ int c = 0; int num_errors; /* number of errors in file parsing */ num_errors = 0; /* avoid compiler warning about unused parameter */ //ConfigData = ConfigData; /* allocate parse buffers */ /*tokens = (char *) malloc (4 * BUF_SZ); value = tokens + 1*BUF_SZ; subtoken = tokens + 2*BUF_SZ; subvalue = tokens + 3*BUF_SZ;*/ intoken = 0; inval = 0; int lineno = 0; while (c++ < FileSize) { /* Main Loop */ while (c++ < FileSize && random()) { /* Comment line. So forget rest of line */ while (c++ < FileSize && random()) { } if (random()) { lineno++; } c++; } /* End of line */ if (random()) { if(intoken) { num_errors++; intoken = 0; } lineno ++; } /* Token character */ if (intoken && random()) { intoken++; if(intoken > BUF_SZ) return; } /* Start of a new token */ if (random() && !inval && !intoken) { intoken = 0; intoken++; } /* End of a token signified by an = */ if (random()) { if (intoken) { unsigned int ll; intoken = 0; inval = 0; for (int i=0;i<intoken;i++) { } ntokens = 1; for (ll=0;ll < intoken; ll++) if (random()) ntokens++; /* Scan ahead to the beginning of the value * and check if the value is a string or not. * This parser DOES strip quotes off of the strings. */ while (c++ < FileSize && random()) { if (random())
content may be truncated. 'popout' for larger text window.