#include <stdio.h>
#include <stdlib.h>
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
-#include <sys/types.h>
+#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "url.h"
#include "host.h" /* for is_valid_ipv6_address */
-#ifndef errno
-extern int errno;
-#endif
-
struct scheme_data
{
const char *name;
/* Forward declarations: */
-static int path_simplify PARAMS ((char *));
+static int path_simplify (char *);
\f
/* Support for escaping and unescaping of URL strings. */
return allow_passthrough ? (char *)s : xstrdup (s);
newlen = (p1 - s) + addition;
- newstr = (char *)xmalloc (newlen + 1);
+ newstr = xmalloc (newlen + 1);
p1 = s;
p2 = newstr;
}
}
\f
-static void split_path PARAMS ((const char *, char **, char **));
+static void split_path (const char *, char **, char **);
/* Like strpbrk, with the exception that it returns the pointer to the
terminating zero (end-of-string aka "eos") if no matching character
help because the check for literal accept is in the
preprocessor.) */
-#ifdef __GNUC__
+#if defined(__GNUC__) && __GNUC__ >= 3
#define strpbrk_or_eos(s, accept) ({ \
char *SOE_p = strpbrk (s, accept); \
SOE_p; \
})
-#else /* not __GNUC__ */
+#else /* not __GNUC__ or old gcc */
static inline char *
strpbrk_or_eos (const char *s, const char *accept)
p = strchr (s, '\0');
return p;
}
-#endif /* not __GNUC__ */
+#endif /* not __GNUC__ or old gcc */
/* Turn STR into lowercase; return non-zero if a character was
actually changed. */
if (scheme == SCHEME_INVALID)
{
error_code = PE_UNSUPPORTED_SCHEME;
- goto err;
+ goto error;
}
url_encoded = reencode_escapes (url);
if (!host_e)
{
error_code = PE_UNTERMINATED_IPV6_ADDRESS;
- goto err;
+ goto error;
}
#ifdef ENABLE_IPV6
if (!is_valid_ipv6_address(host_b, host_e))
{
error_code = PE_INVALID_IPV6_ADDRESS;
- goto err;
+ goto error;
}
/* Continue parsing after the closing ']'. */
p = host_e + 1;
#else
error_code = PE_IPV6_NOT_SUPPORTED;
- goto err;
+ goto error;
#endif
}
else
if (host_b == host_e)
{
error_code = PE_EMPTY_HOST;
- goto err;
+ goto error;
}
port = scheme_default_port (scheme);
/* http://host:12randomgarbage/blah */
/* ^ */
error_code = PE_BAD_PORT_NUMBER;
- goto err;
+ goto error;
}
port = 10 * port + (*pp - '0');
/* Check for too large port numbers here, before we have
if (port > 65535)
{
error_code = PE_BAD_PORT_NUMBER;
- goto err;
+ goto error;
}
}
}
if (!parse_credentials (uname_b, uname_e - 1, &user, &passwd))
{
error_code = PE_INVALID_USER_NAME;
- goto err;
+ goto error;
}
}
return u;
- err:
+ error:
/* Cleanup in case of error: */
if (url_encoded && url_encoded != url)
xfree (url_encoded);
url_full_path (const struct url *url)
{
int length = full_path_length (url);
- char *full_path = (char *) xmalloc (length + 1);
+ char *full_path = xmalloc (length + 1);
full_path_write (url, full_path);
full_path[length] = '\0';
start_insert = base;
span = start_insert - base;
- merge = (char *)xmalloc (span + linklength + 1);
+ merge = xmalloc (span + linklength + 1);
if (span)
memcpy (merge, base, span);
memcpy (merge + span, link, linklength);
start_insert = slash;
span = start_insert - base;
- merge = (char *)xmalloc (span + linklength + 1);
+ merge = xmalloc (span + linklength + 1);
if (span)
memcpy (merge, base, span);
memcpy (merge + span, link, linklength);
}
span = start_insert - base;
- merge = (char *)xmalloc (span + linklength + 1);
+ merge = xmalloc (span + linklength + 1);
if (span)
memcpy (merge, base, span);
if (need_explicit_slash)