From 16d79f55774a2c65863d2d9ec322f9bdbc1297a2 Mon Sep 17 00:00:00 2001 From: bertrand Date: Thu, 15 Jul 1999 11:13:32 +0000 Subject: Do not use GStrings any more. Added assertion code. Cosmetic reformating 1999-07-15 bertrand * camel/url-util.c: * camel/url-util.h: Do not use GStrings any more. Added assertion code. Cosmetic reformating * AUTHORS: * ChangeLog: Changed my email address. svn path=/trunk/; revision=1025 --- camel/url-util.c | 211 +++++++++++++++++++++++++++---------------------------- camel/url-util.h | 16 +++-- 2 files changed, 111 insertions(+), 116 deletions(-) (limited to 'camel') diff --git a/camel/url-util.c b/camel/url-util.c index b9ee4c653b..cf2425fdc3 100644 --- a/camel/url-util.c +++ b/camel/url-util.c @@ -40,29 +40,30 @@ /* general item finder */ /* it begins the search at position @position in @url, returns true when the item is found, amd set position after the item */ -typedef gboolean find_item_func(GString *url, GString **item, guint *position, gboolean *error); +typedef gboolean find_item_func(gchar *url, gchar **item, guint *position, gboolean *error); /* used to find one item (protocol, then user .... */ typedef struct { char *item_name; /* item name : for debug only */ - GString **item_value; /* where the item value will go */ + gchar **item_value; /* where the item value will go */ find_item_func *find_func; /* item finder */ } FindStepStruct; -static gboolean find_protocol(GString *url, GString **item, guint *position, gboolean *error); -static gboolean find_user(GString *url, GString **item, guint *position, gboolean *error); -static gboolean find_passwd(GString *url, GString **item, guint *position, gboolean *error); -static gboolean find_host(GString *url, GString **item, guint *position, gboolean *error); -static gboolean find_port(GString *url, GString **item, guint *position, gboolean *error); -static gboolean find_path(GString *url, GString **item, guint *position, gboolean *error); +static gboolean find_protocol (gchar *url, gchar **item, guint *position, gboolean *error); +static gboolean find_user (gchar *url, gchar **item, guint *position, gboolean *error); +static gboolean find_passwd (gchar *url, gchar **item, guint *position, gboolean *error); +static gboolean find_host (gchar *url, gchar **item, guint *position, gboolean *error); +static gboolean find_port (gchar *url, gchar **item, guint *position, gboolean *error); +static gboolean find_path (gchar *url, gchar **item, guint *position, gboolean *error); /** - * new_g_url: create an Gurl object from a string + * g_url_new: create an Gurl object from a string + * * @url_string: The string containing the URL to scan * - * This routine takes a GString and parses it as an + * This routine takes a gchar and parses it as an * URL of the form: * protocol://user:password@host:port/path * there is no test on the values. For example, @@ -71,19 +72,21 @@ static gboolean find_path(GString *url, GString **item, guint *position, gboolea * the scan results. When a member of the * general URL can not be found, the corresponding * Gurl member is NULL + * Fields filled in the Gurl structure are allocated + * and url_string is not modified. * - * Return value: a Gurl structure containng the URL items. + * Return value: a Gurl structure containing the URL items. **/ -Gurl *g_url_new(GString* url_string) +Gurl *g_url_new (gchar* url_string) { Gurl *g_url; - GString *protocol; - GString *user; - GString *passwd; - GString *host; - GString *port; - GString *path; + gchar *protocol; + gchar *user; + gchar *passwd; + gchar *host; + gchar *port; + gchar *path; guint position=0; gboolean error; @@ -91,7 +94,7 @@ Gurl *g_url_new(GString* url_string) guint i; g_url = g_new(Gurl,1); - + #define NB_STEP_URL 6 { FindStepStruct step[NB_STEP_URL] = { @@ -123,34 +126,33 @@ Gurl *g_url_new(GString* url_string) static gboolean -find_protocol(GString *url, GString **item, guint *position, gboolean *error) +find_protocol(gchar *url, gchar **item, guint *position, gboolean *error) { guint i; - gchar *str_url; gint len_url; - gchar *str_protocol; - - str_url = url->str; - len_url = url->len; + + g_assert (url); + g_assert (item); + g_assert (position); + + len_url = strlen (url); *item = NULL; *error = FALSE; i=*position; /* find a ':' */ - while ( (istr; - len_url = url->len; - + + g_assert (url); + g_assert (item); + g_assert (position); + + len_url = strlen (url); *item = NULL; i=*position; - /* find a '@' */ - while ((istr; - len_url = url->len; - + + g_assert (url); + g_assert (item); + g_assert (position); + + len_url = strlen (url); *item = NULL; i=*position; - /* find a '@' */ - while ((istr; - len_url = url->len; + g_assert (url); + g_assert (item); + g_assert (position); + + len_url = strlen (url); *item = NULL; i=*position; - /* find a '/' */ - while ((istr; - len_url = url->len; + g_assert (url); + g_assert (item); + g_assert (position); + + len_url = strlen (url); *item = NULL; i=*position; - /* find a '/' */ - while ((istr; - len_url = url->len; + g_assert (url); + g_assert (item); + g_assert (position); + + len_url = strlen (url); *item = NULL; i=*position; /* find a '#' */ - while ((istr); + url = argv[1]; + printf("URL to test : %s\n\n", url); for (i=0; istr); + *(test_step[i].item_value)); } else printf("** %s not found in URL\n", test_step[i].item_name); printf("next item position:\n"); - printf("%s\n", url->str); + printf("%s\n", url); for(i_pos=0; i_pos