Moved to the corresponding subdirectory
Showing
14 changed files
with
0 additions
and
916 deletions
mailbox/folder_imap.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/folder_mbox.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/folder_mh.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public | ||
15 | License along with this library; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #ifdef ENABLE_MH | ||
23 | |||
24 | #include <errno.h> | ||
25 | |||
26 | #include <folder0.h> | ||
27 | #include <registrar0.h> | ||
28 | |||
29 | static struct _record _mh_record = | ||
30 | { | ||
31 | MU_MH_SCHEME, | ||
32 | _url_mh_init, /* Url init. */ | ||
33 | _mailbox_mh_init, /* Mailbox init. */ | ||
34 | NULL, /* Mailer init. */ | ||
35 | _folder_mh_init, /* Folder init. */ | ||
36 | NULL, /* back pointer. */ | ||
37 | NULL, /* _is_scheme method. */ | ||
38 | NULL, /* _get_url method. */ | ||
39 | NULL, /* _get_mailbox method. */ | ||
40 | NULL, /* _get_mailer method. */ | ||
41 | NULL /* _get_folder method. */ | ||
42 | }; | ||
43 | record_t mh_record = &_mh_record; | ||
44 | |||
45 | int | ||
46 | _folder_mh_init (folder_t folder) | ||
47 | { | ||
48 | (void)folder; | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | #else | ||
53 | #include <stdio.h> | ||
54 | #include <registrar0.h> | ||
55 | record_t mh_record = NULL; | ||
56 | #endif |
mailbox/folder_pop.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public | ||
15 | License along with this library; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #ifdef ENABLE_POP | ||
23 | |||
24 | #include <errno.h> | ||
25 | #include <stdlib.h> | ||
26 | #include <string.h> | ||
27 | |||
28 | #ifdef HAVE_STRINGS_H | ||
29 | # include <strings.h> | ||
30 | #endif | ||
31 | |||
32 | #include <mailutils/auth.h> | ||
33 | #include <mailutils/mailbox.h> | ||
34 | |||
35 | #include <folder0.h> | ||
36 | #include <registrar0.h> | ||
37 | #include <url0.h> | ||
38 | |||
39 | /* We export url parsing and the initialisation of | ||
40 | the mailbox, via the register entry/record. */ | ||
41 | |||
42 | static struct _record _pop_record = | ||
43 | { | ||
44 | MU_POP_SCHEME, | ||
45 | _url_pop_init, /* Url init. */ | ||
46 | _mailbox_pop_init, /* Mailbox init. */ | ||
47 | NULL, /* Mailer init. */ | ||
48 | _folder_pop_init, /* Folder init. */ | ||
49 | NULL, /* No need for an back pointer. */ | ||
50 | NULL, /* _is_scheme method. */ | ||
51 | NULL, /* _get_url method. */ | ||
52 | NULL, /* _get_mailbox method. */ | ||
53 | NULL, /* _get_mailer method. */ | ||
54 | NULL /* _get_folder method. */ | ||
55 | }; | ||
56 | record_t pop_record = &_pop_record; | ||
57 | |||
58 | static int folder_pop_open __P ((folder_t, int)); | ||
59 | static int folder_pop_close __P ((folder_t)); | ||
60 | static int folder_pop_get_authority __P ((folder_t, authority_t *)); | ||
61 | extern int _pop_user __P ((authority_t)); | ||
62 | extern int _pop_apop __P ((authority_t)); | ||
63 | |||
64 | /* XXX: The way, the POP folder is handle is not clean at all. | ||
65 | the I/O functions should have been here on folder, not in mbx_pop.c */ | ||
66 | int | ||
67 | _folder_pop_init (folder_t folder) | ||
68 | { | ||
69 | int status; | ||
70 | |||
71 | /* Set the authority early: | ||
72 | (1) so we can check for errors. | ||
73 | (2) allow the client to get the authority for setting the ticket | ||
74 | before the open. */ | ||
75 | status = folder_pop_get_authority (folder, NULL); | ||
76 | if (status != 0) | ||
77 | return status; | ||
78 | |||
79 | folder->_open = folder_pop_open; | ||
80 | folder->_close = folder_pop_close; | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | static int | ||
85 | folder_pop_open (folder_t folder, int flags) | ||
86 | { | ||
87 | mailbox_t mbox = folder->data; | ||
88 | return mailbox_open (mbox, flags); | ||
89 | } | ||
90 | |||
91 | static int | ||
92 | folder_pop_close (folder_t folder) | ||
93 | { | ||
94 | mailbox_t mbox = folder->data; | ||
95 | return mailbox_close (mbox); | ||
96 | } | ||
97 | |||
98 | static int | ||
99 | folder_pop_get_authority (folder_t folder, authority_t *pauth) | ||
100 | { | ||
101 | int status = 0; | ||
102 | if (folder->authority == NULL) | ||
103 | { | ||
104 | /* assert (folder->url); */ | ||
105 | if (folder->url == NULL) | ||
106 | return EINVAL; | ||
107 | |||
108 | if (folder->url->auth == NULL | ||
109 | || strcasecmp (folder->url->auth, "*") == 0) | ||
110 | { | ||
111 | status = authority_create (&folder->authority, NULL, folder); | ||
112 | authority_set_authenticate (folder->authority, _pop_user, folder); | ||
113 | } | ||
114 | /* | ||
115 | "+apop" could be supported. | ||
116 | Anything else starting with "+" is an extension mechanism. | ||
117 | Without a "+" it's a SASL mechanism. | ||
118 | */ | ||
119 | else if (strcasecmp (folder->url->auth, "+APOP") == 0) | ||
120 | { | ||
121 | status = authority_create (&folder->authority, NULL, folder); | ||
122 | authority_set_authenticate (folder->authority, _pop_apop, folder); | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | status = ENOSYS; | ||
127 | } | ||
128 | } | ||
129 | if (pauth) | ||
130 | *pauth = folder->authority; | ||
131 | return status; | ||
132 | } | ||
133 | |||
134 | #else | ||
135 | #include <stdio.h> | ||
136 | #include <registrar0.h> | ||
137 | record_t pop_record = NULL; | ||
138 | #endif |
mailbox/mbx_imap.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/mbx_maildir.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public | ||
15 | License along with this library; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
17 | |||
18 | /* First draft by Jeff Bailey based on mbox by Alain Magloire */ | ||
19 | |||
20 | #ifdef HAVE_CONFIG_H | ||
21 | # include <config.h> | ||
22 | #endif | ||
23 | |||
24 | #include <stdlib.h> | ||
25 | #include <stdio.h> | ||
26 | #include <time.h> | ||
27 | #include <sys/stat.h> | ||
28 | #include <fcntl.h> | ||
29 | #include <unistd.h> | ||
30 | #include <signal.h> | ||
31 | #include <time.h> | ||
32 | #include <string.h> | ||
33 | #include <ctype.h> | ||
34 | #include <limits.h> | ||
35 | #include <errno.h> | ||
36 | |||
37 | #ifdef WITH_PTHREAD | ||
38 | # ifdef HAVE_PTHREAD_H | ||
39 | # define _XOPEN_SOURCE 500 | ||
40 | # include <pthread.h> | ||
41 | # endif | ||
42 | #endif | ||
43 | |||
44 | #ifdef HAVE_ALLOCA_H | ||
45 | # include <alloca.h> | ||
46 | #endif | ||
47 | |||
48 | #ifdef HAVE_STRINGS_H | ||
49 | # include <strings.h> | ||
50 | #endif | ||
51 | |||
52 | #include <mailbox0.h> | ||
53 | #include <registrar0.h> | ||
54 | |||
55 | #include <mailutils/address.h> | ||
56 | #include <mailutils/attribute.h> | ||
57 | #include <mailutils/body.h> | ||
58 | #include <mailutils/debug.h> | ||
59 | #include <mailutils/envelope.h> | ||
60 | #include <mailutils/errno.h> | ||
61 | #include <mailutils/error.h> | ||
62 | #include <mailutils/header.h> | ||
63 | #include <mailutils/locker.h> | ||
64 | #include <mailutils/message.h> | ||
65 | #include <mailutils/mutil.h> | ||
66 | #include <mailutils/observer.h> | ||
67 | #include <mailutils/property.h> | ||
68 | #include <mailutils/stream.h> | ||
69 | #include <mailutils/url.h> | ||
70 | |||
71 | /* Mailbox concrete implementation. */ | ||
72 | static int maildir_open __P ((mailbox_t, int)); | ||
73 | static int maildir_close __P ((mailbox_t)); | ||
74 | static void maildir_destroy __P ((mailbox_t)); | ||
75 | static int maildir_get_message __P ((mailbox_t, size_t, message_t *)); | ||
76 | /* static int maildir_get_message_by_uid __P ((mailbox_t, size_t, message_t *)); */ | ||
77 | static int maildir_append_message __P ((mailbox_t, message_t)); | ||
78 | static int maildir_messages_count __P ((mailbox_t, size_t *)); | ||
79 | static int maildir_messages_recent __P ((mailbox_t, size_t *)); | ||
80 | static int maildir_message_unseen __P ((mailbox_t, size_t *)); | ||
81 | static int maildir_expunge __P ((mailbox_t)); | ||
82 | static int maildir_save_attributes __P ((mailbox_t)); | ||
83 | static int maildir_uidvalidity __P ((mailbox_t, unsigned long *)); | ||
84 | static int maildir_uidnext __P ((mailbox_t, size_t *)); | ||
85 | static int maildir_scan __P ((mailbox_t, size_t, size_t *)); | ||
86 | static int maildir_is_updated __P ((mailbox_t)); | ||
87 | static int maildir_get_size __P ((mailbox_t, off_t *)); | ||
88 | |||
89 | int | ||
90 | _mailbox_maildir_init (mailbox_t mailbox) | ||
91 | { | ||
92 | |||
93 | if (mailbox == NULL) | ||
94 | return EINVAL; | ||
95 | |||
96 | /* Overloading the defaults. */ | ||
97 | mailbox->_destroy = maildir_destroy; | ||
98 | |||
99 | mailbox->_open = maildir_open; | ||
100 | mailbox->_close = maildir_close; | ||
101 | |||
102 | /* Overloading of the entire mailbox object methods. */ | ||
103 | mailbox->_get_message = maildir_get_message; | ||
104 | mailbox->_append_message = maildir_append_message; | ||
105 | mailbox->_messages_count = maildir_messages_count; | ||
106 | mailbox->_messages_recent = maildir_messages_recent; | ||
107 | mailbox->_message_unseen = maildir_message_unseen; | ||
108 | mailbox->_expunge = maildir_expunge; | ||
109 | mailbox->_save_attributes = maildir_save_attributes; | ||
110 | mailbox->_uidvalidity = maildir_uidvalidity; | ||
111 | mailbox->_uidnext = maildir_uidnext; | ||
112 | |||
113 | mailbox->_scan = maildir_scan; | ||
114 | mailbox->_is_updated = maildir_is_updated; | ||
115 | |||
116 | mailbox->_get_size = maildir_get_size; | ||
117 | |||
118 | return 0; /* okdoke */ | ||
119 | } | ||
120 | |||
121 | /* Destruct maildir setup */ | ||
122 | static void | ||
123 | maildir_destroy (mailbox_t mailbox) | ||
124 | { | ||
125 | return; | ||
126 | } | ||
127 | |||
128 | /* Open the file. For MU_STREAM_READ, the code tries mmap() first and fall | ||
129 | back to normal file. */ | ||
130 | static int | ||
131 | maildir_open (mailbox_t mailbox, int flags) | ||
132 | { | ||
133 | return -1; | ||
134 | } | ||
135 | |||
136 | static int | ||
137 | maildir_close (mailbox_t mailbox) | ||
138 | { | ||
139 | return -1; | ||
140 | } | ||
141 | |||
142 | /* Cover function that call the real thing, maildir_scan(), with | ||
143 | notification set. */ | ||
144 | static int | ||
145 | maildir_scan (mailbox_t mailbox, size_t msgno, size_t *pcount) | ||
146 | { | ||
147 | return 0; | ||
148 | } | ||
149 | |||
150 | /* FIXME: How to handle a shrink ? meaning, the &^$^@%#@^& user start two | ||
151 | browsers and deleted emails in one session. My views is that we should | ||
152 | scream bloody murder and hunt them with a machette. But for now just play | ||
153 | dumb, but maybe the best approach is to pack our things and leave | ||
154 | .i.e exit()/abort(). */ | ||
155 | static int | ||
156 | maildir_is_updated (mailbox_t mailbox) | ||
157 | { | ||
158 | return -1; | ||
159 | } | ||
160 | |||
161 | static int | ||
162 | maildir_expunge (mailbox_t mailbox) | ||
163 | { | ||
164 | return -1; | ||
165 | } | ||
166 | |||
167 | static int | ||
168 | maildir_get_size (mailbox_t mailbox, off_t *psize) | ||
169 | { | ||
170 | return -1; | ||
171 | } | ||
172 | |||
173 | static int | ||
174 | maildir_save_attributes (mailbox_t mailbox) | ||
175 | { | ||
176 | return -1; | ||
177 | } | ||
178 | |||
179 | static int | ||
180 | maildir_get_message (mailbox_t mailbox, size_t msgno, message_t *pmsg) | ||
181 | { | ||
182 | return -1; | ||
183 | } | ||
184 | |||
185 | static int | ||
186 | maildir_append_message (mailbox_t mailbox, message_t msg) | ||
187 | { | ||
188 | return -1; | ||
189 | } | ||
190 | |||
191 | static int | ||
192 | maildir_messages_count (mailbox_t mailbox, size_t *pcount) | ||
193 | { | ||
194 | return -1; | ||
195 | } | ||
196 | |||
197 | /* A "recent" message is the one not marked with MU_ATTRIBUTE_SEEN | ||
198 | ('O' in the Status header), i.e. a message that is first seen | ||
199 | by the current session (see attributes.h) */ | ||
200 | static int | ||
201 | maildir_messages_recent (mailbox_t mailbox, size_t *pcount) | ||
202 | { | ||
203 | return -1; | ||
204 | } | ||
205 | |||
206 | /* An "unseen" message is the one that has not been read yet */ | ||
207 | static int | ||
208 | maildir_message_unseen (mailbox_t mailbox, size_t *pmsgno) | ||
209 | { | ||
210 | return -1; | ||
211 | } | ||
212 | |||
213 | static int | ||
214 | maildir_uidvalidity (mailbox_t mailbox, unsigned long *puidvalidity) | ||
215 | { | ||
216 | return -1; | ||
217 | } | ||
218 | |||
219 | static int | ||
220 | maildir_uidnext (mailbox_t mailbox, size_t *puidnext) | ||
221 | { | ||
222 | return -1; | ||
223 | } | ||
224 |
mailbox/mbx_mbox.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/mbx_mboxscan.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/mbx_mh.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/mbx_pop.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/url_imap.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public | ||
15 | License along with this library; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #ifdef ENABLE_IMAP | ||
23 | |||
24 | #include <errno.h> | ||
25 | #include <stdlib.h> | ||
26 | #include <string.h> | ||
27 | #include <errno.h> | ||
28 | #ifdef HAVE_STRINGS_H | ||
29 | # include <strings.h> | ||
30 | #endif | ||
31 | |||
32 | #include <registrar0.h> | ||
33 | #include <url0.h> | ||
34 | |||
35 | static void url_imap_destroy (url_t url); | ||
36 | |||
37 | static void | ||
38 | url_imap_destroy (url_t url) | ||
39 | { | ||
40 | (void)url; | ||
41 | } | ||
42 | |||
43 | /* | ||
44 | IMAP URL: | ||
45 | imap://[<user>[;AUTH=<auth>]@]<host>[/<mailbox>] | ||
46 | else | ||
47 | imap://[<user>[:<pass>]@]<host>[/<mailbox>] | ||
48 | */ | ||
49 | |||
50 | int | ||
51 | _url_imap_init (url_t url) | ||
52 | { | ||
53 | int status = 0; | ||
54 | |||
55 | url->_destroy = url_imap_destroy; | ||
56 | |||
57 | status = url_parse (url); | ||
58 | |||
59 | if (status) | ||
60 | return status; | ||
61 | |||
62 | if(!url->host || url->query) | ||
63 | return EINVAL; | ||
64 | |||
65 | /* is it pop? */ | ||
66 | if (strcmp ("imap", url->scheme) != 0) | ||
67 | return EINVAL; | ||
68 | |||
69 | /* fill in default port, if necesary */ | ||
70 | if (url->port == 0) | ||
71 | url->port = MU_IMAP_PORT; | ||
72 | |||
73 | /* fill in default auth, if necessary */ | ||
74 | if (!url->auth) | ||
75 | { | ||
76 | url->auth = malloc (1 + 1); | ||
77 | if (!url->auth) | ||
78 | return ENOMEM; | ||
79 | |||
80 | url->auth[0] = '*'; | ||
81 | url->auth[1] = '\0'; | ||
82 | } | ||
83 | |||
84 | return status; | ||
85 | } | ||
86 | |||
87 | #endif |
mailbox/url_mbox.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public | ||
15 | License along with this library; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #include <errno.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <stdio.h> | ||
25 | #include <string.h> | ||
26 | |||
27 | #ifdef HAVE_STRINGS_H | ||
28 | # include <strings.h> | ||
29 | #endif | ||
30 | |||
31 | #include <registrar0.h> | ||
32 | #include <url0.h> | ||
33 | |||
34 | static void url_mbox_destroy (url_t purl); | ||
35 | |||
36 | static void | ||
37 | url_mbox_destroy (url_t url) | ||
38 | { | ||
39 | (void) url; | ||
40 | } | ||
41 | |||
42 | /* Default mailbox path generator */ | ||
43 | static char * | ||
44 | _url_path_default (const char *spooldir, const char *user, int unused) | ||
45 | { | ||
46 | char *mbox = malloc (sizeof(spooldir) + strlen(user) + 2); | ||
47 | if (!mbox) | ||
48 | errno = ENOMEM; | ||
49 | else | ||
50 | sprintf (mbox, "%s/%s", spooldir, user); | ||
51 | return mbox; | ||
52 | } | ||
53 | |||
54 | /* Hashed indexing */ | ||
55 | static char * | ||
56 | _url_path_hashed (const char *spooldir, const char *user, int param) | ||
57 | { | ||
58 | int i; | ||
59 | int ulen = strlen (user); | ||
60 | char *mbox; | ||
61 | unsigned hash; | ||
62 | |||
63 | if (param > ulen) | ||
64 | param = ulen; | ||
65 | for (i = 0, hash = 0; i < param; i++) | ||
66 | hash += user[i]; | ||
67 | |||
68 | mbox = malloc (ulen + strlen (spooldir) + 5); | ||
69 | sprintf (mbox, "%s/%02X/%s", spooldir, hash % 256, user); | ||
70 | return mbox; | ||
71 | } | ||
72 | |||
73 | static int transtab[] = { | ||
74 | 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', | ||
75 | 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', | ||
76 | 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', | ||
77 | 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', | ||
78 | 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', | ||
79 | 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', | ||
80 | 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', | ||
81 | 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', | ||
82 | 'm', 'a', 'b', 'c', 'd', 'e', 'f', 'g', | ||
83 | 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', | ||
84 | 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', | ||
85 | 'x', 'y', 'z', 'b', 'c', 'd', 'e', 'f', | ||
86 | 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g', | ||
87 | 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', | ||
88 | 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', | ||
89 | 'x', 'y', 'z', 'b', 'c', 'd', 'e', 'f', | ||
90 | 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', | ||
91 | 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', | ||
92 | 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', | ||
93 | 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', | ||
94 | 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', | ||
95 | 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', | ||
96 | 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', | ||
97 | 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', | ||
98 | 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', | ||
99 | 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', | ||
100 | 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', | ||
101 | 'y', 'z', 'b', 'c', 'd', 'e', 'f', 'g', | ||
102 | 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', | ||
103 | 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', | ||
104 | 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', | ||
105 | 'y', 'z', 'b', 'c', 'd', 'e', 'f', 'g' | ||
106 | }; | ||
107 | |||
108 | /* Forward Indexing */ | ||
109 | static char * | ||
110 | _url_path_index (const char *spooldir, const char *iuser, int index_depth) | ||
111 | { | ||
112 | const unsigned char* user = (const unsigned char*) iuser; | ||
113 | int i, ulen = strlen (user); | ||
114 | char *mbox, *p; | ||
115 | |||
116 | if (ulen == 0) | ||
117 | return NULL; | ||
118 | |||
119 | mbox = malloc (ulen + strlen (spooldir) + 2*index_depth + 2); | ||
120 | strcpy (mbox, spooldir); | ||
121 | p = mbox + strlen (mbox); | ||
122 | for (i = 0; i < index_depth && i < ulen; i++) | ||
123 | { | ||
124 | *p++ = '/'; | ||
125 | *p++ = transtab[ user[i] ]; | ||
126 | } | ||
127 | for (; i < index_depth; i++) | ||
128 | { | ||
129 | *p++ = '/'; | ||
130 | *p++ = transtab[ user[ulen-1] ]; | ||
131 | } | ||
132 | *p++ = '/'; | ||
133 | strcpy (p, user); | ||
134 | return mbox; | ||
135 | } | ||
136 | |||
137 | /* Reverse Indexing */ | ||
138 | static char * | ||
139 | _url_path_rev_index (const char *spooldir, const char *iuser, int index_depth) | ||
140 | { | ||
141 | const unsigned char* user = (const unsigned char*) iuser; | ||
142 | int i, ulen = strlen (user); | ||
143 | char *mbox, *p; | ||
144 | |||
145 | if (ulen == 0) | ||
146 | return NULL; | ||
147 | |||
148 | mbox = malloc (ulen + strlen (spooldir) + 2*index_depth + 1); | ||
149 | strcpy (mbox, spooldir); | ||
150 | p = mbox + strlen (mbox); | ||
151 | for (i = 0; i < index_depth && i < ulen; i++) | ||
152 | { | ||
153 | *p++ = '/'; | ||
154 | *p++ = transtab[ user[ulen - i - 1] ]; | ||
155 | } | ||
156 | for (; i < index_depth; i++) | ||
157 | { | ||
158 | *p++ = '/'; | ||
159 | *p++ = transtab[ user[0] ]; | ||
160 | } | ||
161 | *p++ = '/'; | ||
162 | strcpy (p, user); | ||
163 | return mbox; | ||
164 | } | ||
165 | |||
166 | /* | ||
167 | UNIX Mbox | ||
168 | mbox:path[;type=TYPE][;param=PARAM][;user=USERNAME] | ||
169 | */ | ||
170 | int | ||
171 | _url_mbox_init (url_t url) | ||
172 | { | ||
173 | const char *name = url_to_string (url); | ||
174 | size_t len = strlen (name); | ||
175 | char *p; | ||
176 | |||
177 | /* reject the obvious */ | ||
178 | if (name == NULL || strncmp (MU_MBOX_SCHEME, name, MU_MBOX_SCHEME_LEN) != 0 | ||
179 | || len < (MU_MBOX_SCHEME_LEN + 1) /* (scheme)+1(path)*/) | ||
180 | return EINVAL; | ||
181 | |||
182 | /* do I need to decode url encoding '% hex hex' ? */ | ||
183 | |||
184 | /* TYPE */ | ||
185 | url->_destroy = url_mbox_destroy; | ||
186 | |||
187 | /* SCHEME */ | ||
188 | url->scheme = strdup (MU_MBOX_SCHEME); | ||
189 | if (url->scheme == NULL) | ||
190 | { | ||
191 | url_mbox_destroy (url); | ||
192 | return ENOMEM; | ||
193 | } | ||
194 | |||
195 | /* PATH */ | ||
196 | name += MU_MBOX_SCHEME_LEN; /* pass the scheme */ | ||
197 | url->path = strdup (name); | ||
198 | if (url->path == NULL) | ||
199 | { | ||
200 | url_mbox_destroy (url); | ||
201 | return ENOMEM; | ||
202 | } | ||
203 | p = strchr (url->path, ';'); | ||
204 | if (p) | ||
205 | { | ||
206 | char *(*fun)() = _url_path_default; | ||
207 | char *user = NULL; | ||
208 | int param = 0; | ||
209 | |||
210 | *p++ = 0; | ||
211 | while (p) | ||
212 | { | ||
213 | char *q = strchr (p, ';'); | ||
214 | if (q) | ||
215 | *q++ = 0; | ||
216 | if (strncasecmp (p, "type=", 5) == 0) | ||
217 | { | ||
218 | char *type = p + 5; | ||
219 | |||
220 | if (strcmp (type, "hash") == 0) | ||
221 | fun = _url_path_hashed; | ||
222 | else if (strcmp (type, "index") == 0) | ||
223 | fun = _url_path_index; | ||
224 | else if (strcmp (type, "rev-index") == 0) | ||
225 | fun = _url_path_rev_index; | ||
226 | else | ||
227 | { | ||
228 | url_mbox_destroy (url); | ||
229 | return ENOENT; | ||
230 | } | ||
231 | } | ||
232 | else if (strncasecmp (p, "user=", 5) == 0) | ||
233 | { | ||
234 | user = p + 5; | ||
235 | } | ||
236 | else if (strncasecmp (p, "param=", 6) == 0) | ||
237 | { | ||
238 | param = strtoul (p+6, NULL, 0); | ||
239 | } | ||
240 | p = q; | ||
241 | } | ||
242 | |||
243 | if (user) | ||
244 | { | ||
245 | p = fun (url->path, user, param); | ||
246 | free (url->path); | ||
247 | url->path = p; | ||
248 | } | ||
249 | else | ||
250 | { | ||
251 | url_mbox_destroy (url); | ||
252 | return ENOENT; | ||
253 | } | ||
254 | } | ||
255 | |||
256 | return 0; | ||
257 | } | ||
258 |
mailbox/url_mh.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public | ||
15 | License along with this library; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #ifdef ENABLE_MH | ||
23 | |||
24 | #include <errno.h> | ||
25 | #include <stdlib.h> | ||
26 | #include <string.h> | ||
27 | |||
28 | #include <url0.h> | ||
29 | #include <registrar0.h> | ||
30 | |||
31 | static void | ||
32 | url_mh_destroy (url_t url) | ||
33 | { | ||
34 | (void) url; | ||
35 | } | ||
36 | |||
37 | /* | ||
38 | MH url | ||
39 | mh:path | ||
40 | */ | ||
41 | int | ||
42 | _url_mh_init (url_t url) | ||
43 | { | ||
44 | const char *name = url_to_string (url); | ||
45 | size_t len = strlen (name); | ||
46 | |||
47 | /* reject the obvious */ | ||
48 | if (name == NULL || strncmp (MU_MH_SCHEME, name, MU_MH_SCHEME_LEN) != 0 | ||
49 | || len < (MU_MH_SCHEME_LEN + 1) /* (scheme)+1(path)*/) | ||
50 | return EINVAL; | ||
51 | |||
52 | /* do I need to decode url encoding '% hex hex' ? */ | ||
53 | |||
54 | /* TYPE */ | ||
55 | url->_destroy = url_mh_destroy; | ||
56 | |||
57 | /* SCHEME */ | ||
58 | url->scheme = strdup (MU_MH_SCHEME); | ||
59 | if (url->scheme == NULL) | ||
60 | { | ||
61 | url_mh_destroy (url); | ||
62 | return ENOMEM; | ||
63 | } | ||
64 | |||
65 | /* PATH */ | ||
66 | name += MU_MH_SCHEME_LEN; /* pass the scheme */ | ||
67 | url->path = strdup (name); | ||
68 | if (url->path == NULL) | ||
69 | { | ||
70 | url_mh_destroy (url); | ||
71 | return ENOMEM; | ||
72 | } | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | #endif |
mailbox/url_pop.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public | ||
15 | License along with this library; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #ifdef ENABLE_POP | ||
23 | |||
24 | #include <errno.h> | ||
25 | #include <stdlib.h> | ||
26 | #include <string.h> | ||
27 | #include <errno.h> | ||
28 | #ifdef HAVE_STRINGS_H | ||
29 | # include <strings.h> | ||
30 | #endif | ||
31 | |||
32 | #include <url0.h> | ||
33 | #include <registrar0.h> | ||
34 | |||
35 | static void url_pop_destroy (url_t url); | ||
36 | |||
37 | static void | ||
38 | url_pop_destroy (url_t url) | ||
39 | { | ||
40 | (void)url; | ||
41 | } | ||
42 | |||
43 | /* | ||
44 | POP URL: | ||
45 | pop://[<user>[;AUTH=<auth>]@]<host>[:<port>] | ||
46 | or: | ||
47 | pop://[<user>[:pass]@]<host>[:<port>] | ||
48 | */ | ||
49 | |||
50 | int | ||
51 | _url_pop_init (url_t url) | ||
52 | { | ||
53 | int status = 0; | ||
54 | |||
55 | url->_destroy = url_pop_destroy; | ||
56 | |||
57 | status = url_parse(url); | ||
58 | |||
59 | if(status) | ||
60 | return status; | ||
61 | |||
62 | /* is it pop? */ | ||
63 | if (strcmp ("pop", url->scheme) != 0) | ||
64 | return EINVAL; | ||
65 | |||
66 | /* not valid in a pop url */ | ||
67 | if (url->path || url->query || !url->host) | ||
68 | return EINVAL; | ||
69 | |||
70 | if (url->port == 0) | ||
71 | url->port = MU_POP_PORT; | ||
72 | |||
73 | return status; | ||
74 | } | ||
75 | |||
76 | #endif |
-
Please register or sign in to post a comment