aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2001-10-02 22:40:45 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2001-10-02 22:40:45 +0800
commit8828ff2fa35c98b0ec99b18c7594ee5dcb31ba65 (patch)
tree3bfd962bc0eeb7d38de6c2fcdbbdca6433b4fc9c /e-util
parent7e61b6213f906bf5da46dffb19a847d37710ddd3 (diff)
downloadgsoc2013-evolution-8828ff2fa35c98b0ec99b18c7594ee5dcb31ba65.tar
gsoc2013-evolution-8828ff2fa35c98b0ec99b18c7594ee5dcb31ba65.tar.gz
gsoc2013-evolution-8828ff2fa35c98b0ec99b18c7594ee5dcb31ba65.tar.bz2
gsoc2013-evolution-8828ff2fa35c98b0ec99b18c7594ee5dcb31ba65.tar.lz
gsoc2013-evolution-8828ff2fa35c98b0ec99b18c7594ee5dcb31ba65.tar.xz
gsoc2013-evolution-8828ff2fa35c98b0ec99b18c7594ee5dcb31ba65.tar.zst
gsoc2013-evolution-8828ff2fa35c98b0ec99b18c7594ee5dcb31ba65.zip
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
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog4
-rw-r--r--e-util/e-url.c63
-rw-r--r--e-util/e-url.h2
3 files changed, 69 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 310364031f..c0d8ffd630 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -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
diff --git a/e-util/e-url.c b/e-util/e-url.c
index ae37c71a74..9928aeca66 100644
--- a/e-util/e-url.c
+++ b/e-util/e-url.c
@@ -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;
+}
diff --git a/e-util/e-url.h b/e-util/e-url.h
index de24554d9b..d776bb4b08 100644
--- a/e-util/e-url.h
+++ b/e-util/e-url.h
@@ -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__ */