int main(int argc, char **argv){ int ie = 0; float itr_f = 0; int itr_i = 0; struct options *opt; opt = alloc_options(); init_options(opt); get_options(argc-1, argv+1, opt); if((*opt).help == 1){ help(); ie = 1; } if((*opt).stat == 1){ status(); ie = 1; } if((*opt).check == 1){ check_options(opt); ie = 1; } if(ie > 0){ exit(0); } itr_f = 1 / ((*opt).on + (*opt).off); itr_i = (int)itr_f; printf("%d\n",itr_i); return(0); }
void init(int argc,char** argv) { time_t ti; time(&ti); srand(ti); fnit(); rules= alloc_options(argc,argv,"-r"); variables= alloc_options(argc,argv,"-v"); frames= alloc_options(argc,argv,"-f"); yywrap(); varwrap(); varparse(); qTranslationIinitiateVariables(0); qNexus_createNameNexuses(); registerDefaultRules(); qContentFilter_init(); yyparse(); netStruct_init(); }
int main(int argc, char **argv){ struct options *opt; int ie = 0; FILE *IN; int is_open = 0; int c; opt = alloc_options(); init_options(opt); get_options(argc-1, argv+1, opt); if(argc == 1){ (*opt).help = 1; } if((*opt).help == 1){ help(); ie = 1; } if((*opt).stat == 1){ status(); ie = 1; } if((*opt).check == 1){ check_options(opt); ie = 1; } if(ie == 1){ exit(0); } // open file if((IN = fopen((*opt).in,"r")) == NULL){ perror((*opt).in); exit(1); } is_open = 1; // main function c = 1; int DLM_ACC = 1; int R_COUNT = 0; int BRK_REMAIN = 0; while(c != EOF){ //while((c = fgetc(IN)) != EOF){ c = print_CHAR(IN,&DLM_ACC,&R_COUNT,&BRK_REMAIN,(*opt).war); } // close file if(is_open > 0){ fclose(IN); } // finish return(0); }
int main(int argc, char **argv){ struct options *opt; int ie = 0; FILE *IN; int c; int IN_BRK = 0; opt = alloc_options(); init_options(opt); get_options(argc-1, argv+1, opt); if(argc == 1){ (*opt).help = 1; } if((*opt).help == 1){ help(); ie = 1; } if((*opt).stat == 1){ status(); ie = 1; } if((*opt).check == 1){ check_options(opt); ie = 1; } if(ie == 1){ exit(0); } if((IN = fopen((*opt).fname, "r")) == NULL){ perror((*opt).fname); exit(1); } while((c = fgetc(IN)) != EOF){ //putc(c,stdout); if(c == (int)(*opt).brk_start){ IN_BRK++; }else if(c == (int)(*opt).brk_end){ IN_BRK--; }else{ ; } //printf("%d",IN_BRK); if((IN_BRK == 0) && (c == (int)(*opt).dlm)){ putc('\n',stdout); }else{ putc(c,stdout); } } fclose(IN); return(0); }
void init(int argc,char** argv) { printf("Init...\n"); time_t ti; time(&ti); srand(ti); fnit(); rules= alloc_options(argc,argv,"-r"); variables= alloc_options(argc,argv,"-v"); frames= alloc_options(argc,argv,"-f"); yywrap(); varwrap(); varparse(); printf("create %d variables \n",varsParsed); qTranslationIinitiateVariables(); qNexus_createNameNexuses(); registerDefaultRules(); qContentFilter_init(); printf("created nexi\n"); yyparse(); printf("parsed %d rules \n",rulesParsed); netStruct_init(); }
int main(int argc, char **argv){ struct options *opt; opt = alloc_options(); init_options(opt); get_options(argc-1, argv+1, opt); if((*opt).help == 1){ help(); } if((*opt).stat == 1){ status(); } if((*opt).check == 1){ check_options(opt); } return(0); }
int main(int argc, char **argv){ struct options *opt; int ie = 0; FILE *FP; double re,im; complex **xtable; int i,j; opt = alloc_options(); init_options(opt); get_options(argc-1, argv+1, opt); if(argc == 1){ (*opt).help = 1; } if((*opt).help == 1){ help(); ie = 1; } if((*opt).stat == 1){ status(); ie = 1; } if((*opt).check == 1){ check_options(opt); ie = 1; } if(strlen((*opt).file) == 0){ ie = 1; } if(ie == 1){ exit(0); } /* main routine */ xtable = x_alloc_mat((*opt).nlines,(*opt).ntuples); FP = fopen((*opt).file,"r"); read_xtable_from_stream((*opt).nlines,(*opt).ntuples,FP,xtable); //fscanf(FP,"%lf%lf",&x); fclose(FP); //printf("%lf %lf\n",creal(x),cimag(x)); for(i=0;i<(*opt).nlines;i++){ for(j=0;j<(*opt).ntuples;j++){ printf(" %lf+%lfI",creal(xtable[i][j]),cimag(xtable[i][j])); } printf("\n"); } return(0); }
PUBLIC int alloc_status(status** stat) { *stat = malloc(sizeof(status)); if (*stat == NULL) { perror("Malloc failed"); return FAILURE; } (*stat)->nb_folders = 0; (*stat)->nb_files = 0; (*stat)->size_byte = 0; if (alloc_options(&((*stat)->opt)) == FAILURE) return FAILURE; return SUCCESS; }
void ReadUnitsDB (int init) { MYSQL *conn; MYSQL_RES *res_set; MYSQL_ROW row; int i; char UT[20][SHORT_NAME_LEN]; conn = mysql_init (NULL); // fprintf(stderr,"%s, %s, %s\n",HostName, UserName, Password); if (mysql_InitConnect (conn, HostName, UserName, Password)) { for (i = 0; i < MAXUNITS; i++) { Units[i].Ident = -1; Units[i].Name[0] = '\0'; Units[i].type = NONE; Units[i].enable = 0; Units[i].ParentIdent = -1; } for (i = 0; i < 20; i++) UT[i][0] = '\0'; mysql_FillKey (conn, ConfFName, UNIT_CONF_TABLE, "UNITTYPE", UT, 20); alloc_options (); if ((res_set = mysql_SelectAll (conn, ConfFName, UNIT_CONF_TABLE)) != NULL) { i = 0; while ((row = mysql_fetch_row (res_set)) != NULL) { if (mysql_num_fields (res_set) >= 6) { Units[i].type = (unit_t) mysql_KeyNumber (UT, row[2], 20); Units[i].enable = (unsigned char) atoi (row[0]); strcpy (Units[i].Name, row[1]); Units[i].Ident = (unsigned int) atoi (row[3]); Units[i].ParentIdent = (unsigned int) atoi (row[4]); switch (Units[i].type) { case ITEM: ReadItemOptions (&Units[i], &Items[RealItems], row[5]); RealItems++; break; case GROUP: ReadGroupOptions (init, &Units[i], &Groups[RealGroups], row[5]); RealGroups++; break; case DEVICE: ReadDeviceOptions (init, &Units[i],&Devices[RealDevices], row[5]); break; case DRIVER: ReadDriverOptions (init, &Units[i], &Drivers[RealDrivers], row[5]); break; default: continue; break; } // fprintf (stderr, "%d) Id=%d (%s) T=%d, ParId=%d, St=%d\n", // i, Units[i].Ident, Units[i].Name, Units[i].type, // Units[i].ParentIdent, Units[i].enable); i++; if (i >= MAXUNITS) break; } } RealUnits = RealDrivers + RealDevices + RealGroups + RealItems; mysql_free_result (res_set); } free_options(); } mysql_close (conn); fprintf (stderr, "Size = %d\n", sizeof (Units) + sizeof (Drivers) + sizeof (Devices) + sizeof (Groups) + sizeof (Items)); fprintf (stderr, "Drivers (%4d) of maximum (%4d)\n", RealDrivers, MAXDRIVERS); fprintf (stderr, " Devices (%4d) of maximum (%4d)\n", RealDevices, MAXDEVICES); fprintf (stderr, " Groups (%4d) of maximum (%4d)\n", RealGroups, MAXGROUPS); fprintf (stderr, " Items (%4d) of maximum (%4d)\n", RealItems, MAXITEMS); }
int main(int argc, char **argv){ struct options *opt; int ie=0; FILE *fp; char *line; int c; int num_RNG_edge = 0; struct edge_d RNG_edge_d; //struct edge_table RNG_tbl; //float **dmat; float **RNG_d_tbl; float *min_stack; int min_stack_len; float maxmin = 0; int i,j,k,l; /* (* check options */ opt = alloc_options(); init_options(opt); get_options(argc-1, argv+1, opt); if((*opt).loop == 0){ (*opt).loop = (*opt).dsize; } if(argc == 1){ (*opt).help = 1; } if((*opt).help == 1){ help(); ie = 1; } if((*opt).stat == 1){ status(); ie = 1; } if((*opt).check == 1){ check_options(opt); ie = 1; } if(ie == 1){ exit(0); } /* *) */ /* (* read RNG_d */ //must be rewrite line = c_alloc_vec(LEN); if((fp = fopen((*opt).ef,"r")) == NULL){ perror((*opt).ef); exit(1); } num_RNG_edge = 0; while((c=fgetc(fp)) != EOF){ if((char)c == '\n'){ num_RNG_edge++; } } //printf("num_RNG_edge:%d:\n",num_RNG_edge); fseek(fp,0U,SEEK_SET); RNG_edge_d.p = i_alloc_vec(num_RNG_edge); RNG_edge_d.t = i_alloc_vec(num_RNG_edge); RNG_edge_d.d = f_alloc_vec(num_RNG_edge); i = 0; while((fgets(line,LEN,fp)) != NULL){ sscanf(line,"%d %d %f",RNG_edge_d.p+i,RNG_edge_d.t+i,RNG_edge_d.d+i); i++; } fclose(fp); //check /* for(i=0;i<num_RNG_edge;i++){ printf("%d %d %f\n",RNG_edge_d.p[i],RNG_edge_d.t[i],RNG_edge_d.d[i]); } */ /* *) */ /* (* create RNG_d_tbl */ //must be rewite RNG_d_tbl = f_calloc_mat((*opt).dsize,(*opt).dsize); for(i=0;i<(*opt).dsize;i++){ for(j=0;j<(*opt).dsize;j++){ RNG_d_tbl[i][j] = -1; } } for(i=0;i<num_RNG_edge;i++){ RNG_d_tbl[RNG_edge_d.p[i]][RNG_edge_d.t[i]] = RNG_edge_d.d[i]; RNG_d_tbl[RNG_edge_d.t[i]][RNG_edge_d.p[i]] = RNG_edge_d.d[i]; } //check /* printf("dsize:%d:\n",(*opt).dsize); for(i=0;i<(*opt).dsize;i++){ for(j=0;j<(*opt).dsize;j++){ printf(" %f",RNG_d_tbl[i][j]); } printf("\n"); } */ /* *) */ /* (* refine RNG_d_tbl */ min_stack = f_alloc_vec((*opt).dsize); //for l in loop for(l=0;l<(*opt).loop;l++){ //for i in row for(i=0;i<(*opt).dsize;i++){ //for j in row for(j=0;j<(*opt).dsize;j++){ //for k in column //min_stack_len = 0; maxmin = 0; min_stack_len = 0; for(k=0;k<(*opt).dsize;k++){ //comp(dmat[i] dmat[j]) //if dmat[i][k]!=0, dmat[j][k]!=0 //Func1 //if((RNG_d_tbl[i][k] != -1) && (RNG_d_tbl[j][k] != -1)){ if((RNG_d_tbl[i][k] >= 0) && (RNG_d_tbl[j][k] >= 0)){ //add max(pair) to min_stack; nim_stack_len++; min_stack[min_stack_len] = max(RNG_d_tbl[i][k],RNG_d_tbl[j][k]); min_stack_len++; } //end for k } //min of nim_stack //Func2 maxmin = f_min_list(min_stack_len,min_stack); // ?? can rewrite maxmin ?? if((*opt).diag==1 && i==j){ maxmin = -1; } // ?? needs ?? //printf("maxmin:%f:\n",maxmin); //rewrite RNG_d_tbl[i][j] <- nim(nin_stack); if(min_stack_len > 0){ // must be replaced!! //Func3 if(RNG_d_tbl[i][j] >= 0){ maxmin = min(maxmin,RNG_d_tbl[i][j]); } RNG_d_tbl[i][j] = maxmin; } //end for j } //end for i } //end for l } /* *) */ /* (* print results */ //printf("result after %d times loop:\n",l); if((*opt).zeroself == 1){ for(i=0;i<(*opt).dsize;i++){ RNG_d_tbl[i][i] = 0; } } for(i=0;i<(*opt).dsize;i++){ printf("%f",RNG_d_tbl[i][0]); for(j=1;j<(*opt).dsize;j++){ printf(" %f",RNG_d_tbl[i][j]); } printf("\n"); } /* *) */ return(0); }
int main(int argc, char **argv){ struct options *opt; int ie = 0; FILE *fp; char *line; struct edge RNG_edge; int edge,num_RNG_edge = 0; int level,max_level; int cmp_path,num_path; int **path_list; int num_path_new = 0; int **path_list_new; int i,j; int c; int adding_num_path; int cmp_path_new = 0; opt = alloc_options(); init_options(opt); get_options(argc-1, argv+1, opt); if(argc == 1){ (*opt).help = 1; } if((*opt).help == 1){ help(); ie = 1; } if((*opt).stat == 1){ status(); ie = 1; } if((*opt).check == 1){ check_options(opt); ie = 1; } if(ie == 1){ exit(0); } /* (* read RNG edge from ef */ /* (* raed */ line = c_alloc_vec(LEN); if((fp = fopen((*opt).ef,"r")) == NULL){ perror((*opt).ef); exit(1); } num_RNG_edge = 0; while((c=fgetc(fp)) != EOF){ if((char)c == '\n'){ num_RNG_edge++; } } printf("#num_RNG_edge:%d:\n",num_RNG_edge); fseek(fp,0U,SEEK_SET); RNG_edge.p = i_alloc_vec(num_RNG_edge * 2); RNG_edge.t = i_alloc_vec(num_RNG_edge * 2); i = 0; while((fgets(line,LEN,fp)) != NULL){ sscanf(line,"%d %d",RNG_edge.p+i,RNG_edge.t+i); i++; } fclose(fp); /* *) */ /* (* extend data */ for(j=i;j<num_RNG_edge*2;j++){ RNG_edge.t[j] = RNG_edge.p[j-num_RNG_edge]; RNG_edge.p[j] = RNG_edge.t[j-num_RNG_edge]; } /* printf("RNG_edge both:\n"); for(j=0;j<num_RNG_edge*2;j++){ printf("%d,%d\n",RNG_edge.p[j],RNG_edge.t[j]); } printf(":\n"); */ /* *) */ /* *) */ /* (* analyze path */ /* (* create first pathes level 1 */ level = 1; num_path = (*opt).dsize; path_list = i_alloc_mat(num_path,level); for(i=0;i<num_path;i++){ path_list[i][0] = i; } printf("#path level %d:\n",level); for(i=0;i<num_path;i++){ for(j=0;j<level;j++){ printf("%d,",path_list[i][j]); } printf("*\n"); } printf("#;\n"); /* *) */ /* (* extend path */ max_level = (*opt).dsize; for(level=2;level<=max_level;level++){ printf("#path level %d:\n",level); /* current level : to be made */ /* TODO : count num_path */ /* comp_node : path_list[cmp_path][level-2] */ //path_list_new = i_calloc_mat(MEM_BLK,level); //num_path_new = 0; adding_num_path = 0; /* (* count */ for(cmp_path=0;cmp_path<num_path;cmp_path++){ /* comp to RNG edge */ for(edge=0;edge<num_RNG_edge*2;edge++){ //printf("%d vs %d\n",path_list[cmp_path][level-2],RNG_edge.p[edge]); /* if path_list[][] == RNG_edge.p[] ; comp RNG_edge.t[] != path_list[][0:level-2] then ; add */ if(path_list[cmp_path][level-2] == RNG_edge.p[edge]){ //printf(" t:%d:\n",RNG_edge.t[edge]); if(if_match_int_sc_vec(RNG_edge.t[edge],path_list[cmp_path],level-2) == 0){ /* for(j=0;j<level-1;j++){ printf("%d,",path_list[cmp_path][j]); } */ //printf("%d-*\n",RNG_edge.t[edge]); adding_num_path++; } } /* check for(i=0;i<num_path;i++){ for(j=0;j<level-1;j++){ printf("%d,",path_list[i][j]); } printf("* vs %d\n",RNG_edge.p[edge]); } */ } } /* *) */ /* (* add */ //printf(" add_path:%d:\n",adding_num_path); num_path_new = adding_num_path; path_list_new = i_alloc_mat(num_path_new,level); /* TODO : extend path at level from level-1 OK */ cmp_path_new = 0; for(cmp_path=0;cmp_path<num_path;cmp_path++){ /* comp to RNG edge */ for(edge=0;edge<num_RNG_edge*2;edge++){ if(path_list[cmp_path][level-2] == RNG_edge.p[edge]){ //printf(" t:%d:\n",RNG_edge.t[edge]); if(if_match_int_sc_vec(RNG_edge.t[edge],path_list[cmp_path],level-2) == 0){ //for(i=0;i<num_path;i++){ for(j=0;j<level-1;j++){ //printf("%d-",path_list[cmp_path][j]); path_list_new[cmp_path_new][j] = path_list[cmp_path][j]; } //} //printf("%d-*\n",RNG_edge.t[edge]); path_list_new[cmp_path_new][level-1] = RNG_edge.t[edge]; cmp_path_new++; //adding_num_path++; } } } } /* *) */ /* (* print cmp_path_new printf(" path_list_new:\n"); for(i=0;i<num_path_new;i++){ for(j=0;j<level;j++){ printf("%d,",path_list_new[i][j]); } printf("*\n"); } printf(" :\n"); *) */ /* (* copy */ /*TODO : free path_list at level-1 OK */ //printf(" num_path:%d:\n",num_path); //printf(" num_path_new:%d:\n",num_path_new); free(path_list[0]); free(path_list); num_path = num_path_new; path_list = i_alloc_mat(num_path,level); /* copy */ for(i=0;i<num_path;i++){ for(j=0;j<level;j++){ path_list[i][j] = path_list_new[i][j]; } } /* (* check */ //printf(" path_list <copy>:\n"); for(i=0;i<num_path;i++){ for(j=0;j<level;j++){ printf("%d,",path_list[i][j]); } printf("*\n"); } //printf(" :\n"); /* *) */ /* *) */ printf("#;\n"); } /* *) */ /* *) */ return(0); }