diff options
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)); +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 */ diff --git a/include/mailutils/body.h b/include/mailutils/body.h new file mode 100644 index 000000000..f1720b723 --- /dev/null +++ b/include/mailutils/body.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 vers |