added url support for MH mailboxes
Showing
5 changed files
with
160 additions
and
3 deletions
... | @@ -2,6 +2,8 @@ | ... | @@ -2,6 +2,8 @@ |
2 | 2 | ||
3 | * mailbox/mbx_mh.c: new file | 3 | * mailbox/mbx_mh.c: new file |
4 | no header, no error checking, no hable englais | 4 | no header, no error checking, no hable englais |
5 | * url/url_mh.{c,h}: new files | ||
6 | url support for MH mailboxes | ||
5 | 7 | ||
6 | 2000-01-17 Sean 'Shaleh' Perry | 8 | 2000-01-17 Sean 'Shaleh' Perry |
7 | 9 | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | #include <url_mbox.h> | 18 | #include <url_mbox.h> |
19 | #include <url_unix.h> | 19 | #include <url_unix.h> |
20 | #include <url_mdir.h> | 20 | #include <url_mdir.h> |
21 | #include <url_mh.h> | ||
21 | #include <url_mmdf.h> | 22 | #include <url_mmdf.h> |
22 | #include <url_pop.h> | 23 | #include <url_pop.h> |
23 | #include <url_imap.h> | 24 | #include <url_imap.h> |
... | @@ -57,9 +58,10 @@ static struct url_builtin | ... | @@ -57,9 +58,10 @@ static struct url_builtin |
57 | { &_url_mbox_type, 0, &url_builtin[2] }, | 58 | { &_url_mbox_type, 0, &url_builtin[2] }, |
58 | { &_url_unix_type, 0, &url_builtin[3] }, | 59 | { &_url_unix_type, 0, &url_builtin[3] }, |
59 | { &_url_maildir_type, 0, &url_builtin[4] }, | 60 | { &_url_maildir_type, 0, &url_builtin[4] }, |
60 | { &_url_mmdf_type, 0, &url_builtin[5] }, | 61 | { &_url_mh_type, 0, &url_builtin[5] }, |
61 | { &_url_pop_type, 0, &url_builtin[6] }, | 62 | { &_url_mmdf_type, 0, &url_builtin[6] }, |
62 | { &_url_imap_type, 0, &url_builtin[7] }, | 63 | { &_url_pop_type, 0, &url_builtin[7] }, |
64 | { &_url_imap_type, 0, &url_builtin[8] }, | ||
63 | { &_url_mailto_type, 0, &url_builtin[0] }, | 65 | { &_url_mailto_type, 0, &url_builtin[0] }, |
64 | }; | 66 | }; |
65 | 67 | ... | ... |
url/url_mh.c
0 → 100644
1 | /* GNU mailutils - a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program 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 | ||
12 | GNU Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
17 | |||
18 | #include <url_mdir.h> | ||
19 | #include <stdlib.h> | ||
20 | #include <string.h> | ||
21 | |||
22 | struct url_type _url_maildir_type = | ||
23 | { | ||
24 | "mh://", 5, | ||
25 | "mh://<full_directory_name>", | ||
26 | (int)&_url_mh_type, /* uniq id */ | ||
27 | url_mh_init, url_mh_destroy | ||
28 | }; | ||
29 | |||
30 | void | ||
31 | url_mh_destroy (url_t *purl) | ||
32 | { | ||
33 | if (purl && *purl) | ||
34 | { | ||
35 | url_t url = *purl; | ||
36 | if (url->scheme) | ||
37 | free (url->scheme); | ||
38 | if (url->path) | ||
39 | free (url->path); | ||
40 | free (url); | ||
41 | url = NULL; | ||
42 | } | ||
43 | } | ||
44 | |||
45 | /* | ||
46 | MH URL | ||
47 | mh://path | ||
48 | */ | ||
49 | int | ||
50 | url_mh_init (url_t *purl, const char *name) | ||
51 | { | ||
52 | url_t url; | ||
53 | size_t len; | ||
54 | struct url_type *utype = &_url_mh_type; | ||
55 | |||
56 | /* reject the obvious */ | ||
57 | if (name == NULL || strncmp (utype->scheme, name, utype->len) != 0 | ||
58 | || (len = strlen (name)) < (utype->len + 1) /* (scheme)+1(path)*/) | ||
59 | { | ||
60 | return -1; | ||
61 | } | ||
62 | |||
63 | /* do I need to decode url encoding '% hex hex' ? */ | ||
64 | |||
65 | url = calloc(1, sizeof (*url)); | ||
66 | if (url == NULL) | ||
67 | { | ||
68 | return -1; | ||
69 | } | ||
70 | |||
71 | /* TYPE */ | ||
72 | url->utype = utype; | ||
73 | |||
74 | /* SCHEME */ | ||
75 | url->scheme = malloc (utype->len + 1); | ||
76 | if (url->scheme == NULL) | ||
77 | { | ||
78 | utype->_destroy (&url); | ||
79 | return -1; | ||
80 | } | ||
81 | memcpy (url->scheme, utype->scheme, utype->len + 1 /* including the NULL */); | ||
82 | |||
83 | /* PATH */ | ||
84 | name += utype->len; /* pass the scheme */ | ||
85 | len -= utype->len; /* decremente the len */ | ||
86 | url->path = malloc (len + 1); | ||
87 | if (url->path == NULL) | ||
88 | { | ||
89 | utype->_destroy (&url); | ||
90 | return -1; | ||
91 | } | ||
92 | memcpy (url->path, name, len + 1 /* including the NULL*/); | ||
93 | |||
94 | *purl = url; | ||
95 | return 0; | ||
96 | } |
url/url_mh.h
0 → 100644
1 | /* GNU mailutils - a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program 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 | ||
12 | GNU Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
17 | |||
18 | #ifndef _URL_MH_H | ||
19 | #define _URL_MH_H 1 | ||
20 | |||
21 | #include <url.h> | ||
22 | |||
23 | #ifdef __cplusplus | ||
24 | extern "C" { | ||
25 | #endif | ||
26 | |||
27 | #ifndef __P | ||
28 | # ifdef __STDC__ | ||
29 | # define __P(args) args | ||
30 | # else | ||
31 | # define __P(args) () | ||
32 | # endif | ||
33 | #endif /*!__P */ | ||
34 | |||
35 | /* MH */ | ||
36 | extern int url_mh_init __P ((url_t *, const char *name)); | ||
37 | extern void url_mh_destroy __P ((url_t *)); | ||
38 | |||
39 | extern struct url_type _url_mh_type; | ||
40 | |||
41 | #ifndef INLINE | ||
42 | # ifdef __GNUC__ | ||
43 | # define INLINE __inline__ | ||
44 | # else | ||
45 | # define INLINE | ||
46 | # endif | ||
47 | #endif | ||
48 | |||
49 | #ifdef MU_URL_MACROS | ||
50 | #endif /* MU_URL_MACROS */ | ||
51 | |||
52 | #ifdef __cplusplus | ||
53 | } | ||
54 | #endif | ||
55 | |||
56 | #endif /* URL_MH_H */ |
-
Please register or sign in to post a comment