Commit 382f6f4c 382f6f4cf6c5cd26f0891626c7edca075efd79af by Alain Magloire

Makefile.am _cpystr.c chewurl.c url.c url.h url_imap.c

 	url_mailto.c url_mbox.c url_pop.c urli.c
Tightning up the API, still a draft.
1 parent 9d769577
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
2 2
3 AUTOMAKE_OPTIONS = ../lib/ansi2knr 3 AUTOMAKE_OPTIONS = ../lib/ansi2knr
4 4
5 CFLAGS = -Wall -pedantic -g 5 CFLAGS = -Wall -pedantic -g
6 6
7 include_HEADERS = url.h 7 include_HEADERS = url.h url_mbox.h url_pop.h url_imap.h url_mailto.h
8 8
9 noinst_HEADERS = url0.h 9 noinst_HEADERS = cpystr.h
10 10
11 base_sources = _cpystr.c url.c urli.c url_imap.c url_mailto.c \ 11 base_sources = _cpystr.c url.c urli.c url_imap.c url_mailto.c \
12 url_mbox.c url_pop.c 12 url_mbox.c url_pop.c
......
1 #include <url0.h> 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Library Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #include <cpystr.h>
2 #include <string.h> 19 #include <string.h>
3 20
4 int 21 int
5 _cpystr (const char * src, char * dst, unsigned int size) 22 _cpystr (const char *src, char *dst, unsigned int size)
6 { 23 {
7 unsigned int len = src ? strlen (src) : 0 ; 24 unsigned int len = src ? strlen (src) : 0 ;
8 25
9 if (dst == NULL || size == 0) { 26 if (dst == NULL || size == 0)
10 return len; 27 {
28 return len;
11 } 29 }
12 30
13 if (len >= size) { 31 if (len >= size)
14 len = size - 1; 32 {
33 len = size - 1;
15 } 34 }
16 memcpy (dst, src, len); 35 memcpy (dst, src, len);
17 dst[len] = '\0'; 36 dst[len] = '\0';
18 return len; 37 return len;
19 } 38 }
......
...@@ -5,42 +5,50 @@ ...@@ -5,42 +5,50 @@
5 int 5 int
6 main (int argc, char ** argv) 6 main (int argc, char ** argv)
7 { 7 {
8 int status; 8 int status, i;
9 long port; 9 long port;
10 url_t u; 10 url_t u;
11 char buffer[1024]; 11 char buffer[1024];
12 char str[1024]; 12 char str[1024];
13 13 struct url_type *utype;
14 while (fgets(str, sizeof (str), stdin) != NULL) 14
15 url_list_mtype (&utype, &status);
16 for (i = 0; i < status; i++)
15 { 17 {
16 str[strlen(str) - 1] = '\0'; /* chop newline */ 18 puts (utype[i].scheme);
17 status = url_create (&u, str); 19 puts (utype[i].description);
18 if (status == -1) { 20 }
19 printf("%s --> FAILED\n", str); 21 free (utype);
20 continue; 22
21 } 23 while (fgets(str, sizeof (str), stdin) != NULL)
22 printf("%s --> SUCCESS\n", str); 24 {
25 str[strlen(str) - 1] = '\0'; /* chop newline */
26 status = url_init (&u, str);
27 if (status == -1) {
28 printf("%s --> FAILED\n", str);
29 continue;
30 }
31 printf("%s --> SUCCESS\n", str);
23 32
24 url_get_scheme (u, buffer, sizeof (buffer)); 33 url_get_scheme (u, buffer, sizeof (buffer));
25 printf("\tscheme %s\n", buffer); 34 printf("\tscheme <%s>\n", buffer);
26 35
27 url_get_user (u, buffer, sizeof (buffer)); 36 url_get_user (u, buffer, sizeof (buffer));
28 printf("\tuser %s\n", buffer); 37 printf("\tuser <%s>\n", buffer);
29 38
30 url_get_passwd (u, buffer, sizeof (buffer)); 39 url_get_passwd (u, buffer, sizeof (buffer));
31 printf("\tpasswd %s\n", buffer); 40 printf("\tpasswd <%s>\n", buffer);
32 41
33 url_pop_get_auth (u, buffer, sizeof (buffer)); 42 url_pop_get_auth (u, buffer, sizeof (buffer));
34 printf("\tauth %s\n", buffer); 43 printf("\tauth <%s>\n", buffer);
35 44
36 url_get_host (u, buffer, sizeof (buffer)); 45 url_get_host (u, buffer, sizeof (buffer));
37 printf("\thost %s\n", buffer); 46 printf("\thost <%s>\n", buffer);
38 47
39 url_get_port (u, &port); 48 url_get_port (u, &port);
40 printf("\tport %ld\n", port); 49 printf("\tport %ld\n", port);
41 50
42 url_destroy (&u); 51 url_destroy (&u);
43 } 52 }
44 return 0; 53 return 0;
45 } 54 }
46
......
1 #include <url.h> 1 /* GNU mailutils - a suite of utilities for electronic mail
2 #include <url0.h> 2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Library Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #include <url_mbox.h>
19 #include <url_pop.h>
20 #include <url_imap.h>
21 #include <url_mailto.h>
22
23 #include <cpystr.h>
3 #include <string.h> 24 #include <string.h>
25 #include <stdlib.h>
26 #include <errno.h>
4 27
5 /* forward declaration */ 28 /* Forward prototypes */
6 static int get_scheme (const url_t, char *, unsigned int); 29 static int get_scheme (const url_t, char *, int);
7 static int get_user (const url_t, char *, unsigned int); 30 static int get_user (const url_t, char *, int);
8 static int get_passwd (const url_t, char *, unsigned int); 31 static int get_passwd (const url_t, char *, int);
9 static int get_host (const url_t, char *, unsigned int); 32 static int get_host (const url_t, char *, int);
10 static int get_port (const url_t, long *); 33 static int get_port (const url_t, long *);
11 static int get_path (const url_t, char *, unsigned int); 34 static int get_path (const url_t, char *, int);
12 static int get_query (const url_t, char *, unsigned int); 35 static int get_query (const url_t, char *, int);
13 static int is_pop (const url_t); 36 static int get_id (const url_t, int *id);
14 static int is_imap (const url_t); 37
15 38 /*
16 static struct _supported_scheme 39 Builtin url types.
40 We are using a simple circular list to hold the builtin type. */
41 static struct url_builtin
17 { 42 {
18 char * scheme; 43 const struct url_type *utype;
19 char len; 44 int is_malloc;
20 int (*_create) __P ((url_t *, const char *name)); 45 struct url_builtin * next;
21 void (*_destroy) __P ((url_t *)); 46 } url_builtin [] = {
22 } _supported_scheme[] = { 47 { NULL, 0, &url_builtin[1] }, /* Sentinel, head list */
23 { "mailto:", 7, url_mailto_create, url_mailto_destroy }, 48 { &_url_mbox_type, 0, &url_builtin[2] },
24 { "pop://", 6, url_pop_create, url_pop_destroy }, 49 { &_url_pop_type, 0, &url_builtin[3] },
25 { "imap://", 7, url_imap_create, url_imap_destroy }, 50 { &_url_imap_type, 0, &url_builtin[4] },
26 { "file://", 7, url_mbox_create, url_mbox_destroy }, 51 { &_url_mailto_type, 0, &url_builtin[0] },
27 { "/", 1, url_mbox_create, url_mbox_destroy }, /* hack ? */
28 { NULL, NULL, NULL, NULL }
29 }; 52 };
30 53
31 static int 54 /*
32 get_scheme (const url_t u, char * s, unsigned int n) 55 FIXME: Proper locking is not done when accessing the list
56 this code is not thread-safe .. TODO */
57 int
58 url_add_type (struct url_type *utype)
33 { 59 {
34 if (u == NULL) 60 struct url_builtin *current = malloc (sizeof (*current));
35 return -1; 61 if (current == NULL)
36 return _cpystr (u->scheme, s, n); 62 return -1;
63 utype->id = (int)utype; /* It just has to be uniq */
64 current->utype = utype;
65 current->is_malloc = 1;
66 current->next = url_builtin->next;
67 url_builtin->next = current;
68 return 0;
37 } 69 }
38 70
39 static int 71 int
40 get_user (const url_t u, char * s, unsigned int n) 72 url_remove_type (const struct url_type *utype)
41 { 73 {
42 if (u == NULL) 74 struct url_builtin *current, *previous;
43 return -1; 75 for (previous = url_builtin, current = url_builtin->next;
44 return _cpystr (u->user, s, n); 76 current != url_builtin;
77 previous = current, current = current->next)
78 {
79 if (current->utype == utype)
80 {
81 previous->next = current->next;
82 if (current->is_malloc)
83 free (current);
84 return 0;;
85 }
86 }
87 return -1;
45 } 88 }
46 89
47 /* FIXME: We should not store passwd in clear, but rather 90 int
48 have a simple encoding, and decoding mechanism */ 91 url_list_type (struct url_type *list, int n)
49 static int
50 get_passwd (const url_t u, char * s, unsigned int n)
51 { 92 {
52 if (u == NULL) 93 struct url_builtin *current;
53 return -1; 94 int i;
54 return _cpystr (u->passwd, s, n); 95 for (i = 0, current = url_builtin->next; current != url_builtin;
96 current = current->next, i++)
97 {
98 if (list)
99 if (i < n)
100 list[i] = *(current->utype);
101 }
102 return i;
55 } 103 }
56 104
57 static int 105 int
58 get_host (const url_t u, char * s, unsigned int n) 106 url_list_mtype (struct url_type **mlist, int *n)
59 { 107 {
60 if (u == NULL) 108 struct url_type *utype;
61 return -1; 109 int i;
62 return _cpystr (u->host, s, n); 110
111 if ((i = url_list_type (NULL, 0)) <= 0 || (utype = malloc (i)) == NULL)
112 {
113 return -1;
114 }
115
116 *mlist = utype;
117 return *n = url_list_type (utype, i);
63 } 118 }
64 119
120 int
121 url_init (url_t * purl, const char *name)
122 {
123 int status = -1;
124 const struct url_type *utype;
125 struct url_builtin *ub;
126
127 /* Sanity checks */
128 if (name == NULL || *name == '\0')
129 {
130 return status;
131 }
132
133 /* Search for a known scheme */
134 for (ub = url_builtin->next; ub != url_builtin; ub = ub->next)
135 {
136 utype = ub->utype;
137 if (strncasecmp (name, utype->scheme, utype->len) == 0)
138 {
139 status = 0;
140 break;
141 }
142 }
143
144 /* Found one initialize it */
145 if (status == 0)
146 {
147 status = utype->_init (purl, name);
148 if (status == 0)
149 {
150 url_t url = *purl;
151 if (url->utype == NULL)
152 url->utype = utype;
153 if (url->_get_scheme == NULL)
154 url->_get_scheme = get_scheme;
155 if (url->_get_user == NULL)
156 url->_get_user = get_user;
157 if (url->_get_passwd == NULL)
158 url->_get_passwd = get_passwd;
159 if (url->_get_host == NULL)
160 url->_get_host = get_host;
161 if (url->_get_port == NULL)
162 url->_get_port = get_port;
163 if (url->_get_path == NULL)
164 url->_get_path = get_path;
165 if (url->_get_query == NULL)
166 url->_get_query = get_query;
167 if (url->_get_id == NULL)
168 url->_get_id = get_id;
169 }
170 }
171 return status;
172 }
173
174 void
175 url_destroy (url_t *purl)
176 {
177 if (purl && *purl)
178 {
179 const struct url_type *utype = (*purl)->utype;
180 utype->_destroy(purl);
181 (*purl) = NULL;
182 }
183 }
184
185
186 /* Simple stub functions they all call _cpystr */
187
65 static int 188 static int
66 get_port (const url_t u, long * p) 189 get_scheme (const url_t u, char * s, int n)
67 { 190 {
68 if (u == NULL) 191 return _cpystr (u->scheme, s, n);
69 return -1;
70 return *p = u->port;
71 } 192 }
72 193
73 static int 194 static int
74 get_path (const url_t u, char * s, unsigned int n) 195 get_user (const url_t u, char * s, int n)
75 { 196 {
76 if (u == NULL) 197 return _cpystr (u->user, s, n);
77 return -1;
78 return _cpystr(u->path, s, n);
79 } 198 }
80 199
200 /* FIXME: We should not store passwd in clear, but rather
201 have a simple encoding, and decoding mechanism */
81 static int 202 static int
82 get_query (const url_t u, char * s, unsigned int n) 203 get_passwd (const url_t u, char * s, int n)
83 { 204 {
84 if (u == NULL) 205 return _cpystr (u->passwd, s, n);
85 return -1;
86 return _cpystr(u->query, s, n);
87 } 206 }
88 207
89 static int 208 static int
90 is_pop (const url_t u) 209 get_host (const url_t u, char * s, int n)
91 { 210 {
92 return u->type & URL_POP; 211 return _cpystr (u->host, s, n);
93 } 212 }
94 213
95 static int 214 static int
96 is_imap (const url_t u) 215 get_port (const url_t u, long * p)
97 { 216 {
98 return u->type & URL_IMAP; 217 *p = u->port;
218 return 0;
99 } 219 }
100 220
101 static int 221 static int
102 is_unixmbox (const url_t u) 222 get_path (const url_t u, char * s, int n)
103 { 223 {
104 return u->type & URL_MBOX; 224 return _cpystr(u->path, s, n);
105 } 225 }
106 226
107 int 227 static int
108 url_create (url_t * url, const char * name) 228 get_query (const url_t u, char * s, int n)
109 { 229 {
110 int status = -1, i ; 230 return _cpystr(u->query, s, n);
111
112 /* sanity checks */
113 if (name == NULL || *name == '\0')
114 {
115 return status;
116 }
117
118 /* scheme://scheme-specific-part */
119 for (i = 0; _supported_scheme[i].scheme; i++)
120 {
121 if (strncasecmp (name, _supported_scheme[i].scheme,
122 strlen(_supported_scheme[i].scheme)) == 0)
123 {
124 status = 1;
125 break;
126 }
127 }
128
129 if (status == 1)
130 {
131 status =_supported_scheme[i]._create(url, name);
132 if (status == 0)
133 {
134 url_t u = *url;
135 if (u->_get_scheme == NULL)
136 {
137 u->_get_scheme = get_scheme;
138 }
139 if (u->_get_user == NULL)
140 {
141 u->_get_user = get_user;
142 }
143 if (u->_get_passwd == NULL)
144 {
145 u->_get_passwd = get_passwd;
146 }
147 if (u->_get_host == NULL)
148 {
149 u->_get_host = get_host;
150 }
151 if (u->_get_port == NULL)
152 {
153 u->_get_port = get_port;
154 }
155 if (u->_get_path == NULL)
156 {
157 u->_get_path = get_path;
158 }
159 if (u->_get_query == NULL)
160 {
161 u->_get_query = get_query;
162 }
163 if (u->_is_pop == NULL)
164 {
165 u->_is_pop = is_pop;
166 }
167 if (u->_is_imap == NULL)
168 {
169 u->_is_imap = is_imap;
170 }
171 if (u->_is_unixmbox == NULL)
172 {
173 u->_is_unixmbox = is_unixmbox;
174 }
175 if (u->_create == NULL)
176 {
177 u->_create = _supported_scheme[i]._create;
178 }
179 if (u->_destroy == NULL)
180 {
181 u->_destroy= _supported_scheme[i]._destroy;
182 }
183 }
184 }
185 return status;
186 } 231 }
187 232
188 void 233 static int
189 url_destroy (url_t * url) 234 get_id (const url_t u, int *id)
190 { 235 {
191 if (url && *url) 236 const struct url_type *utype = u->utype;
192 { 237 *id = utype->id;
193 url_t u = *url; 238 return 0;
194 u->_destroy(url);
195 u = NULL;
196 }
197 } 239 }
......
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option) 6 the Free Software Foundation; either version 2, or (at your option)
7 any later version. 7 any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Library General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 17
...@@ -23,110 +23,88 @@ extern "C" { ...@@ -23,110 +23,88 @@ extern "C" {
23 #endif 23 #endif
24 24
25 #ifndef __P 25 #ifndef __P
26 #ifdef __STDC__ 26 # ifdef __STDC__
27 #define __P(args) args 27 # define __P(args) args
28 #else 28 # else
29 #define __P(args) () 29 # define __P(args) ()
30 #endif 30 # endif
31 #endif /*!__P */ 31 #endif /*!__P */
32 32
33 /* forward declaration */ 33 /* forward declaration */
34 struct _url; 34 struct _url;
35 typedef struct _url * url_t; 35 typedef struct _url * url_t;
36 36
37 struct _url 37 struct url_type
38 { 38 {
39 /* Data */ 39 char *scheme;
40 #define URL_POP ((int)1) 40 int len;
41 #define URL_IMAP (URL_POP << 1) 41 char *description;
42 #define URL_MBOX (URL_IMAP << 1) 42 int id;
43 int type; 43 int (*_init) __P ((url_t *, const char * name));
44 char *scheme; 44 void (*_destroy) __P ((url_t *));
45 char *user;
46 char *passwd; /* encoded ?? */
47 char *host;
48 long port;
49 char *path;
50 char *query;
51
52
53 void * data;
54 int (*_create) __P ((url_t *, const char *));
55 void (*_destroy) __P ((url_t *));
56
57 /* Methods */
58 int (*_get_scheme) __P ((const url_t, char *, unsigned int));
59 int (*_get_user) __P ((const url_t, char *, unsigned int));
60 int (*_get_passwd) __P ((const url_t, char *, unsigned int));
61 int (*_get_host) __P ((const url_t, char *, unsigned int));
62 int (*_get_port) __P ((const url_t, long *));
63 int (*_get_path) __P ((const url_t, char *, unsigned int));
64 int (*_get_query) __P ((const url_t, char *, unsigned int));
65 int (*_is_pop) __P ((const url_t));
66 int (*_is_imap) __P ((const url_t));
67 int (*_is_unixmbox) __P ((const url_t));
68 }; 45 };
69 46
70 extern int url_mailto_create __P ((url_t *, const char *name)); 47 struct _url
71 extern void url_mailto_destroy __P ((url_t *));
72
73 /* foward decl */
74 struct _url_pop;
75 typedef struct _url_pop * url_pop_t;
76
77 struct _url_pop
78 { 48 {
79 /* we use the fields from url_t */ 49 /* Data */
80 /* user, passwd, host, port */ 50 char *scheme;
81 char * auth; 51 char *user;
82 int (*_get_auth) __P ((const url_pop_t, char *, unsigned int)); 52 char *passwd; /* encoded ?? */
53 char *host;
54 long port;
55 char *path;
56 char *query;
57
58 void *data;
59 const struct url_type * utype;
60
61 /* Methods */
62 int (*_get_scheme) __P ((const url_t, char *scheme, int len));
63 int (*_get_user) __P ((const url_t, char *user, int len));
64 int (*_get_passwd) __P ((const url_t, char *passwd, int len));
65 int (*_get_host) __P ((const url_t, char *host, int len));
66 int (*_get_port) __P ((const url_t, long *port));
67 int (*_get_path) __P ((const url_t, char *path, int len));
68 int (*_get_query) __P ((const url_t, char *query, int len));
69 int (*_get_id) __P ((const url_t, int *id));
83 }; 70 };
84 71
85 extern int url_pop_create __P ((url_t *, const char *name)); 72 extern int url_init __P ((url_t *, const char *name));
86 extern void url_pop_destroy __P ((url_t *)); 73 extern void url_destroy __P ((url_t *));
87
88 extern int url_imap_create __P ((url_t *, const char *name));
89 extern void url_imap_destroy __P ((url_t *));
90 74
91 extern int url_mbox_create __P ((url_t *, const char *name)); 75 extern int url_list_type __P ((struct url_type list[], int len));
92 extern void url_mbox_destroy __P ((url_t *)); 76 extern int url_list_mtype __P ((struct url_type *mlist[], int *len));
77 extern int url_add_type __P ((struct url_type *utype));
78 extern int url_remove_type __P ((const struct url_type *utype));
93 79
94 extern int url_create __P ((url_t *, const char *name)); 80 #ifdef __GNUC__
95 extern void url_destroy __P ((url_t *)); 81 # define INLINE __inline__
82 #else
83 # define INLINE
84 #endif
96 85
97 extern int url_get_scheme (const url_t, char *, unsigned int); 86 extern INLINE int url_get_scheme __P ((const url_t, char *scheme, int len));
98 extern int url_get_user (const url_t , char *, unsigned int); 87 extern INLINE int url_get_user __P ((const url_t, char *user, int len));
99 extern int url_get_passwd (const url_t, char *, unsigned int); 88 extern INLINE int url_get_passwd __P ((const url_t, char *passwd, int len));
100 extern int url_get_host (const url_t, char *, unsigned int); 89 extern INLINE int url_get_host __P ((const url_t, char *host, int len));
101 extern int url_get_port (const url_t, long *); 90 extern INLINE int url_get_port __P ((const url_t, long *port));
102 extern int url_get_path (const url_t, char *, unsigned int); 91 extern INLINE int url_get_path __P ((const url_t, char *path, int len));
103 extern int url_get_query (const url_t, char *, unsigned int); 92 extern INLINE int url_get_query __P ((const url_t, char *query, int len));
104 extern int url_is_pop (const url_t); 93 extern INLINE int url_get_id __P ((const url_t, int *id));
105 extern int url_is_imap (const url_t);
106 extern int url_is_unixmbox (const url_t);
107 /* pop*/
108 extern int url_pop_get_auth (const url_t, char *, unsigned int);
109 94
110 #ifdef URL_MACROS 95 #ifdef URL_MACROS
111 # define url_get_scheme(url, prot, n) url->_get_scheme(url, prot, n) 96 # define url_get_scheme(url, scheme, n) url->_get_scheme (url, scheme, n)
112 # define url_get_user(url, user, n) url->_get_user(url, user, n) 97 # define url_get_user(url, user, n) url->_get_user (url, user, n)
113 # define url_get_passwd(url, passwd, n) url->_get_passwd(url, passwd, n) 98 # define url_get_passwd(url, passwd, n) url->_get_passwd (url, passwd, n)
114 # define url_get_host(url, host, n) url->_get_host(url, host, n) 99 # define url_get_host(url, host, n) url->_get_host (url, host, n)
115 # define url_get_port(url, port) url->_get_port(url, port) 100 # define url_get_port(url, port) url->_get_port (url, port)
116 # define url_get_path(url, path, n) url->_get_path(url, path, n) 101 # define url_get_path(url, path, n) url->_get_path (url, path, n)
117 # define url_get_query(url, query, n) url->_get_query(url, query, n) 102 # define url_get_query(url, query, n) url->_get_query (url, query, n)
118 103 # define url_get_id(url, id) url->_get_id (url, id)
119 /* what we support so far */
120 # define url_is_pop(url) (url->type & URL_POP)
121 # define url_is_imap(url) (url->type & URL_IMAP)
122 # define url_is_unixmbox(url) (url->type & URL_MBOX)
123
124 /* pop */
125 # define url_pop_get_auth(url, auth, n) (((url_pop_t) \
126 (url->data))->_get_auth(url->data, auth, n))
127 #endif /* URL_MACROS */ 104 #endif /* URL_MACROS */
128 105
129 #ifdef __cplusplus 106 #ifdef __cplusplus
130 } 107 }
131 #endif 108 #endif
109
132 #endif /* URL_H */ 110 #endif /* URL_H */
......
1 #include <url.h> 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #include <url_imap.h>
19
20 struct url_type _url_imap_type =
21 {
22 "imap://", 7,
23 "imap://... TODO",
24 (int)&_url_imap_type,
25 url_imap_init, url_imap_destroy
26 };
2 27
3 void 28 void
4 url_imap_destroy (url_t * url) 29 url_imap_destroy (url_t *purl)
5 { 30 {
6 return; 31 return;
7 } 32 }
8 33
9 int 34 int
10 url_imap_create (url_t * u, const char * name) 35 url_imap_init (url_t *purl, const char *name)
11 { 36 {
12 return -1; 37 return -1;
13 } 38 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #ifndef _URL_IMAP_H
19 #define _URL_IMAP_H 1
20
21 #include <url.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #ifndef __P
28 # ifdef __STDC__
29 # define __P(args) args
30 # else
31 # define __P(args) ()
32 # endif
33 #endif /*!__P */
34
35 extern int url_imap_init __P ((url_t *, const char *name));
36 extern void url_imap_destroy __P ((url_t *));
37
38 extern struct url_type _url_imap_type;
39
40 #ifndef INLINE
41 # ifdef __GNUC__
42 # define INLINE __inline__
43 # else
44 # define INLINE
45 # endif
46 #endif
47
48 #ifdef MU_URL_MACROS
49 #endif /* MU_URL_MACROS */
50
51 #ifdef __cplusplus
52 }
53 #endif
54
55 #endif /* URL_IMAP_H */
1 #include <url.h> 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #include <url_mailto.h>
19
20 struct url_type _url_mailto_type =
21 {
22 "mailto:", 6,
23 "mailto:<user>@<hostname>?<query>",
24 (int)&_url_mailto_type,
25 url_mailto_init, url_mailto_destroy
26 };
2 27
3 void 28 void
4 url_mailto_destroy (url_t * url) 29 url_mailto_destroy (url_t *purl)
5 { 30 {
6 return; 31 return;
7 } 32 }
8 33
9 int 34 int
10 url_mailto_create (url_t *u, const char * name) 35 url_mailto_init (url_t *purl, const char *name)
11 { 36 {
12 return -1; 37 return -1;
13 } 38 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #ifndef _URL_MAILTO_H
19 #define _URL_MAILTO_H 1
20
21 #include <url.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #ifndef __P
28 # ifdef __STDC__
29 # define __P(args) args
30 # else
31 # define __P(args) ()
32 # endif
33 #endif /*!__P */
34
35 /* UNIX MBOX */
36 extern int url_mailto_init __P ((url_t *, const char *name));
37 extern void url_mailto_destroy __P ((url_t *));
38
39 extern struct url_type _url_mailto_type;
40
41 #ifndef INLINE
42 # ifdef __GNUC__
43 # define INLINE __inline__
44 # else
45 # define INLINE
46 # endif
47 #endif
48
49 #ifdef MU_URL_MACROS
50 #endif /* MU_URL_MACROS */
51
52 #ifdef __cplusplus
53 }
54 #endif
55
56 #endif /* URL_MAILTO_H */
1 #include <url.h> 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #include <url_mbox.h>
19 #include <stdlib.h>
20 #include <string.h>
21
22 struct url_type _url_mbox_type =
23 {
24 "file://", 7,
25 "file://<full_path_name>",
26 (int)&_url_mbox_type, /* uniq id */
27 url_mbox_init, url_mbox_destroy
28 };
2 29
3 void 30 void
4 url_mbox_destroy (url_t * url) 31 url_mbox_destroy (url_t *purl)
5 { 32 {
6 return; 33 if (purl && *purl)
34 {
35 url_t url = *purl;
36 if (url->scheme)
37 free (url->scheme);
38 if (url->path)
39 free (url->path);
40 free (url);
41 url = NULL;
42 }
7 } 43 }
8 44
45 /*
46 UNIXMBOX and MAILDIR URL
47 file://path
48 */
9 int 49 int
10 url_mbox_create (url_t * u, const char * name) 50 url_mbox_init (url_t *purl, const char *name)
11 { 51 {
12 return -1; 52 url_t url;
53 int len;
54
55 /* reject the obvious */
56 if (name == NULL || strncmp ("file://", name, 7) != 0
57 || (len = strlen (name)) < 8 /* 7(scheme)+1(path)*/)
58 {
59 return -1;
60 }
61
62 /* do I need to decode url encoding '% hex hex' ? */
63
64 url = calloc(1, sizeof (*url));
65 if (url == NULL)
66 {
67 return -1;
68 }
69
70 /* TYPE */
71 url->utype = &_url_mbox_type;
72
73 /* SCHEME */
74 /* strdup ("file://") the hard way */
75 url->scheme = malloc (7 + 1);
76 if (url->scheme == NULL)
77 {
78 url_mbox_destroy (&url);
79 return -1;
80 }
81 memcpy (url->scheme, "file://", 8);
82
83 /* PATH */
84 name += 7; /* pass the scheme */
85 len -= 7;
86 url->path = malloc (len + 1);
87 if (url->path == NULL)
88 {
89 url_mbox_destroy (&url);
90 return -1;
91 }
92 memcpy (url->path, name, len + 1);
93
94 *purl = url;
95 return 0;
13 } 96 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #ifndef _URL_MBOX_H
19 #define _URL_MBOX_H 1
20
21 #include <url.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #ifndef __P
28 # ifdef __STDC__
29 # define __P(args) args
30 # else
31 # define __P(args) ()
32 # endif
33 #endif /*!__P */
34
35 /* UNIX MBOX */
36 extern int url_mbox_init __P ((url_t *, const char *name));
37 extern void url_mbox_destroy __P ((url_t *));
38
39 extern struct url_type _url_mbox_type;
40
41 #ifndef INLINE
42 # ifdef __GNUC__
43 # define INLINE __inline__
44 # else
45 # define INLINE
46 # endif
47 #endif
48
49 #ifdef MU_URL_MACROS
50 #endif /* MU_URL_MACROS */
51
52 #ifdef __cplusplus
53 }
54 #endif
55
56 #endif /* URL_MBOX_H */
1 #include <url.h> 1 /* GNU mailutils - a suite of utilities for electronic mail
2 #include <url0.h> 2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #include <url_pop.h>
19 #include <cpystr.h>
3 #include <stdlib.h> 20 #include <stdlib.h>
4 #include <string.h> 21 #include <string.h>
5 22
6 #define POP_PORT 110 23 struct url_type _url_pop_type =
24 {
25 "pop://", 6,
26 "pop://<user>;AUTH=<auth>@<hostname>:<port>",
27 (int)&_url_pop_type,
28 url_pop_init, url_pop_destroy
29 };
7 30
8 static int get_auth (const url_pop_t up, char * s, unsigned int n); 31 static int get_auth (const url_pop_t up, char *s, int n);
9 32
10 static int 33 static int
11 get_auth (const url_pop_t up, char * s, unsigned int n) 34 get_auth (const url_pop_t up, char * s, int n)
12 { 35 {
13 if (up == NULL) return -1; 36 return _cpystr (up->auth, s, n);
14 return _cpystr (up->auth, s, n);
15 } 37 }
16 38
17 int 39 int
18 (url_pop_get_auth) (const url_t url, char * auth, unsigned int n) 40 (url_pop_get_auth) (const url_t url, char * auth, int n)
19 { 41 {
20 return ((url_pop_t) (url->data))->_get_auth(url->data, auth, n); 42 return ((url_pop_t) (url->data))->_get_auth(url->data, auth, n);
21 } 43 }
22 44
23 void 45 void
24 url_pop_destroy (url_t * url) 46 url_pop_destroy (url_t *purl)
25 { 47 {
26 if (url && *url) 48 if (purl && *purl)
27 { 49 {
28 url_t u = *url; 50 url_t url = *purl;
29 if (u->scheme) 51 if (url->scheme)
30 { 52 free (url->scheme);
31 free (u->scheme); 53 if (url->user)
32 } 54 free (url->user);
33 if (u->user) 55 if (url->passwd)
34 { 56 free (url->passwd);
35 free (u->user); 57 if (url->host)
36 } 58 free (url->host);
37 if (u->passwd) 59 if (url->data)
38 { 60 {
39 free (u->passwd); 61 url_pop_t up = url->data;
40 } 62 if (up->auth)
41 if (u->host) 63 free (up->auth);
42 { 64 free (url->data);
43 free (u->host); 65 }
44 } 66 free (url);
45 if (u->data) 67 url = NULL;
46 { 68 }
47 url_pop_t up = u->data;
48 if (up->auth)
49 {
50 free (up->auth);
51 }
52 free (u->data);
53 }
54 free (u);
55 u = NULL;
56 }
57 } 69 }
58 70
59 /* 71 /*
60 POP URL 72 POP URL
61 pop://<user>;AUTH=<auth>@<host>:<port> 73 pop://<user>;AUTH=<auth>@<host>:<port>
62 */ 74 */
63 int 75 int
64 url_pop_create (url_t * url, const char * name) 76 url_pop_init (url_t *purl, const char *name)
65 { 77 {
66 const char * host_port, * index; 78 const char *host_port, *index;
67 url_t u; 79 url_t url;
68 url_pop_t up; 80 url_pop_t up;
69 81
70 /* reject the obvious */ 82 /* reject the obvious */
71 if (name == NULL || 83 if (name == NULL || strncmp ("pop://", name, 6) != 0
72 strncmp ("pop://", name, 6) != 0 || 84 || (host_port = strchr (name, '@')) == NULL
73 (host_port = strchr (name, '@')) == NULL || 85 || strlen(name) < 9 /* 6(scheme)+1(user)+1(@)+1(host)*/)
74 strlen(name) < 9 /* 6(scheme)+1(user)+1(@)+1(host)*/) { 86 {
75 return -1; 87 return -1;
76 } 88 }
77 89
78 /* do I need to decode url encoding '% hex hex' ? */ 90 /* do I need to decode url encoding '% hex hex' ? */
79 91
80 u = xcalloc(1, sizeof (*u)); 92 url = calloc(1, sizeof (*url));
81 u->data = up = xcalloc(1, sizeof(*up)); 93 url->data = up = calloc(1, sizeof(*up));
82 up->_get_auth = get_auth; 94 up->_get_auth = get_auth;
83 95
84 /* type */ 96 /* TYPE */
85 u->type = URL_POP; 97 url->utype = &_url_pop_type;
86 u->scheme = xstrdup ("pop://"); 98
87 99 /* SCHEME */
88 name += 6; /* pass the scheme */ 100 url->scheme = malloc (6 + 1);
89 101 if (url->scheme == NULL)
90 /* looking for user;auth=auth-enc */ 102 {
91 #if 1 103 url_pop_destroy (&url);
92 for (index = name; index != host_port; index++) 104 return -1;
93 { 105 }
94 /* Auth ? */ 106 memcpy (url->scheme, "pop://", 7);
95 if (*index == ';') 107
96 { 108 name += 6; /* pass the scheme */
97 if (strncasecmp(index +1, "auth=", 5) == 0 ) 109
110 /* looking for "user;auth=auth-enc" */
111 for (index = name; index != host_port; index++)
112 {
113 /* Auth ? */
114 if (*index == ';')
115 {
116 /* make sure it the token */
117 if (strncasecmp(index + 1, "auth=", 5) == 0)
98 break; 118 break;
99 } 119 }
100 } 120 }
101 #endif 121
102 122 if (index == name)
103 /* USER */ 123 {
104 if (index == name) 124 url_pop_destroy (&url);
105 { 125 return -1;
106 //free(); 126 }
107 return -1; 127
108 } 128 /* USER */
109 u->user = malloc(index - name + 1); 129 url->user = malloc(index - name + 1);
110 ((char *)memcpy(u->user, name, index - name))[index - name] = '\0'; 130 if (url->user == NULL)
111 131 {
112 /* AUTH */ 132 url_pop_destroy (&url);
113 if ((host_port - index) <= 6 /*strlen(";AUTH=")*/) 133 return -1;
114 { 134 }
115 /* default AUth is '*'*/ 135 ((char *)memcpy(url->user, name, index - name))[index - name] = '\0';
116 up->auth = malloc (1 + 1); 136
117 up->auth[0] = '*'; 137 /* AUTH */
118 up->auth[1] = '\0'; 138 if ((host_port - index) <= 6 /*strlen(";AUTH=")*/)
119 } 139 {
120 else 140 /* Use default AUTH '*' */
121 { 141 up->auth = malloc (1 + 1);
122 /* move pass AUTH= */ 142 if (up->auth)
123 index += 6; 143 {
124 up->auth = malloc (host_port - index + 1); 144 up->auth[0] = '*';
125 ((char *) memcpy (up->auth, index, host_port - index)) 145 up->auth[1] = '\0';
146 }
147 }
148 else
149 {
150 /* move pass AUTH= */
151 index += 6;
152 up->auth = malloc (host_port - index + 1);
153 if (up->auth)
154 {
155 ((char *)memcpy (up->auth, index, host_port - index))
126 [host_port - index] = '\0'; 156 [host_port - index] = '\0';
127 } 157 }
128 158 }
129 /* HOST:PORT */ 159
130 index = strchr (++host_port, ':'); 160 if (up->auth == NULL)
131 if (index == NULL) 161 {
132 { 162 url_pop_destroy (&url);
133 int len = strlen (host_port); 163 return -1;
134 u->host = malloc (len + 1); 164 }
135 ((char *)memcpy (u->host, host_port, len))[len] = '\0'; 165
136 u->port = POP_PORT; 166 /* HOST:PORT */
137 } 167 index = strchr (++host_port, ':');
138 else 168 if (index == NULL)
139 { 169 {
140 long p = strtol(index + 1, NULL, 10); 170 int len = strlen (host_port);
141 u->host = malloc (index - host_port + 1); 171 url->host = malloc (len + 1);
142 ((char *)memcpy (u->host, host_port, index - host_port)) 172 if (url->host)
173 {
174 ((char *)memcpy (url->host, host_port, len))[len] = '\0';
175 url->port = MU_POP_PORT;
176 }
177 }
178 else
179 {
180 long p = strtol(index + 1, NULL, 10);
181 url->host = malloc (index - host_port + 1);
182 if (url->host)
183 {
184 ((char *)memcpy (url->host, host_port, index - host_port))
143 [index - host_port]='\0'; 185 [index - host_port]='\0';
144 u->port = (p == 0) ? POP_PORT : p; 186 url->port = (p == 0) ? MU_POP_PORT : p;
145 } 187 }
146 188 }
147 *url = u; 189
148 return 0; 190 if (url->host == NULL)
191 {
192 url_pop_destroy (&url);
193 return -1;
194 }
195
196 *purl = url;
197 return 0;
149 } 198 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #ifndef _URL_POP_H
19 #define _URL_POP_H 1
20
21 #include <url.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #ifndef __P
28 # ifdef __STDC__
29 # define __P(args) args
30 # else
31 # define __P(args) ()
32 # endif
33 #endif /*!__P */
34
35 /* POP3 */
36 struct _url_pop;
37 typedef struct _url_pop * url_pop_t;
38
39 struct _url_pop
40 {
41 /* we use the fields from url_t */
42 /* user, passwd, host, port */
43 char * auth;
44 int (*_get_auth) __P ((const url_pop_t, char *, int));
45 };
46
47 extern int url_pop_init __P ((url_t *, const char *name));
48 extern void url_pop_destroy __P ((url_t *));
49
50 #define MU_POP_PORT 110
51
52 extern struct url_type _url_pop_type;
53
54 #ifndef INLINE
55 # ifdef __GNUC__
56 # define INLINE __inline__
57 # else
58 # define INLINE
59 # endif
60 #endif
61
62 /* pop*/
63 extern int url_pop_get_auth (const url_t, char *, int);
64
65 #ifdef MU_URL_MACROS
66 /* pop */
67 # define url_pop_get_auth(url, auth, n) (((url_pop_t) \
68 (url->data))->_get_auth(url->data, auth, n))
69 #endif /* MU_URL_MACROS */
70
71 #ifdef __cplusplus
72 }
73 #endif
74
75 #endif /* URL_POP_H */
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Library Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
1 #include <url.h> 18 #include <url.h>
19
2 int 20 int
3 (url_get_scheme) (const url_t url, char * scheme, unsigned int n) 21 (url_get_scheme) (const url_t url, char *scheme, int n)
4 { return url->_get_scheme(url, scheme, n); } 22 { return url->_get_scheme(url, scheme, n); }
5 23
6 int 24 int
7 (url_get_user) (const url_t url, char *user, unsigned int n) 25 (url_get_user) (const url_t url, char *user, int n)
8 { return url->_get_user(url, user, n); } 26 { return url->_get_user(url, user, n); }
9 27
10 int 28 int
11 (url_get_passwd) (const url_t url, char *passwd, unsigned int n) 29 (url_get_passwd) (const url_t url, char *passwd, int n)
12 { return url->_get_passwd(url, passwd, n); } 30 { return url->_get_passwd(url, passwd, n); }
13 31
14 int 32 int
15 (url_get_host) (const url_t url, char * host, unsigned int n) 33 (url_get_host) (const url_t url, char *host, int n)
16 { return url->_get_host(url, host, n); } 34 { return url->_get_host(url, host, n); }
17 35
18 int 36 int
19 (url_get_port) (const url_t url, long * port) 37 (url_get_port) (const url_t url, long *port)
20 { return url->_get_port(url, port); } 38 { return url->_get_port(url, port); }
21 39
22 int 40 int
23 (url_get_path) (const url_t url, char *path, unsigned int n) 41 (url_get_path) (const url_t url, char *path, int n)
24 { return url->_get_path(url, path, n); } 42 { return url->_get_path(url, path, n); }
25 43
26 int 44 int
27 (url_get_query) (const url_t url, char *query, unsigned int n) 45 (url_get_query) (const url_t url, char *query, int n)
28 { return url->_get_query(url, query, n); } 46 { return url->_get_query(url, query, n); }
29 47
30 int 48 int
31 (url_is_pop) (const url_t url) 49 (url_get_id) (const url_t url, int *id)
32 { return (url->type & URL_POP); } 50 { return url->_get_id (url, id); }
33
34 int
35 (url_is_imap) (const url_t url)
36 { return (url->type & URL_IMAP); }
37
38 int
39 (url_is_unixmbox) (const url_t url)
40 { return (url->type & URL_MBOX); }
......