summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlain Magloire <alainm@gnu.org>2000-09-02 02:46:06 +0000
committerAlain Magloire <alainm@gnu.org>2000-09-02 02:46:06 +0000
commitdcd6e4da331e2e751fb880f9861d117e6787a8e1 (patch)
tree335212e2c25eb6ec37b646d96b0b93720e4a7464
parent55b26b616fd2d33a29f0c77d205a1ebd7cef95be (diff)
downloadmailutils-dcd6e4da331e2e751fb880f9861d117e6787a8e1.tar.gz
mailutils-dcd6e4da331e2e751fb880f9861d117e6787a8e1.tar.bz2
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.
-rw-r--r--Makefile.am5
-rw-r--r--acconfig.h1
-rwxr-xr-xautogen.sh4
-rw-r--r--configure.in26
-rw-r--r--from/Makefile.am7
-rw-r--r--from/from.c222
-rw-r--r--include/mailutils/Makefile.am17
-rw-r--r--include/mailutils/attribute.h95
-rw-r--r--include/mailutils/auth.h62
-rw-r--r--include/mailutils/body.h62
-rw-r--r--include/mailutils/event.h45
-rw-r--r--include/mailutils/header.h96
-rw-r--r--include/mailutils/locker.h58
-rw-r--r--include/mailutils/mailbox.h117
-rw-r--r--include/mailutils/mailer.h51
-rw-r--r--include/mailutils/message.h114
-rw-r--r--include/mailutils/mime.h59
-rw-r--r--include/mailutils/registrar.h73
-rw-r--r--include/mailutils/stream.h121
-rw-r--r--include/mailutils/transcode.h56
-rw-r--r--include/mailutils/url.h68
-rw-r--r--lib/Makefile.am6
-rw-r--r--mail/Makefile.am6
-rw-r--r--mail/mail.c225
-rw-r--r--mailbox/Makefile.am6
-rw-r--r--mailbox/attachment.c6
-rw-r--r--mailbox/attribute.c4
-rw-r--r--mailbox/auth.c6
-rw-r--r--mailbox/body.c8
-rw-r--r--mailbox/file_stream.c2
-rw-r--r--mailbox/header.c6
-rw-r--r--mailbox/include/Makefile.am5
-rw-r--r--mailbox/include/attribute0.h48
-rw-r--r--mailbox/include/auth0.h49
-rw-r--r--mailbox/include/body0.h55
-rw-r--r--mailbox/include/cpystr.h40
-rw-r--r--mailbox/include/header0.h71
-rw-r--r--mailbox/include/mailbox0.h96
-rw-r--r--mailbox/include/mailer0.h67
-rw-r--r--mailbox/include/mbx_imap.h28
-rw-r--r--mailbox/include/mbx_mbox.h28
-rw-r--r--mailbox/include/mbx_mdir.h28
-rw-r--r--mailbox/include/mbx_mmdf.h28
-rw-r--r--mailbox/include/mbx_pop.h28
-rw-r--r--mailbox/include/mbx_unix.h36
-rw-r--r--mailbox/include/message0.h75
-rw-r--r--mailbox/include/mime0.h92
-rw-r--r--mailbox/include/registrar0.h92
-rw-r--r--mailbox/include/stream0.h56
-rw-r--r--mailbox/include/tcp0.h35
-rw-r--r--mailbox/include/url0.h98
-rw-r--r--mailbox/locker.c3
-rw-r--r--mailbox/mailbox.c55
-rw-r--r--mailbox/mapfile_stream.c2
-rw-r--r--mailbox/mbx_default.c2
-rw-r--r--mailbox/mbx_imap.c2
-rw-r--r--mailbox/mbx_mbox.c6
-rw-r--r--mailbox/mbx_mdir.c2
-rw-r--r--mailbox/mbx_mh.c5
-rw-r--r--mailbox/mbx_mmdf.c4
-rw-r--r--mailbox/mbx_pop.c29
-rw-r--r--mailbox/mbx_unix.c26
-rw-r--r--mailbox/message.c2
-rw-r--r--mailbox/mime.c3
-rw-r--r--mailbox/stream.c (renamed from mailbox/io.c)4
-rw-r--r--mailbox/tcp.c4
-rw-r--r--mailbox/trans_stream.c2
-rw-r--r--mailbox/transcode.c4
-rw-r--r--mailbox/url_imap.c2
-rw-r--r--mailbox/url_mail.c2
-rw-r--r--mailbox/url_mbox.c2
-rw-r--r--mailbox/url_mdir.c2
-rw-r--r--mailbox/url_mh.c2
-rw-r--r--mailbox/url_mmdf.c2
-rw-r--r--mailbox/url_pop.c2
-rw-r--r--mailbox/url_unix.c2
76 files changed, 2495 insertions, 365 deletions
diff --git a/Makefile.am b/Makefile.am
index 31b4c2fe5..144136b7c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,6 @@
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
diff --git a/acconfig.h b/acconfig.h
index 318efe305..e4550f8ce 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -17,4 +17,5 @@
/* Define if using libpam */
#undef USE_LIBPAM
+#undef HAVE_SNPRINTF
diff --git a/autogen.sh b/autogen.sh
index 367a7d392..949907e4b 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,7 +1,7 @@
#!/bin/sh
aclocal -I m4
-libtoolize --copy --automake
+libtoolize --automake
autoheader
-automake --add-missing --copy --gnu
+automake -a
autoconf
diff --git a/configure.in b/configure.in
index bae532380..64454bba8 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
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)
diff --git a/from/Makefile.am b/from/Makefile.am
new file mode 100644
index 000000000..8e712a630
--- /dev/null
+++ b/from/Makefile.am
@@ -0,0 +1,7 @@
+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
diff --git a/from/from.c b/from/from.c
index 14f8467bb..470e8b5ec 100644
--- a/from/from.c
+++ b/from/from.c
@@ -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];
+ int status;
- /* set program name */
- program = argv[0];
- if (program && strrchr (program, '/'))
- {
- program = strrchr (program, '/') + 1;
- }
+ /* have an argument */
+ if (argc > 1)
+ mailbox_name = argv[1];
- while ((opt = getopt_long (argc, argv, short_options, long_options, NULL))
- != -1)
+ if ((status = mailbox_create_default (&mbox, mailbox_name)) != 0
+ || (status = mailbox_open (mbox, MU_MAILBOX_RDONLY)) != 0)
{
- 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;
- }
+ fprintf (stderr, "could not create/open: %s\n", strerror (status));
+ exit (1);
}
- /* 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
+ mailbox_messages_count (mbox, &count);
+ for(i = 1; i <= count; ++i)
{
- user = (getenv ("LOGNAME")) ? getenv ("LOGNAME") : getenv ("USER");
- if (user == NULL)
+ message_t msg;
+ header_t hdr;
+ if ((status = mailbox_get_message (mbox, i, &msg)) != 0
+ || (status = message_get_header (msg, &hdr)) != 0)
{
- fprintf (stderr, "who am I?\n");
- exit (1);
+ fprintf (stderr, "msg %d : %s\n", i, strerror(status));
+ exit(2);
}
- }
- 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)
- {
- 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)
- {
- fprintf (stderr, "header %s\n", strerror (rvalue));
- 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;
}
diff --git a/include/mailutils/Makefile.am b/include/mailutils/Makefile.am
new file mode 100644
index 000000000..c07a5f26b
--- /dev/null
+++ b/include/mailutils/Makefile.am
@@ -0,0 +1,17 @@
+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
+
diff --git a/include/mailutils/attribute.h b/include/mailutils/attribute.h
new file mode 100644
index 000000000..6baf13db0
--- /dev/null
+++ b/include/mailutils/attribute.h
@@ -0,0 +1,95 @@
+/* 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 */
diff --git a/include/mailutils/auth.h b/include/mailutils/auth.h
new file mode 100644
index 000000000..7cec61162
--- /dev/null
+++ b/include/mailutils/auth.h
@@ -0,0 +1,62 @@
+/* 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));
+ex