/* ========================================================================== * Function that calls my reload to Index function (reloadIndexHash()) * on a file, reads the file and reconstitutes the hash index. * * *** Content *** * Read in characters from file until file is over, and split up the string * by a whitespace (strtok) and place the relevant parts into the hash table * ========================================================================== */ HashTable *ReadFile(char *filePath) { FILE *fp; fp = fopen(filePath, "r"); if (!fp) { fprintf(stderr, "HashTable reload file failed to open.\n"); exit (1); } HashTable *reloadIndex; reloadIndex = initHash(); char *indexInfo = LoadDocIndex(filePath); // get index.dat into a string char *readIn = NULL; readIn = (char*)calloc(strlen(indexInfo) + 1, sizeof(char)); for ( ;; ) { if (fgets(readIn, strlen(indexInfo) + 1, fp) == NULL) { break; // no more lines in file, stop infinite loop } else { char *document; char *word; // get the first white-spaced delimited element in index.dat // if properly formatted, this will be the word character. char copy[strlen(readIn) + 1]; strcpy(copy, readIn); // want to free readIn later // don't need the number of docnodes. skip over word = strtok(copy, " "); strtok(NULL, " "); while ((document = strtok(NULL, " ")) != NULL) { // "document" now refers to docID char *freqChar = strtok(NULL, " "); // every other number is frequency if (strchr(document, '\n')) { break; // this means that freq will be NULL, so break out } int ID = GetDocID(document); int freq = atoi(freqChar); reloadIndexHash(word, ID, freq, reloadIndex); } } } fclose(fp); free(readIn); free(indexInfo); // char returned by LoadDoc() needs to be freed return reloadIndex; }
} //============================================================================= /*! * MakeFilletAll */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll (Handle(GEOM_Object) theShape, const GEOM_Parameter& theR) { SetErrorCode(GEOM_KO); #ifdef LOCAL_OPS_CREATE_NEW_OBJECT //Add a new Fillet object Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET); #else Handle(GEOM_Object) aFillet = theShape; #endif Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); if (aRefShape.IsNull()) return NULL; //Add a new Fillet function Handle(GEOM_Function) aFunction = aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;