diff options
author | Alain Magloire <alainm@gnu.org> | 2001-12-31 16:39:45 +0000 |
---|---|---|
committer | Alain Magloire <alainm@gnu.org> | 2001-12-31 16:39:45 +0000 |
commit | 25db453e96894f1f8c7320ec49a8213b9a2cdd1f (patch) | |
tree | bf6bf4927f4970e3199fa73825a73a6f838db1b4 | |
parent | 89287b76311a4b74a99243a88ac4bf5dfb3a149a (diff) | |
download | mailutils-25db453e96894f1f8c7320ec49a8213b9a2cdd1f.tar.gz mailutils-25db453e96894f1f8c7320ec49a8213b9a2cdd1f.tar.bz2 |
* doc/texinfo/programs.texi: Descibe the readmsg utility.
* configure.in: Enable readmsg.
* Makefile.in: Enable readmsg.
* readmsg/readmsg.c: Implementation.
* readmsg/msglist.c: Implement Elm weird expansion.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | doc/texinfo/programs.texi | 92 | ||||
-rw-r--r-- | readmsg/msglist.c | 126 | ||||
-rw-r--r-- | readmsg/readmsg.c | 438 | ||||
-rw-r--r-- | readmsg/readmsg.h | 12 |
7 files changed, 396 insertions, 287 deletions
@@ -1,3 +1,11 @@ +2001-12-31 Alain Magloire + + * doc/texinfo/programs.texi: Descibe the readmsg utility. + * configure.in: Enable readmsg. + * Makefile.in: Enable readmsg. + * readmsg/readmsg.c: Implementation. + * readmsg/msglist.c: Implement Elm weird expansion. + 2001-12-29 Sergey Poznyakoff * guimb/scm/numaddr.scm: (new) Implements "numaddr" extension @@ -5,7 +13,7 @@ that contain addresses. It returns true if the total number of addresses satisfies the requested relation, e.g.: if numaddr :over [ "To", "Cc" ] 50 { discard; } - + * guimb/scm/Makefile.am: Added numaddr.scm. * guimb/scm/redirect.scm: Use mu-message-send instead of sieve-message-bounce. diff --git a/Makefile.am b/Makefile.am index 8da93cc2b..ab565219b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = gnu 1.4 ACLOCAL_AMFLAGS = -I m4 SUBDIRS = include doc m4 lib MySql argp mailbox frm from pop3d imap4d mail sieve \ - scripts libmu_scm guimb messages comsat + scripts libmu_scm guimb messages comsat readmsg EXTRA_DIST = mailutils.spec mailutils.spec.in README-alpha COPYING.FDL diff --git a/configure.in b/configure.in index 8dda73f62..180087243 100644 --- a/configure.in +++ b/configure.in @@ -140,7 +140,7 @@ AC_FUNC_FNMATCH if test "$ac_cv_func_fnmatch_works" = "no"; then : LIBOBJS="$LIBOBJS fnmatch.o" fi -AC_REPLACE_FUNCS(fgetpwent setenv snprintf strtok_r strncasecmp strcasecmp \ +AC_REPLACE_FUNCS(fgetpwent getpass setenv snprintf strtok_r strncasecmp strcasecmp \ strsignal vasprintf) AC_CHECK_FUNCS(mkstemp sigaction sysconf getdelim vsyslog) @@ -307,4 +307,5 @@ AC_OUTPUT(Makefile mailutils.spec include/Makefile include/mailutils/Makefile mailbox/include/Makefile from/Makefile mail/Makefile pop3d/Makefile frm/Makefile sieve/Makefile messages/Makefile scripts/Makefile libmu_scm/Makefile guimb/Makefile guimb/scm/Makefile + readmsg/Makefile MySql/Makefile mh/Makefile comsat/Makefile) diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi index edd2cdef0..76e178f4a 100644 --- a/doc/texinfo/programs.texi +++ b/doc/texinfo/programs.texi @@ -3,7 +3,7 @@ @c See file mailutils.texi for copying conditions. @comment ******************************************************************* -GNU Mailutils provides a set of programs for handling the email. +GNU Mailutils provides a set of programs for handling the email. @menu * imap4d:: IMAP4 daemon. @@ -54,7 +54,7 @@ it defaults to 20 processes. Display short help message and exit. @item -i @itemx --inetd -Run in inetd mode. +Run in inetd mode. @item -p NUMBER @itemx --port NUMBER Listen on given port NUMBER. This option is meaningful only in @@ -108,7 +108,7 @@ it defaults to 10 processes. Display short help message and exit. @item -i @itemx --inetd -Run in inetd mode. +Run in inetd mode. @item -p NUMBER @itemx --port NUMBER Listen on given port NUMBER. This option is meaningful only in @@ -395,7 +395,7 @@ are single-character commands, preceded by special @dfn{escape character}, which defaults to @samp{~}. The combination @code{escape character + command} is recognized as a compose escape only if it occurs at the beginning of a line. If the escape character must appear at the beginning of a -line, enter it twice. +line, enter it twice. The actual escape character may be changed by setting the value of @code{escape} mail variable (@pxref{Mail Variables}). @@ -476,7 +476,7 @@ To change the @code{Subject} header, use @samp{~s} escape, e.g.: Finally, to edit all headers, type @samp{~h} escape. This will present you with the values of @code{To}, @code{Cc}, @code{Bcc}, and @code{Subject} headers allowing to edit them with normal text editing -commands. +commands. @node Enclosing Another Message @subsubsection Enclosing Another Message: ~m and ~M @@ -668,7 +668,7 @@ Following commands can be used during the session to request online help: @table @samp -@item help [@var{command}] +@item help [@var{command}] @itemx hel [@var{command}] @itemx ? [@var{command}] Display detailed command synopsis. If no @var{command} is given, help for @@ -815,7 +815,7 @@ out specified message parts. E.g. @example & decode 15[2] +--------------------------------------- -| Message=15[2] +| Message=15[2] | Type=message/delivery-status | encoding=7bit +--------------------------------------- @@ -1044,7 +1044,7 @@ unset prompt endif if s alt gray@@farlep.net gray@@mirddin.farlep.net -set +set @end example @node Aliasing @@ -1225,7 +1225,7 @@ denoting escapes. The name of the directory to use for storing folders of messages. If unset, $HOME is assumed. - + @item header @*Type: Boolean. @*Default: True, unless started with @samp{--nosum} (@samp{-N}) option. @@ -1444,7 +1444,71 @@ Output program version and exit. @section readmsg --- Extract messages from a folder. @pindex readmsg -The program is currently in development +The program, readmsg, extracts with the selection argument messages from +a mailbox. Selection can be specify by: + +@enumerate + +@item +A lone ``*'' means select all messages in the mailbox. + +@item +A list of message numbers may be specified. Values +of ``0'' and ``$'' in the list both mean the last +message in the mailbox. For example: +@example + readmsg 1 3 0 +@end example +extracts three messages from the folder: the first, the third, and the last. + +@item +Finally, the selection may be some text to match. This will select a mail +message which exactly matches the specified text. For example, +@example + readmsg staff meeting +@end example +extracts the message which contains the words ``staff meeting.'' Note that it +will not match a message containing ``Staff Meeting'' - the matching is case +sensitive. Normally only the first message which matches the pattern will be +printed. + +@end enumerate + +@subheading Command line options + +@table @samp + +@item -a +@itemx --show-all +If a pattern is use for selection show all messages that match pattern +by default only the first one is presented. + +@item -d +@itemx --debug +Display mailbox debuging information. + +@item -f @var{MAILBOX} +@itemx --folder=@var{MAILBOX} +Specified the default mailbox. + +@item -h +@itemx --header +Show the entire header and ignore the weedlist. + +@item -n +@itemx --no-header +Do not print the message header. + +@item -p +@itemx --form-feed +Put form-feed (Control-L) between messages instead of newline. + +@item -w @var{weedlist} +@itemx --weedlist=@var{weedlist} +A whitespace or coma separated list of header names to show per message. +Default is --weedlist=''From Subject Date To CC Apparently-'' + +@end table @page @node sieve @@ -1467,7 +1531,7 @@ format. * Specifying Scheme Program to Execute:: * Specifying Mailboxes to Operate Upon:: * Passing Options to Scheme:: -* Guimb Invocation Summary:: +* Guimb Invocation Summary:: * Scheme Procedures and Variables:: @end menu @@ -1816,7 +1880,7 @@ The server is started from @file{/etc/inetd.conf} file: @example comsat dgram udp wait root /usr/sbin/comsatd \ -comsatd -c /etc/comsat.conf +comsatd -c /etc/comsat.conf @end example This is the default operation mode. @@ -1868,7 +1932,7 @@ it is enabled. @subsubsection Security Settings These statements control the way @file{comsatd} fights possible -flooding attacks. +flooding attacks. @table @asis @item max-requests @var{number} @@ -1886,7 +1950,7 @@ within @var{number} seconds, the overflow-delay-time is doubled. @subsubsection Access Control Lists Access control lists determine from which addresses @file{comsatd} -will receive mail notification messages. +will receive mail notification messages. The access control lists are introduced in configuration file using keyword @samp{acl}. General format for an ACL rule is diff --git a/readmsg/msglist.c b/readmsg/msglist.c index 393d631b0..93c0e7937 100644 --- a/readmsg/msglist.c +++ b/readmsg/msglist.c @@ -37,74 +37,104 @@ addset (int **set, int *n, unsigned val) return 0; } +static int +isnumber (const char *s) +{ + int is_number = 1; + if (*s == '\0') + is_number = 0; + for (; *s; s++) + { + if (!isdigit ((unsigned char)*s)) + { + is_number = 0; + break; + } + } + return is_number; +} + +/* + According to ELM readmsg(1): + + 1. A lone ``*'' means select all messages in the mailbox. + + 2. A list of message numbers may be specified. Values of ``0'' and ``$'' in the + list both mean the last message in the mailbox. For example: + + readmsg 1 3 0 + + extracts three messages from the folder: the first, the third, and the last. + + 3. Finally, the selection may be some text to match. This will select a mail + message which exactly matches the specified text. For example, + + readmsg staff meeting + + extracts the message which contains the words ``staff meeting.'' Note that it + will not match a message containing ``Staff Meeting'' - the matching is case + sensitive. Normally only the first message which matches the pattern will be + printed. The -a option discussed in a moment changes this. +*/ + int -msgset (const int argc, char **argv, int **set, int *n) +msglist (mailbox_t mbox, int show_all, int argc, char **argv, int **set, int *n) { - int i = 0, lc = 0; - int undelete = 0; - int *ret = NULL; + int i = 0; + size_t total = 0; + + mailbox_messages_count (mbox, &total); for (i = 0; i < argc; i++) { - /* Last message */ - if (!strcmp (argv[i], "$") || !strcmp (argv[i], "0")) + /* 1. A lone ``*'' means select all messages in the mailbox. */ + if (!strcmp (argv[i], "*")) { - addset (set, n, total); + size_t j; + /* all messages */ + for (j = 1; j <= total; j++) + addset (set, n, j); + j = argc + 1; } - else if (!strcmp (argv[i], "*")) + /* 2. A list of message numbers may be specified. Values of ``0'' and ``$'' in the + list both mean the last message in the mailbox. */ + else if (!strcmp (argv[i], "$") || !strcmp (argv[i], "0")) { - /* all messages */ - for (i = 1; i <= total; i++) - addset (set, n, i); - i = argc + 1; + size_t j; + mailbox_messages_count (mbox, &total); + for (j = 1; j < total; j++) + addset (set, n, j); } - else if (argv[i][0] == '/') + /* 3. Finally, the selection may be some text to match. This will select a mail + message which exactly matches the specified text. */ + else if (!isnumber(argv[i])) { - /* FIXME: all messages with pattern following / in - the subject line, case insensitive */ - /* This currently appears to be quit b0rked */ - message_t msg; - header_t hdr; - char subj[128]; - int j = 1, k = 0, len2 = 0; - int len = strlen (&argv[i][1]); + size_t j; + int found = 0; for (j = 1; j <= total; j++) { + char buf[128]; + size_t len = 0; + off_t offset = 0; + message_t msg = NULL; + stream_t stream = NULL; mailbox_get_message (mbox, j, &msg); - message_get_header (msg, &hdr); - header_get_value (hdr, MU_HEADER_SUBJECT, subj, 128, NULL); - len2 = strlen (subj); - for (k = 0; i < strlen (subj); k++) + message_get_stream (msg, &stream); + while (stream_readline (stream, buf, sizeof buf, offset, &len) == 0 && len > 0) { - if (len2 - k >= len - && !strncasecmp (&argv[i][1], &subj[k], len)) + if (strstr (buf, argv[i]) != NULL) { addset (set, n, j); - k = 128; + found = 1; + break; } + offset += len; } + if (found && !show_all) + break; } } - else if (isalpha(argv[i][0])) - { - /* FIXME: all messages from sender argv[i] */ - } - else if (strchr (argv[i], '-') != NULL) - { - /* message range */ - int j, x, y; - char *arg = strdup (argv[i]); - for (j = 0; j < strlen (arg); j++) - if (arg[j] == '-') - break; - arg[j] = '\0'; - x = strtol (arg, NULL, 10); - y = strtol (&(arg[j + 1]), NULL, 10); - for (; x <= y; x++) - addset (set, n, x); - free (arg); - } - else + else if (isdigit (argv[i][0])) { /* single message */ addset (set, n, strtol (argv[i], NULL, 10)); diff --git a/readmsg/readmsg.c b/readmsg/readmsg.c index 2f5fb3711..615f3f5de 100644 --- a/readmsg/readmsg.c +++ b/readmsg/readmsg.c @@ -20,31 +20,220 @@ #endif #include "readmsg.h" +#define WEEDLIST_SEPARATOR " :," -mailbox_t mbox; -size_t total; +static void usage __P ((int, const char *)); +static void print_header __P ((message_t, int no_header, int all_header, const char *weedlst)); +static void print_body __P ((message_t)); +static int string_starts_with __P ((const char * s1, const char *s2)); -static char from[256]; -static char subject[256]; +const char *short_options = "adnhpf:w:"; +static struct option long_options[] = +{ + {"debug", no_argument, 0, 'd'}, + {"header", no_argument, 0, 'h'}, + {"weedlist", required_argument, 0, 'w'}, + {"folder", no_argument, 0, 'f'}, + {"no-header", no_argument, 0, 'n'}, + {"form-feeds", no_argument, 0, 'p'}, + {"show-all-match", required_argument, 0, 'a'}, + {"help", no_argument, 0, '&'}, + {"version", no_argument, 0, 'v'}, + {0, 0, 0, 0} +}; + +static int +string_starts_with (const char * s1, const char *s2) +{ + const unsigned char * p1 = (const unsigned char *) s1; + const unsigned char * p2 = (const unsigned char *) s2; + int n = 0; + + /* Sanity. */ + if (s1 == NULL || s2 == NULL) + return n; + + while (*p1 && *p2) + { + if ((n = toupper (*p1++) - toupper (*p2++)) != 0) + break; + } + return (n == 0); +} + +static void +print_header (message_t message, int no_header, int all_headers, const char *weedlist) +{ + header_t header = NULL; + + if (no_header) + return; + + message_get_header (message, &header); + + if (all_headers) + { + stream_t stream = NULL; + off_t offset = 0; + size_t len = 0; + char buf[128]; + + header_get_stream (header, &stream); + while (stream_read (stream, buf, sizeof (buf) - 1, offset, &len) == 0 && len != 0) + { + buf[len] ='\0'; + printf ("%s", buf); + offset += len; + } + } + else + { + size_t count = 0; + const char *delim = WEEDLIST_SEPARATOR; + size_t i; + + header_get_field_count (header, &count); + + for (i = 1; i < count; i++) + { + char *name = NULL; + char *value = NULL; + char *token = strdup (weedlist); + char *p = token; + + header_aget_field_name (header, i, &name); + header_aget_field_value (header, i, &value); + for (; (token = strtok (token, delim)) != NULL; token = NULL) + { + if (string_starts_with (name, token)) + { + /* Check if header_aget_value return an empty string. */ + if (value && *value) + printf ("%s: %s\n", name, value); + } + } + free (value); + free (name); + free (p); + } + putchar ('\n'); + } +} + +static void +print_body (message_t message) +{ + char buf[128]; + body_t body = NULL; + stream_t stream = NULL; + off_t offset = 0; + size_t len = 0; + message_get_body (message, &body); + body_get_stream (body, &stream); + while (stream_read (stream, buf, sizeof (buf) - 1, offset, &len) == 0 && len != 0) + { + buf[len] ='\0'; + printf ("%s", buf); + offset += len; + } +} + +static void +usage (int status, const char *prognam) +{ + if (status == 0) + { + printf ("GNU Mailutils.\n"); + printf ("Usage: %s [OPTIONS]\n\n", prognam); + printf (" -d, --debug display debuging information\n"); + printf (" -h, --header display the entire header\n"); + printf (" -f, --folder=FILE folder to use\n"); + printf (" -w, --weelist=LIST list of header names separated by whitespace or commas\n"); + printf (" -n, --no-header exclude all headers\n"); + printf (" -p, --form-feeds put form-feeds between messages instead of newline\n"); + printf (" -a, --show-all-match print all message matching PATTERN\n"); + printf (" --help display this help and exit\n"); + printf (" -v, --version display version information and exit\n"); + printf ("\nReport bugs to bug-mailutils@gnu.org\n"); + } + else + { + printf ("Try: %s --help\n", prognam); + } + exit (status); +} -static void display_parts (message_t, const char *indent); /* This is still work in progress */ +/* FIXME: Parse options: See readmsg(1) part of elm: + readmsg 1 3 0 + extracts three messages from the folder: the first, the third, and + the last. */ int -main(int argc, char **argv) +main (int argc, char **argv) { int status; int *set = NULL; int n = 0; - size_t i; - char *mailbox_name = NULL; - - /* FIXME: Parse options: See readmsg(1) part of elm: - readmsg 1 3 0 - extracts three messages from the folder: the first, the third, and - the last. */ + int i; + int c; + int dbug = 0; + const char *mailbox_name = NULL; + const char *weedlist = NULL; + int no_header = 0; + int all_header = 0; + int form_feed = 0; + int show_all = 0; + mailbox_t mbox = NULL; + + while ((c = getopt_long (argc, argv, short_options, long_options, NULL)) + != -1) + { + switch (c) + { + case 'd': + dbug++; + break; + + case 'h': + all_header = 1; + break; + + case 'f': + mailbox_name = optarg; + break; + + case 'w': + weedlist = optarg; + break; + + case 'n': + no_header = 1; + break; + + case 'p': + form_feed = 1; + break; + + case 'a': + show_all = 1; + break; + + case '&': + usage (0, argv[0]); + break; + + case 'v': + printf ("Mailutils 0.0.0: readmsg\n"); + exit (0); + break; + + default: + usage (1, argv[0]); + break; + } + } - /* Check this in the option --folder. */ /* Registration. */ { @@ -64,7 +253,7 @@ main(int argc, char **argv) } /* Debuging Trace. */ - if ( 0 ) + if (dbug) { mu_debug_t debug; mailbox_get_debug (mbox, &debug); @@ -74,26 +263,21 @@ main(int argc, char **argv) status = mailbox_open (mbox, MU_STREAM_READ); if (status != 0) { - fprintf (stderr, "could not open - %s\n", strerror(status)); + fprintf (stderr, "mailbox open - %s\n", strerror(status)); exit (2); } - mailbox_messages_count (mbox, &total); + if (weedlist == NULL) + weedlist = "Date To Cc Subject From Apparently-"; /* Build an array containing the message number. */ - if (argc > 1) - msgset (argc - 1, &argv[1], &set, &n); - else - { - const char *av[] = { "*" }; - msgset (1, av, &set, &n); - } + argc -= optind; + if (argc > 0) + msglist (mbox, show_all, argc, &argv[optind], &set, &n); for (i = 0; i < n; ++i) { - message_t msg; - header_t hdr; - size_t msize; + message_t msg = NULL; status = mailbox_get_message (mbox, set[i], &msg); if (status != 0) @@ -102,201 +286,15 @@ main(int argc, char **argv) exit (2); } - status = message_get_header (msg, &hdr); - if (status != 0) - { - fprintf (stderr, "message_get_header - %s\n", strerror(status)); - exit(2); - } - - header_get_value (hdr, MU_HEADER_FROM, from, sizeof (from), NULL); - header_get_value (hdr, MU_HEADER_SUBJECT, subject, sizeof (subject), - NULL); - fprintf(stdout, "From: %s\tSubject: %s\n", from, subject); - - status = message_size (msg, &msize); - if (status != 0) - { - fprintf (stderr, "message_size - %s\n", strerror(status)); - exit(2); - } - fprintf (stdout, "-- Total message size - %d\n", msize); - - display_parts (msg, "\t"); + print_header (msg, no_header, all_header, weedlist); + print_body (msg); + if (form_feed) + putchar ('\f'); + else + putchar ('\n'); } + putchar ('\n'); mailbox_close (mbox); mailbox_destroy (&mbox); return 0; } - -static char buf[2048]; - -static void -display_parts (message_t message, const char *indent) -{ - int status, j; - size_t msize, nparts; - message_t msg; - header_t hdr; - char type[256]; - char encoding[256]; - int is_multi = 0; - char *nl; - - status = message_get_num_parts (message, &nparts); - if (status != 0) - { - fprintf (stderr, "message_get_num_parts - %s\n", strerror (status)); - exit (2); - } - fprintf(stdout, "%s-- Number of parts in message - %d\n", indent, nparts); - - for (j = 1; j <= nparts; j++) - { - status = message_get_part (message, j, &msg); - if (status != 0 ) - { - fprintf (stderr, "message_get_part - %s\n", strerror (status)); - exit (2); - } - - status = message_get_header (msg, &hdr); - if (status != 0) - { - fprintf (stderr, "message_get_header - %s\n", strerror (status)); - exit (2); - } - - type[0] = '\0'; - header_get_value (hdr, MU_HEADER_CONTENT_TYPE, type, sizeof (type), - NULL); - - nl = strchr (type, '\n'); - while ((nl = strchr (type, '\n')) != NULL) - { - *nl = ' '; - } - fprintf(stdout, "%sType of part %d = %s\n", indent, j, type); - - status = message_size (msg, &msize); - if (status != 0) - { - fprintf (stderr, "message_size - %s\n", strerror (status)); - exit (2); - } - fprintf(stdout, "%sMessage part size - %d\n",indent, msize); - - encoding[0] = '\0'; - header_get_value (hdr, MU_HEADER_CONTENT_TRANSFER_ENCODING, encoding, - sizeof (encoding), NULL); - - if (type[0] && strncasecmp (type, "message/rfc822", strlen (type)) == 0) - { - message_t submsg = NULL; - char tmp[10]; - tmp[0] = '\0'; - - status = message_unencapsulate (msg, &submsg, NULL); - if (status != 0) - { - fprintf (stderr, "message_unencapsulate - %s\n", strerror (status)); - exit (2); - } - - status = message_get_header (submsg, &hdr); - if (status != 0) - { - fprintf (stderr, "message_get_header - %s\n", strerror (status)); - exit (2); - } - - header_get_value (hdr, MU_HEADER_FROM, from, sizeof (from), NULL); - header_get_value (hdr, MU_HEADER_SUBJECT, subject, sizeof (subject), - NULL); - fprintf (stdout, "%sEncapsulated message : %s\t%s\n", indent, from, - subject); - fprintf (stdout, "%s----------------------------------------------\ ----------------------\n", indent); - - strcpy (tmp, indent); - strcat (tmp,"\t"); - display_parts (submsg, tmp); - message_destroy (&submsg, NULL); - } - else if ((strncasecmp (type, "text/plain", strlen ("text/plain")) == 0) - || (strncasecmp (type, "text/html", strlen ("text/html")) == 0)) - { - stream_t d_stream = NULL; - stream_t b_stream = NULL; - body_t body; - size_t nbytes = 0; - int offset = 0; - fprintf (stdout, "%sText Message\n",indent); - fprintf (stdout, "%s-------------------------------------------------------------------\n", indent); - message_get_body (msg, &body); - body_get_stream (body, &b_stream); - //d_stream = b_stream; - //status = decoder_stream_create(&d_stream, b_stream, encoding); - status = filter_create (&d_stream, b_stream, encoding, 0, 0); - stream_setbufsiz (d_stream, 128); - if (status != 0) - { - d_stream = b_stream; - } - while (stream_readline (d_stream, buf, sizeof (buf), - offset, &nbytes ) == 0 && nbytes ) - { - fprintf (stdout, "%s%s", indent, buf); - offset += nbytes; - } - if (status == 0) - stream_destroy(&d_stream, NULL); - } - else - { - message_is_multipart (msg, &is_multi); - if (is_multi) - { - char tmp[24]; - memset (tmp, '\0', sizeof (tmp)); - strcpy(tmp, indent); - strcat(tmp,"\t"); - display_parts (msg, tmp); - } - else - { - body_t body = NULL; - stream_t stream = NULL; - size_t nbytes = 0; - int offset = 0; - message_get_body (msg, &body); - body_get_stream (body, &stream); -#if 0 - while (stream_readline (stream, buf, sizeof (buf), - offset, &nbytes ) == 0 && nbytes ) - { - fprintf (stdout, "%s%s", indent, buf); - offset += nbytes; - } -#endif - } -#if 0 - { - char *fname; - message_attachment_filename ( msg, &fname); - if ( fname == NULL ) - { - char buffer[PATH_MAX+1]; - fname = tempnam (getcwd(buffer, PATH_MAX), "msg-" ); - } - fprintf (stdout, "%sAttachment - saving [%s]\n",indent, fname); - fprintf (stdout, "%s-------------------------------------------------------------------\n", indent); - message_save_attachment (msg, fname, NULL); - free (fname); - } -#endif - - } - fprintf(stdout, "\n%s End -------------------------------------------------------------------\n", indent); - } -} diff --git a/readmsg/readmsg.h b/readmsg/readmsg.h index b0706b51e..7a2929fbe 100644 --- a/readmsg/readmsg.h +++ b/readmsg/readmsg.h @@ -22,9 +22,11 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <ctype.h> #include <unistd.h> #include <limits.h> #include <errno.h> +#include <getopt.h> #include <mailutils/mailbox.h> #include <mailutils/header.h> @@ -32,7 +34,13 @@ #include <mailutils/filter.h> #include <mailutils/registrar.h> -extern mailbox_t mbox; -extern size_t total; +#ifndef __P +#ifdef __STDC__ +#define __P(args) args +#else +#define __P(args) () +#endif +#endif /*__P */ +int msglist __P ((mailbox_t mbox, int show_all, int argc, char **argv, int **set, int *n)); #endif |