/ChangeLog
/Makefile.in
/aclocal.m4
+/ar-lib
/compile
/config.guess
/config.h.in
/sbr/dtimep.c
/cscope.files
/cscope.out
+/cscope.in.out
+/cscope.po.out
# Removed by distclean:
.deps/
gnutls-devel
libgnutls26
+When running the nmh test suite ("make check"), it helps to have
+/usr/bin/ ahead of any Windows directories on your PATH.
+
Note that the -link switch to refile cannot be used on FAT32 and
similar filesystems.
test/repl/test-multicomp test/repl/test-repl \
test/scan/test-scan test/scan/test-scan-multibyte \
test/sequences/test-flist test/sequences/test-mark \
+ test/sequences/test-out-of-range \
test/slocal/test-slocal \
test/whatnow/test-attach-detach test/whatnow/test-cd \
test/whatnow/test-ls test/whom/test-whom \
##
## Stuff that should be cleaned via "make maintainer-clean"
##
-MAINTAINERCLEANFILES = cscope.files cscope.out
+MAINTAINERCLEANFILES = cscope.files cscope.out cscope.in.out cscope.po.out
##
## And our own superclean, to get everything left by maintainer-clean.
man/sendfiles.1 man/show.1 man/slocal.1 man/sortm.1 man/unseen.1 \
man/whatnow.1 man/whom.1
+##
+## Sources for our man pages
+##
+man_SRCS = man/ali.man man/anno.man man/ap.man man/burst.man man/comp.man \
+ man/conflict.man man/dist.man man/dp.man man/flist.man \
+ man/flists.man man/fmtdump.man man/fnext.man man/folder.man \
+ man/folders.man man/forw.man man/fprev.man man/inc.man \
+ man/install-mh.man man/mark.man man/mh-alias.man \
+ man/mh-chart-gen.sh man/mh-draft.man man/mh-format.man \
+ man/mh-mail.man man/mh-profile.man man/mh_profile.man \
+ man/mh-sequence.man man/mh-tailor.man man/mhbuild.man man/mhl.man \
+ man/mhlist.man man/mhmail.man man/mhn.man man/mhparam.man \
+ man/mhpath.man man/mhshow.man man/mhstore.man man/msgchk.man \
+ man/msh.man man/mts.conf.man man/new.man man/next.man man/nmh.man \
+ man/packf.man man/pick.man man/post.man man/prev.man \
+ man/prompter.man man/rcvdist.man man/rcvpack.man \
+ man/rcvstore.man man/rcvtty.man man/refile.man man/repl.man \
+ man/rmf.man man/rmm.man man/scan.man man/send.man \
+ man/sendfiles.man man/show.man man/slocal.man man/sortm.man \
+ man/unseen.man man/whatnow.man man/whom.man
+
##
## Files we need to include in the distribution which aren't found by
## Automake using the automatic rules
etc/mhn.defaults.sh etc/sendfiles $(MHNSEARCHPROG) DATE MACHINES \
docs/ChangeLog_MH-3_to_MH-6.6 \
docs/ChangeLog_MH-6.7.0_to_MH-6.8.4.html \
- man/ali.man man/anno.man man/ap.man man/burst.man man/comp.man \
- man/conflict.man man/dist.man man/dp.man man/flist.man \
- man/flists.man man/fmtdump.man man/fnext.man man/folder.man \
- man/folders.man man/forw.man man/fprev.man man/inc.man \
- man/install-mh.man man/mark.man man/mh-alias.man \
- man/mh-chart-gen.sh man/mh-draft.man man/mh-format.man \
- man/mh-mail.man man/mh-profile.man man/mh_profile.man \
- man/mh-sequence.man man/mh-tailor.man man/mhbuild.man man/mhl.man \
- man/mhlist.man man/mhmail.man man/mhn.man man/mhparam.man \
- man/mhpath.man man/mhshow.man man/mhstore.man man/msgchk.man \
- man/msh.man man/mts.conf.man man/new.man man/next.man man/nmh.man \
- man/packf.man man/pick.man man/post.man man/prev.man \
- man/prompter.man man/rcvdist.man man/rcvpack.man \
- man/rcvstore.man man/rcvtty.man man/refile.man man/repl.man \
- man/rmf.man man/rmm.man man/scan.man man/send.man \
- man/sendfiles.man man/show.man man/slocal.man man/sortm.man \
- man/unseen.man man/whatnow.man man/whom.man \
test/README test/fakesendmail $(TESTS) test/inc/deb359167.mbox \
test/inc/fromline.txt test/inc/msgheader.txt test/inc/filler.txt \
test/inc/md5sums test/mhmail/attachment.txt \
test/post/test-post-common.sh uip/mhmail \
- SPECS/nmh.spec SPECS/build-nmh-cygwin
+ SPECS/nmh.spec SPECS/build-nmh-cygwin $(man_SRCS)
##
## These are all of the definitions for each of the programs listed above.
uip_mhtest_LDADD = $(LDADD) $(TERMLIB)
uip_post_SOURCES = uip/post.c uip/aliasbr.c
-uip_post_LDADD = mts/libmts.a $(LDADD) $(SASLLIB)
+uip_post_LDADD = mts/libmts.a $(LDADD) $(SASLLIB) $(TLSLIB)
uip_rcvdist_SOURCES = uip/rcvdist.c uip/distsbr.c
uip_rcvdist_LDADD = $(LDADD) $(ICONVLIB)
##
## Our rules to build our internal libraries (libmh.a, libmts.a)
##
-sbr_libmh_a_SOURCES = sbr/addrsbr.c sbr/ambigsw.c sbr/atooi.c sbr/base64.c \
+sbr_libmh_a_SOURCES = sbr/addrsbr.c sbr/ambigsw.c sbr/atooi.c sbr/arglist.c \
+ sbr/base64.c \
sbr/brkstring.c sbr/check_charset.c sbr/client.c \
sbr/closefds.c sbr/concat.c sbr/context_del.c \
sbr/context_find.c sbr/context_foil.c sbr/context_read.c \
sbr/folder_free.c sbr/folder_pack.c \
sbr/folder_read.c sbr/folder_realloc.c sbr/gans.c \
sbr/getans.c sbr/getanswer.c sbr/getarguments.c \
- sbr/getcpy.c sbr/getfolder.c sbr/getpass.c \
+ sbr/getcpy.c sbr/geteditor.c sbr/getfolder.c \
+ sbr/getpass.c \
sbr/fmt_addr.c sbr/fmt_compile.c sbr/fmt_new.c \
sbr/fmt_rfc2047.c sbr/fmt_scan.c sbr/lock_file.c \
sbr/m_atoi.c sbr/m_backup.c sbr/m_convert.c \
sbr_libmh_a_CPPFLAGS = -I./sbr -DNMHETCDIR='"$(sysconfdir)"' \
-DMAILSPOOL='"$(mailspool)"' \
-DSENDMAILPATH='"$(sendmailpath)"' -DNMHBINDIR='"$(bindir)"' \
- -DNMHLIBDIR='"$(libdir)"' \
- -DDEFAULT_EDITOR='"$(editorpath)"' \
- -DDEFAULT_PAGER='"$(pagerpath)"'
+ -DNMHLIBDIR='"$(libdir)"'
sbr_libdtimep_a_SOURCES = sbr/dtimep.l
sbr_libdtimep_a_CFLAGS = $(sbr_libmh_a_CPPFLAGS) \
@echo 's,%mandir%,$(mandir),g' >> $@
@echo 's,%mailspool%,$(mailspool),g' >> $@
@echo 's,%sendmailpath%,$(sendmailpath),g' >> $@
- @echo 's,%default_editor%,$(editorpath),g' >> $@
- @echo 's,%default_pager%,$(pagerpath),g' >> $@
@echo 's,%manext1%,$(manext1),g' >> $@
@echo 's,%manext5%,$(manext5),g' >> $@
@echo 's,%manext7%,$(manext7),g' >> $@
@echo '/%mhl_reply%/r $(top_srcdir)/etc/mhl.reply' >> $@
@echo ' s,%mhl_reply%,,g' >> $@
-man/mh-chart.man:
+man/mh-chart.man: $(man_SRCS)
$(srcdir)/man/mh-chart-gen.sh > $@
.man.$(manext1):
-ba SPECS/nmh.spec
.PHONY: rpm
-##
-## A target to build information needed by cscope
-##
-cscope:
- echo "-I $(srcdir)/h -I $(srcdir)/sbr -I $(srcdir)/uip -I $(srcdir)/mts/smtp" > cscope.files
- find $(srcdir) \( -name docs -prune \) -o \( -name \*.c -o -name \*.l \) -print | grep -v dtimep.c >> cscope.files
-.PHONY: cscope
-
##
## Use GNU gcov to find the coverage of the test suite.
*/
struct swit anoyes[] = {
- { "no", 0 },
- { "yes", 0 },
- { NULL, 0 }
+ { "no", 0, 0 },
+ { "yes", 0, 1 },
+ { NULL, 0, 0 }
};
/*
char *whomproc = nmhbindir (/whom);
-/*
- * This is the editor invoked by the various message
- * composition programs. It SHOULD be a full screen
- * editor, such as vi or emacs, but any editor will work.
- */
-
-char *defaulteditor = DEFAULT_EDITOR;
-
/*
* This is the global nmh alias file. It is somewhat obsolete, since
* global aliases should be handled by the Mail Transport Agent (MTA).
dnl
dnl Move this up a bit
-AC_PREREQ([2.61])
+AC_PREREQ([2.68])
AC_INIT([nmh], m4_normalize(m4_include([VERSION])), [nmh-workers@nongnu.org])
AC_CONFIG_SRCDIR([h/nmh.h])
AC_CONFIG_HEADER([config.h])
-AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
+AM_INIT_AUTOMAKE([-Wall foreign serial-tests subdir-objects 1.12])
AC_CANONICAL_HOST
dnl Do you want to debug nmh?
AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug],[enable nmh code debugging]))
-dnl The old redundant --enable-nmh-debug is deprecated and undocumented.
-AS_IF([test x"$enable_nmh_debug" = x"yes"], [enable_debug=yes])
dnl Do you want to disable use of locale functions
AH_TEMPLATE([LOCALE],
AC_DEFINE([TLS_SUPPORT], [1], [Support TLS for session encryption.])dnl
tls_support=yes],[tls_support=no])
-dnl What should be the default editor?
-AC_ARG_WITH([editor],
- AS_HELP_STRING([--with-editor=EDITOR],[specify the default editor]))
-
-AS_IF([test -n "$with_editor"], [editorpath="$with_editor"])
-
dnl Set the backup prefix
AC_ARG_WITH([hash-backup],
AS_HELP_STRING([--with-hash-backup],[use # as the backup prefix (default: ,)]))
[freebsd*|openbsd*|darwin*], [default_locktype="flock"; default_locking=FLOCK_LOCKING],
[default_locktype="dot"; default_locking=DOT_LOCKING])
-AC_ARG_WITH(locking,
+AC_ARG_WITH([locking],
AS_HELP_STRING([--with-locking=@<:@dot|fcntl|flock|lockf@:>@],
[specify the file locking method]))
-if test x"$with_locking" = x"dot"; then
- LOCKTYPE="dot"
- AC_DEFINE(DOT_LOCKING, 1, [Define to use dot based file locking.])dnl
-elif test x"$with_locking" = x"flock"; then
- LOCKTYPE="flock"
- AC_DEFINE(FLOCK_LOCKING, 1, [Define to use flock() based locking.])dnl
-elif test x"$with_locking" = x"lockf"; then
- LOCKTYPE="lockf"
- AC_DEFINE(LOCKF_LOCKING, 1, [Define to use lockf() based locking.])dnl
-elif test x"$with_locking" = x"fcntl"; then
- LOCKTYPE="fcntl"
- AC_DEFINE(FCNTL_LOCKING, 1, [Define to use fnctl() based locking.])dnl
-else
- LOCKTYPE="$default_locktype"
- AC_DEFINE_UNQUOTED($default_locking, 1)dnl
-fi
+AS_IF([test x"$with_locking" = x"dot"],
+ [LOCKTYPE="dot"
+ AC_DEFINE([DOT_LOCKING], [1], [Define to use dot based file locking.])],
+ [test x"$with_locking" = x"flock"],
+ [LOCKTYPE="flock"
+ AC_DEFINE([FLOCK_LOCKING], [1], [Define to use flock() based locking.])],
+ [test x"$with_locking" = x"lockf"],
+ [LOCKTYPE="lockf"
+ AC_DEFINE([LOCKF_LOCKING], [1], [Define to use lockf() based locking.])],
+ [test x"$with_locking" = x"fcntl"],
+ [LOCKTYPE="fcntl"
+ AC_DEFINE([FCNTL_LOCKING], [1], [Define to use fnctl() based locking.])],
+ [LOCKTYPE="$default_locktype"
+ AC_DEFINE_UNQUOTED([$default_locking], [1])])
dnl Should we use a locking directory?
AC_ARG_ENABLE([lockdir],
[MTS="smtp"])
AC_SUBST([MTS])dnl
-dnl What should be the default pager?
-AC_ARG_WITH([pager],
- AS_HELP_STRING([--with-pager=PAGER],[specify the default pager]))
-
-AS_IF([test -n "$with_pager"], [pagerpath="$with_pager"])
-
-dnl If a pager is not explicitly specified, then look for one.
-dnl Fall back to `cat', to avoid catastrophic failure of
-dnl `mhshow', et al., if pagerpath is set to `no'.
-if test -z "$pagerpath"; then
- pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
- AC_PATH_PROGS([pagerpath], [more less most cat], [no], [$pathtmp])
-fi
-AC_SUBST(pagerpath)dnl
-
dnl What should be the default mail server(s)?
-AC_ARG_WITH(smtpservers,
- AS_HELP_STRING([--with-smtpservers='SMTPSERVER1@<:@ SMTPSERVER2...@:>@'],
- [specify the default SMTP server(s) @<:@localhost@:>@]))
+AC_ARG_WITH([smtpservers],
+ [AS_HELP_STRING([--with-smtpservers='SMTPSERVER1@<:@ SMTPSERVER2...@:>@'],
+ [specify the default SMTP server(s) @<:@localhost@:>@])])
AS_IF([test -n "$with_smtpservers"], [smtpservers="$with_smtpservers"],
[smtpservers="localhost"])
AC_SUBST([smtpservers])dnl
|| CPPFLAGS="$CPPFLAGS -Wunused-macros"
DISABLE_UNUSED_MACROS_WARNING=-Wno-unused-macros
fi
-AC_SUBST(DISABLE_UNUSED_MACROS_WARNING)dnl
+AC_SUBST([DISABLE_UNUSED_MACROS_WARNING])dnl
AC_CACHE_CHECK([whether compiler supports -Wno-sign-compare],
[nmh_cv_has_nosigncompare],
if test "$nmh_cv_has_nosigncompare" = 'yes'; then
DISABLE_SIGN_COMPARE_WARNING=-Wno-sign-compare
fi
-AC_SUBST(DISABLE_SIGN_COMPARE_WARNING)dnl
+AC_SUBST([DISABLE_SIGN_COMPARE_WARNING])dnl
AC_CACHE_CHECK([whether compiler supports -Wextra], [nmh_cv_has_wextra],
[nmh_saved_cflags="$CFLAGS"
fi
fi
-AC_C_CONST dnl Does compiler support `const'.
-
dnl ------------------
dnl CHECK FOR PROGRAMS
dnl ------------------
AC_PROG_RANLIB dnl Check for `ranlib'
AC_PROG_AWK dnl Check for mawk,gawk,nawk, then awk
AC_PROG_SED dnl Check for Posix-compliant sed
-AC_PROG_LEX dnl Check for lex/flex
+AM_PROG_LEX dnl Check for lex/flex
+
+AM_PROG_AR
dnl Look for `cut'
pathtmp=/usr/bin:/bin:/usr/local/bin:/usr/xpg4/bin:/usr/ucb
dnl ----------------------------------------------
dnl check for lclint, and lint if it doesn't exist
dnl ----------------------------------------------
-AC_CHECK_PROG(linttmp1, lclint, lclint, no)dnl
-if test x$ac_cv_prog_linttmp1 != xno ; then
- LINT=$ac_cv_prog_linttmp1
- LINTFLAGS="-weak +posixlib -macrovarprefixexclude"
-else
- AC_CHECK_PROG(linttmp2, lint, lint, no)dnl
- if test x$ac_cv_prog_linttmp2 != xno ; then
- LINT=$ac_cv_prog_linttmp2
- LINTFLAGS=""
- else
- LINT="echo 'No lint program found'"
- LINTFLAGS=""
- fi
-fi
+AC_CHECK_PROG([linttmp1], [lclint], [lclint], [no])dnl
+AS_IF([test x$ac_cv_prog_linttmp1 != xno],
+ [LINT=$ac_cv_prog_linttmp1
+ LINTFLAGS="-weak +posixlib -macrovarprefixexclude"],
+ [AC_CHECK_PROG([linttmp2], [lint], [lint], [no])dnl
+ AS_IF([test x$ac_cv_prog_linttmp2 != xno],
+ [LINT=$ac_cv_prog_linttmp2
+ LINTFLAGS=""],
+ [LINT="echo 'No lint program found'"
+ LINTFLAGS=""])])
AC_SUBST([LINT])dnl
AC_SUBST([LINTFLAGS])dnl
AC_PATH_PROG([lspath], [ls], [no], [$pathtmp])
dnl See how we get ls to display the owner and the group
-if test "$lspath" != "no"; then
- AC_CACHE_CHECK([how to get ls to show us the group ownership of a file],
+AS_IF([test "$lspath" != "no"],
+ [AC_CACHE_CHECK([how to get ls to show us the group ownership of a file],
[nmh_cv_ls_grpopt],
- [if test x"`$lspath -dl / | $AWK '{print $9}'`" = x"/"; then
+ [AS_IF([test x"`$lspath -dl / | $AWK '{print $9}'`" = x"/"],[
dnl There were 9 parameters, so unless this is a really bizarre, nonstandard
dnl ls, it would seem -l gave us both the user and group. On this type of
dnl ls, -g makes _only_ the group be displayed (and not the user).
- nmh_cv_ls_grpopt="-l"
- else
+ nmh_cv_ls_grpopt="-l"],[
dnl Looks like -l only gave us the user, so we need -g to get the group too.
- nmh_cv_ls_grpopt="-lg"
- fi])
-fi
+ nmh_cv_ls_grpopt="-lg"])])])
dnl Look for `sendmail'
pathtmp=/usr/lib:/usr/sbin:/usr/etc:/usr/ucblib:/usr/bin:/bin
AC_PATH_PROG([sendmailpath], [sendmail], [/usr/sbin/sendmail], [$pathtmp])
-dnl Look for `vi'
-pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
-AC_PATH_PROG([vipath], [vi], [/bin/vi], [$pathtmp])
-
-dnl If editor is not specified yet,
-dnl then use `vi' as the default.
-AS_IF([test -z "$editorpath"], [editorpath="$vipath"])
-AC_SUBST([editorpath])dnl
-
dnl Cygwin FAT filesystems do not support hard links. So default to
dnl cp instead, even if running on an NTFS or other filesystem.
AS_CASE(["$host_os"],
dnl Provide a way for distcheck to disable setgid_mail via
dnl DISTCHECK_CONFIGURE_FLAGS.
-if test x"$DISABLE_SETGID_MAIL" != x -a x"$DISABLE_SETGID_MAIL" != x0; then
- nmh_cv_dotlockfile_setgid=yes
-fi
+AS_IF([test x"$DISABLE_SETGID_MAIL" != x -a x"$DISABLE_SETGID_MAIL" != x0],
+ [nmh_cv_dotlockfile_setgid=yes])
dnl If mailspool is not world-writable and dotlockfile is not setgid,
dnl we need to #define MAILGROUP to 1 and make inc setgid.
[Define to 1 if you need to make `inc' set-group-id because your mail spool is not world writable. There are no guarantees as to the safety of doing this, but this #define will add some extra security checks.])dnl
SETGID_MAIL=1
fi
-AC_SUBST(SETGID_MAIL)dnl
+AC_SUBST([SETGID_MAIL])dnl
dnl Use ls to see which group owns the mail spool directory.
AC_CACHE_CHECK(what group owns the mail spool, nmh_cv_ls_mail_grp,
AS_IF([test -z "$CPPFLAGS"],[CPPFLAGS="-D_GNU_SOURCE"],
[CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"])])
-AC_HEADER_STDC
AC_HEADER_TIOCGWINSZ
-AC_CHECK_HEADERS([errno.h fcntl.h crypt.h ncurses/termcap.h termcap.h \
- langinfo.h wchar.h wctype.h iconv.h netdb.h \
- sys/param.h sys/time.h sys/stream.h])
+AC_CHECK_HEADERS([fcntl.h ncurses/termcap.h termcap.h langinfo.h \
+ wchar.h wctype.h sys/param.h sys/time.h sys/stream.h])
dnl
dnl Checks for _IO_write_ptr. A Linuxism used by nmh on linux. We
dnl Checks for network libraries (nsl, socket)
NMH_CHECK_NETLIBS
+dnl Check for readline support
NMH_READLINE
+dnl Check for iconv
+NMH_CHECK_ICONV
+
termcap_curses_order="termcap curses ncurses"
for lib in $termcap_curses_order; do
AC_CHECK_LIB(${lib}, tgetent, [TERMLIB="-l$lib"; break])
[AC_MSG_FAILURE([Could not find tgetent in any library. Is there a curses
or ncurses library or package that you can install?])])
-
-dnl ---------------
-dnl CHECK FOR ICONV
-dnl ---------------
-
-dnl Find iconv. It may be in libiconv and may be iconv() or libiconv()
-if test "x$ac_cv_header_iconv_h" = "xyes"; then
- AC_CHECK_FUNC(iconv, ac_found_iconv=yes, ac_found_iconv=no)
- if test "x$ac_found_iconv" = "xno"; then
- AC_CHECK_LIB(iconv, iconv, ac_found_iconv=yes)
- if test "x$ac_found_iconv" = "xno"; then
- AC_CHECK_LIB(iconv, libiconv, ac_found_iconv=yes)
- fi
- if test "x$ac_found_iconv" != "xno"; then
- ICONVLIB="-liconv"
- fi
- else
- dnl Handle case where there is a native iconv but iconv.h is from libiconv
- AC_CHECK_DECL(_libiconv_version,
- [ AC_CHECK_LIB(iconv, libiconv, LIBS="-liconv $LIBS") ],,
- [ #include <iconv.h> ])
- fi
-fi
-if test "x$ac_found_iconv" = xyes; then
- AC_DEFINE([HAVE_ICONV], [1], [Define if you have the iconv() function.])
-fi
-AC_SUBST([ICONVLIB])
-
-dnl Check if iconv uses const in prototype declaration
-if test "x$ac_found_iconv" = "xyes"; then
- AC_CACHE_CHECK(for iconv declaration, ac_cv_iconv_const,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
- #include <iconv.h>]],
- [[#ifdef __cplusplus
- "C"
- #endif
- #if defined(__STDC__) || defined(__cplusplus)
- size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
- #else
- size_t iconv();
- #endif]])],
- [ac_cv_iconv_const=],
- [ac_cv_iconv_const=const])])
- AC_DEFINE_UNQUOTED([ICONV_CONST], $ac_cv_iconv_const,
- [Define as const if the declaration of iconv() needs const.])
-fi
-
dnl --------------
dnl CHECK FOR NDBM
dnl --------------
dnl nmhrpm is used in the final summary, see below. The default value is
dnl reported there as ./RPM, consistent with the reporting of the default
dnl source code location as ., but its absolute path is used in the Makefile.
-AC_ARG_WITH(rpmdir,
- AS_HELP_STRING([--with-rpmdir=RPMDIR], [RPM build directory @<:@RPM@:>@]))
+AC_ARG_WITH([rpmdir],
+ [AS_HELP_STRING([--with-rpmdir=RPMDIR], [RPM build directory @<:@RPM@:>@])])
AS_IF([test x"$with_rpmdir" = x], [rpmdir='$(abs_srcdir)/RPM'; nmhrpm=./RPM],
[rpmdir="$with_rpmdir"; eval "nmhrpm=${rpmdir}"])
AC_SUBST([rpmdir])
AS_IF([test x"$tls_support" = x"yes"],[
AC_CHECK_HEADER([openssl/ssl.h], , [AC_MSG_ERROR([openssl/ssl.h not found])])
- AC_CHECK_LIB([crypto], [BIO_write], ,
+ AC_CHECK_LIB([crypto], [BIO_write], [TLSLIB="-lcrypto"],
[AC_MSG_ERROR([OpenSSL crypto library not found])])
- AC_CHECK_LIB([ssl], [SSL_library_init], ,
- [AC_MSG_ERROR([OpenSSL library not found])])])
+ AC_CHECK_LIB([ssl], [SSL_library_init], [TLSLIB="-lssl $TLSLIB"],
+ [AC_MSG_ERROR([OpenSSL library not found])])],
+ [TLSLIB=])
+AC_SUBST([TLSLIB])
dnl ---------------------
dnl CHECK TERMCAP LIBRARY
dnl
AC_CONFIG_COMMANDS([build-directories],
-[test -d etc || ${MKDIR_P} etc
-test -d man || ${MKDIR_P} man])
+[test -d etc || AS_MKDIR_P([etc])
+test -d man || AS_MKDIR_P([man])])
AC_CONFIG_COMMANDS_POST([
file locking type : ${LOCKTYPE}
default smtp servers : ${smtpservers}
default editor : ${editorpath}
-default pager : ${pagerpath}
SASL support : ${sasl_support}
TLS support : ${tls_support}
])])dnl
compctl -K mhfseq -x 's[+][@]' -K mhcomp -S / -q - 's[-]' \
-k "(file part type list headers noheaders realsize norealsize nolist \
show serialonly noserialonly form pause nopause noshow store auto noauto \
- nostore cache nocache rcache wcache check nocheck ebcdicsafe noebcdicsafe \
+ nostore cache nocache rcache wcache check nocheck \
rfc934mode norfc934mode verbose noverbose help)" - \
'c[-1,-file]' -f - 'c[-1,-form]' -K mhfile - \
'C[-1,-[rw]cache]' -k '(public private never ask)' -- mhn
from <ftp://ftp.gnu.org/pub/gnu/m4/>, then GNU autoconf
(<ftp://ftp.gnu.org/pub/gnu/autoconf/>) and GNU automake
(<ftp://ftp.gnu.org/pub/gnu/automake/>). Nmh is currently using a
-minimum of autoconf 2.61 and automake 1.10.
+minimum of autoconf 2.68 and automake 1.12.
Most of the configure-related files are automatically generated.
The only files you should need to manually edit are configure.ac
# Configures and builds nmh.
# * This script must be invoked from an nmh source directory.
# * This script retrieves configuration from the first existing nmh
-# installation on your $PATH, if any, as well as any $EDITOR/$VISUAL
-# and $PAGER environment variable settings.
+# installation on your $PATH, if any.
# * Unless the -y option is provided, this script then interactively
# walks you through confirmation of common configuration settings.
#
####
#### OS-specific setup.
####
-which=which
ldd=ldd
####
config_smtpservers=localhost
config_sasl=n
config_tls=n
-config_editor=vi
-for i in more less most cat; do
- if which $i >/dev/null 2>&1; then
- config_pager=$i
- break
- fi
-done
config_debug=n
+
+#### Find location of a program. Bourne shell just puts the name in
+#### $0 if it's found from the PATH, so search that if necessary.
+finddir() {
+ case $1 in
+ */*) dirname "$1" ;;
+ * ) IFS=:
+ for d in $PATH; do
+ [ -f "${d:=.}/$1" -a -x "$d/$1" ] && printf %s "$d" && break
+ done ;;
+ esac
+}
+
+
if install-mh -check >/dev/null 2>&1; then
# Determine config options from installed nmh.
- mhparam=`which mhparam`
- mhbin=`dirname "$mhparam"`
+ mhbin=`finddir install-mh`
config_prefix=`cd $mhbin/.. && pwd`
fi
fi
-if [ "$EDITOR" ]; then
- config_editor="$EDITOR"
-elif [ "$VISUAL" ]; then
- config_editor="$VISUAL"
-fi
-
-[ "$PAGER" ] && config_pager="$PAGER"
-
[ $debug -ge 1 ] && config_debug=y
if [ $yes -eq 0 ]; then
config_tls=n
fi
- printf 'Default editor [%s]: ' $config_editor
- read editor
- [ "$editor" ] && config_editor="$editor"
-
- printf 'Pager [%s]: ' $config_pager
- read pager
- [ "$pager" ] && config_pager="$pager"
-
#### Don't confirm debug here: obey the -d option to this script.
fi
config_opts="$config_opts --with-cyrus-sasl"
[ "$config_tls" = y ] && \
config_opts="$config_opts --with-tls"
-[ "$config_editor" ] && \
- config_opts="$config_opts --with-editor=$config_editor"
-[ "$config_pager" ] && \
- config_opts="$config_opts --with-pager=$config_pager"
[ $config_debug = y ] && \
config_opts="$config_opts --enable-debug"
- inc(1) now supports a -port switch to specify the port used by the
POP server.
- pick(1) now decodes MIME-encoded header fields before searching.
+- The VISUAL and EDITOR environment variables are now supported as fallbacks
+ if the user does not configure an editor entry in their profile.
----------------------------
refuses to do that. For backward compatibility, spost has been
replaced by a simple shell script that exec's post -mts
sendmail/pipe.
+- Support for the undocumented and deprecated --enable-nmh-debug configure
+ flag has been removed.
+- Support for encoding some characters designated as EBCDIC-unsafe
+ via the -ebcdicsafe and -noebcdicsafe switches to mhbuild has
+ been removed.
+- The configure flag --with-pager has been removed; the default pager
+ is now hardcoded as "more". Users are still free to override the
+ default using the PAGER environment variable or entries in .mh_profile.
+- The configure flag --with-editor has been removed; the fallback editor
+ if none is configured is "vi".
---------
BUG FIXES
- Fixed pick(1) to properly unfold multiple-line header fields by
removing newlines instead of replacing them with spaces [Bug #15215].
- Removed the artificial limit of 1000 messages at a time for rmmproc.
+- Fixed decoding of header fields when they contain a character that
+ can't be converted.
#define FT_CONCATADDR 70 /* formataddr w/out duplicate removal */
#define FT_MYMBOX 71 /* do "mymbox" test on comp */
-/* misc. */ /* ADDTOSEQ only works if you include "options LBL" */
-#define FT_ADDTOSEQ 72 /* add current msg to a sequence */
-
/* conditionals & control flow (must be last) */
-#define FT_SAVESTR 73 /* save current str reg */
-#define FT_DONE 74 /* stop formatting */
-#define FT_PAUSE 75 /* pause */
-#define FT_NOP 76 /* nop */
-#define FT_GOTO 77 /* (relative) goto */
-#define FT_IF_S_NULL 78 /* test if "str" null */
-#define FT_IF_S 79 /* test if "str" non-null */
-#define FT_IF_V_EQ 80 /* test if "value" = literal */
-#define FT_IF_V_NE 81 /* test if "value" != literal */
-#define FT_IF_V_GT 82 /* test if "value" > literal */
-#define FT_IF_MATCH 83 /* test if "str" contains literal */
-#define FT_IF_AMATCH 84 /* test if "str" starts with literal */
-#define FT_S_NULL 85 /* V = 1 if "str" null */
-#define FT_S_NONNULL 86 /* V = 1 if "str" non-null */
-#define FT_V_EQ 87 /* V = 1 if "value" = literal */
-#define FT_V_NE 88 /* V = 1 if "value" != literal */
-#define FT_V_GT 89 /* V = 1 if "value" > literal */
-#define FT_V_MATCH 90 /* V = 1 if "str" contains literal */
-#define FT_V_AMATCH 91 /* V = 1 if "str" starts with literal */
+#define FT_SAVESTR 72 /* save current str reg */
+#define FT_DONE 73 /* stop formatting */
+#define FT_PAUSE 74 /* pause */
+#define FT_NOP 75 /* nop */
+#define FT_GOTO 76 /* (relative) goto */
+#define FT_IF_S_NULL 77 /* test if "str" null */
+#define FT_IF_S 78 /* test if "str" non-null */
+#define FT_IF_V_EQ 79 /* test if "value" = literal */
+#define FT_IF_V_NE 80 /* test if "value" != literal */
+#define FT_IF_V_GT 81 /* test if "value" > literal */
+#define FT_IF_MATCH 82 /* test if "str" contains literal */
+#define FT_IF_AMATCH 83 /* test if "str" starts with literal */
+#define FT_S_NULL 84 /* V = 1 if "str" null */
+#define FT_S_NONNULL 85 /* V = 1 if "str" non-null */
+#define FT_V_EQ 86 /* V = 1 if "value" = literal */
+#define FT_V_NE 87 /* V = 1 if "value" != literal */
+#define FT_V_GT 88 /* V = 1 if "value" > literal */
+#define FT_V_MATCH 89 /* V = 1 if "str" contains literal */
+#define FT_V_AMATCH 90 /* V = 1 if "str" starts with literal */
#define IF_FUNCS FT_S_NULL /* start of "if" functions */
#define UNKWNSW (-1) /* from smatch() on unknown switch */
struct swit {
+
+ /*
+ * Switch name
+ */
+
char *sw;
/* The minchars field is apparently used like this:
0 : Switch can't be abbreviated; switch shown in -help.
# : Switch can be abbreviated to # characters; switch shown in -help. */
int minchars;
+
+ /*
+ * If we pick this switch, return this value from smatch
+ */
+
+ int swret;
};
+/*
+ * Macros to use when declaring struct swit arrays.
+ *
+ * These macros are what known as X-Macros. In your source code you
+ * use them like this:
+ *
+ * #define FOO_SWITCHES \
+ * X("switch1", 0, SWITCHSW) \
+ * X("switch2", 0, SWITCH2SW) \
+ * X("thirdswitch", 2, SWITCH3SW) \
+ *
+ * The argument to each entry in FOO_SWITCHES are the switch name (sw),
+ * the minchars field (see above) and the return value for this switch.
+ *
+ * After you define FOO_SWITCHES, you instantiate it as follows:
+ *
+ * #define X(sw, minchars, id) id,
+ * DEFINE_SWITCH_ENUM(FOO);
+ * #undef X
+ *
+ * #define X(sw, minchars, id) { sw, minchars, id },
+ * DEFINE_SWITCH_ARRAY(FOO);
+ * #undef X
+ *
+ * DEFINE_SWITCH_ENUM defines an extra enum at the end of the list called
+ * LEN_FOO.
+ */
+
+#define DEFINE_SWITCH_ENUM(name) \
+ enum { \
+ name ## _SWITCHES \
+ LEN_ ## name \
+ }
+
+#define DEFINE_SWITCH_ARRAY(name, array) \
+ static struct swit array[] = { \
+ name ## _SWITCHES \
+ { NULL, 0, 0 } \
+ }
+
extern struct swit anoyes[]; /* standard yes/no switches */
#define ATTACHFORMATS 3 /* Number of send attach formats. */
extern char *components;
extern char *context;
extern char *current;
-extern char *defaulteditor;
extern char *defaultfolder;
extern char *digestcomps;
extern char *distcomps;
/*
* various cache policies
*/
-static struct swit caches[] = {
-#define CACHE_NEVER 0
- { "never", 0 },
-#define CACHE_PRIVATE 1
- { "private", 0 },
-#define CACHE_PUBLIC 2
- { "public", 0 },
-#define CACHE_ASK 3
- { "ask", 0 },
- { NULL, 0 }
-};
+
+#define CACHE_SWITCHES \
+ X("never", 0, CACHE_NEVER) \
+ X("private", 0, CACHE_PRIVATE) \
+ X("public", 0, CACHE_PUBLIC) \
+ X("ask", 0, CACHE_ASK) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(CACHE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(CACHE, caches);
+#undef X
# endif
#endif
+/*
+ * Defaults for programs if they aren't configured in a user's profile
+ */
+
+#define DEFAULT_PAGER "more"
+#define DEFAULT_EDITOR "vi"
+
#include <signal.h>
char **getarguments (char *, int, char **, int);
char *get_charset(void);
char *getcpy (char *);
+char *get_default_editor(void);
char *getfolder(int);
int lkclose(int, char*);
int lkfclose(FILE *, char *);
--- /dev/null
+dnl
+dnl Check for iconv support. It may be in libiconv and may be iconv()
+dnl or libiconv()
+dnl
+
+AC_DEFUN([NMH_CHECK_ICONV],
+[AC_CHECK_HEADER([iconv.h],
+ [AC_CHECK_FUNC([iconv],
+ [dnl This is where iconv is found in the default libraries (LIBS)
+ nmh_found_iconv=yes
+ dnl Handle the case where there is a native iconv but iconv.h is
+ dnl from libiconv
+ AC_CHECK_DECL([_libiconv_version],
+ [AC_CHECK_LIB([iconv], [libiconv], [LIBS="-liconv $LIBS"])],,
+ [#include <iconv.h>])],
+ [dnl Since we didn't find iconv in LIBS, check libiconv
+ AC_CHECK_LIB([iconv], [iconv], [nmh_found_iconv=yes],
+ [dnl Also check for a function called libiconv()
+ AC_CHECK_LIB([iconv], [libiconv], [nmh_found_iconv=yes])])
+ dnl If either of these tests pass, set ICONVLIB
+ AS_IF([test "x$nmh_found_iconv" = "xyes"], [ICONVLIB="-liconv"])])
+ dnl If we came out of that by finding iconv in some form, define
+ dnl HAVE_ICONV
+ AS_IF([test "x$nmh_found_iconv" = "xyes"],
+ [AC_DEFINE([HAVE_ICONV], [1],
+ [Define if you have the iconv() function.])
+ AC_CACHE_CHECK([for iconv declaration], [nmh_cv_iconv_const],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
+ #include <iconv.h>]],
+ [[#ifdef __cplusplus
+ "C"
+ #endif
+ #if defined(__STDC__) || defined(__cplusplus)
+ size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+ #else
+ size_t iconv();
+ #endif]])],
+ [nmh_cv_iconv_const=],
+ [nmh_cv_iconv_const=const])])
+ AC_DEFINE_UNQUOTED([ICONV_CONST], [$nmh_cv_iconv_const],
+ [Define as const if the declaration of iconv() needs const.])])])
+AC_SUBST([ICONVLIB])])
.RE
.PP
.BR Editor :
-/usr/bin/vi
+vi
.RS 5
Defines the editor to be used by the commands
.BR comp ,
.BR forw ,
and
.BR repl .
-(profile, default: %default_editor%)
+If not set in profile the value will be taken from the VISUAL and
+EDITOR environment variables.
+(profile, default: vi)
.RE
.PP
.BR automimeproc :
.RE
.PP
.BR lproc :
-%default_pager%
+more
.RS 5
This program is used to list the contents of a message in response
to the
.RE
.PP
.BR moreproc :
-%default_pager%
+more
.RS 5
This is the program used by
.B mhl
-.TH MHBUILD %manext1% "May 31, 2012" "%nmhversion%"
+.TH MHBUILD %manext1% "January 4, 2013" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
.RB [ \-realsize " | " \-norealsize ]
.RB [ \-headers " | " \-noheaders ]
.RB [ \-directives " | " \-nodirectives ]
-.RB [ \-ebcdicsafe " | " \-noebcdicsafe ]
.RB [ \-rfc934mode " | " \-norfc934mode ]
.RB [ \-contentid " | " \-nocontentid ]
.RB [ \-verbose " | " \-noverbose ]
.B mhbuild
is given the
.B \-check
-switch, then it will also associate
-an integrity check with each \*(lqleaf\*(rq content. This will add a
-Content-MD5 header field to the content, along with the md5 sum of the
-unencoded contents. This may be used by the receiver of the message to
-verify that the contents of the message were not changed in transport.
+switch, then it will also associate an integrity check with each
+\*(lqleaf\*(rq content. This will add a Content-MD5 header field to
+the content, along with the md5 sum of the unencoded contents, per RFC
+1864. This may be used by the receiver of the message to verify that
+the contents of the message were not changed in transport.
.SS "Transfer Encodings"
After
.B mhbuild
a transfer encoding, even it the content contains only 7\-bit data. This
is to increase the likelihood that the content is not changed while in
transport.
-.PP
-The switch
-.B \-ebcdicsafe
-will cause
-.B mhbuild
-to slightly change
-the way in which it performs the \*(lqquoted-printable\*(rq transfer
-encoding. Along with encoding 8\-bit characters, it will now also encode
-certain common punctuation characters as well. This slightly reduces the
-readability of the message, but allows the message to pass more reliably
-through mail gateways which involve the EBCDIC character encoding.
.SS "Invoking mhbuild"
Typically,
.B mhbuild
.I "Proposed Standard for Message Encapsulation"
(RFC\-934),
.PP
+.I "The Content-MD5 Header Field"
+(RFC\-1864),
+.PP
.I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
(RFC\-2045),
.PP
.RB ` \-norfc934mode '
.RB ` \-contentid '
.RB ` \-nocheck '
-.RB ` \-noebcdicsafe '
.RB ` \-noverbose '
.fi
.B mhn
.B \-build
.I file
-.RB [ \-ebcdicsafe " | " \-noebcdicsafe ]
.RB [ \-rfc934mode " | " \-norfc934mode ]
.ad
.SH DESCRIPTION
--- /dev/null
+
+/*
+ * arglist.c -- Routines for handling argument lists for execvp() and friends
+ *
+ * This code is Copyright (c) 2013, by the authors of nmh. See the
+ * COPYRIGHT file in the root directory of the nmh distribution for
+ * complete copyright information.
+ */
+
+#include <h/mh.h>
+#include <h/utils.h>
+
+/*
+ * Split up a command into an appropriate array to pass to execvp()
+ * or similar function. Returns an allocated argv[] array.
+ *
+ * Function arguments:
+ *
+ * command - String to split up
+ * file - the first argument to "command", suitable for the first argument
+ * to execvp(). Returns allocated memory that must be free()d.
+ * argp - Index to last element (NULL) of returned argv[] array.
+ *
+ * Our basic algorithm is this:
+ *
+ * - If there are no spaces or shell metacharacters in "command", then
+ * take it as-is.
+ * - If there are spaces in command, space-split command string and
+ * append an argument list to it.
+ * - If we have shell metacharacters, run the command using
+ * /bin/sh -c 'command "${@}"'.
+ *
+ * In all cases additional arguments can be added to the argv[] array.
+ */
+
+/* Shell metacharacters we use to trigger a call to the shell */
+
+#define METACHARS "$&*(){}[]'\";\\|?<>~`\n"
+
+char **
+argsplit(char *command, char **file, int *argp)
+{
+ char **argvarray, *p;
+ int space = 0, metachar = 0, i;
+
+ for (p = command; *p; p++) {
+ if (*p == ' ' || *p == '\t') {
+ space = 1;
+ } else if (strchr(METACHARS, *p)) {
+ metachar = 1;
+ break;
+ }
+ }
+
+ argvarray = (char **) mh_xmalloc((sizeof(char **) * MAXARGS));
+
+ /*
+ * The simple case - no spaces or shell metacharacters
+ */
+
+ if (!space && !metachar) {
+ argvarray[0] = getcpy(r1bindex(command, '/'));
+ argvarray[1] = NULL;
+ *file = getcpy(command);
+ if (argp)
+ *argp = 1;
+ return argvarray;
+ }
+
+ /*
+ * Spaces, but no shell metacharacters; space-split into seperate
+ * arguments
+ */
+
+ if (space && !metachar) {
+ char **split;
+ p = getcpy(command);
+ split = brkstring(p, " \t", NULL);
+ if (split[0] == NULL) {
+ adios(NULL, "Invalid blank command found");
+ }
+ argvarray[0] = getcpy(r1bindex(split[0], '/'));
+ for (i = 1; split[i] != NULL; i++) {
+ if (i > MAXARGS) {
+ adios(NULL, "Command exceeded argument limit");
+ }
+ argvarray[i] = getcpy(split[i]);
+ }
+ argvarray[i] = NULL;
+ *file = getcpy(split[0]);
+ if (argp)
+ *argp = i;
+ free(p);
+ return argvarray;
+ }
+
+ /*
+ * Remaining option - pass to the shell.
+ *
+ * Some notes here:
+ *
+ * - The command passed to "sh -c" is actually:
+ * command "$@"
+ *
+ * If there are additional arguments they will be expanded by the
+ * shell, otherwise "$@" expands to nothing.
+ *
+ * - Every argument after the -c string gets put into positional
+ * parameters starting at $0, but $@ starts expanding with $1.
+ * So we put in a dummy argument (we just use /bin/sh)
+ */
+
+ *file = getcpy("/bin/sh");
+ argvarray[0] = getcpy("sh");
+ argvarray[1] = getcpy("-c");
+ argvarray[2] = getcpy(command);
+ argvarray[2] = add(" \"$@\"", argvarray[2]);
+ argvarray[3] = getcpy("/bin/sh");
+ argvarray[4] = NULL;
+
+ if (argp)
+ *argp = 4;
+
+ return argvarray;
+}
twscopy (struct tws *tb, struct tws *tw)
{
*tb = *tw; /* struct copy */
-
-#if 0
- tb->tw_sec = tw->tw_sec;
- tb->tw_min = tw->tw_min;
- tb->tw_hour = tw->tw_hour;
- tb->tw_mday = tw->tw_mday;
- tb->tw_mon = tw->tw_mon;
- tb->tw_year = tw->tw_year;
- tb->tw_wday = tw->tw_wday;
- tb->tw_yday = tw->tw_yday;
- tb->tw_zone = tw->tw_zone;
- tb->tw_clock = tw->tw_clock;
- tb->tw_flags = tw->tw_flags;
-#endif
}
{ "friendly", TF_COMP, FT_LS_FRIENDLY, FT_PARSEADDR, TFL_PUTS },
{ "mymbox", TF_COMP, FT_LV_COMPFLAG, FT_MYMBOX, TFL_PUTN },
- { "addtoseq", TF_STR, FT_ADDTOSEQ, 0, 0 },
{ "unquote", TF_EXPR, FT_LS_UNQUOTE, 0, TFL_PUTS},
break;
/* skip to next input character */
if (fromutf8) {
- for (start++;(start < q) && ((*start & 192) == 128);start++)
- inbytes--;
+ for (++start, --inbytes;
+ start < q && (*start & 192) == 128;
+ ++start, --inbytes)
+ continue;
} else
start++, inbytes--;
if (start >= q)
# include <wchar.h>
#endif
-#ifdef LBL
-struct msgs *fmt_current_folder; /* current folder (set by main program) */
-#endif
-
extern int fmt_norm; /* defined in sbr/fmt_def.c = AD_NAME */
struct mailname fmt_mnull = { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0,
NULL, NULL };
* no more than n bytes are copied
*/
static void
-cptrimmed(char **dest, char *str, unsigned int wid, char fill, size_t n) {
+cptrimmed(char **dest, char *str, unsigned int wid, char fill, size_t n,
+ size_t max) {
int remaining; /* remaining output width available */
int c, ljust;
int end; /* number of input bytes remaining in str */
#endif
char *sp; /* current position in source string */
char *cp = *dest; /* current position in destination string */
- char *ep = cp + n; /* end of destination buffer */
+ char *ep = cp + n; /* end of destination buffer based on desired width */
+ char *epmax = cp + max; /* true end of destination buffer */
int prevCtrl = 1;
/* get alignment */
while (*sp && remaining > 0 && end > 0) {
#ifdef MULTIBYTE_SUPPORT
char_len = mbtowc(&wide_char, sp, end);
+
+ /* Account for multibyte characters taking only one character's
+ width of output. */
+ if (char_len > 1 && epmax - ep >= char_len - 1) {
+ ep += char_len - 1;
+ }
+
if (char_len <= 0 || (cp + char_len > ep))
break;
}
static void
-cpstripped (char **dest, char *end, char *str)
+cpstripped (char **dest, char *end, char *max, char *str)
{
int prevCtrl = 1; /* This is 1 so we strip out leading spaces */
int len;
#ifdef MULTIBYTE_SUPPORT
char_len = mbtowc(&wide_char, str, len);
+ /* Account for multibyte characters taking only one character's
+ width of output. */
+ if (char_len > 1 && max - end >= char_len - 1) {
+ end += char_len - 1;
+ }
+
if (char_len <= 0 || *dest + char_len > end)
break;
comp = fmt->f_comp;
- if (! (comp->c_flags & CF_TRIMMED) && comp->c_text) {
- i = strlen(comp->c_text);
+ if (! (comp->c_flags & CF_TRIMMED) && comp->c_text &&
+ (i = strlen(comp->c_text)) > 0) {
if (comp->c_text[i - 1] == '\n' &&
- strcmp(comp->c_name, "body") != 0 &&
- strcmp(comp->c_name, "text") != 0)
+ strcmp(comp->c_name, "body") != 0 &&
+ strcmp(comp->c_name, "text") != 0)
comp->c_text[i - 1] = '\0';
comp->c_flags |= CF_TRIMMED;
}
switch (fmt->f_type) {
case FT_COMP:
- cpstripped (&cp, ep, fmt->f_comp->c_text);
+ cpstripped (&cp, ep, scanl + max - 1, fmt->f_comp->c_text);
break;
case FT_COMPF:
- cptrimmed (&cp, fmt->f_comp->c_text, fmt->f_width, fmt->f_fill, ep - cp);
+ cptrimmed (&cp, fmt->f_comp->c_text, fmt->f_width, fmt->f_fill,
+ ep - cp, scanl - cp + max - 1);
break;
case FT_LIT:
break;
case FT_STR:
- cpstripped (&cp, ep, str);
+ cpstripped (&cp, ep, scanl + max - 1, str);
break;
case FT_STRF:
- cptrimmed (&cp, str, fmt->f_width, fmt->f_fill, ep - cp);
+ cptrimmed (&cp, str, fmt->f_width, fmt->f_fill, ep - cp,
+ scanl - cp + max - 1);
break;
case FT_STRLIT:
sp = str;
*cp++ = ' ';
}
}
- cpstripped (&cp, ep, lp);
+ cpstripped (&cp, ep, scanl + max - 1, lp);
}
break;
comp->c_mn = &fmt_mnull;
}
break;
-
- case FT_ADDTOSEQ:
-#ifdef LBL
- /* If we're working on a folder (as opposed to a file), add the
- * current msg to sequence given in literal field. Don't
- * disturb string or value registers.
- */
- if (fmt_current_folder)
- seq_addmsg(fmt_current_folder, fmt->f_text, dat[0], -1);
-#endif
- break;
}
fmt++;
}
-#ifndef JLR
+
/* Emit any trailing sequences of zero display length. */
while (fmt->f_type != FT_DONE) {
if (fmt->f_type == FT_LS_LIT) {
}
*cp = '\0';
return ((struct format *)0);
-#else /* JLR */
- if (cp[-1] != '\n')
- *cp++ = '\n';
- while (fmt->f_type != FT_DONE)
- fmt++;
-
- finished:;
- *cp = '\0';
- return (fmt->f_value ? ++fmt : (struct format *) 0);
-
-#endif /* JLR */
}
static void initialize_readline(void);
static char ansbuf[BUFSIZ];
-#if 0
-static sigjmp_buf sigenv;
-
-/*
- * static prototypes
- */
-static void intrser (int);
-
-
-char **
-getans (char *prompt, struct swit *ansp)
-{
- int i;
- SIGNAL_HANDLER istat = NULL;
- char *cp, **cpp;
-
- if (!(sigsetjmp(sigenv, 1))) {
- istat = SIGNAL (SIGINT, intrser);
- } else {
- SIGNAL (SIGINT, istat);
- return NULL;
- }
-
- for (;;) {
- printf ("%s", prompt);
- fflush (stdout);
- cp = ansbuf;
- while ((i = getchar ()) != '\n') {
- if (i == EOF) {
- /*
- * If we get an EOF, return
- */
- if (feof(stdin))
- siglongjmp (sigenv, 1);
-
- /*
- * For errors, if we get an EINTR that means that we got
- * a signal and we should retry. If we get another error,
- * then just return.
- */
-
- else if (ferror(stdin)) {
- if (errno == EINTR) {
- clearerr(stdin);
- continue;
- }
- fprintf(stderr, "\nError %s during read\n",
- strerror(errno));
- siglongjmp (sigenv, 1);
- } else {
- /*
- * Just for completeness's sake ...
- */
-
- fprintf(stderr, "\nUnknown problem in getchar()\n");
- siglongjmp (sigenv, 1);
- }
- }
- if (cp < &ansbuf[sizeof ansbuf - 1])
- *cp++ = i;
- }
- *cp = '\0';
- if (ansbuf[0] == '?' || cp == ansbuf) {
- printf ("Options are:\n");
- print_sw (ALL, ansp, "", stdout);
- continue;
- }
- cpp = brkstring (ansbuf, " ", NULL);
- switch (smatch (*cpp, ansp)) {
- case AMBIGSW:
- ambigsw (*cpp, ansp);
- continue;
- case UNKWNSW:
- printf (" -%s unknown. Hit <CR> for help.\n", *cpp);
- continue;
- default:
- SIGNAL (SIGINT, istat);
- return cpp;
- }
- }
-}
-
-
-static void
-intrser (int i)
-{
- NMH_UNUSED (i);
-
- /*
- * should this be siglongjmp?
- */
- siglongjmp (sigenv, 1);
-}
-#endif
/*
* getans, but with readline support
--- /dev/null
+
+/*
+ * geteditor.c -- Determine the default editor to use
+ *
+ * This code is Copyright (c) 2013, by the authors of nmh. See the
+ * COPYRIGHT file in the root directory of the nmh distribution for
+ * complete copyright information.
+ */
+
+#include <h/mh.h>
+#include <h/utils.h>
+
+static char *default_editor = NULL;
+
+char *
+get_default_editor(void)
+{
+ char *str;
+
+ if (default_editor)
+ return default_editor;
+
+ if (!(str = context_find("editor")) && !(str = getenv("VISUAL")) &&
+ !(str = getenv("EDITOR"))) {
+ str = DEFAULT_EDITOR;
+ }
+
+ return (default_editor = str);
+}
* check if message is in-range and exists.
*/
if (mp->msgflags & ALLOW_NEW) {
+ /*
+ * We can get into a case where the "cur" sequence is way out
+ * of range, and because it's allowed to not exist (think
+ * of "rmm; next") it doesn't get checked to make sure it's
+ * within the range of messages in seq_init(). So if our
+ * desired sequence is out of range of the allocated folder
+ * limits simply reallocate the folder so it's within range.
+ */
+ if (first < mp->lowoff || first > mp->hghoff)
+ mp = folder_realloc(mp, first < mp->lowoff ? first : mp->lowoff,
+ first > mp->hghoff ? first : mp->hghoff);
+
set_select_empty (mp, first);
} else {
if (first > mp->hghmsg
continue; /* no match */
for (sp = string; *sp == *tcp++;) {
if (*sp++ == '\0')
- return (tp - swp); /* exact match */
+ return tp->swret; /* exact match */
}
if (*sp) {
if (*sp != ' ')
continue; /* no match */
if (*--tcp == '\0')
- return (tp - swp); /* exact match */
+ return tp->swret; /* exact match */
}
if (firstone == UNKWNSW)
- firstone = tp - swp;
+ firstone = tp->swret;
else
firstone = AMBIGSW;
}
test -z "$bindir" && bindir="@bindir@"
test -z "$mandir" && mandir="@mandir@"
test -z "$sysconfdir" && sysconfdir="@sysconfdir@"
-test -z "$pagerpath" && pagerpath="@pagerpath@"
test -z "$MULTIBYTE_ENABLED" && MULTIBYTE_ENABLED="@MULTIBYTE_ENABLED@"
-export MH_TEST_DIR auxexecdir bindir mandir sysconfdir pagerpath
+export MH_TEST_DIR auxexecdir bindir mandir sysconfdir
export MULTIBYTE_ENABLED
test -z "$MH_INST_DIR" && MH_INST_DIR="${MH_TEST_DIR}/inst"
#### so that we use fakesmtp.
#### And set up the maildrop in the test directory so tests don't
#### use the user's real maildrop.
+ #### test-slocal needs to look at the original mts.conf, so save it.
+ mv -f "${MHMTSCONF}" "${MHMTSCONF}.old"
sed -e 's/mts: *.*/mts: smtp/' \
-e "s%mmdfldir: *.*%mmdfldir: ${MH_TEST_DIR}/Mail%" \
-e 's%mmdflfil: *.*%mmdflfil: maildrop%' \
- "${MHMTSCONF}" >"${MHMTSCONF}.new"
- mv -f "${MHMTSCONF}.new" "${MHMTSCONF}"
+ "${MHMTSCONF}.old" >"${MHMTSCONF}"
fi
# clean old test data
setup_test
+thisdir="$srcdir/test/inc"
+expected="$MH_TEST_DIR/$$.expected"
+actual="$MH_TEST_DIR/$$.actual"
+
cat > "${MH_TEST_DIR}/test.mbox" <<EOF
From nobody@nowhereville Jan 1 1970
Received: I am the very model of a modern Major-General,
run_test "scan -width 120 +inbox 11" \
" 11+ 03/01 Mr Nobody Who is on first?<<Abbott: Every dollar of it. And why not, the man's entitled to it. Cos"
+# check header field name with ':' character than lands on m_getfld() buffer
+cat >"$MH_TEST_DIR/mess" <<EOF
+Comments: The important characteristic of this message is that the 8193'd
+Comments: byte is the ':' at the end of header field name. That tests some
+Comments: logic in m_getfld (), assuming its MSG_INPUT_SIZE is 8192.
+Comments: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+Comments: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+Comments: CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+Comments: DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
+Comments: EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+Comments: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+Comments: GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
+Comments: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+Comments: IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+Comments: JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
+Comments: KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
+Comments: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
+Comments: MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
+Comments: NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
+Comments: OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
+Comments: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+Comments: QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
+Comments: RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
+Comments: SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
+Comments: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
+Comments: UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
+Comments: VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
+Comments: WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
+Comments: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+Comments: YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
+Comments: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
+Comments: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Comments: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+Comments: cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+Comments: dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
+Comments: eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
+Comments: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+Comments: gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
+Comments: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
+Comments: iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
+Comments: jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
+Comments: kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+Comments: llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
+Comments: mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+Comments: nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
+Comments: oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
+Comments: pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
+Comments: qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
+Comments: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
+Comments: ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
+Comments: tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
+Comments: uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
+Comments: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
+Comments: wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
+Comments: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+Comments: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
+Comments: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
+Comments: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+Comments: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+Comments: CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+Comments: DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
+Comments: EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+Comments: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+Comments: GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
+Comments: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+Comments: IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+Comments: JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
+Comments: KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
+Comments: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
+Comments: MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
+Comments: NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
+Comments: OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
+Comments: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+Comments: QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
+Comments: RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
+Comments: SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
+Comments: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
+Comments: UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
+Comments: VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
+Comments: WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
+Comments: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+Comments: YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
+Comments: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
+Comments: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Comments: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+Comments: cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+Comments: dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
+Comments: eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
+Comments: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+Comments: gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
+Comments: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
+Comments: iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
+Comments: jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
+Comments: kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+Comments: llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
+Comments: mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+Comments: nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
+Comments: oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
+Comments: pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
+Comments: qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
+Comments: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
+Comments: ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
+Comments: tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
+Comments: uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
+Comments: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
+Comments: wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
+Comments: This is it, the line with the 8193'd character of ':'.
+Comments: From somewhere
+From: No Such User <nosuch@example.com>
+To: Some Other User <someother@example.com>
+Subject: all that and nothing to say?
+Date: Thu, 10 Jan 2013 19:54:01 -0500
+
+EOF
+
+run_test 'scan -width 60 -file '"$MH_TEST_DIR/mess" \
+ ' 1 01/10 No Such User all that and nothing to say?'
+rm -f "$MH_TEST_DIR/mess"
+
+# check m_getfld() handling of fields with trailing whitespace
+# Even though header field names aren't supposed to have spaces (RFC
+# 28220, m_getfld () trims trailing whitespace from them.
+cat >`mhpath new` <<EOF
+Date : Sun, 18 Dec 2005 00:52:39 +0100
+From : foo@example.edu
+To: bar@example.edu
+Subject: test
+EOF
+run_test 'scan last' ' 12 12/18 foo@example.edu test'
+
+# check header field body with more than 511 characters
+cat >"$MH_TEST_DIR/mess" <<EOF
+Comments: The important characteristic of this message is that this header
+ field body is more than 511 bytes long. That tests the logic in
+ m_getfld () for transitioning to the FLDPLUS state. This is the
+ only use for the FLDPLUS state, handling header field bodies that
+ are longer than the buffer used to retrieve them. The trailing
+ newline after the last character is the 512th character. The 511th
+ character, counting all spaces, even the leading one, is*
+From: No Such User <nosuch@example.com>
+To: Some Other User <someother@example.com>
+Subject: FLDPLUS test
+Date: Wed, 16 Jan 2013 20:33:58 -0600
+
+EOF
+
+run_test 'scan -width 80 -file '"$MH_TEST_DIR"'/mess' \
+ ' 1 01/16 No Such User FLDPLUS test'
+rm -f "$MH_TEST_DIR/mess"
+
+# check scan and inc of mbox with multiple messages
+echo y | packf -file "$MH_TEST_DIR/msgbox"
+run_test "scan -width 80 -file $MH_TEST_DIR/msgbox" \
+' 1 09/29 Test1 Testing message 1<<This is message number 1 >>
+ 2 09/29 Test2 Testing message 2<<This is message number 2 >>
+ 3 09/29 Test3 Testing message 3<<This is message number 3 >>
+ 4 09/29 Test4 Testing message 4<<This is message number 4 >>
+ 5 09/29 Test5 Testing message 5<<This is message number 5 >>
+ 6 09/29 Test6 Testing message 6<<This is message number 6 >>
+ 7 09/29 Test7 Testing message 7<<This is message number 7 >>
+ 8 09/29 Test8 Testing message 8<<This is message number 8 >>
+ 9 09/29 Test9 Testing message 9<<This is message number 9 >>
+ 10 09/29 Test10 Testing message 10<<This is message number 10 >>
+ 11 03/01 Mr Nobody Who is on first?<<Abbott: Every dollar of it. An
+ 12 12/18 foo@example.edu test'
+run_test "inc -width 80 -file $MH_TEST_DIR/msgbox -truncate" \
+'Incorporating new mail into inbox...
+
+ 13+ 09/29 Test1 Testing message 1<<This is message number 1 >>
+ 14 09/29 Test2 Testing message 2<<This is message number 2 >>
+ 15 09/29 Test3 Testing message 3<<This is message number 3 >>
+ 16 09/29 Test4 Testing message 4<<This is message number 4 >>
+ 17 09/29 Test5 Testing message 5<<This is message number 5 >>
+ 18 09/29 Test6 Testing message 6<<This is message number 6 >>
+ 19 09/29 Test7 Testing message 7<<This is message number 7 >>
+ 20 09/29 Test8 Testing message 8<<This is message number 8 >>
+ 21 09/29 Test9 Testing message 9<<This is message number 9 >>
+ 22 09/29 Test10 Testing message 10<<This is message number 10 >>
+ 23 03/01 Mr Nobody Who is on first?<<Abbott: Every dollar of it. An
+ 24 12/18 foo@example.edu test'
+rm -f "$MH_TEST_DIR/msgbox"
+
+
exit ${failed:-0}
testport=65413
HOME="${MH_TEST_DIR}"; export HOME
-echo "default login ${TESTUSER} password ${TESTPASS}" > ${HOME}/.netrc
-chmod 600 ${HOME}/.netrc
+netrc="${HOME}/.netrc"
+echo "default login ${TESTUSER} password ${TESTPASS}" > "$netrc"
+chmod 600 "$netrc"
expected=$MH_TEST_DIR/$$.expected
expected_err=$MH_TEST_DIR/$$.expected_err
11+ 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're do"
check `mhpath +inbox 11` $testmessage
-rm -f $testmessage
+rm -f $testmessage "$netrc"
exit ${failed:-0}
Subject: Test
Nmh-Attachment: $MH_TEST_DIR/attachment.txt
-¡Ay, caramba!
+¡Ay, caramba!
EOF
cat > "${testname}.expected" <<EOF
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
-=A1Ay, caramba!
+=C2=A1Ay, caramba!
------- =_aaaaaaaaaa0
Content-Type: text/plain; name="attachment.txt"
rm -f ${MHMTSCONF} "${MH_TEST_DIR}/attachment.txt"
exit ${failed:-0}
+
+# emacs hackage to ensure that it writes the inverted exclamation
+# point as UTF-8 multibyte character \xC2\xA1 instead of just \xA1.
+# Local Variables:
+# coding: utf-8
+# End:
700
$bindir/inc
$auxexecdir/install-mh
-$pagerpath
+more
$bindir/mhmail
$MH_INST_DIR$auxexecdir/mhl
cat
setup_test
-expected=$MH_TEST_DIR/$$.expected
-actual=$MH_TEST_DIR/$$.actual
+expected="$MH_TEST_DIR/$$.expected"
+actual="$MH_TEST_DIR/$$.actual"
-cat > $expected <<EOF
+cat >"$expected" <<EOF
1 09/29 Test1 Testing message 1<<This is message number 1 >>
2 09/29 Test2 Testing message 2<<This is message number 2 >>
3 09/29 Test3 Testing message 3<<This is message number 3 >>
10 09/29 Test10 Testing message 10<<This is message number 10 >>
EOF
-scan +inbox -width 80 > $actual || exit 1
-
+scan +inbox -width 80 >"$actual" || exit 1
check "$expected" "$actual"
# check highlighting
-cat > $expected <<EOF
+cat >"$expected" <<EOF
1 09/29 Test1 Testing message 1<<This is message number 1 >>\e[m
2 09/29 Test2 Testing message 2<<This is message number 2 >>\e[m
3 09/29 Test3 Testing message 3<<This is message number 3 >>\e[m
printf 'Unseen-Sequence: unseen\n' >> $MH
mark -sequence cur 5
mark -sequence unseen 10
-scan -form scan.highlighted -width 80 > $actual || exit 1
-
+scan -form scan.highlighted -width 80 >"$actual" || exit 1
check "$expected" "$actual"
Things are looking great!
EOF
-expected=$MH_TEST_DIR/$$.expected
-actual=$MH_TEST_DIR/$$.actual
+expected="$MH_TEST_DIR/$$.expected"
+actual="$MH_TEST_DIR/$$.actual"
-cat > $expected <<EOF
+cat > "$expected" <<EOF
11 03/02 David st Hubbins Spin̈al Tap → Tap into America!<<Things are
EOF
scan -width 80 +inbox 11 > $actual || exit 1
+check "$expected" "$actual"
+
+# check decoding with an invalid multibyte sequence
+cat >`mhpath new` <<EOF
+From: Test12 <test12@example.com>
+To: Some User <user@example.com>
+Date: Mon, 31 Dec 2012 00:00:00
+Message-Id: 12@test.nmh
+Subject: =?UTF-8?B?MjAxMyBOZXcgWWVhcuKAmXMgRGVhbHMhIFN0YXJ0IHRoZSB5ZWFy?=
+ =?UTF-8?B?IHJpZ2h0IHdpdGggYmlnIHNhdmluZ3M=?=
+
+This message has an encoded Subject with an invalid character for the
+ISO-8859-1 character set, but it (U+2019) is valid UTF-8.
+EOF
+
+cat >"$expected" <<EOF
+ 12 12/31 Test12 2013 New Year?s Deals! Start the year right
+EOF
+LC_CTYPE=ISO-8859-1 MM_CHARSET=ISO-8859-1 scan -width 75 last >"$actual"
check "$expected" "$actual"
+# check scan width with a valid multibyte sequence
+cat >"$expected" <<EOF
+ 12 12/31 Test12 2013 New Year’s Deals! Start the year right
+EOF
+
+LC_CTYPE=en_US.UTF-8 MM_CHARSET=UTF-8 scan -width 75 last >"$actual"
+check "$expected" "$actual"
+
+
exit $failed
--- /dev/null
+#!/bin/sh
+############################################################
+#
+# Test to see if a out-of-range sequence is handled properly
+#
+############################################################
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+cat > $MH_TEST_DIR/Mail/inbox/.mh_sequences <<EOS
+cur: 120
+test: 121
+EOS
+
+run_test 'mhpath +inbox test' 'mhpath: sequence test empty'
+
+cat > $MH_TEST_DIR/Mail/inbox/.mh_sequences <<EOS
+cur: 120
+test: 121
+EOS
+
+#
+# Yes, this is right. "cur" is special in that it can refer to messages
+# that don't exist.
+#
+run_test 'mhpath +inbox cur' "$MH_TEST_DIR/Mail/inbox/120"
+
+exit $failed
# check non-switch argument
run_test "$slocal nonexistent" 'slocal: only switch arguments are supported'
+# If no mail spool, explicitly specify the mailbox.
+if grep 'mmdfldir:.*/dev/null' ${MHMTSCONF}.old >/dev/null; then
+ mbox="-mailbox ${MH_TEST_DIR}/Mail/mbox"
+else
+ mbox=
+fi
+
+#### Need to specify full path to tee on Cygwin.
+[ -x /usr/bin/tee ] && tee=/usr/bin/tee || tee=tee
+
# check basic operation
# Can't use rcvstore because slocal wipes out the environment.
# So, it would put the message in the user's inbox, not the
# test inbox. slocal also freopens stdout and stderr to
# /dev/null, so we can't view them to verify simulated delivery.
cat >$md <<EOF
-* 1 qpipe A "tee $actual"
+* 1 qpipe A "$tee $actual"
EOF
-$slocal -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/1
+$slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/1
check "$MH_TEST_DIR/Mail/inbox/1" "$actual" 'keep first'
# check -debug
-$slocal -debug -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/1 >"$actual2" 2>&1
+$slocal -debug -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/1 \
+ >"$actual2" 2>&1
run_test "grep ^retrieving $actual2" 'retrieving message from stdin'
# check -verbose
-$slocal -verbose -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/1 >"$actual2" 2>&1
-run_test "grep ^delivering $actual2" 'delivering to pipe "tee", success.'
+$slocal -verbose -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/1 \
+ >"$actual2" 2>&1
+run_test "grep ^delivering $actual2" "delivering to pipe \"$tee\", success."
# check -noverbose
-$slocal -verbose -noverbose -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/1 \
- >"$actual2" 2>&1
+$slocal -verbose -noverbose -maildelivery $md $mbox \
+ <"$MH_TEST_DIR"/Mail/inbox/1 >"$actual2" 2>&1
run_test "grep ^delivering $actual2" ''
rm -f "$actual2"
# check match of From
cat >$md <<EOF
-From test2@example.com qpipe A "tee $actual"
+From test2@example.com qpipe A "$tee $actual"
EOF
-$slocal -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/2
+$slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/2
check "$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
# check R and ?
cat >$md <<EOF
-From test3@example.com qpipe R "tee $actual"
-From test3@example.com qpipe ? "tee $actual2"
+From test3@example.com qpipe R "$tee $actual"
+From test3@example.com qpipe ? "$tee $actual2"
EOF
-$slocal -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/3
+$slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/3
check "$MH_TEST_DIR/Mail/inbox/3" "$actual" 'keep first'
check "$MH_TEST_DIR/Mail/inbox/3" "$actual2" 'keep first'
# check R and N
cat >$md <<EOF
-From test4@example.com qpipe R "tee $actual"
-From test4@example.com qpipe N "tee $actual2"
+From test4@example.com qpipe R "$tee $actual"
+From test4@example.com qpipe N "$tee $actual2"
EOF
-$slocal -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/4
+$slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/4
check "$MH_TEST_DIR/Mail/inbox/4" "$actual" 'keep first'
check "$MH_TEST_DIR/Mail/inbox/4" "$actual2" 'keep first'
# check default
cat >$md <<EOF
-From test5@example.com qpipe R "tee $actual"
-default 1 qpipe A "tee $actual2"
+From test5@example.com qpipe R "$tee $actual"
+default 1 qpipe A "$tee $actual2"
EOF
-$slocal -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/5
+$slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/5
check "$MH_TEST_DIR/Mail/inbox/5" "$actual" 'keep first'
check "$MH_TEST_DIR/Mail/inbox/5" "$actual2" 'keep first'
# check -addr
cat >$md <<EOF
-addr "$me" qpipe A "tee $actual"
+addr "$me" qpipe A "$tee $actual"
EOF
-$slocal -addr "$me" -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/6
+$slocal -addr "$me" -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/6
check "$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
# check -info
* 1 qpipe A "\$(info) $actual"
EOF
-$slocal -info tee -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/7
+$slocal -info $tee -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/7
check "$MH_TEST_DIR/Mail/inbox/7" "$actual" 'keep first'
# check -sender, which is compared with "source"
cat >$md <<EOF
-source "$me" qpipe A "tee $actual"
+source "$me" qpipe A "$tee $actual"
EOF
-$slocal -sender "$me" -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/8
+$slocal -sender "$me" -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/8
check "$MH_TEST_DIR/Mail/inbox/8" "$actual" 'keep first'
# check -user
cat >$md <<EOF
-* 1 qpipe A "tee $actual"
+* 1 qpipe A "$tee $actual"
EOF
-$slocal -user "$me" -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/9
+$slocal -user "$me" -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/9
check "$MH_TEST_DIR/Mail/inbox/9" "$actual" 'keep first'
# check -mailbox
# check -suppressdup
cat >$md <<EOF
-* 1 qpipe A "tee $actual"
+* 1 qpipe A "$tee $actual"
EOF
-$slocal -suppressdup -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/2
+$slocal -suppressdup -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/2
check "$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
-$slocal -suppressdup -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/2
+$slocal -suppressdup -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/2
if [ -f "$actual" ]; then
echo $0: check -suppressdup failed
failed=`expr ${failed:-0} + 1`
fi
# check -nosuppressdup
-$slocal -suppress -nosuppressdup -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/2
+$slocal -suppress -nosuppressdup -maildelivery $md $mbox \
+ <"$MH_TEST_DIR"/Mail/inbox/2
check "$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
#include <h/mts.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define ALIASW 0
- { "alias aliasfile", 0 },
-#define NALIASW 1
- { "noalias", -7 },
-#define LISTSW 2
- { "list", 0 },
-#define NLISTSW 3
- { "nolist", 0 },
-#define NORMSW 4
- { "normalize", 0 },
-#define NNORMSW 5
- { "nonormalize", 0 },
-#define USERSW 6
- { "user", 0 },
-#define NUSERSW 7
- { "nouser", 0 },
-#define VERSIONSW 8
- { "version", 0 },
-#define HELPSW 9
- { "help", 0 },
- { NULL, 0 }
-};
+#define ALI_SWITCHES \
+ X("alias aliasfile", 0, ALIASW) \
+ X("noalias", -7, NALIASW) \
+ X("list", 0, LISTSW) \
+ X("nolist", 0, NLISTSW) \
+ X("normalize", 0, NORMSW) \
+ X("nonormalize", 0, NNORMSW) \
+ X("user", 0, USERSW) \
+ X("nouser", 0, NUSERSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(ALI);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(ALI, switches);
+#undef X
static int pos = 1;
}
mnfree (mp);
-#if 0
- printf ("%s: ", s);
- print_aka (vp ? vp : s, list, pos += strlen (s) + 1);
-#else
print_aka (vp ? vp : s, list, 0);
-#endif
if (vp)
free (vp);
#include <h/mh.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define COMPSW 0
- { "component field", 0 },
-#define INPLSW 1
- { "inplace", 0 },
-#define NINPLSW 2
- { "noinplace", 0 },
-#define DATESW 3
- { "date", 0 },
-#define NDATESW 4
- { "nodate", 0 },
-#define TEXTSW 5
- { "text body", 0 },
-#define VERSIONSW 6
- { "version", 0 },
-#define HELPSW 7
- { "help", 0 },
-#define DRFTSW 8
- { "draft", 2 },
-#define LISTSW 9
- { "list", 1 },
-#define DELETESW 10
- { "delete", 2 },
-#define NUMBERSW 11
- { "number", 2 },
-#define APPENDSW 12
- { "append", 1 },
-#define PRESERVESW 13
- { "preserve", 1 },
-#define NOPRESERVESW 14
- { "nopreserve", 3 },
- { NULL, 0 }
-};
+#define ANNO_SWITCHES \
+ X("component field", 0, COMPSW) \
+ X("inplace", 0, INPLSW) \
+ X("noinplace", 0, NINPLSW) \
+ X("date", 0, DATESW) \
+ X("nodate", 0, NDATESW) \
+ X("text body", 0, TEXTSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("draft", 2, DRFTSW) \
+ X("list", 1, LISTSW) \
+ X("delete", 2, DELETESW) \
+ X("number", 2, NUMBERSW) \
+ X("append", 1, APPENDSW) \
+ X("preserve", 1, PRESERVESW) \
+ X("nopreserve", 3, NOPRESERVESW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(ANNO);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(ANNO, switches);
+#undef X
/*
* static prototypes
#define FORMAT "%<{error}%{error}: %{text}%|%(putstr(proper{text}))%>"
-static struct swit switches[] = {
-#define FORMSW 0
- { "form formatfile", 0 },
-#define FMTSW 1
- { "format string", 5 },
-#define NORMSW 2
- { "normalize", 0 },
-#define NNORMSW 3
- { "nonormalize", 0 },
-#define WIDTHSW 4
- { "width columns", 0 },
-#define VERSIONSW 5
- { "version", 0 },
-#define HELPSW 6
- { "help", 0 },
- { NULL, 0 }
-};
+#define AP_SWITCHES \
+ X("form formatfile", 0, FORMSW) \
+ X("format string", 5, FMTSW) \
+ X("normalize", 0, NORMSW) \
+ X("nonormalize", 0, NNORMSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(AP);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(AP, switches);
+#undef X
static struct format *fmt;
#include <h/mh.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define INPLSW 0
- { "inplace", 0 },
-#define NINPLSW 1
- { "noinplace", 0 },
-#define QIETSW 2
- { "quiet", 0 },
-#define NQIETSW 3
- { "noquiet", 0 },
-#define VERBSW 4
- { "verbose", 0 },
-#define NVERBSW 5
- { "noverbose", 0 },
-#define VERSIONSW 6
- { "version", 0 },
-#define HELPSW 7
- { "help", 0 },
- { NULL, 0 }
-};
+#define BURST_SWITCHES \
+ X("inplace", 0, INPLSW) \
+ X("noinplace", 0, NINPLSW) \
+ X("quiet", 0, QIETSW) \
+ X("noquiet", 0, NQIETSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(BURST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(BURST, switches);
+#undef X
struct smsg {
off_t s_start;
#include <h/fmt_scan.h>
#include <fcntl.h>
-static struct swit switches[] = {
-#define DFOLDSW 0
- { "draftfolder +folder", 0 },
-#define DMSGSW 1
- { "draftmessage msg", 0 },
-#define NDFLDSW 2
- { "nodraftfolder", 0 },
-#define EDITRSW 3
- { "editor editor", 0 },
-#define NEDITSW 4
- { "noedit", 0 },
-#define FILESW 5
- { "file file", 0 },
-#define FORMSW 6
- { "form formfile", 0 },
-#define USESW 7
- { "use", 0 },
-#define NUSESW 8
- { "nouse", 0 },
-#define WHATSW 9
- { "whatnowproc program", 0 },
-#define NWHATSW 10
- { "nowhatnowproc", 0 },
-#define VERSIONSW 11
- { "version", 0 },
-#define HELPSW 12
- { "help", 0 },
-#define TOSW 13
- { "to address", 0 },
-#define CCSW 14
- { "cc address", 0 },
-#define FROMSW 15
- { "from address", 0 },
-#define FCCSW 16
- { "fcc mailbox", 0 },
-#define WIDTHSW 17
- { "width colums", 0 },
-#define SUBJECTSW 18
- { "subject text", 0 },
- { NULL, 0 }
-};
-
-static struct swit aqrunl[] = {
-#define NOSW 0
- { "quit", 0 },
-#define YESW 1
- { "replace", 0 },
-#define USELSW 2
- { "use", 0 },
-#define LISTDSW 3
- { "list", 0 },
-#define REFILSW 4
- { "refile +folder", 0 },
-#define NEWSW 5
- { "new", 0 },
- { NULL, 0 }
-};
+#define COMP_SWITCHES \
+ X("draftfolder +folder", 0, DFOLDSW) \
+ X("draftmessage msg", 0, DMSGSW) \
+ X("nodraftfolder", 0, NDFLDSW) \
+ X("editor editor", 0, EDITRSW) \
+ X("noedit", 0, NEDITSW) \
+ X("file file", 0, FILESW) \
+ X("form formfile", 0, FORMSW) \
+ X("use", 0, USESW) \
+ X("nouse", 0, NUSESW) \
+ X("whatnowproc program", 0, WHATSW) \
+ X("nowhatnowproc", 0, NWHATSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("to address", 0, TOSW) \
+ X("cc address", 0, CCSW) \
+ X("from address", 0, FROMSW) \
+ X("fcc mailbox", 0, FCCSW) \
+ X("width colums", 0, WIDTHSW) \
+ X("subject text", 0, SUBJECTSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(COMP);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(COMP, switches);
+#undef X
+
+#define DISPO_SWITCHES \
+ X("quit", 0, NOSW) \
+ X("replace", 0, YESW) \
+ X("use", 0, USELSW) \
+ X("list", 0, LISTDSW) \
+ X("refile +folder", 0, REFILSW) \
+ X("new", 0, NEWSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DISPO);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DISPO, aqrunl);
+#undef X
static struct swit aqrul[] = {
- { "quit", 0 },
- { "replace", 0 },
- { "use", 0 },
- { "list", 0 },
- { "refile", 0 },
- { NULL, 0 }
+ { "quit", 0, NOSW },
+ { "replace", 0, YESW },
+ { "use", 0, USELSW },
+ { "list", 0, LISTDSW },
+ { "refile", 0, REFILSW },
+ { NULL, 0, 0 }
};
int
*/
#define NGRPS 100
-static struct swit switches[] = {
-#define MAILSW 0
- { "mail name", 0 },
-#define SERCHSW 1
- { "search directory", 0 },
-#define VERSIONSW 2
- { "version", 0 },
-#define HELPSW 3
- { "help", 0 },
- { NULL, 0 }
-};
+#define CONFLICT_SWITCHES \
+ X("mail name", 0, MAILSW) \
+ X("search directory", 0, SERCHSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(CONFLICT);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(CONFLICT, switches);
+#undef X
static char *mail = NULL;
static char *dirs[NDIRS];
#include <h/utils.h>
#include <fcntl.h>
-static struct swit switches[] = {
-#define ANNOSW 0
- { "annotate", 0 },
-#define NANNOSW 1
- { "noannotate", 0 },
-#define DFOLDSW 2
- { "draftfolder +folder", 0 },
-#define DMSGSW 3
- { "draftmessage msg", 0 },
-#define NDFLDSW 4
- { "nodraftfolder", 0 },
-#define EDITRSW 5
- { "editor editor", 0 },
-#define NEDITSW 6
- { "noedit", 0 },
-#define FORMSW 7
- { "form formfile", 0 },
-#define INPLSW 8
- { "inplace", 0 },
-#define NINPLSW 9
- { "noinplace", 0 },
-#define WHATSW 10
- { "whatnowproc program", 0 },
-#define NWHATSW 11
- { "nowhatnowproc", 0 },
-#define VERSIONSW 12
- { "version", 0 },
-#define HELPSW 13
- { "help", 0 },
-#define FILESW 14
- { "file file", -4 }, /* interface from msh */
-#define FROMSW 15
- { "from address", 0 },
-#define TOSW 16
- { "to address", 0 },
-#define CCSW 17
- { "cc address", 0 },
-#define FCCSW 18
- { "fcc mailbox", 0 },
-#define WIDTHSW 19
- { "width columns", 0 },
-#define ATFILESW 20
- { "atfile", 0 },
-#define NOATFILESW 21
- { "noatfile", 0 },
- { NULL, 0 }
-};
-
-static struct swit aqrnl[] = {
-#define NOSW 0
- { "quit", 0 },
-#define YESW 1
- { "replace", 0 },
-#define LISTDSW 2
- { "list", 0 },
-#define REFILSW 3
- { "refile +folder", 0 },
-#define NEWSW 4
- { "new", 0 },
- { NULL, 0 }
-};
+#define DIST_SWITCHES \
+ X("annotate", 0, ANNOSW) \
+ X("noannotate", 0, NANNOSW) \
+ X("draftfolder +folder", 0, DFOLDSW) \
+ X("draftmessage msg", 0, DMSGSW) \
+ X("nodraftfolder", 0, NDFLDSW) \
+ X("editor editor", 0, EDITRSW) \
+ X("noedit", 0, NEDITSW) \
+ X("form formfile", 0, FORMSW) \
+ X("inplace", 0, INPLSW) \
+ X("noinplace", 0, NINPLSW) \
+ X("whatnowproc program", 0, WHATSW) \
+ X("nowhatnowproc", 0, NWHATSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("file file", -4, FILESW) \
+ X("from address", 0, FROMSW) \
+ X("to address", 0, TOSW) \
+ X("cc address", 0, CCSW) \
+ X("fcc mailbox", 0, FCCSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("atfile", 0, ATFILESW) \
+ X("noatfile", 0, NOATFILESW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DIST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DIST, switches);
+#undef X
+
+#define DISPO_SWITCHES \
+ X("quit", 0, NOSW) \
+ X("replace", 0, YESW) \
+ X("list", 0, LISTDSW) \
+ X("refile +folder", 0, REFILSW) \
+ X("new", 0, NEWSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DISPO);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DISPO, aqrnl);
+#undef X
static struct swit aqrl[] = {
- { "quit", 0 },
- { "replace", 0 },
- { "list", 0 },
- { "refile +folder", 0 },
- { NULL, 0 }
+ { "quit", 0, NOSW },
+ { "replace", 0, YESW },
+ { "list", 0, LISTDSW },
+ { "refile +folder", 0, REFILSW },
+ { NULL, 0, 0 }
};
#define FORMAT "%<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>"
-static struct swit switches[] = {
-#define FORMSW 0
- { "form formatfile", 0 },
-#define FMTSW 1
- { "format string", 5 },
-#define WIDTHSW 2
- { "width columns", 0 },
-#define VERSIONSW 3
- { "version", 0 },
-#define HELPSW 4
- { "help", 0 },
- { NULL, 0 }
-};
+#define DP_SWITCHES \
+ X("form formatfile", 0, FORMSW) \
+ X("format string", 5, FMTSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DP);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DP, switches);
+#undef X
static struct format *fmt;
#define MAXFOLDERS 100
-static struct swit switches[] = {
-#define SEQSW 0
- { "sequence name", 0 },
-#define ALLSW 1
- { "all", 0 },
-#define NOALLSW 2
- { "noall", 0 },
-#define RECURSE 3
- { "recurse", 0 },
-#define NORECURSE 4
- { "norecurse", 0 },
-#define SHOWZERO 5
- { "showzero", 0 },
-#define NOSHOWZERO 6
- { "noshowzero", 0 },
-#define ALPHASW 7
- { "alpha", 0 },
-#define NOALPHASW 8
- { "noalpha", 0 },
-#define FASTSW 9
- { "fast", 0 },
-#define NOFASTSW 10
- { "nofast", 0 },
-#define TOTALSW 11
- { "total", -5 },
-#define NOTOTALSW 12
- { "nototal", -7 },
-#define VERSIONSW 13
- { "version", 0 },
-#define HELPSW 14
- { "help", 0 },
- { NULL, 0 }
-};
+#define FLIST_SWITCHES \
+ X("sequence name", 0, SEQSW) \
+ X("all", 0, ALLSW) \
+ X("noall", 0, NOALLSW) \
+ X("recurse", 0, RECURSE) \
+ X("norecurse", 0, NORECURSE) \
+ X("showzero", 0, SHOWZERO) \
+ X("noshowzero", 0, NOSHOWZERO) \
+ X("alpha", 0, ALPHASW) \
+ X("noalpha", 0, NOALPHASW) \
+ X("fast", 0, FASTSW) \
+ X("nofast", 0, NOFASTSW) \
+ X("total", -5, TOTALSW) \
+ X("nototal", -7, NOTOTALSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FLIST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FLIST, switches);
+#undef X
struct Folder {
char *name; /* name of folder */
#include <h/fmt_compile.h>
#include <h/scansbr.h>
-static struct swit switches[] = {
-#define FORMSW 0
- { "form formatfile", 0 },
-#define FMTSW 1
- { "format string", 5 },
-#define VERSIONSW 2
- { "version", 0 },
-#define HELPSW 3
- { "help", 0 },
- { NULL, 0 }
-};
+#define FMTDUMP_SWITCHES \
+ X("form formatfile", 0, FORMSW) \
+ X("format string", 5, FMTSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FMTDUMP);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FMTDUMP, switches);
+#undef X
/* for assignlabel */
static struct format *lvec[128];
case FT_FORMATADDR: return("FORMATADDR");
case FT_CONCATADDR: return("CONCATADDR");
case FT_MYMBOX: return("MYMBOX");
-#ifdef FT_ADDTOSEQ
- case FT_ADDTOSEQ: return("ADDTOSEQ");
-#endif
case FT_SAVESTR: return("SAVESTR");
#ifdef FT_PAUSE
case FT_PAUSE: return ("PAUSE");
#include <h/utils.h>
#include <errno.h>
-static struct swit switches[] = {
-#define ALLSW 0
- { "all", 0 },
-#define NALLSW 1
- { "noall", 0 },
-#define CREATSW 2
- { "create", 0 },
-#define NCREATSW 3
- { "nocreate", 0 },
-#define FASTSW 4
- { "fast", 0 },
-#define NFASTSW 5
- { "nofast", 0 },
-#define HDRSW 6
- { "header", 0 },
-#define NHDRSW 7
- { "noheader", 0 },
-#define PACKSW 8
- { "pack", 0 },
-#define NPACKSW 9
- { "nopack", 0 },
-#define VERBSW 10
- { "verbose", 0 },
-#define NVERBSW 11
- { "noverbose", 0 },
-#define RECURSW 12
- { "recurse", 0 },
-#define NRECRSW 13
- { "norecurse", 0 },
-#define TOTALSW 14
- { "total", 0 },
-#define NTOTLSW 15
- { "nototal", 0 },
-#define LISTSW 16
- { "list", 0 },
-#define NLISTSW 17
- { "nolist", 0 },
-#define PRNTSW 18
- { "print", 0 },
-#define NPRNTSW 19
- { "noprint", -4 },
-#define PUSHSW 20
- { "push", 0 },
-#define POPSW 21
- { "pop", 0 },
-#define VERSIONSW 22
- { "version", 0 },
-#define HELPSW 23
- { "help", 0 },
- { NULL, 0 }
-};
+#define FOLDER_SWITCHES \
+ X("all", 0, ALLSW) \
+ X("noall", 0, NALLSW) \
+ X("create", 0, CREATSW) \
+ X("nocreate", 0, NCREATSW) \
+ X("fast", 0, FASTSW) \
+ X("nofast", 0, NFASTSW) \
+ X("header", 0, HDRSW) \
+ X("noheader", 0, NHDRSW) \
+ X("pack", 0, PACKSW) \
+ X("nopack", 0, NPACKSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("recurse", 0, RECURSW) \
+ X("norecurse", 0, NRECRSW) \
+ X("total", 0, TOTALSW) \
+ X("nototal", 0, NTOTLSW) \
+ X("list", 0, LISTSW) \
+ X("nolist", 0, NLISTSW) \
+ X("print", 0, PRNTSW) \
+ X("noprint", -4, NPRNTSW) \
+ X("push", 0, PUSHSW) \
+ X("pop", 0, POPSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FOLDER);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FOLDER, switches);
+#undef X
static int fshort = 0; /* output only folder names */
static int fcreat = 0; /* should we ask to create new folders? */
#define IFORMAT "digest-issue-%s"
#define VFORMAT "digest-volume-%s"
-static struct swit switches[] = {
-#define ANNOSW 0
- { "annotate", 0 },
-#define NANNOSW 1
- { "noannotate", 0 },
-#define DFOLDSW 2
- { "draftfolder +folder", 0 },
-#define DMSGSW 3
- { "draftmessage msg", 0 },
-#define NDFLDSW 4
- { "nodraftfolder", 0 },
-#define EDITRSW 5
- { "editor editor", 0 },
-#define NEDITSW 6
- { "noedit", 0 },
-#define FILTSW 7
- { "filter filterfile", 0 },
-#define FORMSW 8
- { "form formfile", 0 },
-#define FRMTSW 9
- { "format", 5 },
-#define NFRMTSW 10
- { "noformat", 7 },
-#define INPLSW 11
- { "inplace", 0 },
-#define NINPLSW 12
- { "noinplace", 0 },
-#define MIMESW 13
- { "mime", 0 },
-#define NMIMESW 14
- { "nomime", 0 },
-#define DGSTSW 15
- { "digest list", 0 },
-#define ISSUESW 16
- { "issue number", 0 },
-#define VOLUMSW 17
- { "volume number", 0 },
-#define WHATSW 18
- { "whatnowproc program", 0 },
-#define NWHATSW 19
- { "nowhatnowproc", 0 },
-#define BITSTUFFSW 20
- { "dashstuffing", 0 }, /* interface to mhl */
-#define NBITSTUFFSW 21
- { "nodashstuffing", 0 },
-#define VERSIONSW 22
- { "version", 0 },
-#define HELPSW 23
- { "help", 0 },
-#define FILESW 24
- { "file file", 4 }, /* interface from msh */
-#define BILDSW 25
- { "build", 5 }, /* interface from mhe */
-#define FROMSW 26
- { "from address", 0 },
-#define TOSW 27
- { "to address", 0 },
-#define CCSW 28
- { "cc address", 0 },
-#define SUBJECTSW 29
- { "subject text", 0 },
-#define FCCSW 30
- { "fcc mailbox", 0 },
-#define WIDTHSW 31
- { "width columns", 0 },
- { NULL, 0 }
-};
-
-static struct swit aqrnl[] = {
-#define NOSW 0
- { "quit", 0 },
-#define YESW 1
- { "replace", 0 },
-#define LISTDSW 2
- { "list", 0 },
-#define REFILSW 3
- { "refile +folder", 0 },
-#define NEWSW 4
- { "new", 0 },
- { NULL, 0 }
-};
+#define FORW_SWITCHES \
+ X("annotate", 0, ANNOSW) \
+ X("noannotate", 0, NANNOSW) \
+ X("draftfolder +folder", 0, DFOLDSW) \
+ X("draftmessage msg", 0, DMSGSW) \
+ X("nodraftfolder", 0, NDFLDSW) \
+ X("editor editor", 0, EDITRSW) \
+ X("noedit", 0, NEDITSW) \
+ X("filter filterfile", 0, FILTSW) \
+ X("form formfile", 0, FORMSW) \
+ X("format", 5, FRMTSW) \
+ X("noformat", 7, NFRMTSW) \
+ X("inplace", 0, INPLSW) \
+ X("noinplace", 0, NINPLSW) \
+ X("mime", 0, MIMESW) \
+ X("nomime", 0, NMIMESW) \
+ X("digest list", 0, DGSTSW) \
+ X("issue number", 0, ISSUESW) \
+ X("volume number", 0, VOLUMSW) \
+ X("whatnowproc program", 0, WHATSW) \
+ X("nowhatnowproc", 0, NWHATSW) \
+ X("dashstuffing", 0, BITSTUFFSW) /* interface to mhl */ \
+ X("nodashstuffing", 0, NBITSTUFFSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("file file", 4, FILESW) /* interface from msh */ \
+ X("build", 5, BILDSW) /* interface from mhe */ \
+ X("from address", 0, FROMSW) \
+ X("to address", 0, TOSW) \
+ X("cc address", 0, CCSW) \
+ X("subject text", 0, SUBJECTSW) \
+ X("fcc mailbox", 0, FCCSW) \
+ X("width columns", 0, WIDTHSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FORW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FORW, switches);
+#undef X
+
+#define DISPO_SWITCHES \
+ X("quit", 0, NOSW) \
+ X("replace", 0, YESW) \
+ X("list", 0, LISTDSW) \
+ X("refile +folder", 0, REFILSW) \
+ X("new", 0, NEWSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DISPO);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DISPO, aqrnl);
+#undef X
static struct swit aqrl[] = {
- { "quit", 0 },
- { "replace", 0 },
- { "list", 0 },
- { "refile +folder", 0 },
- { NULL, 0 }
+ { "quit", 0, NOSW },
+ { "replace", 0, YESW },
+ { "list", 0, LISTDSW },
+ { "refile +folder", 0, REFILSW },
+ { NULL, 0, 0 }
};
static char drft[BUFSIZ];
# define SASLminc(a) 0
#endif
-static struct swit switches[] = {
-#define AUDSW 0
- { "audit audit-file", 0 },
-#define NAUDSW 1
- { "noaudit", 0 },
-#define CHGSW 2
- { "changecur", 0 },
-#define NCHGSW 3
- { "nochangecur", 0 },
-#define FILESW 4
- { "file name", 0 },
-#define FORMSW 5
- { "form formatfile", 0 },
-#define FMTSW 6
- { "format string", 5 },
-#define HOSTSW 7
- { "host hostname", 0 },
-#define USERSW 8
- { "user username", 0 },
-#define PACKSW 9
- { "pack file", 0},
-#define NPACKSW 10
- { "nopack", 0 },
-#define PORTSW 11
- { "port name/number", 0 },
-#define SILSW 12
- { "silent", 0 },
-#define NSILSW 13
- { "nosilent", 0 },
-#define TRNCSW 14
- { "truncate", 0 },
-#define NTRNCSW 15
- { "notruncate", 0 },
-#define WIDTHSW 16
- { "width columns", 0 },
-#define VERSIONSW 17
- { "version", 0 },
-#define HELPSW 18
- { "help", 0 },
-#define SNOOPSW 19
- { "snoop", -5 },
-#define SASLSW 20
- { "sasl", SASLminc(-4) },
-#define NOSASLSW 21
- { "nosasl", SASLminc(-6) },
-#define SASLMECHSW 22
- { "saslmech", SASLminc(-8) },
-#define PROXYSW 23
- { "proxy command", 0 },
- { NULL, 0 }
-};
+#define INC_SWITCHES \
+ X("audit audit-file", 0, AUDSW) \
+ X("noaudit", 0, NAUDSW) \
+ X("changecur", 0, CHGSW) \
+ X("nochangecur", 0, NCHGSW) \
+ X("file name", 0, FILESW) \
+ X("form formatfile", 0, FORMSW) \
+ X("format string", 5, FMTSW) \
+ X("host hostname", 0, HOSTSW) \
+ X("user username", 0, USERSW) \
+ X("pack file", 0, PACKSW) \
+ X("nopack", 0, NPACKSW) \
+ X("port name/number", 0, PORTSW) \
+ X("silent", 0, SILSW) \
+ X("nosilent", 0, NSILSW) \
+ X("truncate", 0, TRNCSW) \
+ X("notruncate", 0, NTRNCSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("snoop", -5, SNOOPSW) \
+ X("sasl", SASLminc(-4), SASLSW) \
+ X("nosasl", SASLminc(-6), NOSASLSW) \
+ X("saslmech", SASLminc(-8), SASLMECHSW) \
+ X("proxy command", 0, PROXYSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(INC);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(INC, switches);
+#undef X
/*
* flags for the mail source
break;
}
-#if 0
- /* copy file from spool to tmp file */
- tmpfilenam = m_scratch ("", invo_name);
- if ((fd = creat (tmpfilenam, m_gmprot ())) == NOTOK)
- adios (tmpfilenam, "unable to create");
- chmod (tmpfilenam, m_gmprot ());
- if (!(in2 = fdopen (fd, "r+")))
- adios (tmpfilenam, "unable to access");
- cpymsg (in, in2);
-
- /* link message into folder */
- newmsg = folder_addmsg(mp, tmpfilenam);
-#endif
/* create scanline for new message */
switch (incerr = scan (in, msgnum + 1, msgnum + 1, nfs, width,
msgnum == hghnum && chgflag, 1, NULL, 0L, noisy)) {
}
-#if 0
-
-/*
- * Copy message message from spool into
- * temporary file. Massage the "From " line
- * while copying.
- */
-
-cpymsg (FILE *in, FILE *out)
-{
- int state;
- char *tmpbuf, name[NAMESZ];
-
- for (;;) {
- state = m_getfld (state, name, tmpbuf, rlwidth, in);
- switch (state) {
- case FLD:
- case FLDPLUS:
- break;
- case BODY:
- break;
- case LENERR:
- case FMTERR:
- break;
- case FILEEOF:
- break;
- default:
- }
- }
-}
-#endif /* if 0 */
-
-
static void
inc_done (int status)
{
#include <h/utils.h>
#include <pwd.h> /* structure for getpwuid() results */
-static struct swit switches[] = {
-#define AUTOSW 0
- { "auto", 0 },
-#define VERSIONSW 1
- { "version", 0 },
-#define HELPSW 2
- { "help", 0 },
-#define CHECKSW 3
- { "check", 1 },
- { NULL, 0 }
-};
+#define INSTALLMH_SWITCHES \
+ X("auto", 0, AUTOSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("check", 1, CHECKSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(INSTALLMH);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(INSTALLMH, switches);
+#undef X
/*
* static prototypes
#include <h/mh.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define ADDSW 0
- { "add", 0 },
-#define DELSW 1
- { "delete", 0 },
-#define LSTSW 2
- { "list", 0 },
-#define SEQSW 3
- { "sequence name", 0 },
-#define PUBLSW 4
- { "public", 0 },
-#define NPUBLSW 5
- { "nopublic", 0 },
-#define ZEROSW 6
- { "zero", 0 },
-#define NZEROSW 7
- { "nozero", 0 },
-#define VERSIONSW 8
- { "version", 0 },
-#define HELPSW 9
- { "help", 0 },
-#define DEBUGSW 10
- { "debug", -5 },
- { NULL, 0 }
-};
+#define MARK_SWITCHES \
+ X("add", 0, ADDSW) \
+ X("delete", 0, DELSW) \
+ X("list", 0, LSTSW) \
+ X("sequence name", 0, SEQSW) \
+ X("public", 0, PUBLSW) \
+ X("nopublic", 0, NPUBLSW) \
+ X("zero", 0, ZEROSW) \
+ X("nozero", 0, NZEROSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MARK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MARK, switches);
+#undef X
/*
* static prototypes
#include <h/mhcachesbr.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define CHECKSW 0
- { "check", 0 },
-#define NCHECKSW 1
- { "nocheck", 0 },
-#define DIRECTIVES 2
- { "directives", 0 },
-#define NDIRECTIVES 3
- { "nodirectives", 0 },
-#define EBCDICSW 4
- { "ebcdicsafe", 0 },
-#define NEBCDICSW 5
- { "noebcdicsafe", 0 },
-#define HEADSW 6
- { "headers", 0 },
-#define NHEADSW 7
- { "noheaders", 0 },
-#define LISTSW 8
- { "list", 0 },
-#define NLISTSW 9
- { "nolist", 0 },
-#define SIZESW 10
- { "realsize", 0 },
-#define NSIZESW 11
- { "norealsize", 0 },
-#define RFC934SW 12
- { "rfc934mode", 0 },
-#define NRFC934SW 13
- { "norfc934mode", 0 },
-#define VERBSW 14
- { "verbose", 0 },
-#define NVERBSW 15
- { "noverbose", 0 },
-#define RCACHESW 16
- { "rcache policy", 0 },
-#define WCACHESW 17
- { "wcache policy", 0 },
-#define CONTENTIDSW 18
- { "contentid", 0 },
-#define NCONTENTIDSW 19
- { "nocontentid", 0 },
-#define VERSIONSW 20
- { "version", 0 },
-#define HELPSW 21
- { "help", 0 },
-#define DEBUGSW 22
- { "debug", -5 },
- { NULL, 0 }
-};
+#define MHBUILD_SWITCHES \
+ X("check", 0, CHECKSW) \
+ X("nocheck", 0, NCHECKSW) \
+ X("directives", 0, DIRECTIVES) \
+ X("nodirectives", 0, NDIRECTIVES) \
+ X("headers", 0, HEADSW) \
+ X("noheaders", 0, NHEADSW) \
+ X("list", 0, LISTSW) \
+ X("nolist", 0, NLISTSW) \
+ X("realsize", 0, SIZESW) \
+ X("norealsize", 0, NSIZESW) \
+ X("rfc934mode", 0, RFC934SW) \
+ X("norfc934mode", 0, NRFC934SW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("rcache policy", 0, RCACHESW) \
+ X("wcache policy", 0, WCACHESW) \
+ X("contentid", 0, CONTENTIDSW) \
+ X("nocontentid", 0, NCONTENTIDSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHBUILD);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHBUILD, switches);
+#undef X
/* mhbuildsbr.c */
int debugsw = 0;
int verbosw = 0;
-int ebcdicsw = 0;
int listsw = 0;
int rfc934sw = 0;
int contentidsw = 1;
checksw = 0;
continue;
- case EBCDICSW:
- ebcdicsw++;
- continue;
- case NEBCDICSW:
- ebcdicsw = 0;
- continue;
-
case HEADSW:
headsw++;
continue;
extern int debugsw;
extern int verbosw;
-extern int ebcdicsw;
extern int listsw;
extern int rfc934sw;
extern int contentidsw;
}
-static char ebcdicsafe[0x100] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-
/*
* Fill out, or expand the various contents in the composition
* draft. Read-in any necessary files. Parse and execute any
int checklinelen = 0, linelen = 0; /* check for long lines */
int checkboundary = 0, boundaryclash = 0; /* check if clashes with multipart boundary */
int checklinespace = 0, linespace = 0; /* check if any line ends with space */
- int checkebcdic = 0, ebcdicunsafe = 0; /* check if contains ebcdic unsafe characters */
unsigned char *cp = NULL, buffer[BUFSIZ];
struct text *t = NULL;
FILE *in = NULL;
check8bit = 1;
checkboundary = 1;
if (ct->c_subtype == TEXT_PLAIN) {
- checkebcdic = 0;
checklinelen = 0;
checklinespace = 0;
} else {
- checkebcdic = ebcdicsw;
checklinelen = 1;
checklinespace = 1;
}
case CT_APPLICATION:
check8bit = 1;
- checkebcdic = ebcdicsw;
checklinelen = 1;
checklinespace = 1;
checkboundary = 1;
case CT_MESSAGE:
check8bit = 0;
- checkebcdic = 0;
checklinelen = 0;
checklinespace = 0;
* since we are forcing use of base64.
*/
check8bit = 0;
- checkebcdic = 0;
checklinelen = 0;
checklinespace = 0;
checkboundary = 0;
contains8bit = 1;
check8bit = 0; /* no need to keep checking */
}
- /*
- * Check if character is ebcdic-safe. We only check
- * this if also checking for 8bit data.
- */
- if (checkebcdic && !ebcdicsafe[*cp & 0xff]) {
- ebcdicunsafe = 1;
- checkebcdic = 0; /* no need to keep checking */
- }
}
}
*ep = cp;
}
- if (contains8bit || ebcdicunsafe || linelen || linespace || checksw)
+ if (contains8bit || linelen || linespace || checksw)
ct->c_encoding = CE_QUOTED;
else
ct->c_encoding = CE_7BIT;
case CT_APPLICATION:
/* For application type, use base64, except when postscript */
- if (contains8bit || ebcdicunsafe || linelen || linespace || checksw)
+ if (contains8bit || linelen || linespace || checksw)
ct->c_encoding = (ct->c_subtype == APPLICATION_POSTSCRIPT)
? CE_QUOTED : CE_BASE64;
else
switch (ct->c_encoding) {
case CE_7BIT:
/* Nothing to output */
-#if 0
- np = add (ENCODING_FIELD, NULL);
- vp = concat (" ", "7bit", "\n", NULL);
- add_header (ct, np, vp);
-#endif
break;
case CE_8BIT:
return;
}
-/* THIS NEEDS TO BE FIXED */
-#if 0
- if (ct->c_ceopenfnx == openMail) {
- advise (NULL, "a radish may no know Greek, but I do...");
- return;
- }
-#endif
-
if (find_cache (NULL, wcachesw != CACHE_NEVER ? wcachesw : CACHE_ASK,
&cachetype, ct->c_id, cachefile, sizeof(cachefile))
== NOTOK) {
#include <h/mhcachesbr.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define CHECKSW 0
- { "check", 0 },
-#define NCHECKSW 1
- { "nocheck", 0 },
-#define HEADSW 2
- { "headers", 0 },
-#define NHEADSW 3
- { "noheaders", 0 },
-#define SIZESW 4
- { "realsize", 0 },
-#define NSIZESW 5
- { "norealsize", 0 },
-#define VERBSW 6
- { "verbose", 0 },
-#define NVERBSW 7
- { "noverbose", 0 },
-#define FILESW 8 /* interface from show */
- { "file file", 0 },
-#define PARTSW 9
- { "part number", 0 },
-#define TYPESW 10
- { "type content", 0 },
-#define RCACHESW 11
- { "rcache policy", 0 },
-#define WCACHESW 12
- { "wcache policy", 0 },
-#define VERSIONSW 13
- { "version", 0 },
-#define HELPSW 14
- { "help", 0 },
-
-/*
- * switches for debugging
- */
-#define DEBUGSW 15
- { "debug", -5 },
- { NULL, 0 }
-};
+#define MHLIST_SWITCHES \
+ X("check", 0, CHECKSW) \
+ X("nocheck", 0, NCHECKSW) \
+ X("headers", 0, HEADSW) \
+ X("noheaders", 0, NHEADSW) \
+ X("realsize", 0, SIZESW) \
+ X("norealsize", 0, NSIZESW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("file file", 0, FILESW) \
+ X("part number", 0, PARTSW) \
+ X("type content", 0, TYPESW) \
+ X("rcache policy", 0, RCACHESW) \
+ X("wcache policy", 0, WCACHESW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHLIST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHLIST, switches);
+#undef X
/* mhparse.c */
#define QUOTE '\\'
-static struct swit mhlswitches[] = {
-#define BELLSW 0
- { "bell", 0 },
-#define NBELLSW 1
- { "nobell", 0 },
-#define CLRSW 2
- { "clear", 0 },
-#define NCLRSW 3
- { "noclear", 0 },
-#define FOLDSW 4
- { "folder +folder", 0 },
-#define FORMSW 5
- { "form formfile", 0 },
-#define PROGSW 6
- { "moreproc program", 0 },
-#define NPROGSW 7
- { "nomoreproc", 0 },
-#define LENSW 8
- { "length lines", 0 },
-#define WIDTHSW 9
- { "width columns", 0 },
-#define SLEEPSW 10
- { "sleep seconds", 0 },
-#define BITSTUFFSW 11
- { "dashstuffing", -12 }, /* interface from forw */
-#define NBITSTUFFSW 12
- { "nodashstuffing", -14 }, /* interface from forw */
-#define VERSIONSW 13
- { "version", 0 },
-#define HELPSW 14
- { "help", 0 },
-#define FORW1SW 15
- { "forward", -7 }, /* interface from forw */
-#define FORW2SW 16
- { "forwall", -7 }, /* interface from forw */
-#define DGSTSW 17
- { "digest list", -6 },
-#define VOLUMSW 18
- { "volume number", -6 },
-#define ISSUESW 19
- { "issue number", -5 },
-#define NBODYSW 20
- { "nobody", -6 },
-#define FMTPROCSW 21
- { "fmtproc program", 0 },
-#define NFMTPROCSW 22
- { "nofmtproc", 0 },
- { NULL, 0 }
-};
+#define MHL_SWITCHES \
+ X("bell", 0, BELLSW) \
+ X("nobell", 0, NBELLSW) \
+ X("clear", 0, CLRSW) \
+ X("noclear", 0, NCLRSW) \
+ X("folder +folder", 0, FOLDSW) \
+ X("form formfile", 0, FORMSW) \
+ X("moreproc program", 0, PROGSW) \
+ X("nomoreproc", 0, NPROGSW) \
+ X("length lines", 0, LENSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("sleep seconds", 0, SLEEPSW) \
+ X("dashstuffing", -12, BITSTUFFSW) /* interface from forw */ \
+ X("nodashstuffing", -14, NBITSTUFFSW) /* interface from forw */ \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("forward", -7, FORW1SW) /* interface from forw */ \
+ X("forwall", -7, FORW2SW) /* interface from forw */ \
+ X("digest list", -6, DGSTSW) \
+ X("volume number", -6, VOLUMSW) \
+ X("issue number", -5, ISSUESW) \
+ X("nobody", -6, NBODYSW) \
+ X("fmtproc program", 0, FMTPROCSW) \
+ X("nofmtproc", 0, NFMTPROCSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHL);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHL, mhlswitches);
+#undef X
#define NOCOMPONENT 0x000001 /* don't show component name */
#define UPPERCASE 0x000002 /* display in all upper case */
#include <h/mhcachesbr.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define AUTOSW 0
- { "auto", 0 },
-#define NAUTOSW 1
- { "noauto", 0 },
-#define CACHESW 2
- { "cache", 0 },
-#define NCACHESW 3
- { "nocache", 0 },
-#define CHECKSW 4
- { "check", 0 },
-#define NCHECKSW 5
- { "nocheck", 0 },
-#define HEADSW 6
- { "headers", 0 },
-#define NHEADSW 7
- { "noheaders", 0 },
-#define LISTSW 8
- { "list", 0 },
-#define NLISTSW 9
- { "nolist", 0 },
-#define PAUSESW 10
- { "pause", 0 },
-#define NPAUSESW 11
- { "nopause", 0 },
-#define SIZESW 12
- { "realsize", 0 },
-#define NSIZESW 13
- { "norealsize", 0 },
-#define SERIALSW 14
- { "serialonly", 0 },
-#define NSERIALSW 15
- { "noserialonly", 0 },
-#define SHOWSW 16
- { "show", 0 },
-#define NSHOWSW 17
- { "noshow", 0 },
-#define STORESW 18
- { "store", 0 },
-#define NSTORESW 19
- { "nostore", 0 },
-#define VERBSW 20
- { "verbose", 0 },
-#define NVERBSW 21
- { "noverbose", 0 },
-#define FILESW 22 /* interface from show */
- { "file file", 0 },
-#define FORMSW 23
- { "form formfile", 0 },
-#define PARTSW 24
- { "part number", 0 },
-#define TYPESW 25
- { "type content", 0 },
-#define RCACHESW 26
- { "rcache policy", 0 },
-#define WCACHESW 27
- { "wcache policy", 0 },
-#define VERSIONSW 28
- { "version", 0 },
-#define HELPSW 29
- { "help", 0 },
-
-/*
- * switches for debugging
- */
-#define DEBUGSW 30
- { "debug", -5 },
-
-/*
- * switches for moreproc/mhlproc
- */
-#define PROGSW 31
- { "moreproc program", -4 },
-#define NPROGSW 32
- { "nomoreproc", -3 },
-#define LENSW 33
- { "length lines", -4 },
-#define WIDTHSW 34
- { "width columns", -4 },
-
-/*
- * switches for mhbuild
- */
-#define BUILDSW 35
- { "build", -5 },
-#define NBUILDSW 36
- { "nobuild", -7 },
-#define EBCDICSW 37
- { "ebcdicsafe", -10 },
-#define NEBCDICSW 38
- { "noebcdicsafe", -12 },
-#define RFC934SW 39
- { "rfc934mode", -10 },
-#define NRFC934SW 40
- { "norfc934mode", -12 },
- { NULL, 0 }
-};
+#define MHN_SWITCHES \
+ X("auto", 0, AUTOSW) \
+ X("noauto", 0, NAUTOSW) \
+ X("cache", 0, CACHESW) \
+ X("nocache", 0, NCACHESW) \
+ X("check", 0, CHECKSW) \
+ X("nocheck", 0, NCHECKSW) \
+ X("headers", 0, HEADSW) \
+ X("noheaders", 0, NHEADSW) \
+ X("list", 0, LISTSW) \
+ X("nolist", 0, NLISTSW) \
+ X("pause", 0, PAUSESW) \
+ X("nopause", 0, NPAUSESW) \
+ X("realsize", 0, SIZESW) \
+ X("norealsize", 0, NSIZESW) \
+ X("serialonly", 0, SERIALSW) \
+ X("noserialonly", 0, NSERIALSW) \
+ X("show", 0, SHOWSW) \
+ X("noshow", 0, NSHOWSW) \
+ X("store", 0, STORESW) \
+ X("nostore", 0, NSTORESW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("file file", 0, FILESW) \
+ X("form formfile", 0, FORMSW) \
+ X("part number", 0, PARTSW) \
+ X("type content", 0, TYPESW) \
+ X("rcache policy", 0, RCACHESW) \
+ X("wcache policy", 0, WCACHESW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ /* \
+ * for debugging \
+ */ \
+ X("debug", -5, DEBUGSW) \
+ /* \
+ * switches for moreproc/mhlproc \
+ */ \
+ X("moreproc program", -4, PROGSW) \
+ X("nomoreproc", -3, NPROGSW) \
+ X("length lines", -4, LENSW) \
+ X("width columns", -4, WIDTHSW) \
+ /* \
+ * switches for mhbuild \
+ */ \
+ X("build", -5, BUILDSW) \
+ X("nobuild", -7, NBUILDSW) \
+ X("rfc934mode", -10, RFC934SW) \
+ X("norfc934mode", -12, NRFC934SW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHN);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHN, switches);
+#undef X
/* mhparse.c */
* variables for mhbuild (mhn -build)
*/
static int buildsw = 0;
-static int ebcdicsw = 0;
static int rfc934sw = 0;
/*
case NRFC934SW:
rfc934sw = -1;
continue;
- case EBCDICSW:
- ebcdicsw = 1;
- continue;
- case NEBCDICSW:
- ebcdicsw = -1;
- continue;
case VERBSW:
verbosw = 1;
vecp = 0;
vec[vecp++] = "mhbuild";
- if (ebcdicsw == 1)
- vec[vecp++] = "-ebcdicsafe";
- else if (ebcdicsw == -1)
- vec[vecp++] = "-noebcdicsafe";
-
if (rfc934sw == 1)
vec[vecp++] = "-rfc934mode";
else if (rfc934sw == -1)
vecp = 0;
vec[vecp++] = "mhbuild";
- if (ebcdicsw == 1)
- vec[vecp++] = "-ebcdicsafe";
- else if (ebcdicsw == -1)
- vec[vecp++] = "-noebcdicsafe";
-
if (rfc934sw == 1)
vec[vecp++] = "-rfc934mode";
else if (rfc934sw == -1)
#include <h/mhparse.h>
-extern int ebcdicsw;
-
-static char ebcdicsafe[0x100] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
/*
* prototypes
*/
break;
default:
- if (*cp < '!' || *cp > '~'
- || (ebcdicsw && !ebcdicsafe[*cp & 0xff]))
+ if (*cp < '!' || *cp > '~')
goto three_print;
putc (*cp, out);
n++;
char *sbackup = BACKUP_PREFIX;
-static struct swit switches[] = {
-#define COMPSW 0
- { "components", 0 },
-#define NCOMPSW 1
- { "nocomponents", 0 },
-#define ALLSW 2
- { "all", 0 },
-#define VERSIONSW 3
- { "version", 0 },
-#define HELPSW 4
- { "help", 0 },
-#define DEBUGSW 5
- { "debug", 5 },
- { NULL, 0 }
-};
+#define MHPARAM_SWITCHES \
+ X("components", 0, COMPSW) \
+ X("nocomponents", 0, NCOMPSW) \
+ X("all", 0, ALLSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("debug", 5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHPARAM);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHPARAM, switches);
+#undef X
struct proc {
char *p_name;
*/
if (ct->c_encoding != CE_7BIT && ct->c_encoding != CE_8BIT
&& ct->c_encoding != CE_BINARY) {
+ /* Copy the Content-Transfer-Encoding header field body so we can
+ remove any trailing whitespace and leading blanks from it. */
+ char *cte = add (ct->c_celine ? ct->c_celine : "(null)", NULL);
+
+ bp = cte + strlen (cte) - 1;
+ while (bp >= cte && isspace (*bp)) *bp-- = '\0';
+ for (bp = cte; *bp && isblank (*bp); ++bp) continue;
+
admonish (NULL,
- "\"%s/%s\" type in message %s must be encoded in 7bit, 8bit, or binary",
- ci->ci_type, ci->ci_subtype, ct->c_file);
+ "\"%s/%s\" type in message %s must be encoded in\n"
+ "7bit, 8bit, or binary, per RFC 2045 (6.4). One workaround "
+ "is to\nmanually edit the file and change the \"%s\"\n"
+ "Content-Transfer-Encoding to one of those. For now",
+ ci->ci_type, ci->ci_subtype, ct->c_file, bp);
+ free (cte);
+
return NOTOK;
}
#include <h/mh.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define VERSIONSW 0
- { "version", 0 },
-#define HELPSW 1
- { "help", 0 },
- { NULL, 0 }
-};
+#define MHPATH_SWITCHES \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHPATH);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHPATH, switches);
+#undef X
int
main(int argc, char **argv)
#include <h/mhcachesbr.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define CHECKSW 0
- { "check", 0 },
-#define NCHECKSW 1
- { "nocheck", 0 },
-#define PAUSESW 2
- { "pause", 0 },
-#define NPAUSESW 3
- { "nopause", 0 },
-#define SERIALSW 4
- { "serialonly", 0 },
-#define NSERIALSW 5
- { "noserialonly", 0 },
-#define VERBSW 6
- { "verbose", 0 },
-#define NVERBSW 7
- { "noverbose", 0 },
-#define FILESW 8 /* interface from show */
- { "file file", 0 },
-#define FORMSW 9
- { "form formfile", 0 },
-#define PARTSW 10
- { "part number", 0 },
-#define TYPESW 11
- { "type content", 0 },
-#define RCACHESW 12
- { "rcache policy", 0 },
-#define WCACHESW 13
- { "wcache policy", 0 },
-#define VERSIONSW 14
- { "version", 0 },
-#define HELPSW 15
- { "help", 0 },
-
-/*
- * switches for moreproc/mhlproc
- */
-#define PROGSW 16
- { "moreproc program", -4 },
-#define NPROGSW 17
- { "nomoreproc", -3 },
-#define LENSW 18
- { "length lines", -4 },
-#define WIDTHSW 19
- { "width columns", -4 },
-
-/*
- * switches for debugging
- */
-#define DEBUGSW 20
- { "debug", -5 },
- { NULL, 0 }
-};
+#define MHSHOW_SWITCHES \
+ X("check", 0, CHECKSW) \
+ X("nocheck", 0, NCHECKSW) \
+ X("pause", 0, PAUSESW) \
+ X("nopause", 0, NPAUSESW) \
+ X("serialonly", 0, SERIALSW) \
+ X("noserialonly", 0, NSERIALSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("file file", 0, FILESW) \
+ X("form formfile", 0, FORMSW) \
+ X("part number", 0, PARTSW) \
+ X("type content", 0, TYPESW) \
+ X("rcache policy", 0, RCACHESW) \
+ X("wcache policy", 0, WCACHESW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ /* \
+ * switches for moreproc/mhlproc \
+ */ \
+ X("moreproc program", -4, PROGSW) \
+ X("nomoreproc", -3, NPROGSW) \
+ X("length lines", -4, LENSW) \
+ X("width columns", -4, WIDTHSW) \
+ /* \
+ * switches for debugging \
+ */ \
+ X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHSHOW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHSHOW, switches);
+#undef X
/* mhparse.c */
return OK;
return show_switch (p, serial, alternate);
-
-#if 0
- content_error (NULL, p, "don't know how to display content");
- return NOTOK;
-#endif
}
#include <h/mhcachesbr.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define AUTOSW 0
- { "auto", 0 },
-#define NAUTOSW 1
- { "noauto", 0 },
-#define CHECKSW 2
- { "check", 0 },
-#define NCHECKSW 3
- { "nocheck", 0 },
-#define VERBSW 4
- { "verbose", 0 },
-#define NVERBSW 5
- { "noverbose", 0 },
-#define FILESW 6 /* interface from show */
- { "file file", 0 },
-#define PARTSW 7
- { "part number", 0 },
-#define TYPESW 8
- { "type content", 0 },
-#define RCACHESW 9
- { "rcache policy", 0 },
-#define WCACHESW 10
- { "wcache policy", 0 },
-#define VERSIONSW 11
- { "version", 0 },
-#define HELPSW 12
- { "help", 0 },
-#define CLOBBERSW 13
- { "clobber always|auto|suffix|ask|never", 0 },
-
-/*
- * switches for debugging
- */
-#define DEBUGSW 14
- { "debug", -5 },
- { NULL, 0 }
-};
+#define MHSTORE_SWITCHES \
+ X("auto", 0, AUTOSW) \
+ X("noauto", 0, NAUTOSW) \
+ X("check", 0, CHECKSW) \
+ X("nocheck", 0, NCHECKSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("file file", 0, FILESW) /* interface from show */ \
+ X("part number", 0, PARTSW) \
+ X("type content", 0, TYPESW) \
+ X("rcache policy", 0, RCACHESW) \
+ X("wcache policy", 0, WCACHESW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("clobber always|auto|suffix|ask|never", 0, CLOBBERSW) \
+ X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHSTORE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHSTORE, switches);
+#undef X
int save_clobber_policy (const char *);
if (stat (file, &st) == OK) {
enum answers { NMH_YES, NMH_NO, NMH_RENAME };
static struct swit answer[4] = {
- { "yes", 0 }, { "no", 0 }, { "rename", 0 }, { NULL, 0 } };
+ { "yes", 0, NMH_YES }, { "no", 0, NMH_NO }, { "rename", 0, NMH_RENAME }, { NULL, 0, 0 } };
char **ans;
if (isatty (fileno (stdin))) {
#include <h/mhcachesbr.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define CHECKSW 0
- { "check", 0 },
-#define NCHECKSW 1
- { "nocheck", 0 },
-#define VERBSW 2
- { "verbose", 0 },
-#define NVERBSW 3
- { "noverbose", 0 },
-#define FILESW 4
- { "file file", 0 },
-#define OUTFILESW 5
- { "outfile file", 0 },
-#define PARTSW 6
- { "part number", 0 },
-#define TYPESW 7
- { "type content", 0 },
-#define RCACHESW 8
- { "rcache policy", 0 },
-#define WCACHESW 9
- { "wcache policy", 0 },
-#define VERSIONSW 10
- { "version", 0 },
-#define HELPSW 11
- { "help", 0 },
+#define MHTEST_SWITCHES \
+ X("check", 0, CHECKSW) \
+ X("nocheck", 0, NCHECKSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("file file", 0, FILESW) \
+ X("outfile file", 0, OUTFILESW) \
+ X("part number", 0, PARTSW) \
+ X("type content", 0, TYPESW) \
+ X("rcache policy", 0, RCACHESW) \
+ X("wcache policy", 0, WCACHESW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHTEST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHTEST, switches);
+#undef X
-/*
- * switches for debugging
- */
-#define DEBUGSW 12
- { "debug", -5 },
- { NULL, 0 }
-};
-
-
-int ebcdicsw = 0; /* hack for linking purposes */
/* mhparse.c */
extern char *tmp; /* directory to place temp files */
# define SASLminc(a) 0
#endif
-static struct swit switches[] = {
-#define DATESW 0
- { "date", 0 },
-#define NDATESW 1
- { "nodate", 0 },
-#define NOTESW 2
- { "notify type", 0 },
-#define NNOTESW 3
- { "nonotify type", 0 },
-#define HOSTSW 4
- { "host hostname", 0 },
-#define USERSW 5
- { "user username", 0 },
-#define PORTSW 6
- { "port name/number", 0 },
-#define VERSIONSW 7
- { "version", 0 },
-#define HELPSW 8
- { "help", 0 },
-#define SNOOPSW 9
- { "snoop", -5 },
-#define SASLSW 10
- { "sasl", SASLminc(-4) },
-#define SASLMECHSW 11
- { "saslmech", SASLminc(-5) },
-#define PROXYSW 12
- { "proxy command", 0 },
- { NULL, 0 }
-};
+#define MSGCHK_SWITCHES \
+ X("date", 0, DATESW) \
+ X("nodate", 0, NDATESW) \
+ X("notify type", 0, NOTESW) \
+ X("nonotify type", 0, NNOTESW) \
+ X("host hostname", 0, HOSTSW) \
+ X("user username", 0, USERSW) \
+ X("port name/number", 0, PORTSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("snoop", -5, SNOOPSW) \
+ X("sasl", SASLminc(-4), SASLSW) \
+ X("saslmech", SASLminc(-5), SASLMECHSW) \
+ X("proxy command", 0, PROXYSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MSGCHK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MSGCHK, switches);
+#undef X
/*
* Maximum numbers of users we can check (plus
}
-static struct swit ntswitches[] = {
-#define NALLSW 0
- { "all", 0 },
-#define NMAISW 1
- { "mail", 0 },
-#define NNMAISW 2
- { "nomail", 0 },
- { NULL, 0 }
-};
+#define NOTE_SWITCHES \
+ X("all", 0, NALLSW) \
+ X("mail", 0, NMAISW) \
+ X("nomail", 0, NNMAISW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(NOTE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(NOTE, ntswitches);
+#undef X
static int
#define QUOTE '\\' /* sigh */
-static struct swit switches[] = {
-#define IDSW 0
- { "idstart number", -7 }, /* interface from bbc */
-#define FDSW 1
- { "idstop number", -6 }, /* .. */
-#define QDSW 2
- { "idquit number", -6 }, /* .. */
-#define NMSW 3
- { "idname BBoard", -6 }, /* .. */
-#define PRMPTSW 4
- { "prompt string", 0 },
-#define SCANSW 5
- { "scan", 0 },
-#define NSCANSW 6
- { "noscan", 0 },
-#define READSW 7
- { "vmhread fd", -7 },
-#define WRITESW 8
- { "vmhwrite fd", -8 },
-#define PREADSW 9
- { "popread fd", -7 },
-#define PWRITSW 10
- { "popwrite fd", -8 },
-#define TCURSW 11
- { "topcur", 0 },
-#define NTCURSW 12
- { "notopcur", 0 },
-#define VERSIONSW 13
- { "version", 0 },
-#define HELPSW 14
- { "help", 0 },
- { NULL, 0 }
-};
+#define MSH_SWITCHES \
+ X("idstart number", -7, IDSW) /* interface from bbc */ \
+ X("idstop number", -6, FDSW) /* .. */ \
+ X("idquit number", -6, QDSW) /* .. */ \
+ X("idname BBoard", -6, NMSW) /* .. */ \
+ X("prompt string", 0, PRMPTSW) \
+ X("scan", 0, SCANSW) \
+ X("noscan", 0, NSCANSW) \
+ X("vmhread fd", -7, READSW) \
+ X("vmhwrite fd", -8, WRITESW) \
+ X("popread fd", -7, PREADSW) \
+ X("popwrite fd", -8, PWRITSW) \
+ X("topcur", 0, TCURSW) \
+ X("notopcur", 0, NTCURSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MSH);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MSH, switches);
+#undef X
static int mbx_style = MMDF_FORMAT;
}
-static struct swit mshcmds[] = {
-#define ADVCMD 0
- { "advance", -7 },
-#define ALICMD 1
- { "ali", 0 },
-#define EXPLCMD 2
- { "burst", 0 },
-#define COMPCMD 3
- { "comp", 0 },
-#define DISTCMD 4
- { "dist", 0 },
-#define EXITCMD 5
- { "exit", 0 },
-#define FOLDCMD 6
- { "folder", 0 },
-#define FORWCMD 7
- { "forw", 0 },
-#define HELPCMD 8
- { "help", 0 },
-#define INCMD 9
- { "inc", 0 },
-#define MARKCMD 10
- { "mark", 0 },
-#define MAILCMD 11
- { "mhmail", 0 },
-#define MHNCMD 12
- { "mhn", 0 },
-#define MSGKCMD 13
- { "msgchk", 0 },
-#define NEXTCMD 14
- { "next", 0 },
-#define PACKCMD 15
- { "packf", 0 },
-#define PICKCMD 16
- { "pick", 0 },
-#define PREVCMD 17
- { "prev", 0 },
-#define QUITCMD 18
- { "quit", 0 },
-#define FILECMD 19
- { "refile", 0 },
-#define REPLCMD 20
- { "repl", 0 },
-#define RMMCMD 21
- { "rmm", 0 },
-#define SCANCMD 22
- { "scan", 0 },
-#define SENDCMD 23
- { "send", 0 },
-#define SHOWCMD 24
- { "show", 0 },
-#define SORTCMD 25
- { "sortm", 0 },
-#define WHATCMD 26
- { "whatnow", 0 },
-#define WHOMCMD 27
- { "whom", 0 },
- { NULL, 0 }
-};
+#define MSHCMDS_SWITCHES \
+ X("advance", -7, ADVCMD) \
+ X("ali", 0, ALICMD) \
+ X("burst", 0, EXPLCMD) \
+ X("comp", 0, COMPCMD) \
+ X("dist", 0, DISTCMD) \
+ X("exit", 0, EXITCMD) \
+ X("folder", 0, FOLDCMD) \
+ X("forw", 0, FORWCMD) \
+ X("help", 0, HELPCMD) \
+ X("inc", 0, INCMD) \
+ X("mark", 0, MARKCMD) \
+ X("mhmail", 0, MAILCMD) \
+ X("mhn", 0, MHNCMD) \
+ X("msgchk", 0, MSGKCMD) \
+ X("next", 0, NEXTCMD) \
+ X("packf", 0, PACKCMD) \
+ X("pick", 0, PICKCMD) \
+ X("prev", 0, PREVCMD) \
+ X("quit", 0, QUITCMD) \
+ X("refile", 0, FILECMD) \
+ X("repl", 0, REPLCMD) \
+ X("rmm", 0, RMMCMD) \
+ X("scan", 0, SCANCMD) \
+ X("send", 0, SENDCMD) \
+ X("show", 0, SHOWCMD) \
+ X("sortm", 0, SORTCMD) \
+ X("whatnow", 0, WHATCMD) \
+ X("whom", 0, WHOMCMD) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MSHCMDS);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MSHCMDS, mshcmds);
+#undef X
static void
}
-static struct swit distswit[] = {
-#define DIANSW 0
- { "annotate", 0 },
-#define DINANSW 1
- { "noannotate", 0 },
-#define DIDFSW 2
- { "draftfolder +folder", 0 },
-#define DIDMSW 3
- { "draftmessage msg", 0 },
-#define DINDFSW 4
- { "nodraftfolder", 0 },
-#define DIEDTSW 5
- { "editor editor", 0 },
-#define DINEDSW 6
- { "noedit", 0 },
-#define DIFRMSW 7
- { "form formfile", 0 },
-#define DIINSW 8
- { "inplace", 0 },
-#define DININSW 9
- { "noinplace", 0 },
-#define DIWHTSW 10
- { "whatnowproc program", 0 },
-#define DINWTSW 11
- { "nowhatnowproc", 0 },
-#define DIHELP 12
- { "help", 0 },
- { NULL, 0 }
-};
+#define DIST_SWITCHES \
+ X("annotate", 0, DIANSW) \
+ X("noannotate", 0, DINANSW) \
+ X("draftfolder +folder", 0, DIDFSW) \
+ X("draftmessage msg", 0, DIDMSW) \
+ X("nodraftfolder", 0, DINDFSW) \
+ X("editor editor", 0, DIEDTSW) \
+ X("noedit", 0, DINEDSW) \
+ X("form formfile", 0, DIFRMSW) \
+ X("inplace", 0, DIINSW) \
+ X("noinplace", 0, DININSW) \
+ X("whatnowproc program", 0, DIWHTSW) \
+ X("nowhatnowproc", 0, DINWTSW) \
+ X("help", 0, DIHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DIST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DIST, distswit);
+#undef X
void
}
-static struct swit explswit[] = {
-#define EXINSW 0
- { "inplace", 0 },
-#define EXNINSW 1
- { "noinplace", 0 },
-#define EXQISW 2
- { "quiet", 0 },
-#define EXNQISW 3
- { "noquiet", 0 },
-#define EXVBSW 4
- { "verbose", 0 },
-#define EXNVBSW 5
- { "noverbose", 0 },
-#define EXHELP 6
- { "help", 0 },
- { NULL, 0 }
-};
+#define EXPLODE_SWITCHES \
+ X("inplace", 0, EXINSW) \
+ X("noinplace", 0, EXNINSW) \
+ X("quiet", 0, EXQISW) \
+ X("noquiet", 0, EXNQISW) \
+ X("verbose", 0, EXVBSW) \
+ X("noverbose", 0, EXNVBSW) \
+ X("help", 0, EXHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(EXPLODE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(EXPLODE, explswit);
+#undef X
void
}
-static struct swit fileswit[] = {
-#define FIDRFT 0
- { "draft", 0 },
-#define FILINK 1
- { "link", 0 },
-#define FINLINK 2
- { "nolink", 0 },
-#define FIPRES 3
- { "preserve", 0 },
-#define FINPRES 4
- { "nopreserve", 0 },
-#define FISRC 5
- { "src +folder", 0 },
-#define FIFILE 6
- { "file file", 0 },
-#define FIPROC 7
- { "rmmproc program", 0 },
-#define FINPRC 8
- { "normmproc", 0 },
-#define FIHELP 9
- { "help", 0 },
- { NULL, 0 }
-};
+#define FILE_SWITCHES \
+ X("draft", 0, FIDRFT) \
+ X("link", 0, FILINK) \
+ X("nolink", 0, FINLINK) \
+ X("preserve", 0, FIPRES) \
+ X("nopreserve", 0, FINPRES) \
+ X("src +folder", 0, FISRC) \
+ X("file file", 0, FIFILE) \
+ X("rmmproc program", 0, FIPROC) \
+ X("normmproc", 0, FINPRC) \
+ X("help", 0, FIHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FILE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FILE, fileswit);
+#undef X
void
}
-static struct swit foldswit[] = {
-#define FLALSW 0
- { "all", 0 },
-#define FLFASW 1
- { "fast", 0 },
-#define FLNFASW 2
- { "nofast", 0 },
-#define FLHDSW 3
- { "header", 0 },
-#define FLNHDSW 4
- { "noheader", 0 },
-#define FLPKSW 5
- { "pack", 0 },
-#define FLNPKSW 6
- { "nopack", 0 },
-#define FLRCSW 7
- { "recurse", 0 },
-#define FLNRCSW 8
- { "norecurse", 0 },
-#define FLTLSW 9
- { "total", 0 },
-#define FLNTLSW 10
- { "nototal", 0 },
-#define FLPRSW 11
- { "print", 0 },
-#define FLPUSW 12
- { "push", 0 },
-#define FLPOSW 13
- { "pop", 0 },
-#define FLLISW 14
- { "list", 0 },
-#define FLHELP 15
- { "help", 0 },
- { NULL, 0 }
-};
+#define FOLDER_SWITCHES \
+ X("all", 0, FLALSW) \
+ X("fast", 0, FLFASW) \
+ X("nofast", 0, FLNFASW) \
+ X("header", 0, FLHDSW) \
+ X("noheader", 0, FLNHDSW) \
+ X("pack", 0, FLPKSW) \
+ X("nopack", 0, FLNPKSW) \
+ X("recurse", 0, FLRCSW) \
+ X("norecurse", 0, FLNRCSW) \
+ X("total", 0, FLTLSW) \
+ X("nototal", 0, FLNTLSW) \
+ X("print", 0, FLPRSW) \
+ X("push", 0, FLPUSW) \
+ X("pop", 0, FLPOSW) \
+ X("list", 0, FLLISW) \
+ X("help", 0, FLHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FOLDER);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FOLDER, foldswit);
+#undef X
void
}
-static struct swit forwswit[] = {
-#define FOANSW 0
- { "annotate", 0 },
-#define FONANSW 1
- { "noannotate", 0 },
-#define FODFSW 2
- { "draftfolder +folder", 0 },
-#define FODMSW 3
- { "draftmessage msg", 0 },
-#define FONDFSW 4
- { "nodraftfolder", 0 },
-#define FOEDTSW 5
- { "editor editor", 0 },
-#define FONEDSW 6
- { "noedit", 0 },
-#define FOFTRSW 7
- { "filter filterfile", 0 },
-#define FOFRMSW 8
- { "form formfile", 0 },
-#define FOFTSW 9
- { "format", 5 },
-#define FONFTSW 10
- { "noformat", 7 },
-#define FOINSW 11
- { "inplace", 0 },
-#define FONINSW 12
- { "noinplace", 0 },
-#define FOMISW 13
- { "mime", 0 },
-#define FONMISW 14
- { "nomime", 0 },
-#define FOWHTSW 15
- { "whatnowproc program", 0 },
-#define FONWTSW 16
- { "nowhatnow", 0 },
-#define FOHELP 17
- { "help", 0 },
- { NULL, 0 }
-};
+#define FORW_SWITCHES \
+ X("annotate", 0, FOANSW) \
+ X("noannotate", 0, FONANSW) \
+ X("draftfolder +folder", 0, FODFSW) \
+ X("draftmessage msg", 0, FODMSW) \
+ X("nodraftfolder", 0, FONDFSW) \
+ X("editor editor", 0, FOEDTSW) \
+ X("noedit", 0, FONEDSW) \
+ X("filter filterfile", 0, FOFTRSW) \
+ X("form formfile", 0, FOFRMSW) \
+ X("format", 5, FOFTSW) \
+ X("noformat", 7, FONFTSW) \
+ X("inplace", 0, FOINSW) \
+ X("noinplace", 0, FONINSW) \
+ X("mime", 0, FOMISW) \
+ X("nomime", 0, FONMISW) \
+ X("whatnowproc program", 0, FOWHTSW) \
+ X("nowhatnow", 0, FONWTSW) \
+ X("help", 0, FOHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FORW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FORW, forwswit);
+#undef X
void
}
-static struct swit markswit[] = {
-#define MADDSW 0
- { "add", 0 },
-#define MDELSW 1
- { "delete", 0 },
-#define MLSTSW 2
- { "list", 0 },
-#define MSEQSW 3
- { "sequence name", 0 },
-#define MPUBSW 4
- { "public", 0 },
-#define MNPUBSW 5
- { "nopublic", 0 },
-#define MZERSW 6
- { "zero", 0 },
-#define MNZERSW 7
- { "nozero", 0 },
-#define MHELP 8
- { "help", 0 },
-#define MDBUGSW 9
- { "debug", -5 },
- { NULL, 0 }
-};
+#define MARK_SWITCHES \
+ X("add", 0, MADDSW) \
+ X("delete", 0, MDELSW) \
+ X("list", 0, MLSTSW) \
+ X("sequence name", 0, MSEQSW) \
+ X("public", 0, MPUBSW) \
+ X("nopublic", 0, MNPUBSW) \
+ X("zero", 0, MZERSW) \
+ X("nozero", 0, MNZERSW) \
+ X("help", 0, MHELP) \
+ X("debug", -5, MDBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MARK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MARK, markswit);
+#undef X
void
}
-static struct swit mhnswit[] = {
-#define MHNAUTOSW 0
- { "auto", 0 },
-#define MHNNAUTOSW 1
- { "noauto", 0 },
-#define MHNDEBUGSW 2
- { "debug", -5 },
-#define MHNEBCDICSW 3
- { "ebcdicsafe", 0 },
-#define MHNNEBCDICSW 4
- { "noebcdicsafe", 0 },
-#define MHNFORMSW 5
- { "form formfile", 4 },
-#define MHNHEADSW 6
- { "headers", 0 },
-#define MHNNHEADSW 7
- { "noheaders", 0 },
-#define MHNLISTSW 8
- { "list", 0 },
-#define MHNNLISTSW 9
- { "nolist", 0 },
-#define MHNPARTSW 10
- { "part number", 0 },
-#define MHNSIZESW 11
- { "realsize", 0 },
-#define MHNNSIZESW 12
- { "norealsize", 0 },
-#define MHNRFC934SW 13
- { "rfc934mode", 0 },
-#define MHNNRFC934SW 14
- { "norfc934mode", 0 },
-#define MHNSERIALSW 15
- { "serialonly", 0 },
-#define MHNNSERIALSW 16
- { "noserialonly", 0 },
-#define MHNSHOWSW 17
- { "show", 0 },
-#define MHNNSHOWSW 18
- { "noshow", 0 },
-#define MHNSTORESW 19
- { "store", 0 },
-#define MHNNSTORESW 20
- { "nostore", 0 },
-#define MHNTYPESW 21
- { "type content", 0 },
-#define MHNVERBSW 22
- { "verbose", 0 },
-#define MHNNVERBSW 23
- { "noverbose", 0 },
-#define MHNHELPSW 24
- { "help", 0 },
-#define MHNPROGSW 25
- { "moreproc program", -4 },
-#define MHNNPROGSW 26
- { "nomoreproc", -3 },
-#define MHNLENSW 27
- { "length lines", -4 },
-#define MHNWIDSW 28
- { "width columns", -4 },
- { NULL, 0 }
-};
+#define MHN_SWITCHES \
+ X("auto", 0, MHNAUTOSW) \
+ X("noauto", 0, MHNNAUTOSW) \
+ X("debug", -5, MHNDEBUGSW) \
+ X("form formfile", 4, MHNFORMSW) \
+ X("headers", 0, MHNHEADSW) \
+ X("noheaders", 0, MHNNHEADSW) \
+ X("list", 0, MHNLISTSW) \
+ X("nolist", 0, MHNNLISTSW) \
+ X("part number", 0, MHNPARTSW) \
+ X("realsize", 0, MHNSIZESW) \
+ X("norealsize", 0, MHNNSIZESW) \
+ X("rfc934mode", 0, MHNRFC934SW) \
+ X("norfc934mode", 0, MHNNRFC934SW) \
+ X("serialonly", 0, MHNSERIALSW) \
+ X("noserialonly", 0, MHNNSERIALSW) \
+ X("show", 0, MHNSHOWSW) \
+ X("noshow", 0, MHNNSHOWSW) \
+ X("store", 0, MHNSTORESW) \
+ X("nostore", 0, MHNNSTORESW) \
+ X("type content", 0, MHNTYPESW) \
+ X("verbose", 0, MHNVERBSW) \
+ X("noverbose", 0, MHNNVERBSW) \
+ X("help", 0, MHNHELPSW) \
+ X("moreproc program", -4, MHNPROGSW) \
+ X("nomoreproc", -3, MHNNPROGSW) \
+ X("length lines", -4, MHNLENSW) \
+ X("width columns", -4, MHNWIDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHN);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHN, mhnswit);
+#undef X
void
case MHNAUTOSW:
case MHNNAUTOSW:
case MHNDEBUGSW:
- case MHNEBCDICSW:
- case MHNNEBCDICSW:
case MHNHEADSW:
case MHNNHEADSW:
case MHNLISTSW:
}
-static struct swit packswit[] = {
-#define PAFISW 0
- { "file name", 0 },
-#define PAHELP 1
- { "help", 0 },
- { NULL, 0 }
-};
+#define PACK_SWITCHES \
+ X("file name", 0, PAFISW) \
+ X("help", 0, PAHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PACK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PACK, packswit);
+#undef X
static int mbx_style = MMDF_FORMAT;
}
-static struct swit pickswit[] = {
-#define PIANSW 0
- { "and", 0 },
-#define PIORSW 1
- { "or", 0 },
-#define PINTSW 2
- { "not", 0 },
-#define PILBSW 3
- { "lbrace", 0 },
-#define PIRBSW 4
- { "rbrace", 0 },
-#define PICCSW 5
- { "cc pattern", 0 },
-#define PIDASW 6
- { "date pattern", 0 },
-#define PIFRSW 7
- { "from pattern", 0 },
-#define PISESW 8
- { "search pattern", 0 },
-#define PISUSW 9
- { "subject pattern", 0 },
-#define PITOSW 10
- { "to pattern", 0 },
-#define PIOTSW 11
- { "-othercomponent pattern", 15 },
-#define PIAFSW 12
- { "after date", 0 },
-#define PIBFSW 13
- { "before date", 0 },
-#define PIDFSW 14
- { "datefield field", 5 },
-#define PISQSW 15
- { "sequence name", 0 },
-#define PIPUSW 16
- { "public", 0 },
-#define PINPUSW 17
- { "nopublic", 0 },
-#define PIZRSW 18
- { "zero", 0 },
-#define PINZRSW 19
- { "nozero", 0 },
-#define PILISW 20
- { "list", 0 },
-#define PINLISW 21
- { "nolist", 0 },
-#define PIHELP 22
- { "help", 0 },
- { NULL, 0 }
-};
+#define PICK_SWITCHES \
+ X("and", 0, PIANSW) \
+ X("or", 0, PIORSW) \
+ X("not", 0, PINTSW) \
+ X("lbrace", 0, PILBSW) \
+ X("rbrace", 0, PIRBSW) \
+ X("cc pattern", 0, PICCSW) \
+ X("date pattern", 0, PIDASW) \
+ X("from pattern", 0, PIFRSW) \
+ X("search pattern", 0, PISESW) \
+ X("subject pattern", 0, PISUSW) \
+ X("to pattern", 0, PITOSW) \
+ X("-othercomponent pattern", 15, PIOTSW) \
+ X("after date", 0, PIAFSW) \
+ X("before date", 0, PIBFSW) \
+ X("datefield field", 5, PIDFSW) \
+ X("sequence name", 0, PISQSW) \
+ X("public", 0, PIPUSW) \
+ X("nopublic", 0, PINPUSW) \
+ X("zero", 0, PIZRSW) \
+ X("nozero", 0, PINZRSW) \
+ X("list", 0, PILISW) \
+ X("nolist", 0, PINLISW) \
+ X("help", 0, PIHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PICK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PICK, pickswit);
+#undef X
void
}
-static struct swit replswit[] = {
-#define REANSW 0
- { "annotate", 0 },
-#define RENANSW 1
- { "noannotate", 0 },
-#define RECCSW 2
- { "cc type", 0 },
-#define RENCCSW 3
- { "nocc type", 0 },
-#define REDFSW 4
- { "draftfolder +folder", 0 },
-#define REDMSW 5
- { "draftmessage msg", 0 },
-#define RENDFSW 6
- { "nodraftfolder", 0 },
-#define REEDTSW 7
- { "editor editor", 0 },
-#define RENEDSW 8
- { "noedit", 0 },
-#define REFCCSW 9
- { "fcc +folder", 0 },
-#define REFLTSW 10
- { "filter filterfile", 0 },
-#define REFRMSW 11
- { "form formfile", 0 },
-#define REINSW 12
- { "inplace", 0 },
-#define RENINSW 13
- { "noinplace", 0 },
-#define REQUSW 14
- { "query", 0 },
-#define RENQUSW 15
- { "noquery", 0 },
-#define REWHTSW 16
- { "whatnowproc program", 0 },
-#define RENWTSW 17
- { "nowhatnow", 0 },
-#define REWIDSW 19
- { "width columns", 0 },
-#define REHELP 20
- { "help", 0 },
- { NULL, 0 }
-};
+#define REPL_SWITCHES \
+ X("annotate", 0, REANSW) \
+ X("noannotate", 0, RENANSW) \
+ X("cc type", 0, RECCSW) \
+ X("nocc type", 0, RENCCSW) \
+ X("draftfolder +folder", 0, REDFSW) \
+ X("draftmessage msg", 0, REDMSW) \
+ X("nodraftfolder", 0, RENDFSW) \
+ X("editor editor", 0, REEDTSW) \
+ X("noedit", 0, RENEDSW) \
+ X("fcc +folder", 0, REFCCSW) \
+ X("filter filterfile", 0, REFLTSW) \
+ X("form formfile", 0, REFRMSW) \
+ X("inplace", 0, REINSW) \
+ X("noinplace", 0, RENINSW) \
+ X("query", 0, REQUSW) \
+ X("noquery", 0, RENQUSW) \
+ X("whatnowproc program", 0, REWHTSW) \
+ X("nowhatnow", 0, RENWTSW) \
+ X("width columns", 0, REWIDSW) \
+ X("help", 0, REHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(REPL);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(REPL, replswit);
+#undef X
void
}
-static struct swit rmmswit[] = {
-#define RMHELP 0
- { "help", 0 },
- { NULL, 0 }
-};
+#define RMM_SWITCHES \
+ X("help", 0, RMHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RMM);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RMM, rmmswit);
+#undef X
void
}
-static struct swit scanswit[] = {
-#define SCCLR 0
- { "clear", 0 },
-#define SCNCLR 1
- { "noclear", 0 },
-#define SCFORM 2
- { "form formatfile", 0 },
-#define SCFMT 3
- { "format string", 5 },
-#define SCHEAD 4
- { "header", 0 },
-#define SCNHEAD 5
- { "noheader", 0 },
-#define SCWID 6
- { "width columns", 0 },
-#define SCHELP 7
- { "help", 0 },
- { NULL, 0 }
-};
+#define SCAN_SWITCHES \
+ X("clear", 0, SCCLR) \
+ X("noclear", 0, SCNCLR) \
+ X("form formatfile", 0, SCFORM) \
+ X("format string", 5, SCFMT) \
+ X("header", 0, SCHEAD) \
+ X("noheader", 0, SCNHEAD) \
+ X("width columns", 0, SCWID) \
+ X("help", 0, SCHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SCAN);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SCAN, scanswit);
+#undef X
void
}
-static struct swit showswit[] = {
-#define SHDRAFT 0
- { "draft", 5 },
-#define SHFORM 1
- { "form formfile", 4 },
-#define SHPROG 2
- { "moreproc program", 4 },
-#define SHNPROG 3
- { "nomoreproc", 3 },
-#define SHLEN 4
- { "length lines", 4 },
-#define SHWID 5
- { "width columns", 4 },
-#define SHSHOW 6
- { "showproc program", 4 },
-#define SHNSHOW 7
- { "noshowproc", 3 },
-#define SHHEAD 8
- { "header", 4 },
-#define SHNHEAD 9
- { "noheader", 3 },
-#define SHHELP 10
- { "help", 0 },
- { NULL, 0 }
-};
+#define SHOW_SWITCHES \
+ X("draft", 5, SHDRAFT) \
+ X("form formfile", 4, SHFORM) \
+ X("moreproc program", 4, SHPROG) \
+ X("nomoreproc", 3, SHNPROG) \
+ X("length lines", 4, SHLEN) \
+ X("width columns", 4, SHWID) \
+ X("showproc program", 4, SHSHOW) \
+ X("noshowproc", 3, SHNSHOW) \
+ X("header", 4, SHHEAD) \
+ X("noheader", 3, SHNHEAD) \
+ X("help", 0, SHHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SHOW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SHOW, showswit);
+#undef X
void
}
-static struct swit sortswit[] = {
-#define SODATE 0
- { "datefield field", 0 },
-#define SOSUBJ 1
- { "textfield field", 0 },
-#define SONSUBJ 2
- { "notextfield", 0 },
-#define SOLIMT 3
- { "limit days", 0 },
-#define SONLIMT 4
- { "nolimit", 0 },
-#define SOVERB 5
- { "verbose", 0 },
-#define SONVERB 6
- { "noverbose", 0 },
-#define SOHELP 7
- { "help", 0 },
- { NULL, 0 }
-};
+#define SORT_SWITCHES \
+ X("datefield field", 0, SODATE) \
+ X("textfield field", 0, SOSUBJ) \
+ X("notextfield", 0, SONSUBJ) \
+ X("limit days", 0, SOLIMT) \
+ X("nolimit", 0, SONLIMT) \
+ X("verbose", 0, SOVERB) \
+ X("noverbose", 0, SONVERB) \
+ X("help", 0, SOHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SORT);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SORT, sortswit);
+#undef X
void
#include <h/crawl_folders.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define MODESW 0
- { "mode", 1 },
-#define FOLDERSSW 1
- { "folders", 1 },
-#define VERSIONSW 2
- { "version", 1 },
-#define HELPSW 3
- { "help", 1 },
- { NULL, 0 }
-};
+#define NEW_SWITCHES \
+ X("mode", 1, MODESW) \
+ X("folders", 1, FOLDERSSW) \
+ X("version", 1, VERSIONSW) \
+ X("help", 1, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(NEW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(NEW, switches);
+#undef X
static enum { NEW, FNEXT, FPREV, UNSEEN } run_mode = NEW;
#include <h/utils.h>
#include <errno.h>
-static struct swit switches[] = {
-#define FILESW 0
- { "file name", 0 },
-#define MBOXSW 1
- { "mbox", 0 },
-#define MMDFSW 2
- { "mmdf", 0 },
-#define VERSIONSW 3
- { "version", 0 },
-#define HELPSW 4
- { "help", 0 },
- { NULL, 0 }
-};
+#define PACKF_SWITCHES \
+ X("file name", 0, FILESW) \
+ X("mbox", 0, MBOXSW) \
+ X("mmdf", 0, MMDFSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PACKF);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PACKF, switches);
+#undef X
static int md = NOTOK;
static int mbx_style = MBOX_FORMAT;
#include <h/picksbr.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define ANDSW 0
- { "and", 0 },
-#define ORSW 1
- { "or", 0 },
-#define NOTSW 2
- { "not", 0 },
-#define LBRSW 3
- { "lbrace", 0 },
-#define RBRSW 4
- { "rbrace", 0 },
-#define CCSW 5
- { "cc pattern", 0 },
-#define DATESW 6
- { "date pattern", 0 },
-#define FROMSW 7
- { "from pattern", 0 },
-#define SRCHSW 8
- { "search pattern", 0 },
-#define SUBJSW 9
- { "subject pattern", 0 },
-#define TOSW 10
- { "to pattern", 0 },
-#define OTHRSW 11
- { "-othercomponent pattern", 0 },
-#define AFTRSW 12
- { "after date", 0 },
-#define BEFRSW 13
- { "before date", 0 },
-#define DATFDSW 14
- { "datefield field", 5 },
-#define SEQSW 15
- { "sequence name", 0 },
-#define NSEQSW 16
- { "nosequence", 0 },
-#define PUBLSW 17
- { "public", 0 },
-#define NPUBLSW 18
- { "nopublic", 0 },
-#define ZEROSW 19
- { "zero", 0 },
-#define NZEROSW 20
- { "nozero", 0 },
-#define LISTSW 21
- { "list", 0 },
-#define NLISTSW 22
- { "nolist", 0 },
-#define VERSIONSW 23
- { "version", 0 },
-#define HELPSW 24
- { "help", 0 },
- { NULL, 0 }
-};
+#define PICK_SWITCHES \
+ X("and", 0, ANDSW) \
+ X("or", 0, ORSW) \
+ X("not", 0, NOTSW) \
+ X("lbrace", 0, LBRSW) \
+ X("rbrace", 0, RBRSW) \
+ X("cc pattern", 0, CCSW) \
+ X("date pattern", 0, DATESW) \
+ X("from pattern", 0, FROMSW) \
+ X("search pattern", 0, SRCHSW) \
+ X("subject pattern", 0, SUBJSW) \
+ X("to pattern", 0, TOSW) \
+ X("-othercomponent pattern", 0, OTHRSW) \
+ X("after date", 0, AFTRSW) \
+ X("before date", 0, BEFRSW) \
+ X("datefield field", 5, DATFDSW) \
+ X("sequence name", 0, SEQSW) \
+ X("nosequence", 0, NSEQSW) \
+ X("public", 0, PUBLSW) \
+ X("nopublic", 0, NPUBLSW) \
+ X("zero", 0, ZEROSW) \
+ X("nozero", 0, NZEROSW) \
+ X("list", 0, LISTSW) \
+ X("nolist", 0, NLISTSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PICK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PICK, switches);
+#undef X
static int listsw = -1;
#endif
#include <time.h>
-static struct swit parswit[] = {
-#define PRAND 0
- { "and", 0 },
-#define PROR 1
- { "or", 0 },
-#define PRNOT 2
- { "not", 0 },
-#define PRLBR 3
- { "lbrace", 0 },
-#define PRRBR 4
- { "rbrace", 0 },
-#define PRCC 5
- { "cc pattern", 0 },
-#define PRDATE 6
- { "date pattern", 0 },
-#define PRFROM 7
- { "from pattern", 0 },
-#define PRSRCH 8
- { "search pattern", 0 },
-#define PRSUBJ 9
- { "subject pattern", 0 },
-#define PRTO 10
- { "to pattern", 0 },
-#define PROTHR 11
- { "-othercomponent pattern", 15 },
-#define PRAFTR 12
- { "after date", 0 },
-#define PRBEFR 13
- { "before date", 0 },
-#define PRDATF 14
- { "datefield field", 5 },
- { NULL, 0 }
-};
+#define PARSE_SWITCHES \
+ X("and", 0, PRAND) \
+ X("or", 0, PROR) \
+ X("not", 0, PRNOT) \
+ X("lbrace", 0, PRLBR) \
+ X("rbrace", 0, PRRBR) \
+ X("cc pattern", 0, PRCC) \
+ X("date pattern", 0, PRDATE) \
+ X("from pattern", 0, PRFROM) \
+ X("search pattern", 0, PRSRCH) \
+ X("subject pattern", 0, PRSUBJ) \
+ X("to pattern", 0, PRTO) \
+ X("-othercomponent pattern", 15, PROTHR) \
+ X("after date", 0, PRAFTR) \
+ X("before date", 0, PRBEFR) \
+ X("datefield field", 5, PRDATF) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PARSE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PARSE, parswit);
+#undef X
/* DEFINITIONS FOR PATTERN MATCHING */
0 : Switch can't be abbreviated; switch shown in -help.
# : Switch can be abbreviated to # characters; switch shown in -help. */
-static struct swit switches[] = {
-#define ALIASW 0
- { "alias aliasfile", 0 },
-#define CHKSW 1
- { "check", -5 }, /* interface from whom */
-#define NCHKSW 2
- { "nocheck", -7 }, /* interface from whom */
-#define DEBUGSW 3
- { "debug", -5 },
-#define DISTSW 4
- { "dist", -4 }, /* interface from dist */
-#define FILTSW 5
- { "filter filterfile", 0 },
-#define NFILTSW 6
- { "nofilter", 0 },
-#define FRMTSW 7
- { "format", 0 },
-#define NFRMTSW 8
- { "noformat", 0 },
-#define LIBSW 9
- { "library directory", -7 }, /* interface from send, whom */
-#define MIMESW 10
- { "mime", 0 },
-#define NMIMESW 11
- { "nomime", 0 },
-#define MSGDSW 12
- { "msgid", 0 },
-#define NMSGDSW 13
- { "nomsgid", 0 },
-#define VERBSW 14
- { "verbose", 0 },
-#define NVERBSW 15
- { "noverbose", 0 },
-#define WATCSW 16
- { "watch", 0 },
-#define NWATCSW 17
- { "nowatch", 0 },
-#define WHOMSW 18
- { "whom", -4 }, /* interface from whom */
-#define WIDTHSW 19
- { "width columns", 0 },
-#define VERSIONSW 20
- { "version", 0 },
-#define HELPSW 21
- { "help", 0 },
-#define BITSTUFFSW 22
- { "dashstuffing", -12 }, /* should we dashstuff BCC messages? */
-#define NBITSTUFFSW 23
- { "nodashstuffing", -14 },
-#define ANNOSW 24
- { "idanno number", -6 }, /* interface from send */
-#define CLIESW 25
- { "client host", -6 },
-#define SERVSW 26
- { "server host", 6 }, /* specify alternate SMTP server */
-#define SNOOPSW 27
- { "snoop", -5 }, /* snoop the SMTP transaction */
-#define PARTSW 28
- { "partno", -6 },
-#define QUEUESW 29
- { "queued", -6 },
-#define SASLSW 30
- { "sasl", SASLminc(-4) },
-#define NOSASLSW 31
- { "nosasl", SASLminc(-6) },
-#define SASLMXSSFSW 32
- { "saslmaxssf", SASLminc(-10) },
-#define SASLMECHSW 33
- { "saslmech", SASLminc(-5) },
-#define USERSW 34
- { "user", SASLminc(-4) },
-#define PORTSW 35
- { "port server port name/number", 4 },
-#define TLSSW 36
- { "tls", TLSminc(-3) },
-#define NTLSSW 37
- { "notls", TLSminc(-5) },
-#define FILEPROCSW 38
- { "fileproc", -4 },
-#define MHLPROCSW 39
- { "mhlproc", -3 },
-#define MTSSW 40
- { "mts smtp|sendmail/smtp|sendmail/pipe", 2 },
-#define MESSAGEIDSW 41
- { "messageid localname|random", 2 },
- { NULL, 0 }
-};
+#define POST_SWITCHES \
+ X("alias aliasfile", 0, ALIASW) \
+ X("check", -5, CHKSW) /* interface from whom */ \
+ X("nocheck", -7, NCHKSW) /* interface from whom */ \
+ X("debug", -5, DEBUGSW) \
+ X("dist", -4, DISTSW) /* interface from dist */ \
+ X("filter filterfile", 0, FILTSW) \
+ X("nofilter", 0, NFILTSW) \
+ X("format", 0, FRMTSW) \
+ X("noformat", 0, NFRMTSW) \
+ X("library directory", -7, LIBSW) /* interface from send, whom */ \
+ X("mime", 0, MIMESW) \
+ X("nomime", 0, NMIMESW) \
+ X("msgid", 0, MSGDSW) \
+ X("nomsgid", 0, NMSGDSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("watch", 0, WATCSW) \
+ X("nowatch", 0, NWATCSW) \
+ X("whom", -4, WHOMSW) /* interface from whom */ \
+ X("width columns", 0, WIDTHSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("dashstuffing", -12, BITSTUFFSW) /* should we dashstuff BCC messages? */ \
+ X("nodashstuffing", -14, NBITSTUFFSW) \
+ X("idanno number", -6, ANNOSW) /* interface from send */ \
+ X("client host", -6, CLIESW) \
+ X("server host", 6, SERVSW) /* specify alternate SMTP server */ \
+ X("snoop", -5, SNOOPSW) /* snoop the SMTP transaction */ \
+ X("partno", -6, PARTSW) \
+ X("queued", -6, QUEUESW) \
+ X("sasl", SASLminc(-4), SASLSW) \
+ X("nosasl", SASLminc(-6), NOSASLSW) \
+ X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
+ X("saslmech", SASLminc(-5), SASLMECHSW) \
+ X("user", SASLminc(-4), USERSW) \
+ X("port server port name/number", 4, PORTSW) \
+ X("tls", TLSminc(-3), TLSSW) \
+ X("notls", TLSminc(-5), NTLSSW) \
+ X("fileproc", -4, FILEPROCSW) \
+ X("mhlproc", -3, MHLPROCSW) \
+ X("mts smtp|sendmail/smtp|sendmail/pipe", 2, MTSSW) \
+ X("messageid localname|random", 2, MESSAGEIDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(POST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(POST, switches);
+#undef X
struct headers {
# define CERASE '#'
#endif
-static struct swit switches[] = {
-#define ERASESW 0
- { "erase chr", 0 },
-#define KILLSW 1
- { "kill chr", 0 },
-#define PREPSW 2
- { "prepend", 0 },
-#define NPREPSW 3
- { "noprepend", 0 },
-#define RAPDSW 4
- { "rapid", 0 },
-#define NRAPDSW 5
- { "norapid", 0 },
-#define BODYSW 6
- { "body", -4 },
-#define NBODYSW 7
- { "nobody", -6 },
-#define DOTSW 8
- { "doteof", 0 },
-#define NDOTSW 9
- { "nodoteof", 0 },
-#define VERSIONSW 10
- { "version", 0 },
-#define HELPSW 11
- { "help", 0 },
- { NULL, 0 }
-};
+#define PROMPTER_SWITCHES \
+ X("erase chr", 0, ERASESW) \
+ X("kill chr", 0, KILLSW) \
+ X("prepend", 0, PREPSW) \
+ X("noprepend", 0, NPREPSW) \
+ X("rapid", 0, RAPDSW) \
+ X("norapid", 0, NRAPDSW) \
+ X("body", -4, BODYSW) \
+ X("nobody", -6, NBODYSW) \
+ X("doteof", 0, DOTSW) \
+ X("nodoteof", 0, NDOTSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PROMPTER);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PROMPTER, switches);
+#undef X
static struct termios tio;
#include <h/mts.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define FORMSW 0
- { "form formfile", 4 },
-#define VERSIONSW 1
- { "version", 0 },
-#define HELPSW 2
- { "help", 0 },
- { NULL, 0 }
-};
+#define RCVDIST_SWITCHES \
+ X("form formfile", 4, FORMSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RCVDIST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RCVDIST, switches);
+#undef X
static char backup[BUFSIZ] = "";
static char drft[BUFSIZ] = "";
#include <h/tws.h>
#include <h/mts.h>
-static struct swit switches[] = {
-#define MBOXSW 0
- { "mbox", 0 },
-#define MMDFSW 1
- { "mmdf", 0 },
-#define VERSIONSW 2
- { "version", 0 },
-#define HELPSW 3
- { "help", 0 },
- { NULL, 0 }
-};
+#define RCVPACK_SWITCHES \
+ X("mbox", 0, MBOXSW) \
+ X("mmdf", 0, MMDFSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RCVPACK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RCVPACK, switches);
+#undef X
/*
* default format in which to save messages
#include <signal.h>
#include <h/mts.h>
-static struct swit switches[] = {
-#define CRETSW 0
- { "create", 0 },
-#define NCRETSW 1
- { "nocreate", 0 },
-#define UNSEENSW 2
- { "unseen", 0 },
-#define NUNSEENSW 3
- { "nounseen", 0 },
-#define PUBSW 4
- { "public", 0 },
-#define NPUBSW 5
- { "nopublic", 0 },
-#define ZEROSW 6
- { "zero", 0 },
-#define NZEROSW 7
- { "nozero", 0 },
-#define SEQSW 8
- { "sequence name", 0 },
-#define VERSIONSW 9
- { "version", 0 },
-#define HELPSW 10
- { "help", 0 },
- { NULL, 0 }
-};
+#define RCVSTORE_SWITCHES \
+ X("create", 0, CRETSW) \
+ X("nocreate", 0, NCRETSW) \
+ X("unseen", 0, UNSEENSW) \
+ X("nounseen", 0, NUNSEENSW) \
+ X("public", 0, PUBSW) \
+ X("nopublic", 0, NPUBSW) \
+ X("zero", 0, ZEROSW) \
+ X("nozero", 0, NZEROSW) \
+ X("sequence name", 0, SEQSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RCVSTORE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RCVSTORE, switches);
+#undef X
/*
%<(mymbox{from})%<{to}To:%14(friendly{to})%>%>%<(zero)%17(friendly{from})%> \
%{subject}%<{body}<<%{body}>>%>"
-static struct swit switches[] = {
-#define BIFFSW 0
- { "biff", 0 },
-#define FORMSW 1
- { "form formatfile", 0 },
-#define FMTSW 2
- { "format string", 5 },
-#define WIDTHSW 3
- { "width columns", 0 },
-#define NLSW 4
- { "newline", 0 },
-#define NNLSW 5
- { "nonewline", 0 },
-#define BELSW 6
- { "bell", 0 },
-#define NBELSW 7
- { "nobell", 0 },
-#define VERSIONSW 8
- { "version", 0 },
-#define HELPSW 9
- { "help", 0 },
- { NULL, 0 }
-};
+#define RCVTTY_SWITCHES \
+ X("biff", 0, BIFFSW) \
+ X("form formatfile", 0, FORMSW) \
+ X("format string", 5, FMTSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("newline", 0, NLSW) \
+ X("nonewline", 0, NNLSW) \
+ X("bell", 0, BELSW) \
+ X("nobell", 0, NBELSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RCVTTY);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RCVTTY, switches);
+#undef X
static jmp_buf myctx;
static int bell = 1;
#include <fcntl.h>
#include <errno.h>
-static struct swit switches[] = {
-#define DRAFTSW 0
- { "draft", 0 },
-#define LINKSW 1
- { "link", 0 },
-#define NLINKSW 2
- { "nolink", 0 },
-#define PRESSW 3
- { "preserve", 0 },
-#define NPRESSW 4
- { "nopreserve", 0 },
-#define UNLINKSW 5
- { "unlink", 0 },
-#define NUNLINKSW 6
- { "nounlink", 0 },
-#define SRCSW 7
- { "src +folder", 0 },
-#define FILESW 8
- { "file file", 0 },
-#define RPROCSW 9
- { "rmmproc program", 0 },
-#define NRPRCSW 10
- { "normmproc", 0 },
-#define VERSIONSW 11
- { "version", 0 },
-#define HELPSW 12
- { "help", 0 },
- { NULL, 0 }
-};
+#define REFILE_SWITCHES \
+ X("draft", 0, DRAFTSW) \
+ X("link", 0, LINKSW) \
+ X("nolink", 0, NLINKSW) \
+ X("preserve", 0, PRESSW) \
+ X("nopreserve", 0, NPRESSW) \
+ X("unlink", 0, UNLINKSW) \
+ X("nounlink", 0, NUNLINKSW) \
+ X("src +folder", 0, SRCSW) \
+ X("file file", 0, FILESW) \
+ X("rmmproc program", 0, RPROCSW) \
+ X("normmproc", 0, NRPRCSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(REFILE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(REFILE, switches);
+#undef X
static char maildir[BUFSIZ];
#include <h/utils.h>
-static struct swit switches[] = {
-#define GROUPSW 0
- { "group", 0 },
-#define NGROUPSW 1
- { "nogroup", 0 },
-#define ANNOSW 2
- { "annotate", 0 },
-#define NANNOSW 3
- { "noannotate", 0 },
-#define CCSW 4
- { "cc all|to|cc|me", 0 },
-#define NCCSW 5
- { "nocc type", 0 },
-#define DFOLDSW 6
- { "draftfolder +folder", 0 },
-#define DMSGSW 7
- { "draftmessage msg", 0 },
-#define NDFLDSW 8
- { "nodraftfolder", 0 },
-#define EDITRSW 9
- { "editor editor", 0 },
-#define NEDITSW 10
- { "noedit", 0 },
-#define FCCSW 11
- { "fcc folder", 0 },
-#define FILTSW 12
- { "filter filterfile", 0 },
-#define FORMSW 13
- { "form formfile", 0 },
-#define FRMTSW 14
- { "format", 5 },
-#define NFRMTSW 15
- { "noformat", 7 },
-#define INPLSW 16
- { "inplace", 0 },
-#define NINPLSW 17
- { "noinplace", 0 },
-#define MIMESW 18
- { "mime", 0 },
-#define NMIMESW 19
- { "nomime", 0 },
-#define QURYSW 20
- { "query", 0 },
-#define NQURYSW 21
- { "noquery", 0 },
-#define WHATSW 22
- { "whatnowproc program", 0 },
-#define NWHATSW 23
- { "nowhatnowproc", 0 },
-#define WIDTHSW 24
- { "width columns", 0 },
-#define VERSIONSW 25
- { "version", 0 },
-#define HELPSW 26
- { "help", 0 },
-#define FILESW 27
- { "file file", 4 }, /* interface from msh */
-#define BILDSW 28
- { "build", 5 }, /* interface from mhe */
-#define ATFILESW 29
- { "atfile", 0 },
-#define NOATFILESW 30
- { "noatfile", 0 },
-#define FMTPROCSW 31
- { "fmtproc program", 0 },
-#define NFMTPROCSW 32
- { "nofmtproc", 0 },
-
- { NULL, 0 }
-};
-
-static struct swit ccswitches[] = {
-#define CTOSW 0
- { "to", 0 },
-#define CCCSW 1
- { "cc", 0 },
-#define CMESW 2
- { "me", 0 },
-#define CALSW 3
- { "all", 0 },
- { NULL, 0 }
-};
-
-static struct swit aqrnl[] = {
-#define NOSW 0
- { "quit", 0 },
-#define YESW 1
- { "replace", 0 },
-#define LISTDSW 2
- { "list", 0 },
-#define REFILSW 3
- { "refile +folder", 0 },
-#define NEWSW 4
- { "new", 0 },
- { NULL, 0 }
-};
+#define REPL_SWITCHES \
+ X("group", 0, GROUPSW) \
+ X("nogroup", 0, NGROUPSW) \
+ X("annotate", 0, ANNOSW) \
+ X("noannotate", 0, NANNOSW) \
+ X("cc all|to|cc|me", 0, CCSW) \
+ X("nocc type", 0, NCCSW) \
+ X("draftfolder +folder", 0, DFOLDSW) \
+ X("draftmessage msg", 0, DMSGSW) \
+ X("nodraftfolder", 0, NDFLDSW) \
+ X("editor editor", 0, EDITRSW) \
+ X("noedit", 0, NEDITSW) \
+ X("fcc folder", 0, FCCSW) \
+ X("filter filterfile", 0, FILTSW) \
+ X("form formfile", 0, FORMSW) \
+ X("format", 5, FRMTSW) \
+ X("noformat", 7, NFRMTSW) \
+ X("inplace", 0, INPLSW) \
+ X("noinplace", 0, NINPLSW) \
+ X("mime", 0, MIMESW) \
+ X("nomime", 0, NMIMESW) \
+ X("query", 0, QURYSW) \
+ X("noquery", 0, NQURYSW) \
+ X("whatnowproc program", 0, WHATSW) \
+ X("nowhatnowproc", 0, NWHATSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("file file", 4, FILESW) /* interface from msh */ \
+ X("build", 5, BILDSW) /* interface from mhe */ \
+ X("atfile", 0, ATFILESW) \
+ X("noatfile", 0, NOATFILESW) \
+ X("fmtproc program", 0, FMTPROCSW) \
+ X("nofmtproc", 0, NFMTPROCSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(REPL);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(REPL, switches);
+#undef X
+
+#define CC_SWITCHES \
+ X("to", 0, CTOSW) \
+ X("cc", 0, CCCSW) \
+ X("me", 0, CMESW) \
+ X("all", 0, CALSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(CC);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(CC, ccswitches);
+#undef X
+
+#define DISPO_SWITCHES \
+ X("quit", 0, NOSW) \
+ X("replace", 0, YESW) \
+ X("list", 0, LISTDSW) \
+ X("refile +folder", 0, REFILSW) \
+ X("new", 0, NEWSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DISPO);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DISPO, aqrnl);
+#undef X
static struct swit aqrl[] = {
- { "quit", 0 },
- { "replace", 0 },
- { "list", 0 },
- { "refile +folder", 0 },
- { NULL, 0 }
+ { "quit", 0, NOSW },
+ { "replace", 0, YESW },
+ { "list", 0, LISTDSW },
+ { "refile +folder", 0, REFILSW },
+ { NULL, 0, 0 }
};
short ccto = -1; /* global for replsbr */
#include <h/mh.h>
-static struct swit switches[] = {
-#define INTRSW 0
- { "interactive", 0 },
-#define NINTRSW 1
- { "nointeractive", 0 },
-#define VERSIONSW 2
- { "version", 0 },
-#define HELPSW 3
- { "help", 0 },
- { NULL, 0 }
-};
+#define RMF_SWITCHES \
+ X("interactive", 0, INTRSW) \
+ X("nointeractive", 0, NINTRSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RMF);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RMF, switches);
+#undef X
/*
* static prototypes
#include <h/mh.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define UNLINKSW 0
- { "unlink", 0 },
-#define NUNLINKSW 1
- { "nounlink", 0 },
-#define VERSIONSW 2
- { "version", 0 },
-#define HELPSW 3
- { "help", 0 },
- { NULL, 0 }
-};
+#define RMM_SWITCHES \
+ X("unlink", 0, UNLINKSW) \
+ X("nounlink", 0, NUNLINKSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RMM);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RMM, switches);
+#undef X
int
#include <h/utils.h>
#include <errno.h>
-static struct swit switches[] = {
-#define CLRSW 0
- { "clear", 0 },
-#define NCLRSW 1
- { "noclear", 0 },
-#define FORMSW 2
- { "form formatfile", 0 },
-#define FMTSW 3
- { "format string", 5 },
-#define HEADSW 4
- { "header", 0 },
-#define NHEADSW 5
- { "noheader", 0 },
-#define WIDTHSW 6
- { "width columns", 0 },
-#define REVSW 7
- { "reverse", 0 },
-#define NREVSW 8
- { "noreverse", 0 },
-#define FILESW 9
- { "file file", 4 },
-#define VERSIONSW 10
- { "version", 0 },
-#define HELPSW 11
- { "help", 0 },
- { NULL, 0 }
-};
+#define SCAN_SWITCHES \
+ X("clear", 0, CLRSW) \
+ X("noclear", 0, NCLRSW) \
+ X("form formatfile", 0, FORMSW) \
+ X("format string", 5, FMTSW) \
+ X("header", 0, HEADSW) \
+ X("noheader", 0, NHEADSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("reverse", 0, REVSW) \
+ X("noreverse", 0, NREVSW) \
+ X("file file", 4, FILESW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SCAN);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SCAN, switches);
+#undef X
-/*
- * global for sbr/formatsbr.c - yech!
- */
-#ifdef LBL
-extern struct msgs *fmt_current_folder;
-#endif
-
/*
* prototypes
*/
adios (file, "unable to open");
}
-#ifndef JLR
if (hdrflag) {
printf ("FOLDER %s\t%s\n", file, dtimenow (1));
}
-#endif /* JLR */
m_unknown (in);
for (msgnum = 1; ; ++msgnum) {
ontty = isatty (fileno (stdout));
-#ifdef LBL
- else
- fmt_current_folder = mp;
-#endif
-
for (msgnum = revflag ? mp->hghsel : mp->lowsel;
(revflag ? msgnum >= mp->lowsel : msgnum <= mp->hghsel);
msgnum += (revflag ? -1 : 1)) {
if (is_selected(mp, msgnum)) {
if ((in = fopen (cp = m_name (msgnum), "r")) == NULL) {
-#if 0
- if (errno != EACCES)
-#endif
admonish (cp, "unable to open message");
-#if 0
- else
- printf ("%*d unreadable\n", DMAXFOLDER, msgnum);
-#endif
continue;
}
-#ifndef JLR
if (hdrflag) {
printf ("FOLDER %s\t%s\n", folder, dtimenow(1));
}
-#endif /* JLR */
/*
* Check if message is in any sequence given
adios (NULL, "scan() botch (%d)", state);
case SCNEOF:
-#if 0
- printf ("%*d empty\n", DMAXFOLDER, msgnum);
-#else
advise (NULL, "message %d: empty", msgnum);
-#endif
break;
}
hdrflag = 0;
}
}
-#ifdef LBL
- seq_save (mp); /* because formatsbr might have made changes */
-#endif
-
folder_free (mp); /* free folder/message structure */
if (clearflag)
clear_screen ();
#include <h/tws.h>
#include <h/utils.h>
-#ifdef _FSTDIO
-# define _ptr _p /* Gag */
-# define _cnt _w /* Wretch */
-#endif
-
#define MAXSCANL 256 /* longest possible scan line */
/*
int unseen, char *folder, long size, int noisy)
{
int i, compnum, encrypted, state;
- unsigned char *cp, *tmpbuf;
+ unsigned char *cp, *tmpbuf, *startbody;
char **nxtbuf;
char *saved_c_text = NULL;
struct comp *cptr;
umask(~m_gmprot());
/* Compile format string */
- ncomps = fmt_compile (nfs, &fmt, 1) + 1;
+ ncomps = fmt_compile (nfs, &fmt, 1) + 2;
bodycomp = fmt_findcomp("body");
datecomp = fmt_findcomp("date");
nxtbuf = compbuffers;
savecomp = used_buf;
tmpbuf = *nxtbuf++;
+ startbody = NULL;
dat[0] = innum ? innum : outnum;
dat[1] = curflg;
dat[4] = unseen;
state = m_getfld (state, name, tmpbuf + i,
rlwidth - i, inb);
}
+
if (! outnum) {
state = FILEEOF; /* stop now if scan cmd */
+ if (bodycomp && startbody == NULL)
+ startbody = tmpbuf;
goto finished;
}
if (putc ('\n', scnout) == EOF) DIEWRERR();
FPUTS (tmpbuf);
/*
- * performance hack: some people like to run "inc" on
- * things like net.sources or large digests. We do a
- * copy directly into the output buffer rather than
- * going through an intermediate buffer.
+ * The previous code here used to call m_getfld() using
+ * pointers to the underlying output stdio buffers to
+ * avoid the extra copy. Tests by Markus Schnalke show
+ * no noticable performance loss on larger mailboxes
+ * if we incur an extra copy, and messing around with
+ * internal stdio buffers is becoming more and more
+ * unportable as times go on. So from now on just deal
+ * with the overhead of an extra copy.
*
- * We need the amount of data m_getfld found & don't
- * want to do a strlen on the long buffer so there's
- * a hack in m_getfld to save the amount of data it
- * returned in the global "msg_count".
+ * Subtle change - with the previous code tmpbuf wasn't
+ * used, so we could reuse it for the {body} component.
+ * Now since we're using tmpbuf as our read buffer we
+ * need to save the beginning of the body for later.
+ * See the above (and below) use of startbody.
*/
body:;
+ if (bodycomp && startbody == NULL) {
+ startbody = tmpbuf;
+ tmpbuf = *nxtbuf++;
+ }
+
while (state == BODY) {
-#ifdef LINUX_STDIO
- if (scnout->_IO_write_ptr == scnout->_IO_write_end) {
-#elif defined(__DragonFly__)
- if (((struct __FILE_public *)scnout)->_w <= 0) {
-#else
- if (scnout->_cnt <= 0) {
-#endif
- if (fflush(scnout) == EOF)
- DIEWRERR ();
- }
-#ifdef LINUX_STDIO
- state = m_getfld(state, name, scnout->_IO_write_ptr,
- (long)scnout->_IO_write_ptr-(long)scnout->_IO_write_end , inb);
- scnout->_IO_write_ptr += msg_count;
-#elif defined(__DragonFly__)
- state = m_getfld( state, name, ((struct __FILE_public *)scnout)->_p, -(((struct __FILE_public *)scnout)->_w), inb );
- ((struct __FILE_public *)scnout)->_w -= msg_count;
- ((struct __FILE_public *)scnout)->_p += msg_count;
-#else
- state = m_getfld( state, name, scnout->_ptr, -(scnout->_cnt), inb );
- scnout->_cnt -= msg_count;
- scnout->_ptr += msg_count;
-#endif
+ state = m_getfld(state, name, tmpbuf, rlwidth, inb);
+ FPUTS(tmpbuf);
}
goto finished;
/* Save and restore buffer so we don't trash our dynamic pool! */
if (bodycomp) {
saved_c_text = bodycomp->c_text;
- bodycomp->c_text = tmpbuf;
+ bodycomp->c_text = startbody;
}
if (size)
/* return dynamically allocated buffers to pool */
while ((cptr = *savecomp++)) {
- *--nxtbuf = cptr->c_text;
cptr->c_text = NULL;
}
- *--nxtbuf = tmpbuf;
if (outnum && (ferror(scnout) || fclose (scnout) == EOF))
DIEWRERR();
# define TLSminc(a) 0
#endif /* TLS_SUPPORT */
-static struct swit switches[] = {
-#define ALIASW 0
- { "alias aliasfile", 0 },
-#define DEBUGSW 1
- { "debug", -5 },
-#define DRAFTSW 2
- { "draft", 0 },
-#define DFOLDSW 3
- { "draftfolder +folder", 6 },
-#define DMSGSW 4
- { "draftmessage msg", 6 },
-#define NDFLDSW 5
- { "nodraftfolder", 0 },
-#define FILTSW 6
- { "filter filterfile", 0 },
-#define NFILTSW 7
- { "nofilter", 0 },
-#define FRMTSW 8
- { "format", 0 },
-#define NFRMTSW 9
- { "noformat", 0 },
-#define FORWSW 10
- { "forward", 0 },
-#define NFORWSW 11
- { "noforward", 0 },
-#define MIMESW 12
- { "mime", 0 },
-#define NMIMESW 13
- { "nomime", 0 },
-#define MSGDSW 14
- { "msgid", 0 },
-#define NMSGDSW 15
- { "nomsgid", 0 },
-#define PUSHSW 16
- { "push", 0 },
-#define NPUSHSW 17
- { "nopush", 0 },
-#define SPLITSW 18
- { "split seconds", 0 },
-#define UNIQSW 19
- { "unique", -6 },
-#define NUNIQSW 20
- { "nounique", -8 },
-#define VERBSW 21
- { "verbose", 0 },
-#define NVERBSW 22
- { "noverbose", 0 },
-#define WATCSW 23
- { "watch", 0 },
-#define NWATCSW 24
- { "nowatch", 0 },
-#define WIDTHSW 25
- { "width columns", 0 },
-#define VERSIONSW 26
- { "version", 0 },
-#define HELPSW 27
- { "help", 0 },
-#define BITSTUFFSW 28
- { "dashstuffing", -12 },
-#define NBITSTUFFSW 29
- { "nodashstuffing", -14 },
-#define MAILSW 30
- { "mail", -4 },
-#define SAMLSW 31
- { "saml", -4 },
-#define SENDSW 32
- { "send", -4 },
-#define SOMLSW 33
- { "soml", -4 },
-#define CLIESW 34
- { "client host", -6 },
-#define SERVSW 35
- { "server host", 6 },
-#define SNOOPSW 36
- { "snoop", 5 },
-#define SASLSW 37
- { "sasl", SASLminc(4) },
-#define NOSASLSW 38
- { "nosasl", SASLminc(-6) },
-#define SASLMXSSFSW 39
- { "saslmaxssf", SASLminc(-10) },
-#define SASLMECHSW 40
- { "saslmech mechanism", SASLminc(-5) },
-#define USERSW 41
- { "user username", SASLminc(-4) },
-#define ATTACHSW 42
- { "attach", 6 },
-#define NOATTACHSW 43
- { "noattach", 0 },
-#define ATTACHFORMATSW 44
- { "attachformat", 7 },
-#define PORTSW 45
- { "port server-port-name/number" , 4 },
-#define TLSSW 46
- { "tls", TLSminc(-3) },
-#define NTLSSW 47
- { "notls", TLSminc(-5) },
-#define MTSSW 48
- { "mts smtp|sendmail/smtp|sendmail/pipe", 2 },
-#define MESSAGEIDSW 49
- { "messageid localname|random", 2 },
- { NULL, 0 }
-};
-
-static struct swit anyl[] = {
-#define NOSW 0
- { "no", 0 },
-#define YESW 1
- { "yes", 0 },
-#define LISTDSW 2
- { "list", 0 },
- { NULL, 0 }
-};
+#define SEND_SWITCHES \
+ X("alias aliasfile", 0, ALIASW) \
+ X("debug", -5, DEBUGSW) \
+ X("draft", 0, DRAFTSW) \
+ X("draftfolder +folder", 6, DFOLDSW) \
+ X("draftmessage msg", 6, DMSGSW) \
+ X("nodraftfolder", 0, NDFLDSW) \
+ X("filter filterfile", 0, FILTSW) \
+ X("nofilter", 0, NFILTSW) \
+ X("format", 0, FRMTSW) \
+ X("noformat", 0, NFRMTSW) \
+ X("forward", 0, FORWSW) \
+ X("noforward", 0, NFORWSW) \
+ X("mime", 0, MIMESW) \
+ X("nomime", 0, NMIMESW) \
+ X("msgid", 0, MSGDSW) \
+ X("nomsgid", 0, NMSGDSW) \
+ X("push", 0, PUSHSW) \
+ X("nopush", 0, NPUSHSW) \
+ X("split seconds", 0, SPLITSW) \
+ X("unique", -6, UNIQSW) \
+ X("nounique", -8, NUNIQSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("watch", 0, WATCSW) \
+ X("nowatch", 0, NWATCSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("dashstuffing", -12, BITSTUFFSW) \
+ X("nodashstuffing", -14, NBITSTUFFSW) \
+ X("mail", -4, MAILSW) \
+ X("saml", -4, SAMLSW) \
+ X("send", -4, SENDSW) \
+ X("soml", -4, SOMLSW) \
+ X("client host", -6, CLIESW) \
+ X("server host", 6, SERVSW) \
+ X("snoop", 5, SNOOPSW) \
+ X("sasl", SASLminc(4), SASLSW) \
+ X("nosasl", SASLminc(-6), NOSASLSW) \
+ X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
+ X("saslmech mechanism", SASLminc(-5), SASLMECHSW) \
+ X("user username", SASLminc(-4), USERSW) \
+ X("attach", 6, ATTACHSW) \
+ X("noattach", 0, NOATTACHSW) \
+ X("attachformat", 7, ATTACHFORMATSW) \
+ X("port server-port-name/number", 4, PORTSW) \
+ X("tls", TLSminc(-3), TLSSW) \
+ X("notls", TLSminc(-5), NTLSSW) \
+ X("mts smtp|sendmail/smtp|sendmail/pipe", 2, MTSSW) \
+ X("messageid localname|random", 2, MESSAGEIDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SEND);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SEND, switches);
+#undef X
+
+#define USE_SWITCHES \
+ X("no", 0, NOSW) \
+ X("yes", 0, YESW) \
+ X("list", 0, LISTDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(USE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(USE, anyl);
+#undef X
extern int debugsw; /* from sendsbr.c */
extern int forwsw;
#include <h/mime.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define CHECKMIMESW 0
- { "checkmime", 0 },
-#define NOCHECKMIMESW 1
- { "nocheckmime", 0 },
-#define HEADSW 2
- { "header", 0 },
-#define NHEADSW 3
- { "noheader", 0 },
-#define FORMSW 4
- { "form formfile", 0 },
-#define PROGSW 5
- { "moreproc program", 0 },
-#define NPROGSW 6
- { "nomoreproc", 0 },
-#define LENSW 7
- { "length lines", 0 },
-#define WIDTHSW 8
- { "width columns", 0 },
-#define SHOWSW 9
- { "showproc program", 0 },
-#define SHOWMIMESW 10
- { "showmimeproc program", 0 },
-#define NSHOWSW 11
- { "noshowproc", 0 },
-#define DRFTSW 12
- { "draft", 0 },
-#define FILESW 13
- { "file file", -4 }, /* interface from showfile */
-#define FMTPROCSW 14
- { "fmtproc program", 0 },
-#define NFMTPROCSW 15
- { "nofmtproc", 0 },
-#define VERSIONSW 16
- { "version", 0 },
-#define HELPSW 17
- { "help", 0 },
- { NULL, 0 }
-};
+#define SHOW_SWITCHES \
+ X("checkmime", 0, CHECKMIMESW) \
+ X("nocheckmime", 0, NOCHECKMIMESW) \
+ X("header", 0, HEADSW) \
+ X("noheader", 0, NHEADSW) \
+ X("form formfile", 0, FORMSW) \
+ X("moreproc program", 0, PROGSW) \
+ X("nomoreproc", 0, NPROGSW) \
+ X("length lines", 0, LENSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("showproc program", 0, SHOWSW) \
+ X("showmimeproc program", 0, SHOWMIMESW) \
+ X("noshowproc", 0, NSHOWSW) \
+ X("draft", 0, DRFTSW) \
+ X("file file", -4, FILESW) /* interface from showfile */ \
+ X("fmtproc program", 0, FMTPROCSW) \
+ X("nofmtproc", 0, NFMTPROCSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SHOW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SHOW, switches);
+#undef X
/*
* static prototypes
#include <utmpx.h>
#endif /* HAVE_GETUTXENT */
-static struct swit switches[] = {
-#define ADDRSW 0
- { "addr address", 0 },
-#define USERSW 1
- { "user name", 0 },
-#define FILESW 2
- { "file file", 0 },
-#define SENDERSW 3
- { "sender address", 0 },
-#define MAILBOXSW 4
- { "mailbox file", 0 },
-#define HOMESW 5
- { "home directory", -4 },
-#define INFOSW 6
- { "info data", 0 },
-#define MAILSW 7
- { "maildelivery file", 0 },
-#define VERBSW 8
- { "verbose", 0 },
-#define NVERBSW 9
- { "noverbose", 0 },
-#define SUPPRESSDUP 10
- { "suppressdup", 0 },
-#define NSUPPRESSDUP 11
- { "nosuppressdup", 0 },
-#define DEBUGSW 12
- { "debug", 0 },
-#define VERSIONSW 13
- { "version", 0 },
-#define HELPSW 14
- { "help", 0 },
- { NULL, 0 }
-};
+#define SLOCAL_SWITCHES \
+ X("addr address", 0, ADDRSW) \
+ X("user name", 0, USERSW) \
+ X("file file", 0, FILESW) \
+ X("sender address", 0, SENDERSW) \
+ X("mailbox file", 0, MAILBOXSW) \
+ X("home directory", -4, HOMESW) \
+ X("info data", 0, INFOSW) \
+ X("maildelivery file", 0, MAILSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("suppressdup", 0, SUPPRESSDUP) \
+ X("nosuppressdup", 0, NSUPPRESSDUP) \
+ X("debug", 0, DEBUGSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SLOCAL);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SLOCAL, switches);
+#undef X
static int globbed = 0; /* have we built "vars" table yet? */
static int parsed = 0; /* have we built header field table yet */
/* use rcvstore to put message in folder */
status = usr_pipe (fd, "rcvstore", rcvstoreproc, vec, 1);
-#if 0
- /*
- * Currently, verbose status messages are handled by usr_pipe().
- */
- if (verbose) {
- if (status == 0)
- verbose_printf (", success.\n");
- else
- verbose_printf (", failed.\n");
- }
-#endif
-
return status;
}
/* get copy of envelope information ("From " line) */
envelope = getcpy (buffer);
-#if 0
- /* First go ahead and put "From " line in message */
- fputs (buffer, ffp);
- if (ferror (ffp))
- goto fputs_error;
-#endif
-
/* Put the delivery date in message */
fputs (ddate, ffp);
if (ferror (ffp))
#include <h/tws.h>
#include <h/utils.h>
-static struct swit switches[] = {
-#define DATESW 0
- { "datefield field", 0 },
-#define TEXTSW 1
- { "textfield field", 0 },
-#define NSUBJSW 2
- { "notextfield", 0 },
-#define SUBJSW 3
- { "subject", -3 }, /* backward-compatibility */
-#define LIMSW 4
- { "limit days", 0 },
-#define NLIMSW 5
- { "nolimit", 0 },
-#define VERBSW 6
- { "verbose", 0 },
-#define NVERBSW 7
- { "noverbose", 0 },
-#define ALLMSGS 8
- { "all", 0 },
-#define NALLMSGS 9
- { "noall", 0 },
-#define CHECKSW 10
- { "check", 0 },
-#define NCHECKSW 11
- { "nocheck", 0 },
-#define VERSIONSW 12
- { "version", 0 },
-#define HELPSW 13
- { "help", 0 },
- { NULL, 0 }
-};
+#define SORTM_SWITCHES \
+ X("datefield field", 0, DATESW) \
+ X("textfield field", 0, TEXTSW) \
+ X("notextfield", 0, NSUBJSW) \
+ X("subject", -3, SUBJSW) /* backward-compatibility */ \
+ X("limit days", 0, LIMSW) \
+ X("nolimit", 0, NLIMSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("all", 0, ALLMSGS) \
+ X("noall", 0, NALLMSGS) \
+ X("check", 0, CHECKSW) \
+ X("nocheck", 0, NCHECKSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SORTM);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SORTM, switches);
+#undef X
struct smsg {
int s_msg;
#include <h/mime.h>
#include <h/mhparse.h>
-static struct swit switches[] = {
-#define TOSW 0
- { "to mailpath", 0 },
-#define FROMSW 1
- { "from mailpath", 0 },
-#define SUBJECTSW 2
- { "subject subject", 0 },
-#define PARAMSW 3
- { "parameters arguments", 0 },
-#define DESCRIPTSW 4
- { "description text", 0 },
-#define COMMENTSW 5
- { "comment text", 0 },
-#define DELAYSW 6
- { "delay seconds", 0 },
-#define VERBSW 7
- { "verbose", 0 },
-#define NVERBSW 8
- { "noverbose", 0 },
-#define VERSIONSW 9
- { "version", 0 },
-#define HELPSW 10
- { "help", 0 },
-#define DEBUGSW 11
- { "debug", -5 },
- { NULL, 0 }
-};
+#define VIAMAIL_SWITCHES \
+ X("to mailpath", 0, TOSW) \
+ X("from mailpath", 0, FROMSW) \
+ X("subject subject", 0, SUBJECTSW) \
+ X("parameters arguments", 0, PARAMSW) \
+ X("description text", 0, DESCRIPTSW) \
+ X("comment text", 0, COMMENTSW) \
+ X("delay seconds", 0, DELAYSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(VIAMAIL);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(VIAMAIL, switches);
+#undef X
extern int debugsw;
extern int splitsw;
extern int verbsw;
-int ebcdicsw = 0; /* hack for linking purposes */
-
/*
* static prototypes
*/
if (nedit) {
unputenv ("mheditor");
} else {
- m_putenv ("mheditor", ed ? ed : (ed = context_find ("editor"))
- ? ed : defaulteditor);
+ m_putenv ("mheditor", ed ? ed : (ed = get_default_editor()));
}
snprintf (buffer, sizeof(buffer), "%d", use);
m_putenv ("mhuse", buffer);
#include <h/mime.h>
#include <h/utils.h>
-static struct swit whatnowswitches[] = {
-#define DFOLDSW 0
- { "draftfolder +folder", 0 },
-#define DMSGSW 1
- { "draftmessage msg", 0 },
-#define NDFLDSW 2
- { "nodraftfolder", 0 },
-#define EDITRSW 3
- { "editor editor", 0 },
-#define NEDITSW 4
- { "noedit", 0 },
-#define PRMPTSW 5
- { "prompt string", 4 },
-#define VERSIONSW 6
- { "version", 0 },
-#define HELPSW 7
- { "help", 0 },
-#define ATTACHSW 8
- { "attach header-field-name", 0 },
-#define NOATTACHSW 9
- { "noattach", 0 },
- { NULL, 0 }
-};
+#define WHATNOW_SWITCHES \
+ X("draftfolder +folder", 0, DFOLDSW) \
+ X("draftmessage msg", 0, DMSGSW) \
+ X("nodraftfolder", 0, NDFLDSW) \
+ X("editor editor", 0, EDITRSW) \
+ X("noedit", 0, NEDITSW) \
+ X("prompt string", 4, PRMPTSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("attach header-field-name", 0, ATTACHSW) \
+ X("noattach", 0, NOATTACHSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(WHATNOW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(WHATNOW, whatnowswitches);
+#undef X
/*
* Options at the "whatnow" prompt
*/
-static struct swit aleqs[] = {
-#define EDITSW 0
- { "edit [<editor> <switches>]", 0 },
-#define REFILEOPT 1
- { "refile [<switches>] +folder", 0 },
-#define BUILDMIMESW 2
- { "mime [<switches>]", 0 },
-#define DISPSW 3
- { "display [<switches>]", 0 },
-#define LISTSW 4
- { "list [<switches>]", 0 },
-#define SENDSW 5
- { "send [<switches>]", 0 },
-#define PUSHSW 6
- { "push [<switches>]", 0 },
-#define WHOMSW 7
- { "whom [<switches>]", 0 },
-#define QUITSW 8
- { "quit [-delete]", 0 },
-#define DELETESW 9
- { "delete", 0 },
-#define CDCMDSW 10
- { "cd [directory]", 0 },
-#define PWDCMDSW 11
- { "pwd", 0 },
-#define LSCMDSW 12
- { "ls", 2 },
-#define ATTACHCMDSW 13
- { "attach", 0 },
-#define DETACHCMDSW 14
- { "detach [-n]", 2 },
-#define ALISTCMDSW 15
- { "alist [-ln] ", 2 },
- { NULL, 0 }
-};
+#define PROMPT_SWITCHES \
+ X("edit [<editor> <switches>]", 0, EDITSW) \
+ X("refile [<switches>] +folder", 0, REFILEOPT) \
+ X("mime [<switches>]", 0, BUILDMIMESW) \
+ X("display [<switches>]", 0, DISPSW) \
+ X("list [<switches>]", 0, LISTSW) \
+ X("send [<switches>]", 0, SENDSW) \
+ X("push [<switches>]", 0, PUSHSW) \
+ X("whom [<switches>]", 0, WHOMSW) \
+ X("quit [-delete]", 0, QUITSW) \
+ X("delete", 0, DELETESW) \
+ X("cd [directory]", 0, CDCMDSW) \
+ X("pwd", 0, PWDCMDSW) \
+ X("ls", 2, LSCMDSW) \
+ X("attach", 0, ATTACHCMDSW) \
+ X("detach [-n]", 2, DETACHCMDSW) \
+ X("alist [-ln] ", 2, ALISTCMDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PROMPT);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PROMPT, aleqs);
+#undef X
static char *myprompt = "\nWhat now? ";
}
} else {
/* set initial editor */
- if (*ed == NULL && (*ed = context_find ("editor")) == NULL)
- *ed = defaulteditor;
+ if (*ed == NULL)
+ *ed = get_default_editor();
}
if (altmsg) {
# define TLSminc(a) 0
#endif /* TLS_SUPPORT */
-static struct swit sendswitches[] = {
-#define ALIASW 0
- { "alias aliasfile", 0 },
-#define DEBUGSW 1
- { "debug", -5 },
-#define FILTSW 2
- { "filter filterfile", 0 },
-#define NFILTSW 3
- { "nofilter", 0 },
-#define FRMTSW 4
- { "format", 0 },
-#define NFRMTSW 5
- { "noformat", 0 },
-#define FORWSW 6
- { "forward", 0 },
-#define NFORWSW 7
- { "noforward", 0 },
-#define MIMESW 8
- { "mime", 0 },
-#define NMIMESW 9
- { "nomime", 0 },
-#define MSGDSW 10
- { "msgid", 0 },
-#define NMSGDSW 11
- { "nomsgid", 0 },
-#define SPSHSW 12
- { "push", 0 },
-#define NSPSHSW 13
- { "nopush", 0 },
-#define SPLITSW 14
- { "split seconds", 0 },
-#define UNIQSW 15
- { "unique", -6 },
-#define NUNIQSW 16
- { "nounique", -8 },
-#define VERBSW 17
- { "verbose", 0 },
-#define NVERBSW 18
- { "noverbose", 0 },
-#define WATCSW 19
- { "watch", 0 },
-#define NWATCSW 20
- { "nowatch", 0 },
-#define WIDTHSW 21
- { "width columns", 0 },
-#define SVERSIONSW 22
- { "version", 0 },
-#define SHELPSW 23
- { "help", 0 },
-#define BITSTUFFSW 24
- { "dashstuffing", -12 },
-#define NBITSTUFFSW 25
- { "nodashstuffing", -14 },
-#define MAILSW 26
- { "mail", -4 },
-#define SAMLSW 27
- { "saml", -4 },
-#define SSNDSW 28
- { "send", -4 },
-#define SOMLSW 29
- { "soml", -4 },
-#define CLIESW 30
- { "client host", -6 },
-#define SERVSW 31
- { "server host", 6 },
-#define SNOOPSW 32
- { "snoop", -5 },
-#define SDRFSW 33
- { "draftfolder +folder", -6 },
-#define SDRMSW 34
- { "draftmessage msg", -6 },
-#define SNDRFSW 35
- { "nodraftfolder", -3 },
-#define SASLSW 36
- { "sasl", SASLminc(-4) },
-#define NOSASLSW 37
- { "nosasl", SASLminc(-6) },
-#define SASLMXSSFSW 38
- { "saslmaxssf", SASLminc(-10) },
-#define SASLMECHSW 39
- { "saslmech", SASLminc(-5) },
-#define USERSW 40
- { "user", SASLminc(-4) },
-#define SNDATTACHSW 41
- { "attach file", 6 },
-#define SNDNOATTACHSW 42
- { "noattach", 0 },
-#define SNDATTACHFORMAT 43
- { "attachformat", 7 },
-#define PORTSW 44
- { "port server-port-name/number", 4 },
-#define TLSSW 45
- { "tls", TLSminc(-3) },
-#define NTLSSW 46
- { "notls", TLSminc(-5) },
-#define MTSSW 47
- { "mts smtp|sendmail/smtp|sendmail/pipe", 2 },
-#define MESSAGEIDSW 48
- { "messageid localname|random", 2 },
- { NULL, 0 }
-};
+#define SEND_SWITCHES \
+ X("alias aliasfile", 0, ALIASW) \
+ X("debug", -5, DEBUGSW) \
+ X("filter filterfile", 0, FILTSW) \
+ X("nofilter", 0, NFILTSW) \
+ X("format", 0, FRMTSW) \
+ X("noformat", 0, NFRMTSW) \
+ X("forward", 0, FORWSW) \
+ X("noforward", 0, NFORWSW) \
+ X("mime", 0, MIMESW) \
+ X("nomime", 0, NMIMESW) \
+ X("msgid", 0, MSGDSW) \
+ X("nomsgid", 0, NMSGDSW) \
+ X("push", 0, SPSHSW) \
+ X("nopush", 0, NSPSHSW) \
+ X("split seconds", 0, SPLITSW) \
+ X("unique", -6, UNIQSW) \
+ X("nounique", -8, NUNIQSW) \
+ X("verbose", 0, VERBSW) \
+ X("noverbose", 0, NVERBSW) \
+ X("watch", 0, WATCSW) \
+ X("nowatch", 0, NWATCSW) \
+ X("width columns", 0, WIDTHSW) \
+ X("version", 0, SVERSIONSW) \
+ X("help", 0, SHELPSW) \
+ X("dashstuffing", -12, BITSTUFFSW) \
+ X("nodashstuffing", -14, NBITSTUFFSW) \
+ X("mail", -4, MAILSW) \
+ X("saml", -4, SAMLSW) \
+ X("send", -4, SSNDSW) \
+ X("soml", -4, SOMLSW) \
+ X("client host", -6, CLIESW) \
+ X("server host", 6, SERVSW) \
+ X("snoop", -5, SNOOPSW) \
+ X("draftfolder +folder", -6, SDRFSW) \
+ X("draftmessage msg", -6, SDRMSW) \
+ X("nodraftfolder", -3, SNDRFSW) \
+ X("sasl", SASLminc(-4), SASLSW) \
+ X("nosasl", SASLminc(-6), NOSASLSW) \
+ X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
+ X("saslmech", SASLminc(-5), SASLMECHSW) \
+ X("user", SASLminc(-4), USERSW) \
+ X("attach file", 6, SNDATTACHSW) \
+ X("noattach", 0, SNDNOATTACHSW) \
+ X("attachformat", 7, SNDATTACHFORMAT) \
+ X("port server-port-name/number", 4, PORTSW) \
+ X("tls", TLSminc(-3), TLSSW) \
+ X("notls", TLSminc(-5), NTLSSW) \
+ X("mts smtp|sendmail/smtp|sendmail/pipe", 2, MTSSW) \
+ X("messageid localname|random", 2, MESSAGEIDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SEND);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SEND, sendswitches);
+#undef X
extern int debugsw; /* from sendsbr.c */
# define TLSminc(a) 0
#endif /* TLS_SUPPORT */
-static struct swit switches[] = {
-#define ALIASW 0
- { "alias aliasfile", 0 },
-#define CHKSW 1
- { "check", 0 },
-#define NOCHKSW 2
- { "nocheck", 0 },
-#define DRAFTSW 3
- { "draft", 0 },
-#define DFOLDSW 4
- { "draftfolder +folder", 6 },
-#define DMSGSW 5
- { "draftmessage msg", 6 },
-#define NDFLDSW 6
- { "nodraftfolder", 0 },
-#define VERSIONSW 7
- { "version", 0 },
-#define HELPSW 8
- { "help", 0 },
-#define CLIESW 9
- { "client host", -6 },
-#define SERVSW 10
- { "server host", -6 },
-#define SNOOPSW 11
- { "snoop", -5 },
-#define SASLSW 12
- { "sasl", SASLminc(4) },
-#define SASLMECHSW 13
- { "saslmech mechanism", SASLminc(-5) },
-#define USERSW 14
- { "user username", SASLminc(-4) },
-#define PORTSW 15
- { "port server port name/number", 4 },
-#define TLSSW 16
- { "tls", TLSminc(-3) },
-#define NTLSSW 17
- { "notls", TLSminc(-5) },
-#define MTSSW 18
- { "mts smtp|sendmail/smtp|sendmail/pipe", 0 },
- { NULL, 0 }
-};
+#define WHOM_SWITCHES \
+ X("alias aliasfile", 0, ALIASW) \
+ X("check", 0, CHKSW) \
+ X("nocheck", 0, NOCHKSW) \
+ X("draft", 0, DRAFTSW) \
+ X("draftfolder +folder", 6, DFOLDSW) \
+ X("draftmessage msg", 6, DMSGSW) \
+ X("nodraftfolder", 0, NDFLDSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("client host", -6, CLIESW) \
+ X("server host", -6, SERVSW) \
+ X("snoop", -5, SNOOPSW) \
+ X("sasl", SASLminc(4), SASLSW) \
+ X("saslmech mechanism", SASLminc(-5), SASLMECHSW) \
+ X("user username", SASLminc(-4), USERSW) \
+ X("port server port name/number", 4, PORTSW) \
+ X("tls", TLSminc(-3), TLSSW) \
+ X("notls", TLSminc(-5), NTLSSW) \
+ X("mts smtp|sendmail/smtp|sendmail/pipe", 0, MTSSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(WHOM);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(WHOM, switches);
+#undef X
int