static int fileinfo_data_cmp_func(GtkTreeModel *unused_model, GtkTreeIter *a, GtkTreeIter *b, void *user_data) { (void) unused_model; return fileinfo_data_cmp(get_fileinfo_data(a), get_fileinfo_data(b), pointer_to_uint(user_data)); }
void on_directory_chooser_response(GtkDialog *dialog, int response_id, void *user_data) { if (GTK_RESPONSE_ACCEPT == response_id) { enum dir_choice dir_choice = pointer_to_uint(user_data); char *pathname; pathname = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); directory_chooser_handle_result(dir_choice, pathname); G_FREE_NULL(pathname); } gtk_widget_destroy(GTK_WIDGET(dialog)); directory_chooser = NULL; }
/** * Remove search handle from the hash table. */ static void sqh_remove(squeue_t *sq, gnet_search_t sh) { const void *key; bool found; g_assert(sq != NULL); found = hset_contains_extended(sq->handles, uint_to_pointer(sh), &key); g_assert(found); g_assert((gnet_search_t) pointer_to_uint(key) == sh); hset_remove(sq->handles, key); }
/** * Watcher callback, invoked when the file from which we read the * geographic IP mappings changed. */ static void gip_changed(const char *filename, void *idx_ptr) { FILE *f; char buf[80]; uint count; unsigned idx = pointer_to_uint(idx_ptr); f = file_fopen(filename, "r"); if (f == NULL) return; count = gip_load(f, idx); fclose(f); str_bprintf(buf, sizeof buf, "Reloaded %u geographic IPv%c ranges.", count, GIP_IPV4 == idx ? '4' : '6'); gcu_statusbar_message(buf); }
/** * Are specified flags all set for the country to which the IP address belongs? */ bool ctl_limit(const host_addr_t ha, unsigned flags) { uint16 code; unsigned cflags; /* * Early optimization to avoid paying the price of gip_country_safe(): * If no flags are given, or the set of flags requested is not a subset * of all the flags ever specified for all countries, we can return. */ if (0 == flags) return FALSE; if ((flags & ctl_all_flags) != flags) return FALSE; code = gip_country_safe(ha); if (ISO3166_INVALID == code) return FALSE; if (GNET_PROPERTY(ancient_version)) return FALSE; cflags = pointer_to_uint( htable_lookup(ctl_by_country, uint_to_pointer(code))); if ((cflags & flags) != flags) return FALSE; if ((cflags & CTL_D_WHITELIST) && whitelist_check(ha)) return FALSE; return TRUE; }
static void render_sources(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *unused_model, GtkTreeIter *iter, void *udata) { struct download *d; enum c_src idx; (void) unused_model; if (!gtk_tree_view_column_get_visible(column)) return; d = get_source(iter); g_return_if_fail(d); idx = pointer_to_uint(udata); if (c_src_progress == idx) { unsigned value = fi_gui_source_get_progress(d); g_object_set(cell, "value", value, (void *) 0); } else { const char *text = fi_gui_source_column_text(d, idx); g_object_set(cell, "text", text, (void *) 0); } }
static void render_files(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *unused_model, GtkTreeIter *iter, void *udata) { const struct fileinfo_data *file; enum c_fi idx; (void) unused_model; if (!gtk_tree_view_column_get_visible(column)) return; file = get_fileinfo_data(iter); g_return_if_fail(file); idx = pointer_to_uint(udata); if (c_fi_progress == idx) { unsigned value = fi_gui_file_get_progress(file); g_object_set(cell, "value", value, (void *) 0); } else { const char *text = fi_gui_file_column_text(file, idx); g_object_set(cell, "text", text, (void *) 0); } }
/** * Parse a list entry. * @return TRUE when done with input. */ static bool ctl_parse_list_entry(struct ctl_string *s) { struct ctl_tok *tok = ctl_next_token(s); GSList *countries = NULL; GSList *sl; char *opt = NULL; unsigned flags; bool done = FALSE; switch (tok->type) { case CTL_TOK_EOF: done = TRUE; goto out; case CTL_TOK_ID: countries = ctl_parse_country(s, tok); break; case CTL_TOK_LBRACE: countries = ctl_parse_countries(s); break; default: ctl_error(s, tok, "'{' or country"); goto out; } if (NULL == countries) goto out; /* * Check presence of options */ ctl_token_free_null(&tok); tok = ctl_next_token(s); switch (tok->type) { case CTL_TOK_EOF: case CTL_TOK_COMMA: ctl_unread(s, &tok); break; case CTL_TOK_COLON: opt = ctl_parse_options(s); break; default: ctl_error(s, tok, "',' or ':' or EOF"); goto out; } /* * Compute flags. */ if (NULL == opt) { flags = ctl_get_flags('a'); } else { char *p = opt; char c; flags = 0; while ((c = *p++)) { unsigned f = ctl_get_flags(c); if (0 == f) g_warning("CTL ignoring unknown option '%c'", c); flags |= f; } } /* * Handle the country list in countries with options in opt. * Nevermind superseding, the latest parsed is the winner. */ GM_SLIST_FOREACH(countries, sl) { unsigned code = pointer_to_uint(sl->data); htable_insert(ctl_by_country, uint_to_pointer(code), uint_to_pointer(flags)); ctl_all_flags |= flags; if (GNET_PROPERTY(ctl_debug)) { g_debug("CTL %s => '%s' (%s)", iso3166_country_cc(code), ctl_flags2str(flags), iso3166_country_name(code)); } }