From: Andrea Zagli Date: Sun, 9 Aug 2015 06:35:37 +0000 (+0200) Subject: ZakCgiMain::get_cookies now returns GValue. X-Git-Tag: v0.1.0~19^2~4 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=b523d7bf228f967bd49209590ca45752b5dfc168;p=libzakcgi ZakCgiMain::get_cookies now returns GValue. --- diff --git a/src/main.c b/src/main.c index c529d80..ec03e8d 100644 --- a/src/main.c +++ b/src/main.c @@ -292,6 +292,7 @@ GHashTable gchar *cookies; gchar **strv_cookies; gchar **parts; + GValue *gval; if (zakcgimain != NULL) { @@ -317,7 +318,10 @@ GHashTable for (i = 0; i < l; i++) { parts = g_strsplit (strv_cookies[i], "=", 2); - g_hash_table_replace (ht, g_strstrip (g_strdup (parts[0])), g_strstrip (g_strdup (parts[1]))); + gval = (GValue *)g_new0 (GValue, 1); + g_value_init (gval, G_TYPE_STRING); + g_value_take_string (gval, g_strstrip (g_strdup (parts[1]))); + g_hash_table_replace (ht, g_strstrip (g_strdup (parts[0])), gval); g_strfreev (parts); } } @@ -355,7 +359,7 @@ gchar while (g_hash_table_iter_next (&iter, &key, &value)) { g_string_append_printf (str, "%s%s\n", - (gchar *)key, (gchar *)value); + (gchar *)key, g_value_get_string ((GValue *)value)); } g_string_append_printf (str, "\n"); diff --git a/tests/cookies.c b/tests/cookies.c index 732d777..9843ed0 100644 --- a/tests/cookies.c +++ b/tests/cookies.c @@ -26,12 +26,14 @@ int main (int argc, char *argv[]) { + ZakCgiMain *zakcgimain; gchar *env; GString *str; GString *header; GHashTable *ht; - env = zak_cgi_main_dump_cookies (NULL); + zakcgimain = zak_cgi_main_new (); + env = zak_cgi_main_dump_cookies (zakcgimain); str = g_string_new ("\n" "Cookies\n"