test/format/test-dp test/format/test-fmtdump \
test/format/test-localmbox test/format/test-myname \
test/format/test-myhost test/format/test-mymbox \
+ test/format/test-rightjustify \
test/forw/test-forw-digest test/forw/test-forw-format \
test/inc/test-deb359167 test/inc/test-eom-align \
test/inc/test-inc-scanout test/inc/test-msgchk \
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 \
test/cleanup ## The "cleanup" test should always be last.
check_SCRIPTS = test/common.sh
-check_PROGRAMS = test/getfullname test/getfqdn test/fakepop test/fakesmtp
+check_PROGRAMS = test/getfullname test/getfqdn test/fakepop test/fakesmtp \
+ test/getcwidth
DISTCHECK_CONFIGURE_FLAGS = DISABLE_SETGID_MAIL=1
##
##
## 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/showfile.c sbr/signals.c sbr/smatch.c \
sbr/snprintb.c sbr/ssequal.c sbr/strcasecmp.c \
sbr/strindex.c sbr/trimcpy.c sbr/uprf.c sbr/vfgets.c \
- sbr/fmt_def.c sbr/m_msgdef.c sbr/mf.c sbr/utils.c \
+ sbr/fmt_def.c sbr/mf.c sbr/utils.c \
sbr/m_mktemp.c sbr/getansreadline.c config/config.c \
config/version.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.
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 color-tests 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 really use a whole set of them, but this check should be
- dnl sufficient.
- dnl
- AC_CHECK_HEADER(libio.h, [
- AC_EGREP_HEADER(_IO_write_ptr, libio.h, [
- AC_DEFINE(LINUX_STDIO,1,[Use the Linux _IO_*_ptr defines from <libio.h>.]) ]) ])
-
AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM,1,
[Define to 1 if `struct winsize' requires <sys/ptem.h>.]),,
[[#if HAVE_SYS_STREAM_H
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
#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. */
#define FMTERR (-3) /* Message Format error */
#define FLD 0 /* Field returned */
#define FLDPLUS 1 /* Field returned with more to come */
- #define FLDEOF 2 /* Field returned ending at eom */
#define BODY 3 /* Body returned with more to come */
- #define BODYEOF 4 /* Body returned ending at eom */
#define FILEEOF 5 /* Reached end of input file */
+ struct m_getfld_state;
+ typedef struct m_getfld_state *m_getfld_state_t;
+
/*
* Maildrop styles
*/
#define MS_MMDF 3 /* string mmdlm2 */
#define MS_MSH 4 /* whacko msh */
- extern int msg_count; /* m_getfld() indicators */
- extern int msg_style; /* .. */
- extern char *msg_delim; /* .. */
-
#define NOUSE 0 /* draft being re-used */
#define TFOLDER 0 /* path() given a +folder */
extern char *components;
extern char *context;
extern char *current;
-extern char *defaulteditor;
extern char *defaultfolder;
extern char *digestcomps;
extern char *distcomps;
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 *);
char *m_backup (char *);
int m_convert (struct msgs *, char *);
char *m_draft (char *, char *, int, int *);
- void m_eomsbr (int (*)(int));
- int m_getfld (int, unsigned char *, unsigned char *, int, FILE *);
+ void m_eomsbr (m_getfld_state_t, int (*)(int));
+ void m_getfld_state_reset (m_getfld_state_t *);
+ void m_getfld_state_destroy (m_getfld_state_t *);
+ int m_getfld (m_getfld_state_t *, unsigned char[NAMESZ], unsigned char *, int *, FILE *);
int m_gmprot (void);
char *m_maildir (char *);
char *m_mailpath (char *);
int m_rand (unsigned char *, size_t);
char *m_mktemp(const char *, int *, FILE **);
char *m_mktemp2(const char *, const char *, int *, FILE **);
- void m_unknown(FILE *);
+ void m_unknown(m_getfld_state_t *, FILE *);
int makedir (char *);
char *message_id (time_t, int);
char *nmh_getpass(const char *);
int refile (char **, char *);
void ruserpass(char *, char **, char **);
int remdir (char *);
+ void scan_detect_mbox_style (FILE *);
+ void scan_finished ();
+ void scan_eom_action (int (*)());
int seq_addmsg (struct msgs *, char *, int, int, int);
int seq_addsel (struct msgs *, char *, int, int);
char *seq_bits (struct msgs *);
# 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
fflush (stdout);
}
+
/*
* Get the mail from a POP server
*/
* Get the mail from file (usually mail spool)
*/
if (inc_type == INC_FILE && Maildir == NULL) {
- m_unknown (in); /* the MAGIC invocation... */
+ scan_detect_mbox_style (in); /* the MAGIC invocation... */
hghnum = msgnum = mp->hghmsg;
for (;;) {
/*
free (Maildir); /* From now on Maildir is just a flag - don't dref! */
}
+ scan_finished ();
+
if (incerr < 0) { /* error */
if (locked) {
GETGROUPPRIVS(); /* Be sure we can unlock mail file */
extern int debugsw;
extern int verbosw;
-extern int ebcdicsw;
extern int listsw;
extern int rfc934sw;
extern int contentidsw;
struct part **pp;
CT ct;
FILE *in;
+ m_getfld_state_t gstate = 0;
directive_init(directives);
* draft into the linked list of header fields for
* the new MIME message.
*/
- for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+ for (compnum = 1;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, name, buf, &bufsz, in)) {
case FLD:
case FLDPLUS:
- case FLDEOF:
compnum++;
/* abort if draft has Mime-Version header field */
/* ignore any Content-Type fields in the header */
if (!mh_strcasecmp (name, TYPE_FIELD)) {
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, in);
+ }
goto finish_field;
}
/* if necessary, get rest of field */
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, in);
vp = add (buf, vp); /* add to previous value */
}
finish_field:
/* if this wasn't the last header field, then continue */
- if (state != FLDEOF)
- continue;
- /* else fall... */
+ continue;
case FILEEOF:
adios (NULL, "draft has empty body -- no directives!");
/* NOTREACHED */
case BODY:
- case BODYEOF:
fseek (in, (long) (-strlen (buf)), SEEK_CUR);
break;
}
break;
}
+ m_getfld_state_destroy (&gstate);
/*
* Now add the MIME-Version header field
}
-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
#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 */
static void mhladios (char *, char *, ...);
static void mhldone (int);
static void m_popen (char *);
- static void filterbody (struct mcomp *, char *, int, int, FILE *);
+ static void filterbody (struct mcomp *, char *, int, int, FILE *,
+ m_getfld_state_t);
static void compile_formatfield(struct mcomp *);
static void compile_filterargs (void);
int state, bucket;
struct mcomp *c1, *c2, *c3;
char **ip, name[NAMESZ], buf[BUFSIZ];
+ m_getfld_state_t gstate = 0;
compile_filterargs();
}
}
- for (state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ for (;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) {
case FLD:
case FLDPLUS:
bucket = fmt_addcomptext(name, buf);
for (ip = ignores; *ip; ip++)
if (!mh_strcasecmp (name, *ip)) {
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
fmt_appendcomp(bucket, name, buf);
}
break;
if (c1 == NULL)
c1 = add_queue (&msghd, &msgtl, name, buf, 0);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
c1->c_text = add (buf, c1->c_text);
fmt_appendcomp(bucket, name, buf);
}
if (dobody && !mh_strcasecmp (c1->c_name, "body")) {
if (c1->c_flags & FMTFILTER && state == BODY &&
formatproc != NULL) {
- filterbody(c1, buf, sizeof(buf), state, fp);
+ filterbody(c1, buf, sizeof(buf), state, fp, gstate);
} else {
holder.c_text = mh_xmalloc (sizeof(buf));
strncpy (holder.c_text, buf, sizeof(buf));
while (state == BODY) {
putcomp (c1, &holder, BODYCOMP);
- state = m_getfld (state, name, holder.c_text,
- sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, holder.c_text,
+ &bufsz, fp);
}
free (holder.c_text);
holder.c_text = NULL;
adios (NULL, "getfld() returned %d", state);
}
}
+ m_getfld_state_destroy (&gstate);
}
*/
static void
- filterbody (struct mcomp *c1, char *buf, int bufsz, int state, FILE *fp)
+ filterbody (struct mcomp *c1, char *buf, int bufsz, int state, FILE *fp,
+ m_getfld_state_t gstate)
{
struct mcomp holder;
char name[NAMESZ];
*/
while (state == BODY) {
+ int bufsz2 = bufsz;
write(fdinput[1], buf, strlen(buf));
- state = m_getfld(state, name, buf, bufsz, fp);
+ state = m_getfld (&gstate, name, buf, &bufsz2, fp);
}
/*
char *np, *vp;
CT ct;
HF hp;
+ m_getfld_state_t gstate = 0;
/* allocate the content structure */
if (!(ct = (CT) calloc (1, sizeof(*ct))))
* Parse the header fields for this
* content into a linked list.
*/
- for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+ for (compnum = 1;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, name, buf, &bufsz, in)) {
case FLD:
case FLDPLUS:
- case FLDEOF:
compnum++;
/* get copies of the buffers */
/* if necessary, get rest of field */
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, in);
vp = add (buf, vp); /* add to previous value */
}
/* Now add the header data to the list */
add_header (ct, np, vp);
- /* continue, if this isn't the last header field */
- if (state != FLDEOF) {
- ct->c_begin = ftell (in) + 1;
- continue;
- }
- /* else fall... */
+ /* continue, to see if this isn't the last header field */
+ ct->c_begin = ftell (in) + 1;
+ continue;
case BODY:
- case BODYEOF:
ct->c_begin = ftell (in) - strlen (buf);
break;
/* break out of the loop */
break;
}
+ m_getfld_state_destroy (&gstate);
/*
* Read the content headers. We will parse the
*/
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;
}
#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;
void padios (char *, char *, ...);
void padvise (char *, char *, ...);
+ extern m_getfld_state_t gstate; /* use the gstate in scansbr.c */
+
/*
* static prototypes
display_info (id > 0 ? scansw : 0);
msh (id > 0 ? scansw : 0);
+ scan_finished ();
m_reset ();
}
-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
mp->msgattrs[0] = getcpy ("unseen");
mp->msgattrs[1] = NULL;
- m_unknown (fp); /* the MAGIC invocation */
+ scan_detect_mbox_style (fp); /* the MAGIC invocation */
if (fmsh) {
free (fmsh);
fmsh = NULL;
return yp;
}
- m_eomsbr ((int (*)()) 0); /* XXX */
+ scan_eom_action ((int (*)()) 0); /* XXX */
fseek (fp, Msgs[msgnum].m_start, SEEK_SET);
return fp;
}
return Msgs[msgnum].m_bboard_id;
zp = msh_ready (msgnum, 0);
- for (state = FLD;;)
- switch (state = m_getfld (state, name, buf, sizeof(buf), zp)) {
+ for (;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, name, buf, &bufsz, zp)) {
case FLD:
- case FLDEOF:
case FLDPLUS:
if (!mh_strcasecmp (name, BBoard_ID)) {
bp = getcpy (buf);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), zp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, zp);
bp = add (buf, bp);
}
i = atoi (bp);
else
continue;
}
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), zp);
- if (state != FLDEOF)
- continue;
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, zp);
+ }
+ continue;
default:
return 0;
}
+ }
}
static void copy_message (int, FILE *);
static void copy_digest (int, FILE *);
+ extern m_getfld_state_t gstate; /* use the gstate in scansbr.c */
+
void
forkcmd (char **args, char *pgm)
{
}
-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
args[i++] = getcpy (m_name (msgnum));
args[i] = NULL;
mhlsbr (i, args, mhl_action);
- m_eomsbr ((int (*) ()) 0);
+ scan_eom_action ((int (*) ()) 0);
fclose (stdout);
_exit (0);
}
-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
if (mp->numsel == 1 && headersw)
show (mp->lowsel);
mhlsbr (vecp, vec, mhl_action);
- m_eomsbr ((int (*)()) 0);
+ scan_eom_action ((int (*)()) 0);
while (msgp < vecp)
free (vec[msgp++]);
} else {
mhlfp = msh_ready (msgnum, 1);
if (!fmsh)
- m_eomsbr (eom_action);
+ scan_eom_action (eom_action);
return mhlfp;
}
fp = msh_ready (msgnum, 1);
- for (state = FLD;;)
- switch (state = m_getfld (state, name, buf, sizeof buf, fp)) {
+ for (;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) {
case FLD:
case FLDPLUS:
- case FLDEOF:
/*
* Check Content-Type field
*/
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, fp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
cp = add (buf, cp);
}
bp = cp;
if (!mh_strcasecmp (name, ENCODING_FIELD)) {
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, fp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
cp = add (buf, cp);
}
for (bp = cp; isspace (*bp); bp++)
* Just skip the rest of this header
* field and go to next one.
*/
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
+ }
break;
/*
default:
return 0;
}
+ }
}
-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
register FILE *zp;
zp = msh_ready (msgnum, 0);
- for (state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof buf, zp)) {
+
+ for (;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, name, buf, &bufsz, zp)) {
case FLD:
- case FLDEOF:
case FLDPLUS:
if (!mh_strcasecmp (name, datesw)) {
bp = getcpy (buf);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, zp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, zp);
bp = add (buf, bp);
}
if ((tw = dparsetime (bp)) == NULL)
else if (subjsw && !mh_strcasecmp(name, subjsw)) {
bp = getcpy (buf);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, zp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, zp);
bp = add (buf, bp);
}
msgp->m_scanl = sosmash(subjsw, bp);
else
subjsw = (char *)0;/* subject done, need date */
} else {
- while (state == FLDPLUS) /* flush this one */
- state = m_getfld (state, name, buf, sizeof buf, zp);
+ while (state == FLDPLUS) { /* flush this one */
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, zp);
+ }
}
continue;
case BODY:
- case BODYEOF:
case FILEEOF:
break;
#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;
char name[NAMESZ], field[BUFSIZ];
char *cp;
char *msgnums = NULL, *this_msgnums, *old_msgnums;
+ m_getfld_state_t gstate = 0;
/* no sequences file -> no messages */
if (fp == NULL) {
}
/* copied from seq_read.c:seq_public */
- for (state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
+ for (;;) {
+ int fieldsz = sizeof field;
+ switch (state = m_getfld (&gstate, name, field, &fieldsz, fp)) {
case FLD:
case FLDPLUS:
- case FLDEOF:
if (state == FLDPLUS) {
cp = getcpy (field);
while (state == FLDPLUS) {
- state = m_getfld (state, name, field,
- sizeof(field), fp);
+ fieldsz = sizeof field;
+ state = m_getfld (&gstate, name, field, &fieldsz, fp);
cp = add (field, cp);
}
}
}
- if (state == FLDEOF)
- break;
continue;
case BODY:
- case BODYEOF:
adios (NULL, "no blank lines are permitted in %s", seqfile);
/* fall */
}
break; /* break from for loop */
}
+ m_getfld_state_destroy (&gstate);
fclose(fp);
#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 */
register char *bp;
char buf[BUFSIZ], name[NAMESZ];
register struct tws *tw;
+ m_getfld_state_t gstate = 0;
NMH_UNUSED (stop);
fseek (fp, start, SEEK_SET);
- for (state = FLD, bp = NULL;;) {
- switch (state = m_getfld (state, name, buf, sizeof buf, fp)) {
+ for (bp = NULL;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) {
case FLD:
- case FLDEOF:
case FLDPLUS:
if (bp != NULL)
free (bp), bp = NULL;
bp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, fp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
bp = add (buf, bp);
}
if (!mh_strcasecmp (name, n->n_datef))
break;
- if (state != FLDEOF)
- continue;
+ continue;
case BODY:
- case BODYEOF:
case FILEEOF:
case LENERR:
case FMTERR:
}
break;
}
+ m_getfld_state_destroy (&gstate);
if ((tw = dparsetime (bp)) == NULL)
advise (NULL, "unable to parse %s field in message %d, 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 {
char *cp, *msg = NULL, **argp, **arguments, *envelope;
char buf[BUFSIZ], name[NAMESZ];
FILE *in, *out;
+ m_getfld_state_t gstate = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
start_headers ();
if (debug) {
verbose++;
- discard (out = stdout); /* XXX: reference discard() to help loader */
+ out = stdout;
} else {
if (whomsw) {
if ((out = fopen ("/dev/null", "w")) == NULL)
hdrtab = msgstate == NORMAL ? NHeaders : RHeaders;
- for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+ for (compnum = 1;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, name, buf, &bufsz, in)) {
case FLD:
- case FLDEOF:
case FLDPLUS:
compnum++;
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, in);
cp = add (buf, cp);
}
putfmt (name, cp, out);
free (cp);
- if (state != FLDEOF)
- continue;
- finish_headers (out);
- break;
+ continue;
case BODY:
- case BODYEOF:
finish_headers (out);
if (whomsw)
break;
fprintf (out, "\n%s", buf);
while (state == BODY) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, in);
fputs (buf, out);
}
break;
}
break;
}
+ m_getfld_state_destroy (&gstate);
if (pfd != NOTOK)
anno ();
# 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;
char **arguments, **argp;
FILE *in, *out;
char *tfile = NULL;
+ m_getfld_state_t gstate = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
/*
* Loop through the lines of the draft skeleton.
*/
- for (state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), in)) {
+ for (;;) {
+ int fieldsz = sizeof field;
+ switch (state = m_getfld (&gstate, name, field, &fieldsz, in)) {
case FLD:
- case FLDEOF:
case FLDPLUS:
/*
* Check if the value of field contains anything
printf ("%s:%s", name, field);
fprintf (out, "%s:%s", name, field);
while (state == FLDPLUS) {
- state =
- m_getfld (state, name, field, sizeof(field), in);
+ fieldsz = sizeof field;
+ state = m_getfld (&gstate, name, field, &fieldsz, in);
printf ("%s", field);
fprintf (out, "%s", field);
}
}
}
- if (state == FLDEOF) { /* moby hack */
- fprintf (out, "--------\n");
- printf ("--------\n");
- if (!body)
- break;
- goto no_body;
- }
continue;
case BODY:
- case BODYEOF:
case FILEEOF:
if (!body)
break;
if (!rapid && !sigint)
printf ("%s", field);
} while (state == BODY &&
- (state = m_getfld (state, name, field, sizeof(field), in)));
+ (fieldsz = sizeof field,
+ state = m_getfld (&gstate, name, field, &fieldsz, in)));
if (prepend || !body)
break;
else
printf ("\n--------Enter additional text\n\n");
}
- no_body:
+
fflush (stdout);
for (;;) {
getln (field, sizeof(field));
}
break;
}
+ m_getfld_state_destroy (&gstate);
if (body)
printf ("--------\n");
#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] = "";
char *cp, *scanl, name[NAMESZ], tmpbuf[SBUFSIZ];
register struct comp *cptr;
FILE *out;
+ m_getfld_state_t gstate = 0;
if (!(out = fopen (drft, "w")))
adios (drft, "unable to create");
if (cptr)
cptr->c_text = addrs;
- for (state = FLD;;) {
- switch (state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb)) {
+ for (;;) {
+ int msg_count = SBUFSIZ;
+ switch (state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb)) {
case FLD:
case FLDPLUS:
i = fmt_addcomptext(name, tmpbuf);
if (i != -1) {
char_read += msg_count;
while (state == FLDPLUS) {
- state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+ msg_count = SBUFSIZ;
+ state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb);
fmt_appendcomp(i, name, tmpbuf);
char_read += msg_count;
}
}
- while (state == FLDPLUS)
- state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+ while (state == FLDPLUS) {
+ msg_count = SBUFSIZ;
+ state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb);
+ }
break;
case LENERR:
}
}
finished: ;
+ m_getfld_state_destroy (&gstate);
i = format_len + char_read + 256;
scanl = mh_xmalloc ((size_t) i + 2);
%<(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;
/* get new format string */
nfs = new_fs (form, format, SCANFMT);
scan (stdin, 0, 0, nfs, width, 0, 0, NULL, 0L, 0);
+ scan_finished ();
if (newline)
write (fd, "\n\r", 2);
write (fd, scanl, strlen (scanl));
#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
*/
printf ("FOLDER %s\t%s\n", file, dtimenow (1));
}
- m_unknown (in);
+ scan_detect_mbox_style (in);
for (msgnum = 1; ; ++msgnum) {
state = scan (in, msgnum, -1, nfs, width, 0, 0,
hdrflag ? file : NULL, 0L, 1);
if (state != SCNMSG && state != SCNENC)
break;
}
+ scan_finished ();
fclose (in);
done (0);
}
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)) {
advise (NULL, "message %d: empty", msgnum);
break;
}
+ scan_finished ();
hdrflag = 0;
fclose (in);
if (ontty)
}
}
-#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/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
char *cp;
char buf[BUFSIZ], name[NAMESZ];
FILE *fp;
+ m_getfld_state_t gstate = 0;
if ((fp = fopen (msgnam, "r")) == NULL)
return 0;
- for (state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ for (;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) {
case FLD:
case FLDPLUS:
- case FLDEOF:
/*
* Check Content-Type field
*/
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
cp = add (buf, cp);
}
bp = cp;
if (!mh_strcasecmp (name, ENCODING_FIELD)) {
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
cp = add (buf, cp);
}
for (bp = cp; isspace (*bp); bp++)
* Just skip the rest of this header
* field and go to next one.
*/
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
+ }
break;
/*
return 0;
}
}
+ m_getfld_state_destroy (&gstate);
}
#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 */
char name[NAMESZ], field[BUFSIZ];
struct pair *p, *q;
FILE *in;
+ m_getfld_state_t gstate = 0;
if (parsed++)
return 0;
* Scan the headers of the message and build
* a lookup table.
*/
- for (i = 0, state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), in)) {
+ for (i = 0;;) {
+ int fieldsz = sizeof field;
+ switch (state = m_getfld (&gstate, name, field, &fieldsz, in)) {
case FLD:
- case FLDEOF:
case FLDPLUS:
lp = add (field, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, field, sizeof(field), in);
+ fieldsz = sizeof field;
+ state = m_getfld (&gstate, name, field, &fieldsz, in);
lp = add (field, lp);
}
for (p = hdrs; p->p_name; p++) {
p++, i++;
p->p_name = NULL;
}
- if (state != FLDEOF)
- continue;
- break;
+ continue;
case BODY:
- case BODYEOF:
case FILEEOF:
break;
}
break;
}
+ m_getfld_state_destroy (&gstate);
fclose (in);
if ((p = lookup (vars, "reply-to"))) {
datum key, value;
DBM *db;
FILE *in;
+ m_getfld_state_t gstate = 0;
if ((fd1 = dup (fd)) == -1)
return -1;
}
rewind (in);
- for (state = FLD;;) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ for (;;) {
+ int bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, in);
switch (state) {
case FLD:
case FLDPLUS:
- case FLDEOF:
/* Search for the message ID */
if (mh_strcasecmp (name, "Message-ID")) {
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, in);
+ }
continue;
}
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, in);
cp = add (buf, cp);
}
key.dptr = trimcpy (cp);
break;
case BODY:
- case BODYEOF:
case FILEEOF:
break;
break;
}
+ m_getfld_state_destroy (&gstate);
fclose (in);
return 0;
#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;
register struct tws *tw;
register char *datecomp = NULL, *subjcomp = NULL;
register FILE *in;
+ m_getfld_state_t gstate = 0;
if ((in = fopen (msgnam = m_name (msg), "r")) == NULL) {
admonish (msgnam, "unable to read message");
return (0);
}
- for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, nam, buf, sizeof(buf), in)) {
+ for (compnum = 1;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, nam, buf, &bufsz, in)) {
case FLD:
- case FLDEOF:
case FLDPLUS:
compnum++;
if (!mh_strcasecmp (nam, datesw)) {
datecomp = add (buf, datecomp);
while (state == FLDPLUS) {
- state = m_getfld (state, nam, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, nam, buf, &bufsz, in);
datecomp = add (buf, datecomp);
}
if (!subjsort || subjcomp)
} else if (subjsort && !mh_strcasecmp (nam, subjsort)) {
subjcomp = add (buf, subjcomp);
while (state == FLDPLUS) {
- state = m_getfld (state, nam, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, nam, buf, &bufsz, in);
subjcomp = add (buf, subjcomp);
}
if (datecomp)
break;
} else {
/* just flush this guy */
- while (state == FLDPLUS)
- state = m_getfld (state, nam, buf, sizeof(buf), in);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, nam, buf, &bufsz, in);
+ }
}
continue;
case BODY:
- case BODYEOF:
case FILEEOF:
break;
}
break;
}
+ m_getfld_state_destroy (&gstate);
/*
* If no date component, then use the modification
if (!datecomp || (tw = dparsetime (datecomp)) == NULL) {
struct stat st;
- admonish (NULL, "can't parse %s field in message %d", datesw, msg);
+ advise (NULL,
+ "can't parse %s field in message %d, "
+ "will use file modification time",
+ datesw, msg);
fstat (fileno (in), &st);
smsg->s_clock = st.st_mtime;
check_failed = 1;
#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) {
int state;
char buf[BUFSIZ], name[NAMESZ];
FILE *fp;
+ m_getfld_state_t gstate = 0;
if ((fp = fopen (msgnam, "r")) == NULL)
return 0;
- for (state = FLD;;)
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ for (;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) {
case FLD:
case FLDPLUS:
- case FLDEOF:
/*
* If draft already contains any of the
* Content-XXX fields, then assume it already
fclose (fp);
return 0;
}
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
+ }
break;
case BODY:
return 1;
}
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (&gstate, name, buf, &bufsz, fp);
} while (state == BODY);
/* and fall... */
fclose (fp);
return 0;
}
+ }
+ m_getfld_state_destroy (&gstate);
}
# 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 */