new functions
2001-10-02 Rodrigo Moya <rodrigo@ximian.com> * e-url.[ch] (e_uri_copy, e_uri_to_string): new functions svn path=/trunk/; revision=13301
This commit is contained in:
committed by
Rodrigo Moya
parent
7e61b6213f
commit
8828ff2fa3
@ -1,3 +1,7 @@
|
||||
2001-10-02 Rodrigo Moya <rodrigo@ximian.com>
|
||||
|
||||
* e-url.[ch] (e_uri_copy, e_uri_to_string): new functions
|
||||
|
||||
2001-10-01 Rodrigo Moya <rodrigo@ximian.com>
|
||||
|
||||
* e-url.[ch]: added basic URI management functions
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "e-url.h"
|
||||
|
||||
@ -261,3 +262,65 @@ e_uri_get_param (EUri *uri, const char *name)
|
||||
{
|
||||
return g_datalist_get_data (&uri->params, name);
|
||||
}
|
||||
|
||||
EUri *
|
||||
e_uri_copy (EUri *uri)
|
||||
{
|
||||
EUri *uri_copy;
|
||||
|
||||
g_return_val_if_fail (uri != NULL, NULL);
|
||||
|
||||
uri_copy = g_new0 (EUri, 1);
|
||||
uri_copy->protocol = g_strdup (uri->protocol);
|
||||
uri_copy->user = g_strdup (uri->user);
|
||||
uri_copy->authmech = g_strdup (uri->authmech);
|
||||
uri_copy->passwd = g_strdup (uri->passwd);
|
||||
uri_copy->host = g_strdup (uri->host);
|
||||
uri_copy->port = uri->port;
|
||||
uri_copy->path = g_strdup (uri->path);
|
||||
uri_copy->query = g_strdup (uri->query);
|
||||
uri_copy->fragment = g_strdup (uri->fragment);
|
||||
/* FIXME: copy uri->params */
|
||||
|
||||
return uri_copy;
|
||||
}
|
||||
|
||||
char *
|
||||
e_uri_to_string (EUri *uri, gboolean show_password)
|
||||
{
|
||||
char *str_uri = NULL;
|
||||
|
||||
g_return_val_if_fail (uri != NULL, NULL);
|
||||
|
||||
if (uri->port != 0)
|
||||
str_uri = g_strdup_printf (
|
||||
"%s://%s%s%s%s%s%s%s:%d%s%s%s",
|
||||
uri->protocol,
|
||||
uri->user ? uri->user : "",
|
||||
uri->authmech ? ";auth=" : "",
|
||||
uri->authmech ? uri->authmech : "",
|
||||
uri->passwd && show_password ? ":" : "",
|
||||
uri->passwd && show_password ? uri->passwd : "",
|
||||
uri->user ? "@" : "",
|
||||
uri->host,
|
||||
uri->port,
|
||||
uri->path ? uri->path : "",
|
||||
uri->query ? "?" : "",
|
||||
uri->query ? uri->query : "");
|
||||
else
|
||||
str_uri = g_strdup_printf(
|
||||
"%s://%s%s%s%s%s%s%s%s%s%s",
|
||||
uri->protocol,
|
||||
uri->user ? uri->user : "",
|
||||
uri->authmech ? ";auth=" : "",
|
||||
uri->authmech ? uri->authmech : "",
|
||||
uri->passwd && show_password ? ":" : "",
|
||||
uri->passwd && show_password ? uri->passwd : "",
|
||||
uri->user ? "@" : "",
|
||||
uri->host,
|
||||
uri->path ? uri->path : "",
|
||||
uri->query ? "?" : "",
|
||||
uri->query ? uri->query : "");
|
||||
|
||||
return str_uri;
|
||||
}
|
||||
|
||||
@ -50,6 +50,8 @@ typedef struct {
|
||||
EUri *e_uri_new (const char *uri_string);
|
||||
void e_uri_free (EUri *uri);
|
||||
const char *e_uri_get_param (EUri *uri, const char *name);
|
||||
EUri *e_uri_copy (EUri *uri);
|
||||
char *e_uri_to_string (EUri *uri, gboolean show_password);
|
||||
|
||||
#endif /* __E_URL_H__ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user