Commit 1918e4dd 1918e4dd1222234ac4bcfc5ee1e4d1f1d53a674d by Alain Magloire

url_mail.c url_mail.h url_mdir.c url_mdir.h url_mmdf.c

 	url_mmdf.h url_unix.c url_unix.h
 	url_mailto.c url_mailto.h

draft support for maildir, mmdf, unix.
1 parent d8d1ab2f
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 17
18 #include <url_mailto.h> 18 #include <url_mail.h>
19 19
20 struct url_type _url_mailto_type = 20 struct url_type _url_mailto_type =
21 { 21 {
......
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 #include <url_mdir.h>
19 #include <stdlib.h>
20 #include <string.h>
21
22 struct url_type _url_maildir_type =
23 {
24 "maildir://", 10,
25 "maildir://<full_directory_name>",
26 (int)&_url_maildir_type, /* uniq id */
27 url_maildir_init, url_maildir_destroy
28 };
29
30 void
31 url_maildir_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 MAILDIR URL
47 maildir://path
48 */
49 int
50 url_maildir_init (url_t *purl, const char *name)
51 {
52 url_t url;
53 int len;
54 struct url_type *utype = &_url_maildir_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 /* strdup ("maildir://") the hard way */
76 url->scheme = malloc (utype->len + 1);
77 if (url->scheme == NULL)
78 {
79 utype->_destroy (&url);
80 return -1;
81 }
82 memcpy (url->scheme, utype->scheme, utype->len + 1 /* including the NULL */);
83
84 /* PATH */
85 name += utype->len; /* pass the scheme */
86 len -= utype->len; /* decremente the len */
87 url->path = malloc (len + 1);
88 if (url->path == NULL)
89 {
90 utype->_destroy (&url);
91 return -1;
92 }
93 memcpy (url->path, name, len + 1 /* including the NULL*/);
94
95 *purl = url;
96 return 0;
97 }
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_MDIR_H
19 #define _URL_MDIR_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 /* Maildir */
36 extern int url_maildir_init __P ((url_t *, const char *name));
37 extern void url_maildir_destroy __P ((url_t *));
38
39 extern struct url_type _url_maildir_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_MDIR_H */
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 #include <url_mmdf.h>
19 #include <stdlib.h>
20 #include <string.h>
21
22 struct url_type _url_mmdf_type =
23 {
24 "mmdf://", 7,
25 "mmdf://<full_path_name>",
26 (int)&_url_mmdf_type, /* uniq id */
27 url_mmdf_init, url_mmdf_destroy
28 };
29
30 void
31 url_mmdf_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 MMDF URL
47 mmdf://path
48 */
49 int
50 url_mmdf_init (url_t *purl, const char *name)
51 {
52 url_t url;
53 int len;
54 struct url_type *utype = &_url_mmdf_type;
55
56 /* reject the obvious */
57 if (name == NULL || strncmp (utype->scheme, name,
58 utype->len) != 0
59 || (len = strlen (name)) < 8 /* 7(scheme)+1(path)*/)
60 {
61 return -1;
62 }
63
64 /* do I need to decode url encoding '% hex hex' ? */
65
66 url = calloc(1, sizeof (*url));
67 if (url == NULL)
68 {
69 return -1;
70 }
71
72 /* TYPE */
73 url->utype = utype;
74
75 /* SCHEME */
76 /* strdup ("mmdf://") the hard way */
77 url->scheme = malloc (utype->len + 1);
78 if (url->scheme == NULL)
79 {
80 utype->_destroy (&url);
81 return -1;
82 }
83 memcpy (url->scheme, utype->scheme, utype->len + 1 /* including the NULL */);
84
85 /* PATH */
86 name += utype->len; /* pass the scheme */
87 len -= utype->len; /* decremente the len */
88 url->path = malloc (len + 1);
89 if (url->path == NULL)
90 {
91 utype->_destroy (&url);
92 return -1;
93 }
94 memcpy (url->path, name, len + 1 /* including the NULL */);
95
96 *purl = url;
97 return 0;
98 }
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_MMDF_H
19 #define _URL_MMDF_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 /* MMDF */
36 extern int url_mmdf_init __P ((url_t *, const char *name));
37 extern void url_mmdf_destroy __P ((url_t *));
38
39 extern struct url_type _url_mmdf_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_MMDF_H */
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 #include <url_unix.h>
19 #include <stdlib.h>
20 #include <string.h>
21
22 struct url_type _url_unix_type =
23 {
24 "unix://", 7,
25 "unix://<full_path_name_of_unix_mbox>",
26 (int)&_url_unix_type, /* uniq id */
27 url_unix_init, url_unix_destroy
28 };
29
30 void
31 url_unix_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 UNIX Mbox
47 unix://path
48 */
49 int
50 url_unix_init (url_t *purl, const char *name)
51 {
52 url_t url;
53 int len;
54 struct url_type *utype = &_url_unix_type;
55
56 /* reject the obvious */
57 if (name == NULL || strncmp (utype->scheme, name, utype->len) != 0
58 || (len = strlen (name)) < utype->len + 1 /* 7(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 /* strdup ("unix://") the hard way */
76 url->scheme = malloc (utype->len + 1);
77 if (url->scheme == NULL)
78 {
79 utype->_destroy (&url);
80 return -1;
81 }
82 memcpy (url->scheme, utype->scheme, utype->len + 1 /* including the NULL */);
83
84 /* PATH */
85 name += utype->len; /* pass the scheme */
86 len -= utype->len; /* decremente the len */
87 url->path = malloc (len + 1);
88 if (url->path == NULL)
89 {
90 utype->_destroy (&url);
91 return -1;
92 }
93 memcpy (url->path, name, len + 1 /* including the NULL*/ );
94
95 *purl = url;
96 return 0;
97 }
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_UNIX_H
19 #define _URL_UNIX_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 /* UNIX MBOX */
36 extern int url_unix_init __P ((url_t *, const char *name));
37 extern void url_unix_destroy __P ((url_t *));
38
39 extern struct url_type _url_unix_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_UNIX_H */