void load_patterns(void) { char buff[MAX_BUFF]; FILE *fp; if((fp=fopen(CONFIG_FILE, "rt"))==NULL) { logit(log_file, "unable to open configuration file\n"); bridge_mode=1; return; } logit(log_file, "Reading configuration from %s\n", CONFIG_FILE); while(!bridge_mode &&(fgets(buff, MAX_BUFF, fp)!=NULL)) { /* skip blank lines and comments */ if((strncmp(buff, "#", 1)==0)||(strncmp(buff, "\n", 1)==0))continue; if(strlen(buff)!=1) { /* chop newline */ buff[strlen(buff)- 1]='\0'; add_to_patterns(buff); } } if(redirect_url==NULL) { logit(log_file, "No redirection URL set, going to BRIDGE mode\n"); bridge_mode=1; } fclose(fp); }
int load_patterns(struct pattern_item **list, char *conf_filename) { char buff[MAX_BUFF]; FILE *fp; fp = fopen(conf_filename, "rt"); if(fp == NULL) { logprint(LOG_ERROR, "unable to open patterns file [%s]\n", conf_filename); dodo_mode = 1; return -1; } logprint(LOG_INFO, "Reading patterns from file %s\n", conf_filename); while(!dodo_mode && (fgets(buff, MAX_BUFF, fp) != NULL)) { /* skip blank lines and comments */ if((strncmp(buff, "#", 1) == 0) || (strncmp(buff, "\n", 1) == 0)) continue; if(strlen(buff) != 1) { /* chop newline */ buff[strlen(buff) - 1] = '\0'; add_to_patterns(buff, list); } } fclose(fp); return 1; }
void load_patterns(void) { char buff[MAX_BUFF]; FILE *fp; /* from main.c - main(), use alternate config if given */ if(alternate_config != NULL) fp = fopen(alternate_config, "rt"); else fp = fopen(REDIRECT_PATTERNS, "rt"); if(fp == NULL) { log(LOG_ERROR, "unable to open redirect patterns file\n"); dodo_mode = 1; return; } if(alternate_config != NULL) log(LOG_INFO, "Reading Patterns from config %s\n", alternate_config); else log(LOG_INFO, "Reading Patterns from config %s\n", REDIRECT_PATTERNS); while(!dodo_mode && (fgets(buff, MAX_BUFF, fp) != NULL)) { /* skip blank lines and comments */ if((strncmp(buff, "#", 1) == 0) || (strncmp(buff, "\n", 1) == 0)) continue; if(strlen(buff) != 1) { /* chop newline */ buff[strlen(buff) - 1] = '\0'; add_to_patterns(buff); } } fclose(fp); }