Commit dcd6e4da dcd6e4da331e2e751fb880f9861d117e6787a8e1 by Alain Magloire

Cleanup, now we can do autogen.sh;configure;make and things will build.

mailutils/from will use the new mailbox API
mailutils/mail will use the new mailbox API
to convert pop3d(still use libmailbox the old API).

mailutils/mail is incomplete and should is equivalent to
LEGACY mail from Unix98.
1 parent 55b26b61
Showing 76 changed files with 2488 additions and 358 deletions
AUTOMAKE_OPTIONS = gnu 1.4
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = lib libmailbox mail pop3d doc m4
# imap4d
SUBDIRS = include doc m4 lib mailbox from mail libmailbox pop3d
#SUBDIRS = lib mailbox mail doc m4
......
......@@ -17,4 +17,5 @@
/* Define if using libpam */
#undef USE_LIBPAM
#undef HAVE_SNPRINTF
......
#!/bin/sh
aclocal -I m4
libtoolize --copy --automake
libtoolize --automake
autoheader
automake --add-missing --copy --gnu
automake -a
autoconf
......
dnl Process this file with autoconf to procude a configure script. -*-m4-*-
AC_INIT(libmailbox/mailbox.c)
AC_INIT(mailbox/mailbox.c)
AM_INIT_AUTOMAKE(mailutils, 0.9.7.1999.09.12)
AM_CONFIG_HEADER(config.h)
......@@ -20,16 +20,27 @@ AC_ARG_ENABLE(pam,
dnl Check for headers
AC_HEADER_STDC
AC_HEADER_DIRENT
AM_C_PROTOTYPES
AC_CHECK_HEADERS(malloc.h stdlib.h stdio.h errno.h unistd.h\
paths.h sys/file.h syslog.h shadow.h limits.h\
inttypes.h)
AC_CHECK_HEADERS(string.h strings.h, break)
AC_CHECK_HEADERS(errno.h fcntl.h inttypes.h limits.h malloc.h paths.h \
shadow.h stdio.h stdlib.h string.h strings.h sys/file.h syslog.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
dnl Check for working functions
AC_REQUIRE([jm_FUNC_MALLOC])
AC_REQUIRE([jm_FUNC_REALLOC])
AC_FUNC_ALLOCA
AC_FUNC_MEMCMP
AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF),
LIBOBJS="$LIBOBJS snprintf.o")
dnl Check for libraries
......@@ -60,6 +71,7 @@ AC_CHECK_FUNC(socket, [true],
AC_CHECK_LIB(socket, socket, LIBS="-lsocket $LIBS"))
dnl Output Makefiles
AC_OUTPUT(Makefile libmailbox/Makefile mail/Makefile pop3d/Makefile
imap4d/Makefile lib/Makefile doc/Makefile m4/Makefile)
AC_OUTPUT(Makefile include/Makefile include/mailutils/Makefile m4/Makefile doc/Makefile
lib/Makefile mailbox/Makefile mailbox/include/Makefile libmailbox/Makefile
from/Makefile mail/Makefile pop3d/Makefile)
......
CFLAGS = -Wall -pedantic -g -DTESTING
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/lib
bin_PROGRAMS = from
from_DEPENDENCIES = ../mailbox/libmailbox.la
from_LDADD = ../mailbox/libmailbox.la ../lib/libmailutils.a
......@@ -37,223 +37,55 @@
# include <paths.h>
#endif
#include <mailbox.h>
#include <header.h>
#include <mailutils/mailbox.h>
/* FIXME: this should be in the mailbox header */
#ifndef _PATH_MAILDIR
# define _PATH_MAILDIR "/var/spool/mail"
#endif
#ifndef VERSION
# define VERSION "unknown"
# define VERSION "unknow"
#endif
#include "getopt.h"
/* Short options. */
static char const short_options[] =
"H:s:m:hv";
static int opt_from;
static int opt_to;
static int opt_cc;
static int opt_date;
static int opt_subject;
static int opt_status_new;;
static int opt_status_read;;
static int opt_status_old;;
static int opt_size;
static int opt_number;
static int opt_mailbox;
/* long options equivalence */
static struct option long_options[] =
{
{"date", no_argument, &opt_date, 1},
{"from", no_argument, &opt_from, 1},
{"to", no_argument, &opt_to, 1},
{"cc", no_argument, &opt_cc, 1},
{"subject", no_argument, &opt_subject, 1},
{"header", required_argument, NULL, 'H'},
{"status", required_argument, NULL, 's'},
{"size", no_argument, &opt_size, 1},
{"number", no_argument, &opt_number, 1},
{"mailbox", required_argument, &opt_mailbox, 'm'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
/* program name */
static char *program;
static void
usage (int type)
{
switch (type)
{
case 1:
printf("%s (GNU mailutils), version %s\n", program, VERSION);
break;
case 2:
/* Fall Through */
default:
printf ("Usage: %s [OPTION] [mailbox]\n", program);
printf ("Retrieve information from a mailbox\n\
\n\
--date equivalent to --header=Date\n\
--from equivalent to --header=From\n\
--to equivalent to --header=To\n\
--cc equivalent to --header=Cc\n\
--subject equivalent to --header=Subject\n\
--header=HEADER Specify the header to display\n\
HEADER is 'Date', 'From', 'To', 'Cc', 'Subject'\n\
default is --header=From --header=Subject\n\
--status=STATUS Display only message with a given status\n\
STATUS is 'new', 'read', 'unread'\n\
defaut is --status=new --status=read --status=unread\n\
--size Display mailbox size\n\
--number Display total of number of messages\n\
--mailbox=MAILBOX Specify another mailbox\n\
MAILBOX is url(pop://pop.server/user),
a file /var/mail/user, or user.
-v, --version Print version information and exit\n\
-h, --help Show this message\n\
\n\
Mailbox :
$MAIL is check for the default mailbox path, if not set
the environ variables $USER or $LOGNAME are use in the default mail spool.\n\
\n\
Report bugs to <bug-mailutils@gnu.org>.\n");
}
}
int
main(int argc, char *argv[])
main(int argc, char **argv)
{
mailbox_t mbox;
size_t rvalue, i;
size_t count = 0, size;
char *user = NULL;
size_t i;
size_t count = 0;
char *mailbox_name = NULL;
int opt;
char buffer[BUFSIZ];
char from[BUFSIZ];
char subject[BUFSIZ];
/* set program name */
program = argv[0];
if (program && strrchr (program, '/'))
{
program = strrchr (program, '/') + 1;
}
while ((opt = getopt_long (argc, argv, short_options, long_options, NULL))
!= -1)
{
switch (opt)
{
case 'H':
if (strcasecmp (optarg, "From") == 0)
opt_from = 1;
else if (strcasecmp (optarg, "To") == 0)
opt_to = 1;
else if (strcasecmp (optarg, "Cc") == 0)
opt_cc = 1;
else if (strcasecmp (optarg, "Date") == 0)
opt_date = 1;
else if (strcasecmp (optarg, "Subject") == 0)
opt_subject = 1;
else
{
fprintf (stderr, "Unknown header\n");
}
break;
case 's':
if (strcasecmp (optarg, "new") == 0)
opt_status_new = 1;
else if (strcasecmp (optarg, "read") == 0)
opt_status_read = 1;
else if (strcasecmp (optarg, "old") == 0)
opt_status_old = 1;
else
{
fprintf (stderr, "Unknown status\n");
}
break;
case 'm':
mailbox_name = optarg;
break;
case 'v':
usage (1);
exit (0);
break;
case 'h':
usage (2);
exit (0);
break;
default:
//usage (2);
//exit (1);
break;
}
}
int status;
/* have an argument */
if (optind > argc)
{
mailbox_name = argv[optind];
/* is it a URL */
if (strchr (mailbox_name, ':') == NULL)
{
/* is it a filename */
if (mailbox_name[0] != '/')
{
user = mailbox_name; /* a user name */
mailbox_name = NULL;
}
}
}
else if (getenv ("MAIL"))
{
mailbox_name = getenv ("MAIL");
}
else
{
user = (getenv ("LOGNAME")) ? getenv ("LOGNAME") : getenv ("USER");
if (user == NULL)
if (argc > 1)
mailbox_name = argv[1];
if ((status = mailbox_create_default (&mbox, mailbox_name)) != 0
|| (status = mailbox_open (mbox, MU_MAILBOX_RDONLY)) != 0)
{
fprintf (stderr, "who am I?\n");
fprintf (stderr, "could not create/open: %s\n", strerror (status));
exit (1);
}
}
if (user)
{
snprintf (buffer, sizeof(buffer), "%s/%s", _PATH_MAILDIR, user);
mailbox_name = buffer;
}
if (mailbox_init (&mbox, mailbox_name, 0) != 0
|| mailbox_open (mbox, MU_MB_RDONLY) != 0)
mailbox_messages_count (mbox, &count);
for(i = 1; i <= count; ++i)
{
fprintf (stderr, "could not open\n");
exit (2);
}
mailbox_scan (mbox, &count);
for(i = 0; i < count; ++i) {
rvalue = mailbox_get_header (mbox, i, 0, buffer, sizeof (buffer), &size);
if (rvalue != 0)
message_t msg;
header_t hdr;
if ((status = mailbox_get_message (mbox, i, &msg)) != 0
|| (status = message_get_header (msg, &hdr)) != 0)
{
fprintf (stderr, "header %s\n", strerror (rvalue));
fprintf (stderr, "msg %d : %s\n", i, strerror(status));
exit(2);
}
header_gvalue (buffer, size, MU_HDR_FROM, from, sizeof (from), NULL);
header_gvalue (buffer, size, MU_HDR_SUBJECT, subject,
sizeof (subject), NULL);
header_get_value (hdr, MU_HEADER_FROM, from, 30, NULL);
header_get_value (hdr, MU_HEADER_SUBJECT, subject, 40, NULL);
fprintf(stdout, "%s\t%s\n", from, subject);
printf("%s %s\n", from, subject);
}
mailbox_close(mbox);
mailbox_destroy(&mbox);
exit(0);
return 0;
}
......
SUBDIR = mailutils
pkginclude_HEADERS = \
attribute.h \
auth.h \
body.h \
event.h \
header.h \
locker.h \
mailbox.h \
mailer.h \
message.h \
mime.h \
registrar.h \
stream.h \
transcode.h \
url.h
/* 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 General Library 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 _ATTRIBUTE_H
#define _ATTRIBUTE_H
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
struct _attribute;
typedef struct _attribute * attribute_t;
#define MU_ATTRIBUTE_ANSWERED 0x01
#define MU_ATTRIBUTE_FLAGGED 0x02
#define MU_ATTRIBUTE_DELETED 0x04
#define MU_ATTRIBUTE_DRAFT 0x08
#define MU_ATTRIBUTE_SEEN 0x10
#define MU_ATTRIBUTE_READ 0x20
#define MU_ATTRIBUTE_RECENT 0x00
extern int attribute_create __P ((attribute_t *, void *));
extern void attribute_destroy __P ((attribute_t *, void *));
extern int attribute_is_seen __P ((attribute_t));
extern int attribute_is_answered __P ((attribute_t));
extern int attribute_is_flagged __P ((attribute_t));
extern int attribute_is_deleted __P ((attribute_t));
extern int attribute_is_draft __P ((attribute_t));
extern int attribute_is_recent __P ((attribute_t));
extern int attribute_is_read __P ((attribute_t));
extern int attribute_set_seen __P ((attribute_t));
extern int attribute_set_answered __P ((attribute_t));
extern int attribute_set_flagged __P ((attribute_t));
extern int attribute_set_deleted __P ((attribute_t));
extern int attribute_set_draft __P ((attribute_t));
extern int attribute_set_recent __P ((attribute_t));
extern int attribute_set_read __P ((attribute_t));
extern int attribute_unset_seen __P ((attribute_t));
extern int attribute_unset_answered __P ((attribute_t));
extern int attribute_unset_flagged __P ((attribute_t));
extern int attribute_unset_deleted __P ((attribute_t));
extern int attribute_unset_draft __P ((attribute_t));
extern int attribute_unset_recent __P ((attribute_t));
extern int attribute_unset_read __P ((attribute_t));
extern int attribute_get_flags __P ((attribute_t, int *));
extern int attribute_set_flags __P ((attribute_t, int));
extern int attribute_set_set_flags __P ((attribute_t, int (*_set_flags)
__P ((attribute_t, int)), void *));
extern int attribute_set_unset_flags __P ((attribute_t, int (*_unset_flags)
__P ((attribute_t, int)), void *));
extern int attribute_set_get_flags __P ((attribute_t, int (*_get_flags)
__P ((attribute_t, int *)), void *));
extern int attribute_is_equal __P ((attribute_t att1, attribute_t att2));
extern int attribute_copy __P ((attribute_t dst,
attribute_t src));
extern int string_to_flags __P ((const char *buf, int *pattr));
extern int flags_to_string __P ((int flags, char *buf,
size_t len, size_t *));
#ifdef __cplusplus
}
#endif
#endif /* _ATTRIBUTE_H */
/* 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 General Library 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 _AUTH_H
#define _AUTH_H
#include <sys/types.h>
#ifndef __P
#ifdef __STDC__
#define __P(args) args
#else
#define __P(args) ()
#endif
#endif /*__P */
#ifdef _cplusplus
extern "C" {
#endif
/* forward declaration */
struct _auth;
typedef struct _auth *auth_t;
extern int auth_create __P ((auth_t *, void *owner));
extern void auth_destroy __P ((auth_t *, void *owner));
extern int auth_prologue __P ((auth_t));
extern int auth_set_prologue __P ((auth_t auth,
int (*_prologue) __P ((auth_t)),
void *owner));
extern int auth_authenticate __P ((auth_t, char **, char **));
extern int auth_set_authenticate __P ((auth_t auth,
int (*_authenticate)
__P ((auth_t, char **, char **)),
void *owner));
extern int auth_epilogue __P ((auth_t));
extern int auth_set_epilogue __P ((auth_t auth,
int (*_epilogue) __P ((auth_t)),
void *owner));
#ifdef _cplusplus
}
#endif
#endif /* _AUTH_H */
/* 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 General Library 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 _BODY_H
#define _BODY_H
#include <sys/types.h>
#include <mailutils/stream.h>
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /* __P */
#ifdef _cplusplus
extern "C" {
#endif
/* forward declaration */
struct _body;
typedef struct _body *body_t;
extern int body_create __P ((body_t *, void *owner));
extern void body_destroy __P ((body_t *, void *owner));
extern int body_get_stream __P ((body_t, stream_t *));
extern int body_set_stream __P ((body_t, stream_t, void *owner));
extern int body_get_filename __P ((body_t, char *, size_t, size_t *));
extern int body_set_filename __P ((body_t, const char*));
extern int body_size __P ((body_t, size_t*));
extern int body_set_size __P ((body_t,
int (*_size) __P ((body_t, size_t*)),
void *owner));
extern int body_lines __P ((body_t, size_t *));
extern int body_set_lines __P ((body_t,
int (*_lines) __P ((body_t, size_t*)),
void *owner));
#ifdef _cplusplus
}
#endif
#endif /* _BODY_H */
/* 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 General Library 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 _EVENT_H
#define _EVENT_H
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /* __P */
#ifdef _cplusplus
extern "C" {
#endif
struct _event
{
size_t type;
void *arg;
int (*_action) __P ((size_t type, void *arg));
};
typedef struct _event *event_t;
#ifdef _cplusplus
}
#endif
#endif /* _EVENT_H */
/* 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 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 _HEADER_H
#define _HEADER_H
#include <sys/types.h>
#include <mailutils/stream.h>
#ifndef __P
#ifdef __STDC__
#define __P(args) args
#else
#define __P(args) ()
#endif
#endif /*__P */
#ifdef _cplusplus
extern "C" {
#endif
#define MU_HEADER_UNIX_FROM "From "
#define MU_HEADER_RETURN_PATH "Return-Path"
#define MU_HEADER_RECEIVED "Received"
#define MU_HEADER_DATE "Date"
#define MU_HEADER_FROM "From"
#define MU_HEADER_RESENT_FROM "Resent-From"
#define MU_HEADER_SUBJECT "Subject"
#define MU_HEADER_SENDER "Sender"
#define MU_HEADER_RESENT_SENDER "Resent-SENDER"
#define MU_HEADER_TO "To"
#define MU_HEADER_RESENT_TO "Resent-To"
#define MU_HEADER_CC "Cc"
#define MU_HEADER_RESENT_CC "Resent-Cc"
#define MU_HEADER_BCC "Bcc"
#define MU_HEADER_RESENT_BCC "Resent-Bcc"
#define MU_HEADER_REPLY_TO "Reply-To"
#define MU_HEADER_RESENT_REPLY_TO "Resent-Reply-To"
#define MU_HEADER_MESSAGE_ID "Message-ID"
#define MU_HEADER_RESENT_MESSAGE_ID "Resent-Message-ID"
#define MU_HEADER_IN_REPLY_TO "In-Reply-To"
#define MU_HEADER_ENCRYPTED "Encrypted"
#define MU_HEADER_PRECEDENCE "Precedence"
#define MU_HEADER_STATUS "Status"
#define MU_HEADER_CONTENT_LENGTH "Content-Length"
#define MU_HEADER_CONTENT_TYPE "Content-Type"
#define MU_HEADER_CONTENT_ENCODING "Content-transfer-encoding"
#define MU_HEADER_MIME_VERSION "MIME-Version"
/* Mime support header attribute */
/* forward declaration */
struct _header;
typedef struct _header * header_t;
extern int header_create __P ((header_t *, const char *,
size_t, void *));
extern void header_destroy __P ((header_t *, void *));
extern int header_set_value __P ((header_t, const char *,
const char *, int));
extern int header_get_value __P ((header_t, const char *, char *,
size_t, size_t *));
extern int header_get_stream __P ((header_t, stream_t *));
extern int header_size __P ((header_t, size_t *));
extern int header_lines __P ((header_t, size_t *));
extern int header_set_stream __P ((header_t, stream_t, void *));
extern int header_set_set_value __P ((header_t, int (*_set_value)
__P ((header_t, const char *,
const char *, int)),
void *));
extern int header_set_get_value __P ((header_t, int (*_get_value)
__P ((header_t, const char *,
char *, size_t, size_t *)),
void *));
#ifdef _cplusplus
}
#endif
#endif /* HEADER_H */
/* 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 General Library 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 _LOCKER_H
#define _LOCKER_H
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
struct _locker;
typedef struct _locker *locker_t;
extern int locker_create __P ((locker_t *, char *filename,
size_t len, int flags));
extern void locker_destroy __P ((locker_t *));
#define MU_LOCKER_RDLOCK 0
#define MU_LOCKER_WRLOCK 1
/* locking flags */
#define MU_LOCKER_PID 1
#define MU_LOCKER_FCNTL 2
#define MU_LOCKER_TIME 4
extern int locker_lock __P ((locker_t, int flag));
extern int locker_touchlock __P ((locker_t));
extern int locker_unlock __P ((locker_t));
#ifdef __cplusplus
}
#endif
#endif /* _MAILBOX_H */
/* 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. */
#ifndef _MAILBOX_H
# define _MAILBOX_H
#include <sys/types.h>
#include <mailutils/url.h>
#include <mailutils/message.h>
#include <mailutils/attribute.h>
#include <mailutils/auth.h>
#include <mailutils/locker.h>
#include <mailutils/stream.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
/* forward declaration */
struct _mailbox;
typedef struct _mailbox *mailbox_t;
/* constructor/destructor and possible types */
extern int mailbox_create __P ((mailbox_t *, const char *, int id));
extern void mailbox_destroy __P ((mailbox_t *));
extern int mailbox_create_default __P ((mailbox_t *, const char *));
/* flags for mailbox_open () */
#define MU_MAILBOX_RDONLY MU_STREAM_READ
#define MU_MAILBOX_WRONLY MU_STREAM_WRITE
#define MU_MAILBOX_RDWR MU_STREAM_RDWR
#define MU_MAILBOX_APPEND MU_STREAM_APPEND
#define MU_MAILBOX_CREAT MU_STREAM_CREAT
#define MU_MAILBOX_NONBLOCK MU_STREAM_NONBLOCK
extern int mailbox_open __P ((mailbox_t, int flag));
extern int mailbox_close __P ((mailbox_t));
/* messages */
extern int mailbox_get_message __P ((mailbox_t, size_t msgno, message_t *msg));
extern int mailbox_append_message __P ((mailbox_t, message_t msg));
extern int mailbox_messages_count __P ((mailbox_t, size_t *num));
extern int mailbox_expunge __P ((mailbox_t));
/* stream settings */
extern int mailbox_get_stream __P ((mailbox_t, stream_t *pstream));
extern int mailbox_set_stream __P ((mailbox_t, stream_t stream));
/* Lock settings */
extern int mailbox_get_locker __P ((mailbox_t, locker_t *locker));
extern int mailbox_set_locker __P ((mailbox_t, locker_t locker));
/* Authentication */
extern int mailbox_get_auth __P ((mailbox_t, auth_t *auth));
extern int mailbox_set_auth __P ((mailbox_t, auth_t auth));
/* update and scanning*/
extern int mailbox_is_updated __P ((mailbox_t));
extern int mailbox_scan __P ((mailbox_t, size_t msgno, size_t *count));
/* mailbox size ? */
extern int mailbox_size __P ((mailbox_t, off_t *size));
extern int mailbox_get_url __P ((mailbox_t, url_t *));
/* events */
#define MU_EVT_MBX_DESTROY 1
#define MU_EVT_MBX_CORRUPTED 2
#define MU_EVT_MBX_MSG_ADD 4
#define MU_EVT_MBX_PROGRESS 8
extern int mailbox_register __P ((mailbox_t mbox, size_t type,
int (*action) (size_t type, void *arg),
void *arg));
extern int mailbox_deregister __P ((mailbox_t mbox, void *action));
/* trace */
#define MU_MAILBOX_DEBUG_TRACE 1
#define MU_MAILBOX_DEBUG_PROT 2
extern int mailbox_set_debug_level __P ((mailbox_t mbox, size_t level));
extern int mailbox_get_debug_level __P ((mailbox_t mbox, size_t *plevel));
extern int mailbox_set_debug_print __P ((mailbox_t mbox, int (*debug_print)
__P ((void *arg, const char *,
size_t)),
void *arg));
#ifdef __cplusplus
}
#endif
#endif /* _MAILBOX_H */
/* 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 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 _MAILER_H
#define _MAILER_H
#include <sys/types.h>
#include <mailutils/message.h>
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /* __P */
#ifdef _cplusplus
extern "C" {
#endif
/* forward declaration */
struct _mailer;
typedef struct _mailer *mailer_t;
extern int mailer_create __P ((mailer_t *, message_t));
extern int mailer_destroy __P ((mailer_t *));
extern int mailer_connect __P ((mailer_t, char *host));
extern int mailer_disconnect __P ((mailer_t));
extern int mailer_send_header __P ((mailer_t, message_t));
extern int mailer_send_message __P ((mailer_t, message_t));
#ifdef _cplusplus
}
#endif
#endif /* _MAILER_H */
/* 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 General Library 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 _MESSAGE_H
#define _MESSAGE_H
#include <sys/types.h>
#include <mailutils/header.h>
#include <mailutils/body.h>
#include <mailutils/attribute.h>
#include <mailutils/stream.h>
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /* __P */
#ifdef _cplusplus
extern "C" {
#endif
/* forward declaration */
struct _message;
typedef struct _message *message_t;
/* A message is considered to be a container for:
* header_t, body_t, and its attribute_t.
*/
extern int message_create __P ((message_t *, void *owner));
extern void message_destroy __P ((message_t *, void *owner));
extern int message_get_header __P ((message_t, header_t *));
extern int message_set_header __P ((message_t, header_t, void *owner));
extern int message_get_body __P ((message_t, body_t *));
extern int message_set_body __P ((message_t, body_t, void *owner));
extern int message_get_stream __P ((message_t, stream_t *));
extern int message_is_mime __P ((message_t));
extern int message_size __P ((message_t, size_t *));
extern int message_lines __P ((message_t, size_t *));
extern int message_from __P ((message_t, char *, size_t, size_t *));
extern int message_set_from __P ((message_t,
int (*_from) __P ((message_t, char *,
size_t, size_t *)),
void *owner));
extern int message_received __P ((message_t, char *, size_t, size_t *));
extern int message_set_received __P ((message_t, int (*_received)
__P ((message_t, char *, size_t,
size_t *)), void *owner));
extern int message_get_attribute __P ((message_t, attribute_t *));
extern int message_set_attribute __P ((message_t, attribute_t, void *owner));
extern int message_get_num_parts __P ((message_t, size_t *nparts));
extern int message_set_get_num_parts __P ((message_t, int (*_getNum_parts)
__P ((message_t, size_t *)),
void *owner));
extern int message_get_part __P ((message_t, size_t part, message_t *msg));
extern int message_set_get_part __P ((message_t, int (*_get_part)
__P ((message_t, size_t, message_t *)),
void *owner));
extern int message_get_uidl __P ((message_t, char *buffer, size_t, size_t *));
extern int message_set_uidl __P ((message_t, int (*_get_uidl)
__P ((message_t, char *, size_t, size_t *)),
void *owner));
/* events */
#define MU_EVT_MSG_DESTROY 32
extern int message_register __P ((message_t msg, size_t type, int (*action)
__P ((size_t typ, void *arg)), void *arg));
extern int message_deregister __P ((message_t msg, void *action));
/* misc functions */
extern int message_create_attachment __P ((const char *content_type,
const char *encoding,
const char *filename,
message_t *newmsg));
extern int message_save_attachment __P ((message_t msg,
const char *filename, void **data));
extern int message_encapsulate __P ((message_t msg, message_t *newmsg,
void **data));
extern int message_unencapsulate __P ((message_t msg, message_t *newmsg,
void **data));
#ifdef _cplusplus
}
#endif
#endif /* _MESSAGE_H */
/* 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 General Library 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 _MIME_H
#define _MIME_H
#include <sys/types.h>
#include <mailutils/header.h>
#include <mailutils/stream.h>
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /* __P */
/* mime flags */
#define MIME_INCREAMENTAL_PARSER 0x00000001
#ifdef _cplusplus
extern "C" {
#endif
/* forward declaration */
struct _mime;
typedef struct _mime *mime_t;
int mime_create __P ((mime_t *pmime, message_t msg, int flags));
void mime_destroy __P ((mime_t *pmime));
int mime_is_multipart __P ((mime_t mime));
int mime_get_num_parts __P ((mime_t mime, int *nparts));
int mime_get_part __P ((mime_t mime, int part, message_t *msg));
int mime_add_part __P ((mime_t mime, message_t msg));
int mime_get_message __P ((mime_t mime, message_t *msg));
#ifdef _cplusplus
}
#endif
#endif /* _MIME_H */
/* 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 General Library 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 _REGISTRAR_H
#define _REGISTRAR_H
#include <sys/types.h>
#include <mailutils/url.h>
#include <mailutils/mailbox.h>
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
#ifdef _cplusplus
extern "C" {
#endif
struct url_registrar
{
const char *scheme;
int (*_create) __P ((url_t *, const char * name));
void (*_destroy) __P ((url_t *));
};
struct mailbox_registrar
{
const char *name;
int (*_create) __P ((mailbox_t *, const char *name));
void (*_destroy) __P ((mailbox_t *));
};
struct _registrar;
typedef struct _registrar* registrar_t;
/* mailbox registration */
extern int registrar_add __P ((struct url_registrar *ureg,
struct mailbox_registrar *mreg, int *id));
extern int registrar_remove __P ((int id));
extern int registrar_get __P ((int id, struct url_registrar **ureg,
struct mailbox_registrar **mreg));
extern int registrar_num __P ((size_t *num));
extern int registrar_get_entry __P ((size_t num, struct url_registrar **ureg,
struct mailbox_registrar **mreg,
int *id));
extern int registrar_list __P ((struct url_registrar **ureg,
struct mailbox_registrar **mreg,
int *id, registrar_t *reg));
#ifdef _cplusplus
}
#endif
#endif /* _REGISTRAR_H */
/* 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 General Library 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 _STREAM_H
# define _STREAM_H
#include <sys/types.h>
#ifdef __cplusplus
extern "C" { /*}*/
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
struct _stream;
typedef struct _stream *stream_t;
#define MU_STREAM_READ 0x00000001
#define MU_STREAM_WRITE 0x00000002
#define MU_STREAM_RDWR 0x00000004
#define MU_STREAM_APPEND 0x00000008
#define MU_STREAM_CREAT 0x00000010
#define MU_STREAM_NONBLOCK 0x00000020
/* stream will be destroy on stream_destroy */
#define MU_STREAM_NO_CHECK 0x00000040
extern int stream_create __P ((stream_t *, int flags, void *owner));
extern void stream_destroy __P ((stream_t *, void *owner));
extern int stream_set_destroy __P ((stream_t, void (*_destroy)
__P ((stream_t)), void *owner));
extern int stream_open __P ((stream_t, const char *, int, int));
extern int stream_set_open __P ((stream_t, int (*_open)
__P ((stream_t, const char *, int, int)),
void *owner));
extern int stream_close __P ((stream_t));
extern int stream_set_close __P ((stream_t, int (*_close) __P ((stream_t)),
void *owner));
extern int stream_get_fd __P ((stream_t , int *));
extern int stream_set_fd __P ((stream_t, int (*_get_fd)(stream_t, int *),
void *owner));
extern int stream_read __P ((stream_t, char *, size_t,
off_t, size_t *));
extern int stream_set_read __P ((stream_t, int (*_read)
__P ((stream_t, char *, size_t,
off_t, size_t *)),
void *owner));
extern int stream_readline __P ((stream_t, char *, size_t,
off_t, size_t *));
extern int stream_set_readline __P ((stream_t, int (*_readline)
__P ((stream_t, char *, size_t,
off_t, size_t *)),
void *owner));
extern int stream_size __P ((stream_t, off_t *));
extern int stream_set_size __P ((stream_t, int (*_size)
__P ((stream_t, off_t *)), void *owner));
extern int stream_truncate __P ((stream_t, off_t));
extern int stream_set_truncate __P ((stream_t, int (*_truncate)
__P ((stream_t, off_t)), void *owner));
extern int stream_write __P ((stream_t, const char *, size_t,
off_t, size_t *));
extern int stream_set_write __P ((stream_t, int (*_write)
__P ((stream_t, const char *,
size_t, off_t, size_t *)),
void *owner));
extern int stream_flush __P ((stream_t));
extern int stream_set_flush __P ((stream_t, int (*_flush)
__P ((stream_t)), void *owner));
extern int stream_get_flags __P ((stream_t, int *pflags));
extern int stream_set_flags __P ((stream_t, int flags, void *owner));
#define MU_STREAM_STATE_OPEN 1
#define MU_STREAM_STATE_READ 2
#define MU_STREAM_STATE_WRITE 4
#define MU_STREAM_STATE_CLOSE 8
extern int stream_get_state __P ((stream_t, int *pstate));
/* misc */
extern int file_stream_create __P ((stream_t *stream));
extern int mapfile_stream_create __P ((stream_t *stream));
extern int encoder_stream_create __P ((stream_t *stream, stream_t iostream,
const char *encoding));
extern int decoder_stream_create __P ((stream_t *stream, stream_t iostream,
const char *encoding));
extern int tcp_stream_create __P ((stream_t *stream));
#ifdef __cplusplus
}
#endif
#endif /* _STREAM_H */
/* 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 General Library 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 _TRANSCODE_H
#define _TRANSCODE_H
#include <sys/types.h>
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /* __P */
#ifdef _cplusplus
extern "C" {
#endif
/* forward declaration */
struct _transcoder;
typedef struct _transcoder *transcoder_t;
struct _transcoder
{
stream_t ustream; /* user reads/writes decoded/encoded data from here */
stream_t stream; /* encoder/decoder read/writes data to here */
void (*destroy)(transcoder_t tc);
void *tcdata;
};
extern int transcode_create __P ((transcoder_t *, char *encoding));
extern void transcode_destroy __P ((transcoder_t *));
extern int transcode_get_stream __P ((transcoder_t tc, stream_t *pis));
extern int transcode_set_stream __P ((transcoder_t tc, stream_t is));
#ifdef _cplusplus
}
#endif
#endif /* _TRANSCODE_H */
/* 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. */
#ifndef _URL_H
#define _URL_H 1
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# if __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*!__P */
/* forward declaration */
struct _url;
typedef struct _url * url_t;
extern int url_create __P ((url_t *, const char *name));
extern void url_destroy __P ((url_t *));
extern int url_get_id __P ((const url_t, int *id));
extern int url_get_scheme __P ((const url_t, char *sch,
size_t, size_t *));
extern int url_get_user __P ((const url_t, char *usr,
size_t, size_t *));
extern int url_get_passwd __P ((const url_t, char *passwd,
size_t, size_t *));
extern int url_get_host __P ((const url_t, char *host,
size_t, size_t *));
extern int url_get_port __P ((const url_t, long *port));
extern int url_get_path __P ((const url_t, char *path,
size_t, size_t *));
extern int url_get_query __P ((const url_t, char *qeury,
size_t, size_t *));
#ifdef __cplusplus
}
#endif
#endif /* URL_H */
noinst_LIBRARIES = libmailutils.a
libmailutils_a_SOURCES = getopt.c getopt1.c md5.c getline.c xstrdup.c \
xstrtol.c xmalloc.c
libmailutils_a_SOURCES = getopt.c getopt1.c md5.c getline.c snprintf.c \
xstrdup.c xstrtol.c xmalloc.c
noinst_HEADERS = getopt.h md5.h getline.h xstrtol.h xalloc.h
noinst_HEADERS = getopt.h md5.h getline.h snprintf.h xstrtol.h xalloc.h
CFLAGS = -Wall -pedantic -g -DTESTING
......
CFLAGS = -Wall -pedantic -g -DTESTING
INCLUDES = -I$(top_srcdir)/libmailbox -I$(top_srcdir)/lib
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/lib
bin_PROGRAMS = mail
mail_DEPENDENCIES = ../libmailbox/libmailbox.la
mail_LDADD = ../libmailbox/libmailbox.la ../lib/libmailutils.a
mail_DEPENDENCIES = ../mailbox/libmailbox.la
mail_LDADD = ../mailbox/libmailbox.la ../lib/libmailutils.a
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
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 General Public License as published by
......@@ -20,19 +20,24 @@
#endif
#include <errno.h>
#include <mailbox.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include <mailutils/mailbox.h>
#ifdef HAVE_PATHS_H
#include <paths.h>
# include <paths.h>
#endif
#ifndef _PATH_MAILDIR
#define _PATH_MAILDIR "/var/spool/mail"
# define _PATH_MAILDIR "/var/spool/mail"
#endif
#ifndef VERSION
# define VERSION "0.0"
#endif
static struct option long_options[] =
......@@ -45,15 +50,26 @@ static struct option long_options[] =
int
main (int argc, char **argv)
{
char *foo, bar[80];
int i = 0;
char c = 0;
char *mboxname = 0;
mailbox *mbox = 0;
char bar[80];
char buf[128];
char foo[80];
mailbox_t mbox;
message_t msg;
header_t hdr;
body_t body;
attribute_t attr;
stream_t os;
int c;
char *mboxname = NULL;
size_t count = 0;
int status;
int num = 0;
size_t n;
i = getopt_long (argc, argv, "hv", long_options, (int *)0);
switch (i)
c = getopt_long (argc, argv, "hv", long_options, (int *)0);
switch (c)
{
case 'v':
printf("mail (GNU mailutils) %s\n", VERSION);
......@@ -74,25 +90,20 @@ Report bugs to <bug-mailutils@gnu.org>.\n");
break;
}
if (argc > 1)
mboxname = argv[1];
mboxname = getenv ("MAIL");
if (mboxname == NULL)
if ((status = mailbox_create_default (&mbox, mboxname)) != 0 ||
(status = mailbox_open (mbox, MU_MAILBOX_RDWR)) != 0)
{
foo = getenv ("LOGNAME");
mboxname = malloc ((strlen(foo) + strlen(_PATH_MAILDIR) + 2) * sizeof(char));
strcpy (mboxname, _PATH_MAILDIR "/");
strcat (mboxname, foo);
free (foo);
}
mbox = mbox_open (mboxname);
if (mbox == NULL)
{
fprintf (stderr, "Ack, %s, reading %s\n", strerror(errno), mboxname);
fprintf (stderr, "Ack, %s, reading %s\n", strerror (status), mboxname);
exit (1);
}
printf ("Number of messages: %d\n", mbox->messages);
mailbox_messages_count (mbox, &count);
printf ("Experimental Mail. Type ? for help\n");
printf ("Number of messages: %d\n", count);
while (1)
{
printf ("& ");
......@@ -101,56 +112,166 @@ Report bugs to <bug-mailutils@gnu.org>.\n");
c = bar[0];
if (c == 'd' || c == 'D' || c == 'b' || c == 'B' || c == 'h' ||
c == 'H' || c == 'r' || c == 'R' || c == 'f' || c == 'F' ||
c == 'T' || c == 't' )
c == 'T' || c == 't' || c == 'p' || c == 'P')
{
if (sscanf (bar, "%80s %d\n", foo, &num) == 1)
{
printf ("# ");
fgets (bar, 80, stdin);
num = atoi (bar);
}
}
switch (c)
{
case 'q':
case 'Q':
mbox_close (mbox);
printf ("<<Quit>>\n");
mailbox_close (mbox);
return 0;
break;
case 'f':
case 'F':
foo = mbox_header_line (mbox, atoi (bar) - 1, "from");
printf ("%s\n", foo);
free (foo);
printf ("<<From %d>>\n", num);
{
size_t i;
if (num == 0)
num = 1;
for (i = num; i <= count; i++)
{
if ((status = mailbox_get_message (mbox, i, &msg)) != 0 ||
(status = message_get_header (msg, &hdr)) != 0 ||
(status = header_get_value (hdr, "From", buf,
sizeof(buf), &n)) != 0)
{
fprintf (stderr, "msg %d: %s\n", i, strerror (status));
break;
}
else
printf ("%d From: %s\n", i, buf);
if ((i % 10) == 0)
{
char tmp[16];
*tmp = '\0';
printf ("\nHit (q|Q)uit to break\n");
fgets (tmp, sizeof(tmp), stdin);
if (*tmp == 'q' || *tmp == 'Q')
break;
}
}
}
break;
case 'r':
case 'R':
foo = mbox_get_header (mbox, atoi (bar) - 1);
printf ("%s\n", foo);
free (foo);
foo = mbox_get_body (mbox, atoi (bar) - 1);
printf ("%s", foo);
free (foo);
printf ("<<Reply %d>>\n", num);
break;
case 'h':
case 'H':
foo = mbox_get_header (mbox, atoi (bar) - 1);
printf ("%s", foo);
free (foo);
printf ("<<Header %d>>\n", num);
if ((status = mailbox_get_message (mbox, num, &msg)) != 0 ||
(status = message_get_header (msg, &hdr)) != 0 ||
(status = header_get_stream (hdr, &os)) != 0)
fprintf (stderr, "msg %d: %s\n", num, strerror (status));
else
{
off_t off = 0;
while (stream_read (os, buf, sizeof (buf) - 1,
off, &n) == 0 && n != 0)
{
buf[n] = '\0';
printf (buf);
off += n;
}
}
break;
case 'b':
case 'B':
foo = mbox_get_body (mbox, atoi (bar) - 1);
printf ("%s", foo);
free (foo);
printf ("<<Body %d>>\n", num);
if ((status = mailbox_get_message (mbox, num, &msg)) != 0 ||
(status = message_get_body (msg, &body)) != 0 ||
(status = body_get_stream (body, &os)) != 0)
fprintf (stderr, "msg %d: %s\n", num, strerror (status));
else
{
off_t off = 0;
while (stream_read (os, buf, sizeof (buf) - 1,
off, &n) == 0 && n != 0)
{
buf[n] = '\0';
printf (buf);
off += n;
}
}
break;
case 'd':
case 'D':
mbox_delete (mbox, atoi (bar) - 1);
printf ("<<Delete %d>>\n", num);
if ((status = mailbox_get_message (mbox, num, &msg)) != 0 ||
(status = message_get_attribute (msg, &attr)) != 0)
fprintf (stderr, "msg %d: %s\n", num, strerror (status));
else
{
status = attribute_set_deleted (attr);
if (status != 0)
fprintf (stderr, "Delete %d: %s\n", num, strerror (status));
else
printf ("msg %d mark deleted\n", num);
}
break;
case 'u':
case 'U':
printf ("<<Undelete %d>>\n", num);
if ((status = mailbox_get_message (mbox, num, &msg)) != 0 ||
(status = message_get_attribute (msg, &attr)) != 0)
fprintf (stderr, "msg %d: %s\n", num, strerror (status));
else
{
status = attribute_unset_deleted (attr);
if (status != 0)
fprintf (stderr, "Undelete %d: %s\n", num, strerror (status));
else
printf ("msg %d unmark deleted\n", num);
}
break;
case 'x':
case 'X':
mbox_expunge (mbox);
printf ("<<Expunge>>\n");
status = mailbox_expunge (mbox);
if (status != 0)
printf ("Expunging: %s\n", strerror (status));
mailbox_messages_count (mbox, &count);
printf ("Number of messages: %d\n", count);
break;
case 'p':
case 'P':
printf ("<<Print %d>>\n", num);
if ((status = mailbox_get_message (mbox, num, &msg)) != 0 ||
(status = message_get_stream (msg, &os)) != 0)
{
fprintf (stderr, "msg %d: %s\n", num, strerror (status));
break;
}
else
{
off_t off = 0;
while (stream_read (os, buf, sizeof (buf) - 1,
off, &n) == 0 && n != 0)
{
buf[n] = '\0';
printf (buf);
off += n;
}
}
break;
case 't':
case 'T':
mbox_tester (mbox, atoi (bar) - 1);
case '?':
printf ("\
(d|D)elete num-msg\n\
(b|B)ody num-msg\n\
(f|F)rom num-msg\n\
(h|H)eader num-msg\n\
(p|P)rint num-msg\n\
(q|Q)uit num-msg\n\
(r|R)eply num-msg\n\
e(x|X)punge num-msg\n");
break;
default:
break;
......
......@@ -2,16 +2,18 @@
AUTOMAKE_OPTIONS = ../lib/ansi2knr
INCLUDES = -I${srcdir}/include -I${srcdir}/include -I${srcdir}/lib
INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/mailbox/include -I${srcdir}/lib
CFLAGS = -Wall -pedantic -g -DTESTING
SUBDIRS = include
lib_LTLIBRARIES = libmailbox.la
EXTRA_DIST = mbx_unixscan.c
libmailbox_la_SOURCES = \
_cpystr.c attachment.c attribute.c auth.c body.c file_stream.c \
header.c io.c locker.c mailbox.c mailer.c mapfile_stream.c \
header.c stream.c locker.c mailbox.c mailer.c mapfile_stream.c \
mbx_default.c mbx_imap.c mbx_mbox.c mbx_mdir.c mbx_mh.c mbx_mmdf.c \
mbx_pop.c mbx_unix.c message.c mime.c registrar.c tcp.c trans_stream.c \
url.c url_file.c url_imap.c url_mail.c url_mbox.c url_mdir.c \
......
......@@ -15,14 +15,14 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <message.h>
#include <io.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mailutils/message.h>
#include <mailutils/stream.h>
#define MAX_HDR_LEN 256
#define BUF_SIZE 2048
......
......@@ -15,13 +15,13 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <attribute0.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <attribute0.h>
int
attribute_create (attribute_t *pattr, void *owner)
{
......
......@@ -15,14 +15,14 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <auth0.h>
#include <cpystr.h>
#include <errno.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <auth0.h>
#include <cpystr.h>
int
auth_create (auth_t *pauth, void *owner)
{
......
......@@ -15,16 +15,16 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <body0.h>
#include <io0.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <body0.h>
#include <stream0.h>
static int body_read (stream_t is, char *buf, size_t buflen,
off_t off, size_t *pnread );
static int body_write (stream_t os, const char *buf, size_t buflen,
......
......@@ -26,7 +26,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <io0.h>
#include <stream0.h>
struct _file_stream
{
......
......@@ -19,14 +19,14 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <header0.h>
#include <io0.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <header0.h>
#include <stream0.h>
static int header_parse (header_t h, const char *blurb, int len);
static int header_read (stream_t is, char *buf, size_t buflen,
off_t off, size_t *pnread);
......
SUBDIR = private public
noinst_HEADERS = \
attribute0.h auth0.h body0.h cpystr.h header0.h mailbox0.h mailer0.h \
mbx_imap.h mbx_mbox.h mbx_mdir.h mbx_mmdf.h mbx_pop.h mbx_unix.h \
message0.h mime0.h registrar0.h stream0.h tcp0.h url0.h
......
/* 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 General Library 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 _ATTRIBUTE0_H
# define _ATTRIBUTE0_H
#include <mailutils/attribute.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
struct _attribute
{
void *owner;
int flags;
int (*_get_flags) __P ((attribute_t, int *));
int (*_set_flags) __P ((attribute_t, int));
int (*_unset_flags) __P ((attribute_t, int));
};
#ifdef __cplusplus
}
#endif
#endif /* _ATTRIBUTE0_H */
/* 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 General Library 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 _AUTH0_H
#define _AUTH0_H
#include <mailutils/auth.h>
#include <sys/types.h>
#ifndef __P
#ifdef __STDC__
#define __P(args) args
#else
#define __P(args) ()
#endif
#endif /*__P */
#ifdef _cplusplus
extern "C" {
#endif
struct _auth
{
void *owner;
int (*_prologue) (auth_t);
int (*_authenticate) (auth_t, char **user, char **passwd);
int (*_epilogue) (auth_t);
};
#ifdef _cplusplus
}
#endif
#endif /* _AUTH0_H */
/* 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 General Library 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 _BODY0_H
#define _BODY0_H
#include <mailutils/stream.h>
#include <mailutils/body.h>
#include <stdio.h>
#include <sys/types.h>
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /* __P */
#ifdef _cplusplus
extern "C" {
#endif
struct _body
{
void *owner;
/* it's better and more portable to use stdio */
FILE *file;
char *filename;
stream_t stream;
int (*_size) (body_t, size_t*);
int (*_lines) (body_t, size_t*);
};
#ifdef _cplusplus
}
#endif
#endif /* _BODY0_H */
/* 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 General Library 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 _CPYSTR_H
#define _CPYSTR_H
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# if __STDC__
# define __P(x) x
# else
# define __P(x)
# endif
#endif
extern size_t _cpystr __P ((char *dst, const char *src, size_t size));
#ifdef __cplusplus
}
#endif
#endif
/* 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 General Library 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 _HEADER0_H
#define _HEADER0_H
#include <mailutils/header.h>
#include <stream0.h>
#include <sys/types.h>
#ifdef _cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
/* The structure members are offset that point to the begin/end of header
fields. */
struct _hdr
{
char *fn;
char *fn_end;
char *fv;
char *fv_end;
};
/* The blurb member represents the headers, hdr_count the number of distinct
header field and the layout is done by struct_hdr *hdr. */
struct _header
{
/* Owner. */
void *owner;
/* Data. */
char *temp_blurb;
size_t temp_blurb_len;
char *blurb;
size_t blurb_len;
size_t hdr_count;
struct _hdr *hdr;
/* Streams. */
stream_t stream;
int (*_get_value) __P ((header_t, const char *, char *, size_t , size_t *));
int (*_set_value) __P ((header_t, const char *, const char *, int));
};
#ifdef _cplusplus
}
#endif
#endif /* _HEADER0_H */
/* 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. */
#ifndef _MAILBOX0_H
#define _MAILBOX0_H
#include <mailutils/mailbox.h>
#include <mailutils/event.h>
#include <sys/types.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
struct _mailbox
{
/* Data */
char *name;
auth_t auth;
locker_t locker;
stream_t stream;
url_t url;
/* register events */
event_t event;
size_t event_num;
/* debug information */
int debug_level;
void *debug_arg;
char *debug_buffer;
size_t debug_bufsize;
int (*debug_print) __P ((void *arg, const char *, size_t));
/* Back pointer to the specific mailbox */
void *data;
/* Public methods */
int (*_create) __P ((mailbox_t *, const char *));
void (*_destroy) __P ((mailbox_t *));
int (*_open) __P ((mailbox_t, int flag));
int (*_close) __P ((mailbox_t));
/* messages */
int (*_get_message) __P ((mailbox_t, size_t msgno, message_t *msg));
int (*_append_message) __P ((mailbox_t, message_t msg));
int (*_messages_count) __P ((mailbox_t, size_t *num));
int (*_expunge) __P ((mailbox_t));
int (*_scan) __P ((mailbox_t, size_t msgno, size_t *count));
int (*_is_updated) __P ((mailbox_t));
int (*_size) __P ((mailbox_t, off_t *size));
/* private */
int (*_num_deleted) __P ((mailbox_t, size_t *));
};
/* private */
extern int mailbox_num_deleted __P ((mailbox_t, size_t *));
extern int mailbox_notification __P ((mailbox_t mbox, size_t type));
extern int mailbox_debug __P ((mailbox_t, int level, const char *fmt, ...));
#ifdef __cplusplus
}
#endif
#endif /* _MAILBOX0_H */
/* 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 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 _MAILER0_H
#define _MAILER0_H
#include <sys/types.h>
#include <mailutils/mailer.h>
#ifdef _cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
// mailer states
#define MAILER_STATE_HDR 1
#define MAILER_STATE_MSG 2
#define MAILER_STATE_COMPLETE 3
// mailer messages
#define MAILER_HELO 1
#define MAILER_MAIL 2
#define MAILER_RCPT 3
#define MAILER_DATA 4
#define MAILER_RSET 5
#define MAILER_QUIT 6
#define MAILER_LINE_BUF_SIZE 1000
struct _mailer
{
int socket;
char *hostname;
char line_buf[MAILER_LINE_BUF_SIZE];
int offset;
int state;
int add_dot;
stream_t stream;
char last_char;
};
#ifdef _cplusplus
}
#endif
#endif /* MAILER0_H */
/* 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. */
#ifndef _MBX_IMAP_H
#define _MBX_IMAP_H 1
#include <mailbox0.h>
extern int mailbox_imap_create __P ((mailbox_t *mbox, const char *name));
extern void mailbox_imap_destroy __P ((mailbox_t *mbox));
extern struct mailbox_type _mailbox_imap_type;
#endif /* _MBX_IMAP_H */
/* 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 _MBX_MBOX_H
#define _MBX_MBOX_H 1
#include <mailutils/mailbox.h>
extern int mailbox_mbox_create __P ((mailbox_t *mbox, const char *name));
extern void mailbox_mbox_destroy __P ((mailbox_t *mbox));
extern struct mailbox_type _mailbox_mbox_type;
#endif /* _MBX_MBOX_H */
/* 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. */
#ifndef _MBX_MDIR_H
#define _MBX_MDIR_H 1
#include <mailbox0.h>
extern int mailbox_maildir_create __P ((mailbox_t *mbox, const char *name));
extern void mailbox_maildir_destroy __P ((mailbox_t *mbox));
extern struct mailbox_type _mailbox_maildir_type;
#endif /* _MBX_MDIR_H */
/* 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. */
#ifndef _MBX_MMDF_H
#define _MBX_MMDF_H 1
#include <mailbox0.h>
extern int mailbox_mmdf_create __P ((mailbox_t *mbox, const char *name));
extern void mailbox_mmdf_destroy __P ((mailbox_t *mbox));
extern struct mailbox_type _mailbox_mmdf_type;
#endif /* _MBX_MMDF_H */
/* 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. */
#ifndef _MBX_POP_H
#define _MBX_POP_H 1
#include <mailbox0.h>
extern int mailbox_pop_create __P ((mailbox_t *mbox, const char *name));
extern void mailbox_pop_destroy __P ((mailbox_t *mbox));
extern struct mailbox_type _mailbox_pop_type;
#endif /* _MBX_POP_H */
/* 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. */
#ifndef _MBX_UNIX_H
#define _MBX_UNIX_H 1
#include <mailbox0.h>
#ifdef __cplucplus
extern "C" {
#endif
extern int mailbox_unix_create __P ((mailbox_t *mbox, const char *name));
extern void mailbox_unix_destroy __P ((mailbox_t *mbox));
extern struct mailbox_type _mailbox_unix_type;
#ifdef __cplucplus
}
#endif
#endif /* _MBX_UNIX_H */
/* 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 General Library 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 _MESSAGE0_H
#define _MESSAGE0_H
#include <mailutils/attribute.h>
#include <mailutils/header.h>
#include <mailutils/message.h>
#include <mailutils/mime.h>
#include <mailutils/mailbox.h>
#include <mailutils/event.h>
#include <sys/types.h>
#include <stdio.h>
#ifdef _cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
/* forward declaration */
struct _message
{
header_t header;
stream_t stream;
body_t body;
attribute_t attribute;
mime_t mime;
/* who is the owner */
void *owner;
event_t event;
size_t event_num;
/* for message_write */
char *hdr_buf;
size_t hdr_buflen;
int hdr_done;
int (*_from) __P ((message_t msg, char *, size_t, size_t *));
int (*_received) __P ((message_t msg, char *, size_t, size_t *));
int (*_get_uidl) __P ((message_t msg, char *, size_t, size_t *));
int (*_get_num_parts) __P ((message_t, size_t *nparts));
int (*_get_part) __P ((message_t, size_t part, message_t *msg));
};
#ifdef _cplusplus
}
#endif
extern void message_notification (message_t msg, size_t type);
#endif /* _MESSAGE_H */
/* 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 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 _MIME0_H
#define _MIME0_H
#include <sys/types.h>
#include <mailutils/mime.h>
#ifndef __P
#ifdef __STDC__
#define __P(args) args
#else
#define __P(args) ()
#endif
#endif /*__P */
#ifdef _cplusplus
extern "C" {
#endif
#define MIME_MAX_HDR_LEN 256
#define MIME_DFLT_BUF_SIZE 2048
/* Parser states */
#define MIME_STATE_BEGIN_LINE 1
#define MIME_STATE_SCAN_BOUNDARY 2
#define MIME_STATE_HEADERS 3
#define MIME_FLAG_MASK 0x0000ffff
/* private */
#define MIME_PARSER_ACTIVE 0x80000000
#define MIME_PARSER_HAVE_CR 0x40000000
#define MIME_NEW_MESSAGE 0x20000000
struct _mime
{
message_t msg;
header_t hdrs;
stream_t stream;
int flags;
char *content_type;
int tparts;
int nmtp_parts;
struct _mime_part **mtp_parts; /* list of parts in the msg */
/* parser state */
char *boundary;
char *cur_line;
int line_ndx;
int cur_offset;
char *cur_buf;
int buf_size;
char *header_buf;
int header_buf_size;
int header_length;
int body_offset;
int body_length;
int parser_state;
};
struct _mime_part
{
char sig[4];
mime_t mime;
header_t hdr;
message_t msg;
int body_offset;
int body_len;
};
#ifdef _cplusplus
}
#endif
#endif /* MIME0_H */
/* 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. */
#ifndef _REGISTRAR0_H
#define _REGISTRAR0_H
#include <mailutils/registrar.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
/*
Builtin mailbox types.
A circular list is use for the builtin.
Proper locking is not done when accessing the list.
FIXME: not thread-safe. */
struct _registrar
{
struct url_registrar *ureg;
struct mailbox_registrar *mreg;
int is_allocated;
struct _registrar *next;
};
/* This is function is obsolete use the registrar_entry_*() ones */
extern int registrar_list __P ((struct url_registrar **ureg,
struct mailbox_registrar **mreg,
int *id, registrar_t *reg));
extern int registrar_entry_count __P ((size_t *num));
extern int registrar_entry __P ((size_t num, struct url_registrar **ureg,
struct mailbox_registrar **mreg,
int *id));
/* IMAP */
extern struct mailbox_registrar _mailbox_imap_registrar;
extern struct url_registrar _url_imap_registrar;
/* FILE */
extern struct url_registrar _url_file_registrar;
/* MBOX */
extern struct mailbox_registrar _mailbox_mbox_registrar;
extern struct url_registrar _url_mbox_registrar;
/* MAILTO */
extern struct mailbox_registrar _mailbox_mailto_registrar;
extern struct url_registrar _url_mailto_registrar;
/* MDIR */
extern struct mailbox_registrar _mailbox_maildir_registrar;
extern struct url_registrar _url_maildir_registrar;
/* MMDF */
extern struct mailbox_registrar _mailbox_mmdf_registrar;
extern struct url_registrar _url_mmdf_registrar;
/* UNIX */
extern struct mailbox_registrar _mailbox_unix_registrar;
extern struct url_registrar _url_unix_registrar;
/* POP */
extern struct mailbox_registrar _mailbox_pop_registrar;
extern struct url_registrar _url_pop_registrar;
#ifdef __cplusplus
}
#endif
#endif /* _REGISTRAR0_H */
/* 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 General Library 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 _IO0_H
# define _IO0_H
#include <mailutils/stream.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
struct _stream
{
void *owner;
int flags;
int state;
void (*_destroy) __P ((stream_t));
int (*_open) __P ((stream_t, const char *, int port, int flags));
int (*_close) __P ((stream_t));
int (*_get_fd) __P ((stream_t, int *));
int (*_read) __P ((stream_t, char *, size_t, off_t, size_t *));
int (*_readline) __P ((stream_t, char *, size_t, off_t, size_t *));
int (*_write) __P ((stream_t, const char *, size_t, off_t, size_t *));
int (*_truncate) __P ((stream_t, off_t));
int (*_size) __P ((stream_t, off_t *));
int (*_flush) __P ((stream_t));
};
#ifdef __cplusplus
}
#endif
#endif /* _IO0_H */
/* 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 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 _TCP0_H
#define _TCP0_H
#define TCP_STATE_INIT 1
#define TCP_STATE_RESOLVE 2
#define TCP_STATE_RESOLVING 3
#define TCP_STATE_CONNECTING 4
#define TCP_STATE_CONNECTED 5
struct _tcp_instance {
int fd;
char *host;
int port;
int state;
unsigned long address;
};
#endif /* _TCP0_H */
/* 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. */
#ifndef _URL0_H
#define _URL0_H 1
#include <mailutils/url.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __P
# if __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*!__P */
struct _url
{
/* Data */
char *scheme;
char *user;
char *passwd; /* encoded ?? */
char *host;
long port;
char *path;
char *query;
int id;
void *data;
int (*_create) __P ((url_t *url, const char *name));
void (*_destroy) __P ((url_t *url));
/* Methods */
int (*_get_id) __P ((const url_t, int *id));
int (*_get_scheme) __P ((const url_t, char *scheme,
size_t len, size_t *n));
int (*_get_user) __P ((const url_t, char *user,
size_t len, size_t *n));
int (*_get_passwd) __P ((const url_t, char *passwd,
size_t len, size_t *n));
int (*_get_host) __P ((const url_t, char *host,
size_t len, size_t *n));
int (*_get_port) __P ((const url_t, long *port));
int (*_get_path) __P ((const url_t, char *path,
size_t len, size_t *n));
int (*_get_query) __P ((const url_t, char *query,
size_t len, size_t *n));
};
/* IMAP */
/* Mailto */
/* UNIX MBOX */
/* Maildir */
/* MMDF */
/* POP3 */
#define MU_POP_PORT 110
/* UNIX MBOX */
#ifdef __cplusplus
}
#endif
#endif /* URL_H */
......@@ -15,7 +15,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <locker.h>
#include <errno.h>
#include <sys/types.h>
#include <stdlib.h>
......@@ -29,6 +28,8 @@
#include <utime.h>
#include <signal.h>
#include <mailutils/locker.h>
#define LOCKFILE_ATTR 0444
#define LOCK_EXPIRE_TIME (5 * 60)
......
......@@ -19,18 +19,17 @@
#include <config.h>
#endif
#include <mailbox0.h>
#include <message0.h>
#include <registrar.h>
#include <locker.h>
#include <mailutils_errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <mailbox0.h>
#include <message0.h>
#include <mailutils/registrar.h>
#include <mailutils/locker.h>
/*
* Point of entry.
* Simple, first check if they ask for something specific; with the ID.
......@@ -40,7 +39,7 @@
int
mailbox_create (mailbox_t *pmbox, const char *name, int id)
{
int status = MU_ERROR_INVALID_ARG;
int status = EINVAL;
struct mailbox_registrar *mreg;
url_t url = NULL;
......@@ -83,7 +82,7 @@ int
mailbox_open (mailbox_t mbox, int flag)
{
if (mbox == NULL || mbox->_open == NULL)
return MU_ERROR_NOT_IMPLEMENTED;
return ENOSYS;
return mbox->_open (mbox, flag);
}
......@@ -91,7 +90,7 @@ int
mailbox_close (mailbox_t mbox)
{
if (mbox == NULL || mbox->_close == NULL)
return MU_ERROR_NOT_IMPLEMENTED;
return ENOSYS;
return mbox->_close (mbox);
}
......@@ -100,7 +99,7 @@ int
mailbox_append_message (mailbox_t mbox, message_t msg)
{
if (mbox == NULL || mbox->_append_message == NULL)
return MU_ERROR_NOT_IMPLEMENTED;
return ENOSYS;
return mbox->_append_message (mbox, msg);
}
......@@ -108,7 +107,7 @@ int
mailbox_get_message (mailbox_t mbox, size_t msgno, message_t *pmsg)
{
if (mbox == NULL || mbox->_get_message == NULL)
return MU_ERROR_INVALID_ARG;
return ENOSYS;
return mbox->_get_message (mbox, msgno, pmsg);
}
......@@ -116,7 +115,7 @@ int
mailbox_messages_count (mailbox_t mbox, size_t *num)
{
if (mbox == NULL || mbox->_messages_count == NULL)
return MU_ERROR_NOT_IMPLEMENTED;
return ENOSYS;
return mbox->_messages_count (mbox, num);
}
......@@ -124,7 +123,7 @@ int
mailbox_expunge (mailbox_t mbox)
{
if (mbox == NULL || mbox->_expunge == NULL)
return MU_ERROR_NOT_IMPLEMENTED;
return ENOSYS;
return mbox->_expunge (mbox);
}
......@@ -132,7 +131,7 @@ int
mailbox_num_deleted (mailbox_t mbox, size_t *num)
{
if (mbox == NULL || mbox->_num_deleted == NULL)
return MU_ERROR_INVALID_ARG;
return ENOSYS;
return mbox->_num_deleted (mbox, num);
}
......@@ -157,7 +156,7 @@ int
mailbox_set_locker (mailbox_t mbox, locker_t locker)
{
if (mbox == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
if (mbox->locker != NULL)
locker_destroy (&mbox->locker);
mbox->locker = locker;
......@@ -168,7 +167,7 @@ int
mailbox_get_locker (mailbox_t mbox, locker_t *plocker)
{
if (mbox == NULL || plocker == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
if (plocker)
*plocker = mbox->locker;
return 0;
......@@ -178,7 +177,7 @@ int
mailbox_set_auth (mailbox_t mbox, auth_t auth)
{
if (mbox == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
mbox->auth = auth;
return 0;
}
......@@ -187,7 +186,7 @@ int
mailbox_get_auth (mailbox_t mbox, auth_t *pauth)
{
if (mbox == NULL || pauth == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
if (pauth)
*pauth = mbox->auth;
return 0;
......@@ -197,7 +196,7 @@ int
mailbox_set_stream (mailbox_t mbox, stream_t stream)
{
if (mbox == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
mbox->stream = stream;
return 0;
}
......@@ -206,7 +205,7 @@ int
mailbox_get_stream (mailbox_t mbox, stream_t *pstream)
{
if (mbox == NULL || pstream == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
if (pstream)
*pstream = mbox->stream;
return 0;
......@@ -222,7 +221,7 @@ mailbox_register (mailbox_t mbox, size_t type,
/* FIXME: I should check for invalid types */
if (mbox == NULL || action == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
/* find a free spot */
for (i = 0; i < mbox->event_num; i++)
......@@ -240,7 +239,7 @@ mailbox_register (mailbox_t mbox, size_t type,
/* a new one */
event = realloc (mbox->event, (mbox->event_num + 1) * sizeof (*event));
if (event == NULL)
return MU_ERROR_OUT_OF_MEMORY;
return ENOMEM;
mbox->event = event;
event[mbox->event_num]._action = action;
......@@ -267,7 +266,7 @@ mailbox_deregister (mailbox_t mbox, void *action)
return 0;
}
}
return MU_ERROR_NO_ENTRY;
return ENOENT;
}
int
......@@ -289,7 +288,7 @@ int
mailbox_set_debug_level (mailbox_t mbox, size_t level)
{
if (mbox == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
mbox->debug_level = level;
return 0;
}
......@@ -298,7 +297,7 @@ int
mailbox_get_debug_level (mailbox_t mbox, size_t *plevel)
{
if (mbox == NULL || plevel == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
*plevel = mbox->debug_level;
return 0;
}
......@@ -308,7 +307,7 @@ mailbox_set_debug_print (mailbox_t mbox, int (*debug_print)
(void *arg, const char *, size_t), void *arg)
{
if (mbox == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
mbox->debug_print = debug_print;
mbox->debug_arg = arg;
return 0;
......@@ -319,7 +318,7 @@ mailbox_debug (mailbox_t mbox, int level, const char *fmt, ...)
{
va_list ap;
if (mbox == NULL)
return MU_ERROR_INVALID_ARG;
return EINVAL;
if (!(mbox->debug_level & level))
return 0;
......@@ -333,7 +332,7 @@ mailbox_debug (mailbox_t mbox, int level, const char *fmt, ...)
mbox->debug_bufsize = 255;
mbox->debug_buffer = malloc (mbox->debug_bufsize);
if (mbox->debug_buffer)
return MU_ERROR_OUT_OF_MEMORY; }
return ENOMEM; }
writen = vsnprintf (mbox->debug_buffer, mbox->debug_bufsize, fmt, ap);
mbox->debug_print (mbox->debug_arg, mbox->debug_buffer, writen);
}
......
......@@ -26,7 +26,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <io0.h>
#include <stream0.h>
#ifdef _POSIX_MAPPED_FILES
......
#include <mailbox.h>
#include <string.h>
#include <stdlib.h>
#include <paths.h>
#include <errno.h>
#include <stdio.h>
#include <mailutils/mailbox.h>
#ifndef _PATH_MAILDIR
# define _PATH_MAILDIR "/var/spool/mail"
......
......@@ -15,9 +15,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <errno.h>
#include <mailbox0.h>
#include <registrar0.h>
#include <errno.h>
static int mailbox_imap_create (mailbox_t *mbox, const char *name);
......
......@@ -14,13 +14,13 @@
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 <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <mailbox0.h>
#include <registrar0.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
static int mailbox_mbox_create (mailbox_t *mbox, const char *name);
static void mailbox_mbox_destroy (mailbox_t *mbox);
......
......@@ -15,9 +15,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <errno.h>
#include <mailbox0.h>
#include <registrar0.h>
#include <errno.h>
static int mailbox_maildir_create (mailbox_t *mbox, const char *name);
static void mailbox_maildir_destroy (mailbox_t *mbox);
......
......@@ -15,8 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <mailbox0.h>
#include <registrar0.h>
#include <dirent.h>
#include <errno.h>
......@@ -27,6 +25,9 @@
#include <stdlib.h>
#include <ctype.h>
#include <mailbox0.h>
#include <registrar0.h>
static int mailbox_mh_create (mailbox_t *pmbox, const char *name);
static void mailbox_mh_destroy (mailbox_t *pmbox);
......
......@@ -15,11 +15,11 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <errno.h>
#include <mailbox0.h>
#include <registrar0.h>
#include <errno.h>
static int mailbox_mmdf_create (mailbox_t *mbox, const char *name);
static void mailbox_mmdf_destroy (mailbox_t *mbox);
......
......@@ -15,15 +15,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <mailbox0.h>
#include <io0.h>
#include <body0.h>
#include <message0.h>
#include <registrar0.h>
#include <auth0.h>
#include <header0.h>
#include <attribute0.h>
#include <termios.h>
#include <errno.h>
#include <stdlib.h>
......@@ -32,6 +23,15 @@
#include <unistd.h>
#include <fcntl.h>
#include <mailbox0.h>
#include <stream0.h>
#include <body0.h>
#include <message0.h>
#include <registrar0.h>
#include <auth0.h>
#include <header0.h>
#include <attribute0.h>
/* The different possible states of a Pop client, it maps to the POP3 commands.
Note that POP3 is not reentrant. It is only one channel. */
......@@ -54,7 +54,7 @@ enum pop_state
POP_TOP_TX, POP_TOP_ACK, POP_TOP_RX,
POP_UIDL_TX, POP_UIDL_ACK,
POP_USER_TX, POP_USER_ACK,
POP_CLOSE_CONNECTION, /* I do not think a shutdown of a connection will
POP_CLOSE_CONNECTION /* I do not think a shutdown of a connection will
block. More for the symmetry. */
};
......@@ -535,6 +535,7 @@ pop_open (mailbox_t mbox, int flags)
/*
fprintf (stderr, "pop_open unknown state\n");
*/
break;
}/* End AUTHORISATION state. */
/* Spawn cleanup functions. */
......@@ -596,6 +597,7 @@ pop_close (mailbox_t mbox)
/*
fprintf (stderr, "pop_close unknow state");
*/
break;
} /* UPDATE state. */
/* free the messages */
......@@ -794,6 +796,7 @@ pop_messages_count (mailbox_t mbox, size_t *pcount)
/*
fprintf (stderr, "pomp_messages_count: unknow state\n");
*/
break;
}
status = sscanf (bio->buffer, "+OK %d %d", &(mpd->messages_count),
......@@ -937,6 +940,7 @@ pop_expunge (mailbox_t mbox)
break;
default:
/* fprintf (stderr, "pop_expunge: unknow state\n"); */
break;
} /* switch (state) */
} /* if attribute_is_deleted() */
} /* message_get_attribute() */
......@@ -1068,6 +1072,7 @@ pop_uidl (message_t msg, char *buffer, size_t buflen, size_t *pnwriten)
/*
fprintf (stderr, "pop_uidl state\n");
*/
break;
}
CLEAR_STATE (mpd);
......@@ -1181,6 +1186,7 @@ pop_header_read (stream_t is, char *buffer, size_t buflen,
break;
default:
/* fprintf (stderr, "pop_header_blurb unknown state\n"); */
break;
} /* switch (state) */
if (nread == 0)
......@@ -1295,6 +1301,7 @@ pop_readstream (stream_t is, char *buffer, size_t buflen,
}
default:
/* fprintf (stderr, "pop_readstream unknow state\n"); */
break;
} /* Switch state. */
if (nread == 0)
......
......@@ -21,12 +21,12 @@
#include <registrar0.h>
#include <message0.h>
#include <url0.h>
#include <io0.h>
#include <stream0.h>
#include <body0.h>
#include <attribute0.h>
#include <header.h>
#include <auth.h>
#include <locker.h>
#include <mailutils/header.h>
#include <mailutils/auth.h>
#include <mailutils/locker.h>
//#define HAVE_PTHREAD_H
......@@ -37,7 +37,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <mailutils_errno.h>
#include <time.h>
#ifdef HAVE_PTHREAD_H
# include <pthread.h>
......@@ -48,6 +47,7 @@
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <errno.h>
#define ATTRIBUTE_IS_DELETED(flag) (flag & MU_ATTRIBUTE_DELETED)
#define ATTRIBUTE_IS_EQUAL(flag1, flag2) (flag1 == flag2)
......@@ -160,7 +160,7 @@ unix_create (mailbox_t *pmbox, const char *name)
/* Sanity check. */
if (name == NULL || *name == '\0')
return MU_ERROR_INVALID_ARG;
return EINVAL;
name_len = strlen (name);
......@@ -183,14 +183,14 @@ unix_create (mailbox_t *pmbox, const char *name)
/* Allocate memory for mbox. */
mbox = calloc (1, sizeof (*mbox));
if (mbox == NULL)
return MU_ERROR_OUT_OF_MEMORY;
return ENOMEM;
/* Allocate specific unix mbox data. */
mud = mbox->data = calloc (1, sizeof (*mud));
if (mbox->data == NULL)
{
unix_destroy (&mbox);
return MU_ERROR_OUT_OF_MEMORY;
return ENOMEM;
}
/* Copy the name. */
......@@ -198,7 +198,7 @@ unix_create (mailbox_t *pmbox, const char *name)
if (mbox->name == NULL)
{
unix_destroy (&mbox);
return MU_ERROR_OUT_OF_MEMORY;
return ENOMEM;
}
memcpy (mbox->name, name, name_len);
......@@ -212,7 +212,7 @@ unix_create (mailbox_t *pmbox, const char *name)
if (mud->dirname == NULL)
{
unix_destroy (&mbox);
return MU_ERROR_OUT_OF_MEMORY;
return ENOMEM;
}
memcpy (mud->dirname, name, sep - name);
......@@ -221,7 +221,7 @@ unix_create (mailbox_t *pmbox, const char *name)
if (mud->basename == NULL)
{
unix_destroy (&mbox);
return MU_ERROR_OUT_OF_MEMORY;
return ENOMEM;
}
memcpy (mud->basename, sep, name_len - (sep - name));
}
......@@ -233,7 +233,7 @@ unix_create (mailbox_t *pmbox, const char *name)
if (mud->dirname == NULL)
{
unix_destroy (&mbox);
return MU_ERROR_OUT_OF_MEMORY;
return ENOMEM;
}
mud->dirname[0] = '.';
......@@ -241,7 +241,7 @@ unix_create (mailbox_t *pmbox, const char *name)
if (mud->basename == NULL)
{
unix_destroy (&mbox);
return MU_ERROR_OUT_OF_MEMORY;
return ENOMEM;
}
memcpy (mud->basename, name, name_len);
}
......
......@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <io0.h>
#include <stream0.h>
#include <message0.h>
#include <errno.h>
......
......@@ -18,9 +18,8 @@
#include <message0.h>
#include <mime0.h>
#include <io0.h>
#include <stream0.h>
#include <body0.h>
#include <mime.h>
#include <errno.h>
#include <stdio.h>
......
......@@ -15,12 +15,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <io0.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <stream0.h>
int
stream_create (stream_t *pstream, int flags, void *owner)
{
......
......@@ -27,8 +27,8 @@
#include <arpa/inet.h>
#include <unistd.h>
#include <io0.h>
#include <tcp.h>
#include <stream0.h>
#include <tcp0.h>
static int _tcp_close(stream_t stream)
{
......
......@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <io0.h>
#include <stream0.h>
struct _ts_desc {
const char *encoding;
......
......@@ -21,8 +21,8 @@
#include <stdlib.h>
#include <string.h>
#include <io0.h>
#include <transcode.h>
#include <steam0.h>
#include <mailutils/transcode.h>
int _base64_decode(stream_t stream, char *optr, size_t osize, off_t offset, size_t *nbytes);
int _base64_encode(stream_t stream, const char *optr, size_t osize, off_t offset, size_t *nbytes);
......
......@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <url0.h>
#include <registrar.h>
#include <mailutils/registrar.h>
#include <errno.h>
static int url_imap_create (url_t *purl, const char *name);
......
......@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <url0.h>
#include <registrar.h>
#include <mailutils/registrar.h>
#include <errno.h>
static int url_mailto_create (url_t *purl, const char *name);
......
......@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <url0.h>
#include <registrar.h>
#include <mailutils/registrar.h>
#include <errno.h>
#include <stdlib.h>
......
......@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <url0.h>
#include <registrar.h>
#include <mailutils/registrar.h>
#include <errno.h>
#include <stdlib.h>
......
......@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <url0.h>
#include <registrar.h>
#include <mailutils/registrar.h>
#include <errno.h>
#include <stdlib.h>
......
......@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <url0.h>
#include <registrar.h>
#include <mailutils/registrar.h>
#include <errno.h>
#include <stdlib.h>
......
......@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <url0.h>
#include <registrar.h>
#include <mailutils/registrar.h>
#include <errno.h>
#include <stdlib.h>
......
......@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <url0.h>
#include <registrar.h>
#include <mailutils/registrar.h>
#include <errno.h>
#include <stdlib.h>
......