Commit 8e968a03 8e968a037791bd9747853d1cdbcbd3e27b31d09b by Alain Magloire

url_pop.c include/private/url0.h include/public/url.h

No need for those bloated url_m*() functions.
url_pop parsing playing smart and nuking trailing '/'
1 parent 8b33f2c5
......@@ -55,29 +55,23 @@ struct _url
int (*_get_scheme) __P ((const url_t, char *scheme,
size_t len, size_t *n));
int (*_get_mscheme) __P ((const url_t, char **, size_t *n));
int (*_get_user) __P ((const url_t, char *user,
size_t len, size_t *n));
int (*_get_muser) __P ((const url_t, char **, size_t *n));
int (*_get_passwd) __P ((const url_t, char *passwd,
size_t len, size_t *n));
int (*_get_mpasswd) __P ((const url_t, char **, size_t *n));
int (*_get_host) __P ((const url_t, char *host,
size_t len, size_t *n));
int (*_get_mhost) __P ((const url_t, char **, size_t *n));
int (*_get_port) __P ((const url_t, long *port));
int (*_get_path) __P ((const url_t, char *path,
size_t len, size_t *n));
int (*_get_mpath) __P ((const url_t, char **, size_t *n));
int (*_get_query) __P ((const url_t, char *query,
size_t len, size_t *n));
int (*_get_mquery) __P ((const url_t, char **, size_t *n));
};
......
......@@ -43,29 +43,23 @@ extern int url_get_id __P ((const url_t, int *id));
extern int url_get_scheme __P ((const url_t, char *sch,
size_t, size_t *));
extern int url_get_mscheme __P ((const url_t, char **, size_t *));
extern int url_get_user __P ((const url_t, char *usr,
size_t, size_t *));
extern int url_get_muser __P ((const url_t, char **, size_t *));
extern int url_get_passwd __P ((const url_t, char *passwd,
size_t, size_t *));
extern int url_get_mpasswd __P ((const url_t, char **, size_t *));
extern int url_get_host __P ((const url_t, char *host,
size_t, size_t *));
extern int url_get_mhost __P ((const url_t, char **, size_t *));
extern int url_get_port __P ((const url_t, long *port));
extern int url_get_path __P ((const url_t, char *path,
size_t, size_t *));
extern int url_get_mpath __P ((const url_t, char **, size_t *));
extern int url_get_query __P ((const url_t, char *qeury,
size_t, size_t *));
extern int url_get_mquery __P ((const url_t, char **, size_t *));
#ifdef __cplusplus
}
......
......@@ -138,7 +138,10 @@ url_pop_create (url_t *purl, const char *name)
}
/* HOST:PORT */
indexe = strchr (++host_port, ':');
if (*host_port == '@')
host_port++;
indexe = strchr (host_port, ':');
if (indexe == NULL)
{
url->host = strdup (host_port);
......@@ -161,6 +164,13 @@ url_pop_create (url_t *purl, const char *name)
url_pop_destroy (&url);
return ENOMEM;
}
else
{
/* playing smart and nuking any trailing slashes on the host */
size_t len = strlen (url->host);
if (url->host[len - 1] == '/')
url->host[len - 1] = '\0'; /* leak a bit */
}
*purl = url;
return 0;
......