File not needed anymore.
Showing
3 changed files
with
0 additions
and
230 deletions
mailbox/mbox/file.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 | #include <string.h> | ||
23 | #include <errno.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <sys/stat.h> | ||
26 | |||
27 | #include <mailutils/url.h> | ||
28 | |||
29 | #include <mailbox0.h> | ||
30 | #include <registrar0.h> | ||
31 | |||
32 | /* | ||
33 | Caveat there is no specific URL for file mailbox or simple path name, | ||
34 | <path_name> | ||
35 | file:<path_name> | ||
36 | |||
37 | It would be preferrable to use : | ||
38 | maildir:<path> | ||
39 | unix:<path> | ||
40 | mmdf:<path> | ||
41 | This would eliminate heuristic discovery that would turn | ||
42 | out to be wrong. | ||
43 | */ | ||
44 | |||
45 | int | ||
46 | _mailbox_file_init (mailbox_t mbox) | ||
47 | { | ||
48 | struct stat st; | ||
49 | size_t len = 0; | ||
50 | char *path; | ||
51 | int status; | ||
52 | |||
53 | status = url_get_path (mbox->url, NULL, 0, &len); | ||
54 | if (status != 0) | ||
55 | return status; | ||
56 | path = calloc (len + 1, sizeof (char)); | ||
57 | if (path == NULL) | ||
58 | return ENOMEM; | ||
59 | status = url_get_path (mbox->url, path, len + 1, NULL); | ||
60 | if (status != 0) | ||
61 | { | ||
62 | free (path); | ||
63 | return status; | ||
64 | } | ||
65 | |||
66 | /* Sigh, if they want to creat ??? they should know the type of ??? | ||
67 | What is the best course of action ? For the default is mbox if the | ||
68 | file does not exist. */ | ||
69 | if (stat (path, &st) < 0) | ||
70 | { | ||
71 | status = _mailbox_mbox_init (mbox); | ||
72 | } | ||
73 | else if (S_ISDIR (st.st_mode)) | ||
74 | { | ||
75 | /* Is that true ? Are all directories Maildir ?? */ | ||
76 | /* NOT SUPPORTED: status = _mailbox_maildir_init (mbox);*/ | ||
77 | status = ENOSYS; | ||
78 | } | ||
79 | else | ||
80 | { | ||
81 | /* | ||
82 | FIXME: We should do an open() and try | ||
83 | to do a better reconnaissance of the type, | ||
84 | maybe MMDF. For now assume Unix MBox */ | ||
85 | status = _mailbox_mbox_init (mbox); | ||
86 | } | ||
87 | |||
88 | free (path); | ||
89 | return status; | ||
90 | } |
mailbox/url_file.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 <string.h> | ||
25 | |||
26 | #include <url0.h> | ||
27 | #include <registrar0.h> | ||
28 | |||
29 | static void url_file_destroy (url_t purl); | ||
30 | |||
31 | static void | ||
32 | url_file_destroy (url_t url ARG_UNUSED) | ||
33 | { | ||
34 | } | ||
35 | |||
36 | /* | ||
37 | UNIX File | ||
38 | file:path | ||
39 | */ | ||
40 | int | ||
41 | _url_file_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 || strncmp (MU_FILE_SCHEME, name, MU_FILE_SCHEME_LEN) != 0 | ||
48 | || len < (MU_FILE_SCHEME_LEN + 1) /* (scheme)+1(path)*/) | ||
49 | return EINVAL; | ||
50 | |||
51 | /* do I need to decode url encoding '% hex hex' ? */ | ||
52 | |||
53 | /* TYPE */ | ||
54 | url->_destroy = url_file_destroy; | ||
55 | |||
56 | /* SCHEME */ | ||
57 | url->scheme = strdup (MU_FILE_SCHEME); | ||
58 | if (url->scheme == NULL) | ||
59 | { | ||
60 | url_file_destroy (url); | ||
61 | return ENOMEM; | ||
62 | } | ||
63 | |||
64 | /* PATH */ | ||
65 | name += MU_FILE_SCHEME_LEN; /* pass the scheme */ | ||
66 | url->path = strdup (name); | ||
67 | if (url->path == NULL) | ||
68 | { | ||
69 | url_file_destroy (url); | ||
70 | return ENOMEM; | ||
71 | } | ||
72 | |||
73 | return 0; | ||
74 | } |
mailbox/url_path.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 <string.h> | ||
25 | |||
26 | #include <registrar0.h> | ||
27 | #include <url0.h> | ||
28 | |||
29 | static void url_path_destroy (url_t); | ||
30 | |||
31 | static void | ||
32 | url_path_destroy (url_t url ARG_UNUSED) | ||
33 | { | ||
34 | } | ||
35 | |||
36 | int | ||
37 | _url_path_init (url_t url) | ||
38 | { | ||
39 | const char *name = url_to_string (url); | ||
40 | /* reject the obvious */ | ||
41 | if (name == NULL || *name == '\0') | ||
42 | return EINVAL; | ||
43 | |||
44 | /* FIXME: do I need to decode url encoding '% hex hex' ? */ | ||
45 | |||
46 | /* TYPE */ | ||
47 | url->_destroy = url_path_destroy; | ||
48 | |||
49 | /* SCHEME */ | ||
50 | url->scheme = strdup (MU_PATH_SCHEME); | ||
51 | if (url->scheme == NULL) | ||
52 | { | ||
53 | url_path_destroy (url); | ||
54 | return ENOMEM; | ||
55 | } | ||
56 | |||
57 | /* PATH */ | ||
58 | url->path = strdup (name); | ||
59 | if (url->path == NULL) | ||
60 | { | ||
61 | url_path_destroy (url); | ||
62 | return ENOMEM; | ||
63 | } | ||
64 | |||
65 | return 0; | ||
66 | } |
-
Please register or sign in to post a comment