#endif
} SoupNTLMConnection;
+static void free_ntlm_connection (SoupNTLMConnection *conn);
+
typedef struct {
gboolean use_ntlm;
SoupAuthManagerNTLMPrivate *priv =
SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (ntlm);
- priv->connections_by_id = g_hash_table_new (NULL, NULL);
+ priv->connections_by_id = g_hash_table_new_full (NULL, NULL, NULL,
+ (GDestroyNotify)free_ntlm_connection);
priv->connections_by_msg = g_hash_table_new (NULL, NULL);
#ifdef USE_NTLM_AUTH
priv->ntlm_auth_accessible = (access (NTLM_AUTH, X_OK) == 0);
}
static void
-free_ntlm_connection_foreach (gpointer key, gpointer value, gpointer user_data)
-{
- free_ntlm_connection (value);
-}
-
-static void
finalize (GObject *object)
{
SoupAuthManagerNTLMPrivate *priv =
SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (object);
- g_hash_table_foreach (priv->connections_by_id,
- free_ntlm_connection_foreach, NULL);
g_hash_table_destroy (priv->connections_by_id);
g_hash_table_destroy (priv->connections_by_msg);
delete_conn (SoupSocket *socket, gpointer user_data)
{
SoupAuthManagerNTLMPrivate *priv = user_data;
- SoupNTLMConnection *conn;
- conn = g_hash_table_lookup (priv->connections_by_id, socket);
- if (conn)
- free_ntlm_connection (conn);
g_hash_table_remove (priv->connections_by_id, socket);
g_signal_handlers_disconnect_by_func (socket, delete_conn, priv);
}
GHashTable *auths; /* scheme:realm -> SoupAuth */
} SoupAuthHost;
+static void soup_auth_host_free (SoupAuthHost *host);
+
static void
soup_auth_manager_init (SoupAuthManager *manager)
{
SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager);
priv->auth_types = g_ptr_array_new ();
- priv->auth_hosts = g_hash_table_new (soup_uri_host_hash,
- soup_uri_host_equal);
-}
-
-static gboolean
-foreach_free_host (gpointer key, gpointer value, gpointer data)
-{
- SoupAuthHost *host = value;
-
- if (host->auth_realms)
- soup_path_map_free (host->auth_realms);
- if (host->auths)
- g_hash_table_destroy (host->auths);
-
- soup_uri_free (host->uri);
- g_slice_free (SoupAuthHost, host);
-
- return TRUE;
+ priv->auth_hosts = g_hash_table_new_full (soup_uri_host_hash,
+ soup_uri_host_equal,
+ NULL,
+ (GDestroyNotify)soup_auth_host_free);
}
static void
g_type_class_unref (priv->auth_types->pdata[i]);
g_ptr_array_free (priv->auth_types, TRUE);
- g_hash_table_foreach_remove (priv->auth_hosts, foreach_free_host, NULL);
g_hash_table_destroy (priv->auth_hosts);
if (priv->proxy_auth)
return host;
}
+static void
+soup_auth_host_free (SoupAuthHost *host)
+{
+ if (host->auth_realms)
+ soup_path_map_free (host->auth_realms);
+ if (host->auths)
+ g_hash_table_destroy (host->auths);
+
+ soup_uri_free (host->uri);
+ g_slice_free (SoupAuthHost, host);
+}
+
static SoupAuth *
lookup_auth (SoupAuthManagerPrivate *priv, SoupMessage *msg)
{
append_form_encoded (str, value);
}
-static void
-hash_encode_foreach (gpointer name, gpointer value, gpointer str)
-{
- encode_pair (str, name, value);
-}
-
/**
* soup_form_encode:
* @first_field: name of the first form field
soup_form_encode_hash (GHashTable *form_data_set)
{
GString *str = g_string_new (NULL);
+ GHashTableIter iter;
+ gpointer name, value;
- g_hash_table_foreach (form_data_set, hash_encode_foreach, str);
+ 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);
}
}
static void
-gather_conns (gpointer key, gpointer host, gpointer data)
-{
- SoupConnection *conn = key;
- GSList **conns = data;
-
- *conns = g_slist_prepend (*conns, g_object_ref (conn));
-}
-
-static void
flush_queue (SoupSession *session)
{
SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session);
{
SoupSessionPrivate *priv;
GSList *conns, *c;
+ GHashTableIter iter;
+ gpointer conn, host;
g_return_if_fail (SOUP_IS_SESSION (session));
priv = SOUP_SESSION_GET_PRIVATE (session);
/* Close all connections */
g_mutex_lock (&priv->host_lock);
conns = NULL;
- g_hash_table_foreach (priv->conns, gather_conns, &conns);
-
+ g_hash_table_iter_init (&iter, priv->conns);
+ while (g_hash_table_iter_next (&iter, &conn, &host))
+ conns = g_slist_prepend (conns, g_object_ref (conn));
g_mutex_unlock (&priv->host_lock);
+
for (c = conns; c; c = c->next) {
soup_connection_disconnect (c->data);
g_object_unref (c->data);
static gboolean insert_value (xmlNode *parent, GValue *value);
-static void
-insert_member (gpointer name, gpointer value, gpointer data)
-{
- xmlNode *member, **struct_node = data;
-
- if (!*struct_node)
- return;
-
- member = xmlNewChild (*struct_node, NULL,
- (const xmlChar *)"member", NULL);
- xmlNewTextChild (member, NULL,
- (const xmlChar *)"name", (const xmlChar *)name);
- if (!insert_value (member, value)) {
- xmlFreeNode (*struct_node);
- *struct_node = NULL;
- }
-}
-
static gboolean
insert_value (xmlNode *parent, GValue *value)
{
g_free (encoded);
} else if (type == G_TYPE_HASH_TABLE) {
GHashTable *hash = g_value_get_boxed (value);
- xmlNode *struct_node;
+ GHashTableIter iter;
+ gpointer mname, mvalue;
+ xmlNode *struct_node, *member;
struct_node = xmlNewChild (xvalue, NULL,
(const xmlChar *)"struct", NULL);
- g_hash_table_foreach (hash, insert_member, &struct_node);
+
+ g_hash_table_iter_init (&iter, hash);
+
+ while (g_hash_table_iter_next (&iter, &mname, &mvalue)) {
+ member = xmlNewChild (struct_node, NULL,
+ (const xmlChar *)"member", NULL);
+ xmlNewTextChild (member, NULL,
+ (const xmlChar *)"name",
+ (const xmlChar *)mname);
+ if (!insert_value (member, mvalue)) {
+ xmlFreeNode (struct_node);
+ struct_node = NULL;
+ break;
+ }
+ }
+
if (!struct_node)
return FALSE;
#ifdef G_GNUC_BEGIN_IGNORE_DEPRECATIONS