url.texi
5.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@comment See rfc2368, rfc2369, rfc2384
A mailbox and mailer can be describe in a URL, the string will contain the
necessary information to initialize @code{mailbox_t}, or @code{mailer_t}
properly.
@section POP3
The POP URL scheme contains a pop server, optional port number
and the authentication mechanism. The general form is
@example
@url{pop://user;AUTH=type@@hostname:port}
@url{pop://obelix;AUTH=+APOP@@village.gaulois.org:2000}
@end example
If @emph{:port} is omitted the default value is 110. Different form of
authentication can be specified with @emph{;AUTH=type}.
The special string @emph{;AUTH=*} indicates that the client will use
a default scheme base on the capability of the server.
@example
@url{pop://obelix@@gaulois.org}
@url{pop://asterix;AUTH=*@@france.com}
@url{pop://falbala;AUTH=+APOP@@france.com}
@end example
For more complete information see @cite{rfc2368}.
@section IMAP
imap://.....
Description of the fields and examples are needed.
@section File
Local folder should be handle by this URL. It is preferable to let
the mailbox recognize the type of mailbox and take the appropriate
action.
@example
@url{file://path}
@url{file://var/mail/user}
@url{file://home/obelix/Mail}
@end example
For MMDF, MH local mailboxes URLs are provided, but it is preferable to
use @url{file://path} and let the library figure out which one.
@example
@url{mmdf://path}
@url{mh://path}
@end example
@section Mailto
After setting a mailer, @url{mailto:} is use to tell the mailer where
and to whom the message is for.
@example
@url{mailto://hostname}
@end example
Mailto can be use to generate short messages for example to subscribe
to mailing lists.
@example
@url{mailto://bug-mailutils@@gnu.org?body=subscribe}
@url{mailto://bug-mailutils@@gnu.org?Subject=hello&body=subscribe}
@end example
For more complete information see @cite{rfc2368}.
@section URL functions
Helper functions are provided to retrieve and set the @emph{URL} fields.
@deftypefun int url_init (url_t *@var{url}, const char *name)
Initialize and parse the @var{url}
@end deftypefun
@deftypefun void url_destroy (url_t *)
@end deftypefun
@deftp {Data type} struct url_type
@example
@{
char *scheme;
size_t len;
char *description;
int id;
int (*_init) (url_t *, const char * name);
void (*_destroy) (url_t *);
@};
@end example
@end deftp
@section URL registration
@deftypefun int url_list_type (struct url_type @var{list}[], size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_list_mtype (struct url_type **@var{mlist}, size_t *@var{n})
@end deftypefun
@deftypefun int url_add_type (struct url_type *@var{utype})
@end deftypefun
@deftypefun int url_remove_type (const struct url_type *@var{utype})
@end deftypefun
@deftypefun int url_get_id (const url_t @var{url}, int *@var{id})
@end deftypefun
@section Helper functions
@example
#include <url.h>
#include <stdio.h>
#include <string.h>
int main ()
@{
char str[1024];
char buffer[1024];
long port = -1;
url_t u;
while (fgets (str, sizeof (str), stdin) != NULL)
@{
str[strlen (str) - 1] = '\0'; /* chop newline */
if (url_init (&u, str) != 0)
@{
printf ("%s --> FAILED\n", str);
continue;
@}
printf ("%s --> SUCCESS\n", str);
url_get_scheme (u, buffer, len, NULL);
printf ("\tscheme <%s>\n", buffer);
url_get_user (u, buffer, len, NULL);
printf ("\tuser <%s>\n", buffer);
url_get_passwd (u, buffer, len, NULL);
printf ("\tpasswd <%s>\n", buffer);
url_get_host (u, buffer, len, NULL);
printf ("\thost <%s>\n", buffer);
url_get_port (u, &port);
printf ("\tport %ld\n", port);
url_get_path (u, buffer, len, NULL);
printf ("\tpath <%s>\n", buffer);
url_get_query (u, buffer, len, NULL);
printf ("\tquery <%s>\n", buffer);
url_destroy (&u);
@}
return 0;
@}
@end example
@deftypefun int url_get_scheme (const url_t @var{url}, char *@var{schem}, size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_mscheme (const url_t @var{url}, char **@var{scheme}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_user (const url_t @var{url}, char *@var{usr}, size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_muser (const url_t @var{url}, char **@var{buf}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_passwd (const url_t @var{url}, char *@var{passwd}, size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_mpasswd (const url_t @var{url}, char **@var{buf}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_host (const url_t @var{url}, char *@var{host}, size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_mhost (const url_t @var{url}, char **@var{buf}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_port (const url_t @var{url}, long *@var{port})
@end deftypefun
@deftypefun int url_get_path (const url_t @var{url}, char *@var{path}, size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_mpath (const url_t @var{url}, char **@var{buffer}, size_t *@var{len})
@end deftypefun
@deftypefun int url_get_query (const url_t @var{url}, char *@var{query}, size_t{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_mquery (const url_t @var{url}, char **@var{buf}, size_t *@var{len})
@end deftypefun