/*
- * config.c -- master nmh configuration file
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** config.c -- master nmh configuration file
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * Find the location of a format or configuration
- * file, and return its absolute pathname.
- *
- * 1) If already absolute pathname, then leave unchanged.
- * 2) Next, if it begins with ~user, then expand it.
- * 3) Next, check in nmh Mail directory.
- * 4) Next, check in nmh `etc' directory.
- */
+** Find the location of a format or configuration
+** file, and return its absolute pathname.
+**
+** 1) If already absolute pathname, then leave unchanged.
+** 2) Next, if it begins with ~user, then expand it.
+** 3) Next, check in nmh Mail directory.
+** 4) Next, check in nmh `etc' directory.
+*/
char *
etcpath (char *file)
/*
- * Standard yes/no switches structure
- */
+** Standard yes/no switches structure
+*/
struct swit anoyes[] = {
{ "no", 0 },
};
/*
- * nmh constants
- */
+** nmh constants
+*/
/* initial profile for new users */
char *mh_defaults = nmhetcdir (/mh.profile);
char *mhetcdir = NMHETCDIR;
/*
- * nmh not-so constants
- */
+** nmh not-so constants
+*/
/*
- * Default name for the nmh context file.
- */
+** Default name for the nmh context file.
+*/
char *context = "context";
/*
- * Default name of file for public sequences. If NULL,
- * then nmh will use private sequences by default, unless the
- * user defines a value using the "mh-sequences" profile entry.
- */
+** Default name of file for public sequences. If NULL,
+** then nmh will use private sequences by default, unless the
+** user defines a value using the "mh-sequences" profile entry.
+*/
#ifdef NOPUBLICSEQ
char *mh_seq = NULL;
#else
#endif
/*
- * nmh globals
- */
+** nmh globals
+*/
char ctxflags; /* status of user's context */
char *invo_name; /* command invocation name */
struct node *m_defs; /* profile/context structure */
/*
- * nmh processes
- */
+** nmh processes
+*/
/*
- * This is the program to process MIME composition files
- */
+** This is the program to process MIME composition files
+*/
char *buildmimeproc = nmhbindir (/mhbuild);
/*
- * This is the program to `cat' a file.
- */
+** This is the program to `cat' a file.
+*/
char *catproc = "/bin/cat";
/*
- * mhl runs this program as a visual-end.
- */
+** mhl runs this program as a visual-end.
+*/
char *faceproc = NULL;
/*
- * This program is usually called directly by users, but it is
- * also invoked by the spost program to process an "Fcc", or by
- * comp/repl/forw/dist to refile a draft message.
- */
+** This program is usually called directly by users, but it is
+** also invoked by the spost program to process an "Fcc", or by
+** comp/repl/forw/dist to refile a draft message.
+*/
char *fileproc = nmhbindir (/refile);
/*
- * This program is called to incorporate messages into a folder.
- */
+** This program is called to incorporate messages into a folder.
+*/
char *incproc = nmhbindir (/inc);
/*
- * When a user runs an nmh program for the first time, this program
- * is called to create his nmh profile, and mail directory.
- */
+** When a user runs an nmh program for the first time, this program
+** is called to create his nmh profile, and mail directory.
+*/
char *installproc = nmhlibdir (/install-mh);
/*
- * This is the default program invoked by a "list" response
- * at the "What now?" prompt. It is also used by the draft
- * folder facility in comp/dist/forw/repl to display the
- * draft message.
- */
+** This is the default program invoked by a "list" response
+** at the "What now?" prompt. It is also used by the draft
+** folder facility in comp/dist/forw/repl to display the
+** draft message.
+*/
char *lproc = "more";
/*
- * This is the path for the Bell equivalent mail program.
- */
+** This is the path for the Bell equivalent mail program.
+*/
char *mailproc = nmhbindir (/mhmail);
/*
- * This is used by mhl as a front-end. It is also used
- * by mhshow as the default method of displaying message bodies
- * or message parts of type text/plain.
- */
+** This is used by mhl as a front-end. It is also used
+** by mhshow as the default method of displaying message bodies
+** or message parts of type text/plain.
+*/
char *moreproc = "more";
/*
- * This is the program (mhl) used to filter messages. It is
- * used by mhshow to filter and display the message headers of
- * MIME messages. It is used by repl/forw (with -filter)
- * to filter the message to which you are replying/forwarding.
- * It is used by send/spost (with -filter) to filter the message
- * for "Bcc:" recipients.
- */
+** This is the program (mhl) used to filter messages. It is
+** used by mhshow to filter and display the message headers of
+** MIME messages. It is used by repl/forw (with -filter)
+** to filter the message to which you are replying/forwarding.
+** It is used by send/spost (with -filter) to filter the message
+** for "Bcc:" recipients.
+*/
char *mhlproc = nmhlibdir (/mhl);
/*
- * This program is called to pack a folder.
- */
+** This program is called to pack a folder.
+*/
char *packproc = nmhbindir (/packf);
/*
- * This is the delivery program called by send to actually
- * deliver mail to users. This is the interface to the MTS.
- */
+** This is the delivery program called by send to actually
+** deliver mail to users. This is the interface to the MTS.
+*/
char *postproc = nmhlibdir (/spost);
/*
- * This is program is called by slocal to handle
- * the action `folder' or `+'.
- */
+** This is program is called by slocal to handle
+** the action `folder' or `+'.
+*/
char *rcvstoreproc = nmhlibdir (/rcvstore);
/*
- * This program is called to remove a folder.
- */
+** This program is called to remove a folder.
+*/
char *rmfproc = nmhbindir (/rmf);
/*
- * This program is called to remove a message by rmm or refile -nolink.
- * It's usually empty, which means to rename the file to a backup name.
- */
+** This program is called to remove a message by rmm or refile -nolink.
+** It's usually empty, which means to rename the file to a backup name.
+*/
char *rmmproc = NULL;
/*
- * This program is usually called by the user's whatnowproc, but it
- * may also be called directly to send a message previously composed.
+** This program is usually called by the user's whatnowproc, but it
+** may also be called directly to send a message previously composed.
*/
char *sendproc = nmhbindir (/send);
/*
- * This is the path to the program used by "show"
- * to display non-text (MIME) messages.
- */
+** This is the path to the program used by "show"
+** to display non-text (MIME) messages.
+*/
char *showmimeproc = nmhbindir (/mhshow);
/*
- * This is the default program called by "show" to filter
- * and display standard text (non-MIME) messages. It can be
- * changed to a pager (such as "more" or "less") if you prefer
- * that such message not be filtered in any way.
- */
+** This is the default program called by "show" to filter
+** and display standard text (non-MIME) messages. It can be
+** changed to a pager (such as "more" or "less") if you prefer
+** that such message not be filtered in any way.
+*/
char *showproc = nmhlibdir (/mhl);
/*
- * This program is called after comp, et. al., have built a draft
- */
+** This program is called after comp, et. al., have built a draft
+*/
char *whatnowproc = nmhbindir (/whatnow);
/*
- * This is the sendmail interface to use for sending mail.
- */
+** This is the sendmail interface to use for sending mail.
+*/
char *sendmail = SENDMAILPATH;
/*
- * The prefix that is prepended to the name of message files when they
- * are "removed" by rmm. This should typically be `,' or `#'.
- */
+** The prefix that is prepended to the name of message files when they
+** are "removed" by rmm. This should typically be `,' or `#'.
+*/
char *backup_prefix = ",";
/*
- * This is the editor invoked by the various message
- * composition programs. It SHOULD be a full screen
- * editor, such as vi or emacs, but any editor will work.
- */
+** This is the editor invoked by the various message
+** composition programs. It SHOULD be a full screen
+** editor, such as vi or emacs, but any editor will work.
+*/
char *defaulteditor = "vi";
/*
- * Name of link to file to which you are replying or which you are
- * redistributing. See `$mhaltmsg' in the mh-profile(5) man page.
- */
+** Name of link to file to which you are replying or which you are
+** redistributing. See `$mhaltmsg' in the mh-profile(5) man page.
+*/
char *altmsglink = "@";
/*
- * This is the global nmh alias file. It is somewhat obsolete, since
- * global aliases should be handled by the Mail Transport Agent (MTA).
- */
+** This is the global nmh alias file. It is somewhat obsolete, since
+** global aliases should be handled by the Mail Transport Agent (MTA).
+*/
char *AliasFile = nmhetcdir (/MailAliases);
/*
- * File protections
- */
+** File protections
+*/
/*
- * Folders (directories) are created with this protection (mode)
- */
+** Folders (directories) are created with this protection (mode)
+*/
char *foldprot = "700";
/*
- * Every NEW message will be created with this protection. When a
- * message is filed it retains its protection, so this only applies
- * to messages coming in through inc.
- */
+** Every NEW message will be created with this protection. When a
+** message is filed it retains its protection, so this only applies
+** to messages coming in through inc.
+*/
char *msgprot = "600";
/*
- * addrsbr.h -- definitions for the address parsing system
- */
+** addrsbr.h -- definitions for the address parsing system
+*/
#define AD_HOST 1 /* getm(): lookup official hostname */
#define AD_NHST 0 /* getm(): do not lookup official name */
/*
- * prototypes
- */
+** prototypes
+*/
void mnfree(struct mailname *);
int ismymbox(struct mailname *);
char *getname(char *);
/*
- * aliasbr.h -- definitions for the aliasing system
- */
+** aliasbr.h -- definitions for the aliasing system
+*/
extern char *AliasFile; /* mh-alias(5) */
#define PASSWD "/etc/passwd" /* passwd(5) */
};
/*
- * incore version of /etc/passwd
- */
+** incore version of /etc/passwd
+*/
struct home {
char *h_name; /* user name */
uid_t h_uid; /* user id */
struct home *seek_home (char *);
/*
- * prototypes
- */
+** prototypes
+*/
int alias (char *);
int akvisible (void);
void init_pw (void);
/*
- * crawl_folders.h -- crawl folder hierarchy
- */
+** crawl_folders.h -- crawl folder hierarchy
+*/
#define CRAWL_NUMFOLDERS 100
-/* Callbacks return TRUE crawl_folders should crawl the children of `folder'.
- * Callbacks need not duplicate folder, as crawl_folders does not free it. */
+/*
+** Callbacks return TRUE crawl_folders should crawl the children of `folder'.
+** Callbacks need not duplicate folder, as crawl_folders does not free it.
+*/
typedef boolean (crawl_callback_t)(char *folder, void *baton);
-/* Crawl the folder hierarchy rooted at the relative path `dir'. For each
- * folder, pass `callback' the folder name (as a path relative to the current
- * directory) and `baton'; the callback may direct crawl_folders not to crawl
- * its children; see above. */
+/*
+** Crawl the folder hierarchy rooted at the relative path `dir'. For each
+** folder, pass `callback' the folder name (as a path relative to the current
+** directory) and `baton'; the callback may direct crawl_folders not to crawl
+** its children; see above.
+*/
void crawl_folders (char *dir, crawl_callback_t *callback, void *baton);
/*
- * dropsbr.h -- definitions for maildrop-style files
- */
+** dropsbr.h -- definitions for maildrop-style files
+*/
/*
- * A file which is formatted like a maildrop may have a corresponding map
- * file which is an index to the bounds of each message. The first record
- * of such an map is special, it contains:
- *
- * d_id = number of messages in file
- * d_size = version number of map
- * d_start = last message read
- * d_stop = size of file
- *
- * Each record after that contains:
- *
- * d_id = BBoard-ID: of message, or similar info
- * d_size = size of message in ARPA Internet octets (\n == 2 octets)
- * d_start = starting position of message in file
- * d_stop = stopping position of message in file
- *
- * Note that d_start/d_stop do NOT include the message delimiters, so
- * programs using the map can simply fseek to d_start and keep reading
- * until the position is at d_stop.
- */
+** A file which is formatted like a maildrop may have a corresponding map
+** file which is an index to the bounds of each message. The first record
+** of such an map is special, it contains:
+**
+** d_id = number of messages in file
+** d_size = version number of map
+** d_start = last message read
+** d_stop = size of file
+**
+** Each record after that contains:
+**
+** d_id = BBoard-ID: of message, or similar info
+** d_size = size of message in ARPA Internet octets (\n == 2 octets)
+** d_start = starting position of message in file
+** d_stop = stopping position of message in file
+**
+** Note that d_start/d_stop do NOT include the message delimiters, so
+** programs using the map can simply fseek to d_start and keep reading
+** until the position is at d_stop.
+*/
/*
- * various formats for maildrop files
- */
+** various formats for maildrop files
+*/
#define OTHER_FORMAT 0
#define MBOX_FORMAT 1
#define MMDF_FORMAT 2
};
/*
- * prototypes
- */
+** prototypes
+*/
int mbx_open (char *, int, uid_t, gid_t, mode_t);
int mbx_read (FILE *, long, struct drop **, int);
int mbx_write(char *, int, FILE *, int, long, long, off_t, int, int);
/*
- * fmt_compile.h -- format types
- */
+** fmt_compile.h -- format types
+*/
/* types that output text */
#define FT_COMP 1 /* the text of a component */
/*
- * fmt_scan.h -- definitions for fmt_scan()
- */
+** fmt_scan.h -- definitions for fmt_scan()
+*/
/*
- * This structure describes an "interesting" component. It holds
- * the name & text from the component (if found) and one piece of
- * auxilary info. The structure for a particular component is located
- * by (open) hashing the name and using it as an index into the ptr array
- * "wantcomp". All format entries that reference a particular component
- * point to its comp struct (so we only have to do component specific
- * processing once. e.g., parse an address.).
- */
+** This structure describes an "interesting" component. It holds
+** the name & text from the component (if found) and one piece of
+** auxilary info. The structure for a particular component is located
+** by (open) hashing the name and using it as an index into the ptr array
+** "wantcomp". All format entries that reference a particular component
+** point to its comp struct (so we only have to do component specific
+** processing once. e.g., parse an address.).
+*/
struct comp {
char *c_name; /* component name (in lower case) */
char *c_text; /* component text (if found) */
#define c_mn c_un.c_u_mn
/*
- * c_type bits
- */
+** c_type bits
+*/
#define CT_ADDR (1<<0) /* referenced as address */
#define CT_DATE (1<<1) /* referenced as date */
/*
- * c_flags bits
- */
+** c_flags bits
+*/
#define CF_TRUE (1<<0) /* usually means component is present */
#define CF_PARSED (1<<1) /* address/date has been parsed */
#define CF_DATEFAB (1<<2) /* datefield fabricated */
extern int fmt_norm;
/*
- * Hash table for deciding if a component is "interesting".
- */
+** Hash table for deciding if a component is "interesting".
+*/
extern struct comp *wantcomp[128];
/*
- * Hash function for component name. The function should be
- * case independent and probably shouldn't involve a routine
- * call. This function is pretty good but will not work on
- * single character component names.
- */
+** Hash function for component name. The function should be
+** case independent and probably shouldn't involve a routine
+** call. This function is pretty good but will not work on
+** single character component names.
+*/
#define CHASH(nm) (((((nm)[0]) - ((nm)[1])) & 0x1f) + (((nm)[2]) & 0x5f))
/*
- * Find a component in the hash table.
- */
+** Find a component in the hash table.
+*/
#define FINDCOMP(comp,name) \
for (comp = wantcomp[CHASH(name)]; \
comp && strcmp(comp->c_name,name); \
comp = comp->c_next) ;
/*
- * This structure defines one formatting instruction.
- */
+** This structure defines one formatting instruction.
+*/
struct format {
unsigned char f_type;
char f_fill;
#define f_value f_un.f_u_value
/*
- * prototypes
- */
+** prototypes
+*/
struct format *fmt_scan (struct format *, char *, int, int *);
char *new_fs (char *, char *, char *);
int fmt_compile (char *, struct format **);
/*
- * md5.h -- header file for md5 message digest
- * taken from RFC-1321/Appendices A.1/A.2
- */
+** md5.h -- header file for md5 message digest
+** taken from RFC-1321/Appendices A.1/A.2
+*/
/*
- * RSAREF types and constants
- */
+** RSAREF types and constants
+*/
/*
- * Use include for nmh/mh
- */
+** Use include for nmh/mh
+*/
#include <h/nmh.h>
/*
- * Use prototypes for nmh/mh
- */
+** Use prototypes for nmh/mh
+*/
#define PROTOTYPES 1
/*
- * PROTOTYPES should be set to one if and only if the compiler
- * supports function argument prototyping. The following makes
- * PROTOTYPES default to 0 if it has not already been defined
- * with C compiler flags.
- */
+** PROTOTYPES should be set to one if and only if the compiler
+** supports function argument prototyping. The following makes
+** PROTOTYPES default to 0 if it has not already been defined
+** with C compiler flags.
+*/
#ifndef PROTOTYPES
# define PROTOTYPES 0
#endif
/* UINT4 defines a four byte word */
typedef unsigned long int UINT4;
-/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
- * If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
- * returns an empty list.
- */
+/*
+** PROTO_LIST is defined depending on how PROTOTYPES is defined above.
+** If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
+** returns an empty list.
+*/
#if PROTOTYPES
# define PROTO_LIST(list) list
#else
# define PROTO_LIST(list) ()
#endif
-/* MD5.H - header file for MD5C.C
- */
-
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
-rights reserved.
-
-License to copy and use this software is granted provided that it
-is identified as the "RSA Data Security, Inc. MD5 Message-Digest
-Algorithm" in all material mentioning or referencing this software
-or this function.
+/* MD5.H - header file for MD5C.C */
-License is also granted to make and use derivative works provided
-that such works are identified as "derived from the RSA Data
-Security, Inc. MD5 Message-Digest Algorithm" in all material
-mentioning or referencing the derived work.
-
-RSA Data Security, Inc. makes no representations concerning either
-the merchantability of this software or the suitability of this
-software for any particular purpose. It is provided "as is"
-without express or implied warranty of any kind.
-
-These notices must be retained in any copies of any part of this
-documentation and/or software.
- */
+/*
+** Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+** rights reserved.
+**
+** License to copy and use this software is granted provided that it
+** is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+** Algorithm" in all material mentioning or referencing this software
+** or this function.
+**
+** License is also granted to make and use derivative works provided
+** that such works are identified as "derived from the RSA Data
+** Security, Inc. MD5 Message-Digest Algorithm" in all material
+** mentioning or referencing the derived work.
+**
+** RSA Data Security, Inc. makes no representations concerning either
+** the merchantability of this software or the suitability of this
+** software for any particular purpose. It is provided "as is"
+** without express or implied warranty of any kind.
+**
+** These notices must be retained in any copies of any part of this
+** documentation and/or software.
+*/
/* MD5 context. */
typedef struct {
/*
- * mf.h -- include file for mailbox filters
- */
+** mf.h -- include file for mailbox filters
+*/
#include <h/nmh.h>
/*
- * Codes returned by uucp2mmdf(), mmdf2uucp()
- */
+** Codes returned by uucp2mmdf(), mmdf2uucp()
+*/
#define MFOK 0 /* all went well */
/* remaining codes must > DONE */
#define MFPRM 2 /* bad parameter */
/*
- * prototypes
- */
+** prototypes
+*/
char *legal_person (char *);
struct adrx *getadrx (char *);
/*
- * mh.h -- main header file for all of nmh
- */
+** mh.h -- main header file for all of nmh
+*/
#include <h/nmh.h>
/*
- * Well-used constants
- */
+** Well-used constants
+*/
#define NOTOK (-1) /* syscall()s return this on error */
#define OK 0 /* ditto on success */
#define DONE 1 /* trinary logic */
typedef unsigned char boolean; /* not int so we can pack in a structure */
/* If we're using gcc then give it some information about
- * functions that abort.
- */
+** functions that abort.
+*/
#if __GNUC__ > 2
# define NORETURN __attribute__((__noreturn__))
#else
#endif
/*
- * user context/profile structure
- */
+** user context/profile structure
+*/
struct node {
char *n_name; /* key */
char *n_field; /* value */
};
/*
- * switches structure
- */
+** switches structure
+*/
#define AMBIGSW (-2) /* from smatch() on ambiguous switch */
#define UNKWNSW (-1) /* from smatch() on unknown switch */
struct swit {
char *sw;
/*
- * The minchars field is apparently used like this:
- *
- * -# : Switch can be abbreviated to # chars; switch hidden in -help.
- * 0 : Switch can't be abbreviated; switch shown in -help.
- * # : Switch can be abbreviated to # chars; switch shown in -help.
- */
+ ** The minchars field is apparently used like this:
+ **
+ ** -# : Switch can be abbreviated to # chars; switch hidden in -help.
+ ** 0 : Switch can't be abbreviated; switch shown in -help.
+ ** # : Switch can be abbreviated to # chars; switch shown in -help.
+ */
int minchars;
};
#define ATTACHFORMATS 3 /* Number of send attach formats. */
/*
- * general folder attributes
- */
+** general folder attributes
+*/
#define READONLY (1<<0) /* No write access to folder */
#define SEQMOD (1<<1) /* folder's sequences modifed */
#define ALLOW_NEW (1<<2) /* allow the "new" sequence */
#define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_NEW\04OTHERS"
/*
- * type for holding the sequence set of a message
- */
+** type for holding the sequence set of a message
+*/
typedef unsigned int seqset_t;
/*
- * Determine the number of user defined sequences we
- * can have. The first 5 sequence flags are for
- * internal nmh message flags.
- */
+** Determine the number of user defined sequences we
+** can have. The first 5 sequence flags are for
+** internal nmh message flags.
+*/
#define NUMATTRS ((sizeof(seqset_t) * Nbby) - 5)
/*
- * first free slot for user defined sequences
- * and attributes
- */
+** first free slot for user defined sequences
+** and attributes
+*/
#define FFATTRSLOT 5
/*
- * internal messages attributes (sequences)
- */
+** internal messages attributes (sequences)
+*/
#define EXISTS (1<<0) /* exists */
#define DELETED (1<<1) /* deleted */
#define SELECTED (1<<2) /* selected for use */
#define MBITS "\020\01EXISTS\02DELETED\03SELECTED\04NEW\05UNSEEN"
/*
- * Primary structure of folder/message information
- */
+** Primary structure of folder/message information
+*/
struct msgs {
int lowmsg; /* Lowest msg number */
int hghmsg; /* Highest msg number */
char *foldpath; /* Pathname of folder */
/*
- * Name of sequences in this folder. We add an
- * extra slot, so we can NULL terminate the list.
- */
+ ** Name of sequences in this folder. We add an
+ ** extra slot, so we can NULL terminate the list.
+ */
char *msgattrs[NUMATTRS + 1];
/*
- * bit flags for whether sequence
- * is public (0), or private (1)
- */
+ ** bit flags for whether sequence
+ ** is public (0), or private (1)
+ */
seqset_t attrstats;
/*
- * These represent the lowest and highest possible
- * message numbers we can put in the message status
- * area, without calling folder_realloc().
- */
+ ** These represent the lowest and highest possible
+ ** message numbers we can put in the message status
+ ** area, without calling folder_realloc().
+ */
int lowoff;
int hghoff;
/*
- * This is an array of seqset_t which we allocate dynamically.
- * Each seqset_t is a set of bits flags for a particular message.
- * These bit flags represent general attributes such as
- * EXISTS, SELECTED, etc. as well as track if message is
- * in a particular sequence.
- */
+ ** This is an array of seqset_t which we allocate dynamically.
+ ** Each seqset_t is a set of bits flags for a particular message.
+ ** These bit flags represent general attributes such as
+ ** EXISTS, SELECTED, etc. as well as track if message is
+ ** in a particular sequence.
+ */
seqset_t *msgstats; /* msg status */
};
/*
- * Amount of space to allocate for msgstats. Allocate
- * the array to have space for messages numbers lo to hi.
- */
+** Amount of space to allocate for msgstats. Allocate
+** the array to have space for messages numbers lo to hi.
+*/
#define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats)))
/*
- * macros for message and sequence manipulation
- */
+** macros for message and sequence manipulation
+*/
#define clear_msg_flags(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = 0)
#define copy_msg_flags(mp,i,j) \
((mp)->msgstats[(i) - mp->lowoff] = (mp)->msgstats[(j) - mp->lowoff])
((mp)->attrstats = 0)
/*
- * macros for folder attributes
- */
+** macros for folder attributes
+*/
#define clear_folder_flags(mp) ((mp)->msgflags = 0)
#define is_readonly(mp) ((mp)->msgflags & READONLY)
#define NULLMP ((struct msgs *) 0)
/*
- * m_getfld() message parsing
- */
-
-#define NAMESZ 999 /* Limit on component name size.
- * RFC 2822 limits line lengths to
- * 998 characters, so a header name
- * can be at most that long.
- * m_getfld limits header names to 2
- * less than NAMESZ, which is fine,
- * because header names must be
- * followed by a colon. Add one for
- * terminating NULL.
- */
+** m_getfld() message parsing
+*/
+
+#define NAMESZ 999 /*
+ ** Limit on component name size.
+ ** RFC 2822 limits line lengths to
+ ** 998 characters, so a header name
+ ** can be at most that long.
+ ** m_getfld limits header names to 2
+ ** less than NAMESZ, which is fine,
+ ** because header names must be
+ ** followed by a colon. Add one for
+ ** terminating NULL.
+ */
#define LENERR (-2) /* Name too long error from getfld */
#define FMTERR (-3) /* Message Format error */
#define FILEEOF 5 /* Reached end of input file */
/*
- * Maildrop styles
- */
+** Maildrop styles
+*/
#define MS_DEFAULT 0 /* default (one msg per file) */
#define MS_UNKNOWN 1 /* type not known yet */
#define MS_MBOX 2 /* Unix-style "from" lines */
#define OUTPUTLINELEN 72 /* default line length for headers */
/*
- * miscellaneous macros
- */
+** miscellaneous macros
+*/
#define pidXwait(pid,cp) pidstatus (pidwait (pid, NOTOK), stdout, cp)
#endif
/*
- * GLOBAL VARIABLES
- */
+** GLOBAL VARIABLES
+*/
#define CTXMOD 0x01 /* context information modified */
#define DBITS "\020\01CTXMOD"
extern char ctxflags;
extern struct node *m_defs; /* list of profile/context entries */
/*
- * These standard strings are defined in config.c. They are the
- * only system-dependent parameters in nmh, and thus by redefining
- * their values and reloading the various modules, nmh will run
- * on any system.
- */
+** These standard strings are defined in config.c. They are the
+** only system-dependent parameters in nmh, and thus by redefining
+** their values and reloading the various modules, nmh will run
+** on any system.
+*/
extern char *buildmimeproc;
extern char *backup_prefix;
extern char *altmsglink;
/*
- * mhcachesbr.h -- definitions for manipulating MIME content cache
- */
+** mhcachesbr.h -- definitions for manipulating MIME content cache
+*/
/*
- * various cache policies
- */
+** various cache policies
+*/
static struct swit caches[] = {
#define CACHE_NEVER 0
{ "never", 0 },
/*
- * mhparse.h -- definitions for parsing/building of MIME content
- * -- (mhparse.c/mhbuildsbr.c)
- */
+** mhparse.h -- definitions for parsing/building of MIME content
+** -- (mhparse.c/mhbuildsbr.c)
+*/
#define NPARTS 50
#define NTYPES 20
#define NPARMS 10
/*
- * Abstract type for header fields
- */
+** Abstract type for header fields
+*/
typedef struct hfield *HF;
/*
- * Abstract types for MIME parsing/building
- */
+** Abstract types for MIME parsing/building
+*/
typedef struct cefile *CE;
typedef struct CTinfo *CI;
typedef struct Content *CT;
/*
- * type for Init function (both type and transfer encoding)
- */
+** type for Init function (both type and transfer encoding)
+*/
typedef int (*InitFunc) (CT);
/*
- * types for various transfer encoding access functions
- */
+** types for various transfer encoding access functions
+*/
typedef int (*OpenCEFunc) (CT, char **);
typedef void (*CloseCEFunc) (CT);
typedef unsigned long (*SizeCEFunc) (CT);
/*
- * Structure for storing/encoding/decoding
- * a header field and its value.
- */
+** Structure for storing/encoding/decoding
+** a header field and its value.
+*/
struct hfield {
char *name; /* field name */
char *value; /* field body */
};
/*
- * Structure for storing parsed elements
- * of the Content-Type component.
- */
+** Structure for storing parsed elements
+** of the Content-Type component.
+*/
struct CTinfo {
char *ci_type; /* content type */
char *ci_subtype; /* content subtype */
};
/*
- * Structure for storing decoded contents after
- * removing Content-Transfer-Encoding.
- */
+** Structure for storing decoded contents after
+** removing Content-Transfer-Encoding.
+*/
struct cefile {
char *ce_file; /* decoded content (file) */
FILE *ce_fp; /* decoded content (stream) */
};
/*
- * Primary structure for handling Content (Entity)
- */
+** Primary structure for handling Content (Entity)
+*/
struct Content {
/* source (read) file */
char *c_file; /* read contents (file) */
};
/*
- * Flags for Content-Type (Content->c_type)
- */
+** Flags for Content-Type (Content->c_type)
+*/
#define CT_UNKNOWN 0x00
#define CT_APPLICATION 0x01
#define CT_AUDIO 0x02
#define CT_EXTENSION 0x08
/*
- * Flags for Content-Transfer-Encoding (Content->c_encoding)
- */
+** Flags for Content-Transfer-Encoding (Content->c_encoding)
+*/
#define CE_UNKNOWN 0x00
#define CE_BASE64 0x01
#define CE_QUOTED 0x02
#define CE_EXTERNAL 0x07 /* for external-body */
/*
- * TEXT content
- */
+** TEXT content
+*/
/* Flags for subtypes of TEXT */
#define TEXT_UNKNOWN 0x00
};
/*
- * MULTIPART content
- */
+** MULTIPART content
+*/
/* Flags for subtypes of MULTIPART */
#define MULTI_UNKNOWN 0x00
};
/*
- * MESSAGE content
- */
+** MESSAGE content
+*/
/* Flags for subtypes of MESSAGE */
#define MESSAGE_UNKNOWN 0x00
};
/*
- * APPLICATION content
- */
+** APPLICATION content
+*/
/* Flags for subtype of APPLICATION */
#define APPLICATION_UNKNOWN 0x00
/*
- * Structures for mapping types to their internal flags
- */
+** Structures for mapping types to their internal flags
+*/
struct k2v {
char *kv_key;
int kv_value;
extern struct k2v SubApplication[];
/*
- * Structures for mapping (content) types to
- * the functions to handle them.
- */
+** Structures for mapping (content) types to
+** the functions to handle them.
+*/
struct str2init {
char *si_key;
int si_val;
extern struct str2init str2methods[];
/*
- * prototypes
- */
+** prototypes
+*/
int pidcheck (int);
CT parse_mime (char *);
int add_header (CT, char *, char *);
/*
- * mime.h -- definitions for MIME
- */
+** mime.h -- definitions for MIME
+*/
#define VRSN_FIELD "MIME-Version"
#define VRSN_VALUE "1.0"
&& (c) != '.' && (c) != '[' && (c) != ']')
/*
- * Test for valid characters used in "token"
- * as defined in RFC2045
- */
+** Test for valid characters used in "token"
+** as defined in RFC2045
+*/
#define istoken(c) (!isspace (c) && !iscntrl (c) && (c) != '(' \
&& (c) != ')' && (c) != '<' && (c) != '>' \
&& (c) != '@' && (c) != ',' && (c) != ';' \
/*
- * mts.h -- definitions for the mail system
- */
+** mts.h -- definitions for the mail system
+*/
/*
- * Local and UUCP Host Name
- */
+** Local and UUCP Host Name
+*/
char *LocalName(void);
char *SystemName(void);
/*
- * Mailboxes
- */
+** Mailboxes
+*/
extern char *mmdfldir;
extern char *mmdflfil;
extern char *uucpldir;
char *getfullname(void);
/*
- * Separators
- */
+** Separators
+*/
extern char *mmdlm1;
extern char *mmdlm2;
#define isdlm2(s) (strcmp (s, mmdlm2) == 0)
/*
- * Read mts.conf file
- */
+** Read mts.conf file
+*/
void mts_init (char *);
/*
- * Global MailDelivery File
- */
+** Global MailDelivery File
+*/
extern char *maildelivery;
/*
- * Aliasing Facility (doesn't belong here)
- */
+** Aliasing Facility (doesn't belong here)
+*/
extern int Everyone;
extern char *NoShell;
/*
- * nmh.h -- system configuration header file
- */
+** nmh.h -- system configuration header file
+*/
#include <config.h>
#endif
/*
- * symbolic constants for lseek and fseek
- */
+** symbolic constants for lseek and fseek
+*/
#ifndef SEEK_SET
# define SEEK_SET 0
#endif
#endif
/*
- * we should be getting this value from pathconf(_PC_PATH_MAX)
- */
+** we should be getting this value from pathconf(_PC_PATH_MAX)
+*/
#ifndef PATH_MAX
# ifdef MAXPATHLEN
# define PATH_MAX MAXPATHLEN
#endif
/*
- * we should get this value from sysconf(_SC_NGROUPS_MAX)
- */
+** we should get this value from sysconf(_SC_NGROUPS_MAX)
+*/
#ifndef NGROUPS_MAX
# ifdef NGROUPS
# define NGROUPS_MAX NGROUPS
#endif
/*
- * we should be getting this value from sysconf(_SC_OPEN_MAX)
- */
+** we should be getting this value from sysconf(_SC_OPEN_MAX)
+*/
#ifndef OPEN_MAX
# ifdef NOFILE
# define OPEN_MAX NOFILE
#endif
/*
- * If your stat macros are broken,
- * we will just undefine them.
- */
+** If your stat macros are broken,
+** we will just undefine them.
+*/
#ifdef STAT_MACROS_BROKEN
# ifdef S_ISBLK
# undef S_ISBLK
/*
- * picksbr.h -- definitions for picksbr.c
- */
+** picksbr.h -- definitions for picksbr.c
+*/
/*
- * prototypes
- */
+** prototypes
+*/
int pcompile (char **, char *);
int pmatches (FILE *, int, long, long);
/*
- * prototypes.h -- various prototypes
- */
+** prototypes.h -- various prototypes
+*/
/*
- * missing system prototypes
- */
+** missing system prototypes
+*/
#ifndef HAVE_TERMCAP_H
extern int tgetent (char *bp, char *name);
extern int tgetnum (char *id);
#endif
/*
- * prototype from config.h
- */
+** prototype from config.h
+*/
char *etcpath(char *);
/*
- * prototypes from the nmh subroutine library
- */
+** prototypes from the nmh subroutine library
+*/
void adios (char *, char *, ...) NORETURN;
void admonish (char *, char *, ...);
void advertise (char *, char *, char *, va_list);
#endif
/*
- * prototypes for compatibility functions in library
- */
+** prototypes for compatibility functions in library
+*/
#ifndef HAVE_SNPRINTF_PROTOTYPE
int snprintf (char *, size_t, const char *, ...);
int vsnprintf (char *, size_t, const char *, va_list);
/*
- * some prototypes for address parsing system
- * (others are in addrsbr.h)
- */
+** some prototypes for address parsing system
+** (others are in addrsbr.h)
+*/
char *LocalName(void);
char *SystemName(void);
char *OfficialName(char *);
/*
- * prototypes for some routines in uip
- */
+** prototypes for some routines in uip
+*/
int annotate (char *, char *, char *, int, int, int, int);
void annolist(char *, char *, char *, int);
void annopreserve(int);
int distout (char *, char *, char *);
void replout (FILE *, char *, char *, struct msgs *, int,
- int, char *, char *, char *);
+ int, char *, char *, char *);
int sendsbr (char **, int, char *, struct stat *, int, char *, int);
int what_now (char *, int, int, char *, char *,
- int, struct msgs *, char *, int, char *);
+ int, struct msgs *, char *, int, char *);
/*
- * rcvmail.h -- rcvmail hook definitions
- */
+** rcvmail.h -- rcvmail hook definitions
+*/
# include <ctype.h>
# include <errno.h>
/*
- * scansbr.h -- definitions for scan()
- */
+** scansbr.h -- definitions for scan()
+*/
extern char *scanl;
#define SCNFAT (-3) /* fatal error */
/*
- * default format for `scan' and `inc'
- */
+** default format for `scan' and `inc'
+*/
#ifndef UK
# define FORMAT \
"%4(msg)%<(cur)+%| %>%<{replied}-%?{encrypted}E%| %>\
#define WIDTH 78
/*
- * prototypes
- */
+** prototypes
+*/
int scan (FILE *, int, int, char *, int, int, int, char *, long, int);
/*
- * signals.h -- header file for nmh signal interface
- */
+** signals.h -- header file for nmh signal interface
+*/
#include <config.h>
/*
- * The type for a signal handler
- */
+** The type for a signal handler
+*/
typedef RETSIGTYPE (*SIGNAL_HANDLER)(int);
/*
- * If not a POSIX machine, then we create our
- * own POSIX style signal sets functions. This
- * currently assumes you have 31 signals, which
- * should be true on most pure BSD machines.
- */
+** If not a POSIX machine, then we create our
+** own POSIX style signal sets functions. This
+** currently assumes you have 31 signals, which
+** should be true on most pure BSD machines.
+*/
#ifndef POSIX_SIGNALS
# define sigemptyset(s) (*(s) = 0)
# define sigfillset(s) (*(s) = ~((sigset_t) 0), 0)
#endif
/*
- * prototypes
- */
+** prototypes
+*/
int SIGPROCMASK (int, const sigset_t *, sigset_t *);
SIGNAL_HANDLER SIGNAL (int, SIGNAL_HANDLER);
SIGNAL_HANDLER SIGNAL2 (int, SIGNAL_HANDLER);
/*
- * tws.h
- */
+** tws.h
+*/
/*
- * If the following is #defined, a timezone given as a numeric-only
- * offset will be treated specially if it's in a zone that observes
- * Daylight Saving Time. For instance, during DST, a Date: like "Mon,
- * 24 Jul 2000 12:31:44 -0700" will be printed as "Mon, 24 Jul 2000
- * 12:31:44 PDT". Without the code activated by the following #define,
- * that'd be incorrectly printed as "...MST".
- */
+** If the following is #defined, a timezone given as a numeric-only
+** offset will be treated specially if it's in a zone that observes
+** Daylight Saving Time. For instance, during DST, a Date: like "Mon,
+** 24 Jul 2000 12:31:44 -0700" will be printed as "Mon, 24 Jul 2000
+** 12:31:44 PDT". Without the code activated by the following #define,
+** that'd be incorrectly printed as "...MST".
+*/
#define ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST 1
struct tws {
extern char *tw_moty[];
/*
- * prototypes
- */
+** prototypes
+*/
char *dtime (time_t *, int);
char *dtimenow (int);
char *dctime (struct tws *);
/*
- * utils.h -- utility prototypes
- */
+** utils.h -- utility prototypes
+*/
void *mh_xmalloc(size_t);
void *mh_xrealloc(void *, size_t);
/*
- * addrsbr.c -- parse addresses 822-style
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** addrsbr.c -- parse addresses 822-style
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/addrsbr.h>
#include <h/mf.h>
/*
- * High level parsing of addresses:
- *
- * The routines in sbr/mf.c parse the syntactic representations of
- * addresses. The routines in sbr/addrsbr.c associate semantics with those
- * addresses.
- *
- * If #ifdef DUMB is in effect, a full 822-style parser is called
- * for syntax recongition. This breaks each address into its components.
- * Note however that no semantics are assumed about the parts or their
- * totality. This means that implicit hostnames aren't made explicit,
- * and explicit hostnames aren't expanded to their "official" represenations.
- *
- * If DUMB is not in effect, then this module does some
- * high-level thinking about what the addresses are.
- *
- * 1. for MMDF systems:
- *
- * string%<uucp>@<local> -> string
- *
- * 2. for non-MMDF systems:
- *
- * string@host.<uucp> -> host!string
- *
- * 3. for any system, an address interpreted relative to the local host:
- *
- * string@<uucp> -> string
- *
- * For cases (1) and (3) above, the leftmost host is extracted. If it's not
- * present, the local host is used. If the tests above fail, the address is
- * considered to be a real 822-style address.
- *
- * If an explicit host is not present, then MH checks for a bang to indicate
- * an explicit UUCP-style address. If so, this is noted. If not, the host is
- * defaulted, typically to the local host. The lack of an explict host is
- * also noted.
- *
- * If an explicit 822-style host is present, then MH checks to see if it
- * can expand this to the official name for the host. If the hostname is
- * unknown, the address is so typed.
- *
- * To summarize, when we're all done, here's what MH knows about the address:
- *
- * DUMB - type: local, uucp, or network
- * host: not locally defaulted, not explicitly expanded
- * everything else
- *
- * other - type: local, uucp, network, unknown
- * everything else
- */
+** High level parsing of addresses:
+**
+** The routines in sbr/mf.c parse the syntactic representations of
+** addresses. The routines in sbr/addrsbr.c associate semantics with those
+** addresses.
+**
+** If #ifdef DUMB is in effect, a full 822-style parser is called
+** for syntax recongition. This breaks each address into its components.
+** Note however that no semantics are assumed about the parts or their
+** totality. This means that implicit hostnames aren't made explicit,
+** and explicit hostnames aren't expanded to their "official" represenations.
+**
+** If DUMB is not in effect, then this module does some
+** high-level thinking about what the addresses are.
+**
+** 1. for MMDF systems:
+**
+** string%<uucp>@<local> -> string
+**
+** 2. for non-MMDF systems:
+**
+** string@host.<uucp> -> host!string
+**
+** 3. for any system, an address interpreted relative to the local host:
+**
+** string@<uucp> -> string
+**
+** For cases (1) and (3) above, the leftmost host is extracted. If it's not
+** present, the local host is used. If the tests above fail, the address is
+** considered to be a real 822-style address.
+**
+** If an explicit host is not present, then MH checks for a bang to indicate
+** an explicit UUCP-style address. If so, this is noted. If not, the host is
+** defaulted, typically to the local host. The lack of an explict host is
+** also noted.
+**
+** If an explicit 822-style host is present, then MH checks to see if it
+** can expand this to the official name for the host. If the hostname is
+** unknown, the address is so typed.
+**
+** To summarize, when we're all done, here's what MH knows about the address:
+**
+** DUMB - type: local, uucp, or network
+** host: not locally defaulted, not explicitly expanded
+** everything else
+**
+** other - type: local, uucp, network, unknown
+** everything else
+*/
static int ingrp = 0;
/*
- * external prototypes
- */
+** external prototypes
+*/
char *getusername (void);
#define WBITS "\020\01MBEG\02MEND\03HBEG\04HEND"
/*
- * Check if this is my address
- */
+** Check if this is my address
+*/
int
ismymbox (struct mailname *np)
static struct mailname mq={NULL};
/*
- * If this is the first call, initialize
- * list of alternate mailboxes.
- */
+ ** If this is the first call, initialize
+ ** list of alternate mailboxes.
+ */
if (am == NULL) {
mq.m_next = NULL;
mq.m_mbox = getusername ();
}
/*
- * Now scan through list of alternate
- * mailboxes, and check for a match.
- */
+ ** Now scan through list of alternate
+ ** mailboxes, and check for a match.
+ */
for (mp = &mq; mp->m_next;) {
mp = mp->m_next;
if (!np->m_mbox)
/*
- * Moved from hosts.c -- find out the official name of a host
- */
+** Moved from hosts.c -- find out the official name of a host
+*/
/*
- * In the SendMail world, we really don't know what the valid
- * hosts are. We could poke around in the sendmail.cf file, but
- * that still isn't a guarantee. As a result, we'll say that
- * everything is a valid host, and let SendMail worry about it.
- */
+** In the SendMail world, we really don't know what the valid
+** hosts are. We could poke around in the sendmail.cf file, but
+** that still isn't a guarantee. As a result, we'll say that
+** everything is a valid host, and let SendMail worry about it.
+*/
#include <h/mts.h>
#include <netdb.h>
/*
- * ambigsw.c -- report an ambiguous switch
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** ambigsw.c -- report an ambiguous switch
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * atooi.c -- octal version of atoi()
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** atooi.c -- octal version of atoi()
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * brkstring.c -- (destructively) split a string into
- * -- an array of substrings
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** brkstring.c -- (destructively) split a string into
+** -- an array of substrings
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
static int len = 0; /* current size of "broken" */
/*
- * static prototypes
- */
+** static prototypes
+*/
static int brkany (char, char *);
}
/*
- * scan string, replacing separators with zeroes
- * and enter start addresses in "broken".
- */
+ ** scan string, replacing separators with zeroes
+ ** and enter start addresses in "broken".
+ */
s = str;
for (i = 0;; i++) {
*s++ = '\0';
/*
- * we are either at the end of the string, or the
- * terminator found has been found, so finish up.
- */
+ ** we are either at the end of the string, or the
+ ** terminator found has been found, so finish up.
+ */
if (!c || brkany (c, brkterm)) {
*s = '\0';
broken[i] = NULL;
/*
- * If the character is in the string,
- * return 1, else return 0.
- */
+** If the character is in the string,
+** return 1, else return 0.
+*/
static int
brkany (char c, char *str)
/*
- * check_charset.c -- routines for character sets
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** check_charset.c -- routines for character sets
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#ifdef HAVE_LANGINFO_H
/*
- * Get the current character set
- */
+** Get the current character set
+*/
char *
get_charset ()
{
/*
- * Check if we can display a given character set natively.
- * We are passed the length of the initial part of the
- * string to check, since we want to allow the name of the
- * character set to be a substring of a larger string.
- */
+** Check if we can display a given character set natively.
+** We are passed the length of the initial part of the
+** string to check, since we want to allow the name of the
+** character set to be a substring of a larger string.
+*/
int
check_charset (char *str, int len)
/*
- * Return the name of the character set we are
- * using for 8bit text.
- */
+** Return the name of the character set we are
+** using for 8bit text.
+*/
char *
write_charset_8bit (void)
{
static char *mm_charset = NULL;
/*
- * Cache the name of the character set to
- * use for 8bit text.
- */
+ ** Cache the name of the character set to
+ ** use for 8bit text.
+ */
if (!mm_charset && !(mm_charset = get_charset ()))
mm_charset = "x-unknown";
/*
- * closefds.c -- close-up fd's
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** closefds.c -- close-up fd's
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * concat.c -- concatenate a variable number (minimum of 1)
- * of strings in managed memory
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** concat.c -- concatenate a variable number (minimum of 1)
+** of strings in managed memory
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
/*
- * context_del.c -- delete an entry from the context/profile list
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** context_del.c -- delete an entry from the context/profile list
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * Delete a key/value pair from the context/profile list.
- * Return 0 if key is found, else return 1.
- */
+** Delete a key/value pair from the context/profile list.
+** Return 0 if key is found, else return 1.
+*/
int
context_del (char *key)
/*
- * context_find.c -- find an entry in the context/profile list
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** context_find.c -- find an entry in the context/profile list
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * context_foil.c -- foil search of profile and context
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** context_foil.c -- foil search of profile and context
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
/*
- * Foil search of users .mh_profile
- * If error, return -1, else return 0
- */
+** Foil search of users .mh_profile
+** If error, return -1, else return 0
+*/
int
context_foil (char *path)
register struct node *np;
/* In fact, nobody examines defpath in code paths where
- * it's been set by us -- the uses in the source tree are:
- * 1 sbr/context_read.c uses it only after setting it itself
- * 2 uip/install_mh.c uses it only after setting it itself
- * 3 uip/mark.c print it if given the -debug switch
- * A worthwhile piece of code cleanup would be to make 1 and
- * 2 use a local variable and just delete 3.
- *
- * Similarly, context and ctxpath are not really used
- * outside the context_* routines. It might be worth combining
- * them into one file so the variables can be made static.
- */
+ ** it's been set by us -- the uses in the source tree are:
+ ** 1 sbr/context_read.c uses it only after setting it itself
+ ** 2 uip/install_mh.c uses it only after setting it itself
+ ** 3 uip/mark.c print it if given the -debug switch
+ ** A worthwhile piece of code cleanup would be to make 1 and
+ ** 2 use a local variable and just delete 3.
+ **
+ ** Similarly, context and ctxpath are not really used
+ ** outside the context_* routines. It might be worth combining
+ ** them into one file so the variables can be made static.
+ */
/* We set context to NULL to indicate that no context file
- * is to be read. (Using /dev/null doesn't work because we
- * would try to lock it, which causes timeouts with some
- * locking methods.)
- */
+ ** is to be read. (Using /dev/null doesn't work because we
+ ** would try to lock it, which causes timeouts with some
+ ** locking methods.)
+ */
defpath = context = NULL;
/*
- * If path is given, create a minimal profile/context list
- */
+ ** If path is given, create a minimal profile/context list
+ */
if (path) {
m_defs = (struct node *) mh_xmalloc (sizeof(*np));
/*
- * context_read.c -- find and read profile and context files
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- *
- * This function must be called early on in any nmh utility, and
- * may only be called once. It does the following:
- *
- * o Sets the global variable "mypath" to the home directory path.
- *
- * o Sets the global variable "defpath" to the absolute path of
- * the profile file.
- *
- * o Reads in the profile file. Bails out if it can't.
- *
- * o Makes sure that the mail directory exists, prompting for
- * creation if it doesn't.
- *
- * o Reads the context file either as set by the MHCONTEXT
- * environment variable or by the profile.
- */
+** context_read.c -- find and read profile and context files
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+**
+** This function must be called early on in any nmh utility, and
+** may only be called once. It does the following:
+**
+** o Sets the global variable "mypath" to the home directory path.
+**
+** o Sets the global variable "defpath" to the absolute path of
+** the profile file.
+**
+** o Reads in the profile file. Bails out if it can't.
+**
+** o Makes sure that the mail directory exists, prompting for
+** creation if it doesn't.
+**
+** o Reads the context file either as set by the MHCONTEXT
+** environment variable or by the profile.
+*/
#include <h/mh.h> /* mh internals */
#include <errno.h> /* system call errors */
register FILE *ib; /* profile and context file pointer */
/*
- * If this routine _is_ called again (despite the wanings in the
- * comments above), return immediately.
- */
+ ** If this routine _is_ called again (despite the wanings in the
+ ** comments above), return immediately.
+ */
if ( m_defs != 0 )
return;
/*
- * Find user's home directory. Try the HOME environment variable first,
- * the home directory field in the password file if that's not found.
- */
+ ** Find user's home directory. Try the HOME environment variable first,
+ ** the home directory field in the password file if that's not found.
+ */
if ((mypath = getenv("HOME")) == (char *)0) {
- if ((pw = getpwuid(getuid())) == (struct passwd *)0 || *pw->pw_dir == '\0')
- adios(NULL, "cannot determine your home directory");
- else
- mypath = pw->pw_dir;
+ if ((pw = getpwuid(getuid())) == (struct passwd *)0 || *pw->pw_dir == '\0')
+ adios(NULL, "cannot determine your home directory");
+ else
+ mypath = pw->pw_dir;
}
/*
- * Find and read user's profile. Check for the existence of an MH environment
- * variable first with non-empty contents. Convert any relative path name
- * found there to an absolute one. Look for the profile in the user's home
- * directory if the MH environment variable isn't set.
- */
+ ** Find and read user's profile. Check for the existence of
+ ** an MH environment variable first with non-empty contents.
+ ** Convert any relative path name found there to an absolute one.
+ ** Look for the profile in the user's home directory if the MH
+ ** environment variable isn't set.
+ */
if ((cp = getenv("MH")) && *cp != '\0') {
defpath = path(cp, TFILE);
fclose (ib);
/*
- * Find the user's nmh directory, which is specified by the "path" profile component.
- * Convert a relative path name to an absolute one rooted in the home directory.
- */
+ ** Find the user's nmh directory, which is specified by the "path"
+ ** profile component. Convert a relative path name to an absolute
+ ** one rooted in the home directory.
+ */
if ((cp = context_find ("path")) == (char *)0)
adios(NULL, "Your %s file does not contain a path entry.", defpath);
adios ((char *)0, "`%s' is not a directory", nd);
/*
- * Open and read user's context file. The name of the context file comes from the
- * profile unless overridden by the MHCONTEXT environment variable.
- */
+ ** Open and read user's context file. The name of the context
+ ** file comes from the profile unless overridden by the MHCONTEXT
+ ** environment variable.
+ */
if ((cp = getenv ("MHCONTEXT")) == (char *)0 || *cp == '\0')
cp = context;
- /* context is NULL if context_foil() was called to disable use of context
- * We also support users setting explicitly setting MHCONTEXT to /dev/null.
- * (if this wasn't specialcased then the locking would be liable to fail)
- */
+ /*
+ ** context is NULL if context_foil() was called to disable use
+ ** of context We also support users setting explicitly setting
+ ** MHCONTEXT to /dev/null. (if this wasn't specialcased then the
+ ** locking would be liable to fail)
+ */
if (!cp || (strcmp(cp,"/dev/null") == 0)) {
ctxpath = NULL;
return;
/*
- * context_replace.c -- add/replace an entry in the context/profile list
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** context_replace.c -- add/replace an entry in the context/profile list
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
register struct node *np;
/*
- * If list is emtpy, allocate head of profile/context list.
- */
+ ** If list is emtpy, allocate head of profile/context list.
+ */
if (!m_defs) {
m_defs = (struct node *) mh_xmalloc (sizeof(*np));
}
/*
- * Search list of context/profile entries for
- * this key, and replace its value if found.
- */
+ ** Search list of context/profile entries for
+ ** this key, and replace its value if found.
+ */
for (np = m_defs;; np = np->n_next) {
if (!mh_strcasecmp (np->n_name, key)) {
if (strcmp (value, np->n_field)) {
}
/*
- * Else add this new entry at the end
- */
+ ** Else add this new entry at the end
+ */
np->n_next = (struct node *) mh_xmalloc (sizeof(*np));
np = np->n_next;
/*
- * context_save.c -- write out the updated context file
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** context_save.c -- write out the updated context file
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/signals.h>
/*
- * static prototypes
- */
+** static prototypes
+*/
static int m_chkids(void);
}
/*
- * This hack brought to you so we can handle set[ug]id MH programs.
- * If we return -1, then no fork is made, we update .mh_profile
- * normally, and return to the caller normally. If we return 0,
- * then the child is executing, .mh_profile is modified after
- * we set our [ug]ids to the norm. If we return > 0, then the
- * parent is executed and .mh_profile has already be modified.
- * We can just return to the caller immediately.
- */
+** This hack brought to you so we can handle set[ug]id MH programs.
+** If we return -1, then no fork is made, we update .mh_profile
+** normally, and return to the caller normally. If we return 0,
+** then the child is executing, .mh_profile is modified after
+** we set our [ug]ids to the norm. If we return > 0, then the
+** parent is executed and .mh_profile has already be modified.
+** We can just return to the caller immediately.
+*/
static int
m_chkids (void)
/*
- * copy.c -- copy a string and return pointer to NULL terminator
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** copy.c -- copy a string and return pointer to NULL terminator
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * copyip.c -- copy a string array and return pointer to end
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** copyip.c -- copy a string array and return pointer to end
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * cpydata.c -- copy all data from one fd to another
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** cpydata.c -- copy all data from one fd to another
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * cpydgst.c -- copy from one fd to another in encapsulating mode
- * -- (do dashstuffing of input data).
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** cpydgst.c -- copy from one fd to another in encapsulating mode
+** -- (do dashstuffing of input data).
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * We want to perform the substitution
- *
- * \n(-.*)\n --> \n- \1\n
- *
- * This is equivalent to the sed substitution
- *
- * sed -e 's%^-%- -%' < ifile > ofile
- *
- * but the routine below is faster than the pipe, fork, and exec.
- */
+** We want to perform the substitution
+**
+** \n(-.*)\n --> \n- \1\n
+**
+** This is equivalent to the sed substitution
+**
+** sed -e 's%^-%- -%' < ifile > ofile
+**
+** but the routine below is faster than the pipe, fork, and exec.
+*/
#define S1 0
#define S2 1
/*
- * crawl_folders.c -- crawl folder hierarchy
- *
- * This code is Copyright (c) 2008, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** crawl_folders.c -- crawl folder hierarchy
+**
+** This code is Copyright (c) 2008, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/crawl_folders.h>
#include <h/utils.h>
struct crawl_context {
- int max; /* how many folders we currently can hold in the array
- * `folders', increased by CRAWL_NUMFOLDERS at a time */
+ int max; /*
+ ** how many folders we currently can hold in the array
+ ** `folders', increased by CRAWL_NUMFOLDERS at a time
+ */
int total; /* how many `folders' actually has */
char **folders; /* the array of folders */
int start;
};
/*
- * Add the folder name into the
- * list in a sorted fashion.
- */
+** Add the folder name into the
+** list in a sorted fashion.
+*/
static void
add_folder (char *fold, struct crawl_context *crawl)
}
while ((dp = readdir (dd))) {
- /* If the system supports it, try to skip processing of
- * children we know are not directories or symlinks. */
+ /*
+ ** If the system supports it, try to skip processing of
+ ** children we know are not directories or symlinks.
+ */
child_is_folder = -1;
#if defined(HAVE_STRUCT_DIRENT_D_TYPE)
if (dp->d_type == DT_DIR) {
continue;
}
child = concat (prefix, dp->d_name, (void *)NULL);
- /* If we have no d_type or d_type is DT_LNK or DT_UNKNOWN, stat the
- * child to see what it is. */
+ /*
+ ** If we have no d_type or d_type is DT_LNK or DT_UNKNOWN,
+ ** stat the child to see what it is.
+ */
if (child_is_folder == -1) {
child_is_folder = (stat (child, &st) != -1 && S_ISDIR(st.st_mode));
}
crawl_folders_body (crawl, dir, callback, baton);
- /* Note that we "leak" the folder names, on the assumption that the caller
- * is using them. */
+ /*
+ ** Note that we "leak" the folder names, on the assumption that the
+ ** caller is using them.
+ */
free (crawl->folders);
free (crawl);
}
/*
- * discard.c -- discard output on a file pointer
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** discard.c -- discard output on a file pointer
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * done.c -- terminate the program
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** done.c -- terminate the program
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * dtime.c -- time/date routines
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** dtime.c -- time/date routines
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h> /* for snprintf() */
#include <h/nmh.h>
#endif
/*
- * The number of days in the year, accounting for leap years
- */
+** The number of days in the year, accounting for leap years
+*/
#define dysize(y) \
(((y) % 4) ? 365 : (((y) % 100) ? 366 : (((y) % 400) ? 365 : 366)))
/*
- * Get current time (adjusted for local time
- * zone and daylight savings time) expressed
- * as nmh "broken-down" time structure.
- */
+** Get current time (adjusted for local time
+** zone and daylight savings time) expressed
+** as nmh "broken-down" time structure.
+*/
struct tws *
dlocaltimenow (void)
/*
- * Take clock value and return pointer to nmh time structure
- * containing "broken-down" time. The time is adjusted for
- * local time zone and daylight savings time.
- */
+** Take clock value and return pointer to nmh time structure
+** containing "broken-down" time. The time is adjusted for
+** local time zone and daylight savings time.
+*/
struct tws *
dlocaltime (time_t *clock)
/*
- * Take clock value and return pointer to nmh time
- * structure containing "broken-down" time. Time is
- * expressed in UTC (Coordinated Universal Time).
- */
+** Take clock value and return pointer to nmh time
+** structure containing "broken-down" time. Time is
+** expressed in UTC (Coordinated Universal Time).
+*/
struct tws *
dgmtime (time_t *clock)
/*
- * Using a nmh "broken-down" time structure,
- * produce a 26-byte date/time string, such as
- *
- * Tue Jan 14 17:49:03 1992\n\0
- */
+** Using a nmh "broken-down" time structure,
+** produce a 26-byte date/time string, such as
+**
+** Tue Jan 14 17:49:03 1992\n\0
+*/
char *
dctime (struct tws *tw)
/*
- * Produce a date/time string of the form
- *
- * Mon, 16 Jun 1992 15:30:48 -700 (or)
- * Mon, 16 Jun 1992 15:30:48 EDT
- *
- * for the current time, as specified by rfc822.
- * The first form is required by rfc1123.
- */
+** Produce a date/time string of the form
+**
+** Mon, 16 Jun 1992 15:30:48 -700 (or)
+** Mon, 16 Jun 1992 15:30:48 EDT
+**
+** for the current time, as specified by rfc822.
+** The first form is required by rfc1123.
+*/
char *
dtimenow (int alpha_timezone)
/*
- * Using a local calendar time value, produce
- * a date/time string of the form
- *
- * Mon, 16 Jun 1992 15:30:48 -700 (or)
- * Mon, 16 Jun 1992 15:30:48 EDT
- *
- * as specified by rfc822. The first form is required
- * by rfc1123 for outgoing messages.
- */
+** Using a local calendar time value, produce
+** a date/time string of the form
+**
+** Mon, 16 Jun 1992 15:30:48 -700 (or)
+** Mon, 16 Jun 1992 15:30:48 EDT
+**
+** as specified by rfc822. The first form is required
+** by rfc1123 for outgoing messages.
+*/
char *
dtime (time_t *clock, int alpha_timezone)
/*
- * Using a nmh "broken-down" time structure, produce
- * a date/time string of the form
- *
- * Mon, 16 Jun 1992 15:30:48 -0700
- *
- * as specified by rfc822 and rfc1123.
- */
+** Using a nmh "broken-down" time structure, produce
+** a date/time string of the form
+**
+** Mon, 16 Jun 1992 15:30:48 -0700
+**
+** as specified by rfc822 and rfc1123.
+*/
char *
dasctime (struct tws *tw, int flags)
/*
- * Get the timezone for given offset
- */
+** Get the timezone for given offset
+*/
char *
dtimezone (int offset, int flags)
/*
- * Convert nmh time structure for local "broken-down"
- * time to calendar time (clock value). This routine
- * is based on the gtime() routine written by Steven Shafer
- * at CMU. It was forwarded to MTR by Jay Lepreau at Utah-CS.
- */
+** Convert nmh time structure for local "broken-down"
+** time to calendar time (clock value). This routine
+** is based on the gtime() routine written by Steven Shafer
+** at CMU. It was forwarded to MTR by Jay Lepreau at Utah-CS.
+*/
time_t
dmktime (struct tws *tw)
/*
- * Simple calculation of day of the week. Algorithm
- * used is Zeller's congruence. We assume that
- * if tw->tw_year < 100, then the century = 19.
- */
+** Simple calculation of day of the week. Algorithm
+** used is Zeller's congruence. We assume that
+** if tw->tw_year < 100, then the century = 19.
+*/
void
set_dotw (struct tws *tw)
/*
- * Copy nmh time structure
- */
+** Copy nmh time structure
+*/
void
twscopy (struct tws *tb, struct tws *tw)
/*
- * Compare two nmh time structures
- */
+** Compare two nmh time structures
+*/
int
twsort (struct tws *tw1, struct tws *tw2)
/*
- * error.c -- main error handling routines
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** error.c -- main error handling routines
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * print out error message
- */
+** print out error message
+*/
void
advise (char *what, char *fmt, ...)
{
/*
- * print out error message and exit
- */
+** print out error message and exit
+*/
void
adios (char *what, char *fmt, ...)
{
/*
- * admonish the user
- */
+** admonish the user
+*/
void
admonish (char *what, char *fmt, ...)
{
/*
- * main routine for printing error messages.
- *
- * Use writev() if available, for slightly better performance.
- * Why? Well, there are a couple of reasons. Primarily, it
- * gives a smoother output... More importantly though, it's a
- * sexy syscall()...
- */
+** main routine for printing error messages.
+**
+** Use writev() if available, for slightly better performance.
+** Why? Well, there are a couple of reasons. Primarily, it
+** gives a smoother output... More importantly though, it's a
+** sexy syscall()...
+*/
void
advertise (char *what, char *tail, char *fmt, va_list ap)
{
/*
- * Run a program that hooks into some other system. The first argument is
- * name of the hook to use, the second is the full path name of a mail message.
- * The third argument is also the full path name of a mail message, or a NULL
- * pointer if it isn't needed. Look in the context for an error message if
- * something goes wrong; there is a built-in message in case one isn't
- * specified. Only produce the error message once.
- */
+** Run a program that hooks into some other system. The first argument is
+** name of the hook to use, the second is the full path name of a mail message.
+** The third argument is also the full path name of a mail message, or a NULL
+** pointer if it isn't needed. Look in the context for an error message if
+** something goes wrong; there is a built-in message in case one isn't
+** specified. Only produce the error message once.
+*/
#include <h/mh.h>
/*
- * fdcompare.c -- are two files identical?
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** fdcompare.c -- are two files identical?
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * fmt_addr.c -- format an address field (from fmt_scan)
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** fmt_addr.c -- format an address field (from fmt_scan)
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/addrsbr.h>
}
-/* fmt_scan will call this routine if the user includes the function
- * "(formataddr {component})" in a format string. "orig" is the
- * original contents of the string register. "str" is the address
- * string to be formatted and concatenated onto orig. This routine
- * returns a pointer to the concatenated address string.
- *
- * We try to not do a lot of malloc/copy/free's (which is why we
- * don't call "getcpy") but still place no upper limit on the
- * length of the result string.
- *
- * This routine is placed in a separate library so it can be
- * overridden by particular programs (e.g., "replsbr").
- */
+/*
+** fmt_scan will call this routine if the user includes the function
+** "(formataddr {component})" in a format string. "orig" is the
+** original contents of the string register. "str" is the address
+** string to be formatted and concatenated onto orig. This routine
+** returns a pointer to the concatenated address string.
+**
+** We try to not do a lot of malloc/copy/free's (which is why we
+** don't call "getcpy") but still place no upper limit on the
+** length of the result string.
+**
+** This routine is placed in a separate library so it can be
+** overridden by particular programs (e.g., "replsbr").
+*/
char *
formataddr (char *orig, char *str)
bufend = buf + bufsiz;
}
/*
- * If "orig" points to our buffer we can just pick up where we
- * left off. Otherwise we have to copy orig into our buffer.
- */
+ ** If "orig" points to our buffer we can just pick up where we
+ ** left off. Otherwise we have to copy orig into our buffer.
+ */
if (orig == buf)
dst = last_dst;
else if (!orig || !*orig) {
/*
- * fmt_compile.c -- "compile" format strings for fmt_scan
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** fmt_compile.c -- "compile" format strings for fmt_scan
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/addrsbr.h>
#endif
/*
- * hash table for deciding if a component is "interesting"
- */
+** hash table for deciding if a component is "interesting"
+*/
struct comp *wantcomp[128];
static struct format *formatvec; /* array to hold formats */
#define TF_NOP 8 /* like expr but no result */
/* ftable->flags */
-/* NB that TFL_PUTS is also used to decide whether the test
- * in a "%<(function)..." should be a string or numeric one.
- */
+/*
+** NB that TFL_PUTS is also used to decide whether the test
+** in a "%<(function)..." should be a string or numeric one.
+*/
#define TFL_PUTS 1 /* implicit putstr if top level */
#define TFL_PUTN 2 /* implicit putnum if top level */
#define CERROR(str) compile_error (str, cp)
/*
- * external prototypes
- */
+** external prototypes
+*/
extern char *getusername(void);
/*
- * static prototypes
- */
+** static prototypes
+*/
static struct ftable *lookup(char *);
static void compile_error(char *, char *);
static char *compile (char *);
}
/*
- * Compile format string "fstring" into format list "fmt".
- * Return the number of header components found in the format
- * string.
- */
+** Compile format string "fstring" into format list "fmt".
+** Return the number of header components found in the format
+** string.
+*/
int
fmt_compile(char *fstring, struct format **fmt)
memset((char *) &fmt_mnull, 0, sizeof(fmt_mnull));
- /* it takes at least 4 char to generate one format so we
- * allocate a worst-case format array using 1/4 the length
- * of the format string. We actually need twice this much
- * to handle both pre-processing (e.g., address parsing) and
- * normal processing.
- */
+ /*
+ ** it takes at least 4 char to generate one format so we
+ ** allocate a worst-case format array using 1/4 the length
+ ** of the format string. We actually need twice this much
+ ** to handle both pre-processing (e.g., address parsing) and
+ ** normal processing.
+ */
i = strlen(fstring)/2 + 1;
if (i == 1)
i++;
if (ftbl->f_type >= IF_FUNCS)
fp->f_type = ftbl->extra;
else {
- /* Put out a string test or a value
- * test depending on what this
- * function 's return type is.
- */
+ /*
+ ** Put out a string test or a value
+ ** test depending on what this
+ ** function 's return type is.
+ */
if (ftbl->flags & TFL_PUTS) {
LV (FT_IF_S, 0);
} else {
/*
- * fmt_def.c -- some defines for sbr/fmt_scan.c
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** fmt_def.c -- some defines for sbr/fmt_scan.c
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/addrsbr.h>
/*
- * fmt_new.c -- read format file/string and normalize
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** fmt_new.c -- read format file/string and normalize
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
static char *formats = 0;
/*
- * static prototypes
- */
+** static prototypes
+*/
static void normalize (char *);
/*
- * Get new format string
- */
+** Get new format string
+*/
char *
new_fs (char *form, char *format, char *default_fs)
/*
- * Expand escapes in format strings
- */
+** Expand escapes in format strings
+*/
static void
normalize (char *cp)
/*
- * fmt_rfc2047.c -- decode RFC-2047 header format
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** fmt_rfc2047.c -- decode RFC-2047 header format
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
/*
- * Decode the string as a RFC-2047 header field
- */
+** Decode the string as a RFC-2047 header field
+*/
/* Add character to the destination buffer, and bomb out if it fills up */
#define ADDCHR(C) do { *q++ = (C); dstlen--; if (!dstlen) goto buffull; } while (0)
return 0;
/*
- * Do a quick and dirty check for the '=' character.
- * This should quickly eliminate many cases.
- */
+ ** Do a quick and dirty check for the '=' character.
+ ** This should quickly eliminate many cases.
+ */
if (!strchr (str, '='))
return 0;
}
#endif
/*
- * If we had an '=' character pending from
- * last iteration, then add it first.
- */
+ ** If we had an '=' character pending from
+ ** last iteration, then add it first.
+ */
if (equals_pending) {
ADDCHR('=');
equals_pending = 0;
startofmime++;
/*
- * Scan ahead for the ending ?=
- *
- * While doing this, we will also check if encoded
- * word has any embedded linear whitespace.
- */
+ ** Scan ahead for the ending ?=
+ **
+ ** While doing this, we will also check if encoded
+ ** word has any embedded linear whitespace.
+ */
endofmime = NULL;
for (pp = startofmime; *pp && *(pp+1); pp++) {
if (is_lws(*pp)) {
continue;
/*
- * We've found an encoded word, so we can drop
- * the '=' that was pending
- */
+ ** We've found an encoded word, so we can drop
+ ** the '=' that was pending
+ */
equals_pending = 0;
/*
- * If we are between two encoded words separated only by
- * linear whitespace, then we ignore the whitespace.
- * We will roll back the buffer the number of whitespace
- * characters we've seen since last encoded word.
- */
+ ** If we are between two encoded words separated
+ ** only by linear whitespace, then we ignore
+ ** the whitespace. We will roll back the buffer
+ ** the number of whitespace characters we've seen
+ ** since last encoded word.
+ */
if (between_encodings) {
q -= whitespace;
dstlen += whitespace;
#ifdef HAVE_ICONV
/*
- * empty encoded text. This ensures that we don't
- * malloc 0 bytes but skip on to the end
- */
+ ** empty encoded text. This ensures that we don't
+ ** malloc 0 bytes but skip on to the end
+ */
if (endofmime == startofmime && use_iconv) {
use_iconv = 0;
iconv_close(cd);
savedstlen = dstlen;
q = convbuf = (char *) mh_xmalloc(endofmime - startofmime);
}
-/* ADDCHR2 is for adding characters when q is or might be convbuf:
- * in this case on buffer-full we want to run iconv before returning.
- * I apologise for the dreadful name.
- */
+/*
+** ADDCHR2 is for adding characters when q is or might be convbuf:
+** in this case on buffer-full we want to run iconv before returning.
+** I apologise for the dreadful name.
+*/
# define ADDCHR2(C) do { *q++ = (C); dstlen--; if (!dstlen) goto iconvbuffull; } while (0)
#else
# define ADDCHR2(C) ADDCHR(C)
#ifdef HAVE_ICONV
iconvbuffull:
- /* NB that the string at convbuf is not necessarily
- * NUL terminated here:
- * q points to the first byte after the valid part.
- */
+ /*
+ ** NB that the string at convbuf is not necessarily
+ ** NUL terminated here:
+ ** q points to the first byte after the valid part.
+ */
/* Convert to native character set */
if (use_iconv) {
size_t inbytes = q - convbuf;
(size_t)-1) {
if (errno != EILSEQ)
break;
- /* character couldn't be converted. we output a `?'
- * and try to carry on which won't work if
- * either encoding was stateful */
+ /*
+ ** character couldn't be
+ ** converted. we output a
+ ** `?' and try to carry on
+ ** which won't work if either
+ ** encoding was stateful
+ */
iconv (cd, 0, 0, &saveq, &savedstlen);
if (!savedstlen)
break;
}
}
q = saveq;
- /* Stop now if (1) we hit the end of the buffer trying to do
- * MIME decoding and have just iconv-converted a partial string
- * or (2) our iconv-conversion hit the end of the buffer.
- */
+ /*
+ ** Stop now if (1) we hit the end of the
+ ** buffer trying to do MIME decoding and
+ ** have just iconv-converted a partial
+ ** string or (2) our iconv-conversion hit
+ ** the end of the buffer.
+ */
if (!dstlen || !savedstlen)
goto buffull;
dstlen = savedstlen;
#endif
/*
- * Now that we are done decoding this particular
- * encoded word, advance string to trailing '='.
- */
+ ** Now that we are done decoding this particular
+ ** encoded word, advance string to trailing '='.
+ */
p = endofmime + 1;
encoding_found = 1; /* we found (at least 1) encoded word */
return encoding_found;
buffull:
- /* q is currently just off the end of the buffer,
- * so rewind to NUL terminate */
+ /*
+ ** q is currently just off the end of the buffer,
+ ** so rewind to NUL terminate
+ */
q--;
*q = '\0';
return encoding_found;
/*
- * fmt_scan.c -- format string interpretation
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** fmt_scan.c -- format string interpretation
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/addrsbr.h>
struct mailname fmt_mnull;
/*
- * static prototypes
- */
+** static prototypes
+*/
static int match (char *, char *);
static char *get_x400_friendly (char *, char *, int);
static int get_x400_comp (char *, char *, char *, int);
/*
- * test if string "sub" appears anywhere in
- * string "str" (case insensitive).
- */
+** test if string "sub" appears anywhere in
+** string "str" (case insensitive).
+*/
static int
match (char *str, char *sub)
}
/*
- * copy a number to the destination subject to a maximum width
- */
+** copy a number to the destination subject to a maximum width
+*/
static void
cpnumber(char **dest, int num, unsigned int wid, char fill, size_t n) {
int i, c;
}
/*
- * copy string from str to dest padding with the fill character to a size
- * of wid characters. if wid is negative, the string is right aligned
- * no more than n bytes are copied
- */
+** copy string from str to dest padding with the fill character to a size
+** of wid characters. if wid is negative, the string is right aligned
+** no more than n bytes are copied
+*/
static void
cptrimmed(char **dest, char *str, unsigned int wid, char fill, size_t n) {
int remaining; /* remaining output width available */
break;
case FT_FORMATADDR:
- /* hook for custom address list formatting (see replsbr.c) */
+ /*
+ ** hook for custom address list formatting
+ ** (see replsbr.c)
+ */
str = formataddr (savestr, str);
break;
case FT_PUTADDR:
- /* output the str register as an address component,
- * splitting it into multiple lines if necessary. The
- * value reg. contains the max line length. The lit.
- * field may contain a string to prepend to the result
- * (e.g., "To: ")
- */
+ /*
+ ** output the str register as an address component,
+ ** splitting it into multiple lines if necessary. The
+ ** value reg. contains the max line length. The lit.
+ ** field may contain a string to prepend to the result
+ ** (e.g., "To: ")
+ */
{
unsigned char *lp;
char *lastb;
case FT_MYMBOX:
/*
- * if there's no component, we say true. Otherwise we
- * say "true" only if we can parse the address and it
- * matches one of our addresses.
- */
+ ** if there's no component, we say true. Otherwise we
+ ** say "true" only if we can parse the address and it
+ ** matches one of our addresses.
+ */
comp = fmt->f_comp;
if (comp->c_mn != &fmt_mnull)
mnfree (comp->c_mn);
case FT_ADDTOSEQ:
#ifdef LBL
- /* If we're working on a folder (as opposed to a file), add the
- * current msg to sequence given in literal field. Don't
- * disturb string or value registers.
- */
+ /*
+ ** If we're working on a folder (as opposed to a
+ ** file), add the current msg to sequence given
+ ** in literal field. Don't disturb string or
+ ** value registers.
+ */
if (fmt_current_folder)
seq_addmsg(fmt_current_folder, fmt->f_text, dat[0], -1);
#endif
/*
- * folder_addmsg.c -- Link message into folder
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** folder_addmsg.c -- Link message into folder
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
#include <errno.h>
/*
- * Link message into a folder. Return the new number
- * of the message. If an error occurs, return -1.
- */
+** Link message into a folder. Return the new number
+** of the message. If an error occurs, return -1.
+*/
int
folder_addmsg (struct msgs **mpp, char *msgfile, int selected,
}
/*
- * We might need to make several attempts
- * in order to add the message to the folder.
- */
+ ** We might need to make several attempts
+ ** in order to add the message to the folder.
+ */
for (;; msgnum++) {
/*
- * See if we need more space. If we need space at the
- * end, then we allocate space for an addition 100 messages.
- * If we need space at the beginning of the range, then just
- * extend message status range to cover this message number.
- */
+ ** See if we need more space. If we need space at the
+ ** end, then we allocate space for an addition 100 messages.
+ ** If we need space at the beginning of the range, then just
+ ** extend message status range to cover this message number.
+ */
if (msgnum > mp->hghoff) {
if ((mp = folder_realloc (mp, mp->lowoff, msgnum + 100)))
*mpp = mp;
}
/*
- * If a message is already in that slot,
- * then loop to next available slot.
- */
+ ** If a message is already in that slot,
+ ** then loop to next available slot.
+ */
if (does_exist (mp, msgnum))
continue;
}
/*
- * check if this is highest or lowest message
- */
+ ** check if this is highest or lowest message
+ */
if (mp->nummsg == 0) {
mp->lowmsg = msgnum;
mp->hghmsg = msgnum;
snprintf (newmsg, sizeof(newmsg), "%s/%s", mp->foldpath, nmsg);
/*
- * Now try to link message into folder.
- * Then run the external hook on the message if one was specified in the context.
- * Run the refile hook if we're moving the message from one place to another.
- * We have to construct the from path name for this because it's not there.
- * Run the add hook if the message is getting copied or linked somewhere else.
- */
+ ** Now try to link message into folder. Then run the
+ ** external hook on the message if one was specified in
+ ** the context. Run the refile hook if we're moving the
+ ** message from one place to another. We have to construct
+ ** the from path name for this because it's not there.
+ ** Run the add hook if the message is getting copied or
+ ** linked somewhere else.
+ */
if (link (msgfile, newmsg) != -1) {
if (deleting) {
#endif /* EISREMOTE */
/*
- * Check if the file in our desired location is the same
- * as the source file. If so, then just leave it alone
- * and return. Otherwise, we will continue the main loop
- * and try again at another slot (hghmsg+1).
- */
+ ** Check if the file in our desired location is
+ ** the same as the source file. If so, then just
+ ** leave it alone and return. Otherwise, we will
+ ** continue the main loop and try again at another
+ ** slot (hghmsg+1).
+ */
if (linkerr == EEXIST) {
if (stat (msgfile, &st2) == 0 && stat (newmsg, &st1) == 0
&& st2.st_ino == st1.st_ino) {
}
/*
- * If link failed because we are trying to link
- * across devices, then check if there is a message
- * already in the desired location. If so, then return
- * error, else just copy the message.
- */
+ ** If link failed because we are trying to link
+ ** across devices, then check if there is a message
+ ** already in the desired location. If so, then return
+ ** error, else just copy the message.
+ */
if (linkerr == EXDEV) {
if (stat (newmsg, &st1) == 0) {
advise (NULL, "message %s:%s already exists", mp->foldpath, newmsg);
}
/*
- * Else, some other type of link error,
- * so just return error.
- */
+ ** Else, some other type of link error,
+ ** so just return error.
+ */
advise (newmsg, "error linking %s to", msgfile);
return -1;
}
/*
- * folder_delmsgs.c -- "remove" SELECTED messages from a folder
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** folder_delmsgs.c -- "remove" SELECTED messages from a folder
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * 1) If we are using an external rmmproc, then exec it.
- * 2) Else if unlink_msgs is non-zero, then unlink the
- * SELECTED messages.
- * 3) Else rename SELECTED messages by prefixing name
- * with backup_prefix.
- *
- * If there is an error, return -1, else return 0.
- */
+** 1) If we are using an external rmmproc, then exec it.
+** 2) Else if unlink_msgs is non-zero, then unlink the
+** SELECTED messages.
+** 3) Else rename SELECTED messages by prefixing name
+** with backup_prefix.
+**
+** If there is an error, return -1, else return 0.
+*/
int
folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook)
char msgpath[BUFSIZ];
/*
- * If "rmmproc" is defined, exec it to remove messages.
- */
+ ** If "rmmproc" is defined, exec it to remove messages.
+ */
if (rmmproc) {
/* Unset the EXISTS flag for each message to be removed */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
}
/*
- * Either unlink or rename the SELECTED messages
- */
+ ** Either unlink or rename the SELECTED messages
+ */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected (mp, msgnum)) {
/* unselect message */
mp->numsel--;
/*
- * Run the external hook on the message if one was specified in the context.
- * All we have is the message number; we have changed to the directory
- * containing the message. So, we need to extract that directory to form
- * the complete path. Note that the caller knows the directory, but has
- * no way of passing that to us.
- */
+ ** Run the external hook on the message if one
+ ** was specified in the context. All we have
+ ** is the message number; we have changed to
+ ** the directory containing the message. So,
+ ** we need to extract that directory to form the
+ ** complete path. Note that the caller knows the
+ ** directory, but has no way of passing that to us.
+ */
if (!nohook) {
(void)snprintf(msgpath, sizeof (msgpath), "%s/%d", mp->foldpath, msgnum);
/*
- * folder_free.c -- free a folder/message structure
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** folder_free.c -- free a folder/message structure
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * folder_pack.c -- pack (renumber) the messages in a folder
- * -- into a contiguous range from 1 to n.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** folder_pack.c -- pack (renumber) the messages in a folder
+** -- into a contiguous range from 1 to n.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * Pack the message in a folder.
- * Return -1 if error, else return 0.
- */
+** Pack the message in a folder.
+** Return -1 if error, else return 0.
+*/
int
folder_pack (struct msgs **mpp, int verbose)
mp = *mpp;
/*
- * Just return if folder is empty.
- */
+ ** Just return if folder is empty.
+ */
if (mp->nummsg == 0)
return 0;
/*
- * Make sure we have message status space allocated
- * for all numbers from 1 to current high message.
- */
+ ** Make sure we have message status space allocated
+ ** for all numbers from 1 to current high message.
+ */
if (mp->lowoff > 1) {
if ((mp = folder_realloc (mp, 1, mp->hghmsg)))
*mpp = mp;
printf ("message %s becomes %s\n", oldmsg, newmsg);
/*
- * Invoke the external refile hook for each message being renamed.
- * This is done before the file is renamed so that the old message
- * file is around for the hook.
- */
+ ** Invoke the external refile hook for each
+ ** message being renamed. This is done
+ ** before the file is renamed so that the
+ ** old message file is around for the hook.
+ */
(void)snprintf(oldmsg, sizeof (oldmsg), "%s/%d", mp->foldpath, msgnum);
(void)snprintf(newmsg, sizeof (newmsg), "%s/%d", mp->foldpath, hole);
if (msgnum == mp->hghsel)
mp->hghsel = hole;
- /* mark that sequence information has been modified */
+ /*
+ ** mark that sequence information has
+ ** been modified
+ */
mp->msgflags |= SEQMOD;
}
hole++;
/*
- * folder_read.c -- initialize folder structure and read folder
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** folder_read.c -- initialize folder structure and read folder
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
#define NUMMSGS 1024
/*
- * 1) Create the folder/message structure
- * 2) Read the directory (folder) and temporarily
- * record the numbers of the messages we have seen.
- * 3) Then allocate the array for message attributes and
- * set the initial flags for all messages we've seen.
- * 4) Read and initialize the sequence information.
- */
+** 1) Create the folder/message structure
+** 2) Read the directory (folder) and temporarily
+** record the numbers of the messages we have seen.
+** 3) Then allocate the array for message attributes and
+** set the initial flags for all messages we've seen.
+** 4) Read and initialize the sequence information.
+*/
struct msgs *
folder_read (char *name)
prefix_len = strlen(backup_prefix);
/*
- * Allocate a temporary place to record the
- * name of the messages in this folder.
- */
+ ** Allocate a temporary place to record the
+ ** name of the messages in this folder.
+ */
len = NUMMSGS;
mi = (int *) mh_xmalloc ((size_t) (len * sizeof(*mi)));
while ((dp = readdir (dd))) {
if ((msgnum = m_atoi (dp->d_name)) && msgnum > 0) {
/*
- * Check if we need to allocate more
- * temporary elements for message names.
- */
+ ** Check if we need to allocate more
+ ** temporary elements for message names.
+ */
if (mp->nummsg >= len) {
len += NUMMSGS;
mi = (int *) mh_xrealloc (mi, (size_t) (len * sizeof(*mi)));
mp->lowmsg = msgnum;
mp->hghmsg = msgnum;
} else {
- /* Check if this is it the highest or lowest we've seen? */
+ /*
+ ** Check if this is it the highest or
+ ** lowest we've seen?
+ */
if (msgnum < mp->lowmsg)
mp->lowmsg = msgnum;
if (msgnum > mp->hghmsg)
}
/*
- * Now increment count, and record message
- * number in a temporary place for now.
- */
+ ** Now increment count, and record message
+ ** number in a temporary place for now.
+ */
mi[mp->nummsg++] = msgnum;
} else {
continue;
default:
- /* skip any files beginning with backup prefix */
+ /*
+ ** skip any files beginning with
+ ** backup prefix
+ */
if (!strncmp (dp->d_name, backup_prefix, prefix_len))
continue;
if (!strcmp (dp->d_name, altmsglink))
continue;
- /* indicate that there are other files in folder */
+ /*
+ ** indicate that there are other
+ ** files in folder
+ */
set_other_files (mp);
continue;
}
/* mp->hghoff = max (mp->hghmsg, 1); */
/*
- * Allocate space for status of each message.
- */
+ ** Allocate space for status of each message.
+ */
mp->msgstats = mh_xmalloc (MSGSTATSIZE(mp, mp->lowoff, mp->hghoff));
/*
- * Clear all the flag bits for all the message
- * status entries we just allocated.
- */
+ ** Clear all the flag bits for all the message
+ ** status entries we just allocated.
+ */
for (msgnum = mp->lowoff; msgnum <= mp->hghoff; msgnum++)
clear_msg_flags (mp, msgnum);
/*
- * Scan through the array of messages we've seen and
- * setup the initial flags for those messages in the
- * newly allocated mp->msgstats area.
- */
+ ** Scan through the array of messages we've seen and
+ ** setup the initial flags for those messages in the
+ ** newly allocated mp->msgstats area.
+ */
for (msgnum = 0; msgnum < mp->nummsg; msgnum++)
set_exists (mp, mi[msgnum]);
free (mi); /* We don't need this anymore */
/*
- * Read and initialize the sequence information.
- */
+ ** Read and initialize the sequence information.
+ */
seq_read (mp);
return mp;
/*
- * folder_realloc.c -- realloc a folder/msgs structure
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** folder_realloc.c -- realloc a folder/msgs structure
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
/*
- * Reallocate some of the space in the folder
- * structure (currently just message status array).
- *
- * Return pointer to new folder structure.
- * If error, return NULL.
- */
+** Reallocate some of the space in the folder
+** structure (currently just message status array).
+**
+** Return pointer to new folder structure.
+** If error, return NULL.
+*/
struct msgs *
folder_realloc (struct msgs *mp, int lo, int hi)
if (lo == mp->lowoff) {
/*
- * We are just extending (or shrinking) the end of message
- * status array. So we don't have to move anything and can
- * just realloc the message status array.
- */
+ ** We are just extending (or shrinking) the end of message
+ ** status array. So we don't have to move anything and can
+ ** just realloc the message status array.
+ */
mp->msgstats = mh_xrealloc (mp->msgstats, MSGSTATSIZE(mp, lo, hi));
} else {
/*
- * We are changing the offset of the message status
- * array. So we will need to shift everything.
- */
+ ** We are changing the offset of the message status
+ ** array. So we will need to shift everything.
+ */
seqset_t *tmpstats;
/* first allocate the new message status space */
mp->hghoff = hi;
/*
- * Clear all the flags for entries outside
- * the current message range for this folder.
- */
+ ** Clear all the flags for entries outside
+ ** the current message range for this folder.
+ */
if (mp->nummsg > 0) {
for (msgnum = mp->lowoff; msgnum < mp->lowmsg; msgnum++)
clear_msg_flags (mp, msgnum);
/*
- * gans.c -- get an answer from the user
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** gans.c -- get an answer from the user
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * getans.c -- get an answer from the user and return a string array
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** getans.c -- get an answer from the user and return a string array
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/signals.h>
static jmp_buf sigenv;
/*
- * static prototypes
- */
+** static prototypes
+*/
static RETSIGTYPE intrser (int);
intrser (int i)
{
/*
- * should this be siglongjmp?
- */
+ ** should this be siglongjmp?
+ */
longjmp (sigenv, 1);
}
/*
- * getanswer.c -- get a yes/no answer from the user
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** getanswer.c -- get a yes/no answer from the user
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <stdio.h>
/*
- * getarguments.c -- Get the argument vector ready to go.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** getarguments.c -- Get the argument vector ready to go.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
int n = 0;
/*
- * Check if profile/context specifies any arguments
- */
+ ** Check if profile/context specifies any arguments
+ */
if (check_context && (cp = context_find (invo_name))) {
cp = getcpy (cp); /* make copy */
ap = brkstring (cp, " ", "\n"); /* split string */
/*
- * getcpy.c -- copy a string in managed memory
- *
- * THIS IS OBSOLETE. NEED TO REPLACE ALL OCCURENCES
- * OF GETCPY WITH STRDUP. BUT THIS WILL REQUIRE
- * CHANGING PARTS OF THE CODE TO DEAL WITH NULL VALUES.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** getcpy.c -- copy a string in managed memory
+**
+** THIS IS OBSOLETE. NEED TO REPLACE ALL OCCURENCES
+** OF GETCPY WITH STRDUP. BUT THIS WILL REQUIRE
+** CHANGING PARTS OF THE CODE TO DEAL WITH NULL VALUES.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
/*
- * getfolder.c -- get the current or default folder
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** getfolder.c -- get the current or default folder
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
register char *folder;
/*
- * If wantcurrent == 1, then try the current folder first
- */
+ ** If wantcurrent == 1, then try the current folder first
+ */
if (wantcurrent && (folder = context_find (pfolder)) && *folder != '\0')
return folder;
/*
- * Else try the Inbox profile entry
- */
+ ** Else try the Inbox profile entry
+ */
if ((folder = context_find (inbox)) && *folder != '\0')
return folder;
/*
- * Else return compile time default.
- */
+ ** Else return compile time default.
+ */
return defaultfolder;
}
/*
- * Portions of this code are Copyright (c) 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
+** Portions of this code are Copyright (c) 1988, 1993
+** The Regents of the University of California. All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+** 1. Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in the
+** documentation and/or other materials provided with the distribution.
+** 3. All advertising materials mentioning features or use of this software
+** must display the following acknowledgement:
+** This product includes software developed by the University of
+** California, Berkeley and its contributors.
+** 4. Neither the name of the University nor the names of its contributors
+** may be used to endorse or promote products derived from this software
+** without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+** ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+** SUCH DAMAGE.
+*/
#include <stdio.h>
#include <termios.h>
#include <unistd.h> /* for isatty() */
#include "h/mh.h" /* for adios() */
-/* We don't use MAX_PASS here because the maximum password length on a remote
- POP daemon will have nothing to do with the length on our OS. 256 is
- arbitrary but hopefully big enough to accomodate everyone. */
+/*
+** We don't use MAX_PASS here because the maximum password length on a remote
+** POP daemon will have nothing to do with the length on our OS. 256 is
+** arbitrary but hopefully big enough to accomodate everyone.
+*/
#define MAX_PASSWORD_LEN 256
#ifndef TCSANOW
static char buf[MAX_PASSWORD_LEN + 1];
int istty = isatty(fileno(stdin));
- /* Find if stdin is connect to a terminal. If so, read directly from
- * the terminal, and turn off echo. Otherwise read from stdin.
- */
+ /*
+ ** Find if stdin is connect to a terminal. If so, read directly from
+ ** the terminal, and turn off echo. Otherwise read from stdin.
+ */
if (!istty || !(fout = fin = fopen("/dev/tty", "w+"))) {
fout = stderr;
/*
- * lock.c -- routines to lock/unlock files
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
-
-/* Modified by Ruud de Rooij to support Miquel van Smoorenburg's liblockfile
- *
- * Since liblockfile locking shares most of its code with dot locking, it
- * is enabled by defining both DOT_LOCKING and HAVE_LIBLOCKFILE.
- *
- * Ruud de Rooij <ruud@debian.org> Sun, 28 Mar 1999 15:34:03 +0200
- */
+** lock.c -- routines to lock/unlock files
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
+
+/*
+** Modified by Ruud de Rooij to support Miquel van Smoorenburg's liblockfile
+**
+** Since liblockfile locking shares most of its code with dot locking, it
+** is enabled by defining both DOT_LOCKING and HAVE_LIBLOCKFILE.
+**
+** Ruud de Rooij <ruud@debian.org> Sun, 28 Mar 1999 15:34:03 +0200
+*/
#include <h/mh.h>
#include <h/signals.h>
};
/*
- * Amount of time to wait before
- * updating ctime of lock file.
- */
+** Amount of time to wait before
+** updating ctime of lock file.
+*/
#define NSECS 20
#if !defined(HAVE_LIBLOCKFILE)
/*
- * How old does a lock file need to be
- * before we remove it.
- */
+** How old does a lock file need to be
+** before we remove it.
+*/
#define RSECS 180
#endif /* HAVE_LIBLOCKFILE */
#endif /* DOT_LOCKING */
/*
- * static prototypes
- */
+** static prototypes
+*/
#ifdef KERNEL_LOCKING
static int lkopen_kernel (char *, int, mode_t);
#endif
#endif
/*
- * Base routine to open and lock a file,
- * and return a file descriptor.
- */
+** Base routine to open and lock a file,
+** and return a file descriptor.
+*/
int
lkopen (char *file, int access, mode_t mode)
/*
- * Base routine to close and unlock a file,
- * given a file descriptor.
- */
+** Base routine to close and unlock a file,
+** given a file descriptor.
+*/
int
lkclose (int fd, char *file)
/*
- * Base routine to open and lock a file,
- * and return a FILE pointer
- */
+** Base routine to open and lock a file,
+** and return a FILE pointer
+*/
FILE *
lkfopen (char *file, char *mode)
/*
- * Base routine to close and unlock a file,
- * given a FILE pointer
- */
+** Base routine to close and unlock a file,
+** given a FILE pointer
+*/
int
lkfclose (FILE *fp, char *file)
#ifdef KERNEL_LOCKING
/*
- * open and lock a file, using kernel locking
- */
+** open and lock a file, using kernel locking
+*/
static int
lkopen_kernel (char *file, int access, mode_t mode)
access &= ~O_APPEND;
/*
- * We MUST have write permission or
- * lockf/fcntl() won't work
- */
+ ** We MUST have write permission or
+ ** lockf/fcntl() won't work
+ */
if ((access & 03) == O_RDONLY) {
access &= ~O_RDONLY;
access |= O_RDWR;
#ifdef DOT_LOCKING
/*
- * open and lock a file, using dot locking
- */
+** open and lock a file, using dot locking
+*/
static int
lkopen_dot (char *file, int access, mode_t mode)
return -1;
/*
- * Get the name of the eventual lock file, as well
- * as a name for a temporary lock file.
- */
+ ** Get the name of the eventual lock file, as well
+ ** as a name for a temporary lock file.
+ */
lockname (file, &lkinfo, 1);
#if !defined(HAVE_LIBLOCKFILE)
return fd;
} else {
/*
- * Abort locking, if we fail to lock after 5 attempts
- * and are never able to stat the lock file.
- */
+ ** Abort locking, if we fail to lock after 5
+ ** attempts and are never able to stat the
+ ** lock file.
+ */
struct stat st;
if (stat (lkinfo.curlock, &st) == -1) {
if (i++ > 5)
i = 0;
time (&curtime);
- /* check for stale lockfile, else sleep */
+ /*
+ ** check for stale lockfile,
+ ** else sleep
+ */
if (curtime > st.st_ctime + RSECS)
unlink (lkinfo.curlock);
else
#if !defined(HAVE_LIBLOCKFILE)
/*
- * Routine that actually tries to create
- * the lock file.
- */
+** Routine that actually tries to create
+** the lock file.
+*/
static int
lockit (struct lockinfo *li)
close (fd);
/*
- * Now try to create the real lock file
- * by linking to the temporary file.
- */
+ ** Now try to create the real lock file
+ ** by linking to the temporary file.
+ */
fd = link(tmplock, curlock);
unlink(tmplock);
#endif /* HAVE_LIBLOCKFILE */
/*
- * Get name of lock file, and temporary lock file
- */
+** Get name of lock file, and temporary lock file
+*/
static void
lockname (char *file, struct lockinfo *li, int isnewlock)
#if 0
/*
- * mmdf style dot locking. Currently not supported.
- * If we start supporting mmdf style dot locking,
- * we will need to change the return value of lockname
- */
+ ** mmdf style dot locking. Currently not supported.
+ ** If we start supporting mmdf style dot locking,
+ ** we will need to change the return value of lockname
+ */
if (stat (file, &st) == -1)
return -1;
#if !defined(HAVE_LIBLOCKFILE)
/*
- * If this is for a new lock, create a name for
- * the temporary lock file for lockit()
- */
+ ** If this is for a new lock, create a name for
+ ** the temporary lock file for lockit()
+ */
if (isnewlock) {
if ((cp = strrchr (li->curlock, '/')) == NULL || *++cp == 0)
strncpy (li->tmplock, ",LCK.XXXXXX", sizeof(li->tmplock));
/*
- * Add new lockfile to the list of open lockfiles
- * and start the lock file timer.
- */
+** Add new lockfile to the list of open lockfiles
+** and start the lock file timer.
+*/
static void
timerON (char *curlock, int fd)
/*
- * Search through the list of lockfiles for the
- * current lockfile, and remove it from the list.
- */
+** Search through the list of lockfiles for the
+** current lockfile, and remove it from the list.
+*/
static void
timerOFF (int fd)
/*
- * If timer goes off, we update the ctime of all open
- * lockfiles, so another command doesn't remove them.
- */
+** If timer goes off, we update the ctime of all open
+** lockfiles, so another command doesn't remove them.
+*/
static RETSIGTYPE
alrmser (int sig)
/*
- * m_atoi.c -- Parse a string representation of a message number, and
- * -- return the numeric value of the message. If the string
- * -- contains any non-digit characters, then return 0.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** m_atoi.c -- Parse a string representation of a message number, and
+** -- return the numeric value of the message. If the string
+** -- contains any non-digit characters, then return 0.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * m_backup.c -- construct a backup file
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** m_backup.c -- construct a backup file
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * m_convert.c -- parse a message range or sequence and set SELECTED
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** m_convert.c -- parse a message range or sequence and set SELECTED
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * error codes for sequence
- * and message range processing
- */
+** error codes for sequence
+** and message range processing
+*/
#define BADMSG (-2)
#define BADRNG (-3)
#define BADNEW (-4)
static char *delimp;
/*
- * static prototypes
- */
+** static prototypes
+*/
static int m_conv (struct msgs *, char *, int);
static int attr (struct msgs *, char *);
else if (err > 0)
return 1;
/*
- * else err == 0, so continue
- */
+ ** else err == 0, so continue
+ */
found = 0;
/*
- * Check for special "new" sequence, which
- * is valid only if ALLOW_NEW is set.
- */
+ ** Check for special "new" sequence, which
+ ** is valid only if ALLOW_NEW is set.
+ */
if ((mp->msgflags & ALLOW_NEW) && !strcmp (cp, "new")) {
if ((err = first = getnew (mp)) <= 0)
goto badmsg;
cp = delimp;
if (*cp != '\0' && *cp != '-' && *cp != ':') {
badelim:
- advise (NULL, "illegal argument delimiter: `%c'(0%o)", *delimp, *delimp);
+ advise (NULL, "illegal argument delimiter: `%c'(0%o)",
+ *delimp, *delimp);
return 0;
}
break;
case BADRNG:
- advise (NULL, "message %s out of range 1-%d", cp, mp->hghmsg);
+ advise (NULL, "message %s out of range 1-%d",
+ cp, mp->hghmsg);
break;
case BADLST:
break;
case BADNEW:
- advise (NULL, "folder full, no %s message", name);
+ advise (NULL, "folder full, no %s message",
+ name);
break;
default:
single:
/*
- * Single Message
- *
- * If ALLOW_NEW is set, then allow selecting of an
- * empty slot. If ALLOW_NEW is not set, then we
- * check if message is in-range and exists.
- */
+ ** Single Message
+ **
+ ** If ALLOW_NEW is set, then allow selecting of an
+ ** empty slot. If ALLOW_NEW is not set, then we
+ ** check if message is in-range and exists.
+ */
if (mp->msgflags & ALLOW_NEW) {
set_select_empty (mp, first);
} else {
}
/*
- * Cycle through the range and select the messages
- * that exist. If ALLOW_NEW is set, then we also check
- * if we are selecting an empty slot.
- */
+ ** Cycle through the range and select the messages
+ ** that exist. If ALLOW_NEW is set, then we also check
+ ** if we are selecting an empty slot.
+ */
for (; first <= last; first++) {
if (does_exist (mp, first) ||
((mp->msgflags & ALLOW_NEW) && is_select_empty (mp, first))) {
}
/*
- * Convert the various message names to
- * their numeric values.
- *
- * n (integer)
- * prev
- * next
- * first
- * last
- * cur
- * . (same as cur)
- */
+** Convert the various message names to
+** their numeric values.
+**
+** n (integer)
+** prev
+** next
+** first
+** last
+** cur
+** . (same as cur)
+*/
static int
m_conv (struct msgs *mp, char *str, int call)
}
/*
- * Handle user defined sequences.
- * They can take the following forms:
- *
- * seq
- * seq:prev
- * seq:next
- * seq:first
- * seq:last
- * seq:+n
- * seq:-n
- * seq:n
- */
+** Handle user defined sequences.
+** They can take the following forms:
+**
+** seq
+** seq:prev
+** seq:next
+** seq:first
+** seq:last
+** seq:+n
+** seq:-n
+** seq:n
+*/
static int
attr (struct msgs *mp, char *cp)
range = 1;
/*
- * seq:prev (or)
- * seq:next (or)
- * seq:first (or)
- * seq:last
- */
+ ** seq:prev (or)
+ ** seq:next (or)
+ ** seq:first (or)
+ ** seq:last
+ */
if (isalpha (*dp)) {
if (!strcmp (dp, "prev")) {
convdir = -1;
return BADLST;
} else {
/*
- * seq:n (or)
- * seq:+n (or)
- * seq:-n
- */
+ ** seq:n (or)
+ ** seq:+n (or)
+ ** seq:-n
+ */
if (*dp == '+')
dp++;
else if (*dp == '-') {
found++;
/*
- * If we have a range, then break out
- * once we've found enough.
- */
+ ** If we have a range, then break out
+ ** once we've found enough.
+ */
if (range && found >= range)
break;
}
/*
- * m_draft.c -- construct the name of a draft message
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** m_draft.c -- construct the name of a draft message
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
adios (NULL, "unable to read folder %s", folder);
/*
- * Make sure we have enough message status space for all
- * the message numbers from 1 to "new", since we might
- * select an empty slot. If we add more space at the
- * end, go ahead and add 10 additional slots.
- */
+ ** Make sure we have enough message status space for all
+ ** the message numbers from 1 to "new", since we might
+ ** select an empty slot. If we add more space at the
+ ** end, go ahead and add 10 additional slots.
+ */
if (mp->hghmsg >= mp->hghoff) {
if (!(mp = folder_realloc (mp, 1, mp->hghmsg + 10)))
adios (NULL, "unable to allocate folder storage");
mp->msgflags |= ALLOW_NEW; /* allow the "new" sequence */
/*
- * The draft message name to return is defined by `which'.
- * Usually it is "cur" (for the current draft) or "new"
- * (to start a new draft).
- */
+ ** The draft message name to return is defined by `which'.
+ ** Usually it is "cur" (for the current draft) or "new"
+ ** (to start a new draft).
+ */
if (!m_convert (mp, which))
done (1);
seq_setprev (mp);
/*
- * m_getfld.c -- read/parse a message
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** m_getfld.c -- read/parse a message
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/mts.h>
#include <h/utils.h>
-/* This module has a long and checkered history. First, it didn't burst
- maildrops correctly because it considered two CTRL-A:s in a row to be
- an inter-message delimiter. It really is four CTRL-A:s followed by a
- newline. Unfortunately, MMDF will convert this delimiter *inside* a
- message to a CTRL-B followed by three CTRL-A:s and a newline. This
- caused the old version of m_getfld() to declare eom prematurely. The
- fix was a lot slower than
-
- c == '\001' && peekc (iob) == '\001'
-
- but it worked, and to increase generality, MBOX style maildrops could
- be parsed as well. Unfortunately the speed issue finally caught up with
- us since this routine is at the very heart of MH.
-
- To speed things up considerably, the routine Eom() was made an auxilary
- function called by the macro eom(). Unless we are bursting a maildrop,
- the eom() macro returns FALSE saying we aren't at the end of the
- message.
-
- The next thing to do is to read the mts.conf file and initialize
- delimiter[] and delimlen accordingly...
-
- After mhl was made a built-in in msh, m_getfld() worked just fine
- (using m_unknown() at startup). Until one day: a message which was
- the result of a bursting was shown. Then, since the burst boundaries
- aren't CTRL-A:s, m_getfld() would blinding plunge on past the boundary.
- Very sad. The solution: introduce m_eomsbr(). This hook gets called
- after the end of each line (since testing for eom involves an fseek()).
- This worked fine, until one day: a message with no body portion arrived.
- Then the
-
- while (eom (c = Getc (iob), iob))
- continue;
-
- loop caused m_getfld() to return FMTERR. So, that logic was changed to
- check for (*eom_action) and act accordingly.
-
- [ Note by meillo 2011-10:
- as msh was removed from mmh, m_eomsbr() became irrelevant. ]
-
- This worked fine, until one day: someone didn't use four CTRL:A's as
- their delimiters. So, the bullet got bit and we read mts.h and
- continue to struggle on. It's not that bad though, since the only time
- the code gets executed is when inc (or msh) calls it, and both of these
- have already called mts_init().
-
- ------------------------
- (Written by Van Jacobson for the mh6 m_getfld, January, 1986):
-
- This routine was accounting for 60% of the cpu time used by most mh
- programs. I spent a bit of time tuning and it now accounts for <10%
- of the time used. Like any heavily tuned routine, it's a bit
- complex and you want to be sure you understand everything that it's
- doing before you start hacking on it. Let me try to emphasize
- that: every line in this atrocity depends on every other line,
- sometimes in subtle ways. You should understand it all, in detail,
- before trying to change any part. If you do change it, test the
- result thoroughly (I use a hand-constructed test file that exercises
- all the ways a header name, header body, header continuation,
- header-body separator, body line and body eom can align themselves
- with respect to a buffer boundary). "Minor" bugs in this routine
- result in garbaged or lost mail.
-
- If you hack on this and slow it down, I, my children and my
- children's children will curse you.
-
- This routine gets used on three different types of files: normal,
- single msg files, "packed" unix or mmdf mailboxs (when used by inc)
- and packed, directoried bulletin board files (when used by msh).
- The biggest impact of different file types is in "eom" testing. The
- code has been carefully organized to test for eom at appropriate
- times and at no other times (since the check is quite expensive).
- I have tried to arrange things so that the eom check need only be
- done on entry to this routine. Since an eom can only occur after a
- newline, this is easy to manage for header fields. For the msg
- body, we try to efficiently search the input buffer to see if
- contains the eom delimiter. If it does, we take up to the
- delimiter, otherwise we take everything in the buffer. (The change
- to the body eom/copy processing produced the most noticeable
- performance difference, particularly for "inc" and "show".)
-
- There are three qualitatively different things this routine busts
- out of a message: field names, field text and msg bodies. Field
- names are typically short (~8 char) and the loop that extracts them
- might terminate on a colon, newline or max width. I considered
- using a Vax "scanc" to locate the end of the field followed by a
- "bcopy" but the routine call overhead on a Vax is too large for this
- to work on short names. If Berkeley ever makes "inline" part of the
- C optimiser (so things like "scanc" turn into inline instructions) a
- change here would be worthwhile.
-
- Field text is typically 60 - 100 characters so there's (barely)
- a win in doing a routine call to something that does a "locc"
- followed by a "bmove". About 30% of the fields have continuations
- (usually the 822 "received:" lines) and each continuation generates
- another routine call. "Inline" would be a big win here, as well.
-
- Messages, as of this writing, seem to come in two flavors: small
- (~1K) and long (>2K). Most messages have 400 - 600 bytes of headers
- so message bodies average at least a few hundred characters.
- Assuming your system uses reasonably sized stdio buffers (1K or
- more), this routine should be able to remove the body in large
- (>500 byte) chunks. The makes the cost of a call to "bcopy"
- small but there is a premium on checking for the eom in packed
- maildrops. The eom pattern is always a simple string so we can
- construct an efficient pattern matcher for it (e.g., a Vax "matchc"
- instruction). Some thought went into recognizing the start of
- an eom that has been split across two buffers.
-
- This routine wants to deal with large chunks of data so, rather
- than "getc" into a local buffer, it uses stdio's buffer. If
- you try to use it on a non-buffered file, you'll get what you
- deserve. This routine "knows" that struct FILEs have a _ptr
- and a _cnt to describe the current state of the buffer and
- it knows that _filbuf ignores the _ptr & _cnt and simply fills
- the buffer. If stdio on your system doesn't work this way, you
- may have to make small changes in this routine.
-
- This routine also "knows" that an EOF indication on a stream is
- "sticky" (i.e., you will keep getting EOF until you reposition the
- stream). If your system doesn't work this way it is broken and you
- should complain to the vendor. As a consequence of the sticky
- EOF, this routine will never return any kind of EOF status when
- there is data in "name" or "buf").
- */
+/*
+** This module has a long and checkered history. First, it didn't burst
+** maildrops correctly because it considered two CTRL-A:s in a row to be
+** an inter-message delimiter. It really is four CTRL-A:s followed by a
+** newline. Unfortunately, MMDF will convert this delimiter *inside* a
+** message to a CTRL-B followed by three CTRL-A:s and a newline. This
+** caused the old version of m_getfld() to declare eom prematurely. The
+** fix was a lot slower than
+**
+** c == '\001' && peekc (iob) == '\001'
+**
+** but it worked, and to increase generality, MBOX style maildrops could
+** be parsed as well. Unfortunately the speed issue finally caught up with
+** us since this routine is at the very heart of MH.
+**
+** To speed things up considerably, the routine Eom() was made an auxilary
+** function called by the macro eom(). Unless we are bursting a maildrop,
+** the eom() macro returns FALSE saying we aren't at the end of the
+** message.
+**
+** The next thing to do is to read the mts.conf file and initialize
+** delimiter[] and delimlen accordingly...
+**
+** After mhl was made a built-in in msh, m_getfld() worked just fine
+** (using m_unknown() at startup). Until one day: a message which was
+** the result of a bursting was shown. Then, since the burst boundaries
+** aren't CTRL-A:s, m_getfld() would blinding plunge on past the boundary.
+** Very sad. The solution: introduce m_eomsbr(). This hook gets called
+** after the end of each line (since testing for eom involves an fseek()).
+** This worked fine, until one day: a message with no body portion arrived.
+** Then the
+**
+** while (eom (c = Getc (iob), iob))
+** continue;
+**
+** loop caused m_getfld() to return FMTERR. So, that logic was changed to
+** check for (*eom_action) and act accordingly.
+**
+** [ Note by meillo 2011-10:
+** as msh was removed from mmh, m_eomsbr() became irrelevant. ]
+**
+** This worked fine, until one day: someone didn't use four CTRL:A's as
+** their delimiters. So, the bullet got bit and we read mts.h and
+** continue to struggle on. It's not that bad though, since the only time
+** the code gets executed is when inc (or msh) calls it, and both of these
+** have already called mts_init().
+**
+** ------------------------
+** (Written by Van Jacobson for the mh6 m_getfld, January, 1986):
+**
+** This routine was accounting for 60% of the cpu time used by most mh
+** programs. I spent a bit of time tuning and it now accounts for <10%
+** of the time used. Like any heavily tuned routine, it's a bit
+** complex and you want to be sure you understand everything that it's
+** doing before you start hacking on it. Let me try to emphasize
+** that: every line in this atrocity depends on every other line,
+** sometimes in subtle ways. You should understand it all, in detail,
+** before trying to change any part. If you do change it, test the
+** result thoroughly (I use a hand-constructed test file that exercises
+** all the ways a header name, header body, header continuation,
+** header-body separator, body line and body eom can align themselves
+** with respect to a buffer boundary). "Minor" bugs in this routine
+** result in garbaged or lost mail.
+**
+** If you hack on this and slow it down, I, my children and my
+** children's children will curse you.
+**
+** This routine gets used on three different types of files: normal,
+** single msg files, "packed" unix or mmdf mailboxs (when used by inc)
+** and packed, directoried bulletin board files (when used by msh).
+** The biggest impact of different file types is in "eom" testing. The
+** code has been carefully organized to test for eom at appropriate
+** times and at no other times (since the check is quite expensive).
+** I have tried to arrange things so that the eom check need only be
+** done on entry to this routine. Since an eom can only occur after a
+** newline, this is easy to manage for header fields. For the msg
+** body, we try to efficiently search the input buffer to see if
+** contains the eom delimiter. If it does, we take up to the
+** delimiter, otherwise we take everything in the buffer. (The change
+** to the body eom/copy processing produced the most noticeable
+** performance difference, particularly for "inc" and "show".)
+**
+** There are three qualitatively different things this routine busts
+** out of a message: field names, field text and msg bodies. Field
+** names are typically short (~8 char) and the loop that extracts them
+** might terminate on a colon, newline or max width. I considered
+** using a Vax "scanc" to locate the end of the field followed by a
+** "bcopy" but the routine call overhead on a Vax is too large for this
+** to work on short names. If Berkeley ever makes "inline" part of the
+** C optimiser (so things like "scanc" turn into inline instructions) a
+** change here would be worthwhile.
+**
+** Field text is typically 60 - 100 characters so there's (barely)
+** a win in doing a routine call to something that does a "locc"
+** followed by a "bmove". About 30% of the fields have continuations
+** (usually the 822 "received:" lines) and each continuation generates
+** another routine call. "Inline" would be a big win here, as well.
+**
+** Messages, as of this writing, seem to come in two flavors: small
+** (~1K) and long (>2K). Most messages have 400 - 600 bytes of headers
+** so message bodies average at least a few hundred characters.
+** Assuming your system uses reasonably sized stdio buffers (1K or
+** more), this routine should be able to remove the body in large
+** (>500 byte) chunks. The makes the cost of a call to "bcopy"
+** small but there is a premium on checking for the eom in packed
+** maildrops. The eom pattern is always a simple string so we can
+** construct an efficient pattern matcher for it (e.g., a Vax "matchc"
+** instruction). Some thought went into recognizing the start of
+** an eom that has been split across two buffers.
+**
+** This routine wants to deal with large chunks of data so, rather
+** than "getc" into a local buffer, it uses stdio's buffer. If
+** you try to use it on a non-buffered file, you'll get what you
+** deserve. This routine "knows" that struct FILEs have a _ptr
+** and a _cnt to describe the current state of the buffer and
+** it knows that _filbuf ignores the _ptr & _cnt and simply fills
+** the buffer. If stdio on your system doesn't work this way, you
+** may have to make small changes in this routine.
+**
+** This routine also "knows" that an EOF indication on a stream is
+** "sticky" (i.e., you will keep getting EOF until you reposition the
+** stream). If your system doesn't work this way it is broken and you
+** should complain to the vendor. As a consequence of the sticky
+** EOF, this routine will never return any kind of EOF status when
+** there is data in "name" or "buf").
+*/
/*
- * static prototypes
- */
+** static prototypes
+*/
static int m_Eom (int, FILE *);
static unsigned char *matchc(int, char *, int, char *);
static unsigned char *locc(int, unsigned char *, unsigned char);
static unsigned char **pat_map;
/*
- * defined in sbr/m_msgdef.c = 0
- * This is a disgusting hack for "inc" so it can know how many
- * characters were stuffed in the buffer on the last call
- * (see comments in uip/scansbr.c).
- */
+** defined in sbr/m_msgdef.c = 0
+** This is a disgusting hack for "inc" so it can know how many
+** characters were stuffed in the buffer on the last call
+** (see comments in uip/scansbr.c).
+*/
extern int msg_count;
/*
- * defined in sbr/m_msgdef.c = MS_DEFAULT
- */
+** defined in sbr/m_msgdef.c = MS_DEFAULT
+*/
extern int msg_style;
/*
- * The "full" delimiter string for a packed maildrop consists
- * of a newline followed by the actual delimiter. E.g., the
- * full string for a Unix maildrop would be: "\n\nFrom ".
- * "Fdelim" points to the start of the full string and is used
- * in the BODY case of the main routine to search the buffer for
- * a possible eom. Msg_delim points to the first character of
- * the actual delim. string (i.e., fdelim+1). Edelim
- * points to the 2nd character of actual delimiter string. It
- * is used in m_Eom because the first character of the string
- * has been read and matched before m_Eom is called.
- */
+** The "full" delimiter string for a packed maildrop consists
+** of a newline followed by the actual delimiter. E.g., the
+** full string for a Unix maildrop would be: "\n\nFrom ".
+** "Fdelim" points to the start of the full string and is used
+** in the BODY case of the main routine to search the buffer for
+** a possible eom. Msg_delim points to the first character of
+** the actual delim. string (i.e., fdelim+1). Edelim
+** points to the 2nd character of actual delimiter string. It
+** is used in m_Eom because the first character of the string
+** has been read and matched before m_Eom is called.
+*/
extern char *msg_delim; /* defined in sbr/m_msgdef.c = "" */
static unsigned char *fdelim;
static unsigned char *delimend;
goto body;
}
/*
- * get the name of this component. take characters up
- * to a ':', a newline or NAMESZ-1 characters,
- * whichever comes first.
- */
+ ** get the name of this component. take characters up
+ ** to a ':', a newline or NAMESZ-1 characters,
+ ** whichever comes first.
+ */
cp = name;
i = NAMESZ - 1;
for (;;) {
break;
/*
- * something went wrong. possibilities are:
- * . hit a newline (error)
- * . got more than namesz chars. (error)
- * . hit the end of the buffer. (loop)
- */
+ ** something went wrong. possibilities are:
+ ** . hit a newline (error)
+ ** . got more than namesz chars. (error)
+ ** . hit the end of the buffer. (loop)
+ */
if (c == '\n') {
- /* We hit the end of the line without seeing ':' to
- * terminate the field name. This is usually (always?)
- * spam. But, blowing up is lame, especially when
- * scan(1)ing a folder with such messages. Pretend such
- * lines are the first of the body (at least mutt also
- * handles it this way). */
-
- /* See if buf can hold this line, since we were assuming
- * we had a buffer of NAMESZ, not bufsz. */
+ /*
+ ** We hit the end of the line
+ ** without seeing ':' to terminate
+ ** the field name. This is usually
+ ** (always?) spam. But, blowing
+ ** up is lame, especially when
+ ** scan(1)ing a folder with such
+ ** messages. Pretend such lines are
+ ** the first of the body (at least
+ ** mutt also handles it this way).
+ */
+
+ /*
+ ** See if buf can hold this line,
+ ** since we were assuming we had
+ ** a buffer of NAMESZ, not bufsz.
+ */
/* + 1 for the newline */
if (bufsz < j + 1) {
- /* No, it can't. Oh well, guess we'll blow up. */
+ /*
+ ** No, it can't. Oh well,
+ ** guess we'll blow up.
+ */
*cp = *buf = 0;
advise (NULL, "eol encountered in field \"%s\"", name);
state = FMTERR;
memcpy (buf, name, j - 1);
buf[j - 1] = '\n';
buf[j] = '\0';
- /* mhparse.c:get_content wants to find the position of the
- * body start, but it thinks there's a blank line between
- * the header and the body (naturally!), so seek back so
- * that things line up even though we don't have that
- * blank line in this case. Simpler parsers (e.g. mhl)
- * get extra newlines, but that should be harmless enough,
- * right? This is a corrupt message anyway. */
+ /*
+ ** mhparse.c:get_content wants to
+ ** find the position of the body
+ ** start, but it thinks there's a
+ ** blank line between the header
+ ** and the body (naturally!), so
+ ** seek back so that things line
+ ** up even though we don't have
+ ** that blank line in this case.
+ ** Simpler parsers (e.g. mhl)
+ ** get extra newlines, but that
+ ** should be harmless enough, right?
+ ** This is a corrupt message anyway.
+ */
fseek (iob, ftell (iob) - 2, SEEK_SET);
return BODY;
}
case FLDPLUS:
/*
- * get (more of) the text of a field. take
- * characters up to the end of this field (newline
- * followed by non-blank) or bufsz-1 characters.
- */
+ ** get (more of) the text of a field. take
+ ** characters up to the end of this field (newline
+ ** followed by non-blank) or bufsz-1 characters.
+ */
cp = buf; i = bufsz-1;
for (;;) {
#ifdef LINUX_STDIO
c = cnt < i ? cnt : i;
while ((ep = locc( c, bp, '\n' ))) {
/*
- * if we hit the end of this field, return.
- */
+ ** if we hit the end of this field,
+ ** return.
+ */
if ((j = *++ep) != ' ' && j != '\t') {
#ifdef LINUX_STDIO
j = ep - (unsigned char *) iob->_IO_read_ptr;
bp = ep;
}
/*
- * end of input or dest buffer - copy what we've found.
- */
+ ** end of input or dest buffer - copy what
+ ** we've found.
+ */
#ifdef LINUX_STDIO
c += bp - (unsigned char *) iob->_IO_read_ptr;
memcpy( cp, iob->_IO_read_ptr, c);
break;
}
/*
- * There's one character left in the input buffer.
- * Copy it & fill the buffer. If the last char
- * was a newline and the next char is not whitespace,
- * this is the end of the field. Otherwise loop.
- */
+ ** There's one character left in the input
+ ** buffer. Copy it & fill the buffer.
+ ** If the last char was a newline and the
+ ** next char is not whitespace, this is
+ ** the end of the field. Otherwise loop.
+ */
--i;
#ifdef LINUX_STDIO
*cp++ = j = *(iob->_IO_read_ptr + c);
case BODY:
body:
/*
- * get the message body up to bufsz characters or the
- * end of the message. Sleazy hack: if bufsz is negative
- * we assume that we were called to copy directly into
- * the output buffer and we don't add an eos.
- */
+ ** get the message body up to bufsz characters or
+ ** the end of the message. Sleazy hack: if bufsz
+ ** is negative we assume that we were called to
+ ** copy directly into the output buffer and we
+ ** don't add an eos.
+ */
i = (bufsz < 0) ? -bufsz : bufsz-1;
#ifdef LINUX_STDIO
bp = (unsigned char *) --iob->_IO_read_ptr;
c = (cnt < i ? cnt : i);
if (msg_style != MS_DEFAULT && c > 1) {
/*
- * packed maildrop - only take up to the (possible)
- * start of the next message. This "matchc" should
- * probably be a Boyer-Moore matcher for non-vaxen,
- * particularly since we have the alignment table
- * all built for the end-of-buffer test (next).
- * But our vax timings indicate that the "matchc"
- * instruction is 50% faster than a carefully coded
- * B.M. matcher for most strings. (So much for elegant
- * algorithms vs. brute force.) Since I (currently)
- * run MH on a vax, we use the matchc instruction. --vj
- */
+ ** packed maildrop - only take up to the
+ ** (possible) start of the next message.
+ ** This "matchc" should probably be a
+ ** Boyer-Moore matcher for non-vaxen,
+ ** particularly since we have the alignment
+ ** table all built for the end-of-buffer
+ ** test (next). But our vax timings
+ ** indicate that the "matchc" instruction
+ ** is 50% faster than a carefully coded
+ ** B.M. matcher for most strings. (So much
+ ** for elegant algorithms vs. brute force.)
+ ** Since I (currently) run MH on a vax,
+ ** we use the matchc instruction. --vj
+ */
if ((ep = matchc( fdelimlen, fdelim, c, bp )))
c = ep - bp + 1;
else {
/*
- * There's no delim in the buffer but there may be
- * a partial one at the end. If so, we want to leave
- * it so the "eom" check on the next call picks it up.
- * Use a modified Boyer-Moore matcher to make this
- * check relatively cheap. The first "if" figures
- * out what position in the pattern matches the last
- * character in the buffer. The inner "while" matches
- * the pattern against the buffer, backwards starting
- * at that position. Note that unless the buffer
- * ends with one of the characters in the pattern
- * (excluding the first and last), we do only one test.
- */
+ ** There's no delim in the buffer
+ ** but there may be a partial one
+ ** at the end. If so, we want
+ ** to leave it so the "eom" check
+ ** on the next call picks it up.
+ ** Use a modified Boyer-Moore
+ ** matcher to make this check
+ ** relatively cheap. The first
+ ** "if" figures out what position
+ ** in the pattern matches the
+ ** last character in the buffer.
+ ** The inner "while" matches the
+ ** pattern against the buffer,
+ ** backwards starting at that
+ ** position. Note that unless
+ ** the buffer ends with one of
+ ** the characters in the pattern
+ ** (excluding the first and last),
+ ** we do only one test.
+ */
ep = bp + c - 1;
if ((sp = pat_map[*ep])) {
do {
- /* This if() is true unless (a) the buffer is too
- * small to contain this delimiter prefix, or
- * (b) it contains exactly enough chars for the
- * delimiter prefix.
- * For case (a) obviously we aren't going to match.
- * For case (b), if the buffer really contained exactly
- * a delim prefix, then the m_eom call at entry
- * should have found it. Thus it's not a delim
- * and we know we won't get a match.
- */
+ /*
+ ** This if() is
+ ** true unless (a)
+ ** the buffer is too
+ ** small to contain
+ ** this delimiter
+ ** prefix, or (b)
+ ** it contains
+ ** exactly enough
+ ** chars for the
+ ** delimiter prefix.
+ ** For case (a)
+ ** obviously we
+ ** aren't going
+ ** to match.
+ ** For case (b),
+ ** if the buffer
+ ** really contained
+ ** exactly a delim
+ ** prefix, then
+ ** the m_eom call
+ ** at entry should
+ ** have found it.
+ ** Thus it's not
+ ** a delim and we
+ ** know we won't
+ ** get a match.
+ */
if (((sp - fdelim) + 2) <= c) {
cp = sp;
- /* Unfortunately although fdelim has a preceding NUL
- * we can't use this as a sentinel in case the buffer
- * contains a NUL in exactly the wrong place (this
- * would cause us to run off the front of fdelim).
- */
+ /*
+ ** Unfortunately although fdelim has a preceding NUL
+ ** we can't use this as a sentinel in case the buffer
+ ** contains a NUL in exactly the wrong place (this
+ ** would cause us to run off the front of fdelim).
+ */
while (*--ep == *--cp)
if (cp < fdelim)
break;
if (cp < fdelim) {
/* we matched the entire delim prefix,
- * so only take the buffer up to there.
- * we know ep >= bp -- check above prevents underrun
- */
+ ** so only take the buffer up to there.
+ ** we know ep >= bp -- check above prevents underrun
+ */
c = (ep - bp) + 2;
break;
}
register char *delimstr;
/*
- * Figure out what the message delimitter string is for this
- * maildrop. (This used to be part of m_Eom but I didn't like
- * the idea of an "if" statement that could only succeed on the
- * first call to m_Eom getting executed on each call, i.e., at
- * every newline in the message).
- *
- * If the first line of the maildrop is a Unix "From " line, we
- * say the style is MBOX and eat the rest of the line. Otherwise
- * we say the style is MMDF and look for the delimiter string
- * specified when nmh was built (or from the mts.conf file).
- */
+** Figure out what the message delimitter string is for this
+** maildrop. (This used to be part of m_Eom but I didn't like
+** the idea of an "if" statement that could only succeed on the
+** first call to m_Eom getting executed on each call, i.e., at
+** every newline in the message).
+**
+** If the first line of the maildrop is a Unix "From " line, we
+** say the style is MBOX and eat the rest of the line. Otherwise
+** we say the style is MMDF and look for the delimiter string
+** specified when nmh was built (or from the mts.conf file).
+*/
msg_style = MS_UNKNOWN;
if (edelimlen <= 1)
adios (NULL, "maildrop delimiter must be at least 2 bytes");
/*
- * build a Boyer-Moore end-position map for the matcher in m_getfld.
- * N.B. - we don't match just the first char (since it's the newline
- * separator) or the last char (since the matchc would have found it
- * if it was a real delim).
- */
+ ** build a Boyer-Moore end-position map for the matcher in m_getfld.
+ ** N.B. - we don't match just the first char (since it's the newline
+ ** separator) or the last char (since the matchc would have found it
+ ** if it was a real delim).
+ */
pat_map = (unsigned char **) calloc (256, sizeof(unsigned char *));
for (cp = (char *) fdelim + 1; cp < (char *) delimend; cp++ )
/*
- * test for msg delimiter string
- */
+** test for msg delimiter string
+*/
static int
m_Eom (int c, FILE *iob)
if ((i = fread (text, sizeof *text, edelimlen, iob)) != edelimlen
|| strncmp (text, (char *)edelim, edelimlen)) {
if (i == 0 && msg_style == MS_MBOX)
- /* the final newline in the (brain damaged) unix-format
- * maildrop is part of the delimitter - delete it.
- */
+ /*
+ ** the final newline in the (brain damaged) unix-format
+ ** maildrop is part of the delimitter - delete it.
+ */
return 1;
#if 0
#ifdef RPATHS
/*
- * Return the Return-Path and Delivery-Date
- * header information.
- *
- * Currently, I'm assuming that the "From " line
- * takes one of the following forms.
- *
- * From sender date remote from host (for UUCP delivery)
- * From sender@host date (for sendmail delivery)
- */
+** Return the Return-Path and Delivery-Date
+** header information.
+**
+** Currently, I'm assuming that the "From " line
+** takes one of the following forms.
+**
+** From sender date remote from host (for UUCP delivery)
+** From sender@host date (for sendmail delivery)
+*/
int
get_returnpath (char *rp, int rplen, char *dd, int ddlen)
return 0;
/*
- * Check for "remote from" in envelope to see
- * if this message uses UUCP style addressing
- */
+ ** Check for "remote from" in envelope to see
+ ** if this message uses UUCP style addressing
+ */
while ((cp = strchr(++cp, 'r'))) {
if (strncmp (cp, "remote from", 11) == 0) {
cp = strrchr (cp, ' ');
}
/*
- * Get the Return-Path information from
- * the "From " envelope.
- */
+ ** Get the Return-Path information from
+ ** the "From " envelope.
+ */
if (cp) {
/* return path for UUCP style addressing */
dp = strchr (++cp, '\n');
}
/*
- * advance over the spaces to get to
- * delivery date on envelope
- */
+ ** advance over the spaces to get to
+ ** delivery date on envelope
+ */
while (*bp == ' ')
bp++;
/*
- * Locate character "term" in the next "cnt" characters of "src".
- * If found, return its address, otherwise return 0.
- */
+** Locate character "term" in the next "cnt" characters of "src".
+** If found, return its address, otherwise return 0.
+*/
static unsigned char *
locc(int cnt, unsigned char *src, unsigned char term)
/*
- * m_gmprot.c -- return the msg-protect value
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** m_gmprot.c -- return the msg-protect value
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * m_maildir.c -- get the path for the mail directory
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** m_maildir.c -- get the path for the mail directory
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
static char mailfold[BUFSIZ];
/*
- * static prototypes
- */
+** static prototypes
+*/
static char *exmaildir (char *);
/*
- * m_mktemp.c -- Construct a temporary file.
- *
- * This code is Copyright (c) 2010, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** m_mktemp.c -- Construct a temporary file.
+**
+** This code is Copyright (c) 2010, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <errno.h>
#include <h/mh.h>
static char *get_temp_dir();
/* Create a temporary file. If pfx_in is null, the temporary file
- * will be created in the temporary directory (more on that later).
- * If pfx_in is not null, then the temporary file location will be
- * defined by the value pfx_in.
- *
- * The file created will be at the pathname specified appended with
- * 6 random (we hope :) characters.
- *
- * The return value will be the pathname to the file created.
- *
- * CAUTION: The return pointer references static data. If
- * you need to modify, or save, the return string, make a copy of it
- * first.
- *
- * When pfx_in is null, the temporary directory is determined as
- * follows, in order:
- *
- * MHTMPDIR envvar
- * TMPDIR envvar
- * TMP envvar
- * User's mail directory.
- *
- * NOTE: One will probably use m_mktemp2() instead of this function.
- * For example, if you want to create a temp file in the defined
- * temporary directory, but with a custom basename prefix, do
- * something like the following:
- *
- * char *tmp_pathname = m_mktemp2(NULL, "mypre", ...);
- */
+** will be created in the temporary directory (more on that later).
+** If pfx_in is not null, then the temporary file location will be
+** defined by the value pfx_in.
+**
+** The file created will be at the pathname specified appended with
+** 6 random (we hope :) characters.
+**
+** The return value will be the pathname to the file created.
+**
+** CAUTION: The return pointer references static data. If
+** you need to modify, or save, the return string, make a copy of it
+** first.
+**
+** When pfx_in is null, the temporary directory is determined as
+** follows, in order:
+**
+** MHTMPDIR envvar
+** TMPDIR envvar
+** TMP envvar
+** User's mail directory.
+**
+** NOTE: One will probably use m_mktemp2() instead of this function.
+** For example, if you want to create a temp file in the defined
+** temporary directory, but with a custom basename prefix, do
+** something like the following:
+**
+** char *tmp_pathname = m_mktemp2(NULL, "mypre", ...);
+*/
char *
m_mktemp (
const char *pfx_in, /* Pathname prefix for temporary file. */
- int *fd_ret, /* (return,optional) File descriptor to temp file. */
- FILE **fp_ret /* (return,optional) FILE pointer to temp file. */
+ int *fd_ret, /* (return,opt.) File descriptor to temp file. */
+ FILE **fp_ret /* (return,opt.) FILE pointer to temp file. */
)
{
static char tmpfil[BUFSIZ];
mode_t oldmode = umask(077);
if (pfx_in == NULL) {
- snprintf(tmpfil, sizeof(tmpfil), "%s/nmhXXXXXX", get_temp_dir());
+ snprintf(tmpfil, sizeof(tmpfil), "%s/nmhXXXXXX",
+ get_temp_dir());
} else {
snprintf(tmpfil, sizeof(tmpfil), "%sXXXXXX", pfx_in);
}
return tmpfil;
}
-/* This version allows one to specify the directory the temp file should
- * by created based on a given pathname. Although m_mktemp() technically
- * supports this, this version is when the directory is defined by
- * a separate variable from the prefix, eliminating the caller from having
- * to do string manipulation to generate the desired. pathname prefix.
- *
- * The pfx_in parameter specifies a basename prefix for the file. If dir_in
- * is NULL, then the defined temporary directory (see comments to m_mktemp()
- * above) is used to create the temp file.
- */
+/*
+** This version allows one to specify the directory the temp file should
+** by created based on a given pathname. Although m_mktemp() technically
+** supports this, this version is when the directory is defined by
+** a separate variable from the prefix, eliminating the caller from having
+** to do string manipulation to generate the desired. pathname prefix.
+**
+** The pfx_in parameter specifies a basename prefix for the file. If dir_in
+** is NULL, then the defined temporary directory (see comments to m_mktemp()
+** above) is used to create the temp file.
+*/
char *
m_mktemp2 (
const char *dir_in, /* Directory to place temp file. */
const char *pfx_in, /* Basename prefix for temp file. */
- int *fd_ret, /* (return,optional) File descriptor to temp file. */
- FILE **fp_ret /* (return,optional) FILE pointer to temp file. */
+ int *fd_ret, /* (return,opt.) File descriptor to temp file. */
+ FILE **fp_ret /* (return,opt.) FILE pointer to temp file. */
)
{
static char buffer[BUFSIZ];
static char *
get_temp_dir()
{
- // Ignore envvars if we are setuid
+ /* Ignore envvars if we are setuid */
if ((getuid()==geteuid()) && (getgid()==getegid())) {
char *tmpdir = NULL;
tmpdir = getenv("MHTMPDIR");
/*
- * m_msgdef.c -- some defines for sbr/m_getfld.c
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** m_msgdef.c -- some defines for sbr/m_getfld.c
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * disgusting hack for "inc" so it can know how many characters
- * were stuffed in the buffer on the last call (see comments
- * in uip/scansbr.c)
- */
+** disgusting hack for "inc" so it can know how many characters
+** were stuffed in the buffer on the last call (see comments
+** in uip/scansbr.c)
+*/
int msg_count = 0;
int msg_style = MS_DEFAULT;
/*
- * The "full" delimiter string for a packed maildrop consists
- * of a newline followed by the actual delimiter. E.g., the
- * full string for a Unix maildrop would be: "\n\nFrom ".
- * "Fdelim" points to the start of the full string and is used
- * in the BODY case of the main routine to search the buffer for
- * a possible eom. Msg_delim points to the first character of
- * the actual delim. string (i.e., fdelim+1). Edelim
- * points to the 2nd character of actual delimiter string. It
- * is used in m_Eom because the first character of the string
- * has been read and matched before m_Eom is called.
- */
+** The "full" delimiter string for a packed maildrop consists
+** of a newline followed by the actual delimiter. E.g., the
+** full string for a Unix maildrop would be: "\n\nFrom ".
+** "Fdelim" points to the start of the full string and is used
+** in the BODY case of the main routine to search the buffer for
+** a possible eom. Msg_delim points to the first character of
+** the actual delim. string (i.e., fdelim+1). Edelim
+** points to the 2nd character of actual delimiter string. It
+** is used in m_Eom because the first character of the string
+** has been read and matched before m_Eom is called.
+*/
char *msg_delim = "";
/*
- * m_name.c -- return a message number as a string
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** m_name.c -- return a message number as a string
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * makedir.c -- make a directory
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** makedir.c -- make a directory
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
/*
- * Modified to try recursive create.
- */
+** Modified to try recursive create.
+*/
#include <h/mh.h>
#include <errno.h>
if (!(folder_perms_ASCII = context_find ("folder-protect")))
folder_perms_ASCII = foldprot; /* defaults to "700" */
- /* Because mh-profile.man documents "Folder-Protect:" as an octal constant,
- and we don't want to force the user to remember to include a leading
- zero, we call atooi(folder_perms_ASCII) here rather than
- strtoul(folder_perms_ASCII, NULL, 0). Therefore, if anyone ever tries to
- specify a mode in say, hex, they'll get garbage. (I guess nmh uses its
- atooi() function rather than calling strtoul() with a radix of 8 because
- some ancient platforms are missing that functionality. */
+ /*
+ ** Because mh-profile.man documents "Folder-Protect:" as an octal
+ ** constant, and we don't want to force the user to remember to
+ ** include a leading zero, we call atooi(folder_perms_ASCII) here
+ ** rather than strtoul(folder_perms_ASCII, NULL, 0). Therefore,
+ ** if anyone ever tries to specify a mode in say, hex, they'll
+ ** get garbage. (I guess nmh uses its atooi() function rather
+ ** than calling strtoul() with a radix of 8 because some ancient
+ ** platforms are missing that functionality.
+ */
folder_perms = atooi(folder_perms_ASCII);
- /* Folders have definite desired permissions that are set -- we don't want
- to interact with the umask. Clear it temporarily. */
+ /*
+ ** Folders have definite desired permissions that are set -- we
+ ** don't want to interact with the umask. Clear it temporarily.
+ */
saved_umask = umask(0);
if (getuid () == geteuid ()) {
}
if (!had_an_error) {
- /* Create the innermost nested subdirectory of the
- * path we're being asked to create. */
+ /*
+ ** Create the innermost nested subdirectory of the
+ ** path we're being asked to create.
+ */
if (mkdir (dir, folder_perms) == -1) {
advise (dir, "unable to create directory");
had_an_error = 1;
/*
- * mf.c -- mail filter subroutines
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mf.c -- mail filter subroutines
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mf.h>
#include <ctype.h>
#include <h/utils.h>
/*
- * static prototypes
- */
+** static prototypes
+*/
static char *getcpy (char *);
static int isat (char *);
static int parse_address (void);
if (!s) {
/*
- * causes compiles to blow up because the symbol _cleanup
- * is undefined where did this ever come from?
- */
+ ** causes compiles to blow up because the symbol _cleanup
+ ** is undefined where did this ever come from?
+ */
/* _cleanup(); */
abort();
for(;;)
/*
- *
- * getadrx() implements a partial 822-style address parser. The parser
- * is neither complete nor correct. It does however recognize nearly all
- * of the 822 address syntax. In addition it handles the majority of the
- * 733 syntax as well. Most problems arise from trying to accomodate both.
- *
- * In terms of 822, the route-specification in
- *
- * "<" [route] local-part "@" domain ">"
- *
- * is parsed and returned unchanged. Multiple at-signs are compressed
- * via source-routing. Recursive groups are not allowed as per the
- * standard.
- *
- * In terms of 733, " at " is recognized as equivalent to "@".
- *
- * In terms of both the parser will not complain about missing hosts.
- *
- * -----
- *
- * We should not allow addresses like
- *
- * Marshall T. Rose <MRose@UCI>
- *
- * but should insist on
- *
- * "Marshall T. Rose" <MRose@UCI>
- *
- * Unfortunately, a lot of mailers stupidly let people get away with this.
- *
- * -----
- *
- * We should not allow addresses like
- *
- * <MRose@UCI>
- *
- * but should insist on
- *
- * MRose@UCI
- *
- * Unfortunately, a lot of mailers stupidly let people's UAs get away with
- * this.
- *
- * -----
- *
- * We should not allow addresses like
- *
- * @UCI:MRose@UCI-750a
- *
- * but should insist on
- *
- * Marshall Rose <@UCI:MRose@UCI-750a>
- *
- * Unfortunately, a lot of mailers stupidly do this.
- *
- */
+**
+** getadrx() implements a partial 822-style address parser. The parser
+** is neither complete nor correct. It does however recognize nearly all
+** of the 822 address syntax. In addition it handles the majority of the
+** 733 syntax as well. Most problems arise from trying to accomodate both.
+**
+** In terms of 822, the route-specification in
+**
+** "<" [route] local-part "@" domain ">"
+**
+** is parsed and returned unchanged. Multiple at-signs are compressed
+** via source-routing. Recursive groups are not allowed as per the
+** standard.
+**
+** In terms of 733, " at " is recognized as equivalent to "@".
+**
+** In terms of both the parser will not complain about missing hosts.
+**
+** -----
+**
+** We should not allow addresses like
+**
+** Marshall T. Rose <MRose@UCI>
+**
+** but should insist on
+**
+** "Marshall T. Rose" <MRose@UCI>
+**
+** Unfortunately, a lot of mailers stupidly let people get away with this.
+**
+** -----
+**
+** We should not allow addresses like
+**
+** <MRose@UCI>
+**
+** but should insist on
+**
+** MRose@UCI
+**
+** Unfortunately, a lot of mailers stupidly let people's UAs get away with
+** this.
+**
+** -----
+**
+** We should not allow addresses like
+**
+** @UCI:MRose@UCI-750a
+**
+** but should insist on
+**
+** Marshall Rose <@UCI:MRose@UCI-750a>
+**
+** Unfortunately, a lot of mailers stupidly do this.
+**
+*/
#define QUOTE '\\'
break;
default:
- sprintf (err, "no mailbox in local-part (%s)", buffer);
+ sprintf (err, "no mailbox in local-part (%s)",
+ buffer);
return NOTOK;
}
register char *bp;
/*
- * Add C to the buffer bp. After use of this macro *bp is guaranteed
- * to be within the buffer.
- */
+ ** Add C to the buffer bp. After use of this macro *bp is guaranteed
+ ** to be within the buffer.
+ */
#define ADDCHR(C) \
do { \
*bp++ = (C); \
/*
- * mts.c -- definitions for the mail transport system
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mts.c -- definitions for the mail transport system
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h> /* for snprintf() */
#include <h/nmh.h>
#define OK 0
/*
- * static prototypes
- */
+** static prototypes
+*/
static char *tailor_value (unsigned char *);
static void getuserinfo (void);
static const char *get_mtsconf_pathname(void);
static void mts_read_conf_file (FILE *fp);
/*
- * *mmdfldir and *uucpldir are the maildrop directories. If maildrops
- * are kept in the user's home directory, then these should be empty
- * strings. In this case, the appropriate ...lfil array should contain
- * the name of the file in the user's home directory. Usually, this is
- * something like ".mail".
- */
+** *mmdfldir and *uucpldir are the maildrop directories. If maildrops
+** are kept in the user's home directory, then these should be empty
+** strings. In this case, the appropriate ...lfil array should contain
+** the name of the file in the user's home directory. Usually, this is
+** something like ".mail".
+*/
/*
- * nmh mail transport interface customization file
- */
+** nmh mail transport interface customization file
+*/
static char *mtsconf = nmhetcdir(/mts.conf);
char *mmdfldir = MAILSPOOL;
static char* masquerade = "";
/*
- * Global MailDelivery file
- */
+** Global MailDelivery file
+*/
char *maildelivery = nmhetcdir(/maildelivery);
/*
- * Aliasing Facility (doesn't belong here)
- */
+** Aliasing Facility (doesn't belong here)
+*/
int Everyone = NOTOK;
static char *everyone = "-1";
char *NoShell = "";
/*
- * Customize the MTS settings for nmh by adjusting
- * the file mts.conf in the nmh etc directory.
- */
+** Customize the MTS settings for nmh by adjusting
+** the file mts.conf in the nmh etc directory.
+*/
struct bind {
char *keyword;
/*
- * Read the configuration file for the nmh interface
- * to the mail transport system (MTS).
- */
+** Read the configuration file for the nmh interface
+** to the mail transport system (MTS).
+*/
void
mts_init (char *name)
#define QUOTE '\\'
/*
- * Convert escaped values, malloc some new space,
- * and copy string to malloc'ed memory.
- */
+** Convert escaped values, malloc some new space,
+** and copy string to malloc'ed memory.
+*/
static char *
tailor_value (unsigned char *s)
}
/*
- * Get the fully qualified name of the local host.
- */
+** Get the fully qualified name of the local host.
+*/
char *
LocalName (void)
/*
- * This is only for UUCP mail. It gets the hostname
- * as part of the UUCP "domain".
- */
+** This is only for UUCP mail. It gets the hostname
+** as part of the UUCP "domain".
+*/
char *
SystemName (void)
/*
- * Get the username of current user
- */
+** Get the username of current user
+*/
char *
getusername (void)
/*
- * Get full name of current user (typically from GECOS
- * field of password file).
- */
+** Get full name of current user (typically from GECOS
+** field of password file).
+*/
char *
getfullname (void)
/*
- * Find the user's username and full name, and cache them.
- * Also, handle "mmailid" username masquerading controlled from the GECOS field
- * of the passwd file.
- */
+** Find the user's username and full name, and cache them.
+** Also, handle "mmailid" username masquerading controlled from the GECOS field
+** of the passwd file.
+*/
static void
getuserinfo (void)
np = pw->pw_gecos;
- /* Get the user's real name from the GECOS field. Stop once we hit a ',',
- * which some OSes use to separate other 'finger' information in the GECOS
- * field, like phone number. Also, if mmailid masquerading is turned on due
- * to "mmailid" appearing on the "masquerade:" line of mts.conf, stop if we
- * hit a '<' (which should precede any ','s). */
+ /*
+ ** Get the user's real name from the GECOS field. Stop once
+ ** we hit a ',', which some OSes use to separate other 'finger'
+ ** information in the GECOS field, like phone number. Also, if
+ ** mmailid masquerading is turned on due to "mmailid" appearing
+ ** on the "masquerade:" line of mts.conf, stop if we hit a '<'
+ ** (which should precede any ','s).
+ */
#ifndef BSD42
if (mmailid_masquerading)
/* Stop at ',' or '<'. */
*cp++ = *np++)
continue;
else
- /* Allow '<' as a legal character of the user's name. This code is
- * basically a duplicate of the code above the "else" -- we don't
- * collapse it down to one copy and put the mmailid_masquerading check
- * inside the loop with "(x ? y : z)" because that's inefficient and the
- * value'll never change while it's in there. */
+ /*
+ ** Allow '<' as a legal character of the user's name.
+ ** This code is basically a duplicate of the code above the
+ ** "else" -- we don't collapse it down to one copy and put
+ ** the mmailid_masquerading check inside the loop with "(x
+ ** ? y : z)" because that's inefficient and the value'll
+ ** never change while it's in there.
+ */
for (cp = fullname; *np != '\0' && *np != ','; *cp++ = *np++)
continue;
#else /* BSD42 */
- /* On BSD(-derived) systems, the system utilities that deal with the GECOS
- * field (finger, mail, sendmail, etc.) translate any '&' character in it to
- * the login name, with the first letter capitalized. So, for instance,
- * fingering a user "bob" with the GECOS field "& Jones" would reveal him to
- * be "In real life: Bob Jones". Surprisingly, though, the OS doesn't do
- * the translation for you, so we have to do it manually here. */
+ /*
+ ** On BSD(-derived) systems, the system utilities that deal with
+ ** the GECOS field (finger, mail, sendmail, etc.) translate
+ ** any '&' character in it to the login name, with the first
+ ** letter capitalized. So, for instance, fingering a user "bob"
+ ** with the GECOS field "& Jones" would reveal him to be "In real
+ ** life: Bob Jones". Surprisingly, though, the OS doesn't do the
+ ** translation for you, so we have to do it manually here.
+ */
if (mmailid_masquerading)
/* Stop at ',' or '<'. */
for (cp = fullname;
}
}
else
- /* Allow '<' as a legal character of the user's name. This code is
- * basically a duplicate of the code above the "else" -- we don't
- * collapse it down to one copy and put the mmailid_masquerading check
- * inside the loop with "(x ? y : z)" because that's inefficient and the
- * value'll never change while it's in there. */
+ /*
+ ** Allow '<' as a legal character of the user's name.
+ ** This code is basically a duplicate of the code above the
+ ** "else" -- we don't collapse it down to one copy and put
+ ** the mmailid_masquerading check inside the loop with "(x
+ ** ? y : z)" because that's inefficient and the value'll
+ ** never change while it's in there.
+ */
for (cp = fullname; *np != '\0' && *np != ',';) {
if (*np == '&') { /* blech! */
strcpy (cp, pw->pw_name);
*cp = '\0';
if (mmailid_masquerading) {
- /* Do mmailid processing. The GECOS field should have the form
- * "Full Name <fakeusername>". For instance,
- * "Dan Harkless <Dan.Harkless>". Naturally, you'll want your MTA to
- * have an alias (e.g. in /etc/aliases) from "fakeusername" to your
- * account name. */
+ /*
+ ** Do mmailid processing. The GECOS field should have
+ ** the form "Full Name <fakeusername>". For instance,
+ ** "Dan Harkless <Dan.Harkless>". Naturally, you'll want
+ ** your MTA to have an alias (e.g. in /etc/aliases) from
+ ** "fakeusername" to your account name.
+ */
if (*np)
np++;
for (cp = username; *np && *np != '>'; *cp++ = *np++)
if (!mmailid_masquerading || *np == '\0')
strncpy (username, pw->pw_name, sizeof(username));
- /* The $SIGNATURE environment variable overrides the GECOS field's
- * idea of your real name. */
+ /*
+ ** The $SIGNATURE environment variable overrides the GECOS field's
+ ** idea of your real name.
+ */
if ((cp = getenv ("SIGNATURE")) && *cp)
strncpy (fullname, cp, sizeof(fullname));
/*
- * The Single Unix Specification function nl_langinfo(CODESET)
- * returns the name of the encoding used by the currently selected
- * locale:
- *
- * http://www.opengroup.org/onlinepubs/7908799/xsh/langinfo.h.html
- *
- * Unfortunately the encoding names are not yet standardized.
- * This function knows about the encoding names used on many
- * different systems and converts them where possible into
- * the corresponding MIME charset name registered in
- *
- * http://www.iana.org/assignments/character-sets
- *
- * Please extend it as needed and suggest improvements to the author.
- *
- * Markus.Kuhn@cl.cam.ac.uk -- 2002-03-11
- * Permission to use, copy, modify, and distribute this software
- * for any purpose and without fee is hereby granted. The author
- * disclaims all warranties with regard to this software.
- *
- * Latest version:
- *
- * http://www.cl.cam.ac.uk/~mgk25/ucs/norm_charmap.c
- */
+** The Single Unix Specification function nl_langinfo(CODESET)
+** returns the name of the encoding used by the currently selected
+** locale:
+**
+** http://www.opengroup.org/onlinepubs/7908799/xsh/langinfo.h.html
+**
+** Unfortunately the encoding names are not yet standardized.
+** This function knows about the encoding names used on many
+** different systems and converts them where possible into
+** the corresponding MIME charset name registered in
+**
+** http://www.iana.org/assignments/character-sets
+**
+** Please extend it as needed and suggest improvements to the author.
+**
+** Markus.Kuhn@cl.cam.ac.uk -- 2002-03-11
+** Permission to use, copy, modify, and distribute this software
+** for any purpose and without fee is hereby granted. The author
+** disclaims all warranties with regard to this software.
+**
+** Latest version:
+**
+** http://www.cl.cam.ac.uk/~mgk25/ucs/norm_charmap.c
+*/
#include <string.h>
if (!name)
return name;
- /* Many need no remapping, but they are listed here so you
- * can see what output to expect, and modify for your needs
- * as necessary. */
+ /*
+ ** Many need no remapping, but they are listed here so you
+ ** can see what output to expect, and modify for your needs
+ ** as necessary.
+ */
if (!strcmp(name, "UTF-8"))
return "UTF-8";
if (!strcmp(name, "EUC-JP"))
if (!strcmp(name, "Big5HKSCS") || !strcmp(name, "BIG5HKSCS"))
return "Big5HKSCS";
- /* I don't know of any implementation of nl_langinfo(CODESET) out
- * there that returns anything else (and I'm not even certain all of
- * the above occur in the wild), but just in case, as a fallback,
- * return the unmodified name. */
+ /*
+ ** I don't know of any implementation of nl_langinfo(CODESET) out
+ ** there that returns anything else (and I'm not even certain all of
+ ** the above occur in the wild), but just in case, as a fallback,
+ ** return the unmodified name.
+ */
return name;
}
/*
- * path.c -- return a pathname
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** path.c -- return a pathname
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
static char *pwds;
/*
- * static prototypes
- */
+** static prototypes
+*/
static char *expath(char *,int);
static void compath(char *);
/*
- * peekc.c -- peek at the next character in a stream
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** peekc.c -- peek at the next character in a stream
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * pidstatus.c -- report child's status
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** pidstatus.c -- report child's status
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * auto-generated header
- */
+** auto-generated header
+*/
#include <sigmsg.h>
#ifdef HAVE_SYS_WAIT_H
int signum;
/*
- * I have no idea what this is for (rc)
- * so I'm commenting it out for right now.
- *
- * if ((status & 0xff00) == 0xff00)
- * return status;
- */
+ ** I have no idea what this is for (rc)
+ ** so I'm commenting it out for right now.
+ **
+ ** if ((status & 0xff00) == 0xff00)
+ ** return status;
+ */
/* If child process returned normally */
if (WIFEXITED(status)) {
/*
- * pidwait.c -- wait for child to exit
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** pidwait.c -- wait for child to exit
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/signals.h>
/*
- * print_help.c -- print a help message, and possibly the
- * -- profile/context entries for this command
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** print_help.c -- print a help message, and possibly the
+** -- profile/context entries for this command
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
print_sw (ALL, swp, "-", stdout);
/*
- * check if we should print any profile entries
- */
+ ** check if we should print any profile entries
+ */
if (print_context && (s = context_find (invo_name)))
printf ("\nProfile: %s\n", s);
}
/*
- * print_sw.c -- print switches
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** print_sw.c -- print switches
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * print_version.c -- print a version string
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** print_version.c -- print a version string
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * push.c -- push a fork into the background
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** push.c -- push a fork into the background
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/signals.h>
/*
- * putenv.c -- (un)set an envariable
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** putenv.c -- (un)set an envariable
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
extern char **environ;
/*
- * prototypes
- */
+** prototypes
+*/
int m_putenv (char *, char *);
int unputenv (char *);
static int nvmatch (char *, char *);
/*
- * r1bindex.c -- Given a string and a character, return a pointer
- * -- to the right of the rightmost occurrence of the
- * -- character. If the character doesn't occur, the
- * -- pointer will be at the beginning of the string.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** r1bindex.c -- Given a string and a character, return a pointer
+** -- to the right of the rightmost occurrence of the
+** -- character. If the character doesn't occur, the
+** -- pointer will be at the beginning of the string.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * readconfig.c -- base routine to read nmh configuration files
- * -- such as nmh profile, context file, or mhn.defaults.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** readconfig.c -- base routine to read nmh configuration files
+** -- such as nmh profile, context file, or mhn.defaults.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
np->n_context = ctx;
/*
- * Now scan the list of `procs' and link in the
- * field value to the global variable.
- */
+ ** Now scan the list of `procs' and link in the
+ ** field value to the global variable.
+ */
for (ps = procs; ps->procname; ps++)
if (strcmp (np->n_name, ps->procname) == 0) {
*ps->procnaddr = np->n_field;
/*
- * refile.c -- call the "fileproc" to refile the
- * -- msg or draft into another folder
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** refile.c -- call the "fileproc" to refile the
+** -- msg or draft into another folder
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * Portions of this code are
- * Copyright (c) 1985 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
+** Portions of this code are
+** Copyright (c) 1985 Regents of the University of California.
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms are permitted
+** provided that the above copyright notice and this paragraph are
+** duplicated in all such forms and that any documentation,
+** advertising materials, and other materials related to such
+** distribution and use acknowledge that the software was developed
+** by the University of California, Berkeley. The name of the
+** University may not be used to endorse or promote products derived
+** from this software without specific prior written permission.
+** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+*/
#include <h/mh.h>
#include <h/utils.h>
};
/*
- * prototypes
- */
+** prototypes
+*/
static int token(void);
case PASSWD:
if (fstat(fileno(cfile), &stb) >= 0 &&
(stb.st_mode & 077) != 0) {
- /* We make this a fatal error to force the user to correct it */
+ /*
+ ** We make this a fatal
+ ** error to force the user
+ ** to correct it
+ */
advise(NULL, "Error - ~/.netrc file must not be world or group readable.");
adios(NULL, "Remove password or correct file permissions.");
}
/*
- * seq_add.c -- add message(s) to a sequence
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_add.c -- add message(s) to a sequence
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * Add all the SELECTED messages to a (possibly new) sequence.
- *
- * If public == 1, make sequence public.
- * If public == 0, make sequence private.
- * If public == -1, leave the public/private bit alone for existing
- * sequences. For new sequences, set this bit based
- * on its readonly status.
- *
- * If error, return 0, else return 1.
- */
+** Add all the SELECTED messages to a (possibly new) sequence.
+**
+** If public == 1, make sequence public.
+** If public == 0, make sequence private.
+** If public == -1, leave the public/private bit alone for existing
+** sequences. For new sequences, set this bit based
+** on its readonly status.
+**
+** If error, return 0, else return 1.
+*/
int
seq_addsel (struct msgs *mp, char *cp, int public, int zero)
return 0;
/*
- * We keep mp->curmsg and "cur" sequence in sync.
- * See seq_list() and seq_init().
- */
+ ** We keep mp->curmsg and "cur" sequence in sync.
+ ** See seq_list() and seq_init().
+ */
if (!strcmp (current,cp))
mp->curmsg = mp->hghsel;
/*
- * Get the number for this sequence
- */
+ ** Get the number for this sequence
+ */
for (i = 0; mp->msgattrs[i]; i++) {
if (!strcmp (mp->msgattrs[i], cp)) {
new_seq = 0;
}
/*
- * If this is a new sequence, add a slot for it
- */
+ ** If this is a new sequence, add a slot for it
+ */
if (new_seq) {
if (i >= NUMATTRS) {
advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
}
/*
- * If sequence is new, or zero flag is set, then first
- * clear the bit for this sequence from all messages.
- */
+ ** If sequence is new, or zero flag is set, then first
+ ** clear the bit for this sequence from all messages.
+ */
if (new_seq || zero) {
for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++)
clear_sequence (mp, i, msgnum);
}
/*
- * Now flip on the bit for this sequence
- * for all selected messages.
- */
+ ** Now flip on the bit for this sequence
+ ** for all selected messages.
+ */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
if (is_selected (mp, msgnum))
add_sequence (mp, i, msgnum);
/*
- * Set the public/private bit for this sequence.
- */
+ ** Set the public/private bit for this sequence.
+ */
if (public == 1)
make_seq_public (mp, i);
else if (public == 0)
make_seq_private (mp, i);
else if (new_seq) {
/*
- * If public == -1, then only set the
- * public/private bit for new sequences.
- */
+ ** If public == -1, then only set the
+ ** public/private bit for new sequences.
+ */
if (is_readonly (mp))
make_seq_private (mp, i);
else
/*
- * Add a message to a (possibly new) sequence.
- *
- * If public == 1, make sequence public.
- * If public == 0, make sequence private.
- * If public == -1, leave the public/private bit alone for existing
- * sequences. For new sequences, set this bit based
- * on its readonly status.
- *
- * If error, return 0, else return 1.
- */
+** Add a message to a (possibly new) sequence.
+**
+** If public == 1, make sequence public.
+** If public == 0, make sequence private.
+** If public == -1, leave the public/private bit alone for existing
+** sequences. For new sequences, set this bit based
+** on its readonly status.
+**
+** If error, return 0, else return 1.
+*/
int
seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero)
return 0;
/*
- * keep mp->curmsg and msgattrs["cur"] in sync - see seq_list()
- */
+ ** keep mp->curmsg and msgattrs["cur"] in sync - see seq_list()
+ */
if (!strcmp (current,cp))
mp->curmsg = msgnum;
/*
- * Get the number for this sequence
- */
+ ** Get the number for this sequence
+ */
for (i = 0; mp->msgattrs[i]; i++) {
if (!strcmp (mp->msgattrs[i], cp)) {
new_seq = 0;
}
/*
- * If this is a new sequence, add a slot for it
- */
+ ** If this is a new sequence, add a slot for it
+ */
if (new_seq) {
if (i >= NUMATTRS) {
advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
}
/*
- * If sequence is new, or zero flag is set, then first
- * clear the bit for this sequence from all messages.
- */
+ ** If sequence is new, or zero flag is set, then first
+ ** clear the bit for this sequence from all messages.
+ */
if (new_seq || zero) {
for (j = mp->lowmsg; j <= mp->hghmsg; j++)
clear_sequence (mp, i, j);
}
/*
- * Now flip on the bit for this sequence
- * for this particular message.
- */
+ ** Now flip on the bit for this sequence
+ ** for this particular message.
+ */
add_sequence (mp, i, msgnum);
/*
- * Set the public/private bit for this sequence.
- */
+ ** Set the public/private bit for this sequence.
+ */
if (public == 1)
make_seq_public (mp, i);
else if (public == 0)
make_seq_private (mp, i);
else if (new_seq) {
/*
- * If public == -1, then only set the
- * public/private bit for new sequences.
- */
+ ** If public == -1, then only set the
+ ** public/private bit for new sequences.
+ */
if (is_readonly (mp))
make_seq_private (mp, i);
else
/*
- * seq_bits.c -- return the snprintb() string for a sequence
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_bits.c -- return the snprintb() string for a sequence
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * seq_del.c -- delete message(s) from a sequence
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_del.c -- delete message(s) from a sequence
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * Delete all SELECTED messages from sequence
- *
- * If public == 1, make sequence public.
- * If public == 0, make sequence private.
- * If public == -1, leave the public/private bit alone for existing
- * sequences. For new sequences, set this bit based
- * on its readonly status.
- *
- * If error, return 0, else return 1.
- */
+** Delete all SELECTED messages from sequence
+**
+** If public == 1, make sequence public.
+** If public == 0, make sequence private.
+** If public == -1, leave the public/private bit alone for existing
+** sequences. For new sequences, set this bit based
+** on its readonly status.
+**
+** If error, return 0, else return 1.
+*/
int
seq_delsel (struct msgs *mp, char *cp, int public, int zero)
return 0;
/*
- * Get the number for this sequence
- */
+ ** Get the number for this sequence
+ */
for (i = 0; mp->msgattrs[i]; i++) {
if (!strcmp (mp->msgattrs[i], cp)) {
new_seq = 0;
}
/*
- * If the zero flag is set, first add all existing
- * messages in this folder to the sequence.
- */
+ ** If the zero flag is set, first add all existing
+ ** messages in this folder to the sequence.
+ */
if (zero) {
/*
- * create the sequence, if necessary
- */
+ ** create the sequence, if necessary
+ */
if (new_seq) {
if (i >= NUMATTRS) {
advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
mp->msgattrs[i + 1] = NULL;
}
/*
- * now add sequence bit to all existing messages
- */
+ ** now add sequence bit to all existing messages
+ */
for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) {
if (does_exist (mp, msgnum))
add_sequence (mp, i, msgnum);
}
/*
- * Now clear the bit on all selected messages
- */
+ ** Now clear the bit on all selected messages
+ */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
if (is_selected (mp, msgnum))
clear_sequence (mp, i, msgnum);
/*
- * Set the public/private bit for this sequence.
- */
+ ** Set the public/private bit for this sequence.
+ */
if (public == 1)
make_seq_public (mp, i);
else if (public == 0)
make_seq_private (mp, i);
else if (new_seq) {
/*
- * If public == -1, then only set the
- * public/private bit for new sequences.
- */
+ ** If public == -1, then only set the
+ ** public/private bit for new sequences.
+ */
if (is_readonly (mp))
make_seq_private (mp, i);
else
/*
- * Delete message from sequence.
- *
- * If error, return 0, else return 1.
- */
+** Delete message from sequence.
+**
+** If error, return 0, else return 1.
+*/
int
seq_delmsg (struct msgs *mp, char *cp, int msgnum)
/*
- * seq_getnum.c -- find the index for a sequence
- * -- return -1 if sequence doesn't exist
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_getnum.c -- find the index for a sequence
+** -- return -1 if sequence doesn't exist
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * seq_list.c -- Get all messages in a sequence and return them
- * -- as a space separated list of message ranges.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_list.c -- Get all messages in a sequence and return them
+** -- as a space separated list of message ranges.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
}
/*
- * Special processing for "cur" sequence. We assume that the
- * "cur" sequence and mp->curmsg are in sync (see seq_add.c).
- * This is returned, even if message doesn't exist or the
- * folder is empty.
- */
+ ** Special processing for "cur" sequence. We assume that the
+ ** "cur" sequence and mp->curmsg are in sync (see seq_add.c).
+ ** This is returned, even if message doesn't exist or the
+ ** folder is empty.
+ */
if (!strcmp (current, seqname)) {
if (mp->curmsg) {
sprintf(buffer, "%s", m_name(mp->curmsg));
for (i = mp->lowmsg; i <= mp->hghmsg; ++i) {
/*
- * If message doesn't exist, or isn't in
- * the sequence, then continue.
- */
+ ** If message doesn't exist, or isn't in
+ ** the sequence, then continue.
+ */
if (!does_exist(mp, i) || !in_sequence(mp, seqnum, i))
continue;
/*
- * See if we need to enlarge buffer. Since we don't know
- * exactly how many character this particular message range
- * will need, we enlarge the buffer if we are within
- * 50 characters of the end.
- */
+ ** See if we need to enlarge buffer. Since we don't know
+ ** exactly how many character this particular message range
+ ** will need, we enlarge the buffer if we are within
+ ** 50 characters of the end.
+ */
if (bp - buffer > len - 50) {
char *newbuf;
}
/*
- * If this is not the first message range in
- * the list, first add a space.
- */
+ ** If this is not the first message range in
+ ** the list, first add a space.
+ */
if (bp > buffer)
*bp++ = ' ';
j = i; /* Remember beginning of message range */
/*
- * Scan to the end of this message range
- */
+ ** Scan to the end of this message range
+ */
for (++i; i <= mp->hghmsg && does_exist(mp, i) && in_sequence(mp, seqnum, i);
++i)
;
/*
- * seq_nameok.c -- check if a sequence name is ok
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_nameok.c -- check if a sequence name is ok
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
}
/*
- * Make sure sequence name doesn't clash with one
- * of the `reserved' sequence names.
- */
+ ** Make sure sequence name doesn't clash with one
+ ** of the `reserved' sequence names.
+ */
if (!(strcmp (s, "new") &&
strcmp (s, "all") &&
strcmp (s, "first") &&
}
/*
- * First character in a sequence name must be
- * an alphabetic character ...
- */
+ ** First character in a sequence name must be
+ ** an alphabetic character ...
+ */
if (!isalpha (*s)) {
advise (NULL, "illegal sequence name: %s", s);
return 0;
}
/*
- * and can be followed by zero or more alphanumeric characters
- */
+ ** and can be followed by zero or more alphanumeric characters
+ */
for (pp = s + 1; *pp; pp++)
if (!isalnum (*pp)) {
advise (NULL, "illegal sequence name: %s", s);
/*
- * seq_print.c -- Routines to print sequence information.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_print.c -- Routines to print sequence information.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#define empty(s) ((s) ? (s) : "")
/*
- * Print all the sequences in a folder
- */
+** Print all the sequences in a folder
+*/
void
seq_printall (struct msgs *mp)
{
/*
- * Print a particular sequence in a folder
- */
+** Print a particular sequence in a folder
+*/
void
seq_print (struct msgs *mp, char *seqname)
{
/*
- * seq_read.c -- read the .mh_sequence file and
- * -- initialize sequence information
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_read.c -- read the .mh_sequence file and
+** -- initialize sequence information
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
/*
- * static prototypes
- */
+** static prototypes
+*/
static int seq_init (struct msgs *, char *, char *);
static void seq_public (struct msgs *);
static void seq_private (struct msgs *);
/*
- * Get the sequence information for this folder from
- * .mh_sequences (or equivalent specified in .mh_profile)
- * or context file (for private sequences).
- */
+** Get the sequence information for this folder from
+** .mh_sequences (or equivalent specified in .mh_profile)
+** or context file (for private sequences).
+*/
void
seq_read (struct msgs *mp)
{
/*
- * Initialize the list of sequence names. Go ahead and
- * add the "cur" sequence to the list of sequences.
- */
+ ** Initialize the list of sequence names. Go ahead and
+ ** add the "cur" sequence to the list of sequences.
+ */
mp->msgattrs[0] = getcpy (current);
mp->msgattrs[1] = NULL;
make_all_public (mp); /* initially, make all public */
/*
- * read folder's sequences file for public sequences
- */
+** read folder's sequences file for public sequences
+*/
static void
seq_public (struct msgs *mp)
FILE *fp;
/*
- * If mh_seq == NULL (such as if nmh been compiled with
- * NOPUBLICSEQ), or if *mh_seq == '\0' (the user has defined
- * the "mh-sequences" profile entry, but left it empty),
- * then just return, and do not initialize any public sequences.
- */
+ ** If mh_seq == NULL (such as if nmh been compiled with
+ ** NOPUBLICSEQ), or if *mh_seq == '\0' (the user has defined
+ ** the "mh-sequences" profile entry, but left it empty),
+ ** then just return, and do not initialize any public sequences.
+ */
if (mh_seq == NULL || *mh_seq == '\0')
return;
/*
- * Scan profile/context list for private sequences.
- *
- * We search the context list for all keys that look like
- * "atr-seqname-folderpath", and add them as private sequences.
- */
+** Scan profile/context list for private sequences.
+**
+** We search the context list for all keys that look like
+** "atr-seqname-folderpath", and add them as private sequences.
+*/
static void
seq_private (struct msgs *mp)
/*
- * Add the name of sequence to the list of folder sequences.
- * Then parse the list of message ranges for this
- * sequence, and setup the various bit flags for each
- * message in the sequence.
- *
- * Return internal index for the sequence if successful.
- * Return -1 on error.
- */
+** Add the name of sequence to the list of folder sequences.
+** Then parse the list of message ranges for this
+** sequence, and setup the various bit flags for each
+** message in the sequence.
+**
+** Return internal index for the sequence if successful.
+** Return -1 on error.
+*/
static int
seq_init (struct msgs *mp, char *name, char *field)
char *cp, **ap;
/*
- * Check if this is "cur" sequence,
- * so we can do some special things.
- */
+ ** Check if this is "cur" sequence,
+ ** so we can do some special things.
+ */
is_current = !strcmp (current, name);
/*
- * Search for this sequence name to see if we've seen
- * it already. If we've seen this sequence before,
- * then clear the bit for this sequence from all the
- * mesages in this folder.
- */
+ ** Search for this sequence name to see if we've seen
+ ** it already. If we've seen this sequence before,
+ ** then clear the bit for this sequence from all the
+ ** mesages in this folder.
+ */
for (i = 0; mp->msgattrs[i]; i++) {
if (!strcmp (mp->msgattrs[i], name)) {
for (j = mp->lowmsg; j <= mp->hghmsg; j++)
}
/*
- * If we've already seen this sequence name, just free the
- * name string. Else add it to the list of sequence names.
- */
+ ** If we've already seen this sequence name, just free the
+ ** name string. Else add it to the list of sequence names.
+ */
if (mp->msgattrs[i]) {
free (name);
} else {
}
/*
- * Split up the different message ranges at whitespace
- */
+ ** Split up the different message ranges at whitespace
+ */
for (ap = brkstring (field, " ", "\n"); *ap; ap++) {
if ((cp = strchr(*ap, '-')))
*cp++ = '\0';
k = cp ? m_atoi (cp) : j;
/*
- * Keep mp->curmsg and "cur" sequence in synch. Unlike
- * other sequences, this message doesn't need to exist.
- * Think about the series of command (rmm; next) to
- * understand why this can be the case. But if it does
- * exist, we will still set the bit flag for it like
- * other sequences.
- */
+ ** Keep mp->curmsg and "cur" sequence in synch. Unlike
+ ** other sequences, this message doesn't need to exist.
+ ** Think about the series of command (rmm; next) to
+ ** understand why this can be the case. But if it does
+ ** exist, we will still set the bit flag for it like
+ ** other sequences.
+ */
if (is_current)
mp->curmsg = j;
/*
- * We iterate through messages in this range
- * and flip on bit for this sequence.
- */
+ ** We iterate through messages in this range
+ ** and flip on bit for this sequence.
+ */
for (; j <= k; j++) {
if (j >= mp->lowmsg && j <= mp->hghmsg && does_exist(mp, j))
add_sequence (mp, i, j);
/*
- * seq_save.c -- 1) synchronize sequences
- * -- 2) save public sequences
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_save.c -- 1) synchronize sequences
+** -- 2) save public sequences
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/signals.h>
/*
- * 1. If sequence is public and folder is readonly,
- * then change it to be private
- * 2a. If sequence is public, then add it to the sequences file
- * in folder (name specified by mh-sequences profile entry).
- * 2b. If sequence is private, then add it to the
- * context file.
- */
+** 1. If sequence is public and folder is readonly,
+** then change it to be private
+** 2a. If sequence is public, then add it to the sequences file
+** in folder (name specified by mh-sequences profile entry).
+** 2b. If sequence is private, then add it to the
+** context file.
+*/
void
seq_save (struct msgs *mp)
flags = mp->msgflags; /* record folder flags */
/*
- * If no mh-sequences file is defined, or if a mh-sequences file
- * is defined but empty (*mh_seq == '\0'), then pretend folder
- * is readonly. This will force all sequences to be private.
- */
+ ** If no mh-sequences file is defined, or if a mh-sequences file
+ ** is defined but empty (*mh_seq == '\0'), then pretend folder
+ ** is readonly. This will force all sequences to be private.
+ */
if (mh_seq == NULL || *mh_seq == '\0')
set_readonly (mp);
else
- snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq);
+ snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath,
+ mh_seq);
for (i = 0; mp->msgattrs[i]; i++) {
- snprintf (attr, sizeof(attr), "atr-%s-%s", mp->msgattrs[i], mp->foldpath);
+ snprintf (attr, sizeof(attr), "atr-%s-%s", mp->msgattrs[i],
+ mp->foldpath);
/* get space separated list of sequence ranges */
if (!(cp = seq_list(mp, mp->msgattrs[i]))) {
if (is_readonly(mp) || is_seq_private(mp, i)) {
priv:
- /*
- * sequence is private
- */
+ /* sequence is private */
context_replace (attr, cp); /* update sequence in context */
} else {
- /*
- * sequence is public
- */
+ /* sequence is public */
context_del (attr); /* delete sequence from context */
if (!fp) {
/*
- * Attempt to open file for public sequences.
- * If that fails (probably because folder is
- * readonly), then make sequence private.
- */
+ ** Attempt to open file for public sequences.
+ ** If that fails (probably because folder is
+ ** readonly), then make sequence private.
+ */
if ((fp = lkfopen (seqfile, "w")) == NULL
&& (unlink (seqfile) == -1 ||
(fp = lkfopen (seqfile, "w")) == NULL)) {
SIGPROCMASK (SIG_SETMASK, &oset, &set); /* reset signal mask */
} else {
/*
- * If folder is not readonly, and we didn't save any
- * public sequences, then remove that file.
- */
+ ** If folder is not readonly, and we didn't save any
+ ** public sequences, then remove that file.
+ */
if (!is_readonly(mp))
unlink (seqfile);
}
/*
- * Reset folder flag, since we may be
- * pretending that folder is readonly.
- */
+ ** Reset folder flag, since we may be
+ ** pretending that folder is readonly.
+ */
mp->msgflags = flags;
}
/*
- * seq_setcur.c -- set the current message ("cur" sequence) for a folder
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_setcur.c -- set the current message ("cur" sequence) for a folder
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
seq_setcur (struct msgs *mp, int msgnum)
{
/*
- * Just call seq_addmsg() to update the
- * "cur" sequence.
- */
+ ** Just call seq_addmsg() to update the
+ ** "cur" sequence.
+ */
seq_addmsg (mp, current, msgnum, -1, 1);
}
/*
- * seq_setprev.c -- set the Previous-Sequence
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_setprev.c -- set the Previous-Sequence
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * Add all the messages currently SELECTED to
- * the Previous-Sequence. This way, when the next
- * command is given, there is a convenient way to
- * selected all the messages used in the previous
- * command.
- */
+** Add all the messages currently SELECTED to
+** the Previous-Sequence. This way, when the next
+** command is given, there is a convenient way to
+** selected all the messages used in the previous
+** command.
+*/
void
seq_setprev (struct msgs *mp)
char **ap, *cp, *dp;
/*
- * Get the list of sequences for Previous-Sequence
- * and split them.
- */
+ ** Get the list of sequences for Previous-Sequence
+ ** and split them.
+ */
if ((cp = context_find (psequence))) {
dp = getcpy (cp);
if (!(ap = brkstring (dp, " ", "\n")) || !*ap) {
/*
- * seq_setunseen.c -- add/delete all messages which have the SELECT_UNSEEN
- * -- bit set to/from the Unseen-Sequence
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** seq_setunseen.c -- add/delete all messages which have the SELECT_UNSEEN
+** -- bit set to/from the Unseen-Sequence
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * We scan through the folder and act upon all messages
- * that are marked with the SELECT_UNSEEN bit.
- *
- * If seen == 1, delete messages from unseen sequence.
- * If seen == 0, add messages to unseen sequence.
- */
+** We scan through the folder and act upon all messages
+** that are marked with the SELECT_UNSEEN bit.
+**
+** If seen == 1, delete messages from unseen sequence.
+** If seen == 0, add messages to unseen sequence.
+*/
void
seq_setunseen (struct msgs *mp, int seen)
char **ap, *cp, *dp;
/*
- * Get the list of sequences for Unseen-Sequence
- * and split them.
- */
+ ** Get the list of sequences for Unseen-Sequence
+ ** and split them.
+ */
if ((cp = context_find (usequence))) {
dp = getcpy (cp);
if (!(ap = brkstring (dp, " ", "\n")) || !*ap) {
}
/*
- * Now add/delete each message which has the SELECT_UNSEEN
- * bit set to/from each of these sequences.
- */
+ ** Now add/delete each message which has the SELECT_UNSEEN
+ ** bit set to/from each of these sequences.
+ */
for (; *ap; ap++) {
if (seen) {
/* make sure sequence exists first */
/*
- * showfile.c -- invoke the `lproc' command
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** showfile.c -- invoke the `lproc' command
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
fflush(stdout);
/*
- * If you have your lproc listed as "mhl",
- * then really invoked the mhlproc instead
- * (which is usually mhl anyway).
- */
+ ** If you have your lproc listed as "mhl",
+ ** then really invoked the mhlproc instead
+ ** (which is usually mhl anyway).
+ */
if (!strcmp (r1bindex (lproc, '/'), "mhl"))
lproc = mhlproc;
/*
- * signals.c -- general signals interface for nmh
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** signals.c -- general signals interface for nmh
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/signals.h>
/*
- * A version of the function `signal' that uses reliable
- * signals, if the machine supports them. Also, (assuming
- * OS support), it restarts interrupted system calls for all
- * signals except SIGALRM.
- */
+** A version of the function `signal' that uses reliable
+** signals, if the machine supports them. Also, (assuming
+** OS support), it restarts interrupted system calls for all
+** signals except SIGALRM.
+*/
SIGNAL_HANDLER
SIGNAL (int sig, SIGNAL_HANDLER func)
/*
- * A version of the function `signal' that will set
- * the handler of `sig' to `func' if the signal is
- * not currently set to SIG_IGN. Also uses reliable
- * signals if available.
- */
+** A version of the function `signal' that will set
+** the handler of `sig' to `func' if the signal is
+** not currently set to SIG_IGN. Also uses reliable
+** signals if available.
+*/
SIGNAL_HANDLER
SIGNAL2 (int sig, SIGNAL_HANDLER func)
{
/*
- * smatch.c -- match a switch (option)
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** smatch.c -- match a switch (option)
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * snprintb.c -- snprintf a %b string
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** snprintb.c -- snprintf a %b string
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * snprintf.c -- formatted output to a string
- *
- * This is an implementation of snprintf() and vsnprintf()
- * taken from the Apache web server. This is only used on
- * systems which do not have a native version.
- */
+** snprintf.c -- formatted output to a string
+**
+** This is an implementation of snprintf() and vsnprintf()
+** taken from the Apache web server. This is only used on
+** systems which do not have a native version.
+*/
/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. All advertising materials mentioning features or use of this
- * software must display the following acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- * This code is based on, and used with the permission of, the
- * SIO stdio-replacement strx_* functions by Panos Tsirigotis
- * <panos@alumni.cs.colorado.edu> for xinetd.
- */
+** Copyright (c) 1995-1999 The Apache Group. All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+**
+** 2. Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+**
+** 3. All advertising materials mentioning features or use of this
+** software must display the following acknowledgment:
+** "This product includes software developed by the Apache Group
+** for use in the Apache HTTP server project (http://www.apache.org/)."
+**
+** 4. The names "Apache Server" and "Apache Group" must not be used to
+** endorse or promote products derived from this software without
+** prior written permission. For written permission, please contact
+** apache@apache.org.
+**
+** 5. Products derived from this software may not be called "Apache"
+** nor may "Apache" appear in their names without prior written
+** permission of the Apache Group.
+**
+** 6. Redistributions of any form whatsoever must retain the following
+** acknowledgment:
+** "This product includes software developed by the Apache Group
+** for use in the Apache HTTP server project (http://www.apache.org/)."
+**
+** THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
+** EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
+** ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+** STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+** OF THE POSSIBILITY OF SUCH DAMAGE.
+** ====================================================================
+**
+** This software consists of voluntary contributions made by many
+** individuals on behalf of the Apache Group and was originally based
+** on public domain software written at the National Center for
+** Supercomputing Applications, University of Illinois, Urbana-Champaign.
+** For more information on the Apache Group and the Apache HTTP server
+** project, please see <http://www.apache.org/>.
+**
+** This code is based on, and used with the permission of, the
+** SIO stdio-replacement strx_* functions by Panos Tsirigotis
+** <panos@alumni.cs.colorado.edu> for xinetd.
+*/
#include <stdio.h>
#include <ctype.h>
#define FLOAT_DIGITS 6
#define EXPONENT_LENGTH 10
-/* These macros allow correct support of 8-bit characters on systems which
- * support 8-bit characters. Pretty dumb how the cast is required, but
- * that's legacy libc for ya. These new macros do not support EOF like
- * the standard macros do. Tough.
- */
+/*
+** These macros allow correct support of 8-bit characters on systems which
+** support 8-bit characters. Pretty dumb how the cast is required, but
+** that's legacy libc for ya. These new macros do not support EOF like
+** the standard macros do. Tough.
+*/
#define ap_isalpha(c) (isalpha(((unsigned char)(c))))
#define ap_isdigit(c) (isdigit(((unsigned char)(c))))
#define ap_islower(c) (islower(((unsigned char)(c))))
/*
- * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions
- *
- * XXX: this is a magic number; do not decrease it
- */
+** NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions
+**
+** XXX: this is a magic number; do not decrease it
+*/
#define NUM_BUF_SIZE 512
/*
- * cvt.c - IEEE floating point formatting routines for FreeBSD
- * from GNU libc-4.6.27. Modified to be thread safe.
- */
+** cvt.c - IEEE floating point formatting routines for FreeBSD
+** from GNU libc-4.6.27. Modified to be thread safe.
+*/
/*
- * ap_ecvt converts to decimal
- * the number of digits is specified by ndigit
- * decpt is set to the position of the decimal point
- * sign is set to 0 for positive, 1 for negative
- */
+** ap_ecvt converts to decimal
+** the number of digits is specified by ndigit
+** decpt is set to the position of the decimal point
+** sign is set to 0 for positive, 1 for negative
+*/
#define NDIG 80
arg = modf(arg, &fi);
p1 = &buf[NDIG];
/*
- * Do integer part
- */
+ ** Do integer part
+ */
if (fi != 0) {
p1 = &buf[NDIG];
while (fi != 0) {
}
/*
- * ap_gcvt - Floating output conversion to
- * minimal length string
- */
+** ap_gcvt - Floating output conversion to
+** minimal length string
+*/
static char *
ap_gcvt(double number, int ndigit, char *buf, boolean_e altform)
}
/*
- * The INS_CHAR macro inserts a character in the buffer and writes
- * the buffer back to disk if necessary
- * It uses the char pointers sp and bep:
- * sp points to the next available character in the buffer
- * bep points to the end-of-buffer+1
- * While using this macro, note that the nextb pointer is NOT updated.
- *
- * NOTE: Evaluation of the c argument should not have any side-effects
- */
+** The INS_CHAR macro inserts a character in the buffer and writes
+** the buffer back to disk if necessary
+** It uses the char pointers sp and bep:
+** sp points to the next available character in the buffer
+** bep points to the end-of-buffer+1
+** While using this macro, note that the nextb pointer is NOT updated.
+**
+** NOTE: Evaluation of the c argument should not have any side-effects
+*/
#define INS_CHAR(c, sp, bep, cc) \
{ \
if (sp >= bep) { \
}
/*
- * This macro does zero padding so that the precision
- * requirement is satisfied. The padding is done by
- * adding '0's to the left of the string that is going
- * to be printed.
- */
+** This macro does zero padding so that the precision
+** requirement is satisfied. The padding is done by
+** adding '0's to the left of the string that is going
+** to be printed.
+*/
#define FIX_PRECISION( adjust, precision, s, s_len ) \
if ( adjust ) \
while ( s_len < precision ) \
}
/*
- * Macro that does padding. The padding is done by printing
- * the character ch.
- */
+** Macro that does padding. The padding is done by printing
+** the character ch.
+*/
#define PAD( width, len, ch ) do \
{ \
INS_CHAR( ch, sp, bep, cc ) ; \
while ( width > len )
/*
- * Prefix the character ch to the string str
- * Increase length
- * Set the has_prefix flag
- */
+** Prefix the character ch to the string str
+** Increase length
+** Set the has_prefix flag
+*/
#define PREFIX( str, length, ch ) *--str = ch ; length++ ; has_prefix = YES
/*
- * Convert num to its decimal format.
- * Return value:
- * - a pointer to a string containing the number (no sign)
- * - len contains the length of the string
- * - is_negative is set to TRUE or FALSE depending on the sign
- * of the number (always set to FALSE if is_unsigned is TRUE)
- *
- * The caller provides a buffer for the string: that is the buf_end argument
- * which is a pointer to the END of the buffer + 1 (i.e. if the buffer
- * is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
- */
+** Convert num to its decimal format.
+** Return value:
+** - a pointer to a string containing the number (no sign)
+** - len contains the length of the string
+** - is_negative is set to TRUE or FALSE depending on the sign
+** of the number (always set to FALSE if is_unsigned is TRUE)
+**
+** The caller provides a buffer for the string: that is the buf_end argument
+** which is a pointer to the END of the buffer + 1 (i.e. if the buffer
+** is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
+*/
static char *
conv_10(register wide_int num, register bool_int is_unsigned,
register bool_int *is_negative, char *buf_end,
*is_negative = (num < 0);
/*
- * On a 2's complement machine, negating the most negative integer
- * results in a number that cannot be represented as a signed integer.
- * Here is what we do to obtain the number's magnitude:
- * a. add 1 to the number
- * b. negate it (becomes positive)
- * c. convert it to unsigned
- * d. add 1
- */
+ ** On a 2's complement machine, negating the most negative
+ ** integer results in a number that cannot be represented
+ ** as a signed integer.
+ ** Here is what we do to obtain the number's magnitude:
+ ** a. add 1 to the number
+ ** b. negate it (becomes positive)
+ ** c. convert it to unsigned
+ ** d. add 1
+ */
if (*is_negative) {
wide_int t = num + 1;
}
/*
- * We use a do-while loop so that we write at least 1 digit
- */
+ ** We use a do-while loop so that we write at least 1 digit
+ */
do {
register u_wide_int new_magnitude = magnitude / 10;
/*
- * Convert a floating point number to a string formats 'f', 'e' or 'E'.
- * The result is placed in buf, and len denotes the length of the string
- * The sign is returned in the is_negative argument (and is not placed
- * in buf).
- */
+** Convert a floating point number to a string formats 'f', 'e' or 'E'.
+** The result is placed in buf, and len denotes the length of the string
+** The sign is returned in the is_negative argument (and is not placed
+** in buf).
+*/
static char *
conv_fp(register char format, register double num,
boolean_e add_dp, int precision, bool_int *is_negative,
p = ap_ecvt(num, precision + 1, &decimal_point, is_negative, buf1);
/*
- * Check for Infinity and NaN
- */
+ ** Check for Infinity and NaN
+ */
if (ap_isalpha(*p)) {
*len = strlen(strcpy(buf, p));
*is_negative = FALSE;
}
/*
- * copy the rest of p, the NUL is NOT copied
- */
+ ** copy the rest of p, the NUL is NOT copied
+ */
while (*p)
*s++ = *p++;
*s++ = exponent_is_negative ? '-' : '+';
/*
- * Make sure the exponent has at least 2 digits
- */
+ ** Make sure the exponent has at least 2 digits
+ */
if (t_len == 1)
*s++ = '0';
while (t_len--)
/*
- * Convert num to a base X number where X is a power of 2. nbits determines X.
- * For example, if nbits is 3, we do base 8 conversion
- * Return value:
- * a pointer to a string containing the number
- *
- * The caller provides a buffer for the string: that is the buf_end argument
- * which is a pointer to the END of the buffer + 1 (i.e. if the buffer
- * is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
- */
+** Convert num to a base X number where X is a power of 2. nbits determines X.
+** For example, if nbits is 3, we do base 8 conversion
+** Return value:
+** a pointer to a string containing the number
+**
+** The caller provides a buffer for the string: that is the buf_end argument
+** which is a pointer to the END of the buffer + 1 (i.e. if the buffer
+** is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
+*/
static char *
conv_p2(register u_wide_int num, register int nbits,
char format, char *buf_end, register int *len)
/*
- * Do format conversion placing the output in buffer
- */
+** Do format conversion placing the output in buffer
+*/
static int
ap_vformatter(int (*flush_func)(ap_vformatter_buff *),
ap_vformatter_buff *vbuff, const char *fmt, va_list ap)
char char_buf[2]; /* for printing %% and %<unknown> */
/*
- * Flag variables
- */
+ ** Flag variables
+ */
boolean_e is_long;
boolean_e alternate_form;
boolean_e print_sign;
INS_CHAR(*fmt, sp, bep, cc);
} else {
/*
- * Default variable settings
- */
+ ** Default variable settings
+ */
adjust = RIGHT;
alternate_form = print_sign = print_blank = NO;
pad_char = ' ';
fmt++;
/*
- * Try to avoid checking for flags, width or precision
- */
+ ** Try to avoid checking for flags, width or precision
+ */
if (!ap_islower(*fmt)) {
/*
- * Recognize flags: -, #, BLANK, +
- */
+ ** Recognize flags: -, #, BLANK, +
+ */
for (;; fmt++) {
if (*fmt == '-')
adjust = LEFT;
}
/*
- * Check if a width was specified
- */
+ ** Check if a width was specified
+ */
if (ap_isdigit(*fmt)) {
STR_TO_DEC(fmt, min_width);
adjust_width = YES;
adjust_width = NO;
/*
- * Check if a precision was specified
- *
- * XXX: an unreasonable amount of precision may be specified
- * resulting in overflow of num_buf. Currently we
- * ignore this possibility.
- */
+ ** Check if a precision was specified
+ **
+ ** XXX: an unreasonable amount of precision
+ ** may be specified resulting in overflow of
+ ** num_buf. Currently we ignore this
+ ** possibility.
+ */
if (*fmt == '.') {
adjust_precision = YES;
fmt++;
adjust_precision = adjust_width = NO;
/*
- * Modifier check
- */
+ ** Modifier check
+ */
if (*fmt == 'l') {
is_long = YES;
fmt++;
}
/*
- * Argument extraction and printing.
- * First we determine the argument type.
- * Then, we convert the argument to a string.
- * On exit from the switch, s points to the string that
- * must be printed, s_len has the length of the string
- * The precision requirements, if any, are reflected in s_len.
- *
- * NOTE: pad_char may be set to '0' because of the 0 flag.
- * It is reset to ' ' by non-numeric formats
- */
+ ** Argument extraction and printing.
+ ** First we determine the argument type.
+ ** Then, we convert the argument to a string.
+ ** On exit from the switch, s points to the string that
+ ** must be printed, s_len has the length of the string
+ ** The precision requirements, if any, are reflected
+ ** in s_len.
+ **
+ ** NOTE: pad_char may be set to '0' because of the
+ ** 0 flag.
+ ** It is reset to ' ' by non-numeric formats
+ */
switch (*fmt) {
case 'u':
if (is_long)
case 'E':
fp_num = va_arg(ap, double);
/*
- * * We use &num_buf[ 1 ], so that we have room for the sign
- */
+ ** We use &num_buf[ 1 ], so that we have
+ ** room for the sign
+ */
s = conv_fp(*fmt, fp_num, alternate_form,
(adjust_precision == NO) ? FLOAT_DIGITS : precision,
&is_negative, &num_buf[1], &s_len);
else if (precision == 0)
precision = 1;
/*
- * * We use &num_buf[ 1 ], so that we have room for the sign
- */
+ ** We use &num_buf[ 1 ], so that we have
+ ** room for the sign
+ */
s = ap_gcvt(va_arg(ap, double), precision, &num_buf[1],
alternate_form);
if (*s == '-')
break;
/*
- * This is where we extend the printf format, with a second
- * type specifier
- */
+ ** This is where we extend the printf format,
+ ** with a second type specifier
+ */
case 'p':
switch(*++fmt) {
/*
- * If the pointer size is equal to the size of an unsigned
- * integer we convert the pointer to a hex number, otherwise
- * we print "%p" to indicate that we don't handle "%p".
- */
+ ** If the pointer size is equal to
+ ** the size of an unsigned integer
+ ** we convert the pointer to a hex
+ ** number, otherwise we print "%p"
+ ** to indicate that we don't handle
+ ** "%p".
+ */
case 'p':
ui_num = (u_wide_int) va_arg(ap, void *);
pad_char = ' ';
break;
- /* print a struct sockaddr_in as a.b.c.d:port */
+ /*
+ ** print a struct sockaddr_in as
+ ** a.b.c.d:port
+ */
case 'I':
{
struct sockaddr_in *si;
s = conv_sockaddr_in(si, &num_buf[NUM_BUF_SIZE], &s_len);
if (adjust_precision && precision < s_len)
s_len = precision;
- }
- else {
+ } else {
s = S_NULL;
s_len = S_NULL_LEN;
}
s = conv_in_addr(ia, &num_buf[NUM_BUF_SIZE], &s_len);
if (adjust_precision && precision < s_len)
s_len = precision;
- }
- else {
+ } else {
s = S_NULL;
s_len = S_NULL_LEN;
}
case NUL:
/*
- * The last character of the format string was %.
- * We ignore it.
- */
+ ** The last character of the format string
+ ** was %. We ignore it.
+ */
continue;
/*
- * The default case is for unrecognized %'s.
- * We print %<char> to help the user identify what
- * option is not understood.
- * This is also useful in case the user wants to pass
- * the output of format_converter to another function
- * that understands some other %<char> (like syslog).
- * Note that we can't point s inside fmt because the
- * unknown <char> could be preceded by width etc.
- */
+ ** The default case is for unrecognized %'s.
+ ** We print %<char> to help the user identify
+ ** what option is not understood. This is
+ ** also useful in case the user wants to
+ ** pass the output of format_converter
+ ** to another function that understands
+ ** some other %<char> (like syslog).
+ ** Note that we can't point s inside fmt
+ ** because the unknown <char> could be
+ ** preceded by width etc.
+ */
default:
char_buf[0] = '%';
char_buf[1] = *fmt;
}
/*
- * Print the string s.
- */
+ ** Print the string s.
+ */
for (i = s_len; i != 0; i--) {
INS_CHAR(*s, sp, bep, cc);
s++;
static int
snprintf_flush(ap_vformatter_buff *vbuff)
{
- /* if the buffer fills we have to abort immediately, there is no way
- * to "flush" a snprintf... there's nowhere to flush it to.
- */
+ /*
+ ** if the buffer fills we have to abort immediately, there is no way
+ ** to "flush" a snprintf... there's nowhere to flush it to.
+ */
return -1;
}
/*
- * ssequal.c -- check if a string is a substring of another
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** ssequal.c -- check if a string is a substring of another
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * THIS CODE DOES NOT WORK AS ADVERTISED.
- * It is actually checking if s1 is a PREFIX of s2.
- * All calls to this function need to be checked to see
- * if that needs to be changed. Prefix checking is cheaper, so
- * should be kept if it's sufficient.
- */
+** THIS CODE DOES NOT WORK AS ADVERTISED.
+** It is actually checking if s1 is a PREFIX of s2.
+** All calls to this function need to be checked to see
+** if that needs to be changed. Prefix checking is cheaper, so
+** should be kept if it's sufficient.
+*/
/*
- * Check if s1 is a substring of s2.
- * If yes, then return 1, else return 0.
- */
+** Check if s1 is a substring of s2.
+** If yes, then return 1, else return 0.
+*/
int
ssequal (char *s1, char *s2)
/*
- * strcasecmp.c -- compare strings, ignoring case
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** strcasecmp.c -- compare strings, ignoring case
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * Our version of strcasecmp has to deal with NULL strings.
- * Once that is fixed in the rest of the code, we can use the
- * native version, instead of this one.
- */
+** Our version of strcasecmp has to deal with NULL strings.
+** Once that is fixed in the rest of the code, we can use the
+** native version, instead of this one.
+*/
int
mh_strcasecmp (const char *s1, const char *s2)
/*
- * strdup.c -- duplicate a string
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** strdup.c -- duplicate a string
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
/*
- * strindex.c -- "unsigned" lexical index
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** strindex.c -- "unsigned" lexical index
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * trimcpy.c -- strip leading and trailing whitespace,
- * -- replace internal whitespace with spaces,
- * -- then return a copy.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** trimcpy.c -- strip leading and trailing whitespace,
+** -- replace internal whitespace with spaces,
+** -- then return a copy.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * uprf.c -- "unsigned" lexical prefix
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** uprf.c -- "unsigned" lexical prefix
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * utils.c -- various utility routines
- *
- * This code is Copyright (c) 2006, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** utils.c -- various utility routines
+**
+** This code is Copyright (c) 2006, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
#include <errno.h>
/*
- * We allocate space for messages (msgs array)
- * this number of elements at a time.
- */
+** We allocate space for messages (msgs array)
+** this number of elements at a time.
+*/
#define MAXMSGS 256
/*
- * Safely call malloc
- */
+** Safely call malloc
+*/
void *
mh_xmalloc(size_t size)
{
}
/*
- * Safely call realloc
- */
+** Safely call realloc
+*/
void *
mh_xrealloc(void *ptr, size_t size)
{
}
/*
- * Return the present working directory, if the current directory does not
- * exist, or is too long, make / the pwd.
- */
+** Return the present working directory, if the current directory does not
+** exist, or is too long, make / the pwd.
+*/
char *
pwd(void)
{
}
/*
- * add -- If "s1" is NULL, this routine just creates a
- * -- copy of "s2" into newly malloc'ed memory.
- * --
- * -- If "s1" is not NULL, then copy the concatenation
- * -- of "s1" and "s2" (note the order) into newly
- * -- malloc'ed memory. Then free "s1".
- */
+** add -- If "s1" is NULL, this routine just creates a
+** -- copy of "s2" into newly malloc'ed memory.
+** --
+** -- If "s1" is not NULL, then copy the concatenation
+** -- of "s1" and "s2" (note the order) into newly
+** -- malloc'ed memory. Then free "s1".
+*/
char *
add (char *s2, char *s1)
{
}
/*
- * folder_exists
- * Check to see if a folder exists.
- */
+** folder_exists
+** Check to see if a folder exists.
+*/
int
folder_exists(char *folder)
{
int exists = 0;
if (stat (folder, &st) == -1) {
- /* The folder either doesn't exist, or we hit an error.
- * Either way return a failure.
- */
+ /*
+ ** The folder either doesn't exist, or we hit an error.
+ ** Either way return a failure.
+ */
exists = 0;
} else {
/* We can see a folder with the right name */
/*
- * create_folder
- * Check to see if a folder exists, if not, prompt the user to create it.
- */
+** create_folder
+** Check to see if a folder exists, if not, prompt the user to create it.
+*/
void
create_folder(char *folder, int autocreate, void (*done_callback)(int))
{
}
/*
- * num_digits
- * Return the number of digits in a nonnegative integer.
- */
+** num_digits
+** Return the number of digits in a nonnegative integer.
+*/
int
num_digits (int n)
{
}
/*
- * Append a message arg to an array of them, resizing it if necessary.
- * The function is written to suit the arg parsing code it was extracted
- * from, and will probably be changed when the other code is cleaned up.
- */
+** Append a message arg to an array of them, resizing it if necessary.
+** The function is written to suit the arg parsing code it was extracted
+** from, and will probably be changed when the other code is cleaned up.
+*/
void
app_msgarg(struct msgs_array *msgs, char *cp)
{
if(msgs->size >= msgs->max)
- msgs->msgs = mh_xrealloc(msgs->msgs, (msgs->max+=MAXMSGS)*sizeof(*msgs->msgs));
+ msgs->msgs = mh_xrealloc(msgs->msgs,
+ (msgs->max+=MAXMSGS)*sizeof(*msgs->msgs));
msgs->msgs[msgs->size++] = cp;
}
/*
- * vfgets.c -- virtual fgets
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** vfgets.c -- virtual fgets
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
/*
- * ali.c -- list nmh mail aliases
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** ali.c -- list nmh mail aliases
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/addrsbr.h>
#include <h/utils.h>
/*
- * maximum number of names
- */
+** maximum number of names
+*/
#define NVEC 50
static struct swit switches[] = {
extern struct aka *akahead;
/*
- * prototypes
- */
+** prototypes
+*/
static void print_aka (char *, int, int);
static void print_usr (char *, int, int);
}
/*
- * If -user is specified
- */
+ ** If -user is specified
+ */
if (inverted) {
if (vecp == 0)
adios (NULL, "usage: %s -user addresses ... (you forgot the addresses)",
/*
- * aliasbr.c -- new aliasing mechanism
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** aliasbr.c -- new aliasing mechanism
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/aliasbr.h>
struct home *hometail = NULL;
/*
- * prototypes
- */
+** prototypes
+*/
int alias (char *);
int akvisible (void);
void init_pw (void);
break;
}
#ifdef DBMPWD
- if ((pw = getpwnam(gp)))
- {
+ if ((pw = getpwnam(gp))) {
hmalloc(pw);
add_aka (ak, gp);
}
#ifdef DBMPWD
static int init;
- if (!init)
- {
- /* if the list has yet to be initialized */
- /* zap the list, and rebuild from scratch */
- homehead=NULL;
- hometail=NULL;
- init++;
+ if (!init) {
+ /* if the list has yet to be initialized */
+ /* zap the list, and rebuild from scratch */
+ homehead=NULL;
+ hometail=NULL;
+ init++;
#endif /* DBMPWD */
- setpwent ();
+ setpwent ();
- while ((pw = getpwent ()))
- if (!hmalloc (pw))
- break;
+ while ((pw = getpwent ()))
+ if (!hmalloc (pw))
+ break;
- endpwent ();
+ endpwent ();
#ifdef DBMPWD
}
#endif /* DBMPWD */
#ifdef DBMPWD
/*
- * The only place where there might be problems.
- * This assumes that ALL usernames are kept in lowercase.
- */
- for (c = name, c1 = lname; *c && (c1 - lname < sizeof(lname) - 1); c++, c1++) {
+ ** The only place where there might be problems.
+ ** This assumes that ALL usernames are kept in lowercase.
+ */
+ for (c = name, c1 = lname; *c && (c1 - lname < sizeof(lname) - 1);
+ c++, c1++) {
if (isalpha(*c) && isupper(*c))
*c1 = tolower (*c);
else
/*
- * anno.c -- annotate messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- *
- * Three new options have been added: delete, list, and number.
- * Message header fields are used by the new MIME attachment code in
- * the send command. Adding features to generalize the anno command
- * seemed to be a better approach than the creation of a new command
- * whose features would overlap with those of the anno command.
- *
- * The -delete option deletes header elements that match the -component
- * field name. If -delete is used without the -text option, the first
- * header field whose field name matches the component name is deleted.
- * If the -delete is used with the -text option, and the -text argument
- * begins with a /, the first header field whose field name matches the
- * component name and whose field body matches the text is deleted. If
- * the -text argument does not begin with a /, then the text is assumed
- * to be the last component of a path name, and the first header field
- * whose field name matches the component name and a field body whose
- * last path name component matches the text is deleted. If the -delete
- * option is used with the new -number option described below, the nth
- * header field whose field name matches the component name is deleted.
- * No header fields are deleted if none of the above conditions are met.
- *
- * The -list option outputs the field bodies from each header field whose
- * field name matches the component name, one per line. If no -text
- * option is specified, only the last path name component of each field
- * body is output. The entire field body is output if the -text option
- * is used; the contents of the -text argument are ignored. If the -list
- * option is used in conjuction with the new -number option described
- * below, each line is numbered starting with 1. A tab separates the
- * number from the field body.
- *
- * The -number option works with both the -delete and -list options as
- * described above. The -number option takes an optional argument. A
- * value of 1 is assumed if this argument is absent.
- */
+** anno.c -- annotate messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+**
+** Three new options have been added: delete, list, and number.
+** Message header fields are used by the new MIME attachment code in
+** the send command. Adding features to generalize the anno command
+** seemed to be a better approach than the creation of a new command
+** whose features would overlap with those of the anno command.
+**
+** The -delete option deletes header elements that match the -component
+** field name. If -delete is used without the -text option, the first
+** header field whose field name matches the component name is deleted.
+** If the -delete is used with the -text option, and the -text argument
+** begins with a /, the first header field whose field name matches the
+** component name and whose field body matches the text is deleted. If
+** the -text argument does not begin with a /, then the text is assumed
+** to be the last component of a path name, and the first header field
+** whose field name matches the component name and a field body whose
+** last path name component matches the text is deleted. If the -delete
+** option is used with the new -number option described below, the nth
+** header field whose field name matches the component name is deleted.
+** No header fields are deleted if none of the above conditions are met.
+**
+** The -list option outputs the field bodies from each header field whose
+** field name matches the component name, one per line. If no -text
+** option is specified, only the last path name component of each field
+** body is output. The entire field body is output if the -text option
+** is used; the contents of the -text argument are ignored. If the -list
+** option is used in conjuction with the new -number option described
+** below, each line is numbered starting with 1. A tab separates the
+** number from the field body.
+**
+** The -number option works with both the -delete and -list options as
+** described above. The -number option takes an optional argument. A
+** value of 1 is assumed if this argument is absent.
+*/
#include <h/mh.h>
#include <h/utils.h>
};
/*
- * static prototypes
- */
+** static prototypes
+*/
static void make_comp (unsigned char **);
else
folder = pluspath (cp);
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
#ifdef UCI
/*
- * annosbr.c -- prepend annotation to messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** annosbr.c -- prepend annotation to messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/tws.h>
/*
- * static prototypes
- */
+** static prototypes
+*/
static int annosbr (int, char *, char *, char *, int, int, int, int);
/*
- * This "local" global and the annopreserve() function are a hack that
- * allows additional functionality to be added to anno without piling
- * on yet another annotate() argument.
- */
+** This "local" global and the annopreserve() function are a hack that
+** allows additional functionality to be added to anno without piling
+** on yet another annotate() argument.
+*/
/* set to preserve access and modification times on annotated message */
static int preserve_actime_and_modtime = 0;
}
/*
- * Produce a listing of all header fields (annotations) whose field
- * name matches comp. Number the listing if number is set. Treate the
- * field bodies as path names and just output the last component unless
- * text is non-NULL. We don't care what text is set to.
- */
+** Produce a listing of all header fields (annotations) whose field
+** name matches comp. Number the listing if number is set. Treate the
+** field bodies as path names and just output the last component unless
+** text is non-NULL. We don't care what text is set to.
+*/
void
annolist(char *file, char *comp, char *text, int number)
adios(file, "unable to open");
/*
- * Allocate a buffer to hold the header components as they're read in.
- * This buffer might need to be quite large, so we grow it as needed.
- */
+ ** Allocate a buffer to hold the header components as they're read in.
+ ** This buffer might need to be quite large, so we grow it as needed.
+ */
field = (char *)mh_xmalloc(field_size = 256);
/*
- * Get the length of the field name since we use it often.
- */
+ ** Get the length of the field name since we use it often.
+ */
length = strlen(comp);
count = 0;
do {
/*
- * Get a line from the input file, growing the field buffer
- * as needed. We do this so that we can fit an entire line
- * in the buffer making it easy to do a string comparison
- * on both the field name and the field body which might be
- * a long path name.
- */
+ ** Get a line from the input file, growing the field buffer
+ ** as needed. We do this so that we can fit an entire line
+ ** in the buffer making it easy to do a string comparison
+ ** on both the field name and the field body which might be
+ ** a long path name.
+ */
for (n = 0, cp = field; (c = getc(fp)) != EOF; *cp++ = c) {
if (c == '\n' && (c = getc(fp)) != ' ' && c != '\t') {
}
}
- /*
- * NUL-terminate the field..
- */
-
+ /* NUL-terminate the field */
*cp = '\0';
if (strncasecmp(field, comp, length) == 0 && field[length] == ':') {
} while (*field != '\0' && *field != '-');
- /*
- * Clean up.
- */
-
+ /* Clean up. */
free(field);
-
(void)fclose(fp);
return;
}
/*
- * Set the preserve-times flag. This hack eliminates the need for an
- * additional argument to annotate().
- */
-
+** Set the preserve-times flag. This hack eliminates the need for an
+** additional argument to annotate().
+*/
void
annopreserve(int preserve)
{
chmod (tmpfil, mode);
/*
- * We're going to need to copy some of the message file to the
- * temporary file while examining the contents. Convert the
- * message file descriptor to a file pointer since it's a lot
- * easier and more efficient to use stdio for this. Also allocate
- * a buffer to hold the header components as they're read in.
- * This buffer is grown as needed later.
- */
+ ** We're going to need to copy some of the message file to the
+ ** temporary file while examining the contents. Convert the
+ ** message file descriptor to a file pointer since it's a lot
+ ** easier and more efficient to use stdio for this. Also allocate
+ ** a buffer to hold the header components as they're read in.
+ ** This buffer is grown as needed later.
+ */
if (delete >= -1 || append != 0) {
if ((fp = fdopen(fd, "r")) == (FILE *)0)
}
/*
- * We're trying to delete a header field (annotation )if the
- * delete flag is not -2 or less. A value greater than zero
- * means that we're deleting the nth header field that matches
- * the field (component) name. A value of zero means that
- * we're deleting the first field in which both the field name
- * matches the component name and the field body matches the text.
- * The text is matched in its entirety if it begins with a slash;
- * otherwise the text is matched against whatever portion of the
- * field body follows the last slash. This allows matching of
- * both absolute and relative path names. This is because this
- * functionality was added to support attachments. It might be
- * worth having a separate flag to indicate path name matching
- * to make it more general. A value of -1 means to delete all
- * matching fields.
- */
+ ** We're trying to delete a header field (annotation )if the
+ ** delete flag is not -2 or less. A value greater than zero
+ ** means that we're deleting the nth header field that matches
+ ** the field (component) name. A value of zero means that
+ ** we're deleting the first field in which both the field name
+ ** matches the component name and the field body matches the text.
+ ** The text is matched in its entirety if it begins with a slash;
+ ** otherwise the text is matched against whatever portion of the
+ ** field body follows the last slash. This allows matching of
+ ** both absolute and relative path names. This is because this
+ ** functionality was added to support attachments. It might be
+ ** worth having a separate flag to indicate path name matching
+ ** to make it more general. A value of -1 means to delete all
+ ** matching fields.
+ */
if (delete >= -1) {
- /*
- * Get the length of the field name since we use it often.
- */
-
+ /* Get the length of the field name since we use it often. */
length = strlen(comp);
/*
- * Initialize the field counter. This is only used if
- * we're deleting by number.
- */
-
+ ** Initialize the field counter. This is only used if
+ ** we're deleting by number.
+ */
count = 0;
/*
- * Copy lines from the input file to the temporary file
- * until we either find the one that we're looking
- * for (which we don't copy) or we reach the end of
- * the headers. Both a blank line and a line beginning
- * with a - terminate the headers so that we can handle
- * both drafts and RFC-2822 format messages.
- */
+ ** Copy lines from the input file to the temporary file
+ ** until we either find the one that we're looking
+ ** for (which we don't copy) or we reach the end of
+ ** the headers. Both a blank line and a line beginning
+ ** with a - terminate the headers so that we can handle
+ ** both drafts and RFC-2822 format messages.
+ */
do {
/*
- * Get a line from the input file, growing the
- * field buffer as needed. We do this so that
- * we can fit an entire line in the buffer making
- * it easy to do a string comparison on both the
- * field name and the field body which might be
- * a long path name.
- */
+ ** Get a line from the input file, growing the
+ ** field buffer as needed. We do this so that
+ ** we can fit an entire line in the buffer making
+ ** it easy to do a string comparison on both the
+ ** field name and the field body which might be
+ ** a long path name.
+ */
for (n = 0, cp = field; (c = getc(fp)) != EOF; *cp++ = c) {
if (c == '\n' && (c = getc(fp)) != ' ' && c != '\t') {
}
}
- /*
- * NUL-terminate the field..
- */
-
+ /* NUL-terminate the field */
*cp = '\0';
/*
- * Check for a match on the field name. We delete
- * the line by not copying it to the temporary
- * file if
- *
- * o The delete flag is 0, meaning that we're
- * going to delete the first matching
- * field, and the text is NULL meaning that
- * we don't care about the field body.
- *
- * o The delete flag is 0, meaning that we're
- * going to delete the first matching
- * field, and the text begins with a / meaning
- * that we're looking for a full path name,
- * and the text matches the field body.
- *
- * o The delete flag is 0, meaning that we're
- * going to delete the first matching
- * field, the text does not begin with a /
- * meaning that we're looking for the last
- * path name component, and the last path
- * name component matches the text.
- *
- * o The delete flag is positive meaning that
- * we're going to delete the nth field
- * with a matching field name, and this is
- * the nth matching field name.
- *
- * o The delete flag is -1 meaning that we're
- * going to delete all fields with a
- * matching field name.
- */
+ ** Check for a match on the field name. We delete
+ ** the line by not copying it to the temporary
+ ** file if
+ **
+ ** o The delete flag is 0, meaning that we're
+ ** going to delete the first matching
+ ** field, and the text is NULL meaning that
+ ** we don't care about the field body.
+ **
+ ** o The delete flag is 0, meaning that we're
+ ** going to delete the first matching
+ ** field, and the text begins with a / meaning
+ ** that we're looking for a full path name,
+ ** and the text matches the field body.
+ **
+ ** o The delete flag is 0, meaning that we're
+ ** going to delete the first matching
+ ** field, the text does not begin with a /
+ ** meaning that we're looking for the last
+ ** path name component, and the last path
+ ** name component matches the text.
+ **
+ ** o The delete flag is positive meaning that
+ ** we're going to delete the nth field
+ ** with a matching field name, and this is
+ ** the nth matching field name.
+ **
+ ** o The delete flag is -1 meaning that we're
+ ** going to delete all fields with a
+ ** matching field name.
+ */
if (strncasecmp(field, comp, length) == 0 && field[length] == ':') {
if (delete == 0) {
}
/*
- * This line wasn't a match so copy it to the
- * temporary file.
- */
+ ** This line wasn't a match so copy it to the
+ ** temporary file.
+ */
if ((n = fputs(field, tmp)) == EOF || (c == '\n' && fputc('\n', tmp) == EOF))
adios(NULL, "unable to write temporary file.");
} while (*field != '\0' && *field != '-');
/*
- * Get rid of the field buffer because we're done with it.
- */
+ ** Get rid of the field buffer because we're done with it.
+ */
free((void *)field);
- }
- else {
+ } else {
/*
- * Find the end of the headers before adding the
- * annotations if we're appending instead of the default
- * prepending. A special check for no headers is needed
- * if appending.
- */
+ ** Find the end of the headers before adding the
+ ** annotations if we're appending instead of the default
+ ** prepending. A special check for no headers is needed
+ ** if appending.
+ */
if (append) {
/*
- * Copy lines from the input file to the temporary
- * file until we reach the end of the headers.
- */
+ ** Copy lines from the input file to the temporary
+ ** file until we reach the end of the headers.
+ */
if ((c = getc(fp)) == '\n')
rewind(fp);
fflush (tmp);
/*
- * We've been messing with the input file position. Move the
- * input file descriptor to the current place in the file
- * because the stock data copying routine uses the descriptor,
- * not the pointer.
- */
+ ** We've been messing with the input file position. Move the
+ ** input file descriptor to the current place in the file
+ ** because the stock data copying routine uses the descriptor,
+ ** not the pointer.
+ */
if (append || delete >= -1) {
if (lseek(fd, (off_t)ftell(fp), SEEK_SET) == (off_t)-1)
lseek (fd, (off_t) 0, SEEK_SET);
/*
- * We're making the file shorter if we're deleting a
- * header field so the file has to be truncated or it
- * will contain garbage.
- */
+ ** We're making the file shorter if we're deleting a
+ ** header field so the file has to be truncated or it
+ ** will contain garbage.
+ */
if (delete >= -1 && ftruncate(fd, 0) == -1)
adios(tmpfil, "unable to truncate.");
}
/*
- * Close the delete file so that we don't run out of file pointers if
- * we're doing piles of files. Note that this will make the close() in
- * lkclose() fail, but that failure is ignored so it's not a problem.
- */
+ ** Close the delete file so that we don't run out of file pointers if
+ ** we're doing piles of files. Note that this will make the close() in
+ ** lkclose() fail, but that failure is ignored so it's not a problem.
+ */
if (delete >= -1)
(void)fclose(fp);
/*
- * ap.c -- parse addresses 822-style
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** ap.c -- parse addresses 822-style
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/addrsbr.h>
static int dat[5];
/*
- * prototypes
- */
+** prototypes
+*/
int sc_width (void); /* from termsbr.c */
/*
- * static prototypes
- */
+** static prototypes
+*/
static int process (char *, int, int);
p->pq_text = getcpy (cp);
p->pq_error = getcpy (error);
status++;
- }
- else {
+ } else {
p->pq_text = getcpy (mp->m_text);
mnfree (mp);
}
/*
- * burst.c -- explode digests into individual messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** burst.c -- explode digests into individual messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
};
/*
- * static prototypes
- */
+** static prototypes
+*/
static int find_delim (int, struct smsg *);
static void burst (struct msgs **, int, struct smsg *, int, int, int, char *);
static void cpybrst (FILE *, FILE *, char *, char *, int);
context_replace (pfolder, folder); /* update current folder */
/*
- * If -inplace is given, then the first message burst becomes
- * the current message (which will now show a table of contents).
- * Otherwise, the first message extracted from the first digest
- * becomes the current message.
- */
+ ** If -inplace is given, then the first message burst becomes
+ ** the current message (which will now show a table of contents).
+ ** Otherwise, the first message extracted from the first digest
+ ** becomes the current message.
+ */
if (inplace) {
if (mp->lowsel != mp->curmsg)
seq_setcur (mp, mp->lowsel);
/*
- * Scan the message and find the beginning and
- * end of all the messages in the digest.
- */
+** Scan the message and find the beginning and
+** end of all the messages in the digest.
+*/
static int
find_delim (int msgnum, struct smsg *smsgs)
/*
- * Burst out the messages in the digest into the folder
- */
+** Burst out the messages in the digest into the folder
+*/
static void
burst (struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst,
mp = *mpp;
/*
- * See if we have enough space in the folder
- * structure for all the new messages.
- */
+ ** See if we have enough space in the folder
+ ** structure for all the new messages.
+ */
if ((mp->hghmsg + numburst > mp->hghoff) &&
!(mp = folder_realloc (mp, mp->lowoff, mp->hghmsg + numburst)))
adios (NULL, "unable to allocate folder storage");
mp->nummsg += numburst;
/*
- * If this is not the highest SELECTED message, then
- * increment mp->hghsel by numburst, since the highest
- * SELECTED is about to be slid down by that amount.
- */
+ ** If this is not the highest SELECTED message, then
+ ** increment mp->hghsel by numburst, since the highest
+ ** SELECTED is about to be slid down by that amount.
+ */
if (msgnum < mp->hghsel)
mp->hghsel += numburst;
/*
- * If -inplace is given, renumber the messages after the
- * source message, to make room for each of the messages
- * contained within the digest.
- *
- * This is equivalent to refiling a message from the point
- * of view of the external hooks.
- */
+ ** If -inplace is given, renumber the messages after the
+ ** source message, to make room for each of the messages
+ ** contained within the digest.
+ **
+ ** This is equivalent to refiling a message from the point
+ ** of view of the external hooks.
+ */
if (inplace) {
for (i = mp->hghmsg; j > msgnum; i--, j--) {
strncpy (f1, m_name (i), sizeof(f1));
unset_selected (mp, msgnum);
/* new hghmsg is hghmsg + numburst
- *
- * At this point, there is an array of numburst smsgs, each
- * element of which contains the starting and stopping offsets
- * (seeks) of the message in the digest. The inplace flag is set
- * if the original digest is replaced by a message containing
- * the table of contents. smsgs[0] is that table of contents.
- * Go through the message numbers in reverse order (high to low).
- *
- * Set f1 to the name of the destination message, f2 to the name
- * of a scratch file. Extract a message from the digest to the
- * scratch file. Move the original message to a backup file if
- * the destination message number is the same as the number of
- * the original message, which only happens if the inplace flag
- * is set. Then move the scratch file to the destination message.
- *
- * Moving the original message to the backup file is equivalent
- * to deleting the message from the point of view of the external
- * hooks. And bursting each message is equivalent to adding a
- * new message.
- */
+ **
+ ** At this point, there is an array of numburst smsgs, each
+ ** element of which contains the starting and stopping offsets
+ ** (seeks) of the message in the digest. The inplace flag is set
+ ** if the original digest is replaced by a message containing
+ ** the table of contents. smsgs[0] is that table of contents.
+ ** Go through the message numbers in reverse order (high to low).
+ **
+ ** Set f1 to the name of the destination message, f2 to the name
+ ** of a scratch file. Extract a message from the digest to the
+ ** scratch file. Move the original message to a backup file if
+ ** the destination message number is the same as the number of
+ ** the original message, which only happens if the inplace flag
+ ** is set. Then move the scratch file to the destination message.
+ **
+ ** Moving the original message to the backup file is equivalent
+ ** to deleting the message from the point of view of the external
+ ** hooks. And bursting each message is equivalent to adding a
+ ** new message.
+ */
i = inplace ? msgnum + numburst : mp->hghmsg;
for (j = numburst; j >= (inplace ? 0 : 1); i--, j--) {
#define S3 2
/*
- * Copy a mesage which is being burst out of a digest.
- * It will remove any "dashstuffing" in the message.
- */
+** Copy a mesage which is being burst out of a digest.
+** It will remove any "dashstuffing" in the message.
+*/
static void
cpybrst (FILE *in, FILE *out, char *ifile, char *ofile, int len)
/*
- * comp.c -- compose a message
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** comp.c -- compose a message
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
if (!use && (folder || msg)) {
/*
- * Take a message as the "form" for the new message.
- */
+ ** Take a message as the "form" for the new message.
+ */
if (!msg)
msg = "cur";
if (!folder)
strncpy (drft, m_draft(use ? (msg?msg:"cur") : "new"), sizeof(drft));
/*
- * Check if we have an existing draft
- */
+ ** Check if we have an existing draft
+ */
if ((out = open (drft, O_RDONLY)) != NOTOK) {
i = fdcompare (in, out);
close (out);
/*
- * If we have given -use flag, or if the
- * draft is just the same as the components
- * file, then no need to ask any questions.
- */
+ ** If we have given -use flag, or if the
+ ** draft is just the same as the components
+ ** file, then no need to ask any questions.
+ */
if (use || i)
goto edit_it;
break;
}
}
- } else {
- if (use)
- adios (drft, "unable to open");
+ } else if (use) {
+ adios (drft, "unable to open");
}
if ((out = creat (drft, m_gmprot ())) == NOTOK)
/*
- * conflict.c -- check for conflicts in mail system
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** conflict.c -- check for conflicts in mail system
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
#include <pwd.h>
/*
- * maximum number of directories that can
- * be specified using -search switch.
- */
+** maximum number of directories that can
+** be specified using -search switch.
+*/
#define NDIRS 100
/*
- * Add space for group names, 100 at a time
- */
+** Add space for group names, 100 at a time
+*/
#define NGRPS 100
static struct swit switches[] = {
extern struct home *homehead;
/*
- * prototypes
- */
+** prototypes
+*/
void alias_files (int, char **);
void pwd_names (void);
void grp_names (void);
if ((err = alias (akv[i])) != AK_OK) {
setup ();
fprintf (out, "aliasing error in %s - %s\n", akv[i], akerror (err));
- }
- else
- if (out && !mail)
- fprintf (out, "alias file %s is ok\n", akv[i]);
+ } else if (out && !mail)
+ fprintf (out, "alias file %s is ok\n", akv[i]);
}
while ((dp = readdir (dd)))
if (dp->d_name[0] != '.' && !check (dp->d_name)) {
setup ();
- fprintf (out,
- "there is a maildrop for the unknown user %s in %s\n",
+ fprintf (out, "there is a maildrop for the unknown user %s in %s\n",
dp->d_name, drop);
hit++;
}
#ifdef UCI
/*
- * UCI specific stuff for conflict
- */
+** UCI specific stuff for conflict
+*/
/* taken from <grpldr.h> */
}
struct grpldr *getglent () {
- register char *cp,
- **q;
+ register char *cp, **q;
if (glp == NULL && !setglent ())
return NULL;
if (gp < NGRPS) {
gldrs[gp++] = getcpy (gl->gl_name);
gldrs[gp] = NULL;
- }
- else {
+ } else {
setup ();
fprintf (out, "more than %d groups in group leaders file%s\n",
" (time to recompile)", NGRPS - 1);
/*
- * dist.c -- re-distribute a message
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** dist.c -- re-distribute a message
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
if (file) {
/*
- * Dist a file
- */
+ ** Dist a file
+ */
anot = 0; /* don't want to annotate a file */
} else {
/*
- * Dist a message
- */
+ ** Dist a message
+ */
if (!msg)
msg = "cur";
if (!folder)
/*
- * distsbr.c -- routines to do additional "dist-style" processing
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** distsbr.c -- routines to do additional "dist-style" processing
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
#define BADRFT "please re-edit %s and fix that header!"
/*
- * static prototypes
- */
+** static prototypes
+*/
static void ready_msg(char *);
int
/*
- * dp.c -- parse dates 822-style
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** dp.c -- parse dates 822-style
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/fmt_scan.h>
static int dat[5];
/*
- * prototypes
- */
+** prototypes
+*/
int sc_width (void); /* from termsbr.c */
/*
- * static prototypes
- */
+** static prototypes
+*/
static int process (char *, int);
/*
- * dropsbr.c -- create/read/manipulate mail drops
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** dropsbr.c -- create/read/manipulate mail drops
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/nmh.h>
#include <h/utils.h>
#include <fcntl.h>
/*
- * static prototypes
- */
+** static prototypes
+*/
static int mbx_chk_mbox (int);
static int mbx_chk_mmdf (int);
static int map_open (char *, int);
/*
- * Main entry point to open/create and lock
- * a file or maildrop.
- */
+** Main entry point to open/create and lock
+** a file or maildrop.
+*/
int
mbx_open (char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
errno = j;
/*
- * Return if we still failed after 4 attempts,
- * or we just want to skip the sanity checks.
- */
+ ** Return if we still failed after 4 attempts,
+ ** or we just want to skip the sanity checks.
+ */
if (fd == NOTOK || mbx_style == OTHER_FORMAT)
return fd;
/*
- * Do sanity checks on maildrop.
- */
+ ** Do sanity checks on maildrop.
+ */
if (fstat (fd, &st) == NOTOK) {
/*
- * The stat failed. So we make sure file
- * has right ownership/modes
- */
+ ** The stat failed. So we make sure file
+ ** has right ownership/modes
+ */
chown (file, uid, gid);
chmod (file, mode);
} else if (st.st_size > (off_t) 0) {
/*
- * Check/prepare MBOX style maildrop for appending.
- */
+** Check/prepare MBOX style maildrop for appending.
+*/
static int
mbx_chk_mbox (int fd)
/*
- * Check/prepare MMDF style maildrop for appending.
- */
+** Check/prepare MMDF style maildrop for appending.
+*/
static int
mbx_chk_mmdf (int fd)
/*
- * Append message to end of file or maildrop.
- */
+** Append message to end of file or maildrop.
+*/
int
mbx_copy (char *mailbox, int mbx_style, int md, int fd,
for (j = 0; fgets (buffer, sizeof(buffer), fp) != NULL; j++) {
/*
- * Check the first line, and make some changes.
- */
+ ** Check the first line, and make some changes.
+ */
if (j == 0 && !text) {
/*
- * Change the "Return-Path:" field (if in first line)
- * back to "From ".
- */
+ ** Change the "Return-Path:" field
+ ** (if in first line) back to "From ".
+ */
if (!strncmp (buffer, "Return-Path:", 12)) {
char tmpbuffer[BUFSIZ];
char *tp, *ep, *fp;
(int)(fp - ep), ep, tp);
} else if (!strncmp (buffer, "X-Envelope-From:", 16)) {
/*
- * Change the "X-Envelope-From:" field
- * (if first line) back to "From ".
- */
+ ** Change the "X-Envelope-From:"
+ ** field (if first line) back
+ ** to "From ".
+ */
char tmpbuffer[BUFSIZ];
char *ep;
snprintf (buffer, sizeof(buffer), "From %s", ep);
} else if (strncmp (buffer, "From ", 5)) {
/*
- * If there is already a "From " line,
- * then leave it alone. Else we add one.
- */
+ ** If there is already a "From "
+ ** line, then leave it alone.
+ ** Else we add one.
+ */
char tmpbuffer[BUFSIZ];
char *tp, *ep;
}
/*
- * If this is not first line, and begins with
- * "From ", then prepend line with ">".
- */
+ ** If this is not first line, and begins with
+ ** "From ", then prepend line with ">".
+ */
if (j != 0 && strncmp (buffer, "From ", 5) == 0) {
write (md, ">", 1);
size++;
lseek (fd, (off_t) 0, SEEK_END);
stop = lseek (md, (off_t) 0, SEEK_CUR);
if (mapping)
- map_write (mailbox, md, 0, (long) 0, start, stop, pos, size, noisy);
+ map_write (mailbox, md, 0, (long) 0, start,
+ stop, pos, size, noisy);
return OK;
}
/*
- * Close and unlock file/maildrop.
- */
+** Close and unlock file/maildrop.
+*/
int
mbx_close (char *mailbox, int md)
/*
- * This function is performed implicitly by getbbent.c:
- * bb->bb_map = map_name (bb->bb_file);
- */
+** This function is performed implicitly by getbbent.c:
+** bb->bb_map = map_name (bb->bb_file);
+*/
char *
map_name (char *file)
/*
- * flist.c -- list nmh folders containing messages
- * -- in a given sequence
- *
- * originally by
- * David Nichols, Xerox-PARC, November, 1992
- *
- * Copyright (c) 1994 Xerox Corporation.
- * Use and copying of this software and preparation of derivative works based
- * upon this software are permitted. Any distribution of this software or
- * derivative works must comply with all applicable United States export
- * control laws. This software is made available AS IS, and Xerox Corporation
- * makes no warranty about the software, its performance or its conformity to
- * any specification.
- */
+** flist.c -- list nmh folders containing messages
+** -- in a given sequence
+**
+** originally by
+** David Nichols, Xerox-PARC, November, 1992
+**
+** Copyright (c) 1994 Xerox Corporation.
+** Use and copying of this software and preparation of derivative works based
+** upon this software are permitted. Any distribution of this software or
+** derivative works must comply with all applicable United States export
+** control laws. This software is made available AS IS, and Xerox Corporation
+** makes no warranty about the software, its performance or its conformity to
+** any specification.
+*/
#include <h/mh.h>
#include <h/utils.h>
#define TRUE 1
/*
- * We allocate space to record the names of folders
- * (foldersToDo array), this number of elements at a time.
- */
+** We allocate space to record the names of folders
+** (foldersToDo array), this number of elements at a time.
+*/
#define MAXFOLDERS 100
static char *nmhdir; /* base nmh mail directory */
/*
- * Type for a compare function for qsort. This keeps
- * the compiler happy.
- */
+** Type for a compare function for qsort. This keeps
+** the compiler happy.
+*/
typedef int (*qsort_comp) (const void *, const void *);
/*
- * prototypes
- */
+** prototypes
+*/
int CompareFolders(struct Folder *, struct Folder *);
void GetFolderOrder(void);
void ScanFolders(void);
context_read();
/*
- * If program was invoked with name ending
- * in `s', then add switch `-all'.
- */
+ ** If program was invoked with name ending
+ ** in `s', then add switch `-all'.
+ */
if (argv[0][strlen (argv[0]) - 1] == 's')
all = TRUE;
}
} else {
/*
- * Check if we need to allocate more space
- * for folder names.
- */
+ ** Check if we need to allocate more space
+ ** for folder names.
+ */
if (numfolders >= maxfolders) {
maxfolders += MAXFOLDERS;
foldersToDo = (char **) mh_xrealloc (foldersToDo,
nmhdir = m_maildir ("");
/*
- * If we didn't specify any sequences, we search
- * for the "Unseen-Sequence" profile entry and use
- * all the sequences defined there. We check to
- * make sure that the Unseen-Sequence entry doesn't
- * contain more than NUMATTRS sequences.
- */
+ ** If we didn't specify any sequences, we search
+ ** for the "Unseen-Sequence" profile entry and use
+ ** all the sequences defined there. We check to
+ ** make sure that the Unseen-Sequence entry doesn't
+ ** contain more than NUMATTRS sequences.
+ */
if (numsequences == 0) {
if ((cp = context_find(usequence)) && *cp) {
char **ap, *dp;
}
/*
- * Read the Flist-Order profile entry to determine
- * how to sort folders for output.
- */
+** Read the Flist-Order profile entry to determine
+** how to sort folders for output.
+*/
void
GetFolderOrder(void)
}
/*
- * Scan all the necessary folders
- */
+** Scan all the necessary folders
+*/
void
ScanFolders(void)
context_save (); /* save the context file */
/*
- * Scan each given folder. If -all is given,
- * then also scan the 1st level subfolders under
- * each given folder.
- */
+ ** Scan each given folder. If -all is given,
+ ** then also scan the 1st level subfolders under
+ ** each given folder.
+ */
for (i = 0; i < numfolders; ++i)
BuildFolderList(foldersToDo[i], all ? 1 : 0);
} else {
if (all) {
/*
- * Do the readonly folders
- */
+ ** Do the readonly folders
+ */
do_readonly_folders();
/*
- * Now scan the entire nmh directory for folders
- */
+ ** Now scan the entire nmh directory for folders
+ */
BuildFolderList(".", 0);
} else {
/*
- * Else scan current folder
- */
+ ** Else scan current folder
+ */
BuildFolderList(curfolder, 0);
}
}
}
/*
- * Initial building of folder list for
- * the top of our search tree.
- */
+** Initial building of folder list for
+** the top of our search tree.
+*/
void
BuildFolderList(char *dirName, int searchdepth)
return;
/*
- * If base directory, don't add it to the
- * folder list. We just recurse into it.
- */
+ ** If base directory, don't add it to the
+ ** folder list. We just recurse into it.
+ */
if (!strcmp (dirName, ".")) {
BuildFolderListRecurse (".", &st, 0);
return;
}
/*
- * Add this folder to the list.
- * If recursing and directory has subfolders,
- * then build folder list for subfolders.
- */
+ ** Add this folder to the list.
+ ** If recursing and directory has subfolders,
+ ** then build folder list for subfolders.
+ */
if (AddFolder(dirName, showzero) && (recurse || searchdepth) && st.st_nlink > 2)
BuildFolderListRecurse(dirName, &st, searchdepth - 1);
}
/*
- * Recursive building of folder list
- */
+** Recursive building of folder list
+*/
void
BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth)
struct stat st;
/*
- * Keep track of number of directories we've seen so we can
- * stop stat'ing entries in this directory once we've seen
- * them all. This optimization will fail if you have extra
- * directories beginning with ".", since we don't bother to
- * stat them. But that shouldn't generally be a problem.
- */
+ ** Keep track of number of directories we've seen so we can
+ ** stop stat'ing entries in this directory once we've seen
+ ** them all. This optimization will fail if you have extra
+ ** directories beginning with ".", since we don't bother to
+ ** stat them. But that shouldn't generally be a problem.
+ */
nlinks = s->st_nlink;
if (!(dir = opendir(dirName)))
adios(dirName, "can't open directory");
/*
- * A hack so that we don't see a
- * leading "./" in folder names.
- */
+ ** A hack so that we don't see a
+ ** leading "./" in folder names.
+ */
base = strcmp (dirName, ".") ? dirName : dirName + 1;
while (nlinks && (dp = readdir(dir))) {
if (dp->d_name[0] == '.')
continue;
/* Check to see if the name of the file is a number
- * if it is, we assume it's a mail file and skip it
- */
+ ** if it is, we assume it's a mail file and skip it
+ */
for (n = dp->d_name; *n && isdigit(*n); n++);
if (!*n)
continue;
strncat(name, dp->d_name, sizeof(name) - strlen(name) - 1);
if ((stat(name, &st) != -1) && S_ISDIR(st.st_mode)) {
/*
- * Check if this was really a symbolic link pointing
- * to a directory. If not, then decrement link count.
- */
+ ** Check if this was really a symbolic link pointing
+ ** to a directory. If not, then decrement link count.
+ */
if (lstat (name, &st) == -1)
nlinks--;
/* Add this folder to the list */
if (AddFolder(name, showzero) &&
- (recurse || searchdepth) && st.st_nlink > 2)
+ (recurse || searchdepth) &&
+ st.st_nlink > 2)
BuildFolderListRecurse(name, &st, searchdepth - 1);
}
}
}
/*
- * Add this folder to our list, counting the total number of
- * messages and the number of messages in each sequence.
- */
+** Add this folder to our list, counting the total number of
+** messages and the number of messages in each sequence.
+*/
int
AddFolder(char *name, int force)
}
/*
- * Print the folder/sequence information
- */
+** Print the folder/sequence information
+*/
void
PrintFolders(void)
}
/*
- * Find the width we need for various fields
- */
+ ** Find the width we need for various fields
+ */
for (i = 0; i < nFolders; ++i) {
/* find the length of longest folder name */
len = strlen(folders[i].name);
}
/*
- * Put them in priority order.
- */
+** Put them in priority order.
+*/
int
CompareFolders(struct Folder *f1, struct Folder *f2)
}
/*
- * Make sure we have at least n folders allocated.
- */
+** Make sure we have at least n folders allocated.
+*/
void
AllocFolders(struct Folder **f, int *nfa, int n)
}
/*
- * Return the priority for a name. The highest comes from an exact match.
- * After that, the longest match (then first) assigns the priority.
- */
+** Return the priority for a name. The highest comes from an exact match.
+** After that, the longest match (then first) assigns the priority.
+*/
int
AssignPriority(char *name)
{
}
/*
- * Do the read only folders
- */
+** Do the read only folders
+*/
static void
do_readonly_folders (void)
/*
- * fmtdump.c -- compile format file and dump out instructions
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** fmtdump.c -- compile format file and dump out instructions
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/fmt_scan.h>
static int lused = 0;
/*
- * static prototypes
- */
+** static prototypes
+*/
static void fmt_dump (struct format *);
static void dumpone(struct format *);
static int findlabel(struct format *);
}
/*
- * Get new format string. Must be before chdir().
- */
+ ** Get new format string. Must be before chdir().
+ */
nfs = new_fs (form, format, FORMAT);
ncomps = fmt_compile(nfs, &fmt);
/*
- * folder(s).c -- set/list the current message and/or folder
- * -- push/pop a folder onto/from the folder stack
- * -- list the folder stack
- *
- * This code is Copyright (c) 2002, 2008, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** folder(s).c -- set/list the current message and/or folder
+** -- push/pop a folder onto/from the folder stack
+** -- list the folder stack
+**
+** This code is Copyright (c) 2002, 2008, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/crawl_folders.h>
static char folder[BUFSIZ];
/*
- * Structure to hold information about
- * folders as we scan them.
- */
+** Structure to hold information about
+** folders as we scan them.
+*/
struct FolderInfo {
char *name;
int nummsg;
};
/*
- * Dynamically allocated space to hold
- * all the folder information.
- */
+** Dynamically allocated space to hold
+** all the folder information.
+*/
static struct FolderInfo *fi;
static int maxFolderInfo;
/*
- * static prototypes
- */
+** static prototypes
+*/
static int get_folder_info (char *, char *);
static crawl_callback_t get_folder_info_callback;
static void print_folders (void);
context_read();
/*
- * If program was invoked with name ending
- * in `s', then add switch `-all'.
- */
+ ** If program was invoked with name ending
+ ** in `s', then add switch `-all'.
+ */
if (argv[0][strlen (argv[0]) - 1] == 's')
all = 1;
nmhdir = concat (m_maildir (""), "/", NULL);
/*
- * If we aren't working with the folder stack
- * (-push, -pop, -list) then the default is to print.
- */
+ ** If we aren't working with the folder stack
+ ** (-push, -pop, -list) then the default is to print.
+ */
if (pushsw == 0 && popsw == 0 && listsw == 0)
printsw++;
cp = add (*ap, add (" ", cp));
context_replace (stack, cp); /* update folder stack */
} else {
- context_del (stack); /* delete folder stack entry from context */
+ /* delete folder stack entry from context */
+ context_del (stack);
}
free (dp);
}
cp = m_maildir(argfolder);
if (access (cp, F_OK) == NOTOK)
adios (cp, "unable to find folder");
- context_replace (pfolder, argfolder); /* update current folder */
+ /* update current folder */
+ context_replace (pfolder, argfolder);
context_save (); /* save the context file */
argfolder = NULL;
}
fi = mh_xmalloc (maxFolderInfo * sizeof(*fi));
/*
- * Scan the folders
- */
+ ** Scan the folders
+ */
if (all || ftotal > 0) {
/*
- * If no folder is given, do them all
- */
- /* change directory to base of nmh directory for crawl_folders */
+ ** If no folder is given, do them all
+ */
+ /*
+ ** change directory to base of nmh directory for
+ ** crawl_folders
+ */
if (chdir (nmhdir) == NOTOK)
adios (nmhdir, "unable to change directory to");
if (!argfolder) {
} else {
strncpy (folder, argfolder, sizeof(folder));
if (get_folder_info (argfolder, msg)) {
- context_replace (pfolder, argfolder);/* update current folder */
- context_save (); /* save the context file */
+ /* update current folder */
+ context_replace (pfolder, argfolder);
+ context_save ();
}
/*
- * Since recurse wasn't done in get_folder_info(),
- * we still need to list all level-1 sub-folders.
- */
+ ** Since recurse wasn't done in get_folder_info(),
+ ** we still need to list all level-1 sub-folders.
+ */
if (!frecurse)
crawl_folders (folder, get_folder_info_callback, NULL);
}
strncpy (folder, argfolder ? argfolder : getfolder (1), sizeof(folder));
/*
- * Check if folder exists. If not, then see if
- * we should create it, or just exit.
- */
+ ** Check if folder exists. If not, then see if
+ ** we should create it, or just exit.
+ */
create_folder (m_maildir (folder), fcreat, done);
if (get_folder_info (folder, msg) && argfolder) {
}
/*
- * Print out folder information
- */
+ ** Print out folder information
+ */
print_folders();
- context_save (); /* save the context file */
+ context_save ();
done (0);
return 1;
}
i = total_folders++;
/*
- * if necessary, reallocate the space
- * for folder information
- */
+ ** if necessary, reallocate the space
+ ** for folder information
+ */
if (total_folders >= maxFolderInfo) {
maxFolderInfo += CRAWL_NUMFOLDERS;
fi = mh_xrealloc (fi, maxFolderInfo * sizeof(*fi));
if ((ftotal > 0) || !fshort || msg || fpack) {
/*
- * create message structure and get folder info
- */
+ ** create message structure and get folder info
+ */
if (!(mp = folder_read (fold))) {
admonish (NULL, "unable to read folder %s", fold);
return 0;
if (crawl_children) {
crawl_folders (fold, get_folder_info_callback, NULL);
}
-
- return retval;
+return retval;
}
/*
- * Print folder information
- */
+** Print folder information
+*/
static void
print_folders (void)
char tmpname[BUFSIZ];
/*
- * compute a few values needed to for
- * printing various fields
- */
+ ** compute a few values needed to for
+ ** printing various fields
+ */
for (i = 0; i < total_folders; i++) {
/* length of folder name */
len = strlen (fi[i].name);
nummsgdigits = 2;
/*
- * Print the header
- */
+ ** Print the header
+ */
if (fheader > 0 || (all && !fshort && fheader >= 0))
printf ("%-*s %*s %-*s; %-*s %*s\n",
maxlen+1, "FOLDER",
9, "(OTHERS)");
/*
- * Print folder information
- */
+ ** Print folder information
+ */
if (all || fshort || ftotal < 1) {
for (i = 0; i < total_folders; i++) {
if (fshort) {
}
/*
- * Print folder/message totals
- */
+ ** Print folder/message totals
+ */
if (ftotal > 0 || (all && !fshort && ftotal >= 0)) {
if (all)
printf ("\n");
}
/*
- * Set the current message and sychronize sequences
- */
+** Set the current message and sychronize sequences
+*/
static int
sfold (struct msgs *mp, char *msg)
/*
- * Do the read only folders
- */
+** Do the read only folders
+*/
static void
readonly_folders (void)
/*
- * forw.c -- forward a message, or group of messages.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** forw.c -- forward a message, or group of messages.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
/*
- * static prototypes
- */
+** static prototypes
+*/
static void mhl_draft (int, char *, int, int, char *, char *, int);
static void copy_draft (int, char *, char *, int, int, int);
static void copy_mime_draft (int);
if (file) {
/*
- * Forwarding a file.
- */
+ ** Forwarding a file.
+ */
anot = 0; /* don't want to annotate a file */
} else {
/*
- * Forwarding a message.
- */
+ ** Forwarding a message.
+ */
if (!msgp)
msgs[msgp++] = "cur";
if (!folder)
adios (filter, "unable to read");
/*
- * Open form (component) file.
- */
+ ** Open form (component) file.
+ */
if (digest) {
if (issue == 0) {
snprintf (buf, sizeof(buf), IFORMAT, digest);
adios (drft, "unable to create");
/*
- * copy the components into the draft
- */
+ ** copy the components into the draft
+ */
cpydata (in, out, form, drft);
close (in);
close (out);
} else {
/*
- * If filter file is defined, then format the
- * messages into the draft using mhlproc.
- */
+ ** If filter file is defined, then format the
+ ** messages into the draft using mhlproc.
+ */
if (filter)
mhl_draft (out, digest, volume, issue, drft, filter, dashstuff);
else if (mime)
/*
- * Filter the messages you are forwarding, into the
- * draft calling the mhlproc, and reading its output
- * from a pipe.
- */
+** Filter the messages you are forwarding, into the
+** draft calling the mhlproc, and reading its output
+** from a pipe.
+*/
static void
mhl_draft (int out, char *digest, int volume, int issue,
}
/*
- * Are we dashstuffing (quoting) the lines that begin
- * with `-'. We use the mhl default (don't add any flag)
- * unless the user has specified a specific flag.
- */
+ ** Are we dashstuffing (quoting) the lines that begin
+ ** with `-'. We use the mhl default (don't add any
+ ** flag) unless the user has specified a specific flag.
+ */
if (dashstuff > 0)
vec[i++] = "-dashstuffing";
else if (dashstuff < 0)
MAXARGS - i, vec[0]);
/*
- * Now add the message names to filter. We can only
- * handle about 995 messages (because vec is fixed size),
- * but that should be plenty.
- */
- for (msgnum = mp->lowsel; msgnum <= mp->hghsel && i < sizeof(vec) - 1;
- msgnum++)
+ ** Now add the message names to filter. We can only
+ ** handle about 995 messages (because vec is fixed
+ ** size), but that should be plenty.
+ */
+ for (msgnum = mp->lowsel;
+ msgnum <= mp->hghsel && i < sizeof(vec) - 1;
+ msgnum++)
if (is_selected (mp, msgnum))
vec[i++] = getcpy (m_name (msgnum));
vec[i] = NULL;
/*
- * Copy the messages into the draft. The messages are
- * not filtered through the mhlproc. Do dashstuffing if
- * necessary.
- */
+** Copy the messages into the draft. The messages are
+** not filtered through the mhlproc. Do dashstuffing if
+** necessary.
+*/
static void
-copy_draft (int out, char *digest, char *file, int volume, int issue, int dashstuff)
+copy_draft (int out, char *digest, char *file, int volume, int issue,
+ int dashstuff)
{
int fd,i, msgcnt, msgnum;
int len, buflen;
}
/*
- * Copy the message. Add RFC934 quoting (dashstuffing)
- * unless given the -nodashstuffing flag.
- */
+ ** Copy the message. Add RFC934 quoting (dashstuffing)
+ ** unless given the -nodashstuffing flag.
+ */
if (dashstuff >= 0)
cpydgst (fd, out, msgnam, file);
else
/*
- * Create a mhbuild composition file for forwarding message.
- */
+** Create a mhbuild composition file for forwarding message.
+*/
static void
copy_mime_draft (int out)
/*
- * ftpsbr.c -- simple FTP client library
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** ftpsbr.c -- simple FTP client library
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/mime.h>
connect ((fd), (struct sockaddr *) (sock), len)
/*
- * prototypes
- */
+** prototypes
+*/
int ftp_get (char *, char *, char *, char *, char *, char *, int, int);
-int ftp_trans (char *, char *, char *, char *, char *, char *, char *, int, int);
+int ftp_trans (char *, char *, char *, char *, char *, char *, char *,
+ int, int);
/*
- * static prototypes
- */
+** static prototypes
+*/
static int start_tcp_server (struct sockaddr_in *, int, int, int);
static void _asnprintf (char *, int, char *, va_list);
static int ftp_quit (void);
/*
- * inc.c -- incorporate messages from a maildrop into a folder
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** inc.c -- incorporate messages from a maildrop into a folder
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#ifdef MAILGROUP
-/* Revised: Sat Apr 14 17:08:17 PDT 1990 (marvit@hplabs)
- * Added hpux hacks to set and reset gid to be "mail" as needed. The reset
- * is necessary so inc'ed mail is the group of the inc'er, rather than
- * "mail". We setgid to egid only when [un]locking the mail file. This
- * is also a major security precaution which will not be explained here.
- *
- * Fri Feb 7 16:04:57 PST 1992 John Romine <bug-mh@ics.uci.edu>
- * NB: I'm not 100% sure that this setgid stuff is secure even now.
- *
- * See the *GROUPPRIVS() macros later. I'm reasonably happy with the setgid
- * attribute. Running setuid root is probably not a terribly good idea, though.
- * -- Peter Maydell <pmaydell@chiark.greenend.org.uk>, 04/1998
- *
- * Peter Maydell's patch slightly modified for nmh 0.28-pre2.
- * Ruud de Rooij <ruud@debian.org> Wed, 22 Jul 1998 13:24:22 +0200
- */
+/*
+** Revised: Sat Apr 14 17:08:17 PDT 1990 (marvit@hplabs)
+** Added hpux hacks to set and reset gid to be "mail" as needed. The reset
+** is necessary so inc'ed mail is the group of the inc'er, rather than
+** "mail". We setgid to egid only when [un]locking the mail file. This
+** is also a major security precaution which will not be explained here.
+**
+** Fri Feb 7 16:04:57 PST 1992 John Romine <bug-mh@ics.uci.edu>
+** NB: I'm not 100% sure that this setgid stuff is secure even now.
+**
+** See the *GROUPPRIVS() macros later. I'm reasonably happy with the setgid
+** attribute. Running setuid root is probably not a terribly good idea, though.
+** -- Peter Maydell <pmaydell@chiark.greenend.org.uk>, 04/1998
+**
+** Peter Maydell's patch slightly modified for nmh 0.28-pre2.
+** Ruud de Rooij <ruud@debian.org> Wed, 22 Jul 1998 13:24:22 +0200
+*/
#endif
#include <h/mh.h>
{ "help", 0 },
};
-/* This is an attempt to simplify things by putting all the
- * privilege ops into macros.
- * *GROUPPRIVS() is related to handling the setgid MAIL property,
- * and only applies if MAILGROUP is defined.
- * Basically, SAVEGROUPPRIVS() is called right at the top of main()
- * to initialise things, and then DROPGROUPPRIVS() and GETGROUPPRIVS()
- * do the obvious thing. TRYDROPGROUPPRIVS() has to be safe to call
- * before DROPUSERPRIVS() is called [this is needed because setgid()
- * sets both effective and real uids if euid is root.]
- *
- * There's probably a better implementation if we're allowed to use
- * BSD-style setreuid() rather than using POSIX saved-ids.
- * Anyway, if you're euid root it's a bit pointless to drop the group
- * permissions...
- *
- * I'm pretty happy that the security is good provided we aren't setuid root.
- * The only things we trust with group=mail privilege are lkfopen()
- * and lkfclose().
- */
+/*
+** This is an attempt to simplify things by putting all the
+** privilege ops into macros.
+** *GROUPPRIVS() is related to handling the setgid MAIL property,
+** and only applies if MAILGROUP is defined.
+** Basically, SAVEGROUPPRIVS() is called right at the top of main()
+** to initialise things, and then DROPGROUPPRIVS() and GETGROUPPRIVS()
+** do the obvious thing. TRYDROPGROUPPRIVS() has to be safe to call
+** before DROPUSERPRIVS() is called [this is needed because setgid()
+** sets both effective and real uids if euid is root.]
+**
+** There's probably a better implementation if we're allowed to use
+** BSD-style setreuid() rather than using POSIX saved-ids.
+** Anyway, if you're euid root it's a bit pointless to drop the group
+** permissions...
+**
+** I'm pretty happy that the security is good provided we aren't setuid root.
+** The only things we trust with group=mail privilege are lkfopen()
+** and lkfclose().
+*/
/*
- * For setting and returning to "mail" gid
- */
+** For setting and returning to "mail" gid
+*/
#ifdef MAILGROUP
static int return_gid;
-/* easy case; we're not setuid root, so can drop group privs
- * immediately.
- */
+/*
+** easy case; we're not setuid root, so can drop group privs immediately.
+*/
#define TRYDROPGROUPPRIVS() DROPGROUPPRIVS()
#define DROPGROUPPRIVS() setgid(getgid())
#define GETGROUPPRIVS() setgid(return_gid)
#define SAVEGROUPPRIVS()
#endif /* not MAILGROUP */
-/* these variables have to be globals so that done() can correctly clean up the lockfile */
+/*
+** these variables have to be globals so that done() can correctly clean
+** up the lockfile
+*/
static int locked = 0;
static char *newmail;
static FILE *in;
/*
- * prototypes
- */
+** prototypes
+*/
char *map_name(char *);
static void inc_done(int) NORETURN;
int chgflag = 1, trnflag = 1;
int noisy = 1, width = 0;
int hghnum = 0, msgnum = 0;
- int incerr = 0; /* <0 if inc hits an error which means it should not truncate mailspool */
+ int incerr = 0; /*
+ ** <0 if inc hits an error which means it should
+ ** not truncate mailspool
+ */
char *cp, *maildir = NULL, *folder = NULL;
char *format = NULL, *form = NULL;
char *audfile = NULL, *from = NULL;
done=inc_done;
-/* absolutely the first thing we do is save our privileges,
- * and drop them if we can.
- */
+/*
+** absolutely the first thing we do is save our privileges,
+** and drop them if we can.
+*/
SAVEGROUPPRIVS();
TRYDROPGROUPPRIVS();
continue;
/*
- * The flag `trnflag' has the value:
- *
- * 2 if -truncate is given
- * 1 by default (truncating is default)
- * 0 if -notruncate is given
- */
+ ** The flag `trnflag' has the value:
+ **
+ ** 2 if -truncate is given
+ ** 1 by default (truncating is default)
+ ** 0 if -notruncate is given
+ */
case TRNCSW:
trnflag = 2;
continue;
from = path (cp, TFILE);
/*
- * If the truncate file is in default state,
- * change to not truncate.
- */
+ ** If the truncate file is in default state,
+ ** change to not truncate.
+ */
if (trnflag == 1)
trnflag = 0;
continue;
}
}
- /* NOTE: above this point you should use TRYDROPGROUPPRIVS(),
- * not DROPGROUPPRIVS().
- */
+ /*
+ ** NOTE: above this point you should use TRYDROPGROUPPRIVS(),
+ ** not DROPGROUPPRIVS().
+ */
/* guarantee dropping group priveleges; we might not have done so earlier */
DROPGROUPPRIVS();
/*
- * We will get the mail from a file
- * (typically the standard maildrop)
- */
+ ** We will get the mail from a file
+ ** (typically the standard maildrop)
+ */
if (from)
newmail = from;
else if ((newmail = getenv ("MAILDROP")) && *newmail)
adios (maildir, "error allocating memory to copy maildir");
if (!folder_exists(maildir)) {
- /* If the folder doesn't exist, and we're given the -silent flag,
- * just fail.
- */
+ /*
+ ** If the folder doesn't exist, and we're given the -silent
+ ** flag, just fail.
+ */
if (noisy)
create_folder(maildir, 0, done);
else
}
/*
- * Get the mail from file (usually mail spool)
- */
+ ** Get the mail from file (usually mail spool)
+ */
m_unknown (in); /* the MAGIC invocation... */
hghnum = msgnum = mp->hghmsg;
for (;;) {
/*
- * Check if we need to allocate more space for message status.
- * If so, then add space for an additional 100 messages.
- */
+ ** Check if we need to allocate more space for message status.
+ ** If so, then add space for an additional 100 messages.
+ */
if (msgnum >= mp->hghoff
&& !(mp = folder_realloc (mp, mp->lowoff, mp->hghoff + 100))) {
advise (NULL, "unable to allocate folder storage");
case SCNMSG:
case SCNENC:
/*
- * Run the external program hook on the message.
- */
+ ** Run the external program hook on the message.
+ */
(void)snprintf(b, sizeof (b), "%s/%d", maildir_copy, msgnum + 1);
(void)ext_hook("add-hook", b, (char *)0);
mp->msgflags |= SEQMOD;
continue;
}
- /* If we get here there was some sort of error from scan(),
- * so stop processing anything more from the spool.
- */
+ /*
+ ** If we get here there was some sort of error from scan(),
+ ** so stop processing anything more from the spool.
+ */
break;
}
if (locked) {
GETGROUPPRIVS(); /* Be sure we can unlock mail file */
(void) lkfclose (in, newmail); in = NULL;
- DROPGROUPPRIVS(); /* And then return us to normal privileges */
+ DROPGROUPPRIVS(); /*
+ ** And then return us to normal
+ ** privileges
+ */
} else {
fclose (in); in = NULL;
}
fflush (stdout);
/*
- * truncate file we are incorporating from
- */
+ ** truncate file we are incorporating from
+ */
if (trnflag) {
if (stat (newmail, &st) != NOTOK && s1.st_mtime != st.st_mtime)
advise (NULL, "new messages have arrived!\007");
admonish (newmail, "error zero'ing");
unlink(map_name(newmail));
}
- } else {
- if (noisy)
- printf ("%s not zero'd\n", newmail);
+ } else if (noisy) {
+ printf ("%s not zero'd\n", newmail);
}
if (msgnum == hghnum) {
}
/*
- * unlock the mail spool
- */
+ ** unlock the mail spool
+ */
if (locked) {
GETGROUPPRIVS(); /* Be sure we can unlock mail file */
(void) lkfclose (in, newmail); in = NULL;
/*
- * install-mh.c -- initialize the nmh environment of a new user
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** install-mh.c -- initialize the nmh environment of a new user
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h> /* mh internals */
#include <h/utils.h>
};
/*
- * static prototypes
- */
+** static prototypes
+*/
static char *geta(void);
}
/*
- * Find user's home directory. Try the HOME environment
- * variable first, the home directory field in the password file
- * if that's not found.
- */
+ ** Find user's home directory. Try the HOME environment
+ ** variable first, the home directory field in the password file
+ ** if that's not found.
+ */
if ((mypath = getenv("HOME")) == (char *)0) {
if ((pw = getpwuid(getuid())) == (struct passwd *)0 || *pw->pw_dir == '\0')
}
/*
- * Find the user's profile. Check for the existence of an
- * MH environment variable first with non-empty contents.
- * Convert any relative path name found there to an absolute one.
- * Look for the profile in the user's home directory if the MH
- * environment variable isn't set.
- */
+ ** Find the user's profile. Check for the existence of an
+ ** MH environment variable first with non-empty contents.
+ ** Convert any relative path name found there to an absolute one.
+ ** Look for the profile in the user's home directory if the MH
+ ** environment variable isn't set.
+ */
if ((cp = getenv("MH")) && *cp != '\0')
defpath = path(cp, TFILE);
defpath = concat(mypath, "/", mh_profile, NULL);
/*
- * Check for the existence of the profile file. It's an
- * error if it exists and this isn't an installation check.
- * An installation check fails if it does not exist, succeeds
- * if it does.
- */
+ ** Check for the existence of the profile file. It's an
+ ** error if it exists and this isn't an installation check.
+ ** An installation check fails if it does not exist, succeeds
+ ** if it does.
+ */
if (stat (defpath, &st) != NOTOK) {
if (check)
}
/*
- * Add some initial elements to the profile/context list
- */
+ ** Add some initial elements to the profile/context list
+ */
m_defs = (struct node *) mh_xmalloc (sizeof *np);
np = m_defs;
np->n_name = getcpy ("Path");
np->n_next = NULL;
/*
- * If there is a default profile file in the
- * nmh `etc' directory, then read it also.
- */
+ ** If there is a default profile file in the
+ ** nmh `etc' directory, then read it also.
+ */
if ((in = fopen (mh_defaults, "r"))) {
readconfig (&np->n_next, in, mh_defaults, 0);
fclose (in);
context_save ();
/*
- * Now write out the initial .mh_profile
- */
+ ** Now write out the initial .mh_profile
+ */
if ((out = fopen (defpath, "w")) == NULL)
adios (defpath, "unable to write");
for (np = m_defs; np; np = np->n_next) {
/*
- * mark.c -- add message(s) to sequences in given folder
- * -- delete messages (s) from sequences in given folder
- * -- list sequences in given folder
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mark.c -- add message(s) to sequences in given folder
+** -- delete messages (s) from sequences in given folder
+** -- list sequences in given folder
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
};
/*
- * static prototypes
- */
+** static prototypes
+*/
static void print_debug (struct msgs *);
static void seq_printdebug (struct msgs *);
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
}
/*
- * If we haven't specified -add, -delete, or -list,
- * then use -add if a sequence was specified, else
- * use -list.
- */
+ ** If we haven't specified -add, -delete, or -list,
+ ** then use -add if a sequence was specified, else
+ ** use -list.
+ */
if (!addsw && !deletesw && !listsw) {
if (seqp)
addsw++;
adios (NULL, "folder %s is read-only, so -public not allowed", folder);
/*
- * Make sure at least one sequence has been
- * specified if we are adding or deleting.
- */
+ ** Make sure at least one sequence has been
+ ** specified if we are adding or deleting.
+ */
if (seqp == 0 && (addsw || deletesw))
adios (NULL, "-%s requires at least one -sequence argument",
addsw ? "add" : "delete");
/*
- * Print general debugging info
- */
+** Print general debugging info
+*/
static void
print_debug (struct msgs *mp)
{
/*
- * Print debugging info about all the SELECTED
- * messages and the sequences they are in.
- */
+** Print debugging info about all the SELECTED
+** messages and the sequences they are in.
+*/
static void
seq_printdebug (struct msgs *mp)
{
/*
- * md5.c -- md5 message digest algorithm
- * taken from RFC-1321/Appendix A.3
- */
+** md5.c -- md5 message digest algorithm
+** taken from RFC-1321/Appendix A.3
+*/
/*
- * MD5C.C -- RSA Data Security, Inc., MD5 message-digest algorithm
- */
+** MD5C.C -- RSA Data Security, Inc., MD5 message-digest algorithm
+*/
/*
- * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
- * rights reserved.
- *
- * License to copy and use this software is granted provided that it
- * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- * Algorithm" in all material mentioning or referencing this software
- * or this function.
- *
- * License is also granted to make and use derivative works provided
- * that such works are identified as "derived from the RSA Data
- * Security, Inc. MD5 Message-Digest Algorithm" in all material
- * mentioning or referencing the derived work.
- *
- * RSA Data Security, Inc. makes no representations concerning either
- * the merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software.
- */
+** Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+** rights reserved.
+**
+** License to copy and use this software is granted provided that it
+** is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+** Algorithm" in all material mentioning or referencing this software
+** or this function.
+**
+** License is also granted to make and use derivative works provided
+** that such works are identified as "derived from the RSA Data
+** Security, Inc. MD5 Message-Digest Algorithm" in all material
+** mentioning or referencing the derived work.
+**
+** RSA Data Security, Inc. makes no representations concerning either
+** the merchantability of this software or the suitability of this
+** software for any particular purpose. It is provided "as is"
+** without express or implied warranty of any kind.
+**
+** These notices must be retained in any copies of any part of this
+** documentation and/or software.
+*/
#include <h/md5.h>
/*
- * Constants for MD5Transform routine.
- */
+** Constants for MD5Transform routine.
+*/
#define S11 7
#define S12 12
#define S13 17
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-/* F, G, H and I are basic MD5 functions.
- */
+/*
+** F, G, H and I are basic MD5 functions.
+*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
-/* ROTATE_LEFT rotates x left n bits.
- */
+/*
+** ROTATE_LEFT rotates x left n bits.
+*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
- * Rotation is separate from addition to prevent recomputation.
- */
+** Rotation is separate from addition to prevent recomputation.
+*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
-/* MD5 initialization. Begins an MD5 operation, writing a new context.
- */
+/*
+** MD5 initialization. Begins an MD5 operation, writing a new context.
+*/
void MD5Init (context)
MD5_CTX *context; /* context */
{
context->count[0] = context->count[1] = 0;
- /* Load magic initialization constants.
- */
+ /*
+ ** Load magic initialization constants.
+ */
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
-/* MD5 block update operation. Continues an MD5 message-digest
- * operation, processing another message block, and updating the
- * context.
- */
+/*
+** MD5 block update operation. Continues an MD5 message-digest
+** operation, processing another message block, and updating the
+** context.
+*/
void MD5Update (context, input, inputLen)
MD5_CTX *context; /* context */
unsigned char *input; /* input block */
}
/*
- * MD5 finalization. Ends an MD5 message-digest operation, writing the
- * the message digest and zeroizing the context.
- */
+** MD5 finalization. Ends an MD5 message-digest operation, writing the
+** the message digest and zeroizing the context.
+*/
void MD5Final (digest, context)
unsigned char digest[16]; /* message digest */
MD5_CTX *context; /* context */
/* Save number of bits */
Encode (bits, context->count, 8);
- /* Pad out to 56 mod 64.
- */
+ /* Pad out to 56 mod 64. */
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
MD5Update (context, PADDING, padLen);
memset ((POINTER)context, 0, sizeof(*context));
}
-/* MD5 basic transformation. Transforms state based on block.
- */
+/*
+** MD5 basic transformation. Transforms state based on block.
+*/
static void MD5Transform (state, block)
UINT4 state[4];
unsigned char block[64];
memset ((POINTER)x, 0, sizeof(x));
}
-/* Encodes input (UINT4) into output (unsigned char). Assumes len is
- * a multiple of 4.
- */
+/*
+** Encodes input (UINT4) into output (unsigned char). Assumes len is
+** a multiple of 4.
+*/
static void Encode (output, input, len)
unsigned char *output;
UINT4 *input;
}
}
-/* Decodes input (unsigned char) into output (UINT4). Assumes len is
- * a multiple of 4.
- */
+/*
+** Decodes input (unsigned char) into output (UINT4). Assumes len is
+** a multiple of 4.
+*/
static void Decode (output, input, len)
UINT4 *output;
unsigned char *input;
/*
- * mhbuild.c -- expand/translate MIME composition files
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhbuild.c -- expand/translate MIME composition files
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
int contentidsw = 1;
/*
- * Temporary files
- */
+** Temporary files
+*/
static char infile[BUFSIZ];
static int unlink_infile = 0;
adios (NULL, "cannot specify both standard input and a file");
else
compfile = cp;
- listsw = 0; /* turn off -list if using standard in/out */
+ listsw = 0; /* turn off -list if using std in/out */
verbosw = 0; /* turn off -verbose listings */
break;
}
listsw = 0;
/*
- * Check if we've specified an additional profile
- */
+ ** Check if we've specified an additional profile
+ */
if ((cp = getenv ("MHBUILD"))) {
if ((fp = fopen (cp, "r"))) {
readconfig ((struct node **) 0, fp, cp, 0);
}
/*
- * Read the standard profile setup
- */
+ ** Read the standard profile setup
+ */
if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) {
readconfig ((struct node **) 0, fp, cp, 0);
fclose (fp);
cache_private = getcpy (m_maildir (cache_private));
/*
- * Check for storage directory. If defined, we
- * will store temporary files there. Else we
- * store them in standard nmh directory.
- */
+ ** Check for storage directory. If defined, we
+ ** will store temporary files there. Else we
+ ** store them in standard nmh directory.
+ */
if ((cp = context_find (nmhstorage)) && *cp)
tmp = concat (cp, "/", invo_name, NULL);
else
adios (NULL, "need to specify a %s composition file", invo_name);
/*
- * Process the composition file from standard input.
- */
+ ** Process the composition file from standard input.
+ */
if (compfile[0] == '-' && compfile[1] == '\0') {
/* copy standard input to temporary file */
strncpy (infile, m_mktemp(invo_name, NULL, &fp), sizeof(infile));
}
/*
- * Process the composition file from a file.
- */
+ ** Process the composition file from a file.
+ */
/* build the content structures for MIME message */
ct = build_mime (compfile);
fclose(fp_out);
/*
- * List the message info
- */
+ ** List the message info
+ */
if (listsw)
list_all_messages (cts, headsw, sizesw, verbosw, debugsw);
unlink_done (int status)
{
/*
- * Check if we need to remove stray
- * temporary files.
- */
+ ** Check if we need to remove stray temporary files.
+ */
if (unlink_infile)
unlink (infile);
if (unlink_outfile)
/*
- * mhbuildsbr.c -- routines to expand/translate MIME composition files
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhbuildsbr.c -- routines to expand/translate MIME composition files
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
/*
- * This code was originally part of mhn.c. I split it into
- * a separate program (mhbuild.c) and then later split it
- * again (mhbuildsbr.c). But the code still has some of
- * the mhn.c code in it. This program needs additional
- * streamlining and removal of unneeded code.
- */
+** This code was originally part of mhn.c. I split it into
+** a separate program (mhbuild.c) and then later split it
+** again (mhbuildsbr.c). But the code still has some of
+** the mhn.c code in it. This program needs additional
+** streamlining and removal of unneeded code.
+*/
#include <h/mh.h>
#include <fcntl.h>
extern int wcachesw; /* mhcachesbr.c */
/*
- * Directory to place tmp files. This must
- * be set before these routines are called.
- */
+** Directory to place tmp files. This must
+** be set before these routines are called.
+*/
char *tmp;
pid_t xpid = 0;
void free_encoding (CT, int);
/*
- * prototypes
- */
+** prototypes
+*/
CT build_mime (char *);
/*
- * static prototypes
- */
+** static prototypes
+*/
static int init_decoded_content (CT);
static char *fgetstr (char *, int, FILE *);
static int user_content (FILE *, char *, char *, CT *);
/*
- * Main routine for translating composition file
- * into valid MIME message. It translates the draft
- * into a content structure (actually a tree of content
- * structures). This message then can be manipulated
- * in various ways, including being output via
- * output_message().
- */
+** Main routine for translating composition file
+** into valid MIME message. It translates the draft
+** into a content structure (actually a tree of content
+** structures). This message then can be manipulated
+** in various ways, including being output via
+** output_message().
+*/
CT
build_mime (char *infile)
adios (infile, "unable to open for reading");
/*
- * Allocate space for primary (outside) content
- */
+ ** Allocate space for primary (outside) content
+ */
if ((ct = (CT) calloc (1, sizeof(*ct))) == NULL)
adios (NULL, "out of memory");
/*
- * Allocate structure for handling decoded content
- * for this part. We don't really need this, but
- * allocate it to remain consistent.
- */
+ ** Allocate structure for handling decoded content
+ ** for this part. We don't really need this, but
+ ** allocate it to remain consistent.
+ */
init_decoded_content (ct);
/*
- * Parse some of the header fields in the composition
- * draft into the linked list of header fields for
- * the new MIME message.
- */
+ ** Parse some of the header fields in the composition
+ ** 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)) {
case FLD:
if (!mh_strcasecmp (name, VRSN_FIELD))
adios (NULL, "draft shouldn't contain %s: field", VRSN_FIELD);
- /* abort if draft has Content-Transfer-Encoding header field */
+ /*
+ ** abort if draft has Content-Transfer-Encoding
+ ** header field
+ */
if (!mh_strcasecmp (name, ENCODING_FIELD))
adios (NULL, "draft shouldn't contain %s: field", ENCODING_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);
+ state = m_getfld (state, name, buf,
+ sizeof(buf), in);
goto finish_field;
}
/* if necessary, get rest of field */
while (state == FLDPLUS) {
state = m_getfld (state, name, buf, sizeof(buf), in);
- vp = add (buf, vp); /* add to previous value */
+ vp = add (buf, vp); /* add to prev value */
}
/* Now add the header data to the list */
add_header (ct, np, vp);
finish_field:
- /* if this wasn't the last header field, then continue */
+ /* if this wasn't the last hdr field, then continue */
if (state != FLDEOF)
continue;
/* else fall... */
case LENERR:
case FMTERR:
- adios (NULL, "message format error in component #%d", compnum);
+ adios (NULL, "message format error in component #%d",
+ compnum);
default:
adios (NULL, "getfld() returned %d", state);
}
/*
- * Now add the MIME-Version header field
- * to the list of header fields.
- */
+ ** Now add the MIME-Version header field
+ ** to the list of header fields.
+ */
np = add (VRSN_FIELD, NULL);
vp = concat (" ", VRSN_VALUE, "\n", NULL);
add_header (ct, np, vp);
/*
- * We initally assume we will find multiple contents in the
- * draft. So create a multipart/mixed content to hold everything.
- * We can remove this later, if it is not needed.
- */
+ ** We initally assume we will find multiple contents in the
+ ** draft. So create a multipart/mixed content to hold everything.
+ ** We can remove this later, if it is not needed.
+ */
if (get_ctinfo ("multipart/mixed", ct, 0) == NOTOK)
done (1);
ct->c_type = CT_MULTIPART;
pp = &m->mp_parts;
/*
- * read and parse the composition file
- * and the directives it contains.
- */
+ ** read and parse the composition file
+ ** and the directives it contains.
+ */
while (fgetstr (buf, sizeof(buf) - 1, in)) {
struct part *part;
CT p;
}
/*
- * close the composition draft since
- * it's not needed any longer.
- */
+ ** close the composition draft since
+ ** it's not needed any longer.
+ */
fclose (in);
/* check if any contents were found */
adios (NULL, "no content directives found");
/*
- * If only one content was found, then remove and
- * free the outer multipart content.
- */
+ ** If only one content was found, then remove and
+ ** free the outer multipart content.
+ */
if (!m->mp_parts->mp_next) {
CT p;
}
/*
- * Fill out, or expand directives. Parse and execute
- * commands specified by profile composition strings.
- */
+ ** Fill out, or expand directives. Parse and execute
+ ** commands specified by profile composition strings.
+ */
compose_content (ct);
if ((cp = strchr(prefix, 'a')) == NULL)
adios (NULL, "internal error(4)");
/*
- * Scan the contents. Choose a transfer encoding, and
- * check if prefix for multipart boundary clashes with
- * any of the contents.
- */
+ ** Scan the contents. Choose a transfer encoding, and
+ ** check if prefix for multipart boundary clashes with
+ ** any of the contents.
+ */
while (scan_content (ct) == NOTOK) {
if (*cp < 'z') {
(*cp)++;
/*
- * Set up structures for placing unencoded
- * content when building parts.
- */
+** Set up structures for placing unencoded
+** content when building parts.
+*/
static int
init_decoded_content (CT ct)
/*
- * Parse the composition draft for text and directives.
- * Do initial setup of Content structure.
- */
+** Parse the composition draft for text and directives.
+** Do initial setup of Content structure.
+*/
static int
user_content (FILE *in, char *file, char *buf, CT *ctp)
set_id (ct, 0);
/*
- * Handle inline text. Check if line
- * is one of the following forms:
- *
- * 1) doesn't begin with '#' (implicit directive)
- * 2) begins with "##" (implicit directive)
- * 3) begins with "#<"
- */
+ ** Handle inline text. Check if line
+ ** is one of the following forms:
+ **
+ ** 1) doesn't begin with '#' (implicit directive)
+ ** 2) begins with "##" (implicit directive)
+ ** 3) begins with "#<"
+ */
if (buf[0] != '#' || buf[1] == '#' || buf[1] == '<') {
int headers;
int inlineD;
char *cp;
cp = m_mktemp2(NULL, invo_name, NULL, &out);
- if (cp == NULL) adios("mhbuildsbr", "unable to create temporary file");
+ if (cp == NULL)
+ adios("mhbuildsbr", "unable to create temporary file");
/* use a temp file to collect the plain text lines */
ce->ce_file = add (cp, NULL);
int i;
if (headers >= 0 && uprf (buffer, DESCR_FIELD)
- && buffer[i = strlen (DESCR_FIELD)] == ':') {
+ && buffer[i = strlen (DESCR_FIELD)] == ':') {
headers = 1;
again_descr:
s2i++;
/*
- * check type specified (possibly implicitly)
- */
+ ** check type specified (possibly implicitly)
+ */
switch (ct->c_type = s2i->si_val) {
case CT_MESSAGE:
if (!mh_strcasecmp (ci->ci_subtype, "rfc822")) {
/* else fall... */
case CT_MULTIPART:
adios (NULL, "it doesn't make sense to define an in-line %s content",
- ct->c_type == CT_MESSAGE ? "message" : "multipart");
+ ct->c_type == CT_MESSAGE ? "message" :
+ "multipart");
/* NOTREACHED */
default:
}
/*
- * If we've reached this point, the next line
- * must be some type of explicit directive.
- */
+ ** If we've reached this point, the next line
+ ** must be some type of explicit directive.
+ */
/* check if directive is external-type */
extrnal = (buf[1] == '@');
break;
/*
- * Check if the directive specified a valid type.
- * This will happen if it was one of the following forms:
- *
- * #type/subtype (or)
- * #@type/subtype
- */
+ ** Check if the directive specified a valid type.
+ ** This will happen if it was one of the following forms:
+ **
+ ** #type/subtype (or)
+ ** #@type/subtype
+ */
if (s2i->si_key) {
if (!ci->ci_subtype)
adios (NULL, "missing subtype in \"#%s\"", ci->ci_type);
}
/*
- * #@type/subtype (external types directive)
- */
+ ** #@type/subtype (external types directive)
+ */
if (extrnal) {
struct exbody *e;
CT p;
ci->ci_magic = NULL;
/*
- * Since we are using the current Content structure to
- * hold information about the type of the external
- * reference, we need to create another Content structure
- * for the message/external-body to wrap it in.
- */
+ ** Since we are using the current Content structure to
+ ** hold information about the type of the external
+ ** reference, we need to create another Content
+ ** structure for the message/external-body to wrap
+ ** it in.
+ */
if ((ct = (CT) calloc (1, sizeof(*ct))) == NULL)
adios (NULL, "out of memory");
*ctp = ct;
}
/*
- * No [file] argument, so check profile for
- * method to compose content.
- */
+ ** No [file] argument, so check profile for
+ ** method to compose content.
+ */
snprintf (buffer, sizeof(buffer), "%s-compose-%s/%s",
invo_name, ci->ci_type, ci->ci_subtype);
if ((cp = context_find (buffer)) == NULL || *cp == '\0') {
- snprintf (buffer, sizeof(buffer), "%s-compose-%s", invo_name, ci->ci_type);
+ snprintf (buffer, sizeof(buffer), "%s-compose-%s",
+ invo_name, ci->ci_type);
if ((cp = context_find (buffer)) == NULL || *cp == '\0') {
content_error (NULL, ct, "don't know how to compose content");
done (1);
}
if (extrnal)
- adios (NULL, "external definition not allowed for \"#%s\"", ci->ci_type);
+ adios (NULL, "external definition not allowed for \"#%s\"",
+ ci->ci_type);
/*
- * Message directive
- * #forw [+folder] [msgs]
- */
+ ** Message directive
+ ** #forw [+folder] [msgs]
+ */
if (!mh_strcasecmp (ci->ci_type, "forw")) {
int msgnum;
char *folder, *arguments[MAXARGS];
free_ctinfo (ct);
/*
- * If there is more than one message to include, make this
- * a content of type "multipart/digest" and insert each message
- * as a subpart. If there is only one message, then make this
- * a content of type "message/rfc822".
- */
+ ** If there is more than one message to include, make this
+ ** a content of type "multipart/digest" and insert each message
+ ** as a subpart. If there is only one message, then make this
+ ** a content of type "message/rfc822".
+ */
if (mp->numsel > 1) {
/* we are forwarding multiple messages */
if (get_ctinfo ("multipart/digest", ct, 0) == NOTOK)
}
/*
- * #end
- */
+ ** #end
+ */
if (!mh_strcasecmp (ci->ci_type, "end")) {
free_content (ct);
*ctp = NULL;
}
/*
- * #begin [ alternative | parallel ]
- */
+ ** #begin [ alternative | parallel ]
+ */
if (!mh_strcasecmp (ci->ci_type, "begin")) {
if (!ci->ci_magic) {
vrsn = MULTI_MIXED;
}
/*
- * Unknown directive
- */
+ ** Unknown directive
+ */
adios (NULL, "unknown directive \"#%s\"", ci->ci_type);
return NOTOK; /* NOT REACHED */
}
/*
- * Fill out, or expand the various contents in the composition
- * draft. Read-in any necessary files. Parse and execute any
- * commands specified by profile composition strings.
- */
+** Fill out, or expand the various contents in the composition
+** draft. Read-in any necessary files. Parse and execute any
+** commands specified by profile composition strings.
+*/
static int
compose_content (CT ct)
}
/* first, we call compose_content on all the subparts */
- for (part = m->mp_parts, partnum = 1; part; part = part->mp_next, partnum++) {
+ for (part = m->mp_parts, partnum = 1; part;
+ part = part->mp_next, partnum++) {
CT p = part->mp_part;
sprintf (pp, "%d", partnum);
}
/*
- * If the -rfc934mode switch is given, then check all
- * the subparts of a multipart/digest. If they are all
- * message/rfc822, then mark this content and all
- * subparts with the rfc934 compatibility mode flag.
- */
+ ** If the -rfc934mode switch is given, then check all
+ ** the subparts of a multipart/digest. If they are all
+ ** message/rfc822, then mark this content and all
+ ** subparts with the rfc934 compatibility mode flag.
+ */
if (rfc934sw && ct->c_subtype == MULTI_DIGEST) {
int is934 = 1;
break;
/*
- * Discrete types (text/application/audio/image/video)
- */
+ ** Discrete types (text/application/audio/image/video)
+ */
default:
if (!ce->ce_file) {
pid_t child_id;
buflen = sizeof(buffer);
/*
- * Parse composition string into buffer
- */
+ ** Parse composition string into buffer
+ */
for ( ; *cp; cp++) {
if (*cp == '%') {
switch (*++cp) {
case 'a':
{
- /* insert parameters from directive */
+ /*
+ ** insert parameters from
+ ** directive
+ */
char **ep;
char *s = "";
case 'f':
/*
- * insert temporary filename where
- * content should be written
- */
+ ** insert temporary filename
+ ** where content should be
+ ** written
+ */
snprintf (bp, buflen, "%s", ce->ce_file);
break;
buflen -= len;
} else {
raw:
- *bp++ = *cp;
- *bp = '\0';
- buflen--;
+ *bp++ = *cp;
+ *bp = '\0';
+ buflen--;
}
}
/*
- * Scan the content.
- *
- * 1) choose a transfer encoding.
- * 2) check for clashes with multipart boundary string.
- * 3) for text content, figure out which character set is being used.
- *
- * If there is a clash with one of the contents and the multipart boundary,
- * this function will exit with NOTOK. This will cause the scanning process
- * to be repeated with a different multipart boundary. It is possible
- * (although highly unlikely) that this scan will be repeated multiple times.
- */
+** Scan the content.
+**
+** 1) choose a transfer encoding.
+** 2) check for clashes with multipart boundary string.
+** 3) for text content, figure out which character set is being used.
+**
+** If there is a clash with one of the contents and the multipart boundary,
+** this function will exit with NOTOK. This will cause the scanning process
+** to be repeated with a different multipart boundary. It is possible
+** (although highly unlikely) that this scan will be repeated multiple times.
+*/
static int
scan_content (CT ct)
CE ce = ct->c_cefile;
/*
- * handle multipart by scanning all subparts
- * and then checking their encoding.
- */
+ ** handle multipart by scanning all subparts
+ ** and then checking their encoding.
+ */
if (ct->c_type == CT_MULTIPART) {
struct multipart *m = (struct multipart *) ct->c_ctparams;
struct part *part;
if (scan_content (p) == NOTOK) /* choose encoding for subpart */
return NOTOK;
- /* if necessary, enlarge encoding for enclosing multipart */
+ /*
+ ** if necessary, enlarge encoding for enclosing
+ ** multipart
+ */
if (p->c_encoding == CE_BINARY)
ct->c_encoding = CE_BINARY;
if (p->c_encoding == CE_8BIT && ct->c_encoding != CE_BINARY)
}
/*
- * Decide what to check while scanning this content.
- */
+ ** Decide what to check while scanning this content.
+ */
switch (ct->c_type) {
case CT_TEXT:
check8bit = 1;
case CT_IMAGE:
case CT_VIDEO:
/*
- * Don't check anything for these types,
- * since we are forcing use of base64.
- */
+ ** Don't check anything for these types,
+ ** since we are forcing use of base64.
+ */
check8bit = 0;
checkebcdic = 0;
checklinelen = 0;
}
/*
- * Scan the unencoded content
- */
+ ** Scan the unencoded content
+ */
if (check8bit || checklinelen || checklinespace || checkboundary) {
if ((in = fopen (ce->ce_file, "r")) == NULL)
adios (ce->ce_file, "unable to open for reading");
while (fgets (buffer, sizeof(buffer) - 1, in)) {
/*
- * Check for 8bit data.
- */
+ ** Check for 8bit data.
+ */
if (check8bit) {
for (cp = buffer; *cp; cp++) {
if (!isascii (*cp)) {
contains8bit = 1;
- check8bit = 0; /* no need to keep checking */
+ /* no need to keep checking */
+ check8bit = 0;
}
/*
- * Check if character is ebcdic-safe. We only check
- * this if also checking for 8bit data.
- */
+ ** 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 */
+ /* no need to keep checking */
+ checkebcdic = 0;
}
}
}
/*
- * Check line length.
- */
+ ** Check line length.
+ */
if (checklinelen && (strlen (buffer) > CPERLIN + 1)) {
linelen = 1;
checklinelen = 0; /* no need to keep checking */
}
/*
- * Check if line ends with a space.
- */
- if (checklinespace && (cp = buffer + strlen (buffer) - 2) > buffer && isspace (*cp)) {
+ ** Check if line ends with a space.
+ */
+ if (checklinespace &&
+ (cp = buffer + strlen (buffer) - 2) >
+ buffer && isspace (*cp)) {
linespace = 1;
- checklinespace = 0; /* no need to keep checking */
+ /* no need to keep checking */
+ checklinespace = 0;
}
/*
- * Check if content contains a line that clashes
- * with our standard boundary for multipart messages.
- */
+ ** Check if content contains a line that clashes
+ ** with our standard boundary for multipart messages.
+ */
if (checkboundary && buffer[0] == '-' && buffer[1] == '-') {
for (cp = buffer + strlen (buffer) - 1; cp >= buffer; cp--)
if (!isspace (*cp))
*++cp = '\0';
if (!strncmp(buffer + 2, prefix, len) && isdigit(buffer[2 + len])) {
boundaryclash = 1;
- checkboundary = 0; /* no need to keep checking */
+ /* no need to keep checking */
+ checkboundary = 0;
}
}
}
}
/*
- * Decide which transfer encoding to use.
- */
+ ** Decide which transfer encoding to use.
+ */
switch (ct->c_type) {
case CT_TEXT:
/*
- * If the text content didn't specify a character
- * set, we need to figure out which one was used.
- */
+ ** If the text content didn't specify a character
+ ** set, we need to figure out which one was used.
+ */
t = (struct text *) ct->c_ctparams;
if (t->tx_charset == CHARSET_UNSPECIFIED) {
CI ci = &ct->c_ctinfo;
/*
- * Scan the content structures, and build header
- * fields that will need to be output into the
- * message.
- */
+** Scan the content structures, and build header
+** fields that will need to be output into the
+** message.
+*/
static int
build_headers (CT ct)
CI ci = &ct->c_ctinfo;
/*
- * If message is type multipart, then add the multipart
- * boundary to the list of attribute/value pairs.
- */
+ ** If message is type multipart, then add the multipart
+ ** boundary to the list of attribute/value pairs.
+ */
if (ct->c_type == CT_MULTIPART) {
char *cp;
static int level = 0; /* store nesting level */
}
/*
- * Skip the output of Content-Type, parameters, content
- * description and disposition, and Content-ID if the
- * content is of type "message" and the rfc934 compatibility
- * flag is set (which means we are inside multipart/digest
- * and the switch -rfc934mode was given).
- */
+ ** Skip the output of Content-Type, parameters, content
+ ** description and disposition, and Content-ID if the
+ ** content is of type "message" and the rfc934 compatibility
+ ** flag is set (which means we are inside multipart/digest
+ ** and the switch -rfc934mode was given).
+ */
if (ct->c_type == CT_MESSAGE && ct->c_rfc934)
goto skip_headers;
/*
- * output the content type and subtype
- */
+ ** output the content type and subtype
+ */
np = add (TYPE_FIELD, NULL);
vp = concat (" ", ci->ci_type, "/", ci->ci_subtype, NULL);
&& ((struct exbody *) ct->c_ctparams)->eb_body;
/*
- * Append the attribute/value pairs to
- * the end of the Content-Type line.
- */
+ ** Append the attribute/value pairs to
+ ** the end of the Content-Type line.
+ */
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
if (mailbody && !mh_strcasecmp (*ap, "body"))
continue;
}
/*
- * Append any RFC-822 comment to the end of
- * the Content-Type line.
- */
+ ** Append any RFC-822 comment to the end of
+ ** the Content-Type line.
+ */
if (ci->ci_comment) {
snprintf (buffer, sizeof(buffer), "(%s)", ci->ci_comment);
if (len + 1 + (cc = 2 + strlen (ci->ci_comment)) >= CPERLIN) {
add_header (ct, np, vp);
/*
- * output the Content-ID, unless disabled by -nocontentid
- */
+ ** output the Content-ID, unless disabled by -nocontentid
+ */
if (contentidsw && ct->c_id) {
np = add (ID_FIELD, NULL);
vp = concat (" ", ct->c_id, NULL);
}
/*
- * output the Content-Description
- */
+ ** output the Content-Description
+ */
if (ct->c_descr) {
np = add (DESCR_FIELD, NULL);
vp = concat (" ", ct->c_descr, NULL);
}
/*
- * output the Content-Disposition
- */
+ ** output the Content-Disposition
+ */
if (ct->c_dispo) {
np = add (DISPO_FIELD, NULL);
vp = concat (" ", ct->c_dispo, NULL);
skip_headers:
/*
- * If this is the internal content structure for a
- * "message/external", then we are done with the
- * headers (since it has no body).
- */
+ ** If this is the internal content structure for a
+ ** "message/external", then we are done with the
+ ** headers (since it has no body).
+ */
if (ct->c_ctexbody)
return OK;
/*
- * output the Content-MD5
- */
+ ** output the Content-MD5
+ */
if (checksw) {
np = add (MD5_FIELD, NULL);
vp = calculate_digest (ct, (ct->c_encoding == CE_QUOTED) ? 1 : 0);
}
/*
- * output the Content-Transfer-Encoding
- */
+ ** output the Content-Transfer-Encoding
+ */
switch (ct->c_encoding) {
case CE_7BIT:
/* Nothing to output */
}
/*
- * Additional content specific header processing
- */
+ ** Additional content specific header processing
+ */
switch (ct->c_type) {
case CT_MULTIPART:
{
}
} else {
while ((cc = fread (buffer, sizeof(*buffer), sizeof(buffer), in)) > 0)
- MD5Update (&mdContext, (unsigned char *) buffer, (unsigned int) cc);
+ MD5Update (&mdContext, (unsigned char *) buffer,
+ (unsigned int) cc);
}
/* md5 finalization. Write digest and zero md5 context */
/*
- * mhcachesbr.c -- routines to manipulate the MIME content cache
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhcachesbr.c -- routines to manipulate the MIME content cache
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
int wcachesw = CACHE_ASK;
/*
- * Location of public and private cache. These must
- * be set before these routines are called.
- */
+** Location of public and private cache. These must
+** be set before these routines are called.
+*/
char *cache_public;
char *cache_private;
void flush_errors (void);
/*
- * prototypes
- */
+** prototypes
+*/
void cache_all_messages (CT *);
int find_cache (CT, int, int *, char *, char *, int);
/*
- * static prototypes
- */
+** static prototypes
+*/
static void cache_content (CT);
static int find_cache_aux (int, char *, char *, char *, int);
static int find_cache_aux2 (char *, char *, char *, int);
/*
- * Top level entry point to cache content
- * from a group of messages
- */
+** Top level entry point to cache content
+** from a group of messages
+*/
void
cache_all_messages (CT *cts)
/*
- * Entry point to cache content from external sources.
- */
+** Entry point to cache content from external sources.
+*/
static void
cache_content (CT ct)
FILE *fp;
if (debugsw)
- fprintf (stderr, "caching by copying %s...\n", ce->ce_file);
+ fprintf (stderr, "caching by copying %s...\n",
+ ce->ce_file);
file = NULL;
if ((*ct->c_ceopenfnx) (ct, &file) == NOTOK)
}
fclose (fp);
} else
- content_error (cachefile, ct, "unable to fopen for writing");
+ content_error (cachefile, ct,
+ "unable to fopen for writing");
reset_umask:
umask (mask);
} else {
id = trimcpy (id);
if (debugsw)
- fprintf (stderr, "find_cache %s(%d) %s %s\n", caches[policy].sw,
- policy, writing ? "writing" : "reading", id);
+ fprintf (stderr, "find_cache %s(%d) %s %s\n",
+ caches[policy].sw, policy,
+ writing ? "writing" : "reading", id);
switch (policy) {
case CACHE_NEVER:
/*
- * mhfree.c -- routines to free the data structures used to
- * -- represent MIME messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhfree.c -- routines to free the data structures used to
+** -- represent MIME messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <errno.h>
CT *cts = NULL;
/*
- * prototypes
- */
+** prototypes
+*/
void free_content (CT);
void free_header (CT);
void free_ctinfo (CT);
void freects_done (int);
/*
- * static prototypes
- */
+** static prototypes
+*/
static void free_text (CT);
static void free_multi (CT);
static void free_partial (CT);
/*
- * Primary routine to free a MIME content structure
- */
+** Primary routine to free a MIME content structure
+*/
void
free_content (CT ct)
return;
/*
- * free all the header fields
- */
+ ** free all the header fields
+ */
free_header (ct);
if (ct->c_partno)
free_ctinfo (ct);
/*
- * some of the content types have extra
- * parts which need to be freed.
- */
+ ** some of the content types have extra
+ ** parts which need to be freed.
+ */
switch (ct->c_type) {
case CT_MULTIPART:
free_multi (ct);
/*
- * Free the linked list of header fields
- * for this content.
- */
+** Free the linked list of header fields
+** for this content.
+*/
void
free_header (CT ct)
/*
- * Free data structures related to encoding/decoding
- * Content-Transfer-Encodings.
- */
+** Free data structures related to encoding/decoding
+** Content-Transfer-Encodings.
+*/
void
free_encoding (CT ct, int toplevel)
/*
- * mhl.c -- the nmh message listing program
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhl.c -- the nmh message listing program
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * mhlist.c -- list the contents of MIME messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhlist.c -- list the contents of MIME messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
{ "help", 0 },
/*
- * switches for debugging
- */
+** switches for debugging
+*/
#define DEBUGSW 15
{ "debug", -5 },
{ NULL, 0 }
extern int userrs;
/*
- * This is currently needed to keep mhparse happy.
- * This needs to be changed.
- */
+** This is currently needed to keep mhparse happy.
+** This needs to be changed.
+*/
pid_t xpid = 0;
int debugsw = 0;
void freects_done (int) NORETURN;
/*
- * static prototypes
- */
+** static prototypes
+*/
static RETSIGTYPE pipeser (int);
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
cache_private = getcpy (m_maildir (cache_private));
/*
- * Check for storage directory. If specified,
- * then store temporary files there. Else we
- * store them in standard nmh directory.
- */
+ ** Check for storage directory. If specified,
+ ** then store temporary files there. Else we
+ ** store them in standard nmh directory.
+ */
if ((cp = context_find (nmhstorage)) && *cp)
tmp = concat (cp, "/", invo_name, NULL);
else
adios (NULL, "cannot specify msg and file at same time!");
/*
- * check if message is coming from file
- */
+ ** check if message is coming from file
+ */
if (file) {
if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
adios (NULL, "out of memory");
*ctp++ = ct;
} else {
/*
- * message(s) are coming from a folder
- */
+ ** message(s) are coming from a folder
+ */
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
done (1);
seq_setprev (mp); /* set the previous-sequence */
- if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
+ if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1),
+ sizeof(*cts))))
adios (NULL, "out of memory");
ctp = cts;
SIGNAL (SIGPIPE, pipeser);
/*
- * Get the associated umask for the relevant contents.
- */
+ ** Get the associated umask for the relevant contents.
+ */
for (ctp = cts; *ctp; ctp++) {
struct stat st;
}
/*
- * List the message content
- */
+ ** List the message content
+ */
list_all_messages (cts, headsw, sizesw, verbosw, debugsw);
/* Now free all the structures for the content */
/*
- * mhlistsbr.c -- routines to list information about the
- * -- contents of MIME messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhlistsbr.c -- routines to list information about the
+** -- contents of MIME messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
void flush_errors (void);
/*
- * prototypes
- */
+** prototypes
+*/
void list_all_messages (CT *, int, int, int, int);
int list_switch (CT, int, int, int, int);
int list_content (CT, int, int, int, int);
/*
- * static prototypes
- */
+** static prototypes
+*/
static void list_single_message (CT, int, int, int);
static int list_debug (CT);
static int list_multi (CT, int, int, int, int);
/*
- * various formats for -list option
- */
+** various formats for -list option
+*/
#define LSTFMT1 "%4s %-5s %-24s %5s %-36s\n"
#define LSTFMT2a "%4d "
#define LSTFMT2b "%-5s %-24.24s "
/*
- * Top level entry point to list group of messages
- */
+** Top level entry point to list group of messages
+*/
void
list_all_messages (CT *cts, int headers, int realsize, int verbose, int debug)
/*
- * Entry point to list a single message
- */
+** Entry point to list a single message
+*/
static void
list_single_message (CT ct, int realsize, int verbose, int debug)
/*
- * Primary switching routine to list information about a content
- */
+** Primary switching routine to list information about a content
+*/
int
list_switch (CT ct, int toplevel, int realsize, int verbose, int debug)
#define empty(s) ((s) ? (s) : "")
/*
- * Method for listing information about a simple/generic content
- */
+** Method for listing information about a simple/generic content
+*/
int
list_content (CT ct, int toplevel, int realsize, int verbose, int debug)
printf ("\n");
/*
- * If verbose, print any RFC-822 comments in the
- * Content-Type line.
- */
+ ** If verbose, print any RFC-822 comments in the
+ ** Content-Type line.
+ */
if (verbose && ci->ci_comment) {
char *dp;
/*
- * Print debugging information about a content
- */
+** Print debugging information about a content
+*/
static int
list_debug (CT ct)
/*
- * list content information for type "multipart"
- */
+** list content information for type "multipart"
+*/
static int
list_multi (CT ct, int toplevel, int realsize, int verbose, int debug)
/*
- * list content information for type "message/partial"
- */
+** list content information for type "message/partial"
+*/
static int
list_partial (CT ct, int toplevel, int realsize, int verbose, int debug)
list_content (ct, toplevel, realsize, verbose, debug);
if (verbose) {
- printf ("\t [message %s, part %d", p->pm_partid, p->pm_partno);
+ printf ("\t [message %s, part %d",
+ p->pm_partid, p->pm_partno);
if (p->pm_maxno)
printf (" of %d", p->pm_maxno);
printf ("]\n");
/*
- * list content information for type "message/external"
- */
+** list content information for type "message/external"
+*/
static int
list_external (CT ct, int toplevel, int realsize, int verbose, int debug)
}
/*
- * Now list the information for the external content
- * to which this content points.
- */
+ ** Now list the information for the external content
+ ** to which this content points.
+ */
list_content (e->eb_content, 0, realsize, verbose, debug);
return OK;
/*
- * list content information for type "application"
- */
+** list content information for type "application"
+*/
static int
list_application (CT ct, int toplevel, int realsize, int verbose, int debug)
/*
- * list information about the Content-Transfer-Encoding
- * used by a content.
- */
+** list information about the Content-Transfer-Encoding
+** used by a content.
+*/
static int
list_encoding (CT ct)
/*
- * mhlsbr.c -- main routines for nmh message lister
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhlsbr.c -- main routines for nmh message lister
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/signals.h>
#include <signal.h>
/*
- * MAJOR BUG:
- * for a component containing addresses, ADDRFMT, if COMPRESS is also
- * set, then addresses get split wrong (not at the spaces between commas).
- * To fix this correctly, putstr() should know about "atomic" strings that
- * must NOT be broken across lines. That's too difficult for right now
- * (it turns out that there are a number of degernate cases), so in
- * oneline(), instead of
- *
- * (*onelp == '\n' && !onelp[1])
- *
- * being a terminating condition,
- *
- * (*onelp == '\n' && (!onelp[1] || (flags & ADDRFMT)))
- *
- * is used instead. This cuts the line prematurely, and gives us a much
- * better chance of getting things right.
- */
+** MAJOR BUG:
+** for a component containing addresses, ADDRFMT, if COMPRESS is also
+** set, then addresses get split wrong (not at the spaces between commas).
+** To fix this correctly, putstr() should know about "atomic" strings that
+** must NOT be broken across lines. That's too difficult for right now
+** (it turns out that there are a number of degernate cases), so in
+** oneline(), instead of
+**
+** (*onelp == '\n' && !onelp[1])
+**
+** being a terminating condition,
+**
+** (*onelp == '\n' && (!onelp[1] || (flags & ADDRFMT)))
+**
+** is used instead. This cuts the line prematurely, and gives us a much
+** better chance of getting things right.
+*/
#define ONECOMP 0
#define TWOCOMP 1
/*
- * Redefine a couple of functions.
- * These are undefined later in the code.
- */
+** Redefine a couple of functions.
+** These are undefined later in the code.
+*/
#define adios mhladios
#define done mhldone
/*
- * prototypes
- */
+** prototypes
+*/
static void mhl_format (char *, int, int);
static int evalvar (struct mcomp *);
static int ptoi (char *, int *);
static int mcomp_flags (char *);
static char *mcomp_add (long, char *, char *);
static void mcomp_format (struct mcomp *, struct mcomp *);
-static struct mcomp *add_queue (struct mcomp **, struct mcomp **, char *, char *, int);
+static struct mcomp *add_queue (struct mcomp **, struct mcomp **,
+ char *, char *, int);
static void free_queue (struct mcomp **, struct mcomp **);
static void putcomp (struct mcomp *, struct mcomp *, int);
static char *oneline (char *, long);
case ',':
case '=':
/*
- * Split this list of fields to ignore,
- * and copy it to the end of the current
- * "ignores" list.
- */
+ ** Split this list of fields to ignore,
+ ** and copy it to the end of the current
+ ** "ignores" list.
+ */
if (!mh_strcasecmp (name, "ignores")) {
char **tmparray, **p;
int n = 0;
while (*p++)
n++;
- /* copy pointers to split fields to ignores array */
+ /*
+ ** copy pointers to split fields
+ ** to ignores array
+ */
ip = copyip (tmparray, ip, MAXARGS - num_ignores);
num_ignores += n;
continue;
default:
/*
- * If we are forwarding this message, and the first
- * column contains a dash, then add a dash and a space.
- */
+ ** If we are forwarding this message, and the first
+ ** column contains a dash, then add a dash and a space.
+ */
if (column == 0 && forwflg && (dashstuff >= 0) && ch == '-') {
putchar ('-');
putchar (' ');
/*
- * faceproc is two elements defining the image agent's location:
- * Internet host
- * UDP port
- */
+** faceproc is two elements defining the image agent's location:
+** Internet host
+** UDP port
+*/
#include <sys/socket.h>
#include <netinet/in.h>
}
/*
- * COMMENTED OUT
- * This version doesn't use sockets
- */
+** COMMENTED OUT
+** This version doesn't use sockets
+*/
#if 0
static int
mhl_action = action;
/*
- * If signal is at default action, then start ignoring
- * it, else let it set to its current action.
- */
+ ** If signal is at default action, then start ignoring
+ ** it, else let it set to its current action.
+ */
if ((istat = SIGNAL (SIGINT, SIG_IGN)) != SIG_DFL)
SIGNAL (SIGINT, istat);
if ((qstat = SIGNAL (SIGQUIT, SIG_IGN)) != SIG_DFL)
default:
SIGNAL (SIGINT, istat);
SIGNAL (SIGQUIT, qstat);
- SIGNAL (SIGPIPE, SIG_IGN); /* should probably change to block instead */
+ SIGNAL (SIGPIPE, SIG_IGN); /*
+ ** should probably change to block
+ ** instead
+ */
if (ontty == PITTY)
m_pclose ();
SIGNAL (SIGPIPE, pstat);
/*
- * mhmail.c -- simple mail program
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhmail.c -- simple mail program
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/signals.h>
static char tmpfil[BUFSIZ];
/*
- * static prototypes
- */
+** static prototypes
+*/
static RETSIGTYPE intrser (int);
fputs ("\n", out);
} else {
for (somebody = 0;
- (i = fread (buf, sizeof(*buf), sizeof(buf), stdin)) > 0;
+ (i = fread (buf, sizeof(*buf), sizeof(buf),
+ stdin)) > 0;
somebody++)
if (fwrite (buf, sizeof(*buf), i, out) != i)
adios (tmpfil, "error writing");
/*
- * mhparse.c -- misc routines to process MIME messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhparse.c -- misc routines to process MIME messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <errno.h>
extern int debugsw;
/*
- * limit actions to specified parts or content types
- */
+** limit actions to specified parts or content types
+*/
int npart = 0;
int ntype = 0;
char *parts[NPARTS + 1];
/*
- * prototypes
- */
+** prototypes
+*/
int part_ok (CT, int);
int type_ok (CT, int);
void set_endian (void);
/*
- * Construct error message for content
- */
+** Construct error message for content
+*/
void
content_error (char *what, CT ct, char *fmt, ...)
/*
- * mhoutsbr.c -- routines to output MIME messages
- * -- given a Content structure
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhoutsbr.c -- routines to output MIME messages
+** -- given a Content structure
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/*
- * prototypes
- */
+** prototypes
+*/
int output_message (CT, char *);
int output_message_fp (CT, FILE *, char *);
int writeBase64aux (FILE *, FILE *);
/*
- * static prototypes
- */
+** static prototypes
+*/
static int output_content (CT, FILE *);
static void output_headers (CT, FILE *);
static int writeExternalBody (CT, FILE *);
/*
- * Main routine to output a MIME message contained
- * in a Content structure, to a file. Any necessary
- * transfer encoding is added.
- */
+** Main routine to output a MIME message contained
+** in a Content structure, to a file. Any necessary
+** transfer encoding is added.
+*/
int
output_message_fp (CT ct, FILE *fp, char *file)
/*
- * Output a Content structure to a file.
- */
+** Output a Content structure to a file.
+*/
static int
output_content (CT ct, FILE *out)
CI ci = &ct->c_ctinfo;
/*
- * Output all header fields for this content
- */
+ ** Output all header fields for this content
+ */
output_headers (ct, out);
/*
- * If this is the internal content structure for a
- * "message/external", then we are done with the
- * headers (since it has no body).
- */
+ ** If this is the internal content structure for a
+ ** "message/external", then we are done with the
+ ** headers (since it has no body).
+ */
if (ct->c_ctexbody)
return OK;
/*
- * Now output the content bodies.
- */
+ ** Now output the content bodies.
+ */
switch (ct->c_type) {
case CT_MULTIPART:
{
break;
/*
- * Handle discrete types (text/application/audio/image/video)
- */
+ ** Handle discrete types (text/application/audio/image/video)
+ */
default:
switch (ct->c_encoding) {
case CE_7BIT:
/*
- * Output all the header fields for a content
- */
+** Output all the header fields for a content
+*/
static void
output_headers (CT ct, FILE *out)
/*
- * Write the phantom body for access-type "mail-server".
- */
+** Write the phantom body for access-type "mail-server".
+*/
static int
writeExternalBody (CT ct, FILE *out)
/*
- * Output a content without any transfer encoding
- */
+** Output a content without any transfer encoding
+*/
static int
write8Bit (CT ct, FILE *out)
/*
- * Output a content using quoted-printable
- */
+** Output a content using quoted-printable
+*/
static int
writeQuoted (CT ct, FILE *out)
/*
- * Output a content using base64
- */
+** Output a content using base64
+*/
static int
writeBase64 (CT ct, FILE *out)
/*
- * mhparam.c -- print mh_profile values
- *
- * Originally contributed by
- * Jeffrey C Honig <Jeffrey_C_Honig@cornell.edu>
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhparam.c -- print mh_profile values
+**
+** Originally contributed by
+** Jeffrey C Honig <Jeffrey_C_Honig@cornell.edu>
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * static prototypes
- */
+** static prototypes
+*/
static char *p_find(char *);
struct proc *ps;
/*
- * Print the current value of everything in
- * procs array. This will show their current
- * value (as determined after context is read).
- */
+ ** Print the current value of everything in
+ ** procs array. This will show their current
+ ** value (as determined after context is read).
+ */
for (ps = procs; ps->p_name; ps++)
- printf ("%s: %s\n", ps->p_name, *ps->p_field ? *ps->p_field : "");
+ printf ("%s: %s\n", ps->p_name,
+ *ps->p_field ? *ps->p_field : "");
} else {
if (components < 0)
/*
- * mhparse.c -- routines to parse the contents of MIME messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhparse.c -- routines to parse the contents of MIME messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
int checksw = 0; /* check Content-MD5 field */
/*
- * Directory to place temp files. This must
- * be set before these routines are called.
- */
+** Directory to place temp files. This must
+** be set before these routines are called.
+*/
char *tmp;
/*
- * Structures for TEXT messages
- */
+** Structures for TEXT messages
+*/
struct k2v SubText[] = {
{ "plain", TEXT_PLAIN },
{ "richtext", TEXT_RICHTEXT }, /* defined in RFC-1341 */
};
/*
- * Structures for MULTIPART messages
- */
+** Structures for MULTIPART messages
+*/
struct k2v SubMultiPart[] = {
{ "mixed", MULTI_MIXED },
{ "alternative", MULTI_ALTERNATE },
};
/*
- * Structures for MESSAGE messages
- */
+** Structures for MESSAGE messages
+*/
struct k2v SubMessage[] = {
{ "rfc822", MESSAGE_RFC822 },
{ "partial", MESSAGE_PARTIAL },
};
/*
- * Structure for APPLICATION messages
- */
+** Structure for APPLICATION messages
+*/
struct k2v SubApplication[] = {
{ "octet-stream", APPLICATION_OCTETS },
{ "postscript", APPLICATION_POSTSCRIPT },
void free_encoding (CT, int);
/*
- * static prototypes
- */
+** static prototypes
+*/
static CT get_content (FILE *, char *, int);
static int get_comment (CT, unsigned char **, int);
};
/*
- * NOTE WELL: si_key MUST NOT have value of NOTOK
- *
- * si_key is 1 if access method is anonymous.
- */
+** NOTE WELL: si_key MUST NOT have value of NOTOK
+**
+** si_key is 1 if access method is anonymous.
+*/
struct str2init str2methods[] = {
{ "afs", 1, InitFile },
{ "anon-ftp", 1, InitFTP },
/*
- * Main entry point for parsing a MIME message or file.
- * It returns the Content structure for the top level
- * entity in the file.
- */
+** Main entry point for parsing a MIME message or file.
+** It returns the Content structure for the top level
+** entity in the file.
+*/
CT
parse_mime (char *file)
{
CT ct;
/*
- * Check if file is actually standard input
- */
+ ** Check if file is actually standard input
+ */
if ((is_stdin = !(strcmp (file, "-")))) {
char *tfile = m_mktemp2(NULL, invo_name, NULL, &fp);
if (tfile == NULL) {
/*
- * Main routine for reading/parsing the headers
- * of a message content.
- *
- * toplevel = 1 # we are at the top level of the message
- * toplevel = 0 # we are inside message type or multipart type
- * # other than multipart/digest
- * toplevel = -1 # we are inside multipart/digest
- * NB: on failure we will fclose(in)!
- */
+** Main routine for reading/parsing the headers
+** of a message content.
+**
+** toplevel = 1 # we are at the top level of the message
+** toplevel = 0 # we are inside message type or multipart type
+** # other than multipart/digest
+** toplevel = -1 # we are inside multipart/digest
+** NB: on failure we will fclose(in)!
+*/
static CT
get_content (FILE *in, char *file, int toplevel)
ct->c_begin = ftell (ct->c_fp) + 1;
/*
- * Parse the header fields for this
- * content into a linked list.
- */
+ ** 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)) {
case FLD:
}
/*
- * Read the content headers. We will parse the
- * MIME related header fields into their various
- * structures and set internal flags related to
- * content type/subtype, etc.
- */
+ ** Read the content headers. We will parse the
+ ** MIME related header fields into their various
+ ** structures and set internal flags related to
+ ** content type/subtype, etc.
+ */
hp = ct->c_first_hf; /* start at first header field */
while (hp) {
admonish (NULL, "message %s has unknown value for %s: field (%s)",
ct->c_file, VRSN_FIELD, cp);
}
- }
- else if (!mh_strcasecmp (hp->name, TYPE_FIELD)) {
- /* Get Content-Type field */
+
+ } else if (!mh_strcasecmp (hp->name, TYPE_FIELD)) {
+ /* Get Content-Type field */
struct str2init *s2i;
CI ci = &ct->c_ctinfo;
goto out;
/*
- * Set the Init function and the internal
- * flag for this content type.
- */
+ ** Set the Init function and the internal
+ ** flag for this content type.
+ */
for (s2i = str2cts; s2i->si_key; s2i++)
if (!mh_strcasecmp (ci->ci_type, s2i->si_key))
break;
s2i++;
ct->c_type = s2i->si_val;
ct->c_ctinitfnx = s2i->si_init;
- }
- else if (!mh_strcasecmp (hp->name, ENCODING_FIELD)) {
- /* Get Content-Transfer-Encoding field */
+
+ } else if (!mh_strcasecmp (hp->name, ENCODING_FIELD)) {
+ /* Get Content-Transfer-Encoding field */
char c;
unsigned char *cp, *dp;
struct str2init *s2i;
/*
- * Check if we've already seen the
- * Content-Transfer-Encoding field
- */
+ ** Check if we've already seen the
+ ** Content-Transfer-Encoding field
+ */
if (ct->c_celine) {
advise (NULL, "message %s has multiple %s: fields",
ct->c_file, ENCODING_FIELD);
*dp = '\0';
/*
- * Find the internal flag and Init function
- * for this transfer encoding.
- */
+ ** Find the internal flag and Init function
+ ** for this transfer encoding.
+ */
for (s2i = str2ces; s2i->si_key; s2i++)
if (!mh_strcasecmp (cp, s2i->si_key))
break;
/* Call the Init function for this encoding */
if (s2i->si_init && (*s2i->si_init) (ct) == NOTOK)
goto out;
- }
- else if (!mh_strcasecmp (hp->name, MD5_FIELD)) {
- /* Get Content-MD5 field */
+
+ } else if (!mh_strcasecmp (hp->name, MD5_FIELD)) {
+ /* Get Content-MD5 field */
unsigned char *cp, *dp;
char *ep;
readDigest (ct, cp);
free (ep);
ct->c_digested++;
- }
- else if (!mh_strcasecmp (hp->name, ID_FIELD)) {
- /* Get Content-ID field */
+
+ } else if (!mh_strcasecmp (hp->name, ID_FIELD)) {
+ /* Get Content-ID field */
ct->c_id = add (hp->value, ct->c_id);
- }
- else if (!mh_strcasecmp (hp->name, DESCR_FIELD)) {
- /* Get Content-Description field */
+
+ } else if (!mh_strcasecmp (hp->name, DESCR_FIELD)) {
+ /* Get Content-Description field */
ct->c_descr = add (hp->value, ct->c_descr);
- }
- else if (!mh_strcasecmp (hp->name, DISPO_FIELD)) {
- /* Get Content-Disposition field */
+
+ } else if (!mh_strcasecmp (hp->name, DISPO_FIELD)) {
+ /* Get Content-Disposition field */
ct->c_dispo = add (hp->value, ct->c_dispo);
}
}
/*
- * Check if we saw a Content-Type field.
- * If not, then assign a default value for
- * it, and the Init function.
- */
+ ** Check if we saw a Content-Type field.
+ ** If not, then assign a default value for
+ ** it, and the Init function.
+ */
if (!ct->c_ctline) {
/*
- * If we are inside a multipart/digest message,
- * so default type is message/rfc822
- */
+ ** If we are inside a multipart/digest message,
+ ** so default type is message/rfc822
+ */
if (toplevel < 0) {
if (get_ctinfo ("message/rfc822", ct, 0) == NOTOK)
goto out;
ct->c_ctinitfnx = InitMessage;
} else {
/*
- * Else default type is text/plain
- */
+ ** Else default type is text/plain
+ */
if (get_ctinfo ("text/plain", ct, 0) == NOTOK)
goto out;
ct->c_type = CT_TEXT;
/*
- * small routine to add header field to list
- */
+** small routine to add header field to list
+*/
int
add_header (CT ct, char *name, char *value)
}
-/* Make sure that buf contains at least one appearance of name,
- followed by =. If not, insert both name and value, just after
- first semicolon, if any. Note that name should not contain a
- trailing =. And quotes will be added around the value. Typical
- usage: make sure that a Content-Disposition header contains
- filename="foo". If it doesn't and value does, use value from
- that. */
+/*
+** Make sure that buf contains at least one appearance of name,
+** followed by =. If not, insert both name and value, just after
+** first semicolon, if any. Note that name should not contain a
+** trailing =. And quotes will be added around the value. Typical
+** usage: make sure that a Content-Disposition header contains
+** filename="foo". If it doesn't and value does, use value from
+** that.
+*/
static char *
incl_name_value (unsigned char *buf, char *name, char *value) {
char *newbuf = buf;
*cp = '\0';
}
- insertion = concat ("; ", name, "=", "\"", value, "\"", NULL);
+ insertion = concat ("; ", name, "=", "\"", value, "\"",
+ NULL);
- /* Insert at first semicolon, if any. If none, append to
- end. */
+ /*
+ ** Insert at first semicolon, if any.
+ ** If none, append to end.
+ */
prefix = add (buf, NULL);
if ((cp = strchr (prefix, ';'))) {
suffix = concat (cp, NULL);
*cp = '\0';
- newbuf = concat (prefix, insertion, suffix, "\n", NULL);
+ newbuf = concat (prefix, insertion, suffix,
+ "\n", NULL);
free (suffix);
} else {
/* Append to end. */
return newbuf;
}
-/* Extract just name_suffix="foo", if any, from value. If there isn't
- one, return the entire value. Note that, for example, a name_suffix
- of name will match filename="foo", and return foo. */
+/*
+** Extract just name_suffix="foo", if any, from value. If there isn't
+** one, return the entire value. Note that, for example, a name_suffix
+** of name will match filename="foo", and return foo.
+*/
static char *
extract_name_value (char *name_suffix, char *value) {
char *extracted_name_value = value;
}
/*
- * Parse Content-Type line and (if `magic' is non-zero) mhbuild composition
- * directives. Fills in the information of the CTinfo structure.
- */
+** Parse Content-Type line and (if `magic' is non-zero) mhbuild composition
+** directives. Fills in the information of the CTinfo structure.
+*/
int
get_ctinfo (unsigned char *cp, CT ct, int magic)
{
if (!*ci->ci_type) {
advise (NULL, "invalid %s: field in message %s (empty type)",
- TYPE_FIELD, ct->c_file);
+ TYPE_FIELD, ct->c_file);
return NOTOK;
}
return NOTOK;
/*
- * Parse attribute/value pairs given with Content-Type
- */
+ ** Parse attribute/value pairs given with Content-Type
+ */
ep = (ap = ci->ci_attrs) + NPARMS;
while (*cp == ';') {
char *vp;
}
/*
- * Get any <Content-Id> given in buffer
- */
+ ** Get any <Content-Id> given in buffer
+ */
if (magic && *cp == '<') {
if (ct->c_id) {
free (ct->c_id);
}
/*
- * Get any [Content-Description] given in buffer.
- */
+ ** Get any [Content-Description] given in buffer.
+ */
if (magic && *cp == '[') {
ct->c_descr = ++cp;
for (dp = cp + strlen (cp) - 1; dp >= cp; dp--)
}
/*
- * Get any {Content-Disposition} given in buffer.
- */
+ ** Get any {Content-Disposition} given in buffer.
+ */
if (magic && *cp == '{') {
ct->c_dispo = ++cp;
for (dp = cp + strlen (cp) - 1; dp >= cp; dp--)
}
/*
- * Check if anything is left over
- */
+ ** Check if anything is left over
+ */
if (*cp) {
if (magic) {
ci->ci_magic = add (cp, NULL);
/*
- * If there is a Content-Disposition header and
- * it doesn't have a *filename=, extract it from
- * the magic contents. The r1bindex call skips
- * any leading directory components.
- */
+ ** If there is a Content-Disposition header and
+ ** it doesn't have a *filename=, extract it from
+ ** the magic contents. The r1bindex call skips
+ ** any leading directory components.
+ */
if (ct->c_dispo)
ct->c_dispo = incl_name_value (ct->c_dispo, "filename", r1bindex (extract_name_value ("name", ci->ci_magic), '/'));
} else
/*
- * CONTENTS
- *
- * Handles content types audio, image, and video.
- * There's not much to do right here.
- */
+** CONTENTS
+**
+** Handles content types audio, image, and video.
+** There's not much to do right here.
+*/
static int
InitGeneric (CT ct)
/*
- * TEXT
- */
+** TEXT
+*/
static int
InitText (CT ct)
}
/*
- * If we can not handle character set natively,
- * then check profile for string to modify the
- * terminal or display method.
- *
- * termproc is for mhshow, though mhlist -debug prints it, too.
- */
+ ** If we can not handle character set natively,
+ ** then check profile for string to modify the
+ ** terminal or display method.
+ **
+ ** termproc is for mhshow, though mhlist -debug prints it, too.
+ */
if (chset != NULL && !check_charset (chset, strlen (chset))) {
snprintf (buffer, sizeof(buffer), "%s-charset-%s", invo_name, chset);
if ((cp = context_find (buffer)))
/*
- * MULTIPART
- */
+** MULTIPART
+*/
static int
InitMultiPart (CT ct)
FILE *fp;
/*
- * The encoding for multipart messages must be either
- * 7bit, 8bit, or binary (per RFC2045).
- */
+ ** The encoding for multipart messages must be either
+ ** 7bit, 8bit, or binary (per RFC2045).
+ */
if (ct->c_encoding != CE_7BIT && ct->c_encoding != CE_8BIT
&& ct->c_encoding != CE_BINARY) {
admonish (NULL,
ct->c_subtype = kv->kv_value;
/*
- * Check for "boundary" parameter, which is
- * required for multipart messages.
- */
+ ** Check for "boundary" parameter, which is
+ ** required for multipart messages.
+ */
bp = 0;
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
if (!mh_strcasecmp (*ap, "boundary")) {
reverse_parts (ct);
/*
- * label all subparts with part number, and
- * then initialize the content of the subpart.
- */
+ ** label all subparts with part number, and
+ ** then initialize the content of the subpart.
+ */
{
int partnum;
char *pp;
/*
- * reverse the order of the parts of a multipart
- */
+** reverse the order of the parts of a multipart
+*/
static void
reverse_parts (CT ct)
/*
- * MESSAGE
- */
+** MESSAGE
+*/
static int
InitMessage (CT ct)
adios (NULL, "out of memory");
ct->c_ctparams = (void *) p;
- /* scan for parameters "id", "number", and "total" */
+ /*
+ ** scan for parameters "id", "number",
+ ** and "total"
+ */
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
if (!mh_strcasecmp (*ap, "id")) {
p->pm_partid = add (*ep, NULL);
/*
- * APPLICATION
- */
+** APPLICATION
+*/
static int
InitApplication (CT ct)
/*
- * TRANSFER ENCODINGS
- */
+** TRANSFER ENCODINGS
+*/
static int
init_encoding (CT ct, OpenCEFunc openfnx)
/*
- * BASE64
- */
+** BASE64
+*/
static unsigned char b642nib[0x80] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
- // Temporary file already exists, so we rename to
- // version with extension.
+ /*
+ ** Temporary file already exists, so we rename to
+ ** version with extension.
+ */
char *file_org = strdup(ce->ce_file);
ce->ce_file = add (cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
/*
- * QUOTED PRINTABLE
- */
+** QUOTED PRINTABLE
+*/
static char hex2nib[0x80] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
if (ce->ce_file) {
if ((ce->ce_fp = fopen (ce->ce_file, "r")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading");
+ content_error (ce->ce_file, ct,
+ "unable to fopen for reading");
return NOTOK;
}
goto ready_to_go;
char *file_org = strdup(ce->ce_file);
ce->ce_file = add (cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
- adios (ce->ce_file, "unable to rename %s to ", file_org);
+ adios (ce->ce_file, "unable to rename %s to ",
+ file_org);
}
free(file_org);
}
if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
+ content_error (ce->ce_file, ct,
+ "unable to fopen for reading/writing");
return NOTOK;
}
if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
+ content_error (ce->ce_file, ct,
+ "unable to fopen for reading/writing");
return NOTOK;
}
content_error (ce->ce_file, ct, "error writing to");
goto clean_up;
}
- /* finished escape sequence; next may
- * be literal or a new escape
- * sequence */
+ /*
+ ** finished escape sequence; next may
+ ** be literal or a new escape sequence
+ */
quoted = 0;
}
/* on to next byte */
/* not in an escape sequence */
if (*cp == '=') {
- /* starting an escape sequence, or invalid '='? */
+ /*
+ ** starting an escape sequence,
+ ** or invalid '='?
+ */
if (cp + 1 < ep && cp[1] == '\n') {
/* "=\n" soft line break, eat the \n */
cp++;
continue;
}
if (cp + 1 >= ep || cp + 2 >= ep) {
- /* We don't have 2 bytes left, so this is an invalid
- * escape sequence; just show the raw bytes (below). */
+ /*
+ ** We don't have 2 bytes left,
+ ** so this is an invalid escape
+ ** sequence; just show the raw bytes
+ ** (below).
+ */
} else if (isxdigit (cp[1]) && isxdigit (cp[2])) {
- /* Next 2 bytes are hex digits, making this a valid escape
- * sequence; let's decode it (above). */
+ /*
+ ** Next 2 bytes are hex digits,
+ ** making this a valid escape
+ ** sequence; let's decode it (above).
+ */
quoted = 1;
continue;
} else {
- /* One or both of the next 2 is out of range, making this
- * an invalid escape sequence; just show the raw bytes
- * (below). */
+ /*
+ ** One or both of the next 2 is
+ ** out of range, making this an
+ ** invalid escape sequence; just
+ ** show the raw bytes (below).
+ */
}
}
/*
- * 7BIT
- */
+** 7BIT
+*/
static int
Init7Bit (CT ct)
if (ce->ce_file) {
if ((ce->ce_fp = fopen (ce->ce_file, "r")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading");
+ content_error (ce->ce_file, ct,
+ "unable to fopen for reading");
return NOTOK;
}
goto ready_to_go;
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
- // Temporary file already exists, so we rename to
- // version with extension.
+ /*
+ ** Temporary file already exists, so we rename to
+ ** version with extension.
+ */
char *file_org = strdup(ce->ce_file);
ce->ce_file = add (cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
- adios (ce->ce_file, "unable to rename %s to ", file_org);
+ adios (ce->ce_file, "unable to rename %s to ",
+ file_org);
}
free(file_org);
}
if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
+ content_error (ce->ce_file, ct,
+ "unable to fopen for reading/writing");
return NOTOK;
}
CI ci = &ct->c_ctinfo;
len = 0;
- fprintf (ce->ce_fp, "%s: %s/%s", TYPE_FIELD, ci->ci_type, ci->ci_subtype);
+ fprintf (ce->ce_fp, "%s: %s/%s", TYPE_FIELD, ci->ci_type,
+ ci->ci_subtype);
len += strlen (TYPE_FIELD) + 2 + strlen (ci->ci_type)
+ 1 + strlen (ci->ci_subtype);
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
putc (';', ce->ce_fp);
len++;
- snprintf (buffer, sizeof(buffer), "%s=\"%s\"", *ap, *ep);
+ snprintf (buffer, sizeof(buffer), "%s=\"%s\"",
+ *ap, *ep);
if (len + 1 + (cc = strlen (buffer)) >= CPERLIN) {
fputs ("\n\t", ce->ce_fp);
/*
- * External
- */
+** External
+*/
static int
openExternal (CT ct, CT cb, CE ce, char **file, int *fd)
if (ce->ce_file) {
if ((ce->ce_fp = fopen (ce->ce_file, "r")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading");
+ content_error (ce->ce_file, ct,
+ "unable to fopen for reading");
return NOTOK;
}
goto ready_already;
}
/*
- * File
- */
+** File
+*/
static int
InitFile (CT ct)
}
/*
- * FTP
- */
+** FTP
+*/
static int
InitFTP (CT ct)
buflen = sizeof(buffer);
/*
- * Construct the query message for user
- */
+ ** Construct the query message for user
+ */
snprintf (bp, buflen, "Retrieve %s", e->eb_name);
len = strlen (bp);
bp += len;
snprintf (bp, buflen, "? ");
/*
- * Now, check the answer
- */
+ ** Now, check the answer
+ */
if (!getanswer (buffer))
return NOTOK;
if (e->eb_flags) {
user = "anonymous";
- snprintf (buffer, sizeof(buffer), "%s@%s", getusername (), LocalName ());
+ snprintf (buffer, sizeof(buffer), "%s@%s", getusername (),
+ LocalName ());
pass = buffer;
} else {
ruserpass (e->eb_site, &username, &password);
caching = 0;
cachefile[0] = '\0';
if ((!e->eb_permission || mh_strcasecmp (e->eb_permission, "read-write"))
- && find_cache (NULL, wcachesw, &cachetype, e->eb_content->c_id,
- cachefile, sizeof(cachefile)) != NOTOK) {
+ && find_cache (NULL, wcachesw, &cachetype, e->eb_content->c_id,
+ cachefile, sizeof(cachefile)) != NOTOK) {
if (*file == NULL) {
ce->ce_unlink = 0;
caching = 1;
/*
- * Mail
- */
+** Mail
+*/
static int
InitMail (CT ct)
return NOTOK;
}
- /* showproc is for mhshow and mhstore, though mhlist -debug
- * prints it, too. */
+ /*
+ ** showproc is for mhshow and mhstore, though mhlist -debug
+ ** prints it, too.
+ */
if (ct->c_showproc)
free (ct->c_showproc);
ct->c_showproc = add ("true", NULL);
}
if (bitno != 18) {
if (debugsw)
- fprintf (stderr, "premature ending (bitno %d)\n", bitno);
+ fprintf (stderr, "premature ending (bitno %d)\n",
+ bitno);
return NOTOK;
}
/*
- * mhpath.c -- print full pathnames of nmh messages and folders
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhpath.c -- print full pathnames of nmh messages and folders
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
adios (NULL, "unable to read folder %s", folder);
/*
- * We need to make sure there is message status space
- * for all the message numbers from 1 to "new" since
- * mhpath can select empty slots. If we are adding
- * space at the end, we go ahead and add 10 slots.
- */
+ ** We need to make sure there is message status space
+ ** for all the message numbers from 1 to "new" since
+ ** mhpath can select empty slots. If we are adding
+ ** space at the end, we go ahead and add 10 slots.
+ */
if (mp->hghmsg >= mp->hghoff) {
if (!(mp = folder_realloc (mp, 1, mp->hghmsg + 10)))
adios (NULL, "unable to allocate folder storage");
/*
- * mhshow.c -- display the contents of MIME messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhshow.c -- display the contents of MIME messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
{ "help", 0 },
/*
- * switches for moreproc/mhlproc
- */
+** switches for moreproc/mhlproc
+*/
#define PROGSW 16
{ "moreproc program", -4 },
#define NPROGSW 17
{ "width columns", -4 },
/*
- * switches for debugging
- */
+** switches for debugging
+*/
#define DEBUGSW 20
{ "debug", -5 },
{ NULL, 0 }
void freects_done (int) NORETURN;
/*
- * static prototypes
- */
+** static prototypes
+*/
static RETSIGTYPE pipeser (int);
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
icachesw = &wcachesw;
do_cache:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
switch (*icachesw = smatch (cp, caches)) {
case AMBIGSW:
ambigsw (cp, caches);
case PARTSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
if (npart >= NPARTS)
adios (NULL, "too many parts (starting with %s), %d max",
cp, NPARTS);
case TYPESW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
if (ntype >= NTYPES)
adios (NULL, "too many types (starting with %s), %d max",
cp, NTYPES);
case FILESW:
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
file = *cp == '-' ? cp : path (cp, TFILE);
continue;
case FORMSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
if (formsw)
free (formsw);
formsw = getcpy (etcpath (cp));
continue;
/*
- * Switches for moreproc/mhlproc
- */
+ ** Switches for moreproc/mhlproc
+ */
case PROGSW:
if (!(progsw = *argp++) || *progsw == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case NPROGSW:
nomore++;
case LENSW:
case WIDTHSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case VERBSW:
}
/*
- * Check if we've specified an additional profile
- */
+ ** Check if we've specified an additional profile
+ */
if ((cp = getenv ("MHSHOW"))) {
if ((fp = fopen (cp, "r"))) {
readconfig ((struct node **) 0, fp, cp, 0);
fclose (fp);
} else {
- admonish ("", "unable to read $MHSHOW profile (%s)", cp);
+ admonish ("", "unable to read $MHSHOW profile (%s)",
+ cp);
}
}
/*
- * Read the standard profile setup
- */
+ ** Read the standard profile setup
+ */
if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) {
readconfig ((struct node **) 0, fp, cp, 0);
fclose (fp);
cache_private = getcpy (m_maildir (cache_private));
/*
- * Check for storage directory. If specified,
- * then store temporary files there. Else we
- * store them in standard nmh directory.
- */
+ ** Check for storage directory. If specified,
+ ** then store temporary files there. Else we
+ ** store them in standard nmh directory.
+ */
if ((cp = context_find (nmhstorage)) && *cp)
tmp = concat (cp, "/", invo_name, NULL);
else
adios (NULL, "cannot specify msg and file at same time!");
/*
- * check if message is coming from file
- */
+ ** check if message is coming from file
+ */
if (file) {
if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
adios (NULL, "out of memory");
*ctp++ = ct;
} else {
/*
- * message(s) are coming from a folder
- */
+ ** message(s) are coming from a folder
+ */
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
done (1);
/*
- * Set the SELECT_UNSEEN bit for all the SELECTED messages,
- * since we will use that as a tag to know which messages
- * to remove from the "unseen" sequence.
- */
+ ** Set the SELECT_UNSEEN bit for all the SELECTED messages,
+ ** since we will use that as a tag to know which messages
+ ** to remove from the "unseen" sequence.
+ */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
if (is_selected(mp, msgnum))
set_unseen (mp, msgnum);
seq_setprev (mp); /* set the Previous-Sequence */
seq_setunseen (mp, 1); /* unset the Unseen-Sequence */
- if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
+ if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1),
+ sizeof(*cts))))
adios (NULL, "out of memory");
ctp = cts;
/*
- * Parse all the SELECTED messages.
- */
+ ** Parse all the SELECTED messages.
+ */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
char *msgnam;
SIGNAL (SIGPIPE, pipeser);
/*
- * Get the associated umask for the relevant contents.
- */
+ ** Get the associated umask for the relevant contents.
+ */
for (ctp = cts; *ctp; ctp++) {
struct stat st;
}
/*
- * Show the message content
- */
+ ** Show the message content
+ */
show_all_messages (cts);
/* Now free all the structures for the content */
/*
- * mhshowsbr.c -- routines to display the contents of MIME messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhshowsbr.c -- routines to display the contents of MIME messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
#endif
/*
- * Just use sigjmp/longjmp on older machines that
- * don't have sigsetjmp/siglongjmp.
- */
+** Just use sigjmp/longjmp on older machines that
+** don't have sigsetjmp/siglongjmp.
+*/
#ifndef HAVE_SIGSETJMP
# define sigjmp_buf jmp_buf
# define sigsetjmp(env,mask) setjmp(env)
int list_content (CT, int, int, int, int);
/*
- * prototypes
- */
+** prototypes
+*/
void show_all_messages (CT *);
int show_content_aux (CT, int, int, char *, char *);
/*
- * static prototypes
- */
+** static prototypes
+*/
static void show_single_message (CT, char *);
static void DisplayMsgHeader (CT, char *);
static int show_switch (CT, int, int);
static int show_content (CT, int, int);
-static int show_content_aux2 (CT, int, int, char *, char *, int, int, int, int, int);
+static int show_content_aux2 (CT, int, int, char *, char *,
+ int, int, int, int, int);
static int show_text (CT, int, int);
static int show_multi (CT, int, int);
static int show_multi_internal (CT, int, int);
/*
- * Top level entry point to show/display a group of messages
- */
+** Top level entry point to show/display a group of messages
+*/
void
show_all_messages (CT *cts)
CT ct, *ctp;
/*
- * If form is not specified, then get default form
- * for showing headers of MIME messages.
- */
+ ** If form is not specified, then get default form
+ ** for showing headers of MIME messages.
+ */
if (!formsw)
formsw = getcpy (etcpath ("mhl.headers"));
/*
- * If form is "mhl.null", suppress display of header.
- */
+ ** If form is "mhl.null", suppress display of header.
+ */
if (!strcmp (formsw, "mhl.null"))
formsw = NULL;
/*
- * Entry point to show/display a single message
- */
+** Entry point to show/display a single message
+*/
static void
show_single_message (CT ct, char *form)
int status;
#endif
- /* Allow user executable bit so that temporary directories created by
- * the viewer (e.g., lynx) are going to be accessible */
+ /*
+ ** Allow user executable bit so that temporary directories created by
+ ** the viewer (e.g., lynx) are going to be accessible
+ */
umask (ct->c_umask & ~(0100));
/*
- * If you have a format file, then display
- * the message headers.
- */
+ ** If you have a format file, then display
+ ** the message headers.
+ */
if (form)
DisplayMsgHeader(ct, form);
else
/*
- * Use the mhlproc to show the header fields
- */
+** Use the mhlproc to show the header fields
+*/
static void
DisplayMsgHeader (CT ct, char *form)
vec[vecp++] = ct->c_file;
/*
- * If we've specified -(no)moreproc,
- * then just pass that along.
- */
+ ** If we've specified -(no)moreproc,
+ ** then just pass that along.
+ */
if (nomore) {
vec[vecp++] = "-nomoreproc";
} else if (progsw) {
/*
- * Switching routine. Call the correct routine
- * based on content type.
- */
+** Switching routine. Call the correct routine
+** based on content type.
+*/
static int
show_switch (CT ct, int serial, int alternate)
/*
- * Generic method for displaying content
- */
+** Generic method for displaying content
+*/
static int
show_content (CT ct, int serial, int alternate)
/*
- * Parse the display string for displaying generic content
- */
+** Parse the display string for displaying generic content
+*/
int
show_content_aux (CT ct, int serial, int alternate, char *cp, char *cracked)
if (!ct->c_ceopenfnx) {
if (!alternate)
- content_error (NULL, ct, "don't know how to decode content");
+ content_error (NULL, ct,
+ "don't know how to decode content");
return NOTOK;
}
char **ap, **ep;
char *s = "";
- for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
- snprintf (bp, buflen, "%s%s=\"%s\"", s, *ap, *ep);
+ for (ap = ci->ci_attrs, ep = ci->ci_values;
+ *ap; ap++, ep++) {
+ snprintf (bp, buflen, "%s%s=\"%s\"",
+ s, *ap, *ep);
len = strlen (bp);
bp += len;
buflen -= len;
case 'f':
/* insert filename containing content */
snprintf (bp, buflen, "'%s'", file);
- /* since we've quoted the file argument, set things up
- * to look past it, to avoid problems with the quoting
- * logic below. (I know, I should figure out what's
- * broken with the quoting logic, but..)
- */
+ /*
+ ** since we've quoted the file argument,
+ ** set things up to look past it, to avoid
+ ** problems with the quoting logic below.
+ ** (I know, I should figure out what's
+ ** broken with the quoting logic, but..)
+ */
len = strlen(bp);
buflen -= len;
bp += len;
/* and fall... */
case 'l':
- /* display listing prior to displaying content */
+ /*
+ ** display listing prior to displaying content
+ */
xlist = !nolist;
break;
/* Did we actually insert something? */
if (bp != pp) {
- /* Insert single quote if not inside quotes already */
+ /*
+ ** Insert single quote if not inside quotes
+ ** already
+ */
if (!quoted && buflen) {
len = strlen (pp);
memmove (pp + 1, pp, len);
buflen -= 3;
bp += 3;
}
- /* If pp is still set, that means we ran out of space. */
+ /*
+ ** If pp is still set, that means we ran
+ ** out of space.
+ */
if (pp)
buflen = 0;
if (!quoted && buflen) {
}
if (buflen <= 0 || (ct->c_termproc && buflen <= strlen(ct->c_termproc))) {
- /* content_error would provide a more useful error message
- * here, except that if we got overrun, it probably would
- * too.
- */
+ /*
+ ** content_error would provide a more useful error message
+ ** here, except that if we got overrun, it probably would
+ ** too.
+ */
fprintf(stderr, "Buffer overflow constructing show command!\n");
return NOTOK;
}
got_command:
return show_content_aux2 (ct, serial, alternate, cracked, buffer,
- fd, xlist, xpause, xstdin, xtty);
+ fd, xlist, xpause, xstdin, xtty);
}
/*
- * Routine to actually display the content
- */
+** Routine to actually display the content
+*/
static int
show_content_aux2 (CT ct, int serial, int alternate, char *cracked,
if (ct->c_partno)
fprintf (stderr, " part %s", ct->c_partno);
if (cracked)
- fprintf (stderr, " using command (cd %s; %s)\n", cracked, buffer);
+ fprintf (stderr, " using command (cd %s; %s)\n",
+ cracked, buffer);
else
fprintf (stderr, " using command %s\n", buffer);
}
/*
- * show content of type "text"
- */
+** show content of type "text"
+*/
static int
show_text (CT ct, int serial, int alternate)
return show_content_aux (ct, serial, alternate, cp, NULL);
/*
- * Use default method if content is text/plain, or if
- * if it is not a text part of a multipart/alternative
- */
+ ** Use default method if content is text/plain, or if
+ ** if it is not a text part of a multipart/alternative
+ */
if (!alternate || ct->c_subtype == TEXT_PLAIN) {
snprintf (buffer, sizeof(buffer), "%%p%s '%%F'", progsw ? progsw :
moreproc && *moreproc ? moreproc : "more");
/*
- * show message body of type "multipart"
- */
+** show message body of type "multipart"
+*/
static int
show_multi (CT ct, int serial, int alternate)
return show_multi_aux (ct, serial, alternate, cp);
/*
- * Use default method to display this multipart content
- * if it is not a (nested) part of a multipart/alternative,
- * or if it is one of the known subtypes of multipart.
- */
+ ** Use default method to display this multipart content
+ ** if it is not a (nested) part of a multipart/alternative,
+ ** or if it is one of the known subtypes of multipart.
+ */
if (!alternate || ct->c_subtype != MULTI_UNKNOWN)
return show_multi_internal (ct, serial, alternate);
/*
- * show message body of subtypes of multipart that
- * we understand directly (mixed, alternate, etc...)
- */
+** show message body of subtypes of multipart that
+** we understand directly (mixed, alternate, etc...)
+*/
static int
show_multi_internal (CT ct, int serial, int alternate)
nowserial = serial;
} else {
/*
- * multipart/mixed
- * mutlipart/digest
- * unknown subtypes of multipart (treat as mixed per rfc2046)
- */
+ ** multipart/mixed
+ ** mutlipart/digest
+ ** unknown subtypes of multipart (treat as mixed per rfc2046)
+ */
nowserial = serial;
}
}
/*
- * alternate -> we are a part inside an multipart/alternative
- * alternating -> we are a multipart/alternative
- */
+** alternate -> we are a part inside an multipart/alternative
+** alternating -> we are a multipart/alternative
+*/
result = alternate ? NOTOK : OK;
/*
- * Parse display string for multipart content
- * and use external program to display it.
- */
+** Parse display string for multipart content
+** and use external program to display it.
+*/
static int
show_multi_aux (CT ct, int serial, int alternate, char *cp)
char **ap, **ep;
char *s = "";
- for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
- snprintf (bp, buflen, "%s%s=\"%s\"", s, *ap, *ep);
+ for (ap = ci->ci_attrs, ep = ci->ci_values;
+ *ap; ap++, ep++) {
+ snprintf (bp, buflen, "%s%s=\"%s\"",
+ s, *ap, *ep);
len = strlen (bp);
bp += len;
buflen -= len;
{
char *s = "";
- for (part = m->mp_parts; part; part = part->mp_next) {
+ for (part = m->mp_parts; part;
+ part = part->mp_next) {
p = part->mp_part;
snprintf (bp, buflen, "%s'%s'", s, p->c_storage);
buflen -= len;
s = " ";
}
- /* set our starting pointer back to bp, to avoid
- * requoting the filenames we just added
- */
+ /*
+ ** set our starting pointer back to bp,
+ ** to avoid requoting the filenames we
+ ** just added
+ */
pp = bp;
}
break;
/* and fall... */
case 'l':
- /* display listing prior to displaying content */
+ /*
+ ** display listing prior to displaying content
+ */
xlist = !nolist;
break;
/* Did we actually insert something? */
if (bp != pp) {
- /* Insert single quote if not inside quotes already */
+ /*
+ ** Insert single quote if not inside quotes
+ ** already
+ */
if (!quoted && buflen) {
len = strlen (pp);
memmove (pp + 1, pp, len);
buflen -= 3;
bp += 3;
}
- /* If pp is still set, that means we ran out of space. */
+ /*
+ ** If pp is still set, that means we ran
+ ** out of space.
+ */
if (pp)
buflen = 0;
if (!quoted && buflen) {
}
if (buflen <= 0 || (ct->c_termproc && buflen <= strlen(ct->c_termproc))) {
- /* content_error would provide a more useful error message
- * here, except that if we got overrun, it probably would
- * too.
- */
+ /*
+ ** content_error would provide a more useful error message
+ ** here, except that if we got overrun, it probably would
+ ** too.
+ */
fprintf(stderr, "Buffer overflow constructing show command!\n");
return NOTOK;
}
}
return show_content_aux2 (ct, serial, alternate, NULL, buffer,
- NOTOK, xlist, xpause, 0, xtty);
+ NOTOK, xlist, xpause, 0, xtty);
}
/*
- * show content of type "message/rfc822"
- */
+** show content of type "message/rfc822"
+*/
static int
show_message_rfc822 (CT ct, int serial, int alternate)
/*
- * Show content of type "message/partial".
- */
+** Show content of type "message/partial".
+*/
static int
show_partial (CT ct, int serial, int alternate)
/*
- * Show content of type "message/external".
- *
- * THE ERROR CHECKING IN THIS ONE IS NOT DONE YET.
- */
+** Show content of type "message/external".
+**
+** THE ERROR CHECKING IN THIS ONE IS NOT DONE YET.
+*/
static int
show_external (CT ct, int serial, int alternate)
/*
- * mhstore.c -- store the contents of MIME messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhstore.c -- store the contents of MIME messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
{ "help", 0 },
/*
- * switches for debugging
- */
+** switches for debugging
+*/
#define DEBUGSW 13
{ "debug", -5 },
{ NULL, 0 }
void freects_done (int) NORETURN;
/*
- * static prototypes
- */
+** static prototypes
+*/
static RETSIGTYPE pipeser (int);
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
set_endian ();
/*
- * Check if we've specified an additional profile
- */
+ ** Check if we've specified an additional profile
+ */
if ((cp = getenv ("MHSTORE"))) {
if ((fp = fopen (cp, "r"))) {
readconfig ((struct node **) 0, fp, cp, 0);
}
/*
- * Read the standard profile setup
- */
+ ** Read the standard profile setup
+ */
if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) {
readconfig ((struct node **) 0, fp, cp, 0);
fclose (fp);
cache_private = getcpy (m_maildir (cache_private));
/*
- * Cache the current directory before we do any chdirs()'s.
- */
+ ** Cache the current directory before we do any chdirs()'s.
+ */
cwd = getcpy (pwd());
/*
- * Check for storage directory. If specified,
- * then store temporary files there. Else we
- * store them in standard nmh directory.
- */
+ ** Check for storage directory. If specified,
+ ** then store temporary files there. Else we
+ ** store them in standard nmh directory.
+ */
if ((cp = context_find (nmhstorage)) && *cp)
tmp = concat (cp, "/", invo_name, NULL);
else
adios (NULL, "cannot specify msg and file at same time!");
/*
- * check if message is coming from file
- */
+ ** check if message is coming from file
+ */
if (file) {
if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
adios (NULL, "out of memory");
*ctp++ = ct;
} else {
/*
- * message(s) are coming from a folder
- */
+ ** message(s) are coming from a folder
+ */
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
done (1);
seq_setprev (mp); /* set the previous-sequence */
- if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
+ if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1),
+ sizeof(*cts))))
adios (NULL, "out of memory");
ctp = cts;
SIGNAL (SIGPIPE, pipeser);
/*
- * Get the associated umask for the relevant contents.
- */
+ ** Get the associated umask for the relevant contents.
+ */
for (ctp = cts; *ctp; ctp++) {
struct stat st;
}
/*
- * Store the message content
- */
+ ** Store the message content
+ */
store_all_messages (cts);
/* Now free all the structures for the content */
/*
- * mhstoresbr.c -- routines to save/store the contents of MIME messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhstoresbr.c -- routines to save/store the contents of MIME messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
/*
- * The list of top-level contents to display
- */
+** The list of top-level contents to display
+*/
extern CT *cts;
int autosw = 0;
/*
- * Cache of current directory. This must be
- * set before these routines are called.
- */
+** Cache of current directory. This must be
+** set before these routines are called.
+*/
char *cwd;
/*
- * The directory in which to store the contents.
- */
+** The directory in which to store the contents.
+*/
static char *dir;
/*
- * Type for a compare function for qsort. This keeps
- * the compiler happy.
- */
+** Type for a compare function for qsort. This keeps
+** the compiler happy.
+*/
typedef int (*qsort_comp) (const void *, const void *);
int show_content_aux (CT, int, int, char *, char *);
/*
- * prototypes
- */
+** prototypes
+*/
void store_all_messages (CT *);
/*
- * static prototypes
- */
+** static prototypes
+*/
static void store_single_message (CT);
static int store_switch (CT);
static int store_generic (CT);
/*
- * Main entry point to store content
- * from a collection of messages.
- */
+** Main entry point to store content
+** from a collection of messages.
+*/
void
store_all_messages (CT *cts)
char *cp;
/*
- * Check for the directory in which to
- * store any contents.
- */
+ ** Check for the directory in which to
+ ** store any contents.
+ */
if (autosw)
dir = getcpy (cwd);
else if ((cp = context_find (nmhstorage)) && *cp)
/*
- * Entry point to store the content
- * in a (single) message
- */
+** Entry point to store the content
+** in a (single) message
+*/
static void
store_single_message (CT ct)
/*
- * Switching routine to store different content types
- */
+** Switching routine to store different content types
+*/
static int
store_switch (CT ct)
/*
- * Generic routine to store a MIME content.
- * (audio, video, image, text, message/rfc922)
- */
+** Generic routine to store a MIME content.
+** (audio, video, image, text, message/rfc922)
+*/
static int
store_generic (CT ct)
{
/*
- * Check if the content specifies a filename.
- * Don't bother with this for type "message"
- * (only "message/rfc822" will use store_generic).
- */
+ ** Check if the content specifies a filename.
+ ** Don't bother with this for type "message"
+ ** (only "message/rfc822" will use store_generic).
+ */
if (autosw && ct->c_type != CT_MESSAGE)
get_storeproc (ct);
/*
- * Store content of type "application"
- */
+** Store content of type "application"
+*/
static int
store_application (CT ct)
get_storeproc (ct);
/*
- * If storeproc is not defined, and the content is type
- * "application/octet-stream", we also check for various
- * attribute/value pairs which specify if this a tar file.
- */
+ ** If storeproc is not defined, and the content is type
+ ** "application/octet-stream", we also check for various
+ ** attribute/value pairs which specify if this a tar file.
+ */
if (!ct->c_storeproc && ct->c_subtype == APPLICATION_OCTETS) {
int tarP = 0, zP = 0, gzP = 0;
}
/* check for "conversions=compress" attribute */
- if ((!mh_strcasecmp (*ap, "conversions") || !mh_strcasecmp (*ap, "x-conversions"))
- && (!mh_strcasecmp (*ep, "compress") || !mh_strcasecmp (*ep, "x-compress"))) {
+ if ((!mh_strcasecmp (*ap, "conversions") ||
+ !mh_strcasecmp (*ap, "x-conversions"))
+ && (!mh_strcasecmp (*ep, "compress") ||
+ !mh_strcasecmp (*ep, "x-compress"))) {
zP = 1;
continue;
}
/* check for "conversions=gzip" attribute */
- if ((!mh_strcasecmp (*ap, "conversions") || !mh_strcasecmp (*ap, "x-conversions"))
- && (!mh_strcasecmp (*ep, "gzip") || !mh_strcasecmp (*ep, "x-gzip"))) {
+ if ((!mh_strcasecmp (*ap, "conversions") ||
+ !mh_strcasecmp (*ap, "x-conversions"))
+ && (!mh_strcasecmp (*ep, "gzip") ||
+ !mh_strcasecmp (*ep, "x-gzip"))) {
gzP = 1;
continue;
}
}
if (tarP) {
- ct->c_showproc = add (zP ? "%euncompress | tar tvf -"
- : (gzP ? "%egzip -dc | tar tvf -"
- : "%etar tvf -"), NULL);
+ ct->c_showproc = add (zP ? "%euncompress | tar tvf -" : (gzP ? "%egzip -dc | tar tvf -" : "%etar tvf -"), NULL);
if (!ct->c_storeproc) {
if (autosw) {
- ct->c_storeproc = add (zP ? "| uncompress | tar xvpf -"
- : (gzP ? "| gzip -dc | tar xvpf -"
- : "| tar xvpf -"), NULL);
+ ct->c_storeproc = add (zP ? "| uncompress | tar xvpf -" : (gzP ? "| gzip -dc | tar xvpf -" : "| tar xvpf -"), NULL);
ct->c_umask = 0022;
} else {
- ct->c_storeproc= add (zP ? "%m%P.tar.Z"
- : (gzP ? "%m%P.tar.gz"
- : "%m%P.tar"), NULL);
+ ct->c_storeproc= add (zP ? "%m%P.tar.Z" : (gzP ? "%m%P.tar.gz" : "%m%P.tar"), NULL);
}
}
}
/*
- * Store the content of a multipart message
- */
+** Store the content of a multipart message
+*/
static int
store_multi (CT ct)
/*
- * Reassemble and store the contents of a collection
- * of messages of type "message/partial".
- */
+** Reassemble and store the contents of a collection
+** of messages of type "message/partial".
+*/
static int
store_partial (CT ct)
pm = (struct partial *) p->c_ctparams;
if (pm->pm_marked != cur) {
if (pm->pm_marked == cur - 1) {
- admonish (NULL,
- "duplicate part %d of %d part multipart message",
- pm->pm_marked, hi);
+ admonish (NULL, "duplicate part %d of %d part multipart message", pm->pm_marked, hi);
continue;
}
missing_part:
- advise (NULL,
- "missing %spart %d of %d part multipart message",
- cur != hi ? "(at least) " : "", cur, hi);
+ advise (NULL, "missing %spart %d of %d part multipart message", cur != hi ? "(at least) " : "", cur, hi);
goto losing;
} else
cur++;
}
/*
- * Now cycle through the sorted list of messages of type
- * "message/partial" and save/append them to a file.
- */
+ ** Now cycle through the sorted list of messages of type
+ ** "message/partial" and save/append them to a file.
+ */
ctq = base;
ct = *ctq++;
/*
- * Store content from a message of type "message/external".
- */
+** Store content from a message of type "message/external".
+*/
static int
store_external (CT ct)
return OK;
/*
- * Check if the parameters for the external body
- * specified a filename.
- */
+ ** Check if the parameters for the external body
+ ** specified a filename.
+ */
if (autosw) {
char *cp;
}
/*
- * Since we will let the Content structure for the
- * external body substitute for the current content,
- * we temporarily change its partno (number inside
- * multipart), so everything looks right.
- */
+ ** Since we will let the Content structure for the
+ ** external body substitute for the current content,
+ ** we temporarily change its partno (number inside
+ ** multipart), so everything looks right.
+ */
p->c_partno = ct->c_partno;
/* we probably need to check if content is really there */
/*
- * Compare the numbering from two different
- * message/partials (needed for sorting).
- */
+** Compare the numbering from two different
+** message/partials (needed for sorting).
+*/
static int
ct_compar (CT *a, CT *b)
/*
- * Store contents of a message or message part to
- * a folder, a file, the standard output, or pass
- * the contents to a command.
- *
- * If the current content to be saved is a followup part
- * to a collection of messages of type "message/partial",
- * then field "p" is a pointer to the Content structure
- * to the first message/partial in the group.
- */
+** Store contents of a message or message part to
+** a folder, a file, the standard output, or pass
+** the contents to a command.
+**
+** If the current content to be saved is a followup part
+** to a collection of messages of type "message/partial",
+** then field "p" is a pointer to the Content structure
+** to the first message/partial in the group.
+*/
static int
store_content (CT ct, CT p)
char *cp, buffer[BUFSIZ];
/*
- * Do special processing for messages of
- * type "message/partial".
- *
- * We first check if this content is of type
- * "message/partial". If it is, then we need to check
- * whether it is the first and/or last in the group.
- *
- * Then if "p" is a valid pointer, it points to the Content
- * structure of the first partial in the group. So we copy
- * the file name and/or folder name from that message. In
- * this case, we also note that we will be appending.
- */
+ ** Do special processing for messages of
+ ** type "message/partial".
+ **
+ ** We first check if this content is of type
+ ** "message/partial". If it is, then we need to check
+ ** whether it is the first and/or last in the group.
+ **
+ ** Then if "p" is a valid pointer, it points to the Content
+ ** structure of the first partial in the group. So we copy
+ ** the file name and/or folder name from that message. In
+ ** this case, we also note that we will be appending.
+ */
if (ct->c_type == CT_MESSAGE && ct->c_subtype == MESSAGE_PARTIAL) {
struct partial *pm = (struct partial *) ct->c_ctparams;
last_partial = 1;
/*
- * If "p" is a valid pointer, then it points to the
- * Content structure for the first message in the group.
- * So we just copy the filename or foldername information
- * from the previous iteration of this function.
- */
+ ** If "p" is a valid pointer, then it points to the
+ ** Content structure for the first message in the group.
+ ** So we just copy the filename or foldername information
+ ** from the previous iteration of this function.
+ */
if (p) {
appending = 1;
ct->c_storage = add (p->c_storage, NULL);
}
/*
- * Get storage formatting string.
- *
- * 1) If we have storeproc defined, then use that
- * 2) Else check for a mhstore-store-<type>/<subtype> entry
- * 3) Else check for a mhstore-store-<type> entry
- * 4) Else if content is "message", use "+" (current folder)
- * 5) Else use string "%m%P.%s".
- */
+ ** Get storage formatting string.
+ **
+ ** 1) If we have storeproc defined, then use that
+ ** 2) Else check for a mhstore-store-<type>/<subtype> entry
+ ** 3) Else check for a mhstore-store-<type> entry
+ ** 4) Else if content is "message", use "+" (current folder)
+ ** 5) Else use string "%m%P.%s".
+ */
if ((cp = ct->c_storeproc) == NULL || *cp == '\0') {
CI ci = &ct->c_ctinfo;
snprintf (buffer, sizeof(buffer), "%s-store-%s/%s",
invo_name, ci->ci_type, ci->ci_subtype);
if ((cp = context_find (buffer)) == NULL || *cp == '\0') {
- snprintf (buffer, sizeof(buffer), "%s-store-%s", invo_name, ci->ci_type);
+ snprintf (buffer, sizeof(buffer), "%s-store-%s",
+ invo_name, ci->ci_type);
if ((cp = context_find (buffer)) == NULL || *cp == '\0') {
cp = ct->c_type == CT_MESSAGE ? "+" : "%m%P.%s";
}
}
/*
- * Check the beginning of storage formatting string
- * to see if we are saving content to a folder.
- */
+ ** Check the beginning of storage formatting string
+ ** to see if we are saving content to a folder.
+ */
if (*cp == '+' || *cp == '@') {
char *tmpfilenam, *folder;
}
/*
- * Parse and expand the storage formatting string
- * in `cp' into `buffer'.
- */
+ ** Parse and expand the storage formatting string
+ ** in `cp' into `buffer'.
+ */
parse_format_string (ct, cp, buffer, sizeof(buffer), dir);
/*
- * If formatting begins with '|' or '!', then pass
- * content to standard input of a command and return.
- */
+ ** If formatting begins with '|' or '!', then pass
+ ** content to standard input of a command and return.
+ */
if (buffer[0] == '|' || buffer[0] == '!')
return show_content_aux (ct, 1, 0, buffer + 1, dir);
return NOTOK;
/*
- * If necessary, link the file into a folder and remove
- * the temporary file. If this message is a partial,
- * then only do this if it is the last one in the group.
- */
+ ** If necessary, link the file into a folder and remove
+ ** the temporary file. If this message is a partial,
+ ** then only do this if it is the last one in the group.
+ */
if (ct->c_folder && (!is_partial || last_partial)) {
msgnum = output_content_folder (ct->c_folder, ct->c_storage);
unlink (ct->c_storage);
}
/*
- * Now print out the name/number of the message
- * that we are storing.
- */
+ ** Now print out the name/number of the message
+ ** that we are storing.
+ */
if (is_partial) {
if (first_partial)
fprintf (stderr, "reassembling partials ");
}
/*
- * Unless we are in the "middle" of group of message/partials,
- * we now print the name of the file, folder, and/or message
- * to which we are storing the content.
- */
+ ** Unless we are in the "middle" of group of message/partials,
+ ** we now print the name of the file, folder, and/or message
+ ** to which we are storing the content.
+ */
if (!is_partial || last_partial) {
if (ct->c_folder) {
fprintf (stderr, " to folder %s as message %d\n", ct->c_folder, msgnum);
/*
- * Output content to a file
- */
+** Output content to a file
+*/
static int
output_content_file (CT ct, int appending)
FILE *fp;
/*
- * If the pathname is absolute, make sure
- * all the relevant directories exist.
- */
+ ** If the pathname is absolute, make sure
+ ** all the relevant directories exist.
+ */
if (strchr(ct->c_storage, '/')
&& make_intermediates (ct->c_storage) == NOTOK)
return NOTOK;
}
/*
- * Send to standard output
- */
+ ** Send to standard output
+ */
if (!strcmp (ct->c_storage, "-")) {
int gd;
}
} else {
/*
- * Open output file
- */
+ ** Open output file
+ */
if ((fp = fopen (ct->c_storage, appending ? "a" : "w")) == NULL) {
advise (ct->c_storage, "unable to fopen for %s",
appending ? "appending" : "writing");
}
/*
- * Filter the header fields of the initial enclosing
- * message/partial into the file.
- */
+ ** Filter the header fields of the initial enclosing
+ ** message/partial into the file.
+ */
if (ct->c_type == CT_MESSAGE && ct->c_subtype == MESSAGE_PARTIAL) {
struct partial *pm = (struct partial *) ct->c_ctparams;
}
/*
- * Copy a few of the header fields of the initial
- * enclosing message/partial into the file.
- */
+ ** Copy a few of the header fields of the initial
+ ** enclosing message/partial into the file.
+ */
filterstate = 0;
if (ct->c_type == CT_MESSAGE && ct->c_subtype == MESSAGE_PARTIAL) {
struct partial *pm = (struct partial *) ct->c_ctparams;
buffer[diff] = '\0';
}
/*
- * If this is the first content of a group of
- * message/partial contents, then we only copy a few
- * of the header fields of the enclosed message.
- */
+ ** If this is the first content of a group of
+ ** message/partial contents, then we only copy a few
+ ** of the header fields of the enclosed message.
+ */
if (filterstate) {
switch (buffer[0]) {
case ' ':
/*
- * Add a file to a folder.
- *
- * Return the new message number of the file
- * when added to the folder. Return -1, if
- * there is an error.
- */
+** Add a file to a folder.
+**
+** Return the new message number of the file
+** when added to the folder. Return -1, if
+** there is an error.
+*/
static int
output_content_folder (char *folder, char *filename)
folder_free (mp);
/*
- * Return msgnum. We are relying on the fact that
- * msgnum will be -1, if folder_addmsg() had an error.
- */
+ ** Return msgnum. We are relying on the fact that
+ ** msgnum will be -1, if folder_addmsg() had an error.
+ */
return msgnum;
}
/*
- * Parse and expand the storage formatting string
- * pointed to by "cp" into "buffer".
- */
+** Parse and expand the storage formatting string
+** pointed to by "cp" into "buffer".
+*/
static int
parse_format_string (CT ct, char *cp, char *buffer, int buflen, char *dir)
CI ci = &ct->c_ctinfo;
/*
- * If storage string is "-", just copy it, and
- * return (send content to standard output).
- */
+ ** If storage string is "-", just copy it, and
+ ** return (send content to standard output).
+ */
if (cp[0] == '-' && cp[1] == '\0') {
strncpy (buffer, cp, buflen);
return 0;
bp[0] = '\0';
/*
- * If formatting string is a pathname that doesn't
- * begin with '/', then preface the path with the
- * appropriate directory.
- */
+ ** If formatting string is a pathname that doesn't
+ ** begin with '/', then preface the path with the
+ ** appropriate directory.
+ */
if (*cp != '/' && *cp != '|' && *cp != '!') {
snprintf (bp, buflen, "%s/", dir[1] ? dir : "");
len = strlen (bp);
switch (*++cp) {
case 'a':
/*
- * Insert parameters from Content-Type.
- * This is only valid for '|' commands.
- */
+ ** Insert parameters from Content-Type.
+ ** This is only valid for '|' commands.
+ */
if (buffer[0] != '|' && buffer[0] != '!') {
*bp++ = *--cp;
*bp = '\0';
/*
- * Check if the content specifies a filename
- * in its MIME parameters.
- */
+** Check if the content specifies a filename
+** in its MIME parameters.
+*/
static void
get_storeproc (CT ct)
CI ci = &ct->c_ctinfo;
/*
- * If the storeproc has already been defined,
- * we just return (for instance, if this content
- * is part of a "message/external".
- */
+ ** If the storeproc has already been defined,
+ ** we just return (for instance, if this content
+ ** is part of a "message/external".
+ */
if (ct->c_storeproc)
return;
/*
- * Check the attribute/value pairs, for the attribute "name".
- * If found, do a few sanity checks and copy the value into
- * the storeproc.
- */
+ ** Check the attribute/value pairs, for the attribute "name".
+ ** If found, do a few sanity checks and copy the value into
+ ** the storeproc.
+ */
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
if (!mh_strcasecmp (*ap, "name")
&& *(cp = *ep) != '/'
/*
- * Copy some of the header fields of the initial message/partial
- * message into the header of the reassembled message.
- */
+** Copy some of the header fields of the initial message/partial
+** message into the header of the reassembled message.
+*/
static int
copy_some_headers (FILE *out, CT ct)
while (hp) {
/*
- * A few of the header fields of the enclosing
- * messages are not copied.
- */
+ ** A few of the header fields of the enclosing
+ ** messages are not copied.
+ */
if (!uprf (hp->name, XXX_FIELD_PRF)
&& mh_strcasecmp (hp->name, VRSN_FIELD)
&& mh_strcasecmp (hp->name, "Subject")
/*
- * mhtest.c -- test harness for MIME routines
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhtest.c -- test harness for MIME routines
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
{ "help", 0 },
/*
- * switches for debugging
- */
+** switches for debugging
+*/
#define DEBUGSW 12
{ "debug", -5 },
{ NULL, 0 }
extern int userrs;
/*
- * This is currently needed to keep mhparse happy.
- * This needs to be changed.
- */
+** This is currently needed to keep mhparse happy.
+** This needs to be changed.
+*/
pid_t xpid = 0;
int debugsw = 0;
void freects_done (int) NORETURN;
/*
- * static prototypes
- */
+** static prototypes
+*/
static int write_content (CT *, char *);
static RETSIGTYPE pipeser (int);
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
+ snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
else
folder = pluspath (cp);
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
/* null terminate the list of acceptable parts/types */
cache_private = getcpy (m_maildir (cache_private));
/*
- * Check for storage directory. If specified,
- * then store temporary files there. Else we
- * store them in standard nmh directory.
- */
+ ** Check for storage directory. If specified,
+ ** then store temporary files there. Else we
+ ** store them in standard nmh directory.
+ */
if ((cp = context_find (nmhstorage)) && *cp)
tmp = concat (cp, "/", invo_name, NULL);
else
adios (NULL, "cannot specify msg and file at same time!");
/*
- * check if message is coming from file
- */
+ ** check if message is coming from file
+ */
if (file) {
if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
adios (NULL, "out of memory");
*ctp++ = ct;
} else {
/*
- * message(s) are coming from a folder
- */
+ ** message(s) are coming from a folder
+ */
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
SIGNAL (SIGPIPE, pipeser);
/*
- * Get the associated umask for the relevant contents.
- */
+ ** Get the associated umask for the relevant contents.
+ */
for (ctp = cts; *ctp; ctp++) {
struct stat st;
}
/*
- * Write the content to a file
- */
+ ** Write the content to a file
+ */
write_content (cts, outfile);
/* Now free all the structures for the content */
/*
- * msgchk.c -- check for mail
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** msgchk.c -- check for mail
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/mts.h>
};
/*
- * Maximum numbers of users we can check (plus
- * one for the NULL vector at the end).
- */
+** Maximum numbers of users we can check (plus
+** one for the NULL vector at the end).
+*/
#define MAXVEC 51
#define NT_NONE 0x0
/*
- * static prototypes
- */
+** static prototypes
+*/
static int donote (char *, int);
static int checkmail (char *, char *, int, int, int);
return NT_NMAI;
}
- return 0; /* Before 1999-07-15, garbage was returned if control got here. */
+ /* Before 1999-07-15, garbage was returned if control got here. */
+ return 0;
}
char buffer[BUFSIZ];
struct stat st;
- snprintf (buffer, sizeof(buffer), "%s/%s", mmdfldir[0] ? mmdfldir : home, mmdflfil[0] ? mmdflfil : user);
+ snprintf (buffer, sizeof(buffer), "%s/%s",
+ mmdfldir[0] ? mmdfldir : home,
+ mmdflfil[0] ? mmdflfil : user);
if (datesw) {
st.st_size = 0;
st.st_atime = st.st_mtime = 0;
if (notifysw & NT_MAIL) {
printf (personal ? "You have " : "%s has ", user);
if (mf & UUCPOK)
- printf ("%s old-style bell", mf & UUCPOLD ? "old" : "new");
+ printf ("%s old-style bell",
+ mf & UUCPOLD ? "old" : "new");
if ((mf & UUCPOK) && (mf & MMDFOK))
printf (" and ");
if (mf & MMDFOK)
else {
if (notifysw & NT_NMAI)
printf (personal ? "You don't %s%s" : "%s doesn't %s",
- personal ? "" : user, "have any mail waiting");
+ personal ? "" : user,
+ "have any mail waiting");
else
notifysw = 0;
/*
- * new.c -- as new, list all folders with unseen messages
- * -- as fnext, move to next folder with unseen messages
- * -- as fprev, move to previous folder with unseen messages
- * -- as unseen, scan all unseen messages
- * This code is Copyright (c) 2008, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- *
- * Inspired by Luke Mewburn's new: http://www.mewburn.net/luke/src/new
- */
+** new.c -- as new, list all folders with unseen messages
+** -- as fnext, move to next folder with unseen messages
+** -- as fprev, move to previous folder with unseen messages
+** -- as unseen, scan all unseen messages
+** This code is Copyright (c) 2008, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+**
+** Inspired by Luke Mewburn's new: http://www.mewburn.net/luke/src/new
+*/
#include <sys/types.h>
static enum { NEW, FNEXT, FPREV, UNSEEN } run_mode = NEW;
-/* check_folders uses this to maintain state with both .folders list of
- * folders and with crawl_folders. */
+/*
+** check_folders uses this to maintain state with both .folders list of
+** folders and with crawl_folders.
+*/
struct list_state {
struct node **first, **cur_node;
size_t *maxlen;
return FALSE;
}
-/* Return the string list of message numbers from the sequences file, or NULL
- * if none. */
+/*
+** Return the string list of message numbers from the sequences file,
+** or NULL if none.
+*/
static char *
get_msgnums(char *folder, char *sequences[])
{
if (state == FLDPLUS) {
cp = getcpy (field);
while (state == FLDPLUS) {
- state = m_getfld (state, name, field,
- sizeof(field), fp);
+ state = m_getfld (state, name,
+ field,
+ sizeof(field),
+ fp);
cp = add (field, cp);
}
- /* Here's where we differ from seq_public: if it's in a
- * sequence we want, save the list of messages. */
+ /*
+ ** Here's where we differ from
+ ** seq_public: if it's in a
+ ** sequence we want, save the list
+ ** of messages.
+ */
if (seq_in_list(name, sequences)) {
this_msgnums = trimcpy(cp);
if (msgnums == NULL) {
msgnums = this_msgnums;
} else {
old_msgnums = msgnums;
- msgnums = concat(old_msgnums, " ",
- this_msgnums, (void *)NULL);
+ msgnums = concat(old_msgnums, " ", this_msgnums, (void *)NULL);
free(old_msgnums);
free(this_msgnums);
}
msgnums = this_msgnums;
} else {
old_msgnums = msgnums;
- msgnums = concat(old_msgnums, " ",
- this_msgnums, (void *)NULL);
+ msgnums = concat(old_msgnums, " ", this_msgnums, (void *)NULL);
free(old_msgnums);
free(this_msgnums);
}
return msgnums;
}
-/* Check `folder' (of length `len') for interesting messages, filling in the
- * list in `b'. */
+/*
+** Check `folder' (of length `len') for interesting messages,
+** filling in the list in `b'.
+*/
static void
check_folder(char *folder, size_t len, struct list_state *b)
{
return TRUE;
}
-/* Scan folders, returning:
- * first -- list of nodes for all folders which have desired messages;
- * if the current folder is listed in .folders, it is also in
- * the list regardless of whether it has any desired messages
- * last -- last node in list
- * cur_node -- node of current folder, if listed in .folders
- * maxlen -- length of longest folder name
- *
- * `cur' points to the name of the current folder, `folders' points to the
- * name of a .folder (if NULL, crawl all folders), and `sequences' points to
- * the array of sequences for which to look.
- *
- * An empty list is returned as first=last=NULL.
- */
+/*
+** Scan folders, returning:
+** first -- list of nodes for all folders which have desired messages;
+** if the current folder is listed in .folders, it is also in
+** the list regardless of whether it has any desired messages
+** last -- last node in list
+** cur_node -- node of current folder, if listed in .folders
+** maxlen -- length of longest folder name
+**
+** `cur' points to the name of the current folder, `folders' points to the
+** name of a .folder (if NULL, crawl all folders), and `sequences' points to
+** the array of sequences for which to look.
+**
+** An empty list is returned as first=last=NULL.
+*/
static void
check_folders(struct node **first, struct node **last,
struct node **cur_node, size_t *maxlen,
return result;
}
-/* Return a struct node for the folder to change to. This is the next
- * (previous, if FPREV mode) folder with desired messages, or the current
- * folder if no folders have desired. If NEW or UNSEEN mode, print the
- * output but don't change folders.
- *
- * n_name is the folder to change to, and n_field is the string list of
- * desired message numbers.
- */
+/*
+** Return a struct node for the folder to change to. This is the next
+** (previous, if FPREV mode) folder with desired messages, or the current
+** folder if no folders have desired. If NEW or UNSEEN mode, print the
+** output but don't change folders.
+**
+** n_name is the folder to change to, and n_field is the string list of
+** desired message numbers.
+*/
static struct node *
doit(char *cur, char *folders, char *sequences[])
{
}
check_folders(&first, &last, &cur_node, &folder_len, cur,
- folders, sequences);
+ folders, sequences);
if (run_mode == FNEXT || run_mode == FPREV) {
if (first == NULL) {
/* No folders at all... */
return NULL;
} else if (first->n_next == NULL) {
- /* We have only one node; any desired messages in it? */
+ /*
+ ** We have only one node; any desired messages in it?
+ */
if (first->n_field == NULL) {
return NULL;
} else {
return first;
}
} else if (cur_node == NULL) {
- /* Current folder is not listed in .folders, return first. */
+ /*
+ ** Current folder is not listed in .folders,
+ ** return first.
+ */
return first;
}
} else if (run_mode == UNSEEN) {
node != NULL;
prev = node, node = node->n_next) {
if (run_mode == FNEXT) {
- /* If we have a previous node and it is the current
- * folder, return this node. */
+ /*
+ ** If we have a previous node and it is the current
+ ** folder, return this node.
+ */
if (prev != NULL && strcmp(prev->n_name, cur) == 0) {
return node;
}
} else if (run_mode == FPREV) {
if (strcmp(node->n_name, cur) == 0) {
- /* Found current folder in fprev mode; if we have a
- * previous node in the list, return it; else return
- * the last node. */
+ /*
+ ** Found current folder in fprev mode;
+ ** if we have a previous node in the list,
+ ** return it; else return the last node.
+ */
if (prev == NULL) {
return last;
}
}
fflush(stdout);
- /* TODO: Split enough of scan.c out so that we can call it here. */
- command = concat("scan +", node->n_name, " ", sequences_s,
- (void *)NULL);
+ /*
+ ** TODO: Split enough of scan.c out so that we can
+ ** call it here.
+ */
+ command = concat("scan +", node->n_name, " ",
+ sequences_s, (void *)NULL);
system(command);
free(command);
} else {
}
}
- /* If we're fnext, we haven't checked the last node yet. If it's the
- * current folder, return the first node. */
+ /*
+ ** If we're fnext, we haven't checked the last node yet. If it's the
+ ** current folder, return the first node.
+ */
if (run_mode == FNEXT && strcmp(last->n_name, cur) == 0) {
return first;
}
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (help, sizeof(help), "%s [switches] [sequences]",
- invo_name);
+ snprintf (help, sizeof(help),
+ "%s [switches] [sequences]",
+ invo_name);
print_help (help, switches, 1);
done (1);
case VERSIONSW:
case FOLDERSSW:
if (!(folders = *argp++) || *folders == '-')
- adios(NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
continue;
case MODESW:
if (!(invo_name = *argp++) || *invo_name == '-')
- adios(NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
invo_name = r1bindex(invo_name, '/');
continue;
}
}
if (run_mode == UNSEEN) {
- /* All the scan(1)s it runs change the current folder, so we
- * need to put it back. Unfortunately, context_replace lamely
- * ignores the new value you give it if it is the same one it
- * has in memory. So, we'll be lame, too. I'm not sure if i
- * should just change context_replace... */
+ /*
+ ** All the scan(1)s it runs change the current folder, so we
+ ** need to put it back. Unfortunately, context_replace lamely
+ ** ignores the new value you give it if it is the same one it
+ ** has in memory. So, we'll be lame, too. I'm not sure if i
+ ** should just change context_replace...
+ */
context_replace(pfolder, "defeat_context_replace_optimization");
}
/*
- * packf.c -- pack a nmh folder into a file
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** packf.c -- pack a nmh folder into a file
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
+ snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
adios (NULL, "only one folder at a time!");
folder = pluspath (cp);
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
if (!file)
file = path (file, TFILE);
/*
- * Check if file to be created (or appended to)
- * exists. If not, ask for confirmation.
- */
+ ** Check if file to be created (or appended to)
+ ** exists. If not, ask for confirmation.
+ */
if (stat (file, &st) == NOTOK) {
if (errno != ENOENT)
adios (file, "error on file");
seq_setprev (mp); /* set the previous-sequence */
/* open and lock new maildrop file */
- if ((md = mbx_open(file, mbx_style, getuid(), getgid(), m_gmprot())) == NOTOK)
+ if ((md = mbx_open(file, mbx_style, getuid(), getgid(), m_gmprot()))
+ == NOTOK)
adios (file, "unable to open");
/* copy all the SELECTED messages to the file */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
if (is_selected(mp, msgnum)) {
- if ((fd = open (msgnam = m_name (msgnum), O_RDONLY)) == NOTOK) {
+ if ((fd = open (msgnam = m_name (msgnum), O_RDONLY))
+ == NOTOK) {
admonish (msgnam, "unable to read message");
break;
}
- if (mbx_copy (file, mbx_style, md, fd, mapping, NULL, 1) == NOTOK)
+ if (mbx_copy(file, mbx_style, md, fd, mapping, NULL, 1)
+ == NOTOK)
adios (file, "error writing to file");
close (fd);
/*
- * pick.c -- search for messages by content
- *
- * This code is Copyright (c) 2002, 2008, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** pick.c -- search for messages by content
+**
+** This code is Copyright (c) 2002, 2008, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/tws.h>
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
+ snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
print_help (buf, switches, 1);
listsw = 0; /* HACK */
done (1);
case SRCHSW:
vec[vecp++] = --cp;
pattern:
- if (!(cp = *argp++))/* allow -xyz arguments */
- adios (NULL, "missing argument to %s", argp[-2]);
+ if (!(cp = *argp++)) /* allow -xyz arguments */
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
vec[vecp++] = cp;
continue;
case OTHRSW:
case SEQSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
/* check if too many sequences specified */
if (seqp >= NUMATTRS)
else
folder = pluspath (cp);
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
vec[vecp] = NULL;
free (path ("./", TFOLDER));
/*
- * If we didn't specify which messages to search,
- * then search the whole folder.
- */
+ ** If we didn't specify which messages to search,
+ ** then search the whole folder.
+ */
if (!msgs.size)
app_msgarg(&msgs, "all");
seq_setprev (mp); /* set the previous-sequence */
/*
- * If we aren't saving the results to a sequence,
- * we default to list the results.
- */
+ ** If we aren't saving the results to a sequence,
+ ** we default to list the results.
+ */
if (listsw == -1)
listsw = !seqp;
if (publicsw == 1 && is_readonly(mp))
- adios (NULL, "folder %s is read-only, so -public not allowed", folder);
+ adios (NULL, "folder %s is read-only, so -public not allowed",
+ folder);
if (!pcompile (vec, NULL))
done (1);
lo = mp->lowsel;
hi = mp->hghsel;
- /* If printing message numbers to standard out, force line buffering on.
- */
+ /*
+ ** If printing message numbers to standard out,
+ ** force line buffering on.
+ */
if (listsw)
setvbuf (stdout, NULL, _IOLBF, 0);
/*
- * Scan through all the SELECTED messages and check for a
- * match. If the message does not match, then unselect it.
- */
+ ** Scan through all the SELECTED messages and check for a
+ ** match. If the message does not match, then unselect it.
+ */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected (mp, msgnum)) {
if ((fp = fopen (cp = m_name (msgnum), "r")) == NULL)
seqs[seqp] = NULL;
/*
- * Add the matching messages to sequences
- */
+ ** Add the matching messages to sequences
+ */
for (seqp = 0; seqs[seqp]; seqp++)
if (!seq_addsel (mp, seqs[seqp], publicsw, zerosw))
done (1);
/*
- * Print total matched if not printing each matched message number.
- */
+ ** Print total matched if not printing each matched message number.
+ */
if (!listsw) {
printf ("%d hit%s\n", mp->numsel, mp->numsel == 1 ? "" : "s");
}
/*
- * picksbr.c -- routines to help pick along...
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** picksbr.c -- routines to help pick along...
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/tws.h>
/* DEFINITIONS FOR PATTERN MATCHING */
/*
- * We really should be using re_comp() and re_exec() here. Unfortunately,
- * pick advertises that lowercase characters matches characters of both
- * cases. Since re_exec() doesn't exhibit this behavior, we are stuck
- * with this version. Furthermore, we need to be able to save and restore
- * the state of the pattern matcher in order to do things "efficiently".
- *
- * The matching power of this algorithm isn't as powerful as the re_xxx()
- * routines (no \(xxx\) and \n constructs). Such is life.
- */
+** We really should be using re_comp() and re_exec() here. Unfortunately,
+** pick advertises that lowercase characters matches characters of both
+** cases. Since re_exec() doesn't exhibit this behavior, we are stuck
+** with this version. Furthermore, we need to be able to save and restore
+** the state of the pattern matcher in order to do things "efficiently".
+**
+** The matching power of this algorithm isn't as powerful as the re_xxx()
+** routines (no \(xxx\) and \n constructs). Such is life.
+*/
#define CCHR 2
#define CDOT 4
};
/*
- * DEFINITIONS FOR NEXUS
- */
+** DEFINITIONS FOR NEXUS
+*/
#define nxtarg() (*argp ? *argp++ : NULL)
#define prvarg() argp--
static struct nexus *head;
/*
- * prototypes for date routines
- */
+** prototypes for date routines
+*/
static struct tws *tws_parse();
static struct tws *tws_special();
/*
- * static prototypes
- */
+** static prototypes
+*/
static void PRaction();
static int gcompile();
static int advance();
strncpy(temp, parswit[i].sw, sizeof(temp));
temp[sizeof(temp) - 1] = '\0';
dp = *brkstring (temp, " ", NULL);
- header: ;
- if (!(cp = nxtarg ())) {/* allow -xyz arguments */
- padvise (NULL, "missing argument to %s", argp[-2]);
+header: ;
+ if (!(cp = nxtarg ())) { /* allow -xyz arguments */
+ padvise (NULL, "missing argument to %s",
+ argp[-2]);
return NULL;
}
n = newnexus (GREPaction);
n->n_header = 1;
- snprintf (buffer, sizeof(buffer), "^%s[ \t]*:.*%s", dp, cp);
+ snprintf (buffer, sizeof(buffer), "^%s[ \t]*:.*%s",
+ dp, cp);
dp = buffer;
goto pattern;
case PRSRCH:
n = newnexus (GREPaction);
n->n_header = 0;
- if (!(cp = nxtarg ())) {/* allow -xyz arguments */
- padvise (NULL, "missing argument to %s", argp[-2]);
+ if (!(cp = nxtarg ())) { /* allow -xyz arguments */
+ padvise (NULL, "missing argument to %s",
+ argp[-2]);
return NULL;
}
dp = cp;
- pattern: ;
+pattern: ;
if (!gcompile (n, dp)) {
- padvise (NULL, "pattern error in %s %s", argp[-2], cp);
+ padvise (NULL, "pattern error in %s %s",
+ argp[-2], cp);
return NULL;
}
n->n_patbuf = getcpy (dp);
case PRDATF:
if (!(datesw = nxtarg ()) || *datesw == '-') {
- padvise (NULL, "missing argument to %s", argp[-2]);
+ padvise (NULL, "missing argument to %s",
+ argp[-2]);
return NULL;
}
return nexp3 ();
case PRAFTR:
case PRBEFR:
- if (!(cp = nxtarg ())) {/* allow -xyz arguments */
- padvise (NULL, "missing argument to %s", argp[-2]);
+ if (!(cp = nxtarg ())) { /* allow -xyz arguments */
+ padvise (NULL, "missing argument to %s",
+ argp[-2]);
return NULL;
}
n = newnexus (TWSaction);
n->n_datef = datesw;
if (!tcompile (cp, &n->n_tws, n->n_after = i == PRAFTR)) {
- padvise (NULL, "unable to parse %s %s", argp[-2], cp);
+ padvise (NULL, "unable to parse %s %s",
+ argp[-2], cp);
return NULL;
}
return n;
free (bp), bp = NULL;
bp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, fp);
+ state = m_getfld (state, name, buf,
+ sizeof buf, fp);
bp = add (buf, bp);
}
if (!mh_strcasecmp (name, n->n_datef))
/*
- * prompter.c -- simple prompting editor front-end
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** prompter.c -- simple prompting editor front-end
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
static jmp_buf sigenv;
/*
- * prototypes
- */
+** prototypes
+*/
int getln (char *, int);
static int chrcnv (char *);
static void chrdsp (char *, char);
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buffer, sizeof(buffer), "%s [switches] file",
- invo_name);
+ snprintf (buffer, sizeof(buffer),
+ "%s [switches] file",
+ invo_name);
print_help (buffer, switches, 1);
done (1);
case VERSIONSW:
doteof = 0;
continue;
}
- } else {
- if (!drft)
- drft = cp;
+ } else if (!drft) {
+ drft = cp;
}
if (!drft)
adios (drft, "unable to open");
tfile = m_mktemp2(NULL, invo_name, NULL, &out);
- if (tfile == NULL) adios("prompter", "unable to create temporary file");
+ if (tfile == NULL)
+ adios("prompter", "unable to create temporary file");
chmod (tmpfil, 0600);
strncpy (tmpfil, tfile, sizeof(tmpfil));
/*
- * Are we changing the kill or erase character?
- */
+ ** Are we changing the kill or erase character?
+ */
if (killp || erasep) {
#ifdef HAVE_TERMIOS_H
cc_t save_erase, save_kill;
fflush (stdout);
/*
- * We set the kill and erase character back to original
- * setup in terminal structure so we can easily
- * restore it upon exit.
- */
+ ** We set the kill and erase character back to original
+ ** setup in terminal structure so we can easily
+ ** restore it upon exit.
+ */
KILL = save_kill;
ERASE = save_erase;
}
SIGNAL2 (SIGINT, intrser);
/*
- * Loop through the lines of the draft skeleton.
- */
+ ** Loop through the lines of the draft skeleton.
+ */
for (state = FLD;;) {
switch (state = m_getfld (state, name, field, sizeof(field), in)) {
case FLD:
case FLDEOF:
case FLDPLUS:
/*
- * Check if the value of field contains anything
- * other than space or tab.
- */
+ ** Check if the value of field contains
+ ** anything other than space or tab.
+ */
for (cp = field; *cp; cp++)
if (*cp != ' ' && *cp != '\t')
break;
/*
- * rcvdist.c -- asynchronously redistribute messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** rcvdist.c -- asynchronously redistribute messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/fmt_scan.h>
static char tmpfil[BUFSIZ] = "";
/*
- * prototypes
- */
+** prototypes
+*/
static void rcvdistout (FILE *, char *, char *);
static void unlink_done (int) NORETURN;
continue;
case HELPSW:
- snprintf (buf, sizeof(buf),
- "%s [switches] [switches for postproc] address ...",
- invo_name);
+ snprintf (buf, sizeof(buf), "%s [switches] [switches for postproc] address ...", invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
}
if (addrs == NULL)
- adios (NULL, "usage: %s [switches] [switches for postproc] address ...",
- invo_name);
+ adios (NULL, "usage: %s [switches] [switches for postproc] address ...", invo_name);
umask (~m_gmprot ());
cp = new_fs (form ? form : rcvdistcomps, NULL, NULL);
format_len = strlen (cp);
ncomps = fmt_compile (cp, &fmt) + 1;
- if (!(nxtbuf = compbuffers = (char **) calloc ((size_t) ncomps, sizeof(char *))))
+ if (!(nxtbuf = compbuffers =
+ (char **) calloc ((size_t) ncomps, sizeof(char *))))
adios (NULL, "unable to allocate component buffers");
- if (!(savecomp = used_buf = (struct comp **) calloc ((size_t) (ncomps + 1), sizeof(struct comp *))))
+ if (!(savecomp = used_buf =
+ (struct comp **) calloc ((size_t) (ncomps + 1),
+ sizeof(struct comp *))))
adios (NULL, "unable to allocate component buffer stack");
savecomp += ncomps + 1;
*--savecomp = 0;
if (cptr->c_type & CT_ADDR) {
cp[i] = 0;
cp = add (",\n\t", cp);
- }
- else
+ } else
cp = add ("\t", cp);
}
cptr->c_text = add (tmpbuf, cp);
fclose (out);
free (scanl);
- for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++); nxtbuf++, i--)
+ for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++);
+ nxtbuf++, i--)
free (cptr->c_text);
while (i-- > 0)
free (*nxtbuf++);
/*
- * rcvpack.c -- append message to a file
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** rcvpack.c -- append message to a file
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/dropsbr.h>
};
/*
- * default format in which to save messages
- */
+** default format in which to save messages
+*/
static int mbx_style = MBOX_FORMAT;
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] file", invo_name);
+ snprintf (buf, sizeof(buf),
+ "%s [switches] file",
+ invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
rewind (stdin);
/* open and lock the file */
- if ((md = mbx_open (file, mbx_style, getuid(), getgid(), m_gmprot())) == NOTOK)
+ if ((md = mbx_open (file, mbx_style, getuid(), getgid(), m_gmprot()))
+ == NOTOK)
done (RCV_MBX);
/* append the message */
- if (mbx_copy (file, mbx_style, md, fileno(stdin), 1, NULL, 0) == NOTOK) {
+ if (mbx_copy (file, mbx_style, md, fileno(stdin), 1, NULL, 0)
+ == NOTOK) {
mbx_close (file, md);
done (RCV_MBX);
}
/*
- * rcvstore.c -- asynchronously add mail to a folder
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** rcvstore.c -- asynchronously add mail to a folder
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
/*
- * name of temporary file to store incoming message
- */
+** name of temporary file to store incoming message
+*/
static char *tmpfilenam = NULL;
static void unlink_done(int) NORETURN;
else
folder = pluspath (cp);
} else {
- adios (NULL, "usage: %s [+folder] [switches]", invo_name);
+ adios (NULL, "usage: %s [+folder] [switches]",
+ invo_name);
}
}
}
/*
- * read folder and create message structure
- */
+ ** read folder and create message structure
+ */
if (!(mp = folder_read (folder)))
adios (NULL, "unable to read folder %s", folder);
/*
- * Link message into folder, and possibly add
- * to the Unseen-Sequence's.
- */
- if ((msgnum = folder_addmsg (&mp, tmpfilenam, 0, unseensw, 0, 0, (char *)0)) == -1)
+ ** Link message into folder, and possibly add
+ ** to the Unseen-Sequence's.
+ */
+ if ((msgnum = folder_addmsg (&mp, tmpfilenam, 0, unseensw, 0, 0,
+ (char *)0)) == -1)
done (1);
/*
- * Add the message to any extra sequences
- * that have been specified.
- */
+ ** Add the message to any extra sequences
+ ** that have been specified.
+ */
for (seqp = 0; seqs[seqp]; seqp++) {
if (!seq_addmsg (mp, seqs[seqp], msgnum, publicsw, zerosw))
done (1);
}
/*
- * Clean up and exit
- */
+** Clean up and exit
+*/
static void
unlink_done(int status)
{
/*
- * rcvtty.c -- a rcvmail program (a lot like rcvalert) handling IPC ttys
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** rcvtty.c -- a rcvmail program (a lot like rcvalert) handling IPC ttys
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
/* Changed to use getutent() and friends. Assumes that when getutent() exists,
- * a number of other things also exist. Please check.
- * Ruud de Rooij <ruud@ruud.org> Sun, 28 May 2000 17:28:55 +0200
- */
+** a number of other things also exist. Please check.
+** Ruud de Rooij <ruud@ruud.org> Sun, 28 May 2000 17:28:55 +0200
+*/
#include <h/mh.h>
#include <h/signals.h>
static char *format = NULL;
/*
- * external prototypes
- */
+** external prototypes
+*/
char *getusername(void);
/*
- * static prototypes
- */
+** static prototypes
+*/
static RETSIGTYPE alrmser (int);
static int message_fd (char **);
static int header_fd (void);
continue;
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [command ...]", invo_name);
+ snprintf (buf, sizeof(buf),
+ "%s [command ...]",
+ invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
while ((utp = getutent()) != NULL) {
if (
#ifdef HAVE_STRUCT_UTMP_UT_TYPE
- utp->ut_type == USER_PROCESS
- &&
+ utp->ut_type == USER_PROCESS &&
#endif
- utp->ut_name[0] != 0
- && utp->ut_line[0] != 0
- && strncmp (user, utp->ut_name, sizeof(utp->ut_name)) == 0) {
+ utp->ut_name[0] != 0 && utp->ut_line[0] != 0
+ && strncmp (user, utp->ut_name,
+ sizeof(utp->ut_name)) == 0) {
strncpy (tty, utp->ut_line, sizeof(utp->ut_line));
alert (tty, md);
}
exit (RCV_MBX);
while (fread ((char *) &ut, sizeof(ut), 1, uf) == 1)
if (ut.ut_name[0] != 0
- && strncmp (user, ut.ut_name, sizeof(ut.ut_name)) == 0) {
+ && strncmp (user, ut.ut_name,
+ sizeof(ut.ut_name)) == 0) {
strncpy (tty, ut.ut_line, sizeof(ut.ut_line));
alert (tty, md);
}
/* parent process */
if (!setjmp (myctx)) {
SIGNAL (SIGALRM, alrmser);
- bytes = fstat(fileno (stdin), &st) != NOTOK ? (int) st.st_size : 100;
+ bytes = fstat(fileno (stdin), &st) != NOTOK ?
+ (int) st.st_size : 100;
/* amount of time to wait depends on message size */
if (bytes <= 100) {
return fd;
} else {
/*
- * Ruthlessly kill the child and anything
- * else in its process group.
- */
+ ** Ruthlessly kill the child and anything
+ ** else in its process group.
+ */
KILLPG(child_id, SIGKILL);
}
close (fd);
snprintf (ttyspec, sizeof(ttyspec), "/dev/%s", tty);
/*
- * The mask depends on whether we are checking for
- * write permission based on `biff' or `mesg'.
- */
+ ** The mask depends on whether we are checking for
+ ** write permission based on `biff' or `mesg'.
+ */
mask = biff ? S_IEXEC : (S_IWRITE >> 3);
if (stat (ttyspec, &st) == NOTOK || (st.st_mode & mask) == 0)
return;
/*
- * refile.c -- move or link message(s) from a source folder
- * -- into one or more destination folders
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** refile.c -- move or link message(s) from a source folder
+** -- into one or more destination folders
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
};
/*
- * static prototypes
- */
+** static prototypes
+*/
static void opnfolds (struct st_fold *, int);
static void clsfolds (struct st_fold *, int);
static void remove_files (int, char **);
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
adios (NULL, "-%s unknown\n", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [msgs] [switches] +folder ...",
- invo_name);
+ snprintf (buf, sizeof(buf), "%s [msgs] [switches] +folder ...", invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
adios (NULL, "only one source folder at a time!");
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
- folder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
- *cp != '@' ? TFOLDER : TSUBCWF);
+ folder = path (*cp == '+' || *cp == '@' ?
+ cp + 1 : cp,
+ *cp != '@' ?
+ TFOLDER : TSUBCWF);
continue;
case FILESW:
if (filep > NFOLDERS)
- adios (NULL, "only %d files allowed!", NFOLDERS);
+ adios (NULL, "only %d files allowed!",
+ NFOLDERS);
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
files[filep++] = path (cp, TFILE);
continue;
case RPROCSW:
if (!(rmmproc = *argp++) || *rmmproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case NRPRCSW:
rmmproc = NULL;
}
if (*cp == '+' || *cp == '@') {
if (foldp > NFOLDERS)
- adios (NULL, "only %d folders allowed!", NFOLDERS);
+ adios (NULL, "only %d folders allowed!",
+ NFOLDERS);
folders[foldp++].f_name =
pluspath (cp);
} else
#endif /* WHATNOW */
/*
- * We are refiling a file to the folders
- */
+ ** We are refiling a file to the folders
+ */
if (filep > 0) {
if (folder || msgs.size)
adios (NULL, "use -file or some messages, not both");
opnfolds (folders, foldp);
/* Link all the selected messages into destination folders.
- *
- * This causes the add hook to be run for messages that are
- * linked into another folder. The refile hook is run for
- * messages that are moved to another folder.
- */
+ **
+ ** This causes the add hook to be run for messages that are
+ ** linked into another folder. The refile hook is run for
+ ** messages that are moved to another folder.
+ */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected (mp, msgnum)) {
cp = getcpy (m_name (msgnum));
}
/*
- * This is a hack. If we are using an external rmmproc,
- * then save the current folder to the context file,
- * so the external rmmproc will remove files from the correct
- * directory. This should be moved to folder_delmsgs().
- */
+ ** This is a hack. If we are using an external rmmproc,
+ ** then save the current folder to the context file,
+ ** so the external rmmproc will remove files from the correct
+ ** directory. This should be moved to folder_delmsgs().
+ */
if (rmmproc) {
context_replace (pfolder, folder);
context_save ();
fflush (stdout);
}
- /* If -nolink, then "remove" messages from source folder.
- *
- * Note that folder_delmsgs does not call the delete hook
- * because the message has already been handled above.
- */
+ /*
+ ** If -nolink, then "remove" messages from source folder.
+ **
+ ** Note that folder_delmsgs does not call the delete hook
+ ** because the message has already been handled above.
+ */
if (!linkf) {
folder_delmsgs (mp, unlink_msgs, 1);
}
/*
- * Read all the destination folders and
- * create folder structures for all of them.
- */
+** Read all the destination folders and
+** create folder structures for all of them.
+*/
static void
opnfolds (struct st_fold *folders, int nfolders)
/*
- * Set the Previous-Sequence and then sychronize the
- * sequence file, for each destination folder.
- */
+** Set the Previous-Sequence and then sychronize the
+** sequence file, for each destination folder.
+*/
static void
clsfolds (struct st_fold *folders, int nfolders)
/*
- * If you have a "rmmproc" defined, we called that
- * to remove all the specified files. If "rmmproc"
- * is not defined, then just unlink the files.
- */
+** If you have a "rmmproc" defined, we called that
+** to remove all the specified files. If "rmmproc"
+** is not defined, then just unlink the files.
+*/
static void
remove_files (int filep, char **files)
/*
- * Link (or copy) the message into each of
- * the destination folders.
- */
+** Link (or copy) the message into each of
+** the destination folders.
+*/
static int
-m_file (char *msgfile, struct st_fold *folders, int nfolders, int preserve, int refile)
+m_file (char *msgfile, struct st_fold *folders, int nfolders, int preserve,
+ int refile)
{
int msgnum;
struct st_fold *fp, *ep;
for (fp = folders, ep = folders + nfolders; fp < ep; fp++) {
- if ((msgnum = folder_addmsg (&fp->f_mp, msgfile, 1, 0, preserve, nfolders == 1 && refile, maildir)) == -1)
+ if ((msgnum = folder_addmsg (&fp->f_mp, msgfile, 1, 0,
+ preserve, nfolders == 1 && refile, maildir))
+ == -1)
return 1;
}
return 0;
/*
- * repl.c -- reply to a message
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** repl.c -- reply to a message
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
/*
- * prototypes
- */
+** prototypes
+*/
void docc (char *, int);
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s: [+folder] [msg] [switches]",
- invo_name);
+ snprintf (buf, sizeof(buf), "%s: [+folder] [msg] [switches]", invo_name);
print_help (buf, switches, 1);
done (0);
case VERSIONSW:
continue;
case WHATSW:
- if (!(whatnowproc = *argp++) || *whatnowproc == '-')
+ if (!(whatnowproc = *argp++) ||
+ *whatnowproc == '-')
adios (NULL, "missing argument to %s", argp[-2]);
nwhat = 0;
continue;
adios (NULL, "missing argument to %s", argp[-2]);
dp = NULL;
if (*cp == '@')
- cp = dp = path (cp + 1, TSUBCWF);
+ cp = dp = path (cp + 1,
+ TSUBCWF);
if (fcc)
fcc = add (", ", fcc);
fcc = add (cp, fcc);
if (file) {
/*
- * We are replying to a file.
- */
+ ** We are replying to a file.
+ */
anot = 0; /* we don't want to annotate a file */
} else {
/*
- * We are replying to a message.
- */
+ ** We are replying to a message.
+ */
if (!msg)
msg = "cur";
if (!folder)
if (mp->numsel > 1)
adios (NULL, "only one message at a time!");
- context_replace (pfolder, folder); /* update current folder */
+ context_replace (pfolder, folder); /* update current folder */
seq_setcur (mp, mp->lowsel); /* update current message */
seq_save (mp); /* synchronize sequences */
context_save (); /* save the context file */
ambigsw (cp, ccswitches);
done (1);
case UNKWNSW:
- adios (NULL, "-%scc %s unknown", ccflag ? "" : "no", cp);
+ adios (NULL, "-%scc %s unknown",
+ ccflag ? "" : "no", cp);
case CTOSW:
ccto = ccflag;
/*
- * replsbr.c -- routines to help repl along...
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** replsbr.c -- routines to help repl along...
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/addrsbr.h>
static struct mailname mq = { NULL };
/*
- * Buffer size for content part of header fields.
- * We want this to be large enough so that we don't
- * do a lot of extra FLDPLUS calls on m_getfld but
- * small enough so that we don't snarf the entire
- * message body when we're not going to use any of it.
- */
+** Buffer size for content part of header fields.
+** We want this to be large enough so that we don't
+** do a lot of extra FLDPLUS calls on m_getfld but
+** small enough so that we don't snarf the entire
+** message body when we're not going to use any of it.
+*/
#define SBUFSIZ 256
static struct format *fmt;
};
/*
- * static prototypes
- */
+** static prototypes
+*/
static int insert (struct mailname *);
static void replfilter (FILE *, FILE *, char *);
}
/*
- * ignore any components killed by command line switches
- */
+ ** ignore any components killed by command line switches
+ */
if (!ccto) {
FINDCOMP (cptr, "to");
if (cptr)
ismymbox (NULL);
/*
- * pick any interesting stuff out of msg "inb"
- */
+ ** pick any interesting stuff out of msg "inb"
+ */
for (state = FLD;;) {
state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
switch (state) {
case FLD:
case FLDPLUS:
/*
- * if we're interested in this component,
- * save a pointer to the component text,
- * then start using our next free buffer
- * as the component temp buffer (buffer
- * switching saves an extra copy of the
- * component text).
- */
+ ** if we're interested in this component,
+ ** save a pointer to the component text,
+ ** then start using our next free buffer
+ ** as the component temp buffer (buffer
+ ** switching saves an extra copy of the
+ ** component text).
+ */
if ((cptr = wantcomp[CHASH(name)]))
do {
if (!mh_strcasecmp(name, cptr->c_name)) {
}
/*
- * format and output the header lines.
- */
+ ** format and output the header lines.
+ */
finished:
/*
- * if there's a "Subject" component, strip any "Re:"s off it
- */
+ ** if there's a "Subject" component, strip any "Re:"s off it
+ */
FINDCOMP (cptr, "subject")
if (cptr && (cp = cptr->c_text)) {
register char *sp = cp;
}
/*
- * Check if we should filter the message
- * or add mhbuild directives
- */
+ ** Check if we should filter the message
+ ** or add mhbuild directives
+ */
if (filter) {
fflush(out);
if (ferror (out))
replfilter (inb, out, filter);
} else if (mime && mp) {
- fprintf (out, "#forw [original message] +%s %s\n",
- mp->foldpath, m_name (mp->lowsel));
+ fprintf (out, "#forw [original message] +%s %s\n",
+ mp->foldpath, m_name (mp->lowsel));
}
fflush(out);
/* return dynamically allocated buffers */
free (scanl);
- for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++); nxtbuf++, i--)
+ for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++);
+ nxtbuf++, i--)
free (cptr->c_text); /* if not nxtbuf, nxtbuf already freed */
while ( i-- > 0)
free (*nxtbuf++); /* free unused nxtbufs */
#define CPY(s) { cp = (s); while ((*dst++ = *cp++)) ; --dst; }
/*
- * check if there's enough room in buf for str.
- * add more mem if needed
- */
+** check if there's enough room in buf for str.
+** add more mem if needed
+*/
#define CHECKMEM(str) \
if ((len = strlen (str)) >= bufend - dst) {\
int i = dst - buf;\
/*
- * fmt_scan will call this routine if the user includes the function
- * "(formataddr {component})" in a format string. "orig" is the
- * original contents of the string register. "str" is the address
- * string to be formatted and concatenated onto orig. This routine
- * returns a pointer to the concatenated address string.
- *
- * We try to not do a lot of malloc/copy/free's (which is why we
- * don't call "getcpy") but still place no upper limit on the
- * length of the result string.
- */
+** fmt_scan will call this routine if the user includes the function
+** "(formataddr {component})" in a format string. "orig" is the
+** original contents of the string register. "str" is the address
+** string to be formatted and concatenated onto orig. This routine
+** returns a pointer to the concatenated address string.
+**
+** We try to not do a lot of malloc/copy/free's (which is why we
+** don't call "getcpy") but still place no upper limit on the
+** length of the result string.
+*/
char *
formataddr (char *orig, char *str)
{
bufend = buf + bufsiz;
}
/*
- * If "orig" points to our buffer we can just pick up where we
- * left off. Otherwise we have to copy orig into our buffer.
- */
+ ** If "orig" points to our buffer we can just pick up where we
+ ** left off. Otherwise we have to copy orig into our buffer.
+ */
if (orig == buf)
dst = last_dst;
else if (!orig || !*orig) {
/* concatenate all the new addresses onto 'buf' */
for (isgroup = 0; (cp = getname (str)); ) {
if ((mp = getm (cp, dfhost, dftype, AD_NAME, error)) == NULL) {
- snprintf (baddr, sizeof(baddr), "\t%s -- %s\n", cp, error);
+ snprintf (baddr, sizeof(baddr), "\t%s -- %s\n",
+ cp, error);
badaddrs = add (baddr, badaddrs);
continue;
}
for (mp = &mq; mp->m_next; mp = mp->m_next) {
if (!mh_strcasecmp (np->m_host, mp->m_next->m_host)
- && !mh_strcasecmp (np->m_mbox, mp->m_next->m_mbox))
+ && !mh_strcasecmp (np->m_mbox,
+ mp->m_next->m_mbox))
return 0;
}
if (!ccme && ismymbox (np))
return 0;
if (querysw) {
- snprintf (buffer, sizeof(buffer), "Reply to %s? ", adrformat (np));
+ snprintf (buffer, sizeof(buffer), "Reply to %s? ",
+ adrformat (np));
if (!gans (buffer, anoyes))
return 0;
}
/*
- * Call the mhlproc
- *
- * This function expects that argument out has been fflushed by the caller.
- */
+** Call the mhlproc
+**
+** This function expects that argument out has been fflushed by the caller.
+*/
static void
replfilter (FILE *in, FILE *out, char *filter)
dup2 (fileno (out), fileno (stdout));
closefds (3);
- execlp (mhlproc, mhl, "-form", filter, "-noclear", NULL);
+ execlp (mhlproc, mhl, "-form", filter, "-noclear",
+ NULL);
errstr = strerror(errno);
write(2, "unable to exec ", 15);
write(2, mhlproc, strlen(mhlproc));
/*
- * rmf.c -- remove a folder
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** rmf.c -- remove a folder
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
};
/*
- * static prototypes
- */
+** static prototypes
+*/
static int rmf(char *);
static void rma (char *);
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [switches]",
- invo_name);
+ snprintf (buf, sizeof(buf), "%s [+folder] [switches]", invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
else
folder = pluspath (cp);
} else {
- adios (NULL, "usage: %s [+folder] [switches]", invo_name);
+ adios (NULL, "usage: %s [+folder] [switches]",
+ invo_name);
}
}
interactive = defolder;
if (strchr (folder, '/') && (*folder != '/') && (*folder != '.')) {
- for (cp = copy (folder, newfolder); cp > newfolder && *cp != '/'; cp--)
+ for (cp = copy (folder, newfolder);
+ cp > newfolder && *cp != '/'; cp--)
continue;
if (cp > newfolder)
*cp = '\0';
char *cfolder = context_find(pfolder);
if (cfolder && strcmp (cfolder, newfolder)) {
printf ("[+%s now current]\n", newfolder);
- context_replace (pfolder, newfolder); /* update current folder */
+ /* update current folder */
+ context_replace (pfolder, newfolder);
}
}
context_save (); /* save the context file */
switch (i = chdir (maildir = m_maildir (folder))) {
case OK:
- if (access (".", W_OK) != NOTOK && access ("..", W_OK) != NOTOK)
+ if (access (".", W_OK) != NOTOK &&
+ access ("..", W_OK) != NOTOK)
break; /* fall otherwise */
case NOTOK:
printf ("[+%s de-referenced]\n", folder);
return OK;
}
- advise (NULL, "you have no profile entry for the %s folder +%s",
- i == NOTOK ? "unreadable" : "read-only", folder);
+ advise (NULL, "you have no profile entry for the %s folder +%s", i == NOTOK ? "unreadable" : "read-only", folder);
return NOTOK;
}
others = 0;
/*
- * Run the external delete hook program.
- */
+ ** Run the external delete hook program.
+ */
(void)ext_hook("del-hook", maildir, (char *)0);
switch (dp->d_name[0]) {
case '.':
if (strcmp (dp->d_name, ".") == 0
- || strcmp (dp->d_name, "..") == 0)
+ || strcmp (dp->d_name, "..")
+ == 0)
continue; /* else fall */
case ',':
if (m_atoi (dp->d_name))
break;
if (strcmp (dp->d_name, altmsglink) == 0
- || strncmp (dp->d_name, backup_prefix, j) == 0)
+ || strncmp (dp->d_name,
+ backup_prefix, j) == 0)
break;
admonish (NULL, "file \"%s/%s\" not deleted",
closedir (dd);
/*
- * Remove any relevant private sequences
- * or attributes from context file.
- */
+ ** Remove any relevant private sequences
+ ** or attributes from context file.
+ */
rma (folder);
chdir ("..");
/*
- * Remove all the (private) sequence information for
- * this folder from the profile/context list.
- */
+** Remove all the (private) sequence information for
+** this folder from the profile/context list.
+*/
static void
rma (char *folder)
plen = strlen (cp = m_mailpath (folder)) + 1;
/*
- * Search context list for keys that look like
- * "atr-something-folderpath", and remove them.
- */
+ ** Search context list for keys that look like
+ ** "atr-something-folderpath", and remove them.
+ */
for (np = m_defs, pp = NULL; np; np = np->n_next) {
if (ssequal ("atr-", np->n_name)
&& (j = strlen (np->n_name) - plen) > alen
&& *(np->n_name + j) == '-'
&& strcmp (cp, np->n_name + j + 1) == 0) {
if (!np->n_context)
- admonish (NULL, "bug: context_del(key=\"%s\")", np->n_name);
+ admonish (NULL, "bug: context_del(key=\"%s\")",
+ np->n_name);
if (pp) {
pp->n_next = np->n_next;
np = pp;
/*
- * rmm.c -- remove a message(s)
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** rmm.c -- remove a message(s)
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/utils.h>
adios (NULL, "-%s unknown\n", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
+ snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
seq_setprev (mp); /* set the previous-sequence */
/*
- * This is hackish. If we are using a external rmmproc,
- * then we need to update the current folder in the
- * context so the external rmmproc will remove files
- * from the correct directory. This should be moved to
- * folder_delmsgs().
- */
+ ** This is hackish. If we are using a external rmmproc,
+ ** then we need to update the current folder in the
+ ** context so the external rmmproc will remove files
+ ** from the correct directory. This should be moved to
+ ** folder_delmsgs().
+ */
if (rmmproc) {
context_replace (pfolder, folder);
context_save ();
/*
- * scan.c -- display a one-line "scan" listing of folder or messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** scan.c -- display a one-line "scan" listing of folder or messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/fmt_scan.h>
/*
- * global for sbr/formatsbr.c - yech!
- */
+** global for sbr/formatsbr.c - yech!
+*/
#ifdef LBL
extern struct msgs *fmt_current_folder;
#endif
/*
- * prototypes
- */
+** prototypes
+*/
void clear_screen(void); /* from termsbr.c */
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
+ snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
format = NULL;
continue;
case FMTSW:
- if (!(format = *argp++) || *format == '-')
+ if (!(format = *argp++) ||
+ *format == '-')
adios (NULL, "missing argument to %s", argp[-2]);
form = NULL;
continue;
free (path ("./", TFOLDER));
/*
- * Get new format string. Must be before chdir().
- */
+ ** Get new format string. Must be before chdir().
+ */
nfs = new_fs (form, format, FORMAT);
/*
- * We are scanning a maildrop file
- */
+ ** We are scanning a maildrop file
+ */
if (file) {
if (msgs.size)
adios (NULL, "\"msgs\" not allowed with -file");
}
/*
- * We are scanning a folder
- */
+ ** We are scanning a folder
+ */
if (!msgs.size)
app_msgarg(&msgs, "all");
context_save (); /* save the context file */
/*
- * Get the sequence number for each sequence
- * specified by Unseen-Sequence
- */
+ ** Get the sequence number for each sequence
+ ** specified by Unseen-Sequence
+ */
if ((cp = context_find (usequence)) && *cp) {
char **ap, *dp;
admonish (cp, "unable to open message");
#if 0
else
- printf ("%*d unreadable\n", DMAXFOLDER, msgnum);
+ printf ("%*d unreadable\n",
+ DMAXFOLDER, msgnum);
#endif
continue;
}
#ifndef JLR
if (hdrflag) {
- printf ("FOLDER %s\t%s\n", folder, dtimenow(1));
+ printf ("FOLDER %s\t%s\n", folder,
+ dtimenow(1));
}
#endif /* JLR */
/*
- * Check if message is in any sequence given
- * by Unseen-Sequence profile entry.
- */
+ ** Check if message is in any sequence given
+ ** by Unseen-Sequence profile entry.
+ */
unseen = 0;
for (i = 0; i < num_unseen_seq; i++) {
if (in_sequence(mp, seqnum[i], msgnum)) {
break;
default:
- adios (NULL, "scan() botch (%d)", state);
+ adios (NULL, "scan() botch (%d)",
+ state);
case SCNEOF:
#if 0
- printf ("%*d empty\n", DMAXFOLDER, msgnum);
+ printf ("%*d empty\n", DMAXFOLDER,
+ msgnum);
#else
- advise (NULL, "message %d: empty", msgnum);
+ advise (NULL, "message %d: empty",
+ msgnum);
#endif
break;
}
/*
- * scansbr.c -- routines to help scan along...
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** scansbr.c -- routines to help scan along...
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/addrsbr.h>
#define MAXSCANL 256 /* longest possible scan line */
/*
- * Buffer size for content part of header fields. We want this
- * to be large enough so that we don't do a lot of extra FLDPLUS
- * calls on m_getfld but small enough so that we don't snarf
- * the entire message body when we're only going to display 30
- * characters of it.
- */
+** Buffer size for content part of header fields. We want this
+** to be large enough so that we don't do a lot of extra FLDPLUS
+** calls on m_getfld but small enough so that we don't snarf
+** the entire message body when we're only going to display 30
+** characters of it.
+*/
#define SBUFSIZ 512
static struct format *fmt;
}
/*
- * prototypes
- */
+** prototypes
+*/
int sc_width (void); /* from termsbr.c */
static int mh_fputs(char *, FILE *);
width = MAXSCANL;
}
dat[3] = slwidth = width;
- scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH * (slwidth + 2) );
+ scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH *
+ (slwidth + 2) );
if (outnum)
umask(~m_gmprot());
cptr->c_text = folder;
FINDCOMP(cptr, "encrypted");
if (!cptr)
- if ((cptr = (struct comp *) calloc (1, sizeof(*cptr)))) {
+ if ((cptr = (struct comp *) calloc (1,
+ sizeof(*cptr)))) {
cptr->c_name = "encrypted";
cptr->c_next = wantcomp[i = CHASH (cptr->c_name)];
wantcomp[i] = cptr;
FINDCOMP (cptr, "dtimenow");
if (cptr)
cptr->c_text = getcpy(dtimenow (0));
- nxtbuf = compbuffers = (char **) calloc((size_t) ncomps, sizeof(char *));
+ nxtbuf = compbuffers = (char **) calloc((size_t) ncomps,
+ sizeof(char *));
if (nxtbuf == NULL)
adios (NULL, "unable to allocate component buffers");
used_buf = (struct comp **) calloc((size_t) (ncomps+1),
}
/*
- * each-message initialization
- */
+ ** each-message initialization
+ */
nxtbuf = compbuffers;
savecomp = used_buf;
tmpbuf = *nxtbuf++;
dat[4] = unseen;
/*
- * Get the first field. If the message is non-empty
- * and we're doing an "inc", open the output file.
- */
+ ** Get the first field. If the message is non-empty
+ ** and we're doing an "inc", open the output file.
+ */
if ((state = m_getfld (FLD, name, tmpbuf, rlwidth, inb)) == FILEEOF) {
if (ferror(inb)) {
advise("read", "unable to"); /* "read error" */
adios (scnmsg, "unable to write");
#ifdef RPATHS
/*
- * Add the Return-Path and Delivery-Date
- * header fields to message.
- */
+ ** Add the Return-Path and Delivery-Date
+ ** header fields to message.
+ */
if (get_returnpath (returnpath, sizeof(returnpath),
deliverydate, sizeof(deliverydate))) {
FPUTS ("Return-Path: ");
}
/* scan - main loop */
- for (compnum = 1; ; state = m_getfld (state, name, tmpbuf, rlwidth, inb)) {
+ for (compnum = 1; ;
+ state = m_getfld (state, name, tmpbuf, rlwidth, inb)) {
switch (state) {
case FLD:
case FLDPLUS:
compnum++;
if (outnum) {
FPUTS (name);
- if ( putc (':', scnout) == EOF) DIEWRERR();
+ if ( putc (':', scnout) == EOF)
+ DIEWRERR();
FPUTS (tmpbuf);
}
/*
- * if we're interested in this component, save a pointer
- * to the component text, then start using our next free
- * buffer as the component temp buffer (buffer switching
- * saves an extra copy of the component text).
- */
+ ** if we're interested in this component,
+ ** save a pointer to the component text,
+ ** then start using our next free buffer
+ ** as the component temp buffer (buffer
+ ** switching saves an extra copy of the
+ ** component text).
+ */
if ((cptr = wantcomp[CHASH(name)])) {
do {
if (!mh_strcasecmp(name, cptr->c_name)) {
if (putc ('\n', scnout) == EOF) DIEWRERR();
FPUTS (tmpbuf);
/*
- * performance hack: some people like to run "inc" on
- * things like net.sources or large digests. We do a
- * copy directly into the output buffer rather than
- * going through an intermediate buffer.
- *
- * We need the amount of data m_getfld found & don't
- * want to do a strlen on the long buffer so there's
- * a hack in m_getfld to save the amount of data it
- * returned in the global "msg_count".
- */
+ ** performance hack: some people like to
+ ** run "inc" on things like net.sources or
+ ** large digests. We do a copy directly
+ ** into the output buffer rather than
+ ** going through an intermediate buffer.
+ **
+ ** We need the amount of data m_getfld
+ ** found & don't want to do a strlen on
+ ** the long buffer so there's a hack in
+ ** m_getfld to save the amount of data it
+ ** returned in the global "msg_count".
+ */
body:;
while (state == BODY) {
#ifdef LINUX_STDIO
case LENERR:
case FMTERR:
- fprintf (stderr,
- innum ? "??Format error (message %d) in "
- : "??Format error in ",
- outnum ? outnum : innum);
+ fprintf (stderr, innum ? "??Format error (message %d) in " : "??Format error in ", outnum ? outnum : innum);
fprintf (stderr, "component %d\n", compnum);
if (outnum) {
}
/*
- * format and output the scan line.
- */
+ ** format and output the scan line.
+ */
finished:
if (ferror(inb)) {
advise("read", "unable to"); /* "read error" */
if (size)
dat[2] = size;
- else if (outnum > 0)
- {
+ else if (outnum > 0) {
dat[2] = ftell(scnout);
if (dat[2] == EOF) DIEWRERR();
}
return(EOF);
return (0);
}
-
/*
- * send.c -- send a composed message
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** send.c -- send a composed message
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
adios (NULL, "-%s unknown\n", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [file] [switches]", invo_name);
+ snprintf (buf, sizeof(buf),
+ "%s [file] [switches]",
+ invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
}
/*
- * check for "Aliasfile:" profile entry
- */
+ ** check for "Aliasfile:" profile entry
+ */
if ((cp = context_find ("Aliasfile"))) {
char *dp = NULL;
- for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++) {
+ for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap;
+ ap++) {
vec[vecp++] = "-alias";
vec[vecp++] = *ap;
}
#ifdef UCI
else {
snprintf (buf, sizeof(buf), "%s/.signature", mypath);
- if ((fp = fopen (buf, "r")) != NULL
- && fgets (buf, sizeof buf, fp) != NULL) {
+ if ((fp = fopen (buf, "r")) != NULL &&
+ fgets(buf, sizeof buf, fp) != NULL) {
fclose (fp);
if (cp = strchr (buf, '\n'))
*cp = 0;
&& errno != EISREMOTE
#endif /* EISREMOTE */
)
- adios (distfile, "unable to link %s to", altmsg);
+ adios (distfile, "unable to link %s to",
+ altmsg);
free (distfile);
- distfile = getcpy (m_mktemp2(NULL, invo_name, NULL, NULL));
+ distfile = getcpy (m_mktemp2(NULL, invo_name,
+ NULL, NULL));
{
int in, out;
struct stat st;
if ((in = open (altmsg, O_RDONLY)) == NOTOK)
adios (altmsg, "unable to open");
fstat(in, &st);
- if ((out = creat (distfile, (int) st.st_mode & 0777)) == NOTOK)
+ if ((out = creat (distfile,
+ (int) st.st_mode & 0777))
+ == NOTOK)
adios (distfile, "unable to write");
cpydata (in, out, altmsg, distfile);
close (in);
for (msgnum = 0; msgnum < msgp; msgnum++) {
switch (sendsbr (vec, vecp, msgs[msgnum], &st, 1, attach,
- attachformat)) {
+ attachformat)) {
case DONE:
done (++status);
case NOTOK:
/*
- * sendsbr.c -- routines to help WhatNow/Send along
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** sendsbr.c -- routines to help WhatNow/Send along
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/signals.h>
static jmp_buf env;
-static char body_file_name[MAXPATHLEN + 1]; /* name of temporary file for body content */
-static char composition_file_name[MAXPATHLEN + 1]; /* name of mhbuild composition temporary file */
+/* name of temp file for body content */
+static char body_file_name[MAXPATHLEN + 1];
+/* name of mhbuild composition temporary file */
+static char composition_file_name[MAXPATHLEN + 1];
static int field_size; /* size of header field buffer */
static char *field; /* header field buffer */
static FILE *draft_file; /* draft file pointer */
static FILE *composition_file; /* composition file pointer */
/*
- * external prototypes
- */
+** external prototypes
+*/
int sendsbr (char **, int, char *, struct stat *, int, char *, int);
char *getusername (void);
/*
- * static prototypes
- */
+** static prototypes
+*/
static void armed_done (int) NORETURN;
static void alert (char *, int);
static int tmp_fd (void);
/*
- * Entry point into (back-end) routines to send message.
- */
+** Entry point into (back-end) routines to send message.
+*/
int
sendsbr (char **vec, int vecp, char *drft, struct stat *st,
char *p; /* string pointer for building file name */
/*
- * Save the original name of the draft file. The name of the
- * draft file is changed to a temporary file containing the built
- * MIME message if there are attachments. We need the original
- * name so that it can be renamed after the message is sent.
- */
+ ** Save the original name of the draft file. The name of the
+ ** draft file is changed to a temporary file containing the built
+ ** MIME message if there are attachments. We need the original
+ ** name so that it can be renamed after the message is sent.
+ */
original_draft = drft;
/*
- * There might be attachments if a header field name for
- * attachments is supplied. Convert the draft to a MIME message.
- * Use the mhbuild composition file for the draft if there was
- * a successful conversion because that now contains the MIME
- * message. A nice side effect of this is that it leaves the
- * original draft file untouched so that it can be retrieved
- * and modified if desired.
- */
+ ** There might be attachments if a header field name for
+ ** attachments is supplied. Convert the draft to a MIME message.
+ ** Use the mhbuild composition file for the draft if there was
+ ** a successful conversion because that now contains the MIME
+ ** message. A nice side effect of this is that it leaves the
+ ** original draft file untouched so that it can be retrieved
+ ** and modified if desired.
+ */
if (attachment_header_field_name != (char *)0) {
- switch (attach(attachment_header_field_name, drft, attachformat)) {
+ switch (attach(attachment_header_field_name, drft,
+ attachformat)) {
case OK:
drft = composition_file_name;
break;
switch (setjmp (env)) {
case OK:
/*
- * If given -push and -unique (which is undocumented), then
- * rename the draft file. I'm not quite sure why.
- */
+ ** If given -push and -unique (which is undocumented), then
+ ** rename the draft file. I'm not quite sure why.
+ */
if (pushsw && unique) {
char *cp = m_mktemp2(drft, invo_name, NULL, NULL);
if (cp == NULL) {
adios ("sendsbr", "unable to create temporary file");
}
- if (rename (drft, strncpy(file, cp, sizeof(file))) == NOTOK)
+ if (rename (drft, strncpy(file, cp, sizeof(file)))
+ == NOTOK)
adios (file, "unable to rename %s to", drft);
drft = file;
}
unlink (distfile);
/*
- * Get rid of any temporary files that we created for attachments.
- * Also get rid of the renamed composition file that mhbuild
- * leaves as a turd. It looks confusing, but we use the body
- * file name to help build the renamed composition file name.
- */
+ ** Get rid of any temporary files that we created for attachments.
+ ** Also get rid of the renamed composition file that mhbuild
+ ** leaves as a turd. It looks confusing, but we use the body
+ ** file name to help build the renamed composition file name.
+ */
if (drft == composition_file_name) {
clean_up_temporary_files();
- if (strlen(composition_file_name) >= sizeof (composition_file_name) - 6)
+ if (strlen(composition_file_name) >=
+ sizeof (composition_file_name) - 6)
advise((char *)0, "unable to remove original composition file.");
else {
- if ((p = strrchr(composition_file_name, '/')) == (char *)0)
+ if ((p = strrchr(composition_file_name, '/')) == NULL)
p = composition_file_name;
else
p++;
char *p; /* miscellaneous string pointer */
/*
- * Open up the draft file.
- */
+ ** Open up the draft file.
+ */
if ((draft_file = fopen(draft_file_name, "r")) == (FILE *)0)
- adios((char *)0, "can't open draft file `%s'.", draft_file_name);
+ adios((char *)0, "can't open draft file `%s'.",
+ draft_file_name);
/*
- * Allocate a buffer to hold the header components as they're read in.
- * This buffer might need to be quite large, so we grow it as needed.
- */
+ ** Allocate a buffer to hold the header components as they're read in.
+ ** This buffer might need to be quite large, so we grow it as needed.
+ */
field = (char *)mh_xmalloc(field_size = 256);
/*
- * Scan the draft file for a header field name that matches the
- * -attach argument. The existence of one indicates that the
- * draft has attachments. Bail out if there are no attachments
- * because we're done. Read to the end of the headers even if
- * we have no attachments.
- */
+ ** Scan the draft file for a header field name that matches the
+ ** -attach argument. The existence of one indicates that the
+ ** draft has attachments. Bail out if there are no attachments
+ ** because we're done. Read to the end of the headers even if
+ ** we have no attachments.
+ */
length = strlen(attachment_header_field_name);
has_attachment = 0;
while (get_line() != EOF && *field != '\0' && *field != '-')
- if (strncasecmp(field, attachment_header_field_name, length) == 0 && field[length] == ':')
+ if (strncasecmp(field, attachment_header_field_name, length)
+ == 0 && field[length] == ':')
has_attachment = 1;
if (has_attachment == 0)
return (DONE);
/*
- * We have at least one attachment. Look for at least one
- * non-blank line in the body of the message which indicates
- * content in the body.
- */
+ ** We have at least one attachment. Look for at least one
+ ** non-blank line in the body of the message which indicates
+ ** content in the body.
+ */
has_body = 0;
}
/*
- * Make names for the temporary files.
- */
+ ** Make names for the temporary files.
+ */
(void)strncpy(body_file_name,
- m_mktemp(m_maildir(invo_name), NULL, NULL),
- sizeof (body_file_name));
+ m_mktemp(m_maildir(invo_name), NULL, NULL),
+ sizeof (body_file_name));
(void)strncpy(composition_file_name,
- m_mktemp(m_maildir(invo_name), NULL, NULL),
- sizeof (composition_file_name));
+ m_mktemp(m_maildir(invo_name), NULL, NULL),
+ sizeof (composition_file_name));
if (has_body)
body_file = fopen(body_file_name, "w");
composition_file = fopen(composition_file_name, "w");
- if ((has_body && body_file == (FILE *)0) || composition_file == (FILE *)0) {
+ if ((has_body && body_file == (FILE *)0) ||
+ composition_file == (FILE *)0) {
clean_up_temporary_files();
adios((char *)0, "unable to open all of the temporary files.");
}
/*
- * Start at the beginning of the draft file. Copy all
- * non-attachment header fields to the temporary composition file.
- * Then add the dashed line separator.
- */
+ ** Start at the beginning of the draft file. Copy all
+ ** non-attachment header fields to the temporary composition file.
+ ** Then add the dashed line separator.
+ */
rewind(draft_file);
while (get_line() != EOF && *field != '\0' && *field != '-')
- if (strncasecmp(field, attachment_header_field_name, length) != 0 || field[length] != ':')
+ if (strncasecmp(field, attachment_header_field_name, length)
+ != 0 || field[length] != ':')
(void)fprintf(composition_file, "%s\n", field);
(void)fputs("--------\n", composition_file);
/*
- * Copy the message body to a temporary file.
- */
+ ** Copy the message body to a temporary file.
+ */
if (has_body) {
while ((c = getc(draft_file)) != EOF)
}
/*
- * Add a mhbuild MIME composition file line for the body if
- * there was one.
- */
+ ** Add a mhbuild MIME composition file line for the body if
+ ** there was one.
+ */
if (has_body)
make_mime_composition_file_entry(body_file_name, attachformat);
/*
- * Now, go back to the beginning of the draft file and look for
- * header fields that specify attachments. Add a mhbuild MIME
- * composition file for each.
- */
+ ** Now, go back to the beginning of the draft file and look for
+ ** header fields that specify attachments. Add a mhbuild MIME
+ ** composition file for each.
+ */
rewind(draft_file);
while (get_line() != EOF && *field != '\0' && *field != '-') {
- if (strncasecmp(field, attachment_header_field_name, length) == 0 && field[length] == ':') {
- for (p = field + length + 1; *p == ' ' || *p == '\t'; p++)
+ if (strncasecmp(field, attachment_header_field_name, length)
+ == 0 && field[length] == ':') {
+ for (p = field + length + 1; *p == ' ' || *p == '\t';
+ p++)
;
make_mime_composition_file_entry(p, attachformat);
(void)fclose(composition_file);
/*
- * We're ready to roll! Run mhbuild on the composition file.
- * Note that mhbuild is in the context as buildmimeproc.
- */
+ ** We're ready to roll! Run mhbuild on the composition file.
+ ** Note that mhbuild is in the context as buildmimeproc.
+ */
(void)sprintf(buf, "%s %s", buildmimeproc, composition_file_name);
char *p; /* buffer pointer */
/*
- * Get a line from the input file, growing the field buffer as
- * needed. We do this so that we can fit an entire line in the
- * buffer making it easy to do a string comparison on both the
- * field name and the field body which might be a long path name.
- */
+ ** Get a line from the input file, growing the field buffer as
+ ** needed. We do this so that we can fit an entire line in the
+ ** buffer making it easy to do a string comparison on both the
+ ** field name and the field body which might be a long path name.
+ */
for (n = 0, p = field; (c = getc(draft_file)) != EOF; *p++ = c) {
if (c == '\n' && (c = getc(draft_file)) != ' ' && c != '\t') {
}
}
- /*
- * NUL-terminate the field..
- */
-
+ /* NUL-terminate the field. */
*p = '\0';
return (c);
content_type = (char *)0;
/*
- * Check the file name for a suffix. Scan the context for that
- * suffix on a mhshow-suffix- entry. We use these entries to
- * be compatible with mhshow, and there's no reason to make the
- * user specify each suffix twice. Context entries of the form
- * "mhshow-suffix-contenttype" in the name have the suffix in
- * the field, including the dot.
- */
+ ** Check the file name for a suffix. Scan the context for that
+ ** suffix on a mhshow-suffix- entry. We use these entries to
+ ** be compatible with mhshow, and there's no reason to make the
+ ** user specify each suffix twice. Context entries of the form
+ ** "mhshow-suffix-contenttype" in the name have the suffix in
+ ** the field, including the dot.
+ */
if ((p = strrchr(file_name, '.')) != (char *)0) {
for (np = m_defs; np; np = np->n_next) {
- if (strncasecmp(np->n_name, "mhshow-suffix-", 14) == 0 && mh_strcasecmp(p, np->n_field) == 0) {
+ if (strncasecmp(np->n_name, "mhshow-suffix-", 14) == 0
+ && mh_strcasecmp(p, np->n_field) == 0)
+ {
content_type = np->n_name + 14;
break;
}
}
/*
- * No content type was found, either because there was no matching
- * entry in the context or because the file name has no suffix.
- * Open the file and check for non-ASCII characters. Choose the
- * content type based on this check.
- */
+ ** No content type was found, either because there was no matching
+ ** entry in the context or because the file name has no suffix.
+ ** Open the file and check for non-ASCII characters. Choose the
+ ** content type based on this check.
+ */
if (content_type == (char *)0) {
if ((fp = fopen(file_name, "r")) == (FILE *)0) {
clean_up_temporary_files();
- adios((char *)0, "unable to access file \"%s\"", file_name);
+ adios((char *)0, "unable to access file \"%s\"",
+ file_name);
}
binary = 0;
(void)fclose(fp);
- content_type = binary ? "application/octet-stream" : "text/plain";
+ content_type = binary ?
+ "application/octet-stream" : "text/plain";
}
/*
- * Make sure that the attachment file exists and is readable.
- * Append a mhbuild directive to the draft file. This starts with
- * the content type. Append a file name attribute and a private
- * x-unix-mode attribute. Also append a description obtained
- * (if possible) by running the "file" command on the file.
- */
+ ** Make sure that the attachment file exists and is readable.
+ ** Append a mhbuild directive to the draft file. This starts with
+ ** the content type. Append a file name attribute and a private
+ ** x-unix-mode attribute. Also append a description obtained
+ ** (if possible) by running the "file" command on the file.
+ */
if (stat(file_name, &st) == -1 || access(file_name, R_OK) != 0) {
clean_up_temporary_files();
switch (attachformat) {
case 0:
/* Insert name, file mode, and Content-Id. */
- (void)fprintf(composition_file, "#%s; name=\"%s\"; x-unix-mode=0%.3ho",
- content_type, ((p = strrchr(file_name, '/')) == (char *)0) ? file_name : p + 1, (unsigned short)(st.st_mode & 0777));
+ (void)fprintf(composition_file,
+ "#%s; name=\"%s\"; x-unix-mode=0%.3ho",
+ content_type, ((p = strrchr(file_name, '/'))
+ == (char *)0) ? file_name : p + 1,
+ (unsigned short)(st.st_mode & 0777));
if (strlen(file_name) > MAXPATHLEN) {
clean_up_temporary_files();
- adios((char *)0, "attachment file name `%s' too long.", file_name);
+ adios((char *)0, "attachment file name `%s' too long.",
+ file_name);
}
(void)sprintf(cmd, "file '%s'", file_name);
- if ((fp = popen(cmd, "r")) != (FILE *)0 && fgets(cmd, sizeof (cmd), fp) != (char *)0) {
+ if ((fp = popen(cmd, "r")) != (FILE *)0 &&
+ fgets(cmd, sizeof (cmd), fp) != (char *)0) {
*strchr(cmd, '\n') = '\0';
/*
- * The output of the "file" command is of the form
- *
- * file: description
- *
- * Strip off the "file:" and subsequent white space.
- */
+ ** The output of the "file" command is of the form
+ **
+ ** file: description
+ **
+ ** Strip off the "file:" and subsequent white space.
+ */
for (p = cmd; *p != '\0'; p++) {
if (*p == ':') {
case 1:
if (stringdex (m_maildir(invo_name), file_name) == 0) {
/*
- * Content had been placed by send into a temp file.
- * Don't generate Content-Disposition header, because
- * it confuses Microsoft Outlook, Build 10.0.6626, at
- * least.
- */
+ ** Content had been placed by send into a temp file.
+ ** Don't generate Content-Disposition header, because
+ ** it confuses Microsoft Outlook, Build 10.0.6626, at
+ ** least.
+ */
(void) fprintf (composition_file, "#%s <>", content_type);
} else {
- /* Suppress Content-Id, insert simple Content-Disposition. */
+ /*
+ ** Suppress Content-Id, insert simple
+ ** Content-Disposition.
+ */
(void) fprintf (composition_file,
"#%s; name=\"%s\" <>{attachment}",
content_type,
case 2:
if (stringdex (m_maildir(invo_name), file_name) == 0) {
/*
- * Content had been placed by send into a temp file.
- * Don't generate Content-Disposition header, because
- * it confuses Microsoft Outlook, Build 10.0.6626, at
- * least.
- */
- (void) fprintf (composition_file, "#%s <>", content_type);
+ ** Content had been placed by send into a temp file.
+ ** Don't generate Content-Disposition header, because
+ ** it confuses Microsoft Outlook, Build 10.0.6626, at
+ ** least.
+ */
+ (void) fprintf (composition_file, "#%s <>",
+ content_type);
} else {
/*
- * Suppress Content-Id, insert Content-Disposition
- * with modification date.
- */
+ ** Suppress Content-Id, insert Content-Disposition
+ ** with modification date.
+ */
(void) fprintf (composition_file,
"#%s; name=\"%s\" <>{attachment; modification-date=\"%s\"}",
content_type,
}
/*
- * Finish up with the file name.
- */
+ ** Finish up with the file name.
+ */
(void)fprintf(composition_file, " %s\n", file_name);
}
/*
- * Annotate original message, and
- * call `postproc' to send message.
- */
+** Annotate original message, and
+** call `postproc' to send message.
+*/
static int
sendaux (char **vec, int vecp, char *drft, struct stat *st)
case 0:
/*
- * child process -- send it
- *
- * If fd is ok, then we are pushing and fd points to temp
- * file, so capture anything on stdout and stderr there.
- */
+ ** child process -- send it
+ **
+ ** If fd is ok, then we are pushing and fd points to temp
+ ** file, so capture anything on stdout and stderr there.
+ */
if (fd != NOTOK) {
dup2 (fd, fileno (stdout));
dup2 (fd, fileno (stderr));
default:
/*
- * parent process -- wait for it
- */
+ ** parent process -- wait for it
+ */
if ((status = pidwait(child_id, NOTOK)) == OK) {
if (annotext && fd2 != NOTOK)
anno (fd2, st);
} else {
/*
- * If postproc failed, and we have good fd (which means
- * we pushed), then mail error message (and possibly the
- * draft) back to the user.
- */
+ ** If postproc failed, and we have good fd (which
+ ** means we pushed), then mail error message
+ ** (and possibly the draft) back to the user.
+ */
if (fd != NOTOK) {
alert (drft, fd);
close (fd);
if (distfile) {
unlink (drft);
if (rename (backup, drft) == NOTOK)
- advise (drft, "unable to rename %s to", backup);
+ advise (drft, "unable to rename %s to",
+ backup);
}
}
break;
/*
- * Mail error notification (and possibly a copy of the
- * message) back to the user, using the mailproc
- */
+** Mail error notification (and possibly a copy of the
+** message) back to the user, using the mailproc
+*/
static void
alert (char *file, int out)
close (out);
/* create subject for error notification */
snprintf (buf, sizeof(buf), "send failed on %s",
- forwsw ? "enclosed draft" : file);
+ forwsw ?
+ "enclosed draft" : file);
- execlp (mailproc, r1bindex (mailproc, '/'), getusername (),
+ execlp (mailproc, r1bindex (mailproc, '/'),
+ getusername (),
"-subject", buf, NULL);
fprintf (stderr, "unable to exec ");
perror (mailproc);
switch (child_id) {
case NOTOK: /* oops */
if (!debugsw)
- advise (NULL,
- "unable to fork, so doing annotations by hand...");
+ advise (NULL, "unable to fork, so doing annotations by hand...");
if (cwd == NULL)
cwd = getcpy (pwd ());
/*
- * show.c -- show/list messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** show.c -- show/list messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/mime.h>
};
/*
- * static prototypes
- */
+** static prototypes
+*/
static int is_nontext(char *);
/* prototype from mhlsbr.c */
continue;
case HELPSW:
- snprintf (buf, sizeof(buf),
- "%s [+folder] %s[switches] [switches for showproc]",
- invo_name, mode == SHOW ? "[msgs] ": "");
+ snprintf (buf, sizeof(buf), "%s [+folder] %s[switches] [switches for showproc]", invo_name, mode == SHOW ? "[msgs] ": "");
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
adios (NULL, "only one folder at a time!");
else
folder = pluspath (cp);
+ } else if (mode != SHOW) {
+ goto usage;
} else {
- if (mode != SHOW)
- goto usage;
- else
- msgs[msgp++] = cp;
+ msgs[msgp++] = cp;
}
}
procp = vecp;
}
#ifdef WHATNOW
- if (!msgp && !folder && mode == SHOW && (cp = getenv ("mhdraft")) && *cp) {
+ if (!msgp && !folder && mode == SHOW &&
+ (cp = getenv ("mhdraft")) && *cp) {
vec[vecp++] = cp;
goto go_to_it;
}
done (1);
/*
- * Set the SELECT_UNSEEN bit for all the SELECTED messages,
- * since we will use that as a tag to know which messages
- * to remove from the "unseen" sequence.
- */
+ ** Set the SELECT_UNSEEN bit for all the SELECTED messages,
+ ** since we will use that as a tag to know which messages
+ ** to remove from the "unseen" sequence.
+ */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
if (is_selected(mp, msgnum))
set_unseen (mp, msgnum);
seq_setunseen (mp, 1); /* unset the Unseen-Sequence */
if (mp->numsel > MAXARGS - 2)
- adios (NULL, "more than %d messages for show exec", MAXARGS - 2);
+ adios (NULL, "more than %d messages for show exec",
+ MAXARGS - 2);
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
if (is_selected(mp, msgnum))
vec[vecp] = NULL;
/*
- * Decide which "proc" to use
- */
+ ** Decide which "proc" to use
+ */
mime = 0;
if (nshow) {
proc = catproc;
/* check if any messages are non-text MIME messages */
if (checkmime && !getenv ("NOMHNPROC")) {
if (!file) {
- /* loop through selected messages and check for MIME */
- for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
+ /*
+ ** loop through selected messages
+ ** and check for MIME
+ */
+ for (msgnum = mp->lowsel;
+ msgnum <= mp->hghsel;
+ msgnum++)
if (is_selected (mp, msgnum) && is_nontext (m_name (msgnum))) {
mime = 1;
break;
m_putenv ("mhfolder", folder);
/*
- * For backward compatibility, if the "proc" is mhn,
- * then add "-show" option. Add "-file" if showing
- * file.
- */
+ ** For backward compatibility, if the "proc" is mhn,
+ ** then add "-show" option. Add "-file" if showing
+ ** file.
+ */
if (strcmp (r1bindex (proc, '/'), "mhn") == 0) {
if (file) {
vec[vecp] = vec[vecp - 1];
vec[vecp] = NULL;
}
- /* If the "proc" is "mhshow", add "-file" if showing file.
- */
+ /* If the "proc" is "mhshow", add "-file" if showing file. */
if (strcmp (r1bindex (proc, '/'), "mhshow") == 0 && file ) {
vec[vecp] = vec[vecp - 1];
vec[vecp - 1] = "-file";
}
/*
- * If "proc" is mhl, then run it internally
- * rather than exec'ing it.
- */
+ ** If "proc" is mhl, then run it internally
+ ** rather than exec'ing it.
+ */
if (strcmp (r1bindex (proc, '/'), "mhl") == 0) {
vec[0] = "mhl";
mhl (vecp, vec);
}
/*
- * If you are not using a nmh command as your "proc", then
- * add the path to the message names. Currently, we are just
- * checking for mhn here, since we've already taken care of mhl.
- */
+ ** If you are not using a nmh command as your "proc", then
+ ** add the path to the message names. Currently, we are just
+ ** checking for mhn here, since we've already taken care of mhl.
+ */
if (!strcmp (r1bindex (proc, '/'), "mhl")
&& !file
- && chdir (maildir = concat (m_maildir (""), "/", NULL)) != NOTOK) {
+ && chdir (maildir =
+ concat (m_maildir (""), "/", NULL)) != NOTOK) {
mp->foldpath = concat (mp->foldpath, "/", NULL);
cp = ssequal (maildir, mp->foldpath)
? mp->foldpath + strlen (maildir)
}
/*
- * Check if a message or file contains any non-text parts
- */
+** Check if a message or file contains any non-text parts
+*/
static int
is_nontext (char *msgnam)
{
case FLDPLUS:
case FLDEOF:
/*
- * Check Content-Type field
- */
+ ** Check Content-Type field
+ */
if (!mh_strcasecmp (name, TYPE_FIELD)) {
int passno;
char c;
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ state = m_getfld (state, name, buf,
+ sizeof(buf), fp);
cp = add (buf, cp);
}
bp = cp;
if (!*bp)
goto invalid;
if (passno > 1) {
- if ((result = (mh_strcasecmp (bp, "plain") != 0)))
+ if ((result = (mh_strcasecmp (bp,
+ "plain") != 0)))
goto out;
*dp = c;
for (dp++; isspace (*dp); dp++)
continue;
if (*dp) {
- if ((result = !uprf (dp, "charset")))
+ if ((result = !uprf (dp,
+ "charset")))
goto out;
dp += sizeof("charset") - 1;
while (isspace (*dp))
}
/*
- * Check Content-Transfer-Encoding field
- */
+ ** Check Content-Transfer-Encoding field
+ */
if (!mh_strcasecmp (name, ENCODING_FIELD)) {
cp = add (buf, NULL);
while (state == FLDPLUS) {
}
/*
- * Just skip the rest of this header
- * field and go to next one.
- */
+ ** 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);
+ state = m_getfld(state, name, buf, sizeof(buf),
+ fp);
break;
/*
- * We've passed the message header,
- * so message is just text.
- */
+ ** We've passed the message header,
+ ** so message is just text.
+ */
default:
fclose (fp);
return 0;
/*
- * slocal.c -- asynchronously filter and deliver new mail
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** slocal.c -- asynchronously filter and deliver new mail
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
/*
- * Under sendmail, users should add the line
- *
- * "| /usr/local/nmh/lib/slocal"
- *
- * to their $HOME/.forward file.
- *
- */
+** Under sendmail, users should add the line
+**
+** "| /usr/local/nmh/lib/slocal"
+**
+** to their $HOME/.forward file.
+**
+*/
/* Changed to use getutent() and friends. Assumes that when getutent() exists,
- * a number of other things also exist. Please check.
- * Ruud de Rooij <ruud@ruud.org> Sun, 28 May 2000 17:28:55 +0200
- */
+** a number of other things also exist. Please check.
+** Ruud de Rooij <ruud@ruud.org> Sun, 28 May 2000 17:28:55 +0200
+*/
#include <h/mh.h>
#include <h/dropsbr.h>
#ifdef INITGROUPS_HEADER
#include INITGROUPS_HEADER
#else
-/* On AIX 4.1, initgroups() is defined and even documented (giving the parameter
- types as char* and int), but doesn't have a prototype in any of the system
- header files. AIX 4.3, SunOS 4.1.3, and ULTRIX 4.2A have the same
- problem. */
+/*
+** On AIX 4.1, initgroups() is defined and even documented (giving the
+** parameter types as char* and int), but doesn't have a prototype in any
+** of the system header files. AIX 4.3, SunOS 4.1.3, and ULTRIX 4.2A have
+** the same problem.
+*/
extern int initgroups(char*, int);
#endif
-/* This define is needed for Berkeley db v2 and above to
- * make the header file expose the 'historical' ndbm APIs.
- * We define it unconditionally because this is simple and
- * harmless.
- */
+/*
+** This define is needed for Berkeley db v2 and above to
+** make the header file expose the 'historical' ndbm APIs.
+** We define it unconditionally because this is simple and
+** harmless.
+*/
#define DB_DBM_HSEARCH 1
#ifdef NDBM_HEADER
#include NDBM_HEADER
#define NVEC 100
/*
- * Lookup table for matching fields and patterns
- * in messages. The rest of the table is added
- * when the message is parsed.
- */
+** Lookup table for matching fields and patterns
+** in messages. The rest of the table is added
+** when the message is parsed.
+*/
static struct pair hdrs[NVEC + 1] = {
{ "source", NULL, P_HID },
{ "addr", NULL, P_HID },
};
/*
- * The list of builtin variables to expand in a string
- * before it is executed by the "pipe" or "qpipe" action.
- */
+** The list of builtin variables to expand in a string
+** before it is executed by the "pipe" or "qpipe" action.
+*/
static struct pair vars[] = {
{ "sender", NULL, P_NIL },
{ "address", NULL, P_NIL },
extern char **environ;
/*
- * static prototypes
- */
+** static prototypes
+*/
static int localmail (int, char *);
static int usr_delivery (int, char *, int);
static int split (char *, char **);
done (1);
case ADDRSW:
- if (!(addr = *argp++))/* allow -xyz arguments */
+ if (!(addr = *argp++))
+ /* allow -xyz arguments */
adios (NULL, "missing argument to %s", argp[-2]);
continue;
case INFOSW:
- if (!(info = *argp++))/* allow -xyz arguments */
+ if (!(info = *argp++))
+ /* allow -xyz arguments */
adios (NULL, "missing argument to %s", argp[-2]);
continue;
case USERSW:
- if (!(user = *argp++))/* allow -xyz arguments */
+ if (!(user = *argp++))
+ /* allow -xyz arguments */
adios (NULL, "missing argument to %s", argp[-2]);
continue;
case FILESW:
adios (NULL, "missing argument to %s", argp[-2]);
continue;
case SENDERSW:
- if (!(sender = *argp++))/* allow -xyz arguments */
+ if (!(sender = *argp++))
+ /* allow -xyz arguments */
adios (NULL, "missing argument to %s", argp[-2]);
continue;
case MAILBOXSW:
snprintf (ddate, sizeof(ddate), "Delivery-Date: %s\n", dtimenow (0));
/*
- * Copy the message to a temporary file
- */
+ ** Copy the message to a temporary file
+ */
if (file) {
int tempfd;
debug_printf ("temporary file=\"%s\"\n", tmpfil);
/*
- * Delete the temp file now or a copy of every single message
- * passed through slocal will be left in the /tmp directory until
- * deleted manually! This unlink() used to be under an 'else'
- * of the 'if (debug)' above, but since some people like to
- * always run slocal with -debug and log the results, the /tmp
- * directory would get choked over time. Of course, now that
- * we always delete the temp file, the "temporary file=" message
- * above is somewhat pointless -- someone watching debug output
- * wouldn't have a chance to 'tail -f' or 'ln' the temp file
- * before it's unlinked. The best thing would be to delay this
- * unlink() until later if debug == 1, but I'll leave that for
- * someone who cares about the temp-file-accessing functionality
- * (they'll have to watch out for cases where we adios()).
- */
+ ** Delete the temp file now or a copy of every single message
+ ** passed through slocal will be left in the /tmp directory until
+ ** deleted manually! This unlink() used to be under an 'else'
+ ** of the 'if (debug)' above, but since some people like to
+ ** always run slocal with -debug and log the results, the /tmp
+ ** directory would get choked over time. Of course, now that
+ ** we always delete the temp file, the "temporary file=" message
+ ** above is somewhat pointless -- someone watching debug output
+ ** wouldn't have a chance to 'tail -f' or 'ln' the temp file
+ ** before it's unlinked. The best thing would be to delay this
+ ** unlink() until later if debug == 1, but I'll leave that for
+ ** someone who cares about the temp-file-accessing functionality
+ ** (they'll have to watch out for cases where we adios()).
+ */
unlink (tmpfil);
if (!(fp = fdopen (fd, "r+")))
adios (NULL, "unable to access temporary file");
/*
- * If no sender given, extract it
- * from envelope information. */
+ ** If no sender given, extract it
+ ** from envelope information.
+ */
if (sender == NULL)
get_sender (envelope, &sender);
debug_printf ("user=\"%s\"\n", trim(user));
debug_printf ("info=\"%s\"\n", trim(info));
debug_printf ("sender=\"%s\"\n", trim(sender));
- debug_printf ("envelope=\"%s\"\n", envelope ? trim(envelope) : "");
+ debug_printf ("envelope=\"%s\"\n",
+ envelope ? trim(envelope) : "");
debug_printf ("mbox=\"%s\"\n", trim(mbox));
debug_printf ("home=\"%s\"\n", trim(home));
debug_printf ("ddate=\"%s\"\n", trim(ddate));
/*
- * Main routine for delivering message.
- */
+** Main routine for delivering message.
+*/
static int
localmail (int fd, char *mdlvr)
{
/* check if this message is a duplicate */
if (suppressdup &&
- suppress_duplicates(fd, mdlvr ? mdlvr : ".maildelivery") == DONE)
+ suppress_duplicates(fd,
+ mdlvr ? mdlvr : ".maildelivery") == DONE)
return 0;
/* delivery according to personal Maildelivery file */
#define matches(a,b) (stringdex (b, a) >= 0)
/*
- * Parse the delivery file, and process incoming message.
- */
+** Parse the delivery file, and process incoming message.
+*/
static int
usr_delivery (int fd, char *delivery, int su)
|| (st.st_uid != 0 && (su || st.st_uid != pw->pw_uid))
|| st.st_mode & (S_IWGRP|S_IWOTH)) {
if (verbose) {
- verbose_printf ("WARNING: %s has bad ownership/modes (su=%d,uid=%d,owner=%d,mode=0%o)\n",
- delivery, su, (int) pw->pw_uid, (int) st.st_uid, (int) st.st_mode);
+ verbose_printf ("WARNING: %s has bad ownership/modes (su=%d,uid=%d,owner=%d,mode=0%o)\n", delivery, su, (int) pw->pw_uid, (int) st.st_uid, (int) st.st_mode);
}
return -1;
}
if (debug) {
for (i = 0; vec[i]; i++)
- debug_printf ("vec[%d]: \"%s\"\n", i, trim(vec[i]));
+ debug_printf ("vec[%d]: \"%s\"\n",
+ i, trim(vec[i]));
}
field = vec[0];
case 'N':
case 'n':
/*
- * If previous condition failed, don't
- * do this - else fall through
- */
+ ** If previous condition failed, don't
+ ** do this - else fall through
+ */
if (!next)
continue; /* else fall */
case '?':
/*
- * If already delivered, skip this action. Else
- * consider delivered if action is successful.
- */
+ ** If already delivered, skip this action.
+ ** Else consider delivered if action is
+ ** successful.
+ */
if (won)
continue; /* else fall */
case 'A':
case 'a':
/*
- * Take action, and consider delivered if
- * action is successful.
- */
+ ** Take action, and consider delivered if
+ ** action is successful.
+ */
accept = 1;
break;
case 'r':
default:
/*
- * Take action, but don't consider delivered, even
- * if action is successful
- */
+ ** Take action, but don't consider delivered,
+ ** even if action is successful
+ */
accept = 0;
break;
}
case 'd':
/*
- * "default" matches only if the message hasn't
- * been delivered yet.
- */
+ ** "default" matches only if the message hasn't
+ ** been delivered yet.
+ */
if (!mh_strcasecmp (field, "default")) {
if (won)
continue;
return -1;
}
/*
- * find header field in lookup table, and
- * see if the pattern matches.
- */
- if ((p = lookup (hdrs, field)) && (p->p_value != NULL)
- && matches (p->p_value, pattern)) {
+ ** find header field in lookup table, and
+ ** see if the pattern matches.
+ */
+ if ((p = lookup (hdrs, field)) &&
+ (p->p_value != NULL) &&
+ matches (p->p_value, pattern)
+ ) {
next = 1;
} else {
next = 0;
expand (tmpbuf, string, fd);
vec[4] = tmpbuf;
vec[5] = NULL;
- status = usr_pipe (fd, tmpbuf, "/bin/sh", vec + 2, 0);
+ status = usr_pipe (fd, tmpbuf, "/bin/sh",
+ vec + 2, 0);
break;
case 'f':
/* mbox format */
if (!mh_strcasecmp (action, "file")) {
- status = usr_file (fd, string, MBOX_FORMAT);
+ status = usr_file (fd, string,
+ MBOX_FORMAT);
break;
}
/* deliver to nmh folder */
case 'm':
/* mmdf format */
if (!mh_strcasecmp (action, "mmdf")) {
- status = usr_file (fd, string, MMDF_FORMAT);
+ status = usr_file (fd, string,
+ MMDF_FORMAT);
break;
}
/* mbox format */
#define QUOTE '\\'
/*
- * Split buffer into fields (delimited by whitespace or
- * comma's). Return the number of fields found.
- */
+** Split buffer into fields (delimited by whitespace or
+** comma's). Return the number of fields found.
+*/
static int
split (char *cp, char **vec)
if (*s == '"') {
for (vec[i++] = ++s; *s && *s != '"'; s++) {
/*
- * Check for escaped double quote. We need
- * to shift the string to remove slash.
- */
+ ** Check for escaped double quote. We need
+ ** to shift the string to remove slash.
+ */
if (*s == QUOTE) {
if (*++s == '"')
strcpy (s - 1, s);
/*
- * Parse the headers of a message, and build the
- * lookup table for matching fields and patterns.
- */
+** Parse the headers of a message, and build the
+** lookup table for matching fields and patterns.
+*/
static int
parse (int fd)
* a lookup table.
*/
for (i = 0, state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), in)) {
+ switch (state = m_getfld (state, name, field, sizeof(field),
+ in)) {
case FLD:
case FLDEOF:
case FLDPLUS:
#define RPAREN ')'
/*
- * Expand any builtin variables such as $(sender),
- * $(address), etc., in a string.
- */
+** Expand any builtin variables such as $(sender),
+** $(address), etc., in a string.
+*/
static void
expand (char *s1, char *s2, int fd)
/*
- * Fill in the information missing from the "vars"
- * table, which is necessary to expand any builtin
- * variables in the string for a "pipe" or "qpipe"
- * action.
- */
+** Fill in the information missing from the "vars"
+** table, which is necessary to expand any builtin
+** variables in the string for a "pipe" or "qpipe"
+** action.
+*/
static void
glob (int fd)
/*
- * Find a matching name in a lookup table. If found,
- * return the "pairs" entry, else return NULL.
- */
+** Find a matching name in a lookup table. If found,
+** return the "pairs" entry, else return NULL.
+*/
static struct pair *
lookup (struct pair *pairs, char *key)
/*
- * Check utmp(x) file to see if user is currently
- * logged in.
- */
+** Check utmp(x) file to see if user is currently
+** logged in.
+*/
#ifdef HAVE_GETUTENT
static int
while ((utp = getutent()) != NULL) {
if (
#ifdef HAVE_STRUCT_UTMP_UT_TYPE
- utp->ut_type == USER_PROCESS
- &&
+ utp->ut_type == USER_PROCESS &&
#endif
- utp->ut_name[0] != 0
- && strncmp (user, utp->ut_name, sizeof(utp->ut_name)) == 0) {
+ utp->ut_name[0] != 0 &&
+ strncmp (user, utp->ut_name,
+ sizeof(utp->ut_name)) == 0) {
if (debug)
continue;
endutent();
return NOTOK;
while (fread ((char *) &ut, sizeof(ut), 1, uf) == 1) {
- if (ut.ut_name[0] != 0
- && strncmp (user, ut.ut_name, sizeof(ut.ut_name)) == 0) {
+ if (ut.ut_name[0] != 0 &&
+ strncmp (user, ut.ut_name, sizeof(ut.ut_name))
+ == 0) {
if (debug)
continue;
fclose (uf);
/*
- * Deliver message by appending to a file.
- */
+** Deliver message by appending to a file.
+*/
static int
usr_file (int fd, char *mailbox, int mbx_style)
}
/* open and lock the file */
- if ((md = mbx_open (mailbox, mbx_style, pw->pw_uid, pw->pw_gid, m_gmprot())) == -1) {
+ if ((md = mbx_open (mailbox, mbx_style, pw->pw_uid, pw->pw_gid,
+ m_gmprot())) == -1) {
if (verbose)
adorn ("", "unable to open:");
return -1;
lseek (fd, (off_t) 0, SEEK_SET);
/* append message to file */
- if (mbx_copy (mailbox, mbx_style, md, fd, mapping, NULL, verbose) == -1) {
+ if (mbx_copy (mailbox, mbx_style, md, fd, mapping, NULL, verbose)
+ == -1) {
if (verbose)
adorn ("", "error writing to:");
return -1;
/*
- * Deliver message to a nmh folder.
- */
+** Deliver message to a nmh folder.
+*/
static int
usr_folder (int fd, char *string)
#if 0
/*
- * Currently, verbose status messages are handled by usr_pipe().
- */
+ ** Currently, verbose status messages are handled by usr_pipe().
+ */
if (verbose) {
if (status == 0)
verbose_printf (", success.\n");
}
/*
- * Deliver message to a process.
- */
+** Deliver message to a process.
+*/
static int
usr_pipe (int fd, char *cmd, char *pgm, char **vec, int suppress)
}
#endif /* TIOCNOTTY */
- setpgid ((pid_t) 0, getpid ()); /* put in own process group */
+ /* put in own process group */
+ setpgid ((pid_t) 0, getpid ());
*environ = NULL;
m_putenv ("USER", pw->pw_name);
/* parent process */
if (!setjmp (myctx)) {
SIGNAL (SIGALRM, alrmser);
- bytes = fstat (fd, &st) != -1 ? (int) st.st_size : 100;
+ bytes = fstat (fd, &st) != -1 ?
+ (int) st.st_size : 100;
- /* amount of time to wait depends on message size */
+ /*
+ ** amount of time to wait depends on
+ ** message size
+ */
if (bytes <= 100) {
/* give at least 5 minutes */
seconds = 300;
return (status == 0 ? 0 : -1);
} else {
/*
- * Ruthlessly kill the child and anything
- * else in its process group.
- */
+ ** Ruthlessly kill the child and anything
+ ** else in its process group.
+ */
KILLPG(child_id, SIGKILL);
if (verbose)
verbose_printf (", timed-out; terminated\n");
/*
- * Get the `sender' from the envelope
- * information ("From " line).
- */
+** Get the `sender' from the envelope
+** information ("From " line).
+*/
static void
get_sender (char *envelope, char **sender)
/*
- * Copy message into a temporary file.
- * While copying, it will do some header processing
- * including the extraction of the envelope information.
- */
+** Copy message into a temporary file.
+** While copying, it will do some header processing
+** including the extraction of the envelope information.
+*/
static int
copy_message (int qd, char *tmpfil, int fold)
}
/*
- * copy message into temporary file
- * and massage the headers. Save
- * a copy of the "From " line for later.
- */
+ ** copy message into temporary file
+ ** and massage the headers. Save
+ ** a copy of the "From " line for later.
+ */
i = strlen ("From ");
while (fgets (buffer, sizeof(buffer), qfp)) {
if (first) {
#ifdef RPATHS
char *fp, *cp, *hp, *ep;
#endif
- /* get copy of envelope information ("From " line) */
+ /*
+ ** get copy of envelope information
+ ** ("From " line)
+ */
envelope = getcpy (buffer);
#if 0
- /* First go ahead and put "From " line in message */
+ /*
+ ** First go ahead and put "From " line
+ ** in message
+ */
fputs (buffer, ffp);
if (ferror (ffp))
goto fputs_error;
#ifdef RPATHS
/*
- * Now create a "Return-Path:" line
- * from the "From " line.
- */
+ ** Now create a "Return-Path:" line
+ ** from the "From " line.
+ */
hp = cp = strchr(fp = envelope + i, ' ');
while ((hp = strchr(++hp, 'r')))
if (uprf (hp, "remote from")) {
break;
}
if (hp) {
- /* return path for UUCP style addressing */
+ /*
+ ** return path for UUCP style
+ ** addressing
+ */
ep = strchr(++hp, '\n');
- snprintf (buffer, sizeof(buffer), "Return-Path: %.*s!%.*s\n",
- (int)(ep - hp), hp, (int)(cp - fp), fp);
+ snprintf (buffer, sizeof(buffer), "Return-Path: %.*s!%.*s\n", (int)(ep - hp), hp, (int)(cp - fp), fp);
} else {
- /* return path for standard domain addressing */
- snprintf (buffer, sizeof(buffer), "Return-Path: %.*s\n",
- (int)(cp - fp), fp);
+ /*
+ ** return path for standard domain
+ ** addressing
+ */
+ snprintf (buffer, sizeof(buffer), "Return-Path: %.*s\n", (int)(cp - fp), fp);
}
/* Add Return-Path header to message */
}
/*
- * Trim strings for pretty printing of debugging output
- */
+** Trim strings for pretty printing of debugging output
+*/
static char *
trim (char *cp)
}
/*
- * Function for printing `verbose' messages.
- */
+** Function for printing `verbose' messages.
+*/
static void
verbose_printf (char *fmt, ...)
/*
- * Function for printing `verbose' delivery
- * error messages.
- */
+** Function for printing `verbose' delivery
+** error messages.
+*/
static void
adorn (char *what, char *fmt, ...)
/*
- * Function for printing `debug' messages.
- */
+** Function for printing `debug' messages.
+*/
static void
debug_printf (char *fmt, ...)
/*
- * Check ndbm/db file(s) to see if the Message-Id of this
- * message matches the Message-Id of a previous message,
- * so we can discard it. If it doesn't match, we add the
- * Message-Id of this message to the ndbm/db file.
- */
+** Check ndbm/db file(s) to see if the Message-Id of this
+** message matches the Message-Id of a previous message,
+** so we can discard it. If it doesn't match, we add the
+** Message-Id of this message to the ndbm/db file.
+*/
static int
suppress_duplicates (int fd, char *file)
{
return -1;
}
/*
- * Since it is difficult to portable
- * lock a ndbm file, we will open and
- * lock the Maildelivery file instead.
- * This will fail if your Maildelivery
- * file doesn't exist.
- */
+ ** Since it is difficult to portable
+ ** lock a ndbm file, we will open and
+ ** lock the Maildelivery file instead.
+ ** This will fail if your Maildelivery
+ ** file doesn't exist.
+ */
if ((lockfd = lkopen(file, O_RDWR, 0)) == -1) {
advise (file, "unable to perform file locking on");
free (cp);
value = dbm_fetch (db, key);
if (value.dptr) {
if (verbose)
- verbose_printf ("Message-ID: %s\n already received on %s",
- cp, value.dptr);
+ verbose_printf ("Message-ID: %s\n already received on %s", cp, value.dptr);
result = DONE;
} else {
value.dptr = ddate + sizeof("Delivery-Date:");
/*
- * sortm.c -- sort messages in a folder by date/time
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** sortm.c -- sort messages in a folder by date/time
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/tws.h>
typedef int (*qsort_comp) (const void *, const void *);
/*
- * static prototypes
- */
+** static prototypes
+*/
static int read_hdrs (struct msgs *, char *);
static int get_fields (char *, int, struct smsg *);
static int dsort (struct smsg **, struct smsg **);
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
if (datesw)
adios (NULL, "only one date field at a time");
if (!(datesw = *argp++) || *datesw == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case TEXTSW:
if (subjsort)
adios (NULL, "only one text field at a time");
if (!(subjsort = *argp++) || *subjsort == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case SUBJSW:
else
folder = pluspath (cp);
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
if (!context_find ("path"))
adios (NULL, "no messages to sort");
/*
- * sort a list of pointers to our "messages to be sorted".
- */
+ ** sort a list of pointers to our "messages to be sorted".
+ */
dlist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*dlist));
for (i = 0; i < nmsgs; i++)
dlist[i] = &smsgs[i];
(qsort_comp) (submajor && subjsort ? txtsort : dsort));
/*
- * if we're sorting on subject, we need another list
- * in subject order, then a merge pass to collate the
- * two sorts.
- */
+ ** if we're sorting on subject, we need another list
+ ** in subject order, then a merge pass to collate the
+ ** two sorts.
+ */
if (!submajor && subjsort) { /* already date sorted */
struct smsg **slist, **flist;
register struct smsg ***il, **fp, **dp;
- slist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*slist));
+ slist = (struct smsg **)
+ mh_xmalloc ((nmsgs+1) * sizeof(*slist));
memcpy((char *)slist, (char *)dlist, (nmsgs+1)*sizeof(*slist));
- qsort((char *)slist, nmsgs, sizeof(*slist), (qsort_comp) subsort);
+ qsort((char *)slist, nmsgs, sizeof(*slist),
+ (qsort_comp) subsort);
/*
- * make an inversion list so we can quickly find
- * the collection of messages with the same subj
- * given a message number.
- */
+ ** make an inversion list so we can quickly find
+ ** the collection of messages with the same subj
+ ** given a message number.
+ */
il = (struct smsg ***) calloc (mp->hghsel+1, sizeof(*il));
if (! il)
adios (NULL, "couldn't allocate msg list");
for (i = 0; i < nmsgs; i++)
il[slist[i]->s_msg] = &slist[i];
/*
- * make up the final list, chronological but with
- * all the same subjects grouped together.
- */
- flist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*flist));
+ ** make up the final list, chronological but with
+ ** all the same subjects grouped together.
+ */
+ flist = (struct smsg **)
+ mh_xmalloc ((nmsgs+1) * sizeof(*flist));
fp = flist;
for (dp = dlist; *dp;) {
register struct smsg **s = il[(*dp++)->s_msg];
*fp++ = *s++;
/*
- * take the next message(s) if there is one,
- * its subject isn't null and its subject
- * is the same as this one and it's not too
- * far away in time.
- */
- while (*s && (*s)->s_subj[0] &&
- strcmp((*s)->s_subj, s[-1]->s_subj) == 0 &&
- (datelimit == 0 ||
- (*s)->s_clock - s[-1]->s_clock <= datelimit)) {
+ ** take the next message(s) if there is one,
+ ** its subject isn't null and its subject
+ ** is the same as this one and it's not too
+ ** far away in time.
+ */
+ while (*s && (*s)->s_subj[0] && strcmp((*s)->s_subj, s[-1]->s_subj) == 0 && (datelimit == 0 || (*s)->s_clock - s[-1]->s_clock <= datelimit)) {
il[(*s)->s_msg] = 0;
*fp++ = *s++;
}
}
/*
- * At this point, dlist is a sorted array of pointers to smsg
- * structures, each of which contains a message number.
- */
+ ** At this point, dlist is a sorted array of pointers to smsg
+ ** structures, each of which contains a message number.
+ */
rename_msgs (mp, dlist);
/*
- * Parse the message and get the data or subject field,
- * if needed.
- */
+** Parse the message and get the data or subject field,
+** if needed.
+*/
static int
get_fields (char *datesw, int msg, struct smsg *smsg)
if (!mh_strcasecmp (nam, datesw)) {
datecomp = add (buf, datecomp);
while (state == FLDPLUS) {
- state = m_getfld (state, nam, buf, sizeof(buf), in);
+ state = m_getfld (state, nam, buf,
+ sizeof(buf), in);
datecomp = add (buf, datecomp);
}
if (!subjsort || subjcomp)
break;
- } else if (subjsort && !mh_strcasecmp (nam, subjsort)) {
+ } else if (subjsort && !mh_strcasecmp(nam, subjsort)) {
subjcomp = add (buf, subjcomp);
while (state == FLDPLUS) {
- state = m_getfld (state, nam, buf, sizeof(buf), in);
+ state = m_getfld (state, nam, buf,
+ sizeof(buf), in);
subjcomp = add (buf, subjcomp);
}
if (datecomp)
} else {
/* just flush this guy */
while (state == FLDPLUS)
- state = m_getfld (state, nam, buf, sizeof(buf), in);
+ state = m_getfld (state, nam, buf,
+ sizeof(buf), in);
}
continue;
case LENERR:
case FMTERR:
if (state == LENERR || state == FMTERR)
- admonish (NULL, "format error in message %d (header #%d)",
- msg, compnum);
+ admonish (NULL, "format error in message %d (header #%d)", msg, compnum);
if (datecomp)
free (datecomp);
if (subjcomp)
}
/*
- * If no date component, then use the modification
- * time of the file as its date
- */
+ ** If no date component, then use the modification
+ ** time of the file as its date
+ */
if (!datecomp || (tw = dparsetime (datecomp)) == NULL) {
struct stat st;
- admonish (NULL, "can't parse %s field in message %d", datesw, msg);
+ admonish (NULL, "can't parse %s field in message %d",
+ datesw, msg);
fstat (fileno (in), &st);
smsg->s_clock = st.st_mtime;
} else {
if (subjsort) {
if (subjcomp) {
/*
- * try to make the subject "canonical": delete
- * leading "re:", everything but letters & smash
- * letters to lower case.
- */
+ ** try to make the subject "canonical": delete
+ ** leading "re:", everything but letters & smash
+ ** letters to lower case.
+ */
register char *cp, *cp2;
register unsigned char c;
}
*cp2 = '\0';
- }
- else
+ } else
subjcomp = "";
smsg->s_subj = subjcomp;
}
/*
- * sort on dates.
- */
+** sort on dates.
+*/
static int
dsort (struct smsg **a, struct smsg **b)
{
}
/*
- * sort on subjects.
- */
+** sort on subjects.
+*/
static int
subsort (struct smsg **a, struct smsg **b)
{
if (verbose)
printf ("message %d becomes message %d\n", old, new);
- (void)snprintf(oldname, sizeof (oldname), "%s/%d", mp->foldpath, old);
- (void)snprintf(newbuf, sizeof (newbuf), "%s/%d", mp->foldpath, new);
+ snprintf(oldname, sizeof (oldname), "%s/%d",
+ mp->foldpath, old);
+ snprintf(newbuf, sizeof (newbuf), "%s/%d", mp->foldpath, new);
ext_hook("ref-hook", oldname, newbuf);
if (rename (oldname, newname) == NOTOK)
continue; /* this one doesn't move */
/*
- * the guy that was msg j is about to become msg i.
- * rename 'j' to make a hole, then recursively rename
- * guys to fill up the hole.
- */
+ ** the guy that was msg j is about to become msg i.
+ ** rename 'j' to make a hole, then recursively rename
+ ** guys to fill up the hole.
+ */
old = smsgs[j].s_msg;
new = smsgs[i].s_msg;
strncpy (f1, m_name (old), sizeof(f1));
if (verbose)
- printf ("renaming message chain from %d to %d\n", old, new);
+ printf ("renaming message chain from %d to %d\n",
+ old, new);
/*
- * Run the external hook to refile the old message as the
- * temporary message number that is off of the end of the
- * messages in the folder.
- */
+ ** Run the external hook to refile the old message as the
+ ** temporary message number that is off of the end of the
+ ** messages in the folder.
+ */
(void)snprintf(f1, sizeof (f1), "%s/%d", mp->foldpath, old);
- (void)snprintf(newbuf, sizeof (newbuf), "%s/%d", mp->foldpath, mp->hghmsg + 1);
+ (void)snprintf(newbuf, sizeof (newbuf), "%s/%d",
+ mp->foldpath, mp->hghmsg + 1);
ext_hook("ref-hook", f1, newbuf);
if (rename (f1, tmpfil) == NOTOK)
rename_chain (mp, mlist, j, i);
/*
- * Run the external hook to refile the temorary message number
- * to the real place.
- */
+ ** Run the external hook to refile the temorary message number
+ ** to the real place.
+ */
(void)snprintf(f1, sizeof (f1), "%s/%d", mp->foldpath, new);
ext_hook("ref-hook", newbuf, f1);
/*
- * spost.c -- feed messages to sendmail
- *
- * This is a simpler, faster, replacement for "post" for use
- * when "sendmail" is the transport system.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** spost.c -- feed messages to sendmail
+**
+** This is a simpler, faster, replacement for "post" for use
+** when "sendmail" is the transport system.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <signal.h>
extern char *sendmail;
/*
- * external prototypes
- */
+** external prototypes
+*/
extern char *getfullname (void);
extern char *getusername (void);
extern boolean draft_from_masquerading; /* defined in mts.c */
/*
- * static prototypes
- */
+** static prototypes
+*/
static void putfmt (char *, char *, FILE *);
static void start_headers (void);
static void finish_headers (FILE *);
continue;
case FILTSW:
- if (!(filter = *argp++) || *filter == '-')
+ if (!(filter = *argp++) ||
+ *filter == '-')
adios (NULL, "missing argument to %s", argp[-2]);
continue;
case NFILTSW:
case ALIASW:
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
- if (aliasflg < 0)
- alias (AliasFile);/* load default aka's */
+ if (aliasflg < 0) {
+ /* load default aka's */
+ alias (AliasFile);
+ }
aliasflg = 1;
if ((state = alias(cp)) != AK_OK)
- adios (NULL, "aliasing error in file %s - %s",
- cp, akerror(state) );
+ adios (NULL, "aliasing error in file %s - %s", cp, akerror(state) );
continue;
case NALIASW:
aliasflg = 0;
finish_headers (out);
fprintf (out, "\n%s", buf);
while (state == BODY) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ state = m_getfld (state, name, buf,
+ sizeof(buf), in);
fputs (buf, out);
}
break;
case LENERR:
case FMTERR:
- adios (NULL, "message format error in component #%d",
- compnum);
+ adios (NULL, "message format error in component #%d", compnum);
default:
adios (NULL, "getfld() returned %d", state);
file (tmpfil);
/*
- * re-open the temp file, unlink it and exec sendmail, giving it
- * the msg temp file as std in.
- */
+ ** re-open the temp file, unlink it and exec sendmail, giving it
+ ** the msg temp file as std in.
+ */
if ( freopen( tmpfil, "r", stdin) == NULL)
adios (tmpfil, "can't reopen for sendmail");
if (rmflg)
sleep(5);
switch (pid) {
case NOTOK:
- fprintf (verbose ? stdout : stderr, "%s: can't fork to %s\n",
- invo_name, sendmail);
+ fprintf (verbose ? stdout : stderr,
+ "%s: can't fork to %s\n",
+ invo_name, sendmail);
exit(-1);
case OK:
/* we're the child .. */
msgflags |= hdr->set;
if (hdr->flags & HSUB)
- subject = subject ? add (str, add ("\t", subject)) : getcpy (str);
+ subject = subject ? add (str, add ("\t", subject)) :
+ getcpy (str);
if (hdr->flags & HFCC) {
if ((cp = strrchr(str, '\n')))
if (*str != '\n' && *str != '\0') {
if (aliasflg && hdr->flags & HTRY) {
- /* this header contains address(es) that we have to do
- * alias expansion on. Because of the saved state in
- * getname we have to put all the addresses into a list.
- * We then let putadr munch on that list, possibly
- * expanding aliases.
- */
+ /*
+ ** this header contains address(es) that we have to do
+ ** alias expansion on. Because of the saved state in
+ ** getname we have to put all the addresses into a
+ ** list. We then let putadr munch on that list,
+ ** possibly expanding aliases.
+ **/
register struct mailname *f = 0;
register struct mailname *mp = 0;
putadr( name, f );
} else {
/*
- * The author(s) of spost decided that alias
- * substitution wasn't necessary for the non-HTRY
- * headers. Unfortunately, one of those headers
- * is "From:", and having alias substitution
- * work on that is extremely useful for someone
- * with a lot of POP3 email accounts or aliases.
- * post supports aliasing of "From:"...
- *
- * Since "From:"-processing is incompletely
- * implemented in this unsupported and
- * undocumented spost backend, I'm not
- * going to take the time to implement my new
- * draft-From:-based email address masquerading.
- * If I do ever implement it here, I'd almost
- * certainly want to implement "From:" line
- * alias processing as well.
- * -- Dan Harkless <dan-nmh@dilvish.speed.net>
- */
+ ** The author(s) of spost decided that alias
+ ** substitution wasn't necessary for the non-HTRY
+ ** headers. Unfortunately, one of those headers
+ ** is "From:", and having alias substitution
+ ** work on that is extremely useful for someone
+ ** with a lot of POP3 email accounts or aliases.
+ ** post supports aliasing of "From:"...
+ **
+ ** Since "From:"-processing is incompletely
+ ** implemented in this unsupported and
+ ** undocumented spost backend, I'm not
+ ** going to take the time to implement my new
+ ** draft-From:-based email address masquerading.
+ ** If I do ever implement it here, I'd almost
+ ** certainly want to implement "From:" line
+ ** alias processing as well.
+ ** -- Dan Harkless <dan-nmh@dilvish.speed.net>
+ */
fprintf (out, "%s: %s", name, str );
}
}
if ((cp = getfullname ()) && *cp) {
strncpy (sigbuf, cp, sizeof(sigbuf));
- snprintf (signature, sizeof(signature), "%s <%s>", sigbuf, from);
+ snprintf (signature, sizeof(signature), "%s <%s>",
+ sigbuf, from);
} else
snprintf (signature, sizeof(signature), "%s", from);
}
fprintf (out, "Date: %s\n", dtimenow (0));
if (msgflags & MFRM) {
- /* There was already a From: in the draft. Don't add one. */
+ /*
+ ** There was already a From: in the draft.
+ ** Don't add one.
+ */
if (!draft_from_masquerading)
/*
- * mts.conf didn't contain
- * "masquerade:[...]draft_from[...]"
- * so we'll reveal the user's
- * actual account@thismachine
- * address in a Sender: header
- * (and use it as the envelope
- * From: later).
- */
+ ** mts.conf didn't contain
+ ** "masquerade:[...]draft_from[...]"
+ ** so we'll reveal the user's
+ ** actual account@thismachine
+ ** address in a Sender: header
+ ** (and use it as the envelope
+ ** From: later).
+ */
fprintf (out, "Sender: %s\n", from);
} else
fprintf (out, "From: %s\n", signature);
case resent:
if (!(msgflags & MRDT))
- fprintf (out, "Resent-Date: %s\n", dtimenow(0));
+ fprintf (out, "Resent-Date: %s\n",
+ dtimenow(0));
if (msgflags & MRFM) {
- /* There was already a Resent-From: in draft. Don't add one. */
+ /*
+ ** There was already a Resent-From: in draft.
+ ** Don't add one.
+ */
if (!draft_from_masquerading)
/*
- * mts.conf didn't contain
- * "masquerade:[...]draft_from[...]"
- * so we'll reveal the user's
- * actual account@thismachine
- * address in a Sender: header
- * (and use it as the envelope
- * From: later).
- */
- fprintf (out, "Resent-Sender: %s\n", from);
+ ** mts.conf didn't contain
+ ** "masquerade:[...]draft_from[...]"
+ ** so we'll reveal the user's
+ ** actual account@thismachine
+ ** address in a Sender: header
+ ** (and use it as the envelope
+ ** From: later).
+ */
+ fprintf (out, "Resent-Sender: %s\n",
+ from);
} else
/* Construct a Resent-From: header. */
fprintf (out, "Resent-From: %s\n", signature);
/*
- * output the address list for header "name". The address list
- * is a linked list of mailname structs. "nl" points to the head
- * of the list. Alias substitution should be done on nl.
- */
+** output the address list for header "name". The address list
+** is a linked list of mailname structs. "nl" points to the head
+** of the list. Alias substitution should be done on nl.
+*/
static void
putadr (char *name, struct mailname *nl)
{
for (mp = nl; mp; ) {
if (linepos > MAX_SM_FIELD) {
- fprintf (out, "\n%s: ", name);
- linepos = namelen;
+ fprintf (out, "\n%s: ", name);
+ linepos = namelen;
}
if (mp->m_nohost) {
/* a local name - see if it's an alias */
cp = akvalue(mp->m_mbox);
if (cp == mp->m_mbox)
/* wasn't an alias - use what the user typed */
- linepos = putone( mp->m_text, linepos, namelen );
+ linepos = putone(mp->m_text, linepos, namelen);
else
/* an alias - expand it */
while ((cp = getname(cp))) {
fprintf ( out, ",\n%*s", indent, "");
linepos = indent;
pos += indent + 2;
- }
- else {
+ } else {
fputs( ", ", out );
linepos += 2;
pos += 2;
/* There was already a From: in the draft. Don't add one. */
if (!draft_from_masquerading)
/*
- * mts.conf didn't contain "masquerade:[...]draft_from[...]"
- * so we'll reveal the user's actual account@thismachine
- * address in a Sender: header (and use it as the envelope
- * From: later).
- */
+ ** mts.conf didn't contain "masquerade:[...]draft_from[...]"
+ ** so we'll reveal the user's actual account@thismachine
+ ** address in a Sender: header (and use it as the envelope
+ ** From: later).
+ */
fprintf (out, "Sender: %s\n", from);
} else
/* Construct a From: header. */
default:
if (status = pidwait(child_id, OK))
- admonish (NULL, "%s lost (status=0%o)", vec[0], status);
+ admonish (NULL, "%s lost (status=0%o)",
+ vec[0], status);
break;
}
}
#if 0
/*
- * TERMINATION
- */
+** TERMINATION
+*/
static void
die (char *what, char *fmt, ...)
/*
- * termsbr.c -- termcap support
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** termsbr.c -- termcap support
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#endif
/*
- * These variables are sometimes defined in,
- * and needed by the termcap library.
- */
+** These variables are sometimes defined in,
+** and needed by the termcap library.
+*/
#ifdef HAVE_OSPEED
# ifdef MUST_DEFINE_OSPEED
extern short ospeed;
return;
/*
- * If possible, we let tgetent allocate its own termcap buffer
- */
+** If possible, we let tgetent allocate its own termcap buffer
+*/
#ifdef TGETENT_ACCEPTS_NULL
if (tgetent (NULL, term) != TGETENT_SUCCESS)
return;
speedcode = cfgetospeed(&tio);
#else
# ifdef HAVE_TERMIO_H
- speedcode = ioctl(fileno(stdout), TCGETA, &tio) != NOTOK ? tio.c_cflag & CBAUD : 0;
+ speedcode = ioctl(fileno(stdout), TCGETA, &tio) != NOTOK ?
+ tio.c_cflag & CBAUD : 0;
# else
- speedcode = ioctl(fileno(stdout), TIOCGETP, (char *) &tio) != NOTOK ? tio.sg_ospeed : 0;
+ speedcode = ioctl(fileno(stdout), TIOCGETP, (char *) &tio) != NOTOK ?
+ tio.sg_ospeed : 0;
# endif
#endif
/*
- * print in standout mode
- */
+** print in standout mode
+*/
int
SOprintf (char *fmt, ...)
{
}
/*
- * Is this a hardcopy terminal?
- */
+** Is this a hardcopy terminal?
+*/
int
sc_hardcopy(void)
/*
- * viamail.c -- send multiple files in a MIME message
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** viamail.c -- send multiple files in a MIME message
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
int writeBase64aux (FILE *, FILE *);
/*
- * static prototypes
- */
+** static prototypes
+*/
static int via_mail (char *, char *, char *, char *, char *, char *);
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches]", invo_name);
+ snprintf (buf, sizeof(buf), "%s [switches]",
+ invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
case TOSW:
if (!(f1 = *argp++))
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case SUBJECTSW:
if (!(f2 = *argp++))
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case PARAMSW:
if (!(f3 = *argp++))
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case DESCRIPTSW:
if (!(f4 = *argp++))
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case COMMENTSW:
if (!(f5 = *argp++))
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case FROMSW:
if (!(f7 = *argp++))
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case VERBSW:
/*
- * VIAMAIL
- */
+** VIAMAIL
+*/
static int
via_mail (char *mailsw, char *subjsw, char *parmsw, char *descsw,
/*
- * whatnow.c -- the nmh `WhatNow' shell
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** whatnow.c -- the nmh `WhatNow' shell
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * whatnowproc.c -- exec the "whatnowproc"
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** whatnowproc.c -- exec the "whatnowproc"
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
/*
- * This routine is used by comp, repl, forw, and dist to exec
- * the "whatnowproc". It first sets up all the environment
- * variables that the "whatnowproc" will need to check, and
- * then execs the command. As an optimization, if the
- * "whatnowproc" is the nmh command "whatnow" (typical case),
- * it will call this routine directly without exec'ing it.
- */
+** This routine is used by comp, repl, forw, and dist to exec
+** the "whatnowproc". It first sets up all the environment
+** variables that the "whatnowproc" will need to check, and
+** then execs the command. As an optimization, if the
+** "whatnowproc" is the nmh command "whatnow" (typical case),
+** it will call this routine directly without exec'ing it.
+*/
/* from whatnowsbr.c */
int WhatNow (int, char **);
if (mp == NULL || *altmsg == '/' || cwd == NULL)
m_putenv ("mhaltmsg", altmsg);
else {
- snprintf (buffer, sizeof(buffer), "%s/%s", mp->foldpath, altmsg);
+ snprintf (buffer, sizeof(buffer), "%s/%s",
+ mp->foldpath, altmsg);
m_putenv ("mhaltmsg", buffer);
}
} else {
buflen = sizeof(buffer);
for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) {
if (is_selected(mp, msgnum)) {
- snprintf (bp, buflen, "%s%s", found ? " " : "", m_name (msgnum));
+ snprintf (bp, buflen, "%s%s",
+ found ? " " : "",
+ m_name (msgnum));
len = strlen (bp);
bp += len;
buflen -= len;
for (k = msgnum + 1; k <= mp->hghmsg && is_selected(mp, k); k++)
continue;
if (--k > msgnum) {
- snprintf (bp, buflen, "-%s", m_name (k));
+ snprintf (bp, buflen, "-%s",
+ m_name (k));
len = strlen (bp);
bp += len;
buflen -= len;
chdir (cwd);
/*
- * If the "whatnowproc" is the nmh command "whatnow",
- * we run it internally, rather than exec'ing it.
- */
+ ** If the "whatnowproc" is the nmh command "whatnow",
+ ** we run it internally, rather than exec'ing it.
+ */
if (strcmp (vec[0], "whatnow") == 0) {
WhatNow (vecp, vec);
done (0);
/*
- * whatnowsbr.c -- the WhatNow shell
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- *
- * Several options have been added to ease the inclusion of attachments
- * using the header field name mechanism added to anno and send. The
- * -attach option is used to specify the header field name for attachments.
- *
- * Several commands have been added at the whatnow prompt:
- *
- * cd [ directory ] This option works just like the shell's
- * cd command and lets the user change the
- * directory from which attachments are
- * taken so that long path names are not
- * needed with every file.
- *
- * ls [ ls-options ] This option works just like the normal
- * ls command and exists to allow the user
- * to verify file names in the directory.
- *
- * pwd This option works just like the normal
- * pwd command and exists to allow the user
- * to verify the directory.
- *
- * attach files This option attaches the named files to
- * the draft.
- *
- * alist [-ln] This option lists the attachments on the
- * draft. -l gets long listings, -n gets
- * numbered listings.
- *
- * detach files This option removes attachments from the
- * detach -n numbers draft. This can be done by file name or
- * by attachment number.
- */
+** whatnowsbr.c -- the WhatNow shell
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+**
+** Several options have been added to ease the inclusion of attachments
+** using the header field name mechanism added to anno and send. The
+** -attach option is used to specify the header field name for attachments.
+**
+** Several commands have been added at the whatnow prompt:
+**
+** cd [ directory ] This option works just like the shell's
+** cd command and lets the user change the
+** directory from which attachments are
+** taken so that long path names are not
+** needed with every file.
+**
+** ls [ ls-options ] This option works just like the normal
+** ls command and exists to allow the user
+** to verify file names in the directory.
+**
+** pwd This option works just like the normal
+** pwd command and exists to allow the user
+** to verify the directory.
+**
+** attach files This option attaches the named files to
+** the draft.
+**
+** alist [-ln] This option lists the attachments on the
+** draft. -l gets long listings, -n gets
+** numbered listings.
+**
+** detach files This option removes attachments from the
+** detach -n numbers draft. This can be done by file name or
+** by attachment number.
+*/
#include <h/mh.h>
#include <fcntl.h>
};
/*
- * Options at the "whatnow" prompt
- */
+** Options at the "whatnow" prompt
+*/
static struct swit aleqs[] = {
#define EDITSW 0
{ "edit [<editor> <switches>]", 0 },
static char *myprompt = "\nWhat now? ";
/*
- * static prototypes
- */
+** static prototypes
+*/
static int editfile (char **, char **, char *, int, struct msgs *,
char *, char *, int);
static int sendfile (char **, char *, int);
argp = arguments;
/*
- * Get the initial current working directory.
- */
+ ** Get the initial current working directory.
+ */
if (getcwd(cwd, sizeof (cwd)) == (char *)0) {
adios("getcwd", "could not get working directory");
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] [file]", invo_name);
+ snprintf (buf, sizeof(buf),
+ "%s [switches] [file]",
+ invo_name);
print_help (buf, whatnowswitches, 1);
done (1);
case VERSIONSW:
case EDITRSW:
if (!(ed = *argp++) || *ed == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
nedit = 0;
continue;
case NEDITSW:
case PRMPTSW:
if (!(myprompt = *argp++) || *myprompt == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case ATTACHSW:
if (attach != (char *)0)
adios(NULL, "only one attachment header field name at a time!");
if (!(attach = *argp++) || *attach == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
}
}
drft = cp;
}
- if ((drft == NULL && (drft = getenv ("mhdraft")) == NULL) || *drft == 0)
+ if ((drft == NULL && (drft = getenv("mhdraft")) == NULL) || *drft == 0)
drft = getcpy (m_draft("cur"));
msgnam = (cp = getenv ("mhaltmsg")) && *cp ? getcpy (cp) : NULL;
}
/* start editing the draft, unless -noedit was given */
- if (!nedit && editfile (&ed, NULL, drft, use, NULL, msgnam, NULL, 1) < 0)
+ if (!nedit && editfile(&ed, NULL, drft, use, NULL, msgnam, NULL, 1)
+ < 0)
done (1);
snprintf (prompt, sizeof(prompt), myprompt, invo_name);
}
switch (smatch (*argp, aleqs)) {
case DISPSW:
- /* display the message being replied to, or distributed */
+ /*
+ ** display the message being replied to,
+ ** or distributed
+ */
if (msgnam)
showfile (++argp, msgnam);
else
/* Call an editor on the draft file */
if (*++argp)
ed = *argp++;
- if (editfile (&ed, argp, drft, NOUSE, NULL, msgnam, NULL, 1) == NOTOK)
+ if (editfile (&ed, argp, drft, NOUSE, NULL,
+ msgnam, NULL, 1) == NOTOK)
done (1);
break;
removefile (drft);
} else {
if (stat (drft, &st) != NOTOK)
- advise (NULL, "draft left on %s", drft);
+ advise(NULL, "draft left on %s", drft);
}
done (1);
case CDCMDSW:
/*
- * Change the working directory for attachments
- *
- * Run the directory through the user's shell
- * so that we can take advantage of any syntax
- * that the user is accustomed to. Read back
- * the absolute path.
- */
+ ** Change the working directory for attachments
+ **
+ ** Run the directory through the user's shell
+ ** so that we can take advantage of any syntax
+ ** that the user is accustomed to. Read back
+ ** the absolute path.
+ */
if (*(argp+1) == (char *)0) {
(void)sprintf(buf, "$SHELL -c \"cd;pwd\"");
case LSCMDSW:
/*
- * List files in the current attachment working
- * directory
- *
- * Use the user's shell so that we can take
- * advantage of any syntax that the user is
- * accustomed to.
- */
+ ** List files in the current attachment working
+ ** directory
+ **
+ ** Use the user's shell so that we can take
+ ** advantage of any syntax that the user is
+ ** accustomed to.
+ */
writelscmd(buf, sizeof(buf), argp);
(void)system_in_dir(cwd, buf);
break;
case ALISTCMDSW:
/*
- * List attachments on current draft. Options are:
- *
- * -l long listing (full path names)
- * -n numbers listing
- */
+ ** List attachments on current draft. Options are:
+ **
+ ** -l long listing (full path names)
+ ** -n numbers listing
+ */
if (attach == (char *)0) {
advise((char *)0, "can't list because no header field name was given.");
else if (strcmp(*argp, "-n") == 0)
n = 1;
- else if (strcmp(*argp, "-ln") == 0 || strcmp(*argp, "-nl") == 0) {
+ else if (strcmp(*argp, "-ln") == 0 ||
+ strcmp(*argp, "-nl") == 0) {
l = "/";
n = 1;
} else {
case ATTACHCMDSW:
/*
- * Attach files to current draft.
- */
+ ** Attach files to current draft.
+ */
if (attach == (char *)0) {
advise((char *)0, "can't attach because no header field name was given.");
}
/*
- * Build a command line that causes the user's
- * shell to list the file name arguments.
- * This handles and wildcard expansion, tilde
- * expansion, etc.
- */
+ ** Build a command line that causes the user's
+ ** shell to list the file name arguments.
+ ** This handles and wildcard expansion, tilde
+ ** expansion, etc.
+ */
writelscmd(buf, sizeof(buf), argp);
/*
- * Read back the response from the shell,
- * which contains a number of lines with one
- * file name per line. Remove off the newline.
- * Determine whether we have an absolute or
- * relative path name. Prepend the current
- * working directory to relative path names.
- * Add the attachment annotation to the draft.
- */
+ ** Read back the response from the shell,
+ ** which contains a number of lines with one
+ ** file name per line. Remove off the newline.
+ ** Determine whether we have an absolute or
+ ** relative path name. Prepend the current
+ ** working directory to relative path names.
+ ** Add the attachment annotation to the draft.
+ */
if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
- while (fgets(shell, sizeof (shell), f) != (char *)0) {
+ while (fgets(shell, sizeof (shell), f)
+ != (char *)0) {
*(strchr(shell, '\n')) = '\0';
if (*shell == '/')
- (void)annotate(drft, attach, shell, 1, 0, -2, 1);
+ annotate(drft, attach, shell,
+ 1, 0, -2, 1);
else {
- (void)sprintf(file, "%s/%s", cwd, shell);
- (void)annotate(drft, attach, file, 1, 0, -2, 1);
+ sprintf(file, "%s/%s", cwd,
+ shell);
+ annotate(drft, attach, file,
+ 1, 0, -2, 1);
}
}
case DETACHCMDSW:
/*
- * Detach files from current draft.
- */
+ ** Detach files from current draft.
+ */
if (attach == (char *)0) {
advise((char *)0, "can't detach because no header field name was given.");
}
/*
- * Scan the arguments for a -n. Mixed file
- * names and numbers aren't allowed, so this
- * catches a -n anywhere in the argument list.
- */
-
- for (n = 0, arguments = argp + 1; *arguments != (char *)0; arguments++) {
+ ** Scan the arguments for a -n. Mixed file
+ ** names and numbers aren't allowed, so this
+ ** catches a -n anywhere in the argument list.
+ */
+
+ for (n = 0, arguments = argp + 1;
+ *arguments != (char *)0;
+ arguments++) {
if (strcmp(*arguments, "-n") == 0) {
n = 1;
break;
}
/*
- * A -n was found so interpret the arguments as
- * attachment numbers. Decrement any remaining
- * argument number that is greater than the one
- * just processed after processing each one so
- * that the numbering stays correct.
- */
+ ** A -n was found so interpret the arguments as
+ ** attachment numbers. Decrement any remaining
+ ** argument number that is greater than the one
+ ** just processed after processing each one so
+ ** that the numbering stays correct.
+ */
if (n == 1) {
- for (arguments = argp + 1; *arguments != (char *)0; arguments++) {
+ for (arguments = argp + 1;
+ *arguments != (char *)0;
+ arguments++) {
if (strcmp(*arguments, "-n") == 0)
continue;
if (**arguments != '\0') {
n = atoi(*arguments);
- (void)annotate(drft, attach, (char *)0, 1, 0, n, 1);
+ annotate(drft, attach, NULL,
+ 1, 0, n, 1);
for (argp = arguments + 1; *argp != (char *)0; argp++) {
if (atoi(*argp) > n) {
}
/*
- * The arguments are interpreted as file names.
- * Run them through the user's shell for wildcard
- * expansion and other goodies. Do this from
- * the current working directory if the argument
- * is not an absolute path name (does not begin
- * with a /).
- *
- * We feed all the file names to the shell at
- * once, otherwise you can't provide a file name
- * with a space in it.
- */
+ ** The arguments are interpreted as file names.
+ ** Run them through the user's shell for wildcard
+ ** expansion and other goodies. Do this from
+ ** the current working directory if the argument
+ ** is not an absolute path name (does not begin
+ ** with a /).
+ **
+ ** We feed all the file names to the shell at
+ ** once, otherwise you can't provide a file name
+ ** with a space in it.
+ */
writelscmd(buf, sizeof(buf), argp);
if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
- while (fgets(shell, sizeof (shell), f) != (char *)0) {
+ while (fgets(shell, sizeof (shell), f)
+ != NULL) {
*(strchr(shell, '\n')) = '\0';
- (void)annotate(drft, attach, shell, 1, 0, 0, 1);
+ annotate(drft, attach, shell,
+ 1, 0, 0, 1);
}
pclose(f);
} else {
/*
- * Build a command line of the form $SHELL -c "cd 'cwd'; cmd argp ... ;
- * trailcmd".
- */
+** Build a command line of the form $SHELL -c "cd 'cwd'; cmd argp ... ;
+** trailcmd".
+*/
static void
writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp)
{
char *cp;
- /* Note that we do not quote -- the argp from the user
- * is assumed to be quoted as they desire. (We can't treat
- * it as pure literal as that would prevent them using ~,
- * wildcards, etc.) The buffer produced by this function
- * should be given to popen_in_dir() or system_in_dir() so
- * that the current working directory is set correctly.
- */
+ /*
+ ** Note that we do not quote -- the argp from the user
+ ** is assumed to be quoted as they desire. (We can't treat
+ ** it as pure literal as that would prevent them using ~,
+ ** wildcards, etc.) The buffer produced by this function
+ ** should be given to popen_in_dir() or system_in_dir() so
+ ** that the current working directory is set correctly.
+ */
int ln = snprintf(buf, bufsz, "$SHELL -c \"%s", cmd);
- /* NB that some snprintf() return -1 on overflow rather than the
- * new C99 mandated 'number of chars that would have been written'
- */
- /* length checks here and inside the loop allow for the
- * trailing ';', trailcmd, '"' and NUL
- */
+ /*
+ ** NB that some snprintf() return -1 on overflow rather than the
+ ** new C99 mandated 'number of chars that would have been written'
+ */
+ /*
+ ** length checks here and inside the loop allow for the
+ ** trailing ';', trailcmd, '"' and NUL
+ */
int trailln = strlen(trailcmd) + 3;
if (ln < 0 || ln + trailln > bufsz)
adios((char *)0, "arguments too long");
}
/*
- * Build a command line that causes the user's shell to list the file name
- * arguments. This handles and wildcard expansion, tilde expansion, etc.
- */
+** Build a command line that causes the user's shell to list the file name
+** arguments. This handles and wildcard expansion, tilde expansion, etc.
+*/
static void
writelscmd(char *buf, int bufsz, char **argp)
{
writesomecmd(buf, bufsz, "ls", "", argp);
}
-/* Like system(), but run the command in directory dir.
- * This assumes the program is single-threaded!
- */
+/*
+** Like system(), but run the command in directory dir.
+** This assumes the program is single-threaded!
+*/
static int
system_in_dir(const char *dir, const char *cmd)
{
/*
- * EDIT
- */
+** EDIT
+*/
static int reedit = 0; /* have we been here before? */
static char *edsave = NULL; /* the editor we used previously */
if (mp == NULL || *altmsg == '/' || cwd == NULL)
strncpy (altpath, altmsg, sizeof(altpath));
else
- snprintf (altpath, sizeof(altpath), "%s/%s", mp->foldpath, altmsg);
+ snprintf (altpath, sizeof(altpath), "%s/%s",
+ mp->foldpath, altmsg);
if (cwd == NULL)
strncpy (linkpath, altmsglink, sizeof(linkpath));
else
- snprintf (linkpath, sizeof(linkpath), "%s/%s", cwd, altmsglink);
+ snprintf (linkpath, sizeof(linkpath), "%s/%s",
+ cwd, altmsglink);
}
if (altmsg) {
if (link (altpath, linkpath) == NOTOK) {
#if 0
/* I don't think permission on symlinks matters /JLR */
- oumask = umask(0044); /* PJS: else symlinks are world 'r' */
+ /* PJS: else symlinks are world 'r' */
+ oumask = umask(0044);
#endif
symlink (altpath, linkpath);
#if 0
|| link (linkpath, altpath) == NOTOK)))
advise (linkpath, "unable to update %s from", altmsg);
#else /* HAVE_LSTAT */
- if (altmsg
- && mp
- && !is_readonly(mp)
+ if (altmsg && mp && !is_readonly(mp)
&& stat (linkpath, &st) != NOTOK
&& st.st_nlink == 1
&& (unlink (altpath) == NOTOK
- || link (linkpath, altpath) == NOTOK))
- advise (linkpath, "unable to update %s from", altmsg);
+ || link (linkpath, altpath) == NOTOK))
+ advise (linkpath, "unable to update %s from",
+ altmsg);
#endif /* HAVE_LSTAT */
}
/*
- * SEND
- */
+** SEND
+*/
static int
sendfile (char **arg, char *file, int pushsw)
char *cp, *sp, *vec[MAXARGS];
/* Translate MIME composition file, if necessary */
- if ((cp = context_find ("automimeproc"))
- && (!strcmp (cp, "1"))
- && !getenv ("NOMHNPROC")
- && check_draft (file)
+ if ((cp = context_find ("automimeproc")) && (!strcmp (cp, "1"))
+ && !getenv ("NOMHNPROC") && check_draft (file)
&& (buildfile (NULL, file) == NOTOK))
return 0;
/* For backwards compatibility */
- if ((cp = context_find ("automhnproc"))
- && !getenv ("NOMHNPROC")
- && check_draft (file)
- && (i = editfile (&cp, NULL, file, NOUSE, NULL, NULL, NULL, 0)))
+ if ((cp = context_find ("automhnproc")) && !getenv ("NOMHNPROC")
+ && check_draft (file) && (i = editfile (&cp, NULL,
+ file, NOUSE, NULL, NULL, NULL, 0)))
return 0;
/*
- * If the sendproc is the nmh command `send', then we call
- * those routines directly rather than exec'ing the command.
- */
+ ** If the sendproc is the nmh command `send', then we call
+ ** those routines directly rather than exec'ing the command.
+ */
if (strcmp (sp = r1bindex (sendproc, '/'), "send") == 0) {
cp = invo_name;
sendit (invo_name = sp, arg, file, pushsw);
/*
- * Translate MIME composition file (call buildmimeproc)
- */
+** Translate MIME composition file (call buildmimeproc)
+*/
static int
buildfile (char **argp, char *file)
args = (char **) mh_xmalloc((i + 2) * sizeof(char *));
/*
- * For backward compatibility, we need to add -build
- * if we are using mhn as buildmimeproc
- */
+ ** For backward compatibility, we need to add -build
+ ** if we are using mhn as buildmimeproc
+ */
i = 0;
if (strcmp (r1bindex (ed, '/'), "mhn") == 0)
args[i++] = "-build";
/*
- * Check if draft is a mhbuild composition file
- */
+** Check if draft is a mhbuild composition file
+*/
static int
check_draft (char *msgnam)
case FLDPLUS:
case FLDEOF:
/*
- * If draft already contains any of the
- * Content-XXX fields, then assume it already
- * been converted.
- */
+ ** If draft already contains any of the
+ ** Content-XXX fields, then assume it already
+ ** been converted.
+ */
if (uprf (name, XXX_FIELD_PRF)) {
fclose (fp);
return 0;
}
while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ state = m_getfld (state, name, buf,
+ sizeof(buf), fp);
break;
case BODY:
return 1;
}
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ state = m_getfld (state, name, buf,
+ sizeof(buf), fp);
} while (state == BODY);
/* and fall... */
char **arguments, *vec[MAXARGS];
struct stat st;
char *attach = (char *)0; /* attachment header field name */
- int attachformat = 0; /* mhbuild format specifier for
- attachments */
+ int attachformat = 0; /* mhbuild format specifier for attachments */
#ifndef lint
int distsw = 0;
#endif
/*
- * Make sure these are defined. In particular, we need
- * vec[1] to be NULL, in case "arg" is NULL below. It
- * doesn't matter what is the value of vec[0], but we
- * set it to NULL, to help catch "off-by-one" errors.
- */
+ ** Make sure these are defined. In particular, we need
+ ** vec[1] to be NULL, in case "arg" is NULL below. It
+ ** doesn't matter what is the value of vec[0], but we
+ ** set it to NULL, to help catch "off-by-one" errors.
+ */
vec[0] = NULL;
vec[1] = NULL;
/*
- * Temporarily copy arg to vec, since the brkstring() call in
- * getarguments() will wipe it out before it is merged in.
- * Also, we skip the first element of vec, since getarguments()
- * skips it. Then we count the number of arguments
- * copied. The value of "n" will be one greater than
- * this in order to simulate the standard argc/argv.
- */
+ ** Temporarily copy arg to vec, since the brkstring() call in
+ ** getarguments() will wipe it out before it is merged in.
+ ** Also, we skip the first element of vec, since getarguments()
+ ** skips it. Then we count the number of arguments
+ ** copied. The value of "n" will be one greater than
+ ** this in order to simulate the standard argc/argv.
+ */
if (arg) {
char **bp;
}
/*
- * Merge any arguments from command line (now in vec)
- * and arguments from profile.
- */
+ ** Merge any arguments from command line (now in vec)
+ ** and arguments from profile.
+ */
arguments = getarguments (sp, n, vec, 1);
argp = arguments;
return;
case SHELPSW:
- snprintf (buf, sizeof(buf), "%s [switches]", sp);
+ snprintf (buf, sizeof(buf),
+ "%s [switches]", sp);
print_help (buf, sendswitches, 1);
return;
case SVERSIONSW:
continue;
case SNDATTACHSW:
- if (!(attach = *argp++) || *attach == '-') {
+ if (!(attach = *argp++) ||
+ *attach == '-') {
advise (NULL, "missing argument to %s", argp[-2]);
return;
}
adios (NULL, "missing argument to %s", argp[-1]);
else {
attachformat = atoi (*argp);
- if (attachformat < 0 ||
- attachformat > ATTACHFORMATS - 1) {
- advise (NULL, "unsupported attachformat %d",
- attachformat);
+ if (attachformat < 0 || attachformat > ATTACHFORMATS - 1) {
+ advise (NULL, "unsupported attachformat %d", attachformat);
continue;
}
}
/*
- * Remove the draft file
- */
+** Remove the draft file
+*/
static int
removefile (char *drft)