Commit eda27cd4 eda27cd412c1459c397940b067ada1191d13cb26 by Sean 'Shaleh' Perry

added url support for MH mailboxes

1 parent 5a2f11bb
......@@ -2,6 +2,8 @@
* mailbox/mbx_mh.c: new file
no header, no error checking, no hable englais
* url/url_mh.{c,h}: new files
url support for MH mailboxes
2000-01-17 Sean 'Shaleh' Perry
......
......@@ -12,4 +12,5 @@ unix:///var/mail/alain
unix://usr/spool/mail
file:///usr/spool/alain
mdir://home/alain
mh://home/shaleh/Mail/inbox
mmdf://u
......
......@@ -18,6 +18,7 @@
#include <url_mbox.h>
#include <url_unix.h>
#include <url_mdir.h>
#include <url_mh.h>
#include <url_mmdf.h>
#include <url_pop.h>
#include <url_imap.h>
......@@ -57,9 +58,10 @@ static struct url_builtin
{ &_url_mbox_type, 0, &url_builtin[2] },
{ &_url_unix_type, 0, &url_builtin[3] },
{ &_url_maildir_type, 0, &url_builtin[4] },
{ &_url_mmdf_type, 0, &url_builtin[5] },
{ &_url_pop_type, 0, &url_builtin[6] },
{ &_url_imap_type, 0, &url_builtin[7] },
{ &_url_mh_type, 0, &url_builtin[5] },
{ &_url_mmdf_type, 0, &url_builtin[6] },
{ &_url_pop_type, 0, &url_builtin[7] },
{ &_url_imap_type, 0, &url_builtin[8] },
{ &_url_mailto_type, 0, &url_builtin[0] },
};
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <url_mdir.h>
#include <stdlib.h>
#include <string.h>
struct url_type _url_maildir_type =
{
"mh://", 5,
"mh://<full_directory_name>",
(int)&_url_mh_type, /* uniq id */
url_mh_init, url_mh_destroy
};
void
url_mh_destroy (url_t *purl)
{
if (purl && *purl)
{
url_t url = *purl;
if (url->scheme)
free (url->scheme);
if (url->path)
free (url->path);
free (url);
url = NULL;
}
}
/*
MH URL
mh://path
*/
int
url_mh_init (url_t *purl, const char *name)
{
url_t url;
size_t len;
struct url_type *utype = &_url_mh_type;
/* reject the obvious */
if (name == NULL || strncmp (utype->scheme, name, utype->len) != 0
|| (len = strlen (name)) < (utype->len + 1) /* (scheme)+1(path)*/)
{
return -1;
}
/* do I need to decode url encoding '% hex hex' ? */
url = calloc(1, sizeof (*url));
if (url == NULL)
{
return -1;
}
/* TYPE */
url->utype = utype;
/* SCHEME */
url->scheme = malloc (utype->len + 1);
if (url->scheme == NULL)
{
utype->_destroy (&url);
return -1;
}
memcpy (url->scheme, utype->scheme, utype->len + 1 /* including the NULL */);
/* PATH */
name += utype->len; /* pass the scheme */
len -= utype->len; /* decremente the len */
url->path = malloc (len + 1);
if (url->path == NULL)
{
utype->_destroy (&url);
return -1;
}
memcpy (url->path, name, len + 1 /* including the NULL*/);
*purl = url;
return 0;
}
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _URL_MH_H
#define _URL_MH_H 1
#include <url.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*!__P */
/* MH */
extern int url_mh_init __P ((url_t *, const char *name));
extern void url_mh_destroy __P ((url_t *));
extern struct url_type _url_mh_type;
#ifndef INLINE
# ifdef __GNUC__
# define INLINE __inline__
# else
# define INLINE
# endif
#endif
#ifdef MU_URL_MACROS
#endif /* MU_URL_MACROS */
#ifdef __cplusplus
}
#endif
#endif /* URL_MH_H */