* zak_cgi_main_get_env:
* @zakcgimain:
*
- * Returns: a #GHashTable with all the environment variables.
+ * Returns: a #GHashTable with all the environment variables as #GValue.
*/
GHashTable
*zak_cgi_main_get_env (ZakCgiMain *zakcgimain)
guint i;
gchar **envs;
+ GValue *gval;
+
if (zakcgimain != NULL)
{
priv = ZAK_CGI_MAIN_GET_PRIVATE (zakcgimain);
for (i = 0; i < l; i++)
{
envs = g_strsplit (environ[i], "=", 2);
- g_hash_table_replace (ht, g_strdup (envs[0]), g_strdup (envs[1]));
+
+ gval = (GValue *)g_new0 (GValue, 1);
+ g_value_init (gval, G_TYPE_STRING);
+ g_value_take_string (gval, g_strdup (envs[1]));
+ g_hash_table_replace (ht, g_strdup (envs[0]), gval);
g_strfreev (envs);
}
while (g_hash_table_iter_next (&iter, &key, &value))
{
g_string_append_printf (str, "<tr><td>%s</td><td>%s</td></tr>\n",
- (gchar *)key, (gchar *)value);
+ (gchar *)key, g_value_get_string ((GValue *)value));
}
g_string_append_printf (str, "</table>\n");
int
main (int argc, char *argv[])
{
+ ZakCgiMain *zakcgimain;
gchar *env;
GString *str;
GHashTable *ht;
gchar *ret;
- env = zak_cgi_main_dump_env (NULL);
+ zakcgimain = zak_cgi_main_new ();
+ env = zak_cgi_main_dump_env (zakcgimain);
str = g_string_new ("<html>\n"
"<head><title>Environment variables</title></head>\n"
g_string_append_printf (str, "%s\n</body>", env);
g_free (env);
- env = zak_cgi_main_get_stdin (NULL);
+ env = zak_cgi_main_get_stdin (zakcgimain);
/*syslog (LOG_MAKEPRI(LOG_SYSLOG, LOG_DEBUG), "stdin: %s", env);*/
if (env != NULL)
{