Added to the repository
Showing
2 changed files
with
132 additions
and
0 deletions
mailbox/maildir/folder.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2004 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_MAILDIR | ||
23 | |||
24 | #include <errno.h> | ||
25 | |||
26 | #include <folder0.h> | ||
27 | #include <registrar0.h> | ||
28 | |||
29 | static struct _record _maildir_record = | ||
30 | { | ||
31 | MU_MAILDIR_SCHEME, | ||
32 | _url_maildir_init, /* Url init. */ | ||
33 | _mailbox_maildir_init, /* Mailbox init. */ | ||
34 | NULL, /* Mailer init. */ | ||
35 | _folder_maildir_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 maildir_record = &_maildir_record; | ||
44 | |||
45 | int | ||
46 | _folder_maildir_init (folder_t folder ARG_UNUSED) | ||
47 | { | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | #else | ||
52 | #include <stdio.h> | ||
53 | #include <registrar0.h> | ||
54 | record_t maildir_record = NULL; | ||
55 | #endif |
mailbox/maildir/url.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2004 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_MAILDIR | ||
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_maildir_destroy (url_t url ARG_UNUSED) | ||
33 | { | ||
34 | } | ||
35 | |||
36 | /* | ||
37 | MAILDIR url | ||
38 | maildir:path | ||
39 | */ | ||
40 | int | ||
41 | _url_maildir_init (url_t url) | ||
42 | { | ||
43 | const char *name = url_to_string (url); | ||
44 | size_t len = strlen (name); | ||
45 | |||
46 | /* reject the obvious */ | ||
47 | if (name == NULL | ||
48 | || strncmp (MU_MAILDIR_SCHEME, name, MU_MAILDIR_SCHEME_LEN) != 0 | ||
49 | || len < (MU_MAILDIR_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_maildir_destroy; | ||
56 | |||
57 | /* SCHEME */ | ||
58 | url->scheme = strdup (MU_MAILDIR_SCHEME); | ||
59 | if (url->scheme == NULL) | ||
60 | { | ||
61 | url_maildir_destroy (url); | ||
62 | return ENOMEM; | ||
63 | } | ||
64 | |||
65 | /* PATH */ | ||
66 | name += MU_MAILDIR_SCHEME_LEN; /* pass the scheme */ | ||
67 | url->path = strdup (name); | ||
68 | if (url->path == NULL) | ||
69 | { | ||
70 | url_maildir_destroy (url); | ||
71 | return ENOMEM; | ||
72 | } | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | #endif |
-
Please register or sign in to post a comment