/** * soup_form_encode_hash: * @form_data_set: (element-type utf8 utf8): a hash table containing * name/value pairs (as strings) * * Encodes @form_data_set into a value of type * "application/x-www-form-urlencoded", as defined in the HTML 4.01 * spec. * * Note that the HTML spec states that "The control names/values are * listed in the order they appear in the document." Since this method * takes a hash table, it cannot enforce that; if you care about the * ordering of the form fields, use soup_form_encode_datalist(). * * Return value: the encoded form **/ char * soup_form_encode_hash (GHashTable *form_data_set) { GString *str = g_string_new (NULL); GHashTableIter iter; gpointer name, value; g_hash_table_iter_init (&iter, form_data_set); while (g_hash_table_iter_next (&iter, &name, &value)) encode_pair (str, name, value); return g_string_free (str, FALSE); }
/** * soup_form_encode_valist: * @first_field: name of the first form field * @args: pointer to additional values, as in soup_form_encode() * * See soup_form_encode(). This is mostly an internal method, used by * various other methods such as soup_uri_set_query_from_fields() and * soup_form_request_new(). * * Return value: the encoded form **/ char * soup_form_encode_valist (const char *first_field, va_list args) { GString *str = g_string_new (NULL); const char *name, *value; name = first_field; value = va_arg (args, const char *); while (name && value) { encode_pair (str, name, value); name = va_arg (args, const char *); if (name) value = va_arg (args, const char *); } return g_string_free (str, FALSE); }
static void datalist_encode_foreach (GQuark key_id, gpointer value, gpointer str) { encode_pair (str, g_quark_to_string (key_id), value); }
static void hash_encode_foreach (gpointer name, gpointer value, gpointer str) { encode_pair (str, name, value); }