#include #include #define err(S) pm_error("bad parameter S") Parms *readparms(char *name) { Parms *p = (Parms*)(malloc(sizeof(Parms))); FILE *f = fopen(name, "r"); if (f == NULL) pm_error("couldn't open input file"); if (p == NULL) pm_error("out of memory"); if (fscanf(f, "z_max = %f\n", &p->z_max) != 1) err("z_max"); if (fscanf(f, "z_min = %f\n", &p->z_min) != 1) err("z_min"); if (fscanf(f, "f_length = %f\n", &p->f_length) != 1) err("f_length"); if (fscanf(f, "b_dist = %f\n", &p->b_dist) != 1) err("b_dist"); if (fscanf(f, "delta = %f\n", &p->delta) != 1) err("delta"); if (fscanf(f, "min_run_w = %d\n", &p->min_run_w) != 1) err("min_run_w"); if (fscanf(f, "max_step_w = %d\n", &p->max_step_w) != 1) err("max_step_w"); if (fscanf(f, "max_steps = %d\n", &p->max_steps) != 1) err("max_steps"); if (fscanf(f, "alpha = %f\n", &p->alpha) != 1) err("alpha"); if (fscanf(f, "beta = %f\n", &p->beta) != 1) err("beta"); if (fscanf(f, "max_disp = %f\n", &p->max_disp) != 1) err("max_disp"); if (fscanf(f, "max_matches = %d\n", &p->max_matches) != 1) err("max_matches"); return(p); }