static inline void magnet_append_item(str_t *s, bool escape_value, const char *key, const char *value) { g_return_if_fail(s); g_return_if_fail(key); g_return_if_fail(value); if (0 == str_len(s)) { str_cat(s, "magnet:?"); } else { str_putc(s, '&'); } str_cat(s, key); str_putc(s, '='); if (escape_value) { char *escaped; escaped = url_escape_query(value); str_cat(s, escaped); if (escaped != value) { HFREE_NULL(escaped); } } else { str_cat(s, value); } }
PSLIST_FOREACH(info, sl) { cq_info_t *cqi = sl->data; cq_info_check(cqi); if (THREAD_INVALID_ID == cqi->stid) str_printf(s, "%-2s ", "-"); else str_printf(s, "%-2d ", cqi->stid); str_catf(s, "%-6zu ", cqi->event_count); str_catf(s, "%-4zu ", cqi->periodic_count); str_catf(s, "%-4zu ", cqi->idle_count); str_catf(s, "%-5s ", 0 == cqi->last_idle ? "-" : compact_time(delta_time(tm_time(), cqi->last_idle))); str_catf(s, "%'6d ", cqi->period); str_catf(s, "%10zu ", cqi->heartbeat_count); str_catf(s, "%10zu ", cqi->triggered_count); str_catf(s, "\"%s\"%*s", cqi->name, (int) (maxlen - vstrlen(cqi->name)), ""); if (cqi->parent != NULL) str_catf(s, " (%s)", cqi->parent); str_putc(s, '\n'); shell_write(sh, str_2c(s)); }
/** * Add continuation line to the `headers' hash for specified field name. * A private copy of the data is made. */ static void add_continuation(header_t *o, const char *field, const char *text) { str_t *v; header_check(o); g_assert(o->headers); v = htable_lookup(o->headers, field); g_assert(v != NULL); str_putc(v, ' '); str_cat(v, text); }
/** * @return A halloc()ed string. */ static char * proxy_sequence_to_string(const sequence_t *s) { str_t *str; str = str_new(0); if (!sequence_is_empty(s)) { sequence_iter_t *iter; iter = sequence_forward_iterator(s); while (sequence_iter_has_next(iter)) { gnet_host_t *host = sequence_iter_next(iter); str_putc(str, ':'); str_cat(str, gnet_host_to_string(host)); } sequence_iterator_release(&iter); } return str_s2c_null(&str); }
void on_button_config_remove_dir_clicked(GtkButton *unused_button, gpointer unused_udata) { GtkTreeView *tv; GtkTreeModel *model; GtkTreeIter iter; GtkTreeSelection *selection; str_t *s; (void) unused_button; (void) unused_udata; tv = GTK_TREE_VIEW(gui_dlg_prefs_lookup("treeview_shared_dirs")); model = gtk_tree_view_get_model(tv); if (!gtk_tree_model_get_iter_first(model, &iter)) return; /* Regenerate the string property holding a list of paths */ selection = gtk_tree_view_get_selection(tv); s = str_new(0); do { gchar *dir = NULL; /* Skip items selected for removal */ if (gtk_tree_selection_iter_is_selected(selection, &iter)) continue; gtk_tree_model_get(model, &iter, 0, &dir, (-1)); if (str_len(s) > 0) str_putc(s, ':'); str_cat(s, dir); G_FREE_NULL(dir); } while (gtk_tree_model_iter_next(model, &iter)); gnet_prop_set_string(PROP_SHARED_DIRS_PATHS, str_2c(s)); str_destroy(s); }