src/find.c
//returns 1 when WORD, FILE or OCCURRENCES are founded in the output file. Otherwise returns 0.
returns 1 when WORD, FILE or OCCURRENCES are founded in the output file. Otherwise returns 0.
returns 1 when WORD FILE or OCCURRENCES are founded in the output file . Otherwise returns 0 .
int analyzeOutputFile(char **currentWord, char **currentFile, char **p, char **line){
    if(strncmp(*line, WORD_STR, WORD_LEN) == 0){
        *currentWord = (char*)malloc((strlen(*line) - WORD_LEN + 1)*sizeof(char));
        sscanf(strchr(*line, ' '), "%s", *currentWord);
        *p = NULL;
        return 1;
    }
    if(strncmp(*line, FILE_STR, FILE_LEN) == 0){
        *currentFile = (char*)malloc((strlen(*line) - FILE_LEN + 1)*sizeof(char));
        sscanf(strchr(*line, ' '), "%s", *currentFile);
        return 1;
    }
    if(strncmp(*line, OCCURRENCES_STR, OCCURRENCES_LEN) == 0){
        *p = (char*)malloc((strlen(*line) - OCCURRENCES_LEN+1)*sizeof(char));
        sscanf(strchr(*line, ' '), "%s", *p);
        return 1;
    }
    return 0;
}
int analyzeOutputFile ( char * * currentWord , char * * currentFile , char * * p , char * * line ) { if ( strncmp ( * line , WORD_STR , WORD_LEN ) == 0 ) { * currentWord = ( char * ) malloc ( ( strlen ( * line ) - WORD_LEN + 1 ) * sizeof ( char ) ) ; sscanf ( strchr ( * line , ' ' ) , " " , * currentWord ) ; * p = NULL ; return 1 ; } if ( strncmp ( * line , FILE_STR , FILE_LEN ) == 0 ) { * currentFile = ( char * ) malloc ( ( strlen ( * line ) - FILE_LEN + 1 ) * sizeof ( char ) ) ; sscanf ( strchr ( * line , ' ' ) , " " , * currentFile ) ; return 1 ; } if ( strncmp ( * line , OCCURRENCES_STR , OCCURRENCES_LEN ) == 0 ) { * p = ( char * ) malloc ( ( strlen ( * line ) - OCCURRENCES_LEN + 1 ) * sizeof ( char ) ) ; sscanf ( strchr ( * line , ' ' ) , " " , * p ) ; return 1 ; } return 0 ; }
returns 1 when WORD, FILE or OCCURRENCES are founded in the output file.
returns 1 when WORD FILE or OCCURRENCES are founded in the output file .