1 $NetBSD: patch-cb,v 1.3 2009/12/01 08:49:46 manu Exp $
2 --- lasso/xml/tools.c.orig 2009-11-30 18:38:05.000000000 +0100
3 +++ lasso/xml/tools.c 2009-11-30 18:39:45.000000000 +0100
10 + * lasso_url_add_parameters:
11 + * @url: the original URL
12 + * @free: whether to free the URL parameter
13 + * @...: pairs of strings, key, value, followed by NULL
15 + * Iterate over all pairs of key,value, and concatenate them to @url encoded as "&key=value", where
16 + * key and value are url-encoded.
17 + * If free is true and at least one pair was given, url is freed. If url is NULL, the first
18 + * ampersand is omitted.
20 + * Return value: a newly allocated string, or url.
23 +lasso_url_add_parameters(char *url,
26 + char *old_url = url, *new_url;
27 + xmlChar *encoded_key, *encoded_value;
37 + key = va_arg(ap, char*);
41 + encoded_key = xmlURIEscapeStr((xmlChar*)key, NULL);
42 + goto_cleanup_if_fail_with_rc(encoded_key, 0);
44 + value = va_arg(ap, char*);
46 + message(G_LOG_LEVEL_CRITICAL, "lasso_url_add_parameter: key without a value !!");
49 + encoded_value = xmlURIEscapeStr((xmlChar*)value, NULL);
50 + goto_cleanup_if_fail_with_rc(encoded_value, 0);
53 + new_url = g_strdup_printf("%s&%s=%s", old_url, (char*)encoded_key, (char*)encoded_value);
55 + new_url = g_strdup_printf("%s=%s", (char*)encoded_key, (char*)encoded_value);
57 + if (old_url != url) {
58 + lasso_release_string(old_url);
62 + lasso_release_xml_string(encoded_key);
63 + lasso_release_xml_string(encoded_value);
67 + if (free && new_url != url) {
70 + lasso_release_xml_string(encoded_key);