src/find.c
//executes the words searching operation. Based on the param passed in input, it executes a different features.
executes the words searching operation. Based on the param passed in input, it executes a different features.
executes the words searching operation . Based on the param passed in input it executes a different features .
void execute(const char *wordFile, const char *inputFile, const char *excluded, const int verboseFlag, const int outputFlag, const char *outputFile){
    FILE *fp = NULL;
    char *appDir = NULL;
    lHead = createllist(lHead, lTail, inputFile);
    lCurr = lHead;
    checkingForRecursion(lCurr, excluded);
    list = listHead; 
    wordHead = createfWord(wordHead, wordTail, wordFile);
    w = wordHead;
    while(w != NULL){
        if(verboseFlag == 1) printf("Start processing word: %s\r\n", w->word);
        while(list != NULL){
            pathHead = createfPath(&w->p, &pathHead, &pathTail, list->path, list->directory);
            fp = fopen(w->p->path, "r"); 
            if(fp == NULL){
                fprintf(stderr, "Cannot open %s, exiting. . .\n", w->p->path);
                exit(1);
            }
            if(verboseFlag == 1) startTime(&appDir, list);
            executeKMP(w, fp); 
            if(verboseFlag == 1) elapsedTime(&appDir, list);
            list = list->next;
            fclose(fp);
        }
        if(verboseFlag == 1) printf("Terminate processing word: %s\n", w->word);
        w->p = pathHead;
        sortFileByOccurrences(pathHead); 
        list = listHead;
        w = w->next;
        pathHead = NULL;
    }
    print(w, wordHead, pathHead);
    if(outputFlag == 1) writeFile(w, wordHead, pathHead, outputFile);
}
void execute ( const char * wordFile , const char * inputFile , const char * excluded , const int verboseFlag , const int outputFlag , const char * outputFile ) { FILE * fp = NULL ; char * appDir = NULL ; lHead = createllist ( lHead , lTail , inputFile ) ; lCurr = lHead ; checkingForRecursion ( lCurr , excluded ) ; list = listHead ; wordHead = createfWord ( wordHead , wordTail , wordFile ) ; w = wordHead ; while ( w != NULL ) { if ( verboseFlag == 1 ) printf ( " \r \n " , w -> word ) ; while ( list != NULL ) { pathHead = createfPath ( & w -> p , & pathHead , & pathTail , list -> path , list -> directory ) ; fp = fopen ( w -> p -> path , " " ) ; if ( fp == NULL ) { fprintf ( stderr , " \n " , w -> p -> path ) ; exit ( 1 ) ; } if ( verboseFlag == 1 ) startTime ( & appDir , list ) ; executeKMP ( w , fp ) ; if ( verboseFlag == 1 ) elapsedTime ( & appDir , list ) ; list = list -> next ; fclose ( fp ) ; } if ( verboseFlag == 1 ) printf ( " \n " , w -> word ) ; w -> p = pathHead ; sortFileByOccurrences ( pathHead ) ; list = listHead ; w = w -> next ; pathHead = NULL ; } print ( w , wordHead , pathHead ) ; if ( outputFlag == 1 ) writeFile ( w , wordHead , pathHead , outputFile ) ; }
executes the words searching operation.
executes the words searching operation .
//creates the structure that stores the lines read from the input file which contains the paths //checks if some path need to be opened recursively //pointer back to the head of fileList //creates the structure that stores the words to search //creates the structure that stores all the files where the program searched and the word occurrences founded in them. //execute the KMP algorithm