int cdot(char *pathname, char *findthis){//pathname, findthis fprintf(stderr, "CDOT ENTERED \n"); int buflen =1024; char line[buflen]; int line_count = 0; int m = 0; int len = strlen(findthis); int ii = 0; int count = 0; // fprintf(stderr, "Looking for %s in: %s\n",findthis ,pathname); FILE* pFile; pFile = fopen(pathname, "r"); if (pFile == NULL){ fprintf(stderr, "Unable to open: %s\n", pathname); } else{ while(fgets(line, buflen, pFile) != NULL){ fprintf(stderr, "line: %s\n", line); line_count++; m = match_dot(line, findthis); if(m != 0){ // fprintf(stdout, "%d \n", m); fprintf(stdout, "\"%s\" found on line %d in: %s\n", findthis, line_count, pathname); } } fclose(pFile); } }
static here_search_result_ctx *here_execute_search_program_step( const char *buffer, const char *buffer_end, here_search_program_ctx *step) { here_search_result_ctx *search_result = NULL; switch (step->ctype) { case HERE_CTYPE_CMATCH: search_result = match_char(buffer, buffer_end, step); break; case HERE_CTYPE_END: search_result = match_end(buffer, buffer_end, step); break; case HERE_CTYPE_DOT: search_result = match_dot(buffer, buffer_end, step); break; case HERE_CTYPE_LIST: search_result = match_list(buffer, buffer_end, step); break; case HERE_CTYPE_OPTION: search_result = match_opt(buffer, buffer_end, step); break; default: //bypass duh! break; } return search_result; }