static int _parse_repo(const char *key, char *value, const char *file, int line, struct section_t *section) { int ret = 0; config_repo_t *repo = section->repo; if(strcmp(key, "Server") == 0) { if(!value) { pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"), file, line, key); ret = 1; } else { repo->servers = alpm_list_add(repo->servers, strdup(value)); } } else if(strcmp(key, "SigLevel") == 0) { if(!value) { pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"), file, line, key); } else { alpm_list_t *values = NULL; setrepeatingoption(value, "SigLevel", &values); if(values) { ret = process_siglevel(values, &repo->siglevel, &repo->siglevel_mask, file, line); FREELIST(values); } } } else if(strcmp(key, "Usage") == 0) { alpm_list_t *values = NULL; setrepeatingoption(value, "Usage", &values); if(values) { if(process_usage(values, &repo->usage, file, line)) { FREELIST(values); return 1; } FREELIST(values); } } else { pm_printf(ALPM_LOG_WARNING, _("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"), file, line, key, repo->name); } return ret; }
/*************************************************************************** Name: xpr_process Description: Process xpr production. Input: sql query in PROCESS_SCHED. Output: none Returns: Success/Failure ***************************************************************************/ static int xpr_process(char * user_condition){ char *fn = (char*)"xpr_process"; int timer; arb_put_state(ModConn->getConn(CUST), ARB_STATUS_PROC); if(Proc_mode == MOD_PRODUCTION) ModLog->tracef(fn,"Start processing XPR production."); if(Proc_mode == MOD_BACKOUT) ModLog->tracef(fn,"Start processing XPR backout."); /* Read sql_query given in process_sched table and accounts to be processed. */ try{ AcctNoList = new CaccountNoList(user_condition,ModConn->getConn(CUST)); AcctNoList->printAcctList(Trace_on); }catch (CoreException& e) { ++ErrorAccounts; throw e; } if(AcctNoList->empty()) { ModLog->batchLog(XPRMOD,XPR_INFO_STR, (char*)"No account found for sql",user_condition); return Failure; } /* Load static data*/ timer = set_perf_timer("load static data"); try { ModLog->tracef((char*)"xpr_process",(char*)"Loading static data..."); StaticData = new CstaticData(ModConn->getConn(CUST)); }catch(CoreException& e) { ModLog->batchLog(XPRMOD,XPR_FAIL_INFO_STR, (char*)"Faile reason",(char*)"Load static"); throw e; } log_perf_time(timer); while((AccountNo = AcctNoList->getNextAccount()) != 0) { AccountErrors = 0; ModLog->tracef((char*)"xpr_process",(char*)"Processing account: %d",AccountNo); /* Initailize account information and load CDRs*/ try { timer = set_perf_timer("loadAccount"); Account = new Caccount(AccountNo, ModConn->getConn(CUST)); log_perf_time(timer); if(Proc_mode == MOD_PRODUCTION) { Account->loadServices(); Account->loadProducts(); timer = set_perf_timer("loadCDR"); Account->loadCDRs(); log_perf_time(timer); } }catch(CoreException& e) { ++ErrorAccounts; eWhatNext next = ModLog->handleEvent(XPRMOD,e.getEvent()); if(next == ERROR_ABORT_ACCOUNT) { free_account_globals(); continue; }else if (next == ERROR_ABORT_PROCESS) { throw e; } } /*Start a transaction point. to commit or rollback from this point.*/ sprintf(trname, "%s%03u%010u", MODULE, iserver_id, AccountNo); if (arb_begin_tran(ModConn->getConn(CUST,LASTCMT), trname) == FAILURE) { ModLog->errorLog(XPRMOD,ERROR_ABORT_PROCESS,DB_ERROR); } else { ModConn->addTransnum(CUST, LASTCMT); } if(Proc_mode == MOD_PRODUCTION) { /* Processing usages for current Account.*/ try{ timer = set_perf_timer("process usage"); process_usage(); log_perf_time(timer); timer = set_perf_timer("update xpr result"); update_xpr_result(); log_perf_time(timer); }catch(CoreException& e) { ++ErrorAccounts; eWhatNext next = ModLog->handleEvent(XPRMOD,e.getEvent()); if(next == ERROR_ABORT_ACCOUNT) { free_account_globals(); continue; }else if (next == ERROR_ABORT_PROCESS) { throw e; } } } if(Proc_mode == MOD_BACKOUT) { try{ backout_usages(); }catch(CoreException& e) { ++ErrorAccounts; eWhatNext next = ModLog->handleEvent(XPRMOD,e.getEvent()); if(next == ERROR_ABORT_ACCOUNT) { free_account_globals(); continue; }else if (next == ERROR_ABORT_PROCESS) { throw e; } } } report_one_run(); free_account_globals(); if(!AccountErrors) ++SuccessAccounts; } return Success; }
int main(int argc,char *argv[]){ char *basename; codebook **b=_ogg_calloc(1,sizeof(codebook *)); int *addmul=_ogg_calloc(1,sizeof(int)); int books=0; int input=0; int interleave=0; int j; int start=0; int num=-1; argv++; if(*argv==NULL){ process_usage(); exit(1); } /* yes, this is evil. However, it's very convenient to parse file extentions */ while(*argv){ if(*argv[0]=='-'){ /* option */ if(argv[0][1]=='s'){ /* subvector */ if(sscanf(argv[1],"%d,%d",&start,&num)!=2){ num= -1; if(sscanf(argv[1],"%d",&start)!=1){ fprintf(stderr,"Syntax error using -s\n"); exit(1); } } argv+=2; } if(argv[0][1]=='i'){ /* interleave */ interleave=1; argv+=1; } }else{ /* input file. What kind? */ char *dot; char *ext=NULL; char *name=strdup(*argv++); dot=strrchr(name,'.'); if(dot) ext=dot+1; else ext=""; /* codebook */ if(!strcmp(ext,"vqh")){ int multp=0; if(input){ fprintf(stderr,"specify all input data (.vqd) files following\n" "codebook header (.vqh) files\n"); exit(1); } /* is it additive or multiplicative? */ if(name[0]=='*'){ multp=1; name++; } if(name[0]=='+')name++; basename=strrchr(name,'/'); if(basename) basename=strdup(basename)+1; else basename=strdup(name); dot=strrchr(basename,'.'); if(dot)*dot='\0'; b=_ogg_realloc(b,sizeof(codebook *)*(books+2)); b[books]=codebook_load(name); addmul=_ogg_realloc(addmul,sizeof(int)*(books+1)); addmul[books++]=multp; b[books]=NULL; } /* data file */ if(!strcmp(ext,"vqd")){ int cols; long lines=0; char *line; float *vec; FILE *in=fopen(name,"r"); if(!in){ fprintf(stderr,"Could not open input file %s\n",name); exit(1); } if(!input){ process_preprocess(b,basename); input++; } reset_next_value(); line=setup_line(in); /* count cols before we start reading */ { char *temp=line; while(*temp==' ')temp++; for(cols=0;*temp;cols++){ while(*temp>32)temp++; while(*temp==' ')temp++; } } vec=alloca(cols*sizeof(float)); while(line){ lines++; for(j=0;j<cols;j++) if(get_line_value(in,vec+j)){ fprintf(stderr,"Too few columns on line %ld in data file\n",lines); exit(1); } /* ignores -s for now */ process_vector(b,addmul,interleave,vec,cols); line=setup_line(in); } fclose(in); } } } /* take any data from stdin */ { struct stat st; if(fstat(STDIN_FILENO,&st)==-1){ fprintf(stderr,"Could not stat STDIN\n"); exit(1); } if((S_IFIFO|S_IFREG|S_IFSOCK)&st.st_mode){ int cols; char *line; long lines=0; float *vec; if(!input){ process_preprocess(b,basename); input++; } line=setup_line(stdin); /* count cols before we start reading */ { char *temp=line; while(*temp==' ')temp++; for(cols=0;*temp;cols++){ while(*temp>32)temp++; while(*temp==' ')temp++; } } vec=alloca(cols*sizeof(float)); while(line){ lines++; for(j=0;j<cols;j++) if(get_line_value(stdin,vec+j)){ fprintf(stderr,"Too few columns on line %ld in data file\n",lines); exit(1); } /* ignores -s for now */ process_vector(b,addmul,interleave,vec,cols); line=setup_line(stdin); } } } process_postprocess(b,basename); return 0; }