return error;
}
+static int urldup(void)
+{
+ const char *url[] = {
+ "http://"
+ "user:pwd@"
+ "[2a04:4e42:e00::347%25eth0]"
+ ":80"
+ "/path"
+ "?query"
+ "#fraggie",
+ "https://example.com",
+ "https://user@example.com",
+ "https://user.pwd@example.com",
+ "https://user.pwd@example.com:1234",
+ "https://example.com:1234",
+ "example.com:1234",
+ "https://user.pwd@example.com:1234/path?query#frag",
+ NULL
+ };
+ CURLU *copy = NULL;
+ char *h_str = NULL, *copy_str = NULL;
+ CURLU *h = curl_url();
+ int i;
+
+ if(!h)
+ goto err;
+
+ for(i = 0; url[i]; i++) {
+ CURLUcode rc = curl_url_set(h, CURLUPART_URL, url[i],
+ CURLU_GUESS_SCHEME);
+ if(rc)
+ goto err;
+ copy = curl_url_dup(h);
+
+ rc = curl_url_get(h, CURLUPART_URL, &h_str, 0);
+ if(rc)
+ goto err;
+
+ rc = curl_url_get(copy, CURLUPART_URL, ©_str, 0);
+ if(rc)
+ goto err;
+
+ if(strcmp(h_str, copy_str)) {
+ printf("Original: %s\nParsed: %s\nCopy: %s\n",
+ url[i], h_str, copy_str);
+ goto err;
+ }
+ curl_free(copy_str);
+ curl_free(h_str);
+ curl_url_cleanup(copy);
+ copy_str = NULL;
+ h_str = NULL;
+ copy = NULL;
+ }
+ curl_url_cleanup(h);
+ return 0;
+err:
+ curl_free(copy_str);
+ curl_free(h_str);
+ curl_url_cleanup(copy);
+ curl_url_cleanup(h);
+ return 1;
+}
+
int test(char *URL)
{
(void)URL; /* not used */
+ if(urldup())
+ return 11;
+
if(setget_parts())
return 10;