Moved mailbox/mbx_file.c to mailbox/mbox/file.c
Showing
1 changed file
with
0 additions
and
90 deletions
mailbox/mbx_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 | } |
-
Please register or sign in to post a comment