/*
- * 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;
}