static void convert_cat(String *cap, char *s, Config *c, int maxlen) { int res; if (config_get_boolean(c, "/enfle/plugins/ui/normal/filename_code_conversion", &res)) { char **froms = config_get_list(c, "/enfle/plugins/ui/normal/filename_code_from", &res); char *to = config_get_str(c, "/enfle/plugins/ui/normal/filename_code_to"); char *from; int i = 0; if (res && to) { while ((from = froms[i++])) { char *tmp; //debug_message_fnc("%s->%s: %s\n", from, to, s); if ((res = converter_convert(s, &tmp, strlen(s), from, to)) < 0) continue; if (maxlen) string_ncat(cap, tmp, maxlen); else string_cat(cap, tmp); free(tmp); return; } } } if (maxlen > 0) string_ncat(cap, s, maxlen); else string_cat(cap, s); }
static AudioDevice * open_device(void *data, Config *c) { AudioDevice *ad; ALSA_data *alsa; char *device = data; int err; if ((ad = calloc(1, sizeof(AudioDevice))) == NULL) return NULL; ad->c = c; if ((alsa = calloc(1, sizeof(ALSA_data))) == NULL) { free(ad); return NULL; } ad->private_data = alsa; if ((device == NULL) && ((device = config_get_str(c, "/enfle/plugins/audio/alsa/device")) == NULL)) device = (char *)"default"; err = snd_output_stdio_attach(&alsa->log, stderr, 0); if ((err = snd_pcm_open(&alsa->fd, device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) { show_message_fnc("error in opening device \"%s\"\n", device); return NULL; } ad->bytes_written = 0; ad->opened = 1; debug_message_fnc("opened device %s successfully.\n", device); return ad; }
char *config_get_str(char *key) { bool using_last = false; unsigned char keylen = strlen(key); node *n; char *nodekey, *nodevalue; if (!last_key || !key) return NULL; if ((using_last = (strcmp(last_key, key) == 0))) n = last_node; else n = first_node.next; while (n) { nodekey = (void *) (n + sizeof(struct node)); nodevalue = (void *) (n + sizeof(struct node) + n->keylen); if (memcmp(key, nodekey, n->keylen < keylen ? n->keylen : keylen) == 0) { last_key = nodekey; last_node = n; return nodevalue; } } if (using_last) { last_key = NULL; last_node = NULL; return config_get_str(key); } else return NULL; }
int config_link_table(config_var_t *table, void *config_root, ...) { xml_node_t *node, *root = config_root; va_list args; gconfig_level++; va_start(args, config_root); root = xml_node_vlookup(root, args, 1); va_end(args); if (!root) { gconfig_level--; return(-1); } while (table->name) { node = xml_node_lookup(root, 1, table->name, 0, NULL); node->client_data = table; if (table->type == CONFIG_INT) config_get_int(table->ptr, root, table->name, 0, NULL); else if (table->type == CONFIG_STRING) { char *str; config_get_str(&str, root, table->name, 0, NULL); str_redup(table->ptr, str); } table++; } gconfig_level--; return(0); }
/** * Reads model type from configuration */ static int get_mdl_type(Config *config) { char *mdl_type; mdl_type = config_get_str(config, "MODEL_TYPE"); if(strcmp(mdl_type, "HC")==0) { return MDL_TYPE_HC; } if(strcmp(mdl_type, "HCM")==0) { return MDL_TYPE_HCM; } if(strcmp(mdl_type, "HCOM")==0) { return MDL_TYPE_HCOM; } if(strcmp(mdl_type, "HCGOM")==0) { return MDL_TYPE_HCGOM; } if(strcmp(mdl_type, "HCGO")==0) { return MDL_TYPE_HCGO; } g_error("get_mdl_type: model type should be HC or HCM not '%s'", mdl_type); return MDL_TYPE_HC; }
// BT_StrValue: with a half-assed "textbox" static OptionBinding* bind_stroption(ConfigIndex cfgentry) { OptionBinding *bind = bind_new(); bind->type = BT_StrValue; bind->configentry = cfgentry; stralloc(&bind->strvalue, config_get_str(cfgentry)); return bind; }
static void destroy_options_menu_gamepad(MenuData *m) { OptionsMenuContext *ctx = m->context; if(config_get_int(CONFIG_GAMEPAD_ENABLED) && strcasecmp(config_get_str(CONFIG_GAMEPAD_DEVICE), ctx->data)) { gamepad_update_devices(); } destroy_options_menu(m); }
int config_get_int(CONFIG_REC *rec, const char *section, const char *key, int def) { char *str; str = config_get_str(rec, section, key, NULL); if (str == NULL) return def; return atoi(str); }
int config_get_bool(CONFIG_REC *rec, const char *section, const char *key, int def) { char *str; str = config_get_str(rec, section, key, NULL); if (str == NULL) return def; return i_toupper(*str) == 'T' || i_toupper(*str) == 'Y'; }
int config_get_num(char *key) { char *str = config_get_str(key); if (str) return atoi(str); else return 0; }
static int bind_gpdev_get(OptionBinding *b) { const char *guid = config_get_str(b->configentry); int val = gamepad_device_num_from_guid(guid); if(val == GAMEPAD_DEVNUM_ANY) { val = -1; } return val; }
void logfile_init(void) { void *root, *node; char *filename, *chname, *mask; int i; script_create_commands(log_script_cmds); bind_add_simple("log", NULL, NULL, on_putlog); bind_add_simple("event", NULL, "minutely", logfile_minutely); bind_add_simple("event", NULL, "5minutely", logfile_5minutely); root = config_get_root("eggdrop"); node = config_lookup_section(root, "eggdrop.logging.logfiles", 0, NULL); for (i = 0; ; i++) { config_get_str(&filename, node, "logfile", i, "filename", 0, NULL); config_get_str(&chname, node, "logfile", i, "channel", 0, NULL); config_get_str(&mask, node, "logfile", i, "mask", 0, NULL); if (!filename || !chname || !mask) break; logfile_add(mask, chname, filename); } }
static MenuData* create_options_menu_gamepad(MenuData *parent) { MenuData *m = create_options_menu_base("Gamepad Options"); m->end = destroy_options_menu_gamepad; OptionsMenuContext *ctx = m->context; ctx->data = strdup(config_get_str(CONFIG_GAMEPAD_DEVICE)); OptionBinding *b; add_menu_entry(m, "Enable Gamepad/Joystick support", do_nothing, b = bind_option(CONFIG_GAMEPAD_ENABLED, bind_common_onoff_get, bind_common_onoff_set) ); bind_onoff(b); add_menu_entry(m, "Device", do_nothing, b = bind_gpdevice(CONFIG_GAMEPAD_DEVICE) ); b->dependence = gamepad_enabled_depencence; add_menu_separator(m); add_menu_entry(m, "Customize controls…", enter_options_menu_gamepad_controls, NULL); add_menu_separator(m); add_menu_entry(m, "X axis", do_nothing, b = bind_gpaxisbinding(CONFIG_GAMEPAD_AXIS_LR) ); add_menu_entry(m, "Y axis", do_nothing, b = bind_gpaxisbinding(CONFIG_GAMEPAD_AXIS_UD) ); add_menu_entry(m, "Axes mode", do_nothing, b = bind_option(CONFIG_GAMEPAD_AXIS_FREE, bind_common_onoff_get, bind_common_onoff_set) ); bind_addvalue(b, "free"); bind_addvalue(b, "restricted"); add_menu_entry(m, "X axis sensitivity", do_nothing, b = bind_scale(CONFIG_GAMEPAD_AXIS_LR_SENS, -2, 2, 0.05) ); b->pad++; add_menu_entry(m, "Y axis sensitivity", do_nothing, b = bind_scale(CONFIG_GAMEPAD_AXIS_UD_SENS, -2, 2, 0.05) ); b->pad++; add_menu_entry(m, "Dead zone", do_nothing, b = bind_scale(CONFIG_GAMEPAD_AXIS_DEADZONE, 0, 1, 0.01) ); add_menu_separator(m); add_menu_entry(m, "Back", menu_action_close, NULL); return m; }
// BT_GamepadDevice: dynamic device list static OptionBinding* bind_gpdevice(int cfgentry) { OptionBinding *bind = bind_new(); bind->configentry = cfgentry; bind->type = BT_GamepadDevice; bind->getter = bind_gpdev_get; bind->setter = bind_gpdev_set; bind->valrange_min = -1; bind->valrange_max = 0; // updated later bind->selected = gamepad_device_num_from_guid(config_get_str(bind->configentry)); return bind; }
/** * Reads the substitution model type from configuration */ static SubstModel *subst_mdl_new(Config *config) { char *mdl_type; SubstModel *smdl; smdl = g_new(SubstModel, 1); mdl_type = config_get_str(config, "SUBST_MODEL_TYPE"); smdl->name = g_strdup(mdl_type); if(strcmp(mdl_type, "JUKES_CANTOR")==0) { smdl->id = SUBST_MDL_JUKES_CANTOR; smdl->n_subst_type = 1; smdl->subst_type_ids = g_new(int, 1); smdl->subst_type_ids[0] = SUBST_TYPE_SUBST; smdl->subst_type_names = g_new(char *, 1); smdl->subst_type_names[0] = NULL; }
FILE *get_output_fh(Analysis *an) { FILE *fh; SeqCoord *region; char *path, *dir; region = analysis_get_region(an); dir = config_get_str(an->config, "OUTPUT_DIR"); path = g_strconcat(dir, region->chr->name, ".bkgd", NULL); fh = fopen(path, "w"); if(fh == NULL) { g_error("get_output_fh: could not open file '%s'", path); } g_free(path); return fh; }
static GamepadDevice* gamepad_find_device(char *guid_out, size_t guid_out_sz, int *out_localdevnum) { GamepadDevice *dev; const char *want_guid = config_get_str(CONFIG_GAMEPAD_DEVICE); dev = gamepad_find_device_by_guid(want_guid, guid_out, guid_out_sz, out_localdevnum); if(dev || *out_localdevnum == GAMEPAD_DEVNUM_ANY) { return dev; } if(strcasecmp(want_guid, "default")) { log_warn("Requested device '%s' is not available", want_guid); return gamepad_find_device_by_guid("any", guid_out, guid_out_sz, out_localdevnum); } *out_localdevnum = GAMEPAD_DEVNUM_INVALID; strcpy(guid_out, want_guid); return NULL; }
gint config_list_find(proplist_t prop, gchar *key, gchar *value) { proplist_t item; gint num, max; gchar *ret; if (prop == NULL) return -1; max = PLGetNumberOfElements(prop); for (num = 0; num < max; num++) { item = PLGetArrayElement(prop, num); ret = config_get_str(item, key, NULL); if (ret != NULL && g_strcasecmp(ret, value) == 0) return num; } return -1; }
int text_ban_get(int bid, int *_uid, char *_mask, int mask_len, char *_note, int note_len) { char row[512], idstr[16]; sprintf(idstr, "%d", bid); if(config_get_str(cfgname, "bans", idstr, row, 512) == CONFIG_OK) { char *uid, *net, *chan, *mask, *note; uid = strtok(row, " \t"); net = strtok(NULL, " \t"); chan = strtok(NULL, " \t"); mask = strtok(NULL, " \t"); note = strtok(NULL, ""); if((!uid) || (!net) || (!chan) || (!mask)) return -1; if(_uid) *_uid = atoi(uid); if(_mask) { strncpy(_mask, mask, mask_len); _mask[mask_len - 1] = 0; } if(_note) { strncpy(_note, note, note_len); _note[note_len - 1] = 0; } return 0; } return -1; }
/* allocate and init plugin */ static int fst_giftcb_start (Protocol *proto) { FSTPlugin *plugin; int i; char *filepath, *p; in_port_t server_port; FST_DBG ("starting up"); if (! (plugin = malloc (sizeof (FSTPlugin)))) return FALSE; #if 0 /* We need to do this again even though we registered the hashes in * fst_plugin_setup_functbl because the algo lookup is based on a * (get this!) _static_ dataset in libgiftproto. Sometimes i think giFT * needs a complete rewrite. */ hash_algo_register (proto, FST_KZHASH_NAME, HASH_PRIMARY, (HashFn)fst_giftcb_kzhash, (HashDspFn)fst_giftcb_kzhash_encode); /* Note: I don't want this to be HASH_LOCAL but a stupid if() in * share_hash.c::get_first makes it necessary for displaying the hash to * the FE in search results. I have no words to express my hatred for the * hash system and its creator. */ hash_algo_register (proto, FST_FTHASH_NAME, HASH_SECONDARY | HASH_LOCAL, (HashFn)fst_giftcb_fthash, (HashDspFn)fst_giftcb_fthash_encode); #endif /* init config and copy to local config if missing */ copy_default_file ("FastTrack.conf.template", "FastTrack.conf"); if (! (plugin->conf = gift_config_new ("FastTrack"))) { free (plugin); FST_ERR ("Unable to open fasttrack configuration, exiting plugin."); return FALSE; } /* set protocol pointer */ proto->udata = (void*)plugin; /* cache user name */ FST_PLUGIN->username = strdup (config_get_str (FST_PLUGIN->conf, "main/alias=giFTed")); /* Make sure there are no spaces or other invalid chars in the user name. */ if (strlen (FST_PLUGIN->username) >= 32) { FST_PLUGIN->username[31] = 0; FST_WARN_1 ("Username too long. Truncating to \"%s\"", FST_PLUGIN->username); } p = FST_PLUGIN->username; string_sep_set (&p, " \t@"); if (p) { if (strlen (FST_PLUGIN->username) == 0) { free (FST_PLUGIN->username); FST_PLUGIN->username = strdup ("giFTed"); FST_WARN_1 ("Invalid character found in username. Replacing with \"%s\"", FST_PLUGIN->username); } else { FST_WARN_1 ("Invalid character found in username. Truncating to \"%s\"", FST_PLUGIN->username); } } /* init node cache */ FST_PLUGIN->nodecache = fst_nodecache_create (); /* load nodes file, copy default if necessary */ copy_default_file ("nodes", "nodes"); filepath = gift_conf_path ("FastTrack/nodes"); i = fst_nodecache_load (plugin->nodecache, filepath); if (i < 0) FST_WARN_1 ("Couldn't find nodes file \"%s\". Fix that!", filepath); else FST_DBG_2 ("Loaded %d supernode addresses from nodes file \"%s\"", i, filepath); /* create list of banned ips */ FST_PLUGIN->banlist = fst_ipset_create (); /* load ban list, copy default if necessary */ copy_default_file ("banlist", "banlist"); filepath = gift_conf_path ("FastTrack/banlist"); i = fst_ipset_load (FST_PLUGIN->banlist, filepath); if(i < 0) FST_WARN_1 ("Couldn't find banlist \"%s\"", filepath); else FST_DBG_2 ("Loaded %d banned ip ranges from \"%s\"", i, filepath); /* attempt to start http server */ FST_PLUGIN->server = NULL; server_port = config_get_int (FST_PLUGIN->conf, "main/port=0"); if (server_port) { FST_PLUGIN->server = fst_http_server_create (server_port, fst_upload_process_request, fst_push_process_reply, NULL); if (!FST_PLUGIN->server) { FST_WARN_1 ("Couldn't bind to port %d. Http server not started.", server_port); } else { FST_DBG_1 ("Http server listening on port %d", server_port); } } else { FST_DBG ("Port set to zero. Http server not started."); } /* set session to NULL */ FST_PLUGIN->session = NULL; FST_PLUGIN->sessions = NULL; /* create discover */ FST_PLUGIN->discover = fst_udp_discover_create (fst_plugin_discover_callback); if (!FST_PLUGIN->discover) { FST_WARN ("Creation of udp discovery failed"); } /* init peers */ FST_PLUGIN->peers = dataset_new (DATASET_HASH); /* init searches */ FST_PLUGIN->searches = fst_searchlist_create(); /* init stats */ FST_PLUGIN->stats = fst_stats_create (); /* init push list */ FST_PLUGIN->pushlist = fst_pushlist_create (); /* get forwarded port from config file */ FST_PLUGIN->forwarding = config_get_int (FST_PLUGIN->conf, "main/forwarding=0"); FST_PLUGIN->local_ip = 0; FST_PLUGIN->external_ip = 0; /* make shares visible until giFT tells us otherwise */ FST_PLUGIN->hide_shares = FALSE; /* cache allow_sharing key */ FST_PLUGIN->allow_sharing = config_get_int (FST_PLUGIN->conf, "main/allow_sharing=0"); #if 0 /* * add some static nodes for faster startup * note: apparently fm2.imesh.com sends udp replies from different ips. * for security reasons we drop those. */ FST_DBG ("adding fm2.imesh.com:1214 as index node"); fst_nodecache_add (FST_PLUGIN->nodecache, NodeKlassIndex, "fm2.imesh.com", 1214, 0, time (NULL)); #endif /* start first connection */ fst_plugin_connect_next (); /* and periodically retry */ FST_PLUGIN->retry_timer = timer_add (60*SECONDS, fst_plugin_try_connect, NULL); return TRUE; }
bool replay_write(Replay *rpy, SDL_RWops *file, uint16_t version) { uint16_t base_version = (version & ~REPLAY_VERSION_COMPRESSION_BIT); bool compression = (version & REPLAY_VERSION_COMPRESSION_BIT); int i, j; SDL_RWwrite(file, replay_magic_header, sizeof(replay_magic_header), 1); SDL_WriteLE16(file, version); if(base_version >= REPLAY_STRUCT_VERSION_TS102000_REV0) { TaiseiVersion v; TAISEI_VERSION_GET_CURRENT(&v); if(taisei_version_write(file, &v) != TAISEI_VERSION_SIZE) { log_warn("Failed to write game version: %s", SDL_GetError()); return false; } } void *buf; SDL_RWops *abuf = NULL; SDL_RWops *vfile = file; if(compression) { abuf = SDL_RWAutoBuffer(&buf, 64); vfile = SDL_RWWrapZWriter(abuf, REPLAY_COMPRESSION_CHUNK_SIZE, false); } replay_write_string(vfile, config_get_str(CONFIG_PLAYERNAME), base_version); fix_flags(rpy); if(base_version >= REPLAY_STRUCT_VERSION_TS102000_REV1) { SDL_WriteLE32(vfile, rpy->flags); } SDL_WriteLE16(vfile, rpy->numstages); for(i = 0; i < rpy->numstages; ++i) { if(!replay_write_stage(rpy->stages + i, vfile, base_version)) { if(compression) { SDL_RWclose(vfile); SDL_RWclose(abuf); } return false; } } if(compression) { SDL_RWclose(vfile); SDL_WriteLE32(file, SDL_RWtell(file) + SDL_RWtell(abuf) + 4); SDL_RWwrite(file, buf, SDL_RWtell(abuf), 1); SDL_RWclose(abuf); vfile = SDL_RWWrapZWriter(file, REPLAY_COMPRESSION_CHUNK_SIZE, false); } for(i = 0; i < rpy->numstages; ++i) { ReplayStage *stg = rpy->stages + i; for(j = 0; j < stg->numevents; ++j) { if(!replay_write_stage_event(stg->events + j, vfile)) { if(compression) { SDL_RWclose(vfile); } return false; } } } if(compression) { SDL_RWclose(vfile); } // useless byte to simplify the premature EOF check, can be anything SDL_WriteU8(file, REPLAY_USELESS_BYTE); return true; }
void setup_renderer_car(Viewer *viewer, int render_priority) { RendererCar *self = (RendererCar*) calloc (1, sizeof (RendererCar)); Renderer *renderer = &self->renderer; renderer->draw = car_draw; renderer->destroy = car_free; renderer->widget = gtk_vbox_new(FALSE, 0); renderer->name = RENDERER_NAME; renderer->user = self; renderer->enabled = 1; EventHandler *ehandler = &self->ehandler; ehandler->name = RENDERER_NAME; ehandler->enabled = 1; ehandler->pick_query = pick_query; ehandler->key_press = key_press; ehandler->hover_query = pick_query; ehandler->mouse_press = mouse_press; ehandler->mouse_release = mouse_release; ehandler->mouse_motion = mouse_motion; ehandler->user = self; self->viewer = viewer; self->lc = globals_get_lcm (); self->config = globals_get_config (); self->pw = GTKU_PARAM_WIDGET(gtku_param_widget_new()); self->ctrans = globals_get_ctrans (); self->path = gu_ptr_circular_new (MAX_POSES, free_path_element, NULL); gtk_box_pack_start(GTK_BOX(renderer->widget), GTK_WIDGET(self->pw), TRUE, TRUE, 0); gtku_param_widget_add_booleans (self->pw, 0, PARAM_FOLLOW_POS, 1, NULL); gtku_param_widget_add_booleans (self->pw, 0, PARAM_FOLLOW_YAW, 0, NULL); char * model; char path[256]; if (config_get_str (self->config, "renderer_car.chassis_model", &model) == 0) { snprintf (path, sizeof (path), "%s/%s", MESH_MODEL_PATH, model); self->chassis_model = rwx_model_create (path); } if (config_get_str (self->config, "renderer_car.wheel_model", &model) == 0) { snprintf (path, sizeof (path), "%s/%s", MESH_MODEL_PATH, model); self->wheel_model = rwx_model_create (path); } if (self->chassis_model) gtku_param_widget_add_booleans (self->pw, 0, PARAM_NAME_BLING, 1, NULL); if (self->wheel_model) gtku_param_widget_add_booleans (self->pw, 0, PARAM_NAME_WHEELS, 1, NULL); self->max_draw_poses = 1000; gtku_param_widget_add_int (self->pw, PARAM_MAXPOSES, GTKU_PARAM_WIDGET_SLIDER, 0, MAX_POSES, 100, self->max_draw_poses); GtkWidget *find_button = gtk_button_new_with_label("Find"); gtk_box_pack_start(GTK_BOX(renderer->widget), find_button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(find_button), "clicked", G_CALLBACK (on_find_button), self); GtkWidget *clear_button = gtk_button_new_with_label("Clear path"); gtk_box_pack_start(GTK_BOX(renderer->widget), clear_button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(clear_button), "clicked", G_CALLBACK (on_clear_button), self); gtk_widget_show_all(renderer->widget); g_signal_connect (G_OBJECT (self->pw), "changed", G_CALLBACK (on_param_widget_changed), self); on_param_widget_changed(self->pw, "", self); ctrans_subscribe (self->ctrans, pose_listener, self); #ifdef USE_CANDECODE self->can = can_decode_new (self->lc); can_decode_subscribe (self->can, CAN_MSG_WHEELSPEEDS, on_wheelspeeds, self); can_decode_subscribe (self->can, CAN_MSG_STEERING_WHEEL, on_steering, self); can_decode_subscribe (self->can, CAN_MSG_SUSPENSION_HEIGHT, on_suspension, self); #endif viewer_add_renderer(viewer, &self->renderer, render_priority); viewer_add_event_handler(viewer, &self->ehandler, render_priority); self->footprint = config_util_get_vehicle_footprint (self->config); assert (self->footprint); g_signal_connect (G_OBJECT (viewer), "load-preferences", G_CALLBACK (on_load_preferences), self); g_signal_connect (G_OBJECT (viewer), "save-preferences", G_CALLBACK (on_save_preferences), self); }
/* * Main program logic */ int main(int argc, char **argv) { Config *config; Analysis *analysis; char *bkgd1_dir, *bkgd2_dir; SeqCoord *region; long len; int i, b1_int, b2_int, b_new, last_b, b_len; double uscale1, uscale2; BkgdReader *br1, *br2; FILE *out_fh; if(argc != 2) { fprintf(stderr, "usage: %s <config_file>\n", argv[0]); exit(2); } fprintf(stderr, "Reading config\n"); config = config_read_file(argv[1], CONFIG_MISSING_KEY_ERROR); analysis = analysis_new(config); bkgd1_dir = config_get_str(config, "BKGD1_DIR"); bkgd2_dir = config_get_str(config, "BKGD2_DIR"); /* get deleterious mutation rate rescale */ uscale1 = config_get_double(config, "BKGD1_USCALE"); uscale2 = config_get_double(config, "BKGD2_USCALE"); fprintf(stderr, "using uscale1=%g, uscale2=%g\n", uscale1, uscale2); while(analysis_next_region(analysis)) { region = analysis_get_region(analysis); fprintf(stderr, "chromosome %s\n", region->chr->name); len = region->end - region->start + 1; out_fh = get_output_fh(analysis); br1 = get_bkgd_reader(analysis, bkgd1_dir); br2 = get_bkgd_reader(analysis, bkgd2_dir); last_b = B_UNDEF; b_len = 0; for(i = 0; i < len; i++) { b1_int = bkgd_reader_get_pos(br1, i+1); b2_int = bkgd_reader_get_pos(br2, i+1); b_new = combine_bkgd(b1_int, uscale1, b2_int, uscale2); if(b_new == last_b) { b_len++; } else { if(b_len > 0) { fprintf(out_fh, "%d %d\n", last_b, b_len); } b_len = 1; last_b = b_new; } } /* write final region */ if(b_len > 0) { fprintf(out_fh, "%d %d\n", last_b, b_len); } bkgd_reader_free(br1); bkgd_reader_free(br2); } fprintf(stderr, "Freeing analysis\n"); analysis_free(analysis); fprintf(stderr, "Freeing config\n"); config_free(config); return 0; }