From c19253d0806d84bc1a8557ab1472f0439af291ea Mon Sep 17 00:00:00 2001 From: Daniel Spiljar Date: Wed, 19 Apr 2023 21:55:25 +0200 Subject: [PATCH] Check command-line options for conflicting matchers and actions. --- src/main.c | 30 +++----- src/mbox.c | 46 ++++++------ src/mboxgrep.h | 46 +++++++----- src/mh.c | 4 +- src/misc.c | 186 ++++++++++++++++++++++++++++++++++++------------- src/misc.h | 11 +-- src/re.c | 2 +- src/scan.c | 68 +++++++++--------- 8 files changed, 241 insertions(+), 152 deletions(-) diff --git a/src/main.c b/src/main.c index da14fac..bdbe76f 100644 --- a/src/main.c +++ b/src/main.c @@ -24,7 +24,6 @@ #include #include #include -#include #ifdef HAVE_LIBZ # include #endif /* HAVE_LIBZ */ @@ -81,21 +80,11 @@ main (int argc, char **argv) {0, 0, 0, 0} }; - set_default_options (); + init_options (); - get_runtime_options (&argc, argv, long_options); + get_options (&argc, argv, long_options); - if ((config.body == 0) && (config.headers == 0)) - { - config.body = 1; - config.headers = 1; - } - - if (config.format == MAILDIR && config.action == WRITE) - { - gethostname (config.hostname, HOST_NAME_SIZE); - config.pid = (int) getpid (); - } + check_options (); runtime.cs = (checksum_t *) xmalloc (sizeof (checksum_t)); runtime.cs->md5 = (char **) xcalloc (1, sizeof (char **)); @@ -111,7 +100,7 @@ main (int argc, char **argv) if (config.haveregex) { #ifdef HAVE_LIBPCRE - if (config.perl) + if (config.regextype == REGEX_PERL) pcre_init (); else #endif /* HAVE_LIBPCRE */ @@ -125,7 +114,7 @@ main (int argc, char **argv) while (optind < argc) { - if (config.action == DELETE) + if (config.action == ACTION_DELETE) { tmpmbox_create (argv[optind]); runtime.tmp_mbox = (mbox_t *) mbox_open (config.tmpfilename, "w"); @@ -140,7 +129,7 @@ main (int argc, char **argv) havemailbox = 1; - if (config.action == COUNT) + if (config.action == ACTION_COUNT) { if (singlefile) fprintf (stdout, "%i\n", runtime.count); @@ -152,19 +141,20 @@ main (int argc, char **argv) fprintf (stdout, "%s:%i\n", argv[optind], runtime.count); } } - if (config.action == DELETE) + if (config.action == ACTION_DELETE) { mbox_close (runtime.tmp_mbox); rename (config.tmpfilename, argv[optind]); } + ++optind; } if (!havemailbox) { - config.format = MBOX; + config.format = FORMAT_MBOX; scan_mailbox ("-"); - if (config.action == COUNT) + if (config.action == ACTION_COUNT) fprintf (stdout, "%i\n", runtime.count); } diff --git a/src/mbox.c b/src/mbox.c index 6329d68..9151c05 100644 --- a/src/mbox.c +++ b/src/mbox.c @@ -1,6 +1,6 @@ /* mboxgrep - scan mailbox for messages matching a regular expression - Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 Daniel Spiljar + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2023 Daniel Spiljar Mboxgrep is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -89,7 +89,7 @@ mbox_open (const char *path, const char *mode) return NULL; } - if (config.lock) + if (config.lock > LOCK_NONE) { #ifdef HAVE_FLOCK int op; @@ -123,27 +123,27 @@ mbox_open (const char *path, const char *mode) if (mode[0] == 'r') { - if (config.format == MBOX) + if (config.format == FORMAT_MBOX) mp->fp = (FILE *) m_fdopen (fd, "r"); #ifdef HAVE_LIBZ - else if (config.format == ZMBOX) + else if (config.format == FORMAT_ZMBOX) mp->fp = (gzFile *) m_gzdopen (fd, "rb"); #endif /* HAVE_LIBZ */ #ifdef HAVE_LIBBZ2 - else if (config.format == BZ2MBOX) + else if (config.format == FORMAT_BZ2MBOX) mp->fp = (BZFILE *) BZ2_bzdopen (fd, "rb"); #endif /* HAVE_LIBBZ2 */ } else if (mode[0] == 'w') { - if (config.format == MBOX) + if (config.format == FORMAT_MBOX) mp->fp = (FILE *) m_fdopen (fd, "w"); #ifdef HAVE_LIBZ - else if (config.format == ZMBOX) + else if (config.format == FORMAT_ZMBOX) mp->fp = (gzFile *) m_gzdopen (fd, "wb"); #endif /* HAVE_LIBZ */ #ifdef HAVE_LIBBZ2 - else if (config.format == BZ2MBOX) + else if (config.format == FORMAT_BZ2MBOX) mp->fp = (BZFILE *) BZ2_bzdopen (fd, "wb"); #endif /* HAVE_LIBBZ2 */ } @@ -163,14 +163,14 @@ mbox_open (const char *path, const char *mode) if (mode[0] == 'r') { - if (config.format == MBOX) + if (config.format == FORMAT_MBOX) fgets (buffer, BUFSIZ, mp->fp); #ifdef HAVE_LIBZ - else if (config.format == ZMBOX) + else if (config.format == FORMAT_ZMBOX) gzgets (mp->fp, buffer, BUFSIZ); #endif /* HAVE_LIBZ */ #ifdef HAVE_LIBBZ2 - else if (config.format == BZ2MBOX) + else if (config.format == FORMAT_BZ2MBOX) { char c[1] = "\0"; int n = 0; @@ -196,14 +196,14 @@ mbox_open (const char *path, const char *mode) fprintf (stderr, "%s: %s: Not a mbox folder\n", APPNAME, path); } - if (config.format == MBOX) + if (config.format == FORMAT_MBOX) fclose (mp->fp); #ifdef HAVE_LIBZ - else if (config.format == ZMBOX) + else if (config.format == FORMAT_ZMBOX) gzclose (mp->fp); #endif /* HAVE_LIBZ */ #ifdef HAVE_LIBBZ2 - else if (config.format == BZ2MBOX) + else if (config.format == FORMAT_BZ2MBOX) BZ2_bzclose (mp->fp); #endif /* HAVE_LIBBZ2 */ return NULL; @@ -216,14 +216,14 @@ mbox_open (const char *path, const char *mode) void mbox_close (mbox_t * mp) { - if (config.format == MBOX) + if (config.format == FORMAT_MBOX) fclose (mp->fp); #ifdef HAVE_LIBZ - else if (config.format == ZMBOX) + else if (config.format == FORMAT_ZMBOX) gzclose (mp->fp); #endif /* HAVE_LIBZ */ #ifdef HAVE_LIBBZ2 - else if (config.format == BZ2MBOX) + else if (config.format == FORMAT_BZ2MBOX) BZ2_bzclose (mp->fp); #endif /* HAVE_LIBBZ2 */ @@ -249,7 +249,7 @@ mbox_read_message (mbox_t * mp) for (;;) { - if (config.format == MBOX) + if (config.format == FORMAT_MBOX) { if (fgets (buffer, BUFSIZ, mp->fp) == NULL) { @@ -261,7 +261,7 @@ mbox_read_message (mbox_t * mp) } #ifdef HAVE_LIBZ - else if (config.format == ZMBOX) + else if (config.format == FORMAT_ZMBOX) { if (gzgets (mp->fp, buffer, BUFSIZ) == NULL) { @@ -274,7 +274,7 @@ mbox_read_message (mbox_t * mp) #endif /* HAVE_LIBZ */ #ifdef HAVE_LIBBZ2 - else if (config.format == BZ2MBOX) + else if (config.format == FORMAT_BZ2MBOX) { char c[1] = "\0"; int n = 0; @@ -370,10 +370,10 @@ tmpfile_name (const char *path) void mbox_write_message (message_t * msg, mbox_t * mbox) { - if (config.format == MBOX) + if (config.format == FORMAT_MBOX) fprintf (mbox->fp, "%s\n%s", msg->headers, msg->body); #ifdef HAVE_LIBZ - else if (config.format == ZMBOX) + else if (config.format == FORMAT_ZMBOX) { gzwrite_loop (mbox->fp, msg->headers); gzwrite (mbox->fp, "\n", 1); @@ -381,7 +381,7 @@ mbox_write_message (message_t * msg, mbox_t * mbox) } #endif /* HAVE_LIBZ */ #ifdef HAVE_LIBBZ2 - else if (config.format == BZ2MBOX) + else if (config.format == FORMAT_BZ2MBOX) { bzwrite_loop (mbox->fp, msg->headers); BZ2_bzwrite (mbox->fp, "\n", 1); diff --git a/src/mboxgrep.h b/src/mboxgrep.h index 171dfcf..f06b95c 100644 --- a/src/mboxgrep.h +++ b/src/mboxgrep.h @@ -46,34 +46,46 @@ typedef enum { - MBOX, - ZMBOX, - MH, - NNML, - NNMH, - MAILDIR, - BZ2MBOX + FORMAT_UNDEF, + FORMAT_MBOX, + FORMAT_ZMBOX, + FORMAT_MH, + FORMAT_NNML, + FORMAT_NNMH, + FORMAT_MAILDIR, + FORMAT_BZ2MBOX } format_t; typedef enum { - NONE, - FCNTL, - FLOCK + LOCK_UNDEF, + LOCK_NONE, + LOCK_FCNTL, + LOCK_FLOCK } lockmethod_t; typedef enum { - DISPLAY, - WRITE, - COUNT, - DELETE, - PIPE + ACTION_UNDEF, + ACTION_DISPLAY, + ACTION_WRITE, + ACTION_COUNT, + ACTION_DELETE, + ACTION_PIPE } action_t; +typedef enum + { + REGEX_UNDEF, + REGEX_BASIC, + REGEX_EXTENDED, + REGEX_PERL + } +regextype_t; + typedef struct { FILE *fp; @@ -93,9 +105,6 @@ checksum_t; typedef struct { - int extended; - int perl; - int body; int headers; int dedup; @@ -117,6 +126,7 @@ typedef struct action_t action; format_t format; lockmethod_t lock; + regextype_t regextype; } option_t; diff --git a/src/mh.c b/src/mh.c index 684d175..7947f6b 100644 --- a/src/mh.c +++ b/src/mh.c @@ -1,6 +1,6 @@ /* -*- C -*- mboxgrep - scan mailbox for messages matching a regular expression - Copyright (C) 2000, 2001, 2002, 2003, 2006 Daniel Spiljar + Copyright (C) 2000, 2001, 2002, 2003, 2006, 2023 Daniel Spiljar Mboxgrep is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -129,7 +129,7 @@ mh_read_message (DIR * dp) fgets (buffer, BUFSIZ, fp); -/* if (config.format == NNML || config.format == NNMH) */ +/* if (config.format == FORMAT_NNML || config.format == FORMAT_NNMH) */ /* { */ /* if (0 != strncmp ("X-From-Line: ", buffer, 13)) */ /* { */ diff --git a/src/misc.c b/src/misc.c index f08d34a..7a6973b 100644 --- a/src/misc.c +++ b/src/misc.c @@ -28,62 +28,76 @@ #include #include #include +#include #include "mboxgrep.h" +#include "misc.h" #include "wrap.h" #include "getopt.h" #include "info.h" #include "message.h" -format_t -folder_format (const char *name) +/* Determine the folder format passed to -m. */ + +void +set_folder_format (const char *name) { - format_t f; + if (config.format > 0) + { + if (config.merr) + fprintf (stderr, "%s: multiple mailbox types specified\n", APPNAME); + exit (2); + } if (0 == strncasecmp (name, "mbox", 4)) - f = MBOX; + config.format = FORMAT_MBOX; else if (0 == strncasecmp (name, "zmbox", 5)) - f = ZMBOX; + config.format = FORMAT_ZMBOX; else if (0 == strncasecmp (name, "gzmbox", 6)) - f = ZMBOX; + config.format = FORMAT_ZMBOX; else if (0 == strncasecmp (name, "bzmbox", 5)) - f = BZ2MBOX; + config.format = FORMAT_BZ2MBOX; else if (0 == strncasecmp (name, "bz2mbox", 5)) - f = BZ2MBOX; + config.format = FORMAT_BZ2MBOX; else if (0 == strncasecmp (name, "mh", 2)) - f = MH; + config.format = FORMAT_MH; else if (0 == strncasecmp (name, "nnml", 4)) - f = NNML; + config.format = FORMAT_NNML; else if (0 == strncasecmp (name, "nnmh", 4)) - f = NNMH; + config.format = FORMAT_NNMH; else if (0 == strncasecmp (name, "maildir", 7)) - f = MAILDIR; + config.format = FORMAT_MAILDIR; else { if (config.merr) fprintf (stderr, "%s: %s: unknown folder type\n", APPNAME, name); exit (2); } - - return f; } -lockmethod_t -lock_method (const char *name) +/* Determine the file locking method passed to -l. */ + +void +set_lock_method (const char *name) { - lockmethod_t l; + if (config.lock > 0) + { + if (config.merr) + fprintf (stderr, "%s: conflicting file locking options specified\n", APPNAME); + exit (2); + } if (0 == strncasecmp (name, "none", 4)) - l = NONE; + config.lock = LOCK_NONE; else if (0 == strncasecmp (name, "off", 3)) - l = NONE; + config.lock = LOCK_NONE; #ifdef HAVE_FCNTL else if (0 == strncasecmp (name, "fcntl", 5)) - l = FCNTL; + config.lock = LOCK_FCNTL; #endif /* HAVE_FCNTL */ #ifdef HAVE_FLOCK else if (0 == strncasecmp (name, "flock", 5)) - l = FLOCK; + config.lock = LOCK_FLOCK; #endif /* HAVE_FLOCK */ else { @@ -91,10 +105,10 @@ lock_method (const char *name) fprintf (stderr, "mboxgrep: %s: unknown file locking method\n", name); exit (2); } - - return l; } +/* Dead code */ + /* time_t parse_date(char *datestr) { @@ -170,26 +184,29 @@ postmark_print (message_t * msg) fprintf (stdout, "From nobody %s\n", date_str); } +/* Initialize the option_t struct. */ + void -set_default_options (void) +init_options (void) { - config.perl = 0; - config.extended = 1; + config.regextype = REGEX_UNDEF; config.invert = 0; config.headers = 0; config.body = 0; - config.action = DISPLAY; + config.action = ACTION_UNDEF; config.dedup = 0; config.recursive = 0; config.ignorecase = 0; - config.format = MBOX; /* default mailbox format */ - config.lock = FCNTL; /* default file locking method */ + config.format = FORMAT_UNDEF; + config.lock = LOCK_UNDEF; /* default file locking method */ config.merr = 1; /* report errors by default */ config.debug = 0; } +/* Parse command-line arguments and assign values to option_t. */ + void -get_runtime_options (int *argc, char **argv, struct option *long_options) +get_options (int *argc, char **argv, struct option *long_options) { int option_index = 0, c; @@ -206,35 +223,26 @@ get_runtime_options (int *argc, char **argv, struct option *long_options) case '?': usage (); case 'c': - config.action = COUNT; + set_option_action (ACTION_COUNT, NULL); break; case 'd': - config.action = DELETE; + set_option_action (ACTION_DELETE, NULL); break; case 'e': config.regex_s = xstrdup (optarg); config.haveregex = 1; break; case 'o': - config.outboxname = xstrdup (optarg); - config.action = WRITE; + set_option_action (ACTION_WRITE, optarg); break; case 'E': - config.extended = 1; + set_option_regextype (REGEX_EXTENDED); break; case 'G': - config.extended = 0; + set_option_regextype (REGEX_BASIC); break; case 'P': -#ifdef HAVE_LIBPCRE - config.extended = 0; - config.perl = 1; -#else - fprintf (stderr, - "%s: Support for Perl regular expressions not " - "compiled in\n", APPNAME); - exit (2); -#endif /* HAVE_LIBPCRE */ + set_option_regextype (REGEX_PERL); break; case 'h': help (); @@ -243,14 +251,13 @@ get_runtime_options (int *argc, char **argv, struct option *long_options) config.ignorecase = 1; break; case 'm': - config.format = folder_format (optarg); + set_folder_format (optarg); break; case 'l': - config.lock = lock_method (optarg); + set_lock_method (optarg); break; case 'p': - config.action = PIPE; - config.pipecmd = xstrdup (optarg); + set_option_action (ACTION_PIPE, optarg); break; case 'V': version (); @@ -289,7 +296,7 @@ get_runtime_options (int *argc, char **argv, struct option *long_options) config.dedup = 1; break; case 'l': - config.lock = 0; + set_lock_method ("none"); break; default: fprintf (stderr, "%s: invalid option -- n%c\n", @@ -300,3 +307,82 @@ get_runtime_options (int *argc, char **argv, struct option *long_options) } /* switch */ } /* while */ } + +/* Check the state of command-line options after parsing them. + * Raise error on conflicting options and set uninitialized ones to default values. + */ + +void +check_options (void) +{ + gethostname (config.hostname, HOST_NAME_SIZE); + config.pid = (int) getpid (); + + if (config.action == ACTION_UNDEF) + { + config.action = ACTION_DISPLAY; + } + + if (config.format == FORMAT_UNDEF) + { + config.format = FORMAT_MBOX; /* default mailbox format */ + } + + if (config.regextype == REGEX_UNDEF) + { + config.regextype = REGEX_EXTENDED; /* default regex type */ + } + + if ((config.body == 0) && (config.headers == 0)) + { + config.body = 1; + config.headers = 1; + } +} + +void +set_option_action (action_t action, char *path) +{ + if (config.action > 0) + { + if (config.merr) + fprintf (stderr, "%s: conflicting actions specified\n", APPNAME); + exit (2); + } + + config.action = action; + + if (action == ACTION_WRITE) + { + config.outboxname = xstrdup (path); + } + + if (action == ACTION_PIPE) + { + config.pipecmd = xstrdup (optarg); + } +} + +void +set_option_regextype (regextype_t regextype) +{ + if (config.regextype > 0) + { + if (config.merr) + fprintf (stderr, "%s: conflicting matchers specified\n", APPNAME); + exit (2); + } + +#ifndef HAVE_LIBPCRE + if (regextype == REGEX_PERL); + { + fprintf (stderr, + "%s: Support for Perl regular expressions not compiled in\n", + APPNAME); + exit (2); + } + } +#endif /* HAVE_LIBPCRE */ + + config.regextype = regextype; +} diff --git a/src/misc.h b/src/misc.h index 4e91970..0aec8c2 100644 --- a/src/misc.h +++ b/src/misc.h @@ -25,14 +25,17 @@ # include "message.h" /* #include */ -format_t folder_format (const char *name); -lockmethod_t lock_method (const char *name); +void set_folder_format (const char *name); +void set_lock_method (const char *name); /* time_t parse_date(char *datestr); */ char *parse_return_path (char *rpath); void *allocate_message (void); void postmark_print (message_t * msg); -void set_default_options (void); -void get_runtime_options (int *argc, char **argv, +void init_options (void); +void get_options (int *argc, char **argv, struct option *long_options); +void check_options (void); +void set_option_action (action_t action, char *path); +void set_option_regextype (regextype_t regextype); #endif /* MISC_H */ diff --git a/src/re.c b/src/re.c index 54d03db..77696cb 100644 --- a/src/re.c +++ b/src/re.c @@ -77,7 +77,7 @@ regex_init (void) if (config.ignorecase) flag1 = REG_ICASE; - if (config.extended) + if (config.regextype == REGEX_EXTENDED) flag2 = REG_EXTENDED; config.posix_pattern = (regex_t *) xmalloc (sizeof (regex_t)); diff --git a/src/scan.c b/src/scan.c index bdfe6ba..ef04a2f 100644 --- a/src/scan.c +++ b/src/scan.c @@ -83,7 +83,7 @@ scan_mailbox (char path[]) int delete = 0; int isdup = 0; - if (config.format == MAILDIR && config.action == WRITE) + if (config.format == FORMAT_MAILDIR && config.action == ACTION_WRITE) { foo = opendir (config.outboxname); /* do NOT change this to m_opendir! */ if (foo == NULL && errno == ENOENT) @@ -101,24 +101,24 @@ scan_mailbox (char path[]) } runtime.count = 0; - if (config.action == DELETE) + if (config.action == ACTION_DELETE) delete = 1; - if ((config.format == MBOX) || (config.format == ZMBOX) - || (config.format == BZ2MBOX)) + if ((config.format == FORMAT_MBOX) || (config.format == FORMAT_ZMBOX) + || (config.format == FORMAT_BZ2MBOX)) { mbox = (mbox_t *) mbox_open (path, "r"); if (mbox == NULL) return; } - else if ((config.format == MH) || (config.format == NNMH) - || (config.format == NNML)) + else if ((config.format == FORMAT_MH) || (config.format == FORMAT_NNMH) + || (config.format == FORMAT_NNML)) { boxd = mh_open (path); if (boxd == NULL) return; } - else if (config.format == MAILDIR) + else if (config.format == FORMAT_MAILDIR) { maildird = maildir_open (path); @@ -131,13 +131,13 @@ scan_mailbox (char path[]) config.res1 = 1; config.res2 = 1; - if ((config.format == MBOX) || (config.format == ZMBOX) - || (config.format == BZ2MBOX)) + if ((config.format == FORMAT_MBOX) || (config.format == FORMAT_ZMBOX) + || (config.format == FORMAT_BZ2MBOX)) msg = (message_t *) mbox_read_message (mbox); - else if ((config.format == MH) || (config.format == NNMH) - || (config.format == NNML)) + else if ((config.format == FORMAT_MH) || (config.format == FORMAT_NNMH) + || (config.format == FORMAT_NNML)) msg = (message_t *) mh_read_message (boxd); - else if (config.format == MAILDIR) + else if (config.format == FORMAT_MAILDIR) msg = (message_t *) maildir_read_message (maildird); if (msg == NULL) @@ -147,7 +147,7 @@ scan_mailbox (char path[]) msg->from = (char *) xstrdup ("nobody"); #ifdef HAVE_LIBPCRE - if (config.perl) + if (config.regextype == REGEX_PERL) pcre_match (msg); else #endif /* HAVE_LIBPCRE */ @@ -160,24 +160,24 @@ scan_mailbox (char path[]) ((config.invert ^ delete)) && ((config.dedup && !isdup) || !config.dedup)) { - if (config.action == DISPLAY) + if (config.action == ACTION_DISPLAY) { - if (config.format != MBOX && config.format != ZMBOX - && config.format != BZ2MBOX + if (config.format != FORMAT_MBOX && config.format != FORMAT_ZMBOX + && config.format != FORMAT_BZ2MBOX && 0 != strncmp ("From ", msg->headers, 5)) postmark_print (msg); fprintf (stdout, "%s\n%s", msg->headers, msg->body); } - else if (config.action == WRITE) + else if (config.action == ACTION_WRITE) { - if (config.format == MAILDIR) + if (config.format == FORMAT_MAILDIR) maildir_write_message (msg, config.outboxname); - else if (config.format == MH || config.format == NNMH - || config.format == NNML) + else if (config.format == FORMAT_MH || config.format == FORMAT_NNMH + || config.format == FORMAT_NNML) mh_write_message (msg, config.outboxname); - else if ((config.format == MBOX) || (config.format == ZMBOX) - || (config.format == BZ2MBOX)) + else if ((config.format == FORMAT_MBOX) || (config.format == FORMAT_ZMBOX) + || (config.format == FORMAT_BZ2MBOX)) { out = mbox_open (config.outboxname, "w"); /* fprintf (out->fp, "%s\n%s", msg->headers, msg->body); */ @@ -185,7 +185,7 @@ scan_mailbox (char path[]) mbox_close (out); } } - else if (config.action == PIPE) + else if (config.action == ACTION_PIPE) { outf = popen (config.pipecmd, "w"); if (outf == NULL) @@ -200,19 +200,19 @@ scan_mailbox (char path[]) fprintf (outf, "%s\n%s", msg->headers, msg->body); pclose (outf); } - else if (config.action == COUNT) + else if (config.action == ACTION_COUNT) runtime.count++; - else if (config.action == DELETE && - ((config.format == MBOX) || (config.format == ZMBOX) - || (config.format == BZ2MBOX))) + else if (config.action == ACTION_DELETE && + ((config.format == FORMAT_MBOX) || (config.format == FORMAT_ZMBOX) + || (config.format == FORMAT_BZ2MBOX))) mbox_write_message (msg, runtime.tmp_mbox); } else if (((((config.res1 == 0) | (config.res2 == 0)) ^ config.invert) - && delete) && ((config.format == MH) || (config.format == NNMH) - || (config.format == NNML) - || (config.format == MAILDIR))) + && delete) && ((config.format == FORMAT_MH) || (config.format == FORMAT_NNMH) + || (config.format == FORMAT_NNML) + || (config.format == FORMAT_MAILDIR))) m_unlink (msg->filename); free (msg->body); @@ -220,11 +220,11 @@ scan_mailbox (char path[]) free (msg); } /* for */ - if ((config.format == MBOX) || (config.format == ZMBOX) - || (config.format == BZ2MBOX)) + if ((config.format == FORMAT_MBOX) || (config.format == FORMAT_ZMBOX) + || (config.format == FORMAT_BZ2MBOX)) mbox_close (mbox); - else if ((config.format == MH) || (config.format == NNMH) - || (config.format == NNML)) + else if ((config.format == FORMAT_MH) || (config.format == FORMAT_NNMH) + || (config.format == FORMAT_NNML)) mh_close (boxd); }