Commit 11bc148b 11bc148b1877b7c692f28d90847bc74737068416 by Sergey Poznyakoff

'Moved from ../'

1 parent 887e7b3b
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef ENABLE_IMAP
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <registrar0.h>
#include <url0.h>
static void url_imap_destroy (url_t url);
static void
url_imap_destroy (url_t url)
{
(void)url;
}
/*
IMAP URL:
imap://[<user>[;AUTH=<auth>]@]<host>[/<mailbox>]
else
imap://[<user>[:<pass>]@]<host>[/<mailbox>]
*/
int
_url_imap_init (url_t url)
{
int status = 0;
url->_destroy = url_imap_destroy;
status = url_parse (url);
if (status)
return status;
if(!url->host || url->query)
return EINVAL;
/* is it pop? */
if (strcmp ("imap", url->scheme) != 0)
return EINVAL;
/* fill in default port, if necesary */
if (url->port == 0)
url->port = MU_IMAP_PORT;
/* fill in default auth, if necessary */
if (!url->auth)
{
url->auth = malloc (1 + 1);
if (!url->auth)
return ENOMEM;
url->auth[0] = '*';
url->auth[1] = '\0';
}
return status;
}
#endif
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* First draft by Jeff Bailey based on mbox by Alain Magloire */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <errno.h>
#ifdef WITH_PTHREAD
# ifdef HAVE_PTHREAD_H
# define _XOPEN_SOURCE 500
# include <pthread.h>
# endif
#endif
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <mailbox0.h>
#include <registrar0.h>
#include <mailutils/address.h>
#include <mailutils/attribute.h>
#include <mailutils/body.h>
#include <mailutils/debug.h>
#include <mailutils/envelope.h>
#include <mailutils/errno.h>
#include <mailutils/error.h>
#include <mailutils/header.h>
#include <mailutils/locker.h>
#include <mailutils/message.h>
#include <mailutils/mutil.h>
#include <mailutils/observer.h>
#include <mailutils/property.h>
#include <mailutils/stream.h>
#include <mailutils/url.h>
/* Mailbox concrete implementation. */
static int maildir_open __P ((mailbox_t, int));
static int maildir_close __P ((mailbox_t));
static void maildir_destroy __P ((mailbox_t));
static int maildir_get_message __P ((mailbox_t, size_t, message_t *));
/* static int maildir_get_message_by_uid __P ((mailbox_t, size_t, message_t *)); */
static int maildir_append_message __P ((mailbox_t, message_t));
static int maildir_messages_count __P ((mailbox_t, size_t *));
static int maildir_messages_recent __P ((mailbox_t, size_t *));
static int maildir_message_unseen __P ((mailbox_t, size_t *));
static int maildir_expunge __P ((mailbox_t));
static int maildir_save_attributes __P ((mailbox_t));
static int maildir_uidvalidity __P ((mailbox_t, unsigned long *));
static int maildir_uidnext __P ((mailbox_t, size_t *));
static int maildir_scan __P ((mailbox_t, size_t, size_t *));
static int maildir_is_updated __P ((mailbox_t));
static int maildir_get_size __P ((mailbox_t, off_t *));
int
_mailbox_maildir_init (mailbox_t mailbox)
{
if (mailbox == NULL)
return EINVAL;
/* Overloading the defaults. */
mailbox->_destroy = maildir_destroy;
mailbox->_open = maildir_open;
mailbox->_close = maildir_close;
/* Overloading of the entire mailbox object methods. */
mailbox->_get_message = maildir_get_message;
mailbox->_append_message = maildir_append_message;
mailbox->_messages_count = maildir_messages_count;
mailbox->_messages_recent = maildir_messages_recent;
mailbox->_message_unseen = maildir_message_unseen;
mailbox->_expunge = maildir_expunge;
mailbox->_save_attributes = maildir_save_attributes;
mailbox->_uidvalidity = maildir_uidvalidity;
mailbox->_uidnext = maildir_uidnext;
mailbox->_scan = maildir_scan;
mailbox->_is_updated = maildir_is_updated;
mailbox->_get_size = maildir_get_size;
return 0; /* okdoke */
}
/* Destruct maildir setup */
static void
maildir_destroy (mailbox_t mailbox)
{
return;
}
/* Open the file. For MU_STREAM_READ, the code tries mmap() first and fall
back to normal file. */
static int
maildir_open (mailbox_t mailbox, int flags)
{
return -1;
}
static int
maildir_close (mailbox_t mailbox)
{
return -1;
}
/* Cover function that call the real thing, maildir_scan(), with
notification set. */
static int
maildir_scan (mailbox_t mailbox, size_t msgno, size_t *pcount)
{
return 0;
}
/* FIXME: How to handle a shrink ? meaning, the &^$^@%#@^& user start two
browsers and deleted emails in one session. My views is that we should
scream bloody murder and hunt them with a machette. But for now just play
dumb, but maybe the best approach is to pack our things and leave
.i.e exit()/abort(). */
static int
maildir_is_updated (mailbox_t mailbox)
{
return -1;
}
static int
maildir_expunge (mailbox_t mailbox)
{
return -1;
}
static int
maildir_get_size (mailbox_t mailbox, off_t *psize)
{
return -1;
}
static int
maildir_save_attributes (mailbox_t mailbox)
{
return -1;
}
static int
maildir_get_message (mailbox_t mailbox, size_t msgno, message_t *pmsg)
{
return -1;
}
static int
maildir_append_message (mailbox_t mailbox, message_t msg)
{
return -1;
}
static int
maildir_messages_count (mailbox_t mailbox, size_t *pcount)
{
return -1;
}
/* A "recent" message is the one not marked with MU_ATTRIBUTE_SEEN
('O' in the Status header), i.e. a message that is first seen
by the current session (see attributes.h) */
static int
maildir_messages_recent (mailbox_t mailbox, size_t *pcount)
{
return -1;
}
/* An "unseen" message is the one that has not been read yet */
static int
maildir_message_unseen (mailbox_t mailbox, size_t *pmsgno)
{
return -1;
}
static int
maildir_uidvalidity (mailbox_t mailbox, unsigned long *puidvalidity)
{
return -1;
}
static int
maildir_uidnext (mailbox_t mailbox, size_t *puidnext)
{
return -1;
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <registrar0.h>
#include <url0.h>
static void url_mbox_destroy (url_t purl);
static void
url_mbox_destroy (url_t url)
{
(void) url;
}
/* Default mailbox path generator */
static char *
_url_path_default (const char *spooldir, const char *user, int unused)
{
char *mbox = malloc (sizeof(spooldir) + strlen(user) + 2);
if (!mbox)
errno = ENOMEM;
else
sprintf (mbox, "%s/%s", spooldir, user);
return mbox;
}
/* Hashed indexing */
static char *
_url_path_hashed (const char *spooldir, const char *user, int param)
{
int i;
int ulen = strlen (user);
char *mbox;
unsigned hash;
if (param > ulen)
param = ulen;
for (i = 0, hash = 0; i < param; i++)
hash += user[i];
mbox = malloc (ulen + strlen (spooldir) + 5);
sprintf (mbox, "%s/%02X/%s", spooldir, hash % 256, user);
return mbox;
}
static int transtab[] = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', 'b', 'c', 'd', 'e', 'f',
'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', 'b', 'c', 'd', 'e', 'f',
'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', 'b', 'c', 'd', 'e', 'f', 'g',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', 'b', 'c', 'd', 'e', 'f', 'g'
};
/* Forward Indexing */
static char *
_url_path_index (const char *spooldir, const char *iuser, int index_depth)
{
const unsigned char* user = (const unsigned char*) iuser;
int i, ulen = strlen (user);
char *mbox, *p;
if (ulen == 0)
return NULL;
mbox = malloc (ulen + strlen (spooldir) + 2*index_depth + 2);
strcpy (mbox, spooldir);
p = mbox + strlen (mbox);
for (i = 0; i < index_depth && i < ulen; i++)
{
*p++ = '/';
*p++ = transtab[ user[i] ];
}
for (; i < index_depth; i++)
{
*p++ = '/';
*p++ = transtab[ user[ulen-1] ];
}
*p++ = '/';
strcpy (p, user);
return mbox;
}
/* Reverse Indexing */
static char *
_url_path_rev_index (const char *spooldir, const char *iuser, int index_depth)
{
const unsigned char* user = (const unsigned char*) iuser;
int i, ulen = strlen (user);
char *mbox, *p;
if (ulen == 0)
return NULL;
mbox = malloc (ulen + strlen (spooldir) + 2*index_depth + 1);
strcpy (mbox, spooldir);
p = mbox + strlen (mbox);
for (i = 0; i < index_depth && i < ulen; i++)
{
*p++ = '/';
*p++ = transtab[ user[ulen - i - 1] ];
}
for (; i < index_depth; i++)
{
*p++ = '/';
*p++ = transtab[ user[0] ];
}
*p++ = '/';
strcpy (p, user);
return mbox;
}
/*
UNIX Mbox
mbox:path[;type=TYPE][;param=PARAM][;user=USERNAME]
*/
int
_url_mbox_init (url_t url)
{
const char *name = url_to_string (url);
size_t len = strlen (name);
char *p;
/* reject the obvious */
if (name == NULL || strncmp (MU_MBOX_SCHEME, name, MU_MBOX_SCHEME_LEN) != 0
|| len < (MU_MBOX_SCHEME_LEN + 1) /* (scheme)+1(path)*/)
return EINVAL;
/* do I need to decode url encoding '% hex hex' ? */
/* TYPE */
url->_destroy = url_mbox_destroy;
/* SCHEME */
url->scheme = strdup (MU_MBOX_SCHEME);
if (url->scheme == NULL)
{
url_mbox_destroy (url);
return ENOMEM;
}
/* PATH */
name += MU_MBOX_SCHEME_LEN; /* pass the scheme */
url->path = strdup (name);
if (url->path == NULL)
{
url_mbox_destroy (url);
return ENOMEM;
}
p = strchr (url->path, ';');
if (p)
{
char *(*fun)() = _url_path_default;
char *user = NULL;
int param = 0;
*p++ = 0;
while (p)
{
char *q = strchr (p, ';');
if (q)
*q++ = 0;
if (strncasecmp (p, "type=", 5) == 0)
{
char *type = p + 5;
if (strcmp (type, "hash") == 0)
fun = _url_path_hashed;
else if (strcmp (type, "index") == 0)
fun = _url_path_index;
else if (strcmp (type, "rev-index") == 0)
fun = _url_path_rev_index;
else
{
url_mbox_destroy (url);
return ENOENT;
}
}
else if (strncasecmp (p, "user=", 5) == 0)
{
user = p + 5;
}
else if (strncasecmp (p, "param=", 6) == 0)
{
param = strtoul (p+6, NULL, 0);
}
p = q;
}
if (user)
{
p = fun (url->path, user, param);
free (url->path);
url->path = p;
}
else
{
url_mbox_destroy (url);
return ENOENT;
}
}
return 0;
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef ENABLE_MH
#include <errno.h>
#include <folder0.h>
#include <registrar0.h>
static struct _record _mh_record =
{
MU_MH_SCHEME,
_url_mh_init, /* Url init. */
_mailbox_mh_init, /* Mailbox init. */
NULL, /* Mailer init. */
_folder_mh_init, /* Folder init. */
NULL, /* back pointer. */
NULL, /* _is_scheme method. */
NULL, /* _get_url method. */
NULL, /* _get_mailbox method. */
NULL, /* _get_mailer method. */
NULL /* _get_folder method. */
};
record_t mh_record = &_mh_record;
int
_folder_mh_init (folder_t folder)
{
(void)folder;
return 0;
}
#else
#include <stdio.h>
#include <registrar0.h>
record_t mh_record = NULL;
#endif
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef ENABLE_MH
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <url0.h>
#include <registrar0.h>
static void
url_mh_destroy (url_t url)
{
(void) url;
}
/*
MH url
mh:path
*/
int
_url_mh_init (url_t url)
{
const char *name = url_to_string (url);
size_t len = strlen (name);
/* reject the obvious */
if (name == NULL || strncmp (MU_MH_SCHEME, name, MU_MH_SCHEME_LEN) != 0
|| len < (MU_MH_SCHEME_LEN + 1) /* (scheme)+1(path)*/)
return EINVAL;
/* do I need to decode url encoding '% hex hex' ? */
/* TYPE */
url->_destroy = url_mh_destroy;
/* SCHEME */
url->scheme = strdup (MU_MH_SCHEME);
if (url->scheme == NULL)
{
url_mh_destroy (url);
return ENOMEM;
}
/* PATH */
name += MU_MH_SCHEME_LEN; /* pass the scheme */
url->path = strdup (name);
if (url->path == NULL)
{
url_mh_destroy (url);
return ENOMEM;
}
return 0;
}
#endif
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef ENABLE_POP
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <mailutils/auth.h>
#include <mailutils/mailbox.h>
#include <folder0.h>
#include <registrar0.h>
#include <url0.h>
/* We export url parsing and the initialisation of
the mailbox, via the register entry/record. */
static struct _record _pop_record =
{
MU_POP_SCHEME,
_url_pop_init, /* Url init. */
_mailbox_pop_init, /* Mailbox init. */
NULL, /* Mailer init. */
_folder_pop_init, /* Folder init. */
NULL, /* No need for an back pointer. */
NULL, /* _is_scheme method. */
NULL, /* _get_url method. */
NULL, /* _get_mailbox method. */
NULL, /* _get_mailer method. */
NULL /* _get_folder method. */
};
record_t pop_record = &_pop_record;
static int folder_pop_open __P ((folder_t, int));
static int folder_pop_close __P ((folder_t));
static int folder_pop_get_authority __P ((folder_t, authority_t *));
extern int _pop_user __P ((authority_t));
extern int _pop_apop __P ((authority_t));
/* XXX: The way, the POP folder is handle is not clean at all.
the I/O functions should have been here on folder, not in mbx_pop.c */
int
_folder_pop_init (folder_t folder)
{
int status;
/* Set the authority early:
(1) so we can check for errors.
(2) allow the client to get the authority for setting the ticket
before the open. */
status = folder_pop_get_authority (folder, NULL);
if (status != 0)
return status;
folder->_open = folder_pop_open;
folder->_close = folder_pop_close;
return 0;
}
static int
folder_pop_open (folder_t folder, int flags)
{
mailbox_t mbox = folder->data;
return mailbox_open (mbox, flags);
}
static int
folder_pop_close (folder_t folder)
{
mailbox_t mbox = folder->data;
return mailbox_close (mbox);
}
static int
folder_pop_get_authority (folder_t folder, authority_t *pauth)
{
int status = 0;
if (folder->authority == NULL)
{
/* assert (folder->url); */
if (folder->url == NULL)
return EINVAL;
if (folder->url->auth == NULL
|| strcasecmp (folder->url->auth, "*") == 0)
{
status = authority_create (&folder->authority, NULL, folder);
authority_set_authenticate (folder->authority, _pop_user, folder);
}
/*
"+apop" could be supported.
Anything else starting with "+" is an extension mechanism.
Without a "+" it's a SASL mechanism.
*/
else if (strcasecmp (folder->url->auth, "+APOP") == 0)
{
status = authority_create (&folder->authority, NULL, folder);
authority_set_authenticate (folder->authority, _pop_apop, folder);
}
else
{
status = ENOSYS;
}
}
if (pauth)
*pauth = folder->authority;
return status;
}
#else
#include <stdio.h>
#include <registrar0.h>
record_t pop_record = NULL;
#endif
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef ENABLE_POP
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <url0.h>
#include <registrar0.h>
static void url_pop_destroy (url_t url);
static void
url_pop_destroy (url_t url)
{
(void)url;
}
/*
POP URL:
pop://[<user>[;AUTH=<auth>]@]<host>[:<port>]
or:
pop://[<user>[:pass]@]<host>[:<port>]
*/
int
_url_pop_init (url_t url)
{
int status = 0;
url->_destroy = url_pop_destroy;
status = url_parse(url);
if(status)
return status;
/* is it pop? */
if (strcmp ("pop", url->scheme) != 0)
return EINVAL;
/* not valid in a pop url */
if (url->path || url->query || !url->host)
return EINVAL;
if (url->port == 0)
url->port = MU_POP_PORT;
return status;
}
#endif