return g_hash_table_ref (priv->ht_env);
}
}
-
+
ht = g_hash_table_new (g_str_hash, g_str_equal);
if (zakcgimain != NULL)
{
if (priv->ht_cookies != NULL)
{
return g_hash_table_ref (priv->ht_cookies);
- }
+ }
}
ht = g_hash_table_new (g_str_hash, g_str_equal);
if (zakcgimain != NULL)
guint l;
GValue *gval;
+ GPtrArray *ar;
ht = NULL;
-
+
if (zakcgimain != NULL)
{
priv = ZAK_CGI_MAIN_GET_PRIVATE (zakcgimain);
if (priv->ht_parameters != NULL)
{
ht = g_hash_table_ref (priv->ht_parameters);
- }
+ }
}
if (ht == NULL)
l = g_strv_length (params);
for (i = 0; i < l; i++)
{
- gval = g_new0 (GValue, 1);
-
parts = g_strsplit (params[i], "=", 2);
- g_value_init (gval, G_TYPE_STRING);
- g_value_set_string (gval, g_strdup (parts[1] == NULL ? "" : parts[1]));
+ gval = (GValue *)g_hash_table_lookup (ht, parts[0]);
+ if (gval != NULL)
+ {
+ if (!G_VALUE_HOLDS (gval, G_TYPE_BOXED))
+ {
+ /* convert to GPtrArray */
+ ar = g_ptr_array_new ();
+
+ g_ptr_array_add (ar, g_strdup (g_value_get_string (gval)));
+ g_value_unset (gval);
- g_hash_table_replace (ht, g_strdup (parts[0]), gval);
- g_strfreev (parts);
+ g_value_init (gval, G_TYPE_PTR_ARRAY);
+ g_value_take_boxed (gval, ar);
+ g_hash_table_replace (ht, g_strdup (parts[0]), gval);
+ }
+ else
+ {
+ ar = (GPtrArray *)g_value_get_boxed (gval);
+ }
+ g_ptr_array_add (ar, g_strdup (parts[1] == NULL ? "" : parts[1]));
+ }
+ else
+ {
+ gval = g_new0 (GValue, 1);
+
+ g_value_init (gval, G_TYPE_STRING);
+ g_value_set_string (gval, g_strdup (parts[1] == NULL ? "" : parts[1]));
+
+ g_hash_table_replace (ht, g_strdup (parts[0]), gval);
+ g_strfreev (parts);
+ }
}
+ g_strfreev (params);
return ht;
}
gchar *ret;
ZakCgiMainPrivate *priv;
-
+
const gchar *env;
guint l;
gsize bytesread;
{
priv->stdin = g_strdup (ret);
}
-
+
return ret;
}
{
/* read line */
line = zak_cgi_main_read_line (buf, l, &i, TRUE, &bytesread);
- syslog (LOG_MAKEPRI(LOG_SYSLOG, LOG_DEBUG), "boundary: %s %d", line, bytesread);
if (g_strcmp0 (line, _boundary) == 0)
{
/* content-disposition */
GValue *gval;
content_disposition = zak_cgi_main_read_line (buf, l, &i, TRUE, &bytesread);
- syslog (LOG_MAKEPRI(LOG_SYSLOG, LOG_DEBUG), "content_disposition: %s", content_disposition);
v_content = g_strsplit (content_disposition, ";", -1);
l_v_content = g_strv_length (v_content);
parts = g_strsplit (v_content[2], "=", 2);
param_name_file = g_strndup (parts[1] + 1, strlen (parts[1]) - 2);
param_name_file[strlen (parts[1]) - 2] = '\0';
- syslog (LOG_MAKEPRI(LOG_SYSLOG, LOG_DEBUG), "param_name_file: %s", param_name_file);
g_strfreev (parts);
/* content-type */
content_type = zak_cgi_main_read_line (buf, l, &i, TRUE, &bytesread);
- syslog (LOG_MAKEPRI(LOG_SYSLOG, LOG_DEBUG), "content_type: %s", content_type);
g_free (content_type);
}
do
{
tmp = zak_cgi_main_read_line (buf, l, &i, FALSE, &bytesread);
- syslog (LOG_MAKEPRI(LOG_SYSLOG, LOG_DEBUG), "tmp: %s %d", tmp, bytesread);
if (memcmp (tmp, _boundary, strlen (_boundary)) == 0)
{
else
{
param_value = zak_cgi_main_read_line (buf, l, &i, TRUE, &bytesread);
- syslog (LOG_MAKEPRI(LOG_SYSLOG, LOG_DEBUG), "param_value: %s", param_value);
}
gval = g_new0 (GValue, 1);
g_free (line);
} while (i < l);
-
+
g_free (_boundary);
}
-
+
return ht;
}
g_hash_table_iter_init (&iter, ht_env);
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 *)g_value_get_string ((GValue *)value));
+ if (G_VALUE_HOLDS ((GValue *)value, G_TYPE_BOXED))
+ {
+ guint i;
+ GPtrArray *ar = (GPtrArray *)g_value_get_boxed ((GValue *)value);
+ for (i = 0; i < ar->len; i++)
+ {
+ g_string_append_printf (str,
+ "<tr><td>%s[%d]</td><td>%s</td></tr>\n",
+ (gchar *)key,
+ i,
+ (gchar *)g_ptr_array_index (ar, i));
+ }
+ }
+ else
+ {
+ g_string_append_printf (str,
+ "<tr><td>%s</td><td>%s</td></tr>\n",
+ (gchar *)key,
+ (gchar *)g_value_get_string ((GValue *)value));
+ }
}
g_string_append_printf (str, "</table>\n");
return 0;
}
-