/* Open the machine description file & parse it */ machine *getdescr(char *filename) { FILE *f = fopen(filename, "r"); if (!f) feil("file error\n"); machine *m = calloc(1, sizeof(machine)); //Parse the machine description yyin = f; yyparse(m); fclose(f); if (m->broken_description) { free(m); return NULL; } /* toss the dummy wheel */ wheel *w = m->wheel_list; m->wheel_list = m->wheel_list->next_in_set; free(w); circularize(m->wheel_list); /* A machine with slots must have at least one code wheel */ if (m->wheelslots && !m->wheel_list) feil("A machine with wheel slots cannot work with no code wheels.\n"); /* set a default wheel order, so the machine is instantly useable */ default_wheelorder(m); return m; }
int compute_sel_bary_positions(GraphFrame *gf) { int mes = 0; int cycle_len = count_llist(gf->list_sel_vertex); enumerate_vertices(gf); reset_mark_pick_vertices(gf); reset_level_vertices(gf); if(!gf->the_cycle) gf->the_cycle = init_linked_list(); if(!gf->list_visited_vertex) gf->list_visited_vertex = init_linked_list(); if(!gf->the_rest) gf->the_rest = init_linked_list(); get_sel_cycle(gf); /*printing_linked_list(gf->the_cycle);*/ if(!is_empty_list(gf->the_cycle)) { Delete_hash_table(gf->HV); circularize(gf,gf->the_cycle, cycle_len); get_rest(gf); /*printing_linked_list(gf->the_rest);*/ if(!is_empty_list(gf->the_rest)) mes = layout_rest(gf, gf->the_rest, gf->count_vertex-cycle_len); } else mes = NO_CYCLE; Delete_all_list(gf->the_cycle); Delete_all_list(gf->list_visited_vertex); Delete_all_list(gf->the_rest); gf->the_cycle = init_linked_list(); gf->list_visited_vertex = init_linked_list(); gf->the_rest = init_linked_list(); return mes; }