From: markus schnalke Date: Mon, 31 Oct 2011 14:06:33 +0000 (+0100) Subject: Reformated comments and long lines X-Git-Tag: mmh-thesis-end~488 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=ced6090a330d3d83d0bce709f756aa3d7d65fea4 Reformated comments and long lines --- diff --git a/config/config.c b/config/config.c index 5d11ef3..d72cd91 100644 --- a/config/config.c +++ b/config/config.c @@ -1,10 +1,10 @@ /* - * 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 @@ -18,14 +18,14 @@ /* - * 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) @@ -85,8 +85,8 @@ try_it: /* - * Standard yes/no switches structure - */ +** Standard yes/no switches structure +*/ struct swit anoyes[] = { { "no", 0 }, @@ -95,8 +95,8 @@ struct swit anoyes[] = { }; /* - * nmh constants - */ +** nmh constants +*/ /* initial profile for new users */ char *mh_defaults = nmhetcdir (/mh.profile); @@ -143,19 +143,19 @@ char *mhlibdir = NMHLIBDIR; 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 @@ -163,8 +163,8 @@ char *mh_seq = ".mh_sequences"; #endif /* - * nmh globals - */ +** nmh globals +*/ char ctxflags; /* status of user's context */ char *invo_name; /* command invocation name */ @@ -174,166 +174,166 @@ char *ctxpath; /* pathname of user's context */ 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"; diff --git a/h/addrsbr.h b/h/addrsbr.h index 7c997f6..5e19b78 100644 --- a/h/addrsbr.h +++ b/h/addrsbr.h @@ -1,6 +1,6 @@ /* - * 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 */ @@ -28,8 +28,8 @@ struct mailname { /* - * prototypes - */ +** prototypes +*/ void mnfree(struct mailname *); int ismymbox(struct mailname *); char *getname(char *); diff --git a/h/aliasbr.h b/h/aliasbr.h index aa38c42..5405531 100644 --- a/h/aliasbr.h +++ b/h/aliasbr.h @@ -1,6 +1,6 @@ /* - * 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) */ @@ -21,8 +21,8 @@ struct adr { }; /* - * incore version of /etc/passwd - */ +** incore version of /etc/passwd +*/ struct home { char *h_name; /* user name */ uid_t h_uid; /* user id */ @@ -36,8 +36,8 @@ struct home { struct home *seek_home (char *); /* - * prototypes - */ +** prototypes +*/ int alias (char *); int akvisible (void); void init_pw (void); diff --git a/h/crawl_folders.h b/h/crawl_folders.h index a5ac7b4..e81acb1 100644 --- a/h/crawl_folders.h +++ b/h/crawl_folders.h @@ -1,15 +1,19 @@ /* - * 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); diff --git a/h/dropsbr.h b/h/dropsbr.h index c261541..2742ae6 100644 --- a/h/dropsbr.h +++ b/h/dropsbr.h @@ -1,32 +1,32 @@ /* - * 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 @@ -41,8 +41,8 @@ struct drop { }; /* - * 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); diff --git a/h/fmt_compile.h b/h/fmt_compile.h index f3b2b9b..d60ac4a 100644 --- a/h/fmt_compile.h +++ b/h/fmt_compile.h @@ -1,6 +1,6 @@ /* - * fmt_compile.h -- format types - */ +** fmt_compile.h -- format types +*/ /* types that output text */ #define FT_COMP 1 /* the text of a component */ diff --git a/h/fmt_scan.h b/h/fmt_scan.h index ea34898..f65dab1 100644 --- a/h/fmt_scan.h +++ b/h/fmt_scan.h @@ -1,16 +1,16 @@ /* - * 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) */ @@ -27,14 +27,14 @@ struct comp { #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 */ @@ -42,29 +42,29 @@ struct comp { 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; @@ -85,8 +85,8 @@ struct format { #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 **); diff --git a/h/md5.h b/h/md5.h index 0a750be..8a1104a 100644 --- a/h/md5.h +++ b/h/md5.h @@ -1,29 +1,29 @@ /* - * 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 /* - * 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 @@ -37,40 +37,41 @@ typedef unsigned short int UINT2; /* 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 { diff --git a/h/mf.h b/h/mf.h index 7fd5ef5..b5a7892 100644 --- a/h/mf.h +++ b/h/mf.h @@ -1,6 +1,6 @@ /* - * mf.h -- include file for mailbox filters - */ +** mf.h -- include file for mailbox filters +*/ #include @@ -52,8 +52,8 @@ struct adrx { /* - * 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 */ @@ -66,7 +66,7 @@ struct adrx { /* - * prototypes - */ +** prototypes +*/ char *legal_person (char *); struct adrx *getadrx (char *); diff --git a/h/mh.h b/h/mh.h index 35c8b41..70bfee7 100644 --- a/h/mh.h +++ b/h/mh.h @@ -1,12 +1,12 @@ /* - * mh.h -- main header file for all of nmh - */ +** mh.h -- main header file for all of nmh +*/ #include /* - * 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 */ @@ -27,8 +27,8 @@ 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 @@ -36,8 +36,8 @@ typedef unsigned char boolean; /* not int so we can pack in a structure */ #endif /* - * user context/profile structure - */ +** user context/profile structure +*/ struct node { char *n_name; /* key */ char *n_field; /* value */ @@ -46,20 +46,20 @@ struct node { }; /* - * 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; }; @@ -68,8 +68,8 @@ extern struct swit anoyes[]; /* standard yes/no switches */ #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 */ @@ -78,26 +78,26 @@ extern struct swit anoyes[]; /* standard yes/no switches */ #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 */ @@ -107,8 +107,8 @@ typedef unsigned int seqset_t; #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 */ @@ -124,44 +124,44 @@ struct msgs { 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]) @@ -202,8 +202,8 @@ struct msgs { ((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) @@ -215,19 +215,20 @@ struct msgs { #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 */ @@ -239,8 +240,8 @@ struct msgs { #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 */ @@ -259,8 +260,8 @@ extern char *msg_delim; /* .. */ #define OUTPUTLINELEN 72 /* default line length for headers */ /* - * miscellaneous macros - */ +** miscellaneous macros +*/ #define pidXwait(pid,cp) pidstatus (pidwait (pid, NOTOK), stdout, cp) @@ -277,8 +278,8 @@ extern char *msg_delim; /* .. */ #endif /* - * GLOBAL VARIABLES - */ +** GLOBAL VARIABLES +*/ #define CTXMOD 0x01 /* context information modified */ #define DBITS "\020\01CTXMOD" extern char ctxflags; @@ -290,11 +291,11 @@ extern char *ctxpath; /* pathname of user's context */ 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; diff --git a/h/mhcachesbr.h b/h/mhcachesbr.h index 68bd2be..77caabf 100644 --- a/h/mhcachesbr.h +++ b/h/mhcachesbr.h @@ -1,10 +1,10 @@ /* - * 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 }, diff --git a/h/mhparse.h b/h/mhparse.h index e3abf31..bef3f4f 100644 --- a/h/mhparse.h +++ b/h/mhparse.h @@ -1,40 +1,40 @@ /* - * 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 */ @@ -43,9 +43,9 @@ struct hfield { }; /* - * 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 */ @@ -56,9 +56,9 @@ struct CTinfo { }; /* - * 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) */ @@ -66,8 +66,8 @@ struct cefile { }; /* - * Primary structure for handling Content (Entity) - */ +** Primary structure for handling Content (Entity) +*/ struct Content { /* source (read) file */ char *c_file; /* read contents (file) */ @@ -126,8 +126,8 @@ struct Content { }; /* - * 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 @@ -139,8 +139,8 @@ struct Content { #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 @@ -151,8 +151,8 @@ struct Content { #define CE_EXTERNAL 0x07 /* for external-body */ /* - * TEXT content - */ +** TEXT content +*/ /* Flags for subtypes of TEXT */ #define TEXT_UNKNOWN 0x00 @@ -172,8 +172,8 @@ struct text { }; /* - * MULTIPART content - */ +** MULTIPART content +*/ /* Flags for subtypes of MULTIPART */ #define MULTI_UNKNOWN 0x00 @@ -196,8 +196,8 @@ struct multipart { }; /* - * MESSAGE content - */ +** MESSAGE content +*/ /* Flags for subtypes of MESSAGE */ #define MESSAGE_UNKNOWN 0x00 @@ -233,8 +233,8 @@ struct exbody { }; /* - * APPLICATION content - */ +** APPLICATION content +*/ /* Flags for subtype of APPLICATION */ #define APPLICATION_UNKNOWN 0x00 @@ -243,8 +243,8 @@ struct exbody { /* - * Structures for mapping types to their internal flags - */ +** Structures for mapping types to their internal flags +*/ struct k2v { char *kv_key; int kv_value; @@ -256,9 +256,9 @@ extern struct k2v SubMessage[]; 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; @@ -269,8 +269,8 @@ extern struct str2init str2ces[]; extern struct str2init str2methods[]; /* - * prototypes - */ +** prototypes +*/ int pidcheck (int); CT parse_mime (char *); int add_header (CT, char *, char *); diff --git a/h/mime.h b/h/mime.h index 9773293..dc37db2 100644 --- a/h/mime.h +++ b/h/mime.h @@ -1,6 +1,6 @@ /* - * mime.h -- definitions for MIME - */ +** mime.h -- definitions for MIME +*/ #define VRSN_FIELD "MIME-Version" #define VRSN_VALUE "1.0" @@ -19,9 +19,9 @@ && (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) != ';' \ diff --git a/h/mts.h b/h/mts.h index 20b42a0..df1d9b5 100644 --- a/h/mts.h +++ b/h/mts.h @@ -1,16 +1,16 @@ /* - * 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; @@ -25,8 +25,8 @@ char *getusername(void); char *getfullname(void); /* - * Separators - */ +** Separators +*/ extern char *mmdlm1; extern char *mmdlm2; @@ -34,17 +34,17 @@ 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; diff --git a/h/nmh.h b/h/nmh.h index f10ec1e..4ae127d 100644 --- a/h/nmh.h +++ b/h/nmh.h @@ -1,6 +1,6 @@ /* - * nmh.h -- system configuration header file - */ +** nmh.h -- system configuration header file +*/ #include @@ -60,8 +60,8 @@ #endif /* - * symbolic constants for lseek and fseek - */ +** symbolic constants for lseek and fseek +*/ #ifndef SEEK_SET # define SEEK_SET 0 #endif @@ -73,8 +73,8 @@ #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 @@ -85,8 +85,8 @@ #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 @@ -96,8 +96,8 @@ #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 @@ -121,9 +121,9 @@ #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 diff --git a/h/picksbr.h b/h/picksbr.h index 9c4b475..d69825a 100644 --- a/h/picksbr.h +++ b/h/picksbr.h @@ -1,9 +1,9 @@ /* - * picksbr.h -- definitions for picksbr.c - */ +** picksbr.h -- definitions for picksbr.c +*/ /* - * prototypes - */ +** prototypes +*/ int pcompile (char **, char *); int pmatches (FILE *, int, long, long); diff --git a/h/prototypes.h b/h/prototypes.h index c54172b..baf40d9 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -1,10 +1,10 @@ /* - * 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); @@ -15,13 +15,13 @@ extern int tputs (char *cp, int affcnt, int (*outc) (int)); #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); @@ -126,8 +126,8 @@ int get_returnpath (char *, int, char *, int); #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); @@ -138,22 +138,22 @@ int strncasecmp (const char *s1, const char *s2, size_t n); /* - * 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 *); diff --git a/h/rcvmail.h b/h/rcvmail.h index 98a7f18..6a62284 100644 --- a/h/rcvmail.h +++ b/h/rcvmail.h @@ -1,6 +1,6 @@ /* - * rcvmail.h -- rcvmail hook definitions - */ +** rcvmail.h -- rcvmail hook definitions +*/ # include # include diff --git a/h/scansbr.h b/h/scansbr.h index d3b1c9f..bba2b44 100644 --- a/h/scansbr.h +++ b/h/scansbr.h @@ -1,6 +1,6 @@ /* - * scansbr.h -- definitions for scan() - */ +** scansbr.h -- definitions for scan() +*/ extern char *scanl; @@ -12,8 +12,8 @@ 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%| %>\ @@ -33,6 +33,6 @@ extern char *scanl; #define WIDTH 78 /* - * prototypes - */ +** prototypes +*/ int scan (FILE *, int, int, char *, int, int, int, char *, long, int); diff --git a/h/signals.h b/h/signals.h index d65da58..645c340 100644 --- a/h/signals.h +++ b/h/signals.h @@ -1,20 +1,20 @@ /* - * signals.h -- header file for nmh signal interface - */ +** signals.h -- header file for nmh signal interface +*/ #include /* - * 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) @@ -24,8 +24,8 @@ typedef RETSIGTYPE (*SIGNAL_HANDLER)(int); #endif /* - * prototypes - */ +** prototypes +*/ int SIGPROCMASK (int, const sigset_t *, sigset_t *); SIGNAL_HANDLER SIGNAL (int, SIGNAL_HANDLER); SIGNAL_HANDLER SIGNAL2 (int, SIGNAL_HANDLER); diff --git a/h/tws.h b/h/tws.h index 1db78c7..77ccaa6 100644 --- a/h/tws.h +++ b/h/tws.h @@ -1,15 +1,15 @@ /* - * 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 { @@ -51,8 +51,8 @@ extern char *tw_ldotw[]; extern char *tw_moty[]; /* - * prototypes - */ +** prototypes +*/ char *dtime (time_t *, int); char *dtimenow (int); char *dctime (struct tws *); diff --git a/h/utils.h b/h/utils.h index bc5c2ec..18d778e 100644 --- a/h/utils.h +++ b/h/utils.h @@ -1,6 +1,6 @@ /* - * utils.h -- utility prototypes - */ +** utils.h -- utility prototypes +*/ void *mh_xmalloc(size_t); void *mh_xrealloc(void *, size_t); diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c index d8f6a12..c8eb0c8 100644 --- a/sbr/addrsbr.c +++ b/sbr/addrsbr.c @@ -1,65 +1,65 @@ /* - * 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 #include #include /* - * 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%@ -> string - * - * 2. for non-MMDF systems: - * - * string@host. -> host!string - * - * 3. for any system, an address interpreted relative to the local host: - * - * string@ -> 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%@ -> string +** +** 2. for non-MMDF systems: +** +** string@host. -> host!string +** +** 3. for any system, an address interpreted relative to the local host: +** +** string@ -> 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; @@ -77,8 +77,8 @@ extern boolean username_extension_masquerading; /* defined in mts.c */ /* - * external prototypes - */ +** external prototypes +*/ char *getusername (void); @@ -309,8 +309,8 @@ adrformat (struct mailname *mp) #define WBITS "\020\01MBEG\02MEND\03HBEG\04HEND" /* - * Check if this is my address - */ +** Check if this is my address +*/ int ismymbox (struct mailname *np) @@ -325,9 +325,9 @@ 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 (); @@ -397,9 +397,9 @@ local_test: ; } /* - * 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) @@ -459,15 +459,15 @@ local_test: ; /* - * 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 #include diff --git a/sbr/ambigsw.c b/sbr/ambigsw.c index cd84ad6..6105a50 100644 --- a/sbr/ambigsw.c +++ b/sbr/ambigsw.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/atooi.c b/sbr/atooi.c index a0e4f74..cb557b7 100644 --- a/sbr/atooi.c +++ b/sbr/atooi.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/brkstring.c b/sbr/brkstring.c index 1e78b17..4496ae6 100644 --- a/sbr/brkstring.c +++ b/sbr/brkstring.c @@ -1,11 +1,11 @@ /* - * 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 #include @@ -17,8 +17,8 @@ static char **broken = NULL; /* array of substring start addresses */ static int len = 0; /* current size of "broken" */ /* - * static prototypes - */ +** static prototypes +*/ static int brkany (char, char *); @@ -35,9 +35,9 @@ brkstring (char *str, char *brksep, char *brkterm) } /* - * 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++) { @@ -52,9 +52,9 @@ brkstring (char *str, char *brksep, char *brkterm) *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; @@ -73,9 +73,9 @@ brkstring (char *str, char *brksep, char *brkterm) /* - * 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) diff --git a/sbr/check_charset.c b/sbr/check_charset.c index e6debc2..cba270d 100644 --- a/sbr/check_charset.c +++ b/sbr/check_charset.c @@ -1,10 +1,10 @@ /* - * 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 #ifdef HAVE_LANGINFO_H @@ -13,8 +13,8 @@ /* - * Get the current character set - */ +** Get the current character set +*/ char * get_charset () { @@ -28,11 +28,11 @@ 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) @@ -67,18 +67,18 @@ 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"; diff --git a/sbr/closefds.c b/sbr/closefds.c index 99543f5..0f87bde 100644 --- a/sbr/closefds.c +++ b/sbr/closefds.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/concat.c b/sbr/concat.c index 2d0bc60..65ded77 100644 --- a/sbr/concat.c +++ b/sbr/concat.c @@ -1,11 +1,11 @@ /* - * 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 #include diff --git a/sbr/context_del.c b/sbr/context_del.c index f2ff0a4..1341424 100644 --- a/sbr/context_del.c +++ b/sbr/context_del.c @@ -1,17 +1,17 @@ /* - * 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 /* - * 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) diff --git a/sbr/context_find.c b/sbr/context_find.c index da1ee10..e5ba5ff 100644 --- a/sbr/context_find.c +++ b/sbr/context_find.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/context_foil.c b/sbr/context_foil.c index 94f687a..93b198d 100644 --- a/sbr/context_foil.c +++ b/sbr/context_foil.c @@ -1,18 +1,18 @@ /* - * 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 #include /* - * 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) @@ -20,28 +20,28 @@ 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)); diff --git a/sbr/context_read.c b/sbr/context_read.c index 24e6350..1e1a84e 100644 --- a/sbr/context_read.c +++ b/sbr/context_read.c @@ -1,26 +1,26 @@ /* - * 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 /* mh internals */ #include /* system call errors */ @@ -37,29 +37,30 @@ context_read (void) 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); @@ -82,9 +83,10 @@ context_read (void) 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); @@ -110,17 +112,20 @@ context_read (void) 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; diff --git a/sbr/context_replace.c b/sbr/context_replace.c index dbe1014..bb49a90 100644 --- a/sbr/context_replace.c +++ b/sbr/context_replace.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -16,8 +16,8 @@ context_replace (char *key, char *value) 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)); @@ -31,9 +31,9 @@ context_replace (char *key, char *value) } /* - * 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)) { @@ -51,8 +51,8 @@ context_replace (char *key, char *value) } /* - * 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; diff --git a/sbr/context_save.c b/sbr/context_save.c index d4a56ed..7d99cc3 100644 --- a/sbr/context_save.c +++ b/sbr/context_save.c @@ -1,17 +1,17 @@ /* - * 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 #include /* - * static prototypes - */ +** static prototypes +*/ static int m_chkids(void); @@ -56,14 +56,14 @@ context_save (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) diff --git a/sbr/copy.c b/sbr/copy.c index 4a0ef51..0e013ab 100644 --- a/sbr/copy.c +++ b/sbr/copy.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/copyip.c b/sbr/copyip.c index 5ae52bd..e4253da 100644 --- a/sbr/copyip.c +++ b/sbr/copyip.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/cpydata.c b/sbr/cpydata.c index c74b2ae..207bc03 100644 --- a/sbr/cpydata.c +++ b/sbr/cpydata.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/cpydgst.c b/sbr/cpydgst.c index 7195cd1..04ca76e 100644 --- a/sbr/cpydgst.c +++ b/sbr/cpydgst.c @@ -1,25 +1,25 @@ /* - * 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 /* - * 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 diff --git a/sbr/crawl_folders.c b/sbr/crawl_folders.c index 28116b7..2691a78 100644 --- a/sbr/crawl_folders.c +++ b/sbr/crawl_folders.c @@ -1,18 +1,20 @@ /* - * 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 #include #include 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; @@ -20,9 +22,9 @@ struct crawl_context { }; /* - * 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) @@ -70,8 +72,10 @@ add_children (char *name, 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) { @@ -84,8 +88,10 @@ add_children (char *name, struct crawl_context *crawl) 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)); } @@ -140,8 +146,10 @@ crawl_folders (char *dir, crawl_callback_t *callback, void *baton) 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); } diff --git a/sbr/discard.c b/sbr/discard.c index 496bb7a..eb7e7c8 100644 --- a/sbr/discard.c +++ b/sbr/discard.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/done.c b/sbr/done.c index e4efff3..3545d10 100644 --- a/sbr/done.c +++ b/sbr/done.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/dtime.c b/sbr/dtime.c index 0c229ee..60ab9d7 100644 --- a/sbr/dtime.c +++ b/sbr/dtime.c @@ -1,10 +1,10 @@ /* - * 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 /* for snprintf() */ #include @@ -36,8 +36,8 @@ extern char *tzname[]; #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))) @@ -112,10 +112,10 @@ static int dmsize[] = { /* - * 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) @@ -128,10 +128,10 @@ 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) @@ -192,10 +192,10 @@ 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) @@ -240,11 +240,11 @@ 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) @@ -264,14 +264,14 @@ 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) @@ -284,15 +284,15 @@ 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) @@ -307,13 +307,13 @@ 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) @@ -348,8 +348,8 @@ dasctime (struct tws *tw, int flags) /* - * Get the timezone for given offset - */ +** Get the timezone for given offset +*/ char * dtimezone (int offset, int flags) @@ -388,11 +388,11 @@ 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) @@ -438,10 +438,10 @@ 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) @@ -471,8 +471,8 @@ set_dotw (struct tws *tw) /* - * Copy nmh time structure - */ +** Copy nmh time structure +*/ void twscopy (struct tws *tb, struct tws *tw) @@ -496,8 +496,8 @@ 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) diff --git a/sbr/error.c b/sbr/error.c index 1c15006..42511c9 100644 --- a/sbr/error.c +++ b/sbr/error.c @@ -1,10 +1,10 @@ /* - * 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 @@ -17,8 +17,8 @@ /* - * print out error message - */ +** print out error message +*/ void advise (char *what, char *fmt, ...) { @@ -31,8 +31,8 @@ advise (char *what, char *fmt, ...) /* - * print out error message and exit - */ +** print out error message and exit +*/ void adios (char *what, char *fmt, ...) { @@ -46,8 +46,8 @@ adios (char *what, char *fmt, ...) /* - * admonish the user - */ +** admonish the user +*/ void admonish (char *what, char *fmt, ...) { @@ -60,13 +60,13 @@ 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) { diff --git a/sbr/ext_hook.c b/sbr/ext_hook.c index 8986c03..db7bcec 100644 --- a/sbr/ext_hook.c +++ b/sbr/ext_hook.c @@ -1,11 +1,11 @@ /* - * 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 diff --git a/sbr/fdcompare.c b/sbr/fdcompare.c index 72dff99..769c525 100644 --- a/sbr/fdcompare.c +++ b/sbr/fdcompare.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/fmt_addr.c b/sbr/fmt_addr.c index bfb42d8..a2338e3 100644 --- a/sbr/fmt_addr.c +++ b/sbr/fmt_addr.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -33,19 +33,20 @@ static unsigned int bufsiz; /* current size of buf */ } -/* fmt_scan will call this routine if the user includes the function - * "(formataddr {component})" in a format string. "orig" is the - * original contents of the string register. "str" is the address - * string to be formatted and concatenated onto orig. This routine - * returns a pointer to the concatenated address string. - * - * We try to not do a lot of malloc/copy/free's (which is why we - * don't call "getcpy") but still place no upper limit on the - * length of the result string. - * - * 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) @@ -65,9 +66,9 @@ 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) { diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index 87e0769..9d8f41d 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -24,8 +24,8 @@ #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 */ @@ -50,9 +50,10 @@ extern struct mailname fmt_mnull; #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 */ @@ -191,13 +192,13 @@ static unsigned char *usr_fstring; /* for CERROR */ #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 *); @@ -250,10 +251,10 @@ compile_error(char *str, char *cp) } /* - * 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) @@ -272,12 +273,13 @@ 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++; @@ -609,10 +611,11 @@ do_if(char *sp) 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 { diff --git a/sbr/fmt_def.c b/sbr/fmt_def.c index d6e2e9f..65890e9 100644 --- a/sbr/fmt_def.c +++ b/sbr/fmt_def.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/fmt_new.c b/sbr/fmt_new.c index 4acabe7..7576ae4 100644 --- a/sbr/fmt_new.c +++ b/sbr/fmt_new.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -14,14 +14,14 @@ 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) @@ -58,8 +58,8 @@ new_fs (char *form, char *format, char *default_fs) /* - * Expand escapes in format strings - */ +** Expand escapes in format strings +*/ static void normalize (char *cp) diff --git a/sbr/fmt_rfc2047.c b/sbr/fmt_rfc2047.c index debc81e..5bc7850 100644 --- a/sbr/fmt_rfc2047.c +++ b/sbr/fmt_rfc2047.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -50,8 +50,8 @@ unqp (unsigned char byte1, unsigned char byte2) /* - * 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) @@ -78,9 +78,9 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) 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; @@ -94,9 +94,9 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) } #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; @@ -158,11 +158,11 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) 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)) { @@ -176,17 +176,18 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) 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; @@ -194,9 +195,9 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) #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); @@ -207,10 +208,11 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) 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) @@ -278,10 +280,11 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) #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; @@ -292,9 +295,13 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) (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; @@ -313,10 +320,13 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) } } 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; @@ -325,9 +335,9 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) #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 */ @@ -347,8 +357,10 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) 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; diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 14ec48b..8a8e4c1 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -39,17 +39,17 @@ extern int fmt_norm; /* defined in sbr/fmt_def.c = AD_NAME */ 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) @@ -87,8 +87,8 @@ 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; @@ -118,10 +118,10 @@ cpnumber(char **dest, int num, unsigned int wid, char fill, size_t n) { } /* - * 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 */ @@ -789,17 +789,21 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) 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; @@ -868,10 +872,10 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) 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); @@ -900,10 +904,12 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) 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 diff --git a/sbr/folder_addmsg.c b/sbr/folder_addmsg.c index e26e3bf..5d1690e 100644 --- a/sbr/folder_addmsg.c +++ b/sbr/folder_addmsg.c @@ -1,19 +1,19 @@ /* - * 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 #include #include /* - * 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, @@ -39,17 +39,17 @@ 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; @@ -67,9 +67,9 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, } /* - * 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; @@ -102,8 +102,8 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, } /* - * 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; @@ -121,12 +121,14 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, 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) { @@ -145,11 +147,12 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, #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) { @@ -160,11 +163,11 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, } /* - * 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); @@ -195,9 +198,9 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, } /* - * 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; } diff --git a/sbr/folder_delmsgs.c b/sbr/folder_delmsgs.c index 0636d11..5df5b5f 100644 --- a/sbr/folder_delmsgs.c +++ b/sbr/folder_delmsgs.c @@ -1,22 +1,22 @@ /* - * 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 /* - * 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) @@ -27,8 +27,8 @@ 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++) { @@ -73,8 +73,8 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) } /* - * 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 */ @@ -82,12 +82,14 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) 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); diff --git a/sbr/folder_free.c b/sbr/folder_free.c index 985c7a4..d88febe 100644 --- a/sbr/folder_free.c +++ b/sbr/folder_free.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/folder_pack.c b/sbr/folder_pack.c index 2e321b0..29ed687 100644 --- a/sbr/folder_pack.c +++ b/sbr/folder_pack.c @@ -1,18 +1,18 @@ /* - * 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 /* - * 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) @@ -24,15 +24,15 @@ 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; @@ -51,10 +51,11 @@ folder_pack (struct msgs **mpp, int verbose) 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); @@ -78,7 +79,10 @@ folder_pack (struct msgs **mpp, int verbose) 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++; diff --git a/sbr/folder_read.c b/sbr/folder_read.c index c77ea1e..5743166 100644 --- a/sbr/folder_read.c +++ b/sbr/folder_read.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -13,13 +13,13 @@ #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) @@ -59,18 +59,18 @@ 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))); @@ -81,7 +81,10 @@ folder_read (char *name) 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) @@ -89,9 +92,9 @@ folder_read (char *name) } /* - * 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 { @@ -104,7 +107,10 @@ folder_read (char *name) 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; @@ -112,7 +118,10 @@ folder_read (char *name) 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; } @@ -129,30 +138,30 @@ folder_read (char *name) /* 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; diff --git a/sbr/folder_realloc.c b/sbr/folder_realloc.c index 1d2b140..2418abd 100644 --- a/sbr/folder_realloc.c +++ b/sbr/folder_realloc.c @@ -1,21 +1,21 @@ /* - * 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 #include /* - * 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) @@ -40,16 +40,16 @@ 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 */ @@ -68,9 +68,9 @@ folder_realloc (struct msgs *mp, int lo, int hi) 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); diff --git a/sbr/gans.c b/sbr/gans.c index 270b729..27d91cd 100644 --- a/sbr/gans.c +++ b/sbr/gans.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/getans.c b/sbr/getans.c index befbd9a..3e38d87 100644 --- a/sbr/getans.c +++ b/sbr/getans.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -15,8 +15,8 @@ static char ansbuf[BUFSIZ]; static jmp_buf sigenv; /* - * static prototypes - */ +** static prototypes +*/ static RETSIGTYPE intrser (int); @@ -70,7 +70,7 @@ static RETSIGTYPE intrser (int i) { /* - * should this be siglongjmp? - */ + ** should this be siglongjmp? + */ longjmp (sigenv, 1); } diff --git a/sbr/getanswer.c b/sbr/getanswer.c index ed5fac0..4707255 100644 --- a/sbr/getanswer.c +++ b/sbr/getanswer.c @@ -1,10 +1,10 @@ /* - * 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 #include diff --git a/sbr/getarguments.c b/sbr/getarguments.c index d133e06..5dbdf56 100644 --- a/sbr/getarguments.c +++ b/sbr/getarguments.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -16,8 +16,8 @@ getarguments (char *invo_name, int argc, char **argv, int check_context) 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 */ diff --git a/sbr/getcpy.c b/sbr/getcpy.c index 2e94f08..b2891b8 100644 --- a/sbr/getcpy.c +++ b/sbr/getcpy.c @@ -1,14 +1,14 @@ /* - * 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 #include diff --git a/sbr/getfolder.c b/sbr/getfolder.c index 11e2b21..02910c3 100644 --- a/sbr/getfolder.c +++ b/sbr/getfolder.c @@ -1,10 +1,10 @@ /* - * 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 @@ -15,19 +15,19 @@ getfolder(int wantcurrent) 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; } diff --git a/sbr/getpass.c b/sbr/getpass.c index 865a6c9..14f2242 100644 --- a/sbr/getpass.c +++ b/sbr/getpass.c @@ -1,44 +1,46 @@ /* - * 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 #include #include /* 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 @@ -55,9 +57,10 @@ nmh_getpass(const char *prompt) 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; diff --git a/sbr/lock_file.c b/sbr/lock_file.c index 5bc83cc..d3d447e 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -1,18 +1,19 @@ /* - * 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 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 Sun, 28 Mar 1999 15:34:03 +0200 +*/ #include #include @@ -69,16 +70,16 @@ struct lockinfo { }; /* - * 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 */ @@ -94,8 +95,8 @@ static struct lock *l_top = NULL; #endif /* DOT_LOCKING */ /* - * static prototypes - */ +** static prototypes +*/ #ifdef KERNEL_LOCKING static int lkopen_kernel (char *, int, mode_t); #endif @@ -113,9 +114,9 @@ static int lockit (struct lockinfo *); #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) @@ -131,9 +132,9 @@ 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) @@ -182,9 +183,9 @@ 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) @@ -222,9 +223,9 @@ 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) @@ -275,8 +276,8 @@ 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) @@ -297,9 +298,9 @@ 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; @@ -349,8 +350,8 @@ lkopen_kernel (char *file, int access, mode_t mode) #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) @@ -363,9 +364,9 @@ 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) @@ -379,9 +380,10 @@ lkopen_dot (char *file, int access, mode_t mode) 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) @@ -392,7 +394,10 @@ lkopen_dot (char *file, int access, mode_t mode) 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 @@ -415,9 +420,9 @@ lkopen_dot (char *file, int access, mode_t mode) #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) @@ -454,9 +459,9 @@ 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); @@ -465,8 +470,8 @@ lockit (struct lockinfo *li) #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) @@ -499,10 +504,10 @@ 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; @@ -514,9 +519,9 @@ lockname (char *file, struct lockinfo *li, int isnewlock) #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)); @@ -529,9 +534,9 @@ lockname (char *file, struct lockinfo *li, int isnewlock) /* - * 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) @@ -558,9 +563,9 @@ 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) @@ -592,9 +597,9 @@ 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) diff --git a/sbr/m_atoi.c b/sbr/m_atoi.c index 21606c4..0222533 100644 --- a/sbr/m_atoi.c +++ b/sbr/m_atoi.c @@ -1,12 +1,12 @@ /* - * 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 diff --git a/sbr/m_backup.c b/sbr/m_backup.c index 1b219a2..e8c5566 100644 --- a/sbr/m_backup.c +++ b/sbr/m_backup.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/m_convert.c b/sbr/m_convert.c index ee9ba5b..cd18406 100644 --- a/sbr/m_convert.c +++ b/sbr/m_convert.c @@ -1,17 +1,17 @@ /* - * 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 /* - * 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) @@ -27,8 +27,8 @@ static int convdir; /* convert direction */ static char *delimp; /* - * static prototypes - */ +** static prototypes +*/ static int m_conv (struct msgs *, char *, int); static int attr (struct msgs *, char *); @@ -50,15 +50,15 @@ m_convert (struct msgs *mp, char *name) 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; @@ -75,7 +75,8 @@ m_convert (struct msgs *mp, char *name) 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; } @@ -93,7 +94,8 @@ badmsg: 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: @@ -102,7 +104,8 @@ badlist: break; case BADNEW: - advise (NULL, "folder full, no %s message", name); + advise (NULL, "folder full, no %s message", + name); break; default: @@ -170,12 +173,12 @@ rangerr: 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 { @@ -193,10 +196,10 @@ single: } /* - * 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))) { @@ -219,17 +222,17 @@ single: } /* - * 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) @@ -305,18 +308,18 @@ 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) @@ -351,11 +354,11 @@ 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; @@ -373,10 +376,10 @@ attr (struct msgs *mp, char *cp) 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 == '-') { @@ -418,9 +421,9 @@ attr (struct msgs *mp, char *cp) 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; } diff --git a/sbr/m_draft.c b/sbr/m_draft.c index 4a64804..845fb96 100644 --- a/sbr/m_draft.c +++ b/sbr/m_draft.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -39,11 +39,11 @@ m_draft(char *which) 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"); @@ -55,10 +55,10 @@ m_draft(char *which) 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); diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index f2c2ffa..1ce52b6 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -1,145 +1,146 @@ /* - * 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 #include #include -/* 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); @@ -152,30 +153,30 @@ 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; @@ -255,10 +256,10 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, 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 (;;) { @@ -308,24 +309,35 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, 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; @@ -334,13 +346,20 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, 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; } @@ -359,10 +378,10 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, 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 @@ -378,8 +397,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, 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; @@ -404,8 +424,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, 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); @@ -433,11 +454,12 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, 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); @@ -473,11 +495,12 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, 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; @@ -492,61 +515,91 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, 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; } @@ -598,17 +651,17 @@ m_unknown(FILE *iob) 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; @@ -647,11 +700,11 @@ m_unknown(FILE *iob) 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++ ) @@ -668,8 +721,8 @@ m_unknown(FILE *iob) /* - * test for msg delimiter string - */ +** test for msg delimiter string +*/ static int m_Eom (int c, FILE *iob) @@ -685,9 +738,10 @@ 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 @@ -718,15 +772,15 @@ m_Eom (int c, FILE *iob) #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) @@ -738,9 +792,9 @@ 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, ' '); @@ -749,9 +803,9 @@ get_returnpath (char *rp, int rplen, char *dd, int ddlen) } /* - * 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'); @@ -762,9 +816,9 @@ get_returnpath (char *rp, int rplen, char *dd, int ddlen) } /* - * 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++; @@ -802,9 +856,9 @@ matchc(int patln, char *pat, int strln, char *str) /* - * 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) diff --git a/sbr/m_gmprot.c b/sbr/m_gmprot.c index 9bf7088..999e6f7 100644 --- a/sbr/m_gmprot.c +++ b/sbr/m_gmprot.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/m_maildir.c b/sbr/m_maildir.c index 15e4a66..1ba21c8 100644 --- a/sbr/m_maildir.c +++ b/sbr/m_maildir.c @@ -1,10 +1,10 @@ /* - * 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 @@ -18,8 +18,8 @@ static char mailfold[BUFSIZ]; /* - * static prototypes - */ +** static prototypes +*/ static char *exmaildir (char *); diff --git a/sbr/m_mktemp.c b/sbr/m_mktemp.c index 6f2089b..9b9652b 100644 --- a/sbr/m_mktemp.c +++ b/sbr/m_mktemp.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -12,39 +12,39 @@ 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]; @@ -53,7 +53,8 @@ m_mktemp ( 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); } @@ -87,22 +88,23 @@ m_mktemp ( 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]; @@ -130,7 +132,7 @@ m_mktemp2 ( 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"); diff --git a/sbr/m_msgdef.c b/sbr/m_msgdef.c index cddb4e9..cdab622 100644 --- a/sbr/m_msgdef.c +++ b/sbr/m_msgdef.c @@ -1,32 +1,32 @@ /* - * 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 /* - * 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 = ""; diff --git a/sbr/m_name.c b/sbr/m_name.c index bc3a681..20acffe 100644 --- a/sbr/m_name.c +++ b/sbr/m_name.c @@ -1,10 +1,10 @@ /* - * 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 diff --git a/sbr/makedir.c b/sbr/makedir.c index 1e03caa..89e9045 100644 --- a/sbr/makedir.c +++ b/sbr/makedir.c @@ -1,14 +1,14 @@ /* - * 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 #include @@ -31,17 +31,22 @@ makedir (char *dir) 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 ()) { @@ -64,8 +69,10 @@ makedir (char *dir) } 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; diff --git a/sbr/mf.c b/sbr/mf.c index fdad91e..8f7e357 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -1,10 +1,10 @@ /* - * 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 #include @@ -12,8 +12,8 @@ #include /* - * static prototypes - */ +** static prototypes +*/ static char *getcpy (char *); static int isat (char *); static int parse_address (void); @@ -32,9 +32,9 @@ getcpy (char *s) 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(;;) @@ -62,62 +62,62 @@ isat (char *p) /* - * - * 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 - * - * but should insist on - * - * "Marshall T. Rose" - * - * Unfortunately, a lot of mailers stupidly let people get away with this. - * - * ----- - * - * We should not allow addresses like - * - * - * - * 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 +** +** but should insist on +** +** "Marshall T. Rose" +** +** Unfortunately, a lot of mailers stupidly let people get away with this. +** +** ----- +** +** We should not allow addresses like +** +** +** +** 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 '\\' @@ -477,7 +477,8 @@ local_part (char *buffer) break; default: - sprintf (err, "no mailbox in local-part (%s)", buffer); + sprintf (err, "no mailbox in local-part (%s)", + buffer); return NOTOK; } @@ -588,9 +589,9 @@ my_lex (char *buffer) 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); \ diff --git a/sbr/mts.c b/sbr/mts.c index 4e02831..55c0f02 100644 --- a/sbr/mts.c +++ b/sbr/mts.c @@ -1,10 +1,10 @@ /* - * 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 /* for snprintf() */ #include @@ -26,8 +26,8 @@ #define OK 0 /* - * static prototypes - */ +** static prototypes +*/ static char *tailor_value (unsigned char *); static void getuserinfo (void); static const char *get_mtsconf_pathname(void); @@ -35,16 +35,16 @@ static const char *get_mtsuserconf_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; @@ -66,22 +66,22 @@ boolean username_extension_masquerading = FALSE; /* " from addrsbr.c */ 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; @@ -104,9 +104,9 @@ static struct bind binds[] = { /* - * 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) @@ -143,9 +143,9 @@ 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) @@ -194,8 +194,8 @@ 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) @@ -236,9 +236,9 @@ 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) @@ -267,8 +267,8 @@ SystemName (void) /* - * Get the username of current user - */ +** Get the username of current user +*/ char * getusername (void) @@ -281,9 +281,9 @@ 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) @@ -296,10 +296,10 @@ 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) @@ -319,11 +319,14 @@ 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 '<'. */ @@ -331,20 +334,26 @@ getuserinfo (void) *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; @@ -360,11 +369,14 @@ getuserinfo (void) } } 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); @@ -380,11 +392,13 @@ getuserinfo (void) *cp = '\0'; if (mmailid_masquerading) { - /* Do mmailid processing. The GECOS field should have the form - * "Full Name ". For instance, - * "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 ". For instance, + ** "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++) @@ -394,8 +408,10 @@ getuserinfo (void) 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)); diff --git a/sbr/norm_charmap.c b/sbr/norm_charmap.c index 8ec544f..ca3a2c4 100644 --- a/sbr/norm_charmap.c +++ b/sbr/norm_charmap.c @@ -1,28 +1,28 @@ /* - * 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 @@ -38,9 +38,11 @@ norm_charmap(char *name) 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")) @@ -106,9 +108,11 @@ norm_charmap(char *name) 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; } diff --git a/sbr/path.c b/sbr/path.c index a01385f..502ad97 100644 --- a/sbr/path.c +++ b/sbr/path.c @@ -1,10 +1,10 @@ /* - * path.c -- return a pathname - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** path.c -- return a pathname +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include @@ -18,8 +18,8 @@ static char *pwds; /* - * static prototypes - */ +** static prototypes +*/ static char *expath(char *,int); static void compath(char *); diff --git a/sbr/peekc.c b/sbr/peekc.c index cee7504..7d5f7f9 100644 --- a/sbr/peekc.c +++ b/sbr/peekc.c @@ -1,10 +1,10 @@ /* - * peekc.c -- peek at the next character in a stream - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** peekc.c -- peek at the next character in a stream +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/pidstatus.c b/sbr/pidstatus.c index 6f5f578..ff8cf48 100644 --- a/sbr/pidstatus.c +++ b/sbr/pidstatus.c @@ -1,16 +1,16 @@ /* - * pidstatus.c -- report child's status - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** pidstatus.c -- report child's status +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include /* - * auto-generated header - */ +** auto-generated header +*/ #include #ifdef HAVE_SYS_WAIT_H @@ -31,12 +31,12 @@ pidstatus (int status, FILE *fp, char *cp) int signum; /* - * I have no idea what this is for (rc) - * so I'm commenting it out for right now. - * - * if ((status & 0xff00) == 0xff00) - * return status; - */ + ** I have no idea what this is for (rc) + ** so I'm commenting it out for right now. + ** + ** if ((status & 0xff00) == 0xff00) + ** return status; + */ /* If child process returned normally */ if (WIFEXITED(status)) { diff --git a/sbr/pidwait.c b/sbr/pidwait.c index d7dd1d7..65c55b9 100644 --- a/sbr/pidwait.c +++ b/sbr/pidwait.c @@ -1,10 +1,10 @@ /* - * pidwait.c -- wait for child to exit - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** pidwait.c -- wait for child to exit +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include diff --git a/sbr/print_help.c b/sbr/print_help.c index ff3f0f1..a46a88b 100644 --- a/sbr/print_help.c +++ b/sbr/print_help.c @@ -1,11 +1,11 @@ /* - * print_help.c -- print a help message, and possibly the - * -- profile/context entries for this command - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** print_help.c -- print a help message, and possibly the +** -- profile/context entries for this command +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include @@ -23,8 +23,8 @@ print_help (char *str, struct swit *swp, int print_context) print_sw (ALL, swp, "-", stdout); /* - * check if we should print any profile entries - */ + ** check if we should print any profile entries + */ if (print_context && (s = context_find (invo_name))) printf ("\nProfile: %s\n", s); } diff --git a/sbr/print_sw.c b/sbr/print_sw.c index dad30d2..8e489dc 100644 --- a/sbr/print_sw.c +++ b/sbr/print_sw.c @@ -1,10 +1,10 @@ /* - * print_sw.c -- print switches - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** print_sw.c -- print switches +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/print_version.c b/sbr/print_version.c index 28ce0c9..162e171 100644 --- a/sbr/print_version.c +++ b/sbr/print_version.c @@ -1,10 +1,10 @@ /* - * print_version.c -- print a version string - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** print_version.c -- print a version string +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/push.c b/sbr/push.c index b2517b3..70fba6c 100644 --- a/sbr/push.c +++ b/sbr/push.c @@ -1,10 +1,10 @@ /* - * push.c -- push a fork into the background - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** push.c -- push a fork into the background +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include diff --git a/sbr/putenv.c b/sbr/putenv.c index bade935..5b53298 100644 --- a/sbr/putenv.c +++ b/sbr/putenv.c @@ -1,10 +1,10 @@ /* - * putenv.c -- (un)set an envariable - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** putenv.c -- (un)set an envariable +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -12,8 +12,8 @@ extern char **environ; /* - * prototypes - */ +** prototypes +*/ int m_putenv (char *, char *); int unputenv (char *); static int nvmatch (char *, char *); diff --git a/sbr/r1bindex.c b/sbr/r1bindex.c index 93ec950..49ac0f5 100644 --- a/sbr/r1bindex.c +++ b/sbr/r1bindex.c @@ -1,13 +1,13 @@ /* - * r1bindex.c -- Given a string and a character, return a pointer - * -- to the right of the rightmost occurrence of the - * -- character. If the character doesn't occur, the - * -- pointer will be at the beginning of the string. - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** r1bindex.c -- Given a string and a character, return a pointer +** -- to the right of the rightmost occurrence of the +** -- character. If the character doesn't occur, the +** -- pointer will be at the beginning of the string. +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/readconfig.c b/sbr/readconfig.c index 5db7920..cc8be82 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -1,11 +1,11 @@ /* - * readconfig.c -- base routine to read nmh configuration files - * -- such as nmh profile, context file, or mhn.defaults. - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** readconfig.c -- base routine to read nmh configuration files +** -- such as nmh profile, context file, or mhn.defaults. +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -82,9 +82,9 @@ readconfig (struct node **npp, FILE *ib, char *file, int ctx) np->n_context = ctx; /* - * Now scan the list of `procs' and link in the - * field value to the global variable. - */ + ** Now scan the list of `procs' and link in the + ** field value to the global variable. + */ for (ps = procs; ps->procname; ps++) if (strcmp (np->n_name, ps->procname) == 0) { *ps->procnaddr = np->n_field; diff --git a/sbr/refile.c b/sbr/refile.c index 5637d6f..ef95db8 100644 --- a/sbr/refile.c +++ b/sbr/refile.c @@ -1,11 +1,11 @@ /* - * refile.c -- call the "fileproc" to refile the - * -- msg or draft into another folder - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** refile.c -- call the "fileproc" to refile the +** -- msg or draft into another folder +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/ruserpass.c b/sbr/ruserpass.c index 5437674..c1e9243 100644 --- a/sbr/ruserpass.c +++ b/sbr/ruserpass.c @@ -1,20 +1,20 @@ /* - * Portions of this code are - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ +** Portions of this code are +** Copyright (c) 1985 Regents of the University of California. +** All rights reserved. +** +** Redistribution and use in source and binary forms are permitted +** provided that the above copyright notice and this paragraph are +** duplicated in all such forms and that any documentation, +** advertising materials, and other materials related to such +** distribution and use acknowledge that the software was developed +** by the University of California, Berkeley. The name of the +** University may not be used to endorse or promote products derived +** from this software without specific prior written permission. +** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +*/ #include #include @@ -54,8 +54,8 @@ static struct toktab toktabs[] = { }; /* - * prototypes - */ +** prototypes +*/ static int token(void); @@ -106,7 +106,11 @@ match: case PASSWD: if (fstat(fileno(cfile), &stb) >= 0 && (stb.st_mode & 077) != 0) { - /* We make this a fatal error to force the user to correct it */ + /* + ** We make this a fatal + ** error to force the user + ** to correct it + */ advise(NULL, "Error - ~/.netrc file must not be world or group readable."); adios(NULL, "Remove password or correct file permissions."); } diff --git a/sbr/seq_add.c b/sbr/seq_add.c index fb56bb9..4e01692 100644 --- a/sbr/seq_add.c +++ b/sbr/seq_add.c @@ -1,25 +1,25 @@ /* - * seq_add.c -- add message(s) to a sequence - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_add.c -- add message(s) to a sequence +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include /* - * Add all the SELECTED messages to a (possibly new) sequence. - * - * If public == 1, make sequence public. - * If public == 0, make sequence private. - * If public == -1, leave the public/private bit alone for existing - * sequences. For new sequences, set this bit based - * on its readonly status. - * - * If error, return 0, else return 1. - */ +** Add all the SELECTED messages to a (possibly new) sequence. +** +** If public == 1, make sequence public. +** If public == 0, make sequence private. +** If public == -1, leave the public/private bit alone for existing +** sequences. For new sequences, set this bit based +** on its readonly status. +** +** If error, return 0, else return 1. +*/ int seq_addsel (struct msgs *mp, char *cp, int public, int zero) @@ -30,15 +30,15 @@ seq_addsel (struct msgs *mp, char *cp, int public, int zero) return 0; /* - * We keep mp->curmsg and "cur" sequence in sync. - * See seq_list() and seq_init(). - */ + ** We keep mp->curmsg and "cur" sequence in sync. + ** See seq_list() and seq_init(). + */ if (!strcmp (current,cp)) mp->curmsg = mp->hghsel; /* - * Get the number for this sequence - */ + ** Get the number for this sequence + */ for (i = 0; mp->msgattrs[i]; i++) { if (!strcmp (mp->msgattrs[i], cp)) { new_seq = 0; @@ -47,8 +47,8 @@ seq_addsel (struct msgs *mp, char *cp, int public, int zero) } /* - * If this is a new sequence, add a slot for it - */ + ** If this is a new sequence, add a slot for it + */ if (new_seq) { if (i >= NUMATTRS) { advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp); @@ -62,34 +62,34 @@ seq_addsel (struct msgs *mp, char *cp, int public, int zero) } /* - * If sequence is new, or zero flag is set, then first - * clear the bit for this sequence from all messages. - */ + ** If sequence is new, or zero flag is set, then first + ** clear the bit for this sequence from all messages. + */ if (new_seq || zero) { for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) clear_sequence (mp, i, msgnum); } /* - * Now flip on the bit for this sequence - * for all selected messages. - */ + ** Now flip on the bit for this sequence + ** for all selected messages. + */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) if (is_selected (mp, msgnum)) add_sequence (mp, i, msgnum); /* - * Set the public/private bit for this sequence. - */ + ** Set the public/private bit for this sequence. + */ if (public == 1) make_seq_public (mp, i); else if (public == 0) make_seq_private (mp, i); else if (new_seq) { /* - * If public == -1, then only set the - * public/private bit for new sequences. - */ + ** If public == -1, then only set the + ** public/private bit for new sequences. + */ if (is_readonly (mp)) make_seq_private (mp, i); else @@ -102,16 +102,16 @@ seq_addsel (struct msgs *mp, char *cp, int public, int zero) /* - * Add a message to a (possibly new) sequence. - * - * If public == 1, make sequence public. - * If public == 0, make sequence private. - * If public == -1, leave the public/private bit alone for existing - * sequences. For new sequences, set this bit based - * on its readonly status. - * - * If error, return 0, else return 1. - */ +** Add a message to a (possibly new) sequence. +** +** If public == 1, make sequence public. +** If public == 0, make sequence private. +** If public == -1, leave the public/private bit alone for existing +** sequences. For new sequences, set this bit based +** on its readonly status. +** +** If error, return 0, else return 1. +*/ int seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero) @@ -122,14 +122,14 @@ seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero) return 0; /* - * keep mp->curmsg and msgattrs["cur"] in sync - see seq_list() - */ + ** keep mp->curmsg and msgattrs["cur"] in sync - see seq_list() + */ if (!strcmp (current,cp)) mp->curmsg = msgnum; /* - * Get the number for this sequence - */ + ** Get the number for this sequence + */ for (i = 0; mp->msgattrs[i]; i++) { if (!strcmp (mp->msgattrs[i], cp)) { new_seq = 0; @@ -138,8 +138,8 @@ seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero) } /* - * If this is a new sequence, add a slot for it - */ + ** If this is a new sequence, add a slot for it + */ if (new_seq) { if (i >= NUMATTRS) { advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp); @@ -153,32 +153,32 @@ seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero) } /* - * If sequence is new, or zero flag is set, then first - * clear the bit for this sequence from all messages. - */ + ** If sequence is new, or zero flag is set, then first + ** clear the bit for this sequence from all messages. + */ if (new_seq || zero) { for (j = mp->lowmsg; j <= mp->hghmsg; j++) clear_sequence (mp, i, j); } /* - * Now flip on the bit for this sequence - * for this particular message. - */ + ** Now flip on the bit for this sequence + ** for this particular message. + */ add_sequence (mp, i, msgnum); /* - * Set the public/private bit for this sequence. - */ + ** Set the public/private bit for this sequence. + */ if (public == 1) make_seq_public (mp, i); else if (public == 0) make_seq_private (mp, i); else if (new_seq) { /* - * If public == -1, then only set the - * public/private bit for new sequences. - */ + ** If public == -1, then only set the + ** public/private bit for new sequences. + */ if (is_readonly (mp)) make_seq_private (mp, i); else diff --git a/sbr/seq_bits.c b/sbr/seq_bits.c index e93846a..3d52ed5 100644 --- a/sbr/seq_bits.c +++ b/sbr/seq_bits.c @@ -1,10 +1,10 @@ /* - * seq_bits.c -- return the snprintb() string for a sequence - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_bits.c -- return the snprintb() string for a sequence +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/seq_del.c b/sbr/seq_del.c index 44ae6ce..1dbb0b8 100644 --- a/sbr/seq_del.c +++ b/sbr/seq_del.c @@ -1,25 +1,25 @@ /* - * seq_del.c -- delete message(s) from a sequence - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_del.c -- delete message(s) from a sequence +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include /* - * Delete all SELECTED messages from sequence - * - * If public == 1, make sequence public. - * If public == 0, make sequence private. - * If public == -1, leave the public/private bit alone for existing - * sequences. For new sequences, set this bit based - * on its readonly status. - * - * If error, return 0, else return 1. - */ +** Delete all SELECTED messages from sequence +** +** If public == 1, make sequence public. +** If public == 0, make sequence private. +** If public == -1, leave the public/private bit alone for existing +** sequences. For new sequences, set this bit based +** on its readonly status. +** +** If error, return 0, else return 1. +*/ int seq_delsel (struct msgs *mp, char *cp, int public, int zero) @@ -30,8 +30,8 @@ seq_delsel (struct msgs *mp, char *cp, int public, int zero) return 0; /* - * Get the number for this sequence - */ + ** Get the number for this sequence + */ for (i = 0; mp->msgattrs[i]; i++) { if (!strcmp (mp->msgattrs[i], cp)) { new_seq = 0; @@ -40,13 +40,13 @@ seq_delsel (struct msgs *mp, char *cp, int public, int zero) } /* - * If the zero flag is set, first add all existing - * messages in this folder to the sequence. - */ + ** If the zero flag is set, first add all existing + ** messages in this folder to the sequence. + */ if (zero) { /* - * create the sequence, if necessary - */ + ** create the sequence, if necessary + */ if (new_seq) { if (i >= NUMATTRS) { advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp); @@ -59,8 +59,8 @@ seq_delsel (struct msgs *mp, char *cp, int public, int zero) mp->msgattrs[i + 1] = NULL; } /* - * now add sequence bit to all existing messages - */ + ** now add sequence bit to all existing messages + */ for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) { if (does_exist (mp, msgnum)) add_sequence (mp, i, msgnum); @@ -75,24 +75,24 @@ seq_delsel (struct msgs *mp, char *cp, int public, int zero) } /* - * Now clear the bit on all selected messages - */ + ** Now clear the bit on all selected messages + */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) if (is_selected (mp, msgnum)) clear_sequence (mp, i, msgnum); /* - * Set the public/private bit for this sequence. - */ + ** Set the public/private bit for this sequence. + */ if (public == 1) make_seq_public (mp, i); else if (public == 0) make_seq_private (mp, i); else if (new_seq) { /* - * If public == -1, then only set the - * public/private bit for new sequences. - */ + ** If public == -1, then only set the + ** public/private bit for new sequences. + */ if (is_readonly (mp)) make_seq_private (mp, i); else @@ -105,10 +105,10 @@ seq_delsel (struct msgs *mp, char *cp, int public, int zero) /* - * Delete message from sequence. - * - * If error, return 0, else return 1. - */ +** Delete message from sequence. +** +** If error, return 0, else return 1. +*/ int seq_delmsg (struct msgs *mp, char *cp, int msgnum) diff --git a/sbr/seq_getnum.c b/sbr/seq_getnum.c index c5ff8b4..34e6049 100644 --- a/sbr/seq_getnum.c +++ b/sbr/seq_getnum.c @@ -1,11 +1,11 @@ /* - * seq_getnum.c -- find the index for a sequence - * -- return -1 if sequence doesn't exist - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_getnum.c -- find the index for a sequence +** -- return -1 if sequence doesn't exist +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/seq_list.c b/sbr/seq_list.c index 23bd544..87c5d04 100644 --- a/sbr/seq_list.c +++ b/sbr/seq_list.c @@ -1,11 +1,11 @@ /* - * seq_list.c -- Get all messages in a sequence and return them - * -- as a space separated list of message ranges. - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_list.c -- Get all messages in a sequence and return them +** -- as a space separated list of message ranges. +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -31,11 +31,11 @@ seq_list(struct msgs *mp, char *seqname) } /* - * Special processing for "cur" sequence. We assume that the - * "cur" sequence and mp->curmsg are in sync (see seq_add.c). - * This is returned, even if message doesn't exist or the - * folder is empty. - */ + ** Special processing for "cur" sequence. We assume that the + ** "cur" sequence and mp->curmsg are in sync (see seq_add.c). + ** This is returned, even if message doesn't exist or the + ** folder is empty. + */ if (!strcmp (current, seqname)) { if (mp->curmsg) { sprintf(buffer, "%s", m_name(mp->curmsg)); @@ -56,18 +56,18 @@ seq_list(struct msgs *mp, char *seqname) for (i = mp->lowmsg; i <= mp->hghmsg; ++i) { /* - * If message doesn't exist, or isn't in - * the sequence, then continue. - */ + ** If message doesn't exist, or isn't in + ** the sequence, then continue. + */ if (!does_exist(mp, i) || !in_sequence(mp, seqnum, i)) continue; /* - * See if we need to enlarge buffer. Since we don't know - * exactly how many character this particular message range - * will need, we enlarge the buffer if we are within - * 50 characters of the end. - */ + ** See if we need to enlarge buffer. Since we don't know + ** exactly how many character this particular message range + ** will need, we enlarge the buffer if we are within + ** 50 characters of the end. + */ if (bp - buffer > len - 50) { char *newbuf; @@ -78,9 +78,9 @@ seq_list(struct msgs *mp, char *seqname) } /* - * If this is not the first message range in - * the list, first add a space. - */ + ** If this is not the first message range in + ** the list, first add a space. + */ if (bp > buffer) *bp++ = ' '; @@ -89,8 +89,8 @@ seq_list(struct msgs *mp, char *seqname) j = i; /* Remember beginning of message range */ /* - * Scan to the end of this message range - */ + ** Scan to the end of this message range + */ for (++i; i <= mp->hghmsg && does_exist(mp, i) && in_sequence(mp, seqnum, i); ++i) ; diff --git a/sbr/seq_nameok.c b/sbr/seq_nameok.c index e10ef92..e9598c0 100644 --- a/sbr/seq_nameok.c +++ b/sbr/seq_nameok.c @@ -1,10 +1,10 @@ /* - * seq_nameok.c -- check if a sequence name is ok - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_nameok.c -- check if a sequence name is ok +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include @@ -20,9 +20,9 @@ seq_nameok (unsigned char *s) } /* - * Make sure sequence name doesn't clash with one - * of the `reserved' sequence names. - */ + ** Make sure sequence name doesn't clash with one + ** of the `reserved' sequence names. + */ if (!(strcmp (s, "new") && strcmp (s, "all") && strcmp (s, "first") && @@ -34,17 +34,17 @@ seq_nameok (unsigned char *s) } /* - * First character in a sequence name must be - * an alphabetic character ... - */ + ** First character in a sequence name must be + ** an alphabetic character ... + */ if (!isalpha (*s)) { advise (NULL, "illegal sequence name: %s", s); return 0; } /* - * and can be followed by zero or more alphanumeric characters - */ + ** and can be followed by zero or more alphanumeric characters + */ for (pp = s + 1; *pp; pp++) if (!isalnum (*pp)) { advise (NULL, "illegal sequence name: %s", s); diff --git a/sbr/seq_print.c b/sbr/seq_print.c index 2db6656..e73424e 100644 --- a/sbr/seq_print.c +++ b/sbr/seq_print.c @@ -1,18 +1,18 @@ /* - * seq_print.c -- Routines to print sequence information. - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_print.c -- Routines to print sequence information. +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #define empty(s) ((s) ? (s) : "") /* - * Print all the sequences in a folder - */ +** Print all the sequences in a folder +*/ void seq_printall (struct msgs *mp) { @@ -29,8 +29,8 @@ seq_printall (struct msgs *mp) /* - * Print a particular sequence in a folder - */ +** Print a particular sequence in a folder +*/ void seq_print (struct msgs *mp, char *seqname) { diff --git a/sbr/seq_read.c b/sbr/seq_read.c index 6945f00..448f9ef 100644 --- a/sbr/seq_read.c +++ b/sbr/seq_read.c @@ -1,36 +1,36 @@ /* - * seq_read.c -- read the .mh_sequence file and - * -- initialize sequence information - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_read.c -- read the .mh_sequence file and +** -- initialize sequence information +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include /* - * static prototypes - */ +** static prototypes +*/ static int seq_init (struct msgs *, char *, char *); static void seq_public (struct msgs *); static void seq_private (struct msgs *); /* - * Get the sequence information for this folder from - * .mh_sequences (or equivalent specified in .mh_profile) - * or context file (for private sequences). - */ +** Get the sequence information for this folder from +** .mh_sequences (or equivalent specified in .mh_profile) +** or context file (for private sequences). +*/ void seq_read (struct msgs *mp) { /* - * Initialize the list of sequence names. Go ahead and - * add the "cur" sequence to the list of sequences. - */ + ** Initialize the list of sequence names. Go ahead and + ** add the "cur" sequence to the list of sequences. + */ mp->msgattrs[0] = getcpy (current); mp->msgattrs[1] = NULL; make_all_public (mp); /* initially, make all public */ @@ -48,8 +48,8 @@ seq_read (struct msgs *mp) /* - * read folder's sequences file for public sequences - */ +** read folder's sequences file for public sequences +*/ static void seq_public (struct msgs *mp) @@ -60,11 +60,11 @@ seq_public (struct msgs *mp) FILE *fp; /* - * If mh_seq == NULL (such as if nmh been compiled with - * NOPUBLICSEQ), or if *mh_seq == '\0' (the user has defined - * the "mh-sequences" profile entry, but left it empty), - * then just return, and do not initialize any public sequences. - */ + ** If mh_seq == NULL (such as if nmh been compiled with + ** NOPUBLICSEQ), or if *mh_seq == '\0' (the user has defined + ** the "mh-sequences" profile entry, but left it empty), + ** then just return, and do not initialize any public sequences. + */ if (mh_seq == NULL || *mh_seq == '\0') return; @@ -114,11 +114,11 @@ seq_public (struct msgs *mp) /* - * Scan profile/context list for private sequences. - * - * We search the context list for all keys that look like - * "atr-seqname-folderpath", and add them as private sequences. - */ +** Scan profile/context list for private sequences. +** +** We search the context list for all keys that look like +** "atr-seqname-folderpath", and add them as private sequences. +*/ static void seq_private (struct msgs *mp) @@ -145,14 +145,14 @@ seq_private (struct msgs *mp) /* - * Add the name of sequence to the list of folder sequences. - * Then parse the list of message ranges for this - * sequence, and setup the various bit flags for each - * message in the sequence. - * - * Return internal index for the sequence if successful. - * Return -1 on error. - */ +** Add the name of sequence to the list of folder sequences. +** Then parse the list of message ranges for this +** sequence, and setup the various bit flags for each +** message in the sequence. +** +** Return internal index for the sequence if successful. +** Return -1 on error. +*/ static int seq_init (struct msgs *mp, char *name, char *field) @@ -161,17 +161,17 @@ seq_init (struct msgs *mp, char *name, char *field) char *cp, **ap; /* - * Check if this is "cur" sequence, - * so we can do some special things. - */ + ** Check if this is "cur" sequence, + ** so we can do some special things. + */ is_current = !strcmp (current, name); /* - * Search for this sequence name to see if we've seen - * it already. If we've seen this sequence before, - * then clear the bit for this sequence from all the - * mesages in this folder. - */ + ** Search for this sequence name to see if we've seen + ** it already. If we've seen this sequence before, + ** then clear the bit for this sequence from all the + ** mesages in this folder. + */ for (i = 0; mp->msgattrs[i]; i++) { if (!strcmp (mp->msgattrs[i], name)) { for (j = mp->lowmsg; j <= mp->hghmsg; j++) @@ -188,9 +188,9 @@ seq_init (struct msgs *mp, char *name, char *field) } /* - * If we've already seen this sequence name, just free the - * name string. Else add it to the list of sequence names. - */ + ** If we've already seen this sequence name, just free the + ** name string. Else add it to the list of sequence names. + */ if (mp->msgattrs[i]) { free (name); } else { @@ -199,8 +199,8 @@ seq_init (struct msgs *mp, char *name, char *field) } /* - * Split up the different message ranges at whitespace - */ + ** Split up the different message ranges at whitespace + */ for (ap = brkstring (field, " ", "\n"); *ap; ap++) { if ((cp = strchr(*ap, '-'))) *cp++ = '\0'; @@ -208,19 +208,19 @@ seq_init (struct msgs *mp, char *name, char *field) k = cp ? m_atoi (cp) : j; /* - * Keep mp->curmsg and "cur" sequence in synch. Unlike - * other sequences, this message doesn't need to exist. - * Think about the series of command (rmm; next) to - * understand why this can be the case. But if it does - * exist, we will still set the bit flag for it like - * other sequences. - */ + ** Keep mp->curmsg and "cur" sequence in synch. Unlike + ** other sequences, this message doesn't need to exist. + ** Think about the series of command (rmm; next) to + ** understand why this can be the case. But if it does + ** exist, we will still set the bit flag for it like + ** other sequences. + */ if (is_current) mp->curmsg = j; /* - * We iterate through messages in this range - * and flip on bit for this sequence. - */ + ** We iterate through messages in this range + ** and flip on bit for this sequence. + */ for (; j <= k; j++) { if (j >= mp->lowmsg && j <= mp->hghmsg && does_exist(mp, j)) add_sequence (mp, i, j); diff --git a/sbr/seq_save.c b/sbr/seq_save.c index 0c14f47..e6f5a5b 100644 --- a/sbr/seq_save.c +++ b/sbr/seq_save.c @@ -1,24 +1,24 @@ /* - * seq_save.c -- 1) synchronize sequences - * -- 2) save public sequences - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_save.c -- 1) synchronize sequences +** -- 2) save public sequences +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include /* - * 1. If sequence is public and folder is readonly, - * then change it to be private - * 2a. If sequence is public, then add it to the sequences file - * in folder (name specified by mh-sequences profile entry). - * 2b. If sequence is private, then add it to the - * context file. - */ +** 1. If sequence is public and folder is readonly, +** then change it to be private +** 2a. If sequence is public, then add it to the sequences file +** in folder (name specified by mh-sequences profile entry). +** 2b. If sequence is private, then add it to the +** context file. +*/ void seq_save (struct msgs *mp) @@ -37,17 +37,19 @@ seq_save (struct msgs *mp) flags = mp->msgflags; /* record folder flags */ /* - * If no mh-sequences file is defined, or if a mh-sequences file - * is defined but empty (*mh_seq == '\0'), then pretend folder - * is readonly. This will force all sequences to be private. - */ + ** If no mh-sequences file is defined, or if a mh-sequences file + ** is defined but empty (*mh_seq == '\0'), then pretend folder + ** is readonly. This will force all sequences to be private. + */ if (mh_seq == NULL || *mh_seq == '\0') set_readonly (mp); else - snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq); + snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, + mh_seq); for (i = 0; mp->msgattrs[i]; i++) { - snprintf (attr, sizeof(attr), "atr-%s-%s", mp->msgattrs[i], mp->foldpath); + snprintf (attr, sizeof(attr), "atr-%s-%s", mp->msgattrs[i], + mp->foldpath); /* get space separated list of sequence ranges */ if (!(cp = seq_list(mp, mp->msgattrs[i]))) { @@ -57,22 +59,18 @@ seq_save (struct msgs *mp) if (is_readonly(mp) || is_seq_private(mp, i)) { priv: - /* - * sequence is private - */ + /* sequence is private */ context_replace (attr, cp); /* update sequence in context */ } else { - /* - * sequence is public - */ + /* sequence is public */ context_del (attr); /* delete sequence from context */ if (!fp) { /* - * Attempt to open file for public sequences. - * If that fails (probably because folder is - * readonly), then make sequence private. - */ + ** Attempt to open file for public sequences. + ** If that fails (probably because folder is + ** readonly), then make sequence private. + */ if ((fp = lkfopen (seqfile, "w")) == NULL && (unlink (seqfile) == -1 || (fp = lkfopen (seqfile, "w")) == NULL)) { @@ -97,16 +95,16 @@ priv: SIGPROCMASK (SIG_SETMASK, &oset, &set); /* reset signal mask */ } else { /* - * If folder is not readonly, and we didn't save any - * public sequences, then remove that file. - */ + ** If folder is not readonly, and we didn't save any + ** public sequences, then remove that file. + */ if (!is_readonly(mp)) unlink (seqfile); } /* - * Reset folder flag, since we may be - * pretending that folder is readonly. - */ + ** Reset folder flag, since we may be + ** pretending that folder is readonly. + */ mp->msgflags = flags; } diff --git a/sbr/seq_setcur.c b/sbr/seq_setcur.c index fdf2028..357c04b 100644 --- a/sbr/seq_setcur.c +++ b/sbr/seq_setcur.c @@ -1,10 +1,10 @@ /* - * seq_setcur.c -- set the current message ("cur" sequence) for a folder - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_setcur.c -- set the current message ("cur" sequence) for a folder +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include @@ -13,8 +13,8 @@ void seq_setcur (struct msgs *mp, int msgnum) { /* - * Just call seq_addmsg() to update the - * "cur" sequence. - */ + ** Just call seq_addmsg() to update the + ** "cur" sequence. + */ seq_addmsg (mp, current, msgnum, -1, 1); } diff --git a/sbr/seq_setprev.c b/sbr/seq_setprev.c index 7e62b64..530c11f 100644 --- a/sbr/seq_setprev.c +++ b/sbr/seq_setprev.c @@ -1,20 +1,20 @@ /* - * seq_setprev.c -- set the Previous-Sequence - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_setprev.c -- set the Previous-Sequence +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include /* - * Add all the messages currently SELECTED to - * the Previous-Sequence. This way, when the next - * command is given, there is a convenient way to - * selected all the messages used in the previous - * command. - */ +** Add all the messages currently SELECTED to +** the Previous-Sequence. This way, when the next +** command is given, there is a convenient way to +** selected all the messages used in the previous +** command. +*/ void seq_setprev (struct msgs *mp) @@ -22,9 +22,9 @@ seq_setprev (struct msgs *mp) char **ap, *cp, *dp; /* - * Get the list of sequences for Previous-Sequence - * and split them. - */ + ** Get the list of sequences for Previous-Sequence + ** and split them. + */ if ((cp = context_find (psequence))) { dp = getcpy (cp); if (!(ap = brkstring (dp, " ", "\n")) || !*ap) { diff --git a/sbr/seq_setunseen.c b/sbr/seq_setunseen.c index a115564..8c9fe41 100644 --- a/sbr/seq_setunseen.c +++ b/sbr/seq_setunseen.c @@ -1,21 +1,21 @@ /* - * seq_setunseen.c -- add/delete all messages which have the SELECT_UNSEEN - * -- bit set to/from the Unseen-Sequence - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** seq_setunseen.c -- add/delete all messages which have the SELECT_UNSEEN +** -- bit set to/from the Unseen-Sequence +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include /* - * We scan through the folder and act upon all messages - * that are marked with the SELECT_UNSEEN bit. - * - * If seen == 1, delete messages from unseen sequence. - * If seen == 0, add messages to unseen sequence. - */ +** We scan through the folder and act upon all messages +** that are marked with the SELECT_UNSEEN bit. +** +** If seen == 1, delete messages from unseen sequence. +** If seen == 0, add messages to unseen sequence. +*/ void seq_setunseen (struct msgs *mp, int seen) @@ -24,9 +24,9 @@ seq_setunseen (struct msgs *mp, int seen) char **ap, *cp, *dp; /* - * Get the list of sequences for Unseen-Sequence - * and split them. - */ + ** Get the list of sequences for Unseen-Sequence + ** and split them. + */ if ((cp = context_find (usequence))) { dp = getcpy (cp); if (!(ap = brkstring (dp, " ", "\n")) || !*ap) { @@ -38,9 +38,9 @@ seq_setunseen (struct msgs *mp, int seen) } /* - * Now add/delete each message which has the SELECT_UNSEEN - * bit set to/from each of these sequences. - */ + ** Now add/delete each message which has the SELECT_UNSEEN + ** bit set to/from each of these sequences. + */ for (; *ap; ap++) { if (seen) { /* make sure sequence exists first */ diff --git a/sbr/showfile.c b/sbr/showfile.c index b8e984b..ac9fc69 100644 --- a/sbr/showfile.c +++ b/sbr/showfile.c @@ -1,10 +1,10 @@ /* - * showfile.c -- invoke the `lproc' command - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** showfile.c -- invoke the `lproc' command +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include @@ -20,10 +20,10 @@ showfile (char **arg, char *file) fflush(stdout); /* - * If you have your lproc listed as "mhl", - * then really invoked the mhlproc instead - * (which is usually mhl anyway). - */ + ** If you have your lproc listed as "mhl", + ** then really invoked the mhlproc instead + ** (which is usually mhl anyway). + */ if (!strcmp (r1bindex (lproc, '/'), "mhl")) lproc = mhlproc; diff --git a/sbr/signals.c b/sbr/signals.c index 00f516c..1f1b0be 100644 --- a/sbr/signals.c +++ b/sbr/signals.c @@ -1,10 +1,10 @@ /* - * signals.c -- general signals interface for nmh - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** signals.c -- general signals interface for nmh +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -40,11 +40,11 @@ SIGPROCMASK (int how, const sigset_t *set, sigset_t *oset) /* - * A version of the function `signal' that uses reliable - * signals, if the machine supports them. Also, (assuming - * OS support), it restarts interrupted system calls for all - * signals except SIGALRM. - */ +** A version of the function `signal' that uses reliable +** signals, if the machine supports them. Also, (assuming +** OS support), it restarts interrupted system calls for all +** signals except SIGALRM. +*/ SIGNAL_HANDLER SIGNAL (int sig, SIGNAL_HANDLER func) @@ -75,11 +75,11 @@ SIGNAL (int sig, SIGNAL_HANDLER func) /* - * A version of the function `signal' that will set - * the handler of `sig' to `func' if the signal is - * not currently set to SIG_IGN. Also uses reliable - * signals if available. - */ +** A version of the function `signal' that will set +** the handler of `sig' to `func' if the signal is +** not currently set to SIG_IGN. Also uses reliable +** signals if available. +*/ SIGNAL_HANDLER SIGNAL2 (int sig, SIGNAL_HANDLER func) { diff --git a/sbr/smatch.c b/sbr/smatch.c index b22df66..5bee67f 100644 --- a/sbr/smatch.c +++ b/sbr/smatch.c @@ -1,10 +1,10 @@ /* - * smatch.c -- match a switch (option) - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** smatch.c -- match a switch (option) +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/snprintb.c b/sbr/snprintb.c index baab61f..655831c 100644 --- a/sbr/snprintb.c +++ b/sbr/snprintb.c @@ -1,10 +1,10 @@ /* - * snprintb.c -- snprintf a %b string - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** snprintb.c -- snprintf a %b string +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/snprintf.c b/sbr/snprintf.c index 2b19881..1dd4a65 100644 --- a/sbr/snprintf.c +++ b/sbr/snprintf.c @@ -1,70 +1,70 @@ /* - * snprintf.c -- formatted output to a string - * - * This is an implementation of snprintf() and vsnprintf() - * taken from the Apache web server. This is only used on - * systems which do not have a native version. - */ +** snprintf.c -- formatted output to a string +** +** This is an implementation of snprintf() and vsnprintf() +** taken from the Apache web server. This is only used on +** systems which do not have a native version. +*/ /* ==================================================================== - * Copyright (c) 1995-1999 The Apache Group. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Group and was originally based - * on public domain software written at the National Center for - * Supercomputing Applications, University of Illinois, Urbana-Champaign. - * For more information on the Apache Group and the Apache HTTP server - * project, please see . - * - * This code is based on, and used with the permission of, the - * SIO stdio-replacement strx_* functions by Panos Tsirigotis - * for xinetd. - */ +** Copyright (c) 1995-1999 The Apache Group. All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** +** 3. All advertising materials mentioning features or use of this +** software must display the following acknowledgment: +** "This product includes software developed by the Apache Group +** for use in the Apache HTTP server project (http://www.apache.org/)." +** +** 4. The names "Apache Server" and "Apache Group" must not be used to +** endorse or promote products derived from this software without +** prior written permission. For written permission, please contact +** apache@apache.org. +** +** 5. Products derived from this software may not be called "Apache" +** nor may "Apache" appear in their names without prior written +** permission of the Apache Group. +** +** 6. Redistributions of any form whatsoever must retain the following +** acknowledgment: +** "This product includes software developed by the Apache Group +** for use in the Apache HTTP server project (http://www.apache.org/)." +** +** THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY +** EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR +** ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +** STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +** OF THE POSSIBILITY OF SUCH DAMAGE. +** ==================================================================== +** +** This software consists of voluntary contributions made by many +** individuals on behalf of the Apache Group and was originally based +** on public domain software written at the National Center for +** Supercomputing Applications, University of Illinois, Urbana-Champaign. +** For more information on the Apache Group and the Apache HTTP server +** project, please see . +** +** This code is based on, and used with the permission of, the +** SIO stdio-replacement strx_* functions by Panos Tsirigotis +** for xinetd. +*/ #include #include @@ -104,33 +104,34 @@ typedef int bool_int; #define FLOAT_DIGITS 6 #define EXPONENT_LENGTH 10 -/* These macros allow correct support of 8-bit characters on systems which - * support 8-bit characters. Pretty dumb how the cast is required, but - * that's legacy libc for ya. These new macros do not support EOF like - * the standard macros do. Tough. - */ +/* +** These macros allow correct support of 8-bit characters on systems which +** support 8-bit characters. Pretty dumb how the cast is required, but +** that's legacy libc for ya. These new macros do not support EOF like +** the standard macros do. Tough. +*/ #define ap_isalpha(c) (isalpha(((unsigned char)(c)))) #define ap_isdigit(c) (isdigit(((unsigned char)(c)))) #define ap_islower(c) (islower(((unsigned char)(c)))) /* - * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions - * - * XXX: this is a magic number; do not decrease it - */ +** NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions +** +** XXX: this is a magic number; do not decrease it +*/ #define NUM_BUF_SIZE 512 /* - * cvt.c - IEEE floating point formatting routines for FreeBSD - * from GNU libc-4.6.27. Modified to be thread safe. - */ +** cvt.c - IEEE floating point formatting routines for FreeBSD +** from GNU libc-4.6.27. Modified to be thread safe. +*/ /* - * ap_ecvt converts to decimal - * the number of digits is specified by ndigit - * decpt is set to the position of the decimal point - * sign is set to 0 for positive, 1 for negative - */ +** ap_ecvt converts to decimal +** the number of digits is specified by ndigit +** decpt is set to the position of the decimal point +** sign is set to 0 for positive, 1 for negative +*/ #define NDIG 80 @@ -154,8 +155,8 @@ ap_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf) arg = modf(arg, &fi); p1 = &buf[NDIG]; /* - * Do integer part - */ + ** Do integer part + */ if (fi != 0) { p1 = &buf[NDIG]; while (fi != 0) { @@ -221,9 +222,9 @@ ap_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf) } /* - * ap_gcvt - Floating output conversion to - * minimal length string - */ +** ap_gcvt - Floating output conversion to +** minimal length string +*/ static char * ap_gcvt(double number, int ndigit, char *buf, boolean_e altform) @@ -284,15 +285,15 @@ ap_gcvt(double number, int ndigit, char *buf, boolean_e altform) } /* - * The INS_CHAR macro inserts a character in the buffer and writes - * the buffer back to disk if necessary - * It uses the char pointers sp and bep: - * sp points to the next available character in the buffer - * bep points to the end-of-buffer+1 - * While using this macro, note that the nextb pointer is NOT updated. - * - * NOTE: Evaluation of the c argument should not have any side-effects - */ +** The INS_CHAR macro inserts a character in the buffer and writes +** the buffer back to disk if necessary +** It uses the char pointers sp and bep: +** sp points to the next available character in the buffer +** bep points to the end-of-buffer+1 +** While using this macro, note that the nextb pointer is NOT updated. +** +** NOTE: Evaluation of the c argument should not have any side-effects +*/ #define INS_CHAR(c, sp, bep, cc) \ { \ if (sp >= bep) { \ @@ -317,11 +318,11 @@ ap_gcvt(double number, int ndigit, char *buf, boolean_e altform) } /* - * This macro does zero padding so that the precision - * requirement is satisfied. The padding is done by - * adding '0's to the left of the string that is going - * to be printed. - */ +** This macro does zero padding so that the precision +** requirement is satisfied. The padding is done by +** adding '0's to the left of the string that is going +** to be printed. +*/ #define FIX_PRECISION( adjust, precision, s, s_len ) \ if ( adjust ) \ while ( s_len < precision ) \ @@ -331,9 +332,9 @@ ap_gcvt(double number, int ndigit, char *buf, boolean_e altform) } /* - * Macro that does padding. The padding is done by printing - * the character ch. - */ +** Macro that does padding. The padding is done by printing +** the character ch. +*/ #define PAD( width, len, ch ) do \ { \ INS_CHAR( ch, sp, bep, cc ) ; \ @@ -342,25 +343,25 @@ ap_gcvt(double number, int ndigit, char *buf, boolean_e altform) while ( width > len ) /* - * Prefix the character ch to the string str - * Increase length - * Set the has_prefix flag - */ +** Prefix the character ch to the string str +** Increase length +** Set the has_prefix flag +*/ #define PREFIX( str, length, ch ) *--str = ch ; length++ ; has_prefix = YES /* - * Convert num to its decimal format. - * Return value: - * - a pointer to a string containing the number (no sign) - * - len contains the length of the string - * - is_negative is set to TRUE or FALSE depending on the sign - * of the number (always set to FALSE if is_unsigned is TRUE) - * - * The caller provides a buffer for the string: that is the buf_end argument - * which is a pointer to the END of the buffer + 1 (i.e. if the buffer - * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) - */ +** Convert num to its decimal format. +** Return value: +** - a pointer to a string containing the number (no sign) +** - len contains the length of the string +** - is_negative is set to TRUE or FALSE depending on the sign +** of the number (always set to FALSE if is_unsigned is TRUE) +** +** The caller provides a buffer for the string: that is the buf_end argument +** which is a pointer to the END of the buffer + 1 (i.e. if the buffer +** is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) +*/ static char * conv_10(register wide_int num, register bool_int is_unsigned, register bool_int *is_negative, char *buf_end, @@ -376,14 +377,15 @@ conv_10(register wide_int num, register bool_int is_unsigned, *is_negative = (num < 0); /* - * On a 2's complement machine, negating the most negative integer - * results in a number that cannot be represented as a signed integer. - * Here is what we do to obtain the number's magnitude: - * a. add 1 to the number - * b. negate it (becomes positive) - * c. convert it to unsigned - * d. add 1 - */ + ** On a 2's complement machine, negating the most negative + ** integer results in a number that cannot be represented + ** as a signed integer. + ** Here is what we do to obtain the number's magnitude: + ** a. add 1 to the number + ** b. negate it (becomes positive) + ** c. convert it to unsigned + ** d. add 1 + */ if (*is_negative) { wide_int t = num + 1; @@ -393,8 +395,8 @@ conv_10(register wide_int num, register bool_int is_unsigned, } /* - * We use a do-while loop so that we write at least 1 digit - */ + ** We use a do-while loop so that we write at least 1 digit + */ do { register u_wide_int new_magnitude = magnitude / 10; @@ -449,11 +451,11 @@ conv_sockaddr_in(struct sockaddr_in *si, char *buf_end, int *len) /* - * Convert a floating point number to a string formats 'f', 'e' or 'E'. - * The result is placed in buf, and len denotes the length of the string - * The sign is returned in the is_negative argument (and is not placed - * in buf). - */ +** Convert a floating point number to a string formats 'f', 'e' or 'E'. +** The result is placed in buf, and len denotes the length of the string +** The sign is returned in the is_negative argument (and is not placed +** in buf). +*/ static char * conv_fp(register char format, register double num, boolean_e add_dp, int precision, bool_int *is_negative, @@ -470,8 +472,8 @@ conv_fp(register char format, register double num, p = ap_ecvt(num, precision + 1, &decimal_point, is_negative, buf1); /* - * Check for Infinity and NaN - */ + ** Check for Infinity and NaN + */ if (ap_isalpha(*p)) { *len = strlen(strcpy(buf, p)); *is_negative = FALSE; @@ -500,8 +502,8 @@ conv_fp(register char format, register double num, } /* - * copy the rest of p, the NUL is NOT copied - */ + ** copy the rest of p, the NUL is NOT copied + */ while (*p) *s++ = *p++; @@ -519,8 +521,8 @@ conv_fp(register char format, register double num, *s++ = exponent_is_negative ? '-' : '+'; /* - * Make sure the exponent has at least 2 digits - */ + ** Make sure the exponent has at least 2 digits + */ if (t_len == 1) *s++ = '0'; while (t_len--) @@ -538,15 +540,15 @@ conv_fp(register char format, register double num, /* - * Convert num to a base X number where X is a power of 2. nbits determines X. - * For example, if nbits is 3, we do base 8 conversion - * Return value: - * a pointer to a string containing the number - * - * The caller provides a buffer for the string: that is the buf_end argument - * which is a pointer to the END of the buffer + 1 (i.e. if the buffer - * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) - */ +** Convert num to a base X number where X is a power of 2. nbits determines X. +** For example, if nbits is 3, we do base 8 conversion +** Return value: +** a pointer to a string containing the number +** +** The caller provides a buffer for the string: that is the buf_end argument +** which is a pointer to the END of the buffer + 1 (i.e. if the buffer +** is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) +*/ static char * conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register int *len) @@ -569,8 +571,8 @@ conv_p2(register u_wide_int num, register int nbits, /* - * Do format conversion placing the output in buffer - */ +** Do format conversion placing the output in buffer +*/ static int ap_vformatter(int (*flush_func)(ap_vformatter_buff *), ap_vformatter_buff *vbuff, const char *fmt, va_list ap) @@ -600,8 +602,8 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), char char_buf[2]; /* for printing %% and % */ /* - * Flag variables - */ + ** Flag variables + */ boolean_e is_long; boolean_e alternate_form; boolean_e print_sign; @@ -618,8 +620,8 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), INS_CHAR(*fmt, sp, bep, cc); } else { /* - * Default variable settings - */ + ** Default variable settings + */ adjust = RIGHT; alternate_form = print_sign = print_blank = NO; pad_char = ' '; @@ -628,12 +630,12 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), fmt++; /* - * Try to avoid checking for flags, width or precision - */ + ** Try to avoid checking for flags, width or precision + */ if (!ap_islower(*fmt)) { /* - * Recognize flags: -, #, BLANK, + - */ + ** Recognize flags: -, #, BLANK, + + */ for (;; fmt++) { if (*fmt == '-') adjust = LEFT; @@ -650,8 +652,8 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), } /* - * Check if a width was specified - */ + ** Check if a width was specified + */ if (ap_isdigit(*fmt)) { STR_TO_DEC(fmt, min_width); adjust_width = YES; @@ -667,12 +669,13 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), adjust_width = NO; /* - * Check if a precision was specified - * - * XXX: an unreasonable amount of precision may be specified - * resulting in overflow of num_buf. Currently we - * ignore this possibility. - */ + ** Check if a precision was specified + ** + ** XXX: an unreasonable amount of precision + ** may be specified resulting in overflow of + ** num_buf. Currently we ignore this + ** possibility. + */ if (*fmt == '.') { adjust_precision = YES; fmt++; @@ -691,8 +694,8 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), adjust_precision = adjust_width = NO; /* - * Modifier check - */ + ** Modifier check + */ if (*fmt == 'l') { is_long = YES; fmt++; @@ -703,16 +706,18 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), } /* - * Argument extraction and printing. - * First we determine the argument type. - * Then, we convert the argument to a string. - * On exit from the switch, s points to the string that - * must be printed, s_len has the length of the string - * The precision requirements, if any, are reflected in s_len. - * - * NOTE: pad_char may be set to '0' because of the 0 flag. - * It is reset to ' ' by non-numeric formats - */ + ** Argument extraction and printing. + ** First we determine the argument type. + ** Then, we convert the argument to a string. + ** On exit from the switch, s points to the string that + ** must be printed, s_len has the length of the string + ** The precision requirements, if any, are reflected + ** in s_len. + ** + ** NOTE: pad_char may be set to '0' because of the + ** 0 flag. + ** It is reset to ' ' by non-numeric formats + */ switch (*fmt) { case 'u': if (is_long) @@ -795,8 +800,9 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), case 'E': fp_num = va_arg(ap, double); /* - * * We use &num_buf[ 1 ], so that we have room for the sign - */ + ** We use &num_buf[ 1 ], so that we have + ** room for the sign + */ s = conv_fp(*fmt, fp_num, alternate_form, (adjust_precision == NO) ? FLOAT_DIGITS : precision, &is_negative, &num_buf[1], &s_len); @@ -816,8 +822,9 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), else if (precision == 0) precision = 1; /* - * * We use &num_buf[ 1 ], so that we have room for the sign - */ + ** We use &num_buf[ 1 ], so that we have + ** room for the sign + */ s = ap_gcvt(va_arg(ap, double), precision, &num_buf[1], alternate_form); if (*s == '-') @@ -859,16 +866,19 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), break; /* - * This is where we extend the printf format, with a second - * type specifier - */ + ** This is where we extend the printf format, + ** with a second type specifier + */ case 'p': switch(*++fmt) { /* - * If the pointer size is equal to the size of an unsigned - * integer we convert the pointer to a hex number, otherwise - * we print "%p" to indicate that we don't handle "%p". - */ + ** If the pointer size is equal to + ** the size of an unsigned integer + ** we convert the pointer to a hex + ** number, otherwise we print "%p" + ** to indicate that we don't handle + ** "%p". + */ case 'p': ui_num = (u_wide_int) va_arg(ap, void *); @@ -883,7 +893,10 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), pad_char = ' '; break; - /* print a struct sockaddr_in as a.b.c.d:port */ + /* + ** print a struct sockaddr_in as + ** a.b.c.d:port + */ case 'I': { struct sockaddr_in *si; @@ -893,8 +906,7 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), s = conv_sockaddr_in(si, &num_buf[NUM_BUF_SIZE], &s_len); if (adjust_precision && precision < s_len) s_len = precision; - } - else { + } else { s = S_NULL; s_len = S_NULL_LEN; } @@ -912,8 +924,7 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), s = conv_in_addr(ia, &num_buf[NUM_BUF_SIZE], &s_len); if (adjust_precision && precision < s_len) s_len = precision; - } - else { + } else { s = S_NULL; s_len = S_NULL_LEN; } @@ -935,22 +946,24 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), case NUL: /* - * The last character of the format string was %. - * We ignore it. - */ + ** The last character of the format string + ** was %. We ignore it. + */ continue; /* - * The default case is for unrecognized %'s. - * We print % to help the user identify what - * option is not understood. - * This is also useful in case the user wants to pass - * the output of format_converter to another function - * that understands some other % (like syslog). - * Note that we can't point s inside fmt because the - * unknown could be preceded by width etc. - */ + ** The default case is for unrecognized %'s. + ** We print % to help the user identify + ** what option is not understood. This is + ** also useful in case the user wants to + ** pass the output of format_converter + ** to another function that understands + ** some other % (like syslog). + ** Note that we can't point s inside fmt + ** because the unknown could be + ** preceded by width etc. + */ default: char_buf[0] = '%'; char_buf[1] = *fmt; @@ -976,8 +989,8 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), } /* - * Print the string s. - */ + ** Print the string s. + */ for (i = s_len; i != 0; i--) { INS_CHAR(*s, sp, bep, cc); s++; @@ -996,9 +1009,10 @@ ap_vformatter(int (*flush_func)(ap_vformatter_buff *), static int snprintf_flush(ap_vformatter_buff *vbuff) { - /* if the buffer fills we have to abort immediately, there is no way - * to "flush" a snprintf... there's nowhere to flush it to. - */ + /* + ** if the buffer fills we have to abort immediately, there is no way + ** to "flush" a snprintf... there's nowhere to flush it to. + */ return -1; } diff --git a/sbr/ssequal.c b/sbr/ssequal.c index e7a12ad..95c6776 100644 --- a/sbr/ssequal.c +++ b/sbr/ssequal.c @@ -1,25 +1,25 @@ /* - * ssequal.c -- check if a string is a substring of another - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** ssequal.c -- check if a string is a substring of another +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include /* - * THIS CODE DOES NOT WORK AS ADVERTISED. - * It is actually checking if s1 is a PREFIX of s2. - * All calls to this function need to be checked to see - * if that needs to be changed. Prefix checking is cheaper, so - * should be kept if it's sufficient. - */ +** THIS CODE DOES NOT WORK AS ADVERTISED. +** It is actually checking if s1 is a PREFIX of s2. +** All calls to this function need to be checked to see +** if that needs to be changed. Prefix checking is cheaper, so +** should be kept if it's sufficient. +*/ /* - * Check if s1 is a substring of s2. - * If yes, then return 1, else return 0. - */ +** Check if s1 is a substring of s2. +** If yes, then return 1, else return 0. +*/ int ssequal (char *s1, char *s2) diff --git a/sbr/strcasecmp.c b/sbr/strcasecmp.c index 79fc5a8..354fd0f 100644 --- a/sbr/strcasecmp.c +++ b/sbr/strcasecmp.c @@ -1,18 +1,18 @@ /* - * strcasecmp.c -- compare strings, ignoring case - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** strcasecmp.c -- compare strings, ignoring case +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include /* - * Our version of strcasecmp has to deal with NULL strings. - * Once that is fixed in the rest of the code, we can use the - * native version, instead of this one. - */ +** Our version of strcasecmp has to deal with NULL strings. +** Once that is fixed in the rest of the code, we can use the +** native version, instead of this one. +*/ int mh_strcasecmp (const char *s1, const char *s2) diff --git a/sbr/strdup.c b/sbr/strdup.c index 3e206c7..7696e5f 100644 --- a/sbr/strdup.c +++ b/sbr/strdup.c @@ -1,10 +1,10 @@ /* - * strdup.c -- duplicate a string - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** strdup.c -- duplicate a string +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include diff --git a/sbr/strindex.c b/sbr/strindex.c index 92245b2..fdde7fd 100644 --- a/sbr/strindex.c +++ b/sbr/strindex.c @@ -1,10 +1,10 @@ /* - * strindex.c -- "unsigned" lexical index - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** strindex.c -- "unsigned" lexical index +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/trimcpy.c b/sbr/trimcpy.c index f24563c..1f590c3 100644 --- a/sbr/trimcpy.c +++ b/sbr/trimcpy.c @@ -1,12 +1,12 @@ /* - * trimcpy.c -- strip leading and trailing whitespace, - * -- replace internal whitespace with spaces, - * -- then return a copy. - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** trimcpy.c -- strip leading and trailing whitespace, +** -- replace internal whitespace with spaces, +** -- then return a copy. +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/uprf.c b/sbr/uprf.c index 7964a82..ea0964e 100644 --- a/sbr/uprf.c +++ b/sbr/uprf.c @@ -1,10 +1,10 @@ /* - * uprf.c -- "unsigned" lexical prefix - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** uprf.c -- "unsigned" lexical prefix +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/sbr/utils.c b/sbr/utils.c index 3bde778..f450c58 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -1,10 +1,10 @@ /* - * utils.c -- various utility routines - * - * This code is Copyright (c) 2006, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** utils.c -- various utility routines +** +** This code is Copyright (c) 2006, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -13,14 +13,14 @@ #include /* - * We allocate space for messages (msgs array) - * this number of elements at a time. - */ +** We allocate space for messages (msgs array) +** this number of elements at a time. +*/ #define MAXMSGS 256 /* - * Safely call malloc - */ +** Safely call malloc +*/ void * mh_xmalloc(size_t size) { @@ -37,8 +37,8 @@ mh_xmalloc(size_t size) } /* - * Safely call realloc - */ +** Safely call realloc +*/ void * mh_xrealloc(void *ptr, size_t size) { @@ -59,9 +59,9 @@ mh_xrealloc(void *ptr, size_t size) } /* - * Return the present working directory, if the current directory does not - * exist, or is too long, make / the pwd. - */ +** Return the present working directory, if the current directory does not +** exist, or is too long, make / the pwd. +*/ char * pwd(void) { @@ -85,13 +85,13 @@ pwd(void) } /* - * add -- If "s1" is NULL, this routine just creates a - * -- copy of "s2" into newly malloc'ed memory. - * -- - * -- If "s1" is not NULL, then copy the concatenation - * -- of "s1" and "s2" (note the order) into newly - * -- malloc'ed memory. Then free "s1". - */ +** add -- If "s1" is NULL, this routine just creates a +** -- copy of "s2" into newly malloc'ed memory. +** -- +** -- If "s1" is not NULL, then copy the concatenation +** -- of "s1" and "s2" (note the order) into newly +** -- malloc'ed memory. Then free "s1". +*/ char * add (char *s2, char *s1) { @@ -122,9 +122,9 @@ add (char *s2, char *s1) } /* - * folder_exists - * Check to see if a folder exists. - */ +** folder_exists +** Check to see if a folder exists. +*/ int folder_exists(char *folder) { @@ -132,9 +132,10 @@ folder_exists(char *folder) int exists = 0; if (stat (folder, &st) == -1) { - /* The folder either doesn't exist, or we hit an error. - * Either way return a failure. - */ + /* + ** The folder either doesn't exist, or we hit an error. + ** Either way return a failure. + */ exists = 0; } else { /* We can see a folder with the right name */ @@ -146,9 +147,9 @@ folder_exists(char *folder) /* - * create_folder - * Check to see if a folder exists, if not, prompt the user to create it. - */ +** create_folder +** Check to see if a folder exists, if not, prompt the user to create it. +*/ void create_folder(char *folder, int autocreate, void (*done_callback)(int)) { @@ -175,9 +176,9 @@ create_folder(char *folder, int autocreate, void (*done_callback)(int)) } /* - * num_digits - * Return the number of digits in a nonnegative integer. - */ +** num_digits +** Return the number of digits in a nonnegative integer. +*/ int num_digits (int n) { @@ -199,15 +200,16 @@ num_digits (int n) } /* - * Append a message arg to an array of them, resizing it if necessary. - * The function is written to suit the arg parsing code it was extracted - * from, and will probably be changed when the other code is cleaned up. - */ +** Append a message arg to an array of them, resizing it if necessary. +** The function is written to suit the arg parsing code it was extracted +** from, and will probably be changed when the other code is cleaned up. +*/ void app_msgarg(struct msgs_array *msgs, char *cp) { if(msgs->size >= msgs->max) - msgs->msgs = mh_xrealloc(msgs->msgs, (msgs->max+=MAXMSGS)*sizeof(*msgs->msgs)); + msgs->msgs = mh_xrealloc(msgs->msgs, + (msgs->max+=MAXMSGS)*sizeof(*msgs->msgs)); msgs->msgs[msgs->size++] = cp; } diff --git a/sbr/vfgets.c b/sbr/vfgets.c index 1a99b76..e9ed23e 100644 --- a/sbr/vfgets.c +++ b/sbr/vfgets.c @@ -1,10 +1,10 @@ /* - * vfgets.c -- virtual fgets - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** vfgets.c -- virtual fgets +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include diff --git a/uip/ali.c b/uip/ali.c index 00af8ce..21b95e1 100644 --- a/uip/ali.c +++ b/uip/ali.c @@ -1,10 +1,10 @@ /* - * ali.c -- list nmh mail aliases - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** ali.c -- list nmh mail aliases +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -13,8 +13,8 @@ #include /* - * maximum number of names - */ +** maximum number of names +*/ #define NVEC 50 static struct swit switches[] = { @@ -46,8 +46,8 @@ static int pos = 1; extern struct aka *akahead; /* - * prototypes - */ +** prototypes +*/ static void print_aka (char *, int, int); static void print_usr (char *, int, int); @@ -141,8 +141,8 @@ main (int argc, char **argv) } /* - * If -user is specified - */ + ** If -user is specified + */ if (inverted) { if (vecp == 0) adios (NULL, "usage: %s -user addresses ... (you forgot the addresses)", diff --git a/uip/aliasbr.c b/uip/aliasbr.c index 752cda7..094b1a5 100644 --- a/uip/aliasbr.c +++ b/uip/aliasbr.c @@ -1,10 +1,10 @@ /* - * aliasbr.c -- new aliasing mechanism - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** aliasbr.c -- new aliasing mechanism +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -22,8 +22,8 @@ struct home *homehead = NULL; struct home *hometail = NULL; /* - * prototypes - */ +** prototypes +*/ int alias (char *); int akvisible (void); void init_pw (void); @@ -364,8 +364,7 @@ addgroup (struct aka *ak, char *grp) break; } #ifdef DBMPWD - if ((pw = getpwnam(gp))) - { + if ((pw = getpwnam(gp))) { hmalloc(pw); add_aka (ak, gp); } @@ -488,22 +487,21 @@ init_pw (void) #ifdef DBMPWD static int init; - if (!init) - { - /* if the list has yet to be initialized */ - /* zap the list, and rebuild from scratch */ - homehead=NULL; - hometail=NULL; - init++; + if (!init) { + /* if the list has yet to be initialized */ + /* zap the list, and rebuild from scratch */ + homehead=NULL; + hometail=NULL; + init++; #endif /* DBMPWD */ - setpwent (); + setpwent (); - while ((pw = getpwent ())) - if (!hmalloc (pw)) - break; + while ((pw = getpwent ())) + if (!hmalloc (pw)) + break; - endpwent (); + endpwent (); #ifdef DBMPWD } #endif /* DBMPWD */ @@ -576,10 +574,11 @@ seek_home (char *name) #ifdef DBMPWD /* - * The only place where there might be problems. - * This assumes that ALL usernames are kept in lowercase. - */ - for (c = name, c1 = lname; *c && (c1 - lname < sizeof(lname) - 1); c++, c1++) { + ** The only place where there might be problems. + ** This assumes that ALL usernames are kept in lowercase. + */ + for (c = name, c1 = lname; *c && (c1 - lname < sizeof(lname) - 1); + c++, c1++) { if (isalpha(*c) && isupper(*c)) *c1 = tolower (*c); else diff --git a/uip/anno.c b/uip/anno.c index 7fd22c1..8967961 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -1,43 +1,43 @@ /* - * anno.c -- annotate messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - * - * Three new options have been added: delete, list, and number. - * Message header fields are used by the new MIME attachment code in - * the send command. Adding features to generalize the anno command - * seemed to be a better approach than the creation of a new command - * whose features would overlap with those of the anno command. - * - * The -delete option deletes header elements that match the -component - * field name. If -delete is used without the -text option, the first - * header field whose field name matches the component name is deleted. - * If the -delete is used with the -text option, and the -text argument - * begins with a /, the first header field whose field name matches the - * component name and whose field body matches the text is deleted. If - * the -text argument does not begin with a /, then the text is assumed - * to be the last component of a path name, and the first header field - * whose field name matches the component name and a field body whose - * last path name component matches the text is deleted. If the -delete - * option is used with the new -number option described below, the nth - * header field whose field name matches the component name is deleted. - * No header fields are deleted if none of the above conditions are met. - * - * The -list option outputs the field bodies from each header field whose - * field name matches the component name, one per line. If no -text - * option is specified, only the last path name component of each field - * body is output. The entire field body is output if the -text option - * is used; the contents of the -text argument are ignored. If the -list - * option is used in conjuction with the new -number option described - * below, each line is numbered starting with 1. A tab separates the - * number from the field body. - * - * The -number option works with both the -delete and -list options as - * described above. The -number option takes an optional argument. A - * value of 1 is assumed if this argument is absent. - */ +** anno.c -- annotate messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +** +** Three new options have been added: delete, list, and number. +** Message header fields are used by the new MIME attachment code in +** the send command. Adding features to generalize the anno command +** seemed to be a better approach than the creation of a new command +** whose features would overlap with those of the anno command. +** +** The -delete option deletes header elements that match the -component +** field name. If -delete is used without the -text option, the first +** header field whose field name matches the component name is deleted. +** If the -delete is used with the -text option, and the -text argument +** begins with a /, the first header field whose field name matches the +** component name and whose field body matches the text is deleted. If +** the -text argument does not begin with a /, then the text is assumed +** to be the last component of a path name, and the first header field +** whose field name matches the component name and a field body whose +** last path name component matches the text is deleted. If the -delete +** option is used with the new -number option described below, the nth +** header field whose field name matches the component name is deleted. +** No header fields are deleted if none of the above conditions are met. +** +** The -list option outputs the field bodies from each header field whose +** field name matches the component name, one per line. If no -text +** option is specified, only the last path name component of each field +** body is output. The entire field body is output if the -text option +** is used; the contents of the -text argument are ignored. If the -list +** option is used in conjuction with the new -number option described +** below, each line is numbered starting with 1. A tab separates the +** number from the field body. +** +** The -number option works with both the -delete and -list options as +** described above. The -number option takes an optional argument. A +** value of 1 is assumed if this argument is absent. +*/ #include #include @@ -75,8 +75,8 @@ static struct swit switches[] = { }; /* - * static prototypes - */ +** static prototypes +*/ static void make_comp (unsigned char **); @@ -200,7 +200,7 @@ main (int argc, char **argv) else folder = pluspath (cp); } else - app_msgarg(&msgs, cp); + app_msgarg(&msgs, cp); } #ifdef UCI diff --git a/uip/annosbr.c b/uip/annosbr.c index 427daba..db74870 100644 --- a/uip/annosbr.c +++ b/uip/annosbr.c @@ -1,10 +1,10 @@ /* - * annosbr.c -- prepend annotation to messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** annosbr.c -- prepend annotation to messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -15,15 +15,15 @@ /* - * static prototypes - */ +** static prototypes +*/ static int annosbr (int, char *, char *, char *, int, int, int, int); /* - * This "local" global and the annopreserve() function are a hack that - * allows additional functionality to be added to anno without piling - * on yet another annotate() argument. - */ +** This "local" global and the annopreserve() function are a hack that +** allows additional functionality to be added to anno without piling +** on yet another annotate() argument. +*/ /* set to preserve access and modification times on annotated message */ static int preserve_actime_and_modtime = 0; @@ -67,11 +67,11 @@ annotate (char *file, char *comp, char *text, int inplace, int datesw, } /* - * Produce a listing of all header fields (annotations) whose field - * name matches comp. Number the listing if number is set. Treate the - * field bodies as path names and just output the last component unless - * text is non-NULL. We don't care what text is set to. - */ +** Produce a listing of all header fields (annotations) whose field +** name matches comp. Number the listing if number is set. Treate the +** field bodies as path names and just output the last component unless +** text is non-NULL. We don't care what text is set to. +*/ void annolist(char *file, char *comp, char *text, int number) @@ -90,26 +90,26 @@ annolist(char *file, char *comp, char *text, int number) adios(file, "unable to open"); /* - * Allocate a buffer to hold the header components as they're read in. - * This buffer might need to be quite large, so we grow it as needed. - */ + ** Allocate a buffer to hold the header components as they're read in. + ** This buffer might need to be quite large, so we grow it as needed. + */ field = (char *)mh_xmalloc(field_size = 256); /* - * Get the length of the field name since we use it often. - */ + ** Get the length of the field name since we use it often. + */ length = strlen(comp); count = 0; do { /* - * Get a line from the input file, growing the field buffer - * as needed. We do this so that we can fit an entire line - * in the buffer making it easy to do a string comparison - * on both the field name and the field body which might be - * a long path name. - */ + ** Get a line from the input file, growing the field buffer + ** as needed. We do this so that we can fit an entire line + ** in the buffer making it easy to do a string comparison + ** on both the field name and the field body which might be + ** a long path name. + */ for (n = 0, cp = field; (c = getc(fp)) != EOF; *cp++ = c) { if (c == '\n' && (c = getc(fp)) != ' ' && c != '\t') { @@ -125,10 +125,7 @@ annolist(char *file, char *comp, char *text, int number) } } - /* - * NUL-terminate the field.. - */ - + /* NUL-terminate the field */ *cp = '\0'; if (strncasecmp(field, comp, length) == 0 && field[length] == ':') { @@ -146,22 +143,17 @@ annolist(char *file, char *comp, char *text, int number) } while (*field != '\0' && *field != '-'); - /* - * Clean up. - */ - + /* Clean up. */ free(field); - (void)fclose(fp); return; } /* - * Set the preserve-times flag. This hack eliminates the need for an - * additional argument to annotate(). - */ - +** Set the preserve-times flag. This hack eliminates the need for an +** additional argument to annotate(). +*/ void annopreserve(int preserve) { @@ -192,13 +184,13 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, chmod (tmpfil, mode); /* - * We're going to need to copy some of the message file to the - * temporary file while examining the contents. Convert the - * message file descriptor to a file pointer since it's a lot - * easier and more efficient to use stdio for this. Also allocate - * a buffer to hold the header components as they're read in. - * This buffer is grown as needed later. - */ + ** We're going to need to copy some of the message file to the + ** temporary file while examining the contents. Convert the + ** message file descriptor to a file pointer since it's a lot + ** easier and more efficient to use stdio for this. Also allocate + ** a buffer to hold the header components as they're read in. + ** This buffer is grown as needed later. + */ if (delete >= -1 || append != 0) { if ((fp = fdopen(fd, "r")) == (FILE *)0) @@ -208,54 +200,50 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, } /* - * We're trying to delete a header field (annotation )if the - * delete flag is not -2 or less. A value greater than zero - * means that we're deleting the nth header field that matches - * the field (component) name. A value of zero means that - * we're deleting the first field in which both the field name - * matches the component name and the field body matches the text. - * The text is matched in its entirety if it begins with a slash; - * otherwise the text is matched against whatever portion of the - * field body follows the last slash. This allows matching of - * both absolute and relative path names. This is because this - * functionality was added to support attachments. It might be - * worth having a separate flag to indicate path name matching - * to make it more general. A value of -1 means to delete all - * matching fields. - */ + ** We're trying to delete a header field (annotation )if the + ** delete flag is not -2 or less. A value greater than zero + ** means that we're deleting the nth header field that matches + ** the field (component) name. A value of zero means that + ** we're deleting the first field in which both the field name + ** matches the component name and the field body matches the text. + ** The text is matched in its entirety if it begins with a slash; + ** otherwise the text is matched against whatever portion of the + ** field body follows the last slash. This allows matching of + ** both absolute and relative path names. This is because this + ** functionality was added to support attachments. It might be + ** worth having a separate flag to indicate path name matching + ** to make it more general. A value of -1 means to delete all + ** matching fields. + */ if (delete >= -1) { - /* - * Get the length of the field name since we use it often. - */ - + /* Get the length of the field name since we use it often. */ length = strlen(comp); /* - * Initialize the field counter. This is only used if - * we're deleting by number. - */ - + ** Initialize the field counter. This is only used if + ** we're deleting by number. + */ count = 0; /* - * Copy lines from the input file to the temporary file - * until we either find the one that we're looking - * for (which we don't copy) or we reach the end of - * the headers. Both a blank line and a line beginning - * with a - terminate the headers so that we can handle - * both drafts and RFC-2822 format messages. - */ + ** Copy lines from the input file to the temporary file + ** until we either find the one that we're looking + ** for (which we don't copy) or we reach the end of + ** the headers. Both a blank line and a line beginning + ** with a - terminate the headers so that we can handle + ** both drafts and RFC-2822 format messages. + */ do { /* - * Get a line from the input file, growing the - * field buffer as needed. We do this so that - * we can fit an entire line in the buffer making - * it easy to do a string comparison on both the - * field name and the field body which might be - * a long path name. - */ + ** Get a line from the input file, growing the + ** field buffer as needed. We do this so that + ** we can fit an entire line in the buffer making + ** it easy to do a string comparison on both the + ** field name and the field body which might be + ** a long path name. + */ for (n = 0, cp = field; (c = getc(fp)) != EOF; *cp++ = c) { if (c == '\n' && (c = getc(fp)) != ' ' && c != '\t') { @@ -271,44 +259,41 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, } } - /* - * NUL-terminate the field.. - */ - + /* NUL-terminate the field */ *cp = '\0'; /* - * Check for a match on the field name. We delete - * the line by not copying it to the temporary - * file if - * - * o The delete flag is 0, meaning that we're - * going to delete the first matching - * field, and the text is NULL meaning that - * we don't care about the field body. - * - * o The delete flag is 0, meaning that we're - * going to delete the first matching - * field, and the text begins with a / meaning - * that we're looking for a full path name, - * and the text matches the field body. - * - * o The delete flag is 0, meaning that we're - * going to delete the first matching - * field, the text does not begin with a / - * meaning that we're looking for the last - * path name component, and the last path - * name component matches the text. - * - * o The delete flag is positive meaning that - * we're going to delete the nth field - * with a matching field name, and this is - * the nth matching field name. - * - * o The delete flag is -1 meaning that we're - * going to delete all fields with a - * matching field name. - */ + ** Check for a match on the field name. We delete + ** the line by not copying it to the temporary + ** file if + ** + ** o The delete flag is 0, meaning that we're + ** going to delete the first matching + ** field, and the text is NULL meaning that + ** we don't care about the field body. + ** + ** o The delete flag is 0, meaning that we're + ** going to delete the first matching + ** field, and the text begins with a / meaning + ** that we're looking for a full path name, + ** and the text matches the field body. + ** + ** o The delete flag is 0, meaning that we're + ** going to delete the first matching + ** field, the text does not begin with a / + ** meaning that we're looking for the last + ** path name component, and the last path + ** name component matches the text. + ** + ** o The delete flag is positive meaning that + ** we're going to delete the nth field + ** with a matching field name, and this is + ** the nth matching field name. + ** + ** o The delete flag is -1 meaning that we're + ** going to delete all fields with a + ** matching field name. + */ if (strncasecmp(field, comp, length) == 0 && field[length] == ':') { if (delete == 0) { @@ -339,9 +324,9 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, } /* - * This line wasn't a match so copy it to the - * temporary file. - */ + ** This line wasn't a match so copy it to the + ** temporary file. + */ if ((n = fputs(field, tmp)) == EOF || (c == '\n' && fputc('\n', tmp) == EOF)) adios(NULL, "unable to write temporary file."); @@ -349,25 +334,24 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, } while (*field != '\0' && *field != '-'); /* - * Get rid of the field buffer because we're done with it. - */ + ** Get rid of the field buffer because we're done with it. + */ free((void *)field); - } - else { + } else { /* - * Find the end of the headers before adding the - * annotations if we're appending instead of the default - * prepending. A special check for no headers is needed - * if appending. - */ + ** Find the end of the headers before adding the + ** annotations if we're appending instead of the default + ** prepending. A special check for no headers is needed + ** if appending. + */ if (append) { /* - * Copy lines from the input file to the temporary - * file until we reach the end of the headers. - */ + ** Copy lines from the input file to the temporary + ** file until we reach the end of the headers. + */ if ((c = getc(fp)) == '\n') rewind(fp); @@ -408,11 +392,11 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, fflush (tmp); /* - * We've been messing with the input file position. Move the - * input file descriptor to the current place in the file - * because the stock data copying routine uses the descriptor, - * not the pointer. - */ + ** We've been messing with the input file position. Move the + ** input file descriptor to the current place in the file + ** because the stock data copying routine uses the descriptor, + ** not the pointer. + */ if (append || delete >= -1) { if (lseek(fd, (off_t)ftell(fp), SEEK_SET) == (off_t)-1) @@ -429,10 +413,10 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, lseek (fd, (off_t) 0, SEEK_SET); /* - * We're making the file shorter if we're deleting a - * header field so the file has to be truncated or it - * will contain garbage. - */ + ** We're making the file shorter if we're deleting a + ** header field so the file has to be truncated or it + ** will contain garbage. + */ if (delete >= -1 && ftruncate(fd, 0) == -1) adios(tmpfil, "unable to truncate."); @@ -461,10 +445,10 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, } /* - * Close the delete file so that we don't run out of file pointers if - * we're doing piles of files. Note that this will make the close() in - * lkclose() fail, but that failure is ignored so it's not a problem. - */ + ** Close the delete file so that we don't run out of file pointers if + ** we're doing piles of files. Note that this will make the close() in + ** lkclose() fail, but that failure is ignored so it's not a problem. + */ if (delete >= -1) (void)fclose(fp); diff --git a/uip/ap.c b/uip/ap.c index 1e2151b..a9f0775 100644 --- a/uip/ap.c +++ b/uip/ap.c @@ -1,10 +1,10 @@ /* - * ap.c -- parse addresses 822-style - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** ap.c -- parse addresses 822-style +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -41,13 +41,13 @@ static struct format *fmt; static int dat[5]; /* - * prototypes - */ +** prototypes +*/ int sc_width (void); /* from termsbr.c */ /* - * static prototypes - */ +** static prototypes +*/ static int process (char *, int, int); @@ -178,8 +178,7 @@ process (char *arg, int length, int norm) p->pq_text = getcpy (cp); p->pq_error = getcpy (error); status++; - } - else { + } else { p->pq_text = getcpy (mp->m_text); mnfree (mp); } diff --git a/uip/burst.c b/uip/burst.c index 8f0a238..9d33214 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -1,10 +1,10 @@ /* - * burst.c -- explode digests into individual messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** burst.c -- explode digests into individual messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include @@ -36,8 +36,8 @@ struct smsg { }; /* - * static prototypes - */ +** static prototypes +*/ static int find_delim (int, struct smsg *); static void burst (struct msgs **, int, struct smsg *, int, int, int, char *); static void cpybrst (FILE *, FILE *, char *, char *, int); @@ -170,11 +170,11 @@ main (int argc, char **argv) context_replace (pfolder, folder); /* update current folder */ /* - * If -inplace is given, then the first message burst becomes - * the current message (which will now show a table of contents). - * Otherwise, the first message extracted from the first digest - * becomes the current message. - */ + ** If -inplace is given, then the first message burst becomes + ** the current message (which will now show a table of contents). + ** Otherwise, the first message extracted from the first digest + ** becomes the current message. + */ if (inplace) { if (mp->lowsel != mp->curmsg) seq_setcur (mp, mp->lowsel); @@ -192,9 +192,9 @@ main (int argc, char **argv) /* - * Scan the message and find the beginning and - * end of all the messages in the digest. - */ +** Scan the message and find the beginning and +** end of all the messages in the digest. +*/ static int find_delim (int msgnum, struct smsg *smsgs) @@ -249,8 +249,8 @@ find_delim (int msgnum, struct smsg *smsgs) /* - * Burst out the messages in the digest into the folder - */ +** Burst out the messages in the digest into the folder +*/ static void burst (struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, @@ -270,9 +270,9 @@ burst (struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, mp = *mpp; /* - * See if we have enough space in the folder - * structure for all the new messages. - */ + ** See if we have enough space in the folder + ** structure for all the new messages. + */ if ((mp->hghmsg + numburst > mp->hghoff) && !(mp = folder_realloc (mp, mp->lowoff, mp->hghmsg + numburst))) adios (NULL, "unable to allocate folder storage"); @@ -283,21 +283,21 @@ burst (struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, mp->nummsg += numburst; /* - * If this is not the highest SELECTED message, then - * increment mp->hghsel by numburst, since the highest - * SELECTED is about to be slid down by that amount. - */ + ** If this is not the highest SELECTED message, then + ** increment mp->hghsel by numburst, since the highest + ** SELECTED is about to be slid down by that amount. + */ if (msgnum < mp->hghsel) mp->hghsel += numburst; /* - * If -inplace is given, renumber the messages after the - * source message, to make room for each of the messages - * contained within the digest. - * - * This is equivalent to refiling a message from the point - * of view of the external hooks. - */ + ** If -inplace is given, renumber the messages after the + ** source message, to make room for each of the messages + ** contained within the digest. + ** + ** This is equivalent to refiling a message from the point + ** of view of the external hooks. + */ if (inplace) { for (i = mp->hghmsg; j > msgnum; i--, j--) { strncpy (f1, m_name (i), sizeof(f1)); @@ -323,26 +323,26 @@ burst (struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, unset_selected (mp, msgnum); /* new hghmsg is hghmsg + numburst - * - * At this point, there is an array of numburst smsgs, each - * element of which contains the starting and stopping offsets - * (seeks) of the message in the digest. The inplace flag is set - * if the original digest is replaced by a message containing - * the table of contents. smsgs[0] is that table of contents. - * Go through the message numbers in reverse order (high to low). - * - * Set f1 to the name of the destination message, f2 to the name - * of a scratch file. Extract a message from the digest to the - * scratch file. Move the original message to a backup file if - * the destination message number is the same as the number of - * the original message, which only happens if the inplace flag - * is set. Then move the scratch file to the destination message. - * - * Moving the original message to the backup file is equivalent - * to deleting the message from the point of view of the external - * hooks. And bursting each message is equivalent to adding a - * new message. - */ + ** + ** At this point, there is an array of numburst smsgs, each + ** element of which contains the starting and stopping offsets + ** (seeks) of the message in the digest. The inplace flag is set + ** if the original digest is replaced by a message containing + ** the table of contents. smsgs[0] is that table of contents. + ** Go through the message numbers in reverse order (high to low). + ** + ** Set f1 to the name of the destination message, f2 to the name + ** of a scratch file. Extract a message from the digest to the + ** scratch file. Move the original message to a backup file if + ** the destination message number is the same as the number of + ** the original message, which only happens if the inplace flag + ** is set. Then move the scratch file to the destination message. + ** + ** Moving the original message to the backup file is equivalent + ** to deleting the message from the point of view of the external + ** hooks. And bursting each message is equivalent to adding a + ** new message. + */ i = inplace ? msgnum + numburst : mp->hghmsg; for (j = numburst; j >= (inplace ? 0 : 1); i--, j--) { @@ -385,9 +385,9 @@ burst (struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, #define S3 2 /* - * Copy a mesage which is being burst out of a digest. - * It will remove any "dashstuffing" in the message. - */ +** Copy a mesage which is being burst out of a digest. +** It will remove any "dashstuffing" in the message. +*/ static void cpybrst (FILE *in, FILE *out, char *ifile, char *ofile, int len) diff --git a/uip/comp.c b/uip/comp.c index 554d310..b39b6e7 100644 --- a/uip/comp.c +++ b/uip/comp.c @@ -1,10 +1,10 @@ /* - * comp.c -- compose a message - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** comp.c -- compose a message +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -144,8 +144,8 @@ main (int argc, char **argv) if (!use && (folder || msg)) { /* - * Take a message as the "form" for the new message. - */ + ** Take a message as the "form" for the new message. + */ if (!msg) msg = "cur"; if (!folder) @@ -181,17 +181,17 @@ try_it_again: strncpy (drft, m_draft(use ? (msg?msg:"cur") : "new"), sizeof(drft)); /* - * Check if we have an existing draft - */ + ** Check if we have an existing draft + */ if ((out = open (drft, O_RDONLY)) != NOTOK) { i = fdcompare (in, out); close (out); /* - * If we have given -use flag, or if the - * draft is just the same as the components - * file, then no need to ask any questions. - */ + ** If we have given -use flag, or if the + ** draft is just the same as the components + ** file, then no need to ask any questions. + */ if (use || i) goto edit_it; @@ -224,9 +224,8 @@ try_it_again: break; } } - } else { - if (use) - adios (drft, "unable to open"); + } else if (use) { + adios (drft, "unable to open"); } if ((out = creat (drft, m_gmprot ())) == NOTOK) diff --git a/uip/conflict.c b/uip/conflict.c index b49c1cc..fdd6de2 100644 --- a/uip/conflict.c +++ b/uip/conflict.c @@ -1,10 +1,10 @@ /* - * conflict.c -- check for conflicts in mail system - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** conflict.c -- check for conflicts in mail system +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -15,14 +15,14 @@ #include /* - * maximum number of directories that can - * be specified using -search switch. - */ +** maximum number of directories that can +** be specified using -search switch. +*/ #define NDIRS 100 /* - * Add space for group names, 100 at a time - */ +** Add space for group names, 100 at a time +*/ #define NGRPS 100 static struct swit switches[] = { @@ -45,8 +45,8 @@ extern struct aka *akahead; extern struct home *homehead; /* - * prototypes - */ +** prototypes +*/ void alias_files (int, char **); void pwd_names (void); void grp_names (void); @@ -150,10 +150,8 @@ alias_files (int akp, char **akv) if ((err = alias (akv[i])) != AK_OK) { setup (); fprintf (out, "aliasing error in %s - %s\n", akv[i], akerror (err)); - } - else - if (out && !mail) - fprintf (out, "alias file %s is ok\n", akv[i]); + } else if (out && !mail) + fprintf (out, "alias file %s is ok\n", akv[i]); } @@ -316,8 +314,7 @@ mdrop(char *drop) while ((dp = readdir (dd))) if (dp->d_name[0] != '.' && !check (dp->d_name)) { setup (); - fprintf (out, - "there is a maildrop for the unknown user %s in %s\n", + fprintf (out, "there is a maildrop for the unknown user %s in %s\n", dp->d_name, drop); hit++; } @@ -381,8 +378,8 @@ setup (void) #ifdef UCI /* - * UCI specific stuff for conflict - */ +** UCI specific stuff for conflict +*/ /* taken from */ @@ -427,8 +424,7 @@ endglent() { } struct grpldr *getglent () { - register char *cp, - **q; + register char *cp, **q; if (glp == NULL && !setglent ()) return NULL; @@ -495,8 +491,7 @@ ldr_names () { if (gp < NGRPS) { gldrs[gp++] = getcpy (gl->gl_name); gldrs[gp] = NULL; - } - else { + } else { setup (); fprintf (out, "more than %d groups in group leaders file%s\n", " (time to recompile)", NGRPS - 1); diff --git a/uip/dist.c b/uip/dist.c index 0b8edb3..86c564f 100644 --- a/uip/dist.c +++ b/uip/dist.c @@ -1,10 +1,10 @@ /* - * dist.c -- re-distribute a message - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** dist.c -- re-distribute a message +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -157,13 +157,13 @@ main (int argc, char **argv) if (file) { /* - * Dist a file - */ + ** Dist a file + */ anot = 0; /* don't want to annotate a file */ } else { /* - * Dist a message - */ + ** Dist a message + */ if (!msg) msg = "cur"; if (!folder) diff --git a/uip/distsbr.c b/uip/distsbr.c index a40d3e4..7c46da1 100644 --- a/uip/distsbr.c +++ b/uip/distsbr.c @@ -1,10 +1,10 @@ /* - * distsbr.c -- routines to do additional "dist-style" processing - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** distsbr.c -- routines to do additional "dist-style" processing +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -19,8 +19,8 @@ static int txtfd = NOTOK; #define BADRFT "please re-edit %s and fix that header!" /* - * static prototypes - */ +** static prototypes +*/ static void ready_msg(char *); int diff --git a/uip/dp.c b/uip/dp.c index 0db0ba5..67b2fee 100644 --- a/uip/dp.c +++ b/uip/dp.c @@ -1,10 +1,10 @@ /* - * dp.c -- parse dates 822-style - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** dp.c -- parse dates 822-style +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -36,13 +36,13 @@ static struct format *fmt; static int dat[5]; /* - * prototypes - */ +** prototypes +*/ int sc_width (void); /* from termsbr.c */ /* - * static prototypes - */ +** static prototypes +*/ static int process (char *, int); diff --git a/uip/dropsbr.c b/uip/dropsbr.c index 0e3ce19..40de763 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -1,10 +1,10 @@ /* - * dropsbr.c -- create/read/manipulate mail drops - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** dropsbr.c -- create/read/manipulate mail drops +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -28,17 +28,17 @@ #include /* - * static prototypes - */ +** static prototypes +*/ static int mbx_chk_mbox (int); static int mbx_chk_mmdf (int); static int map_open (char *, int); /* - * Main entry point to open/create and lock - * a file or maildrop. - */ +** Main entry point to open/create and lock +** a file or maildrop. +*/ int mbx_open (char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode) @@ -78,20 +78,20 @@ mbx_open (char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode) errno = j; /* - * Return if we still failed after 4 attempts, - * or we just want to skip the sanity checks. - */ + ** Return if we still failed after 4 attempts, + ** or we just want to skip the sanity checks. + */ if (fd == NOTOK || mbx_style == OTHER_FORMAT) return fd; /* - * Do sanity checks on maildrop. - */ + ** Do sanity checks on maildrop. + */ if (fstat (fd, &st) == NOTOK) { /* - * The stat failed. So we make sure file - * has right ownership/modes - */ + ** The stat failed. So we make sure file + ** has right ownership/modes + */ chown (file, uid, gid); chmod (file, mode); } else if (st.st_size > (off_t) 0) { @@ -121,8 +121,8 @@ mbx_open (char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode) /* - * Check/prepare MBOX style maildrop for appending. - */ +** Check/prepare MBOX style maildrop for appending. +*/ static int mbx_chk_mbox (int fd) @@ -136,8 +136,8 @@ mbx_chk_mbox (int fd) /* - * Check/prepare MMDF style maildrop for appending. - */ +** Check/prepare MMDF style maildrop for appending. +*/ static int mbx_chk_mmdf (int fd) @@ -275,8 +275,8 @@ mbx_write(char *mailbox, int md, FILE *fp, int id, long last, /* - * Append message to end of file or maildrop. - */ +** Append message to end of file or maildrop. +*/ int mbx_copy (char *mailbox, int mbx_style, int md, int fd, @@ -356,13 +356,13 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, for (j = 0; fgets (buffer, sizeof(buffer), fp) != NULL; j++) { /* - * Check the first line, and make some changes. - */ + ** Check the first line, and make some changes. + */ if (j == 0 && !text) { /* - * Change the "Return-Path:" field (if in first line) - * back to "From ". - */ + ** Change the "Return-Path:" field + ** (if in first line) back to "From ". + */ if (!strncmp (buffer, "Return-Path:", 12)) { char tmpbuffer[BUFSIZ]; char *tp, *ep, *fp; @@ -376,9 +376,10 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, (int)(fp - ep), ep, tp); } else if (!strncmp (buffer, "X-Envelope-From:", 16)) { /* - * Change the "X-Envelope-From:" field - * (if first line) back to "From ". - */ + ** Change the "X-Envelope-From:" + ** field (if first line) back + ** to "From ". + */ char tmpbuffer[BUFSIZ]; char *ep; @@ -387,9 +388,10 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, snprintf (buffer, sizeof(buffer), "From %s", ep); } else if (strncmp (buffer, "From ", 5)) { /* - * If there is already a "From " line, - * then leave it alone. Else we add one. - */ + ** If there is already a "From " + ** line, then leave it alone. + ** Else we add one. + */ char tmpbuffer[BUFSIZ]; char *tp, *ep; @@ -401,9 +403,9 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, } /* - * If this is not first line, and begins with - * "From ", then prepend line with ">". - */ + ** If this is not first line, and begins with + ** "From ", then prepend line with ">". + */ if (j != 0 && strncmp (buffer, "From ", 5) == 0) { write (md, ">", 1); size++; @@ -429,7 +431,8 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, lseek (fd, (off_t) 0, SEEK_END); stop = lseek (md, (off_t) 0, SEEK_CUR); if (mapping) - map_write (mailbox, md, 0, (long) 0, start, stop, pos, size, noisy); + map_write (mailbox, md, 0, (long) 0, start, + stop, pos, size, noisy); return OK; } @@ -460,8 +463,8 @@ mbx_size (int md, off_t start, off_t stop) /* - * Close and unlock file/maildrop. - */ +** Close and unlock file/maildrop. +*/ int mbx_close (char *mailbox, int md) @@ -473,9 +476,9 @@ mbx_close (char *mailbox, int md) /* - * This function is performed implicitly by getbbent.c: - * bb->bb_map = map_name (bb->bb_file); - */ +** This function is performed implicitly by getbbent.c: +** bb->bb_map = map_name (bb->bb_file); +*/ char * map_name (char *file) diff --git a/uip/flist.c b/uip/flist.c index 51eff1e..17916fb 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -1,18 +1,18 @@ /* - * flist.c -- list nmh folders containing messages - * -- in a given sequence - * - * originally by - * David Nichols, Xerox-PARC, November, 1992 - * - * Copyright (c) 1994 Xerox Corporation. - * Use and copying of this software and preparation of derivative works based - * upon this software are permitted. Any distribution of this software or - * derivative works must comply with all applicable United States export - * control laws. This software is made available AS IS, and Xerox Corporation - * makes no warranty about the software, its performance or its conformity to - * any specification. - */ +** flist.c -- list nmh folders containing messages +** -- in a given sequence +** +** originally by +** David Nichols, Xerox-PARC, November, 1992 +** +** Copyright (c) 1994 Xerox Corporation. +** Use and copying of this software and preparation of derivative works based +** upon this software are permitted. Any distribution of this software or +** derivative works must comply with all applicable United States export +** control laws. This software is made available AS IS, and Xerox Corporation +** makes no warranty about the software, its performance or its conformity to +** any specification. +*/ #include #include @@ -21,9 +21,9 @@ #define TRUE 1 /* - * We allocate space to record the names of folders - * (foldersToDo array), this number of elements at a time. - */ +** We allocate space to record the names of folders +** (foldersToDo array), this number of elements at a time. +*/ #define MAXFOLDERS 100 @@ -97,14 +97,14 @@ static char curfolder[BUFSIZ]; /* name of the current folder */ static char *nmhdir; /* base nmh mail directory */ /* - * Type for a compare function for qsort. This keeps - * the compiler happy. - */ +** Type for a compare function for qsort. This keeps +** the compiler happy. +*/ typedef int (*qsort_comp) (const void *, const void *); /* - * prototypes - */ +** prototypes +*/ int CompareFolders(struct Folder *, struct Folder *); void GetFolderOrder(void); void ScanFolders(void); @@ -134,9 +134,9 @@ main(int argc, char **argv) context_read(); /* - * If program was invoked with name ending - * in `s', then add switch `-all'. - */ + ** If program was invoked with name ending + ** in `s', then add switch `-all'. + */ if (argv[0][strlen (argv[0]) - 1] == 's') all = TRUE; @@ -220,9 +220,9 @@ main(int argc, char **argv) } } else { /* - * Check if we need to allocate more space - * for folder names. - */ + ** Check if we need to allocate more space + ** for folder names. + */ if (numfolders >= maxfolders) { maxfolders += MAXFOLDERS; foldersToDo = (char **) mh_xrealloc (foldersToDo, @@ -246,12 +246,12 @@ main(int argc, char **argv) nmhdir = m_maildir (""); /* - * If we didn't specify any sequences, we search - * for the "Unseen-Sequence" profile entry and use - * all the sequences defined there. We check to - * make sure that the Unseen-Sequence entry doesn't - * contain more than NUMATTRS sequences. - */ + ** If we didn't specify any sequences, we search + ** for the "Unseen-Sequence" profile entry and use + ** all the sequences defined there. We check to + ** make sure that the Unseen-Sequence entry doesn't + ** contain more than NUMATTRS sequences. + */ if (numsequences == 0) { if ((cp = context_find(usequence)) && *cp) { char **ap, *dp; @@ -279,9 +279,9 @@ main(int argc, char **argv) } /* - * Read the Flist-Order profile entry to determine - * how to sort folders for output. - */ +** Read the Flist-Order profile entry to determine +** how to sort folders for output. +*/ void GetFolderOrder(void) @@ -312,8 +312,8 @@ GetFolderOrder(void) } /* - * Scan all the necessary folders - */ +** Scan all the necessary folders +*/ void ScanFolders(void) @@ -333,36 +333,36 @@ ScanFolders(void) context_save (); /* save the context file */ /* - * Scan each given folder. If -all is given, - * then also scan the 1st level subfolders under - * each given folder. - */ + ** Scan each given folder. If -all is given, + ** then also scan the 1st level subfolders under + ** each given folder. + */ for (i = 0; i < numfolders; ++i) BuildFolderList(foldersToDo[i], all ? 1 : 0); } else { if (all) { /* - * Do the readonly folders - */ + ** Do the readonly folders + */ do_readonly_folders(); /* - * Now scan the entire nmh directory for folders - */ + ** Now scan the entire nmh directory for folders + */ BuildFolderList(".", 0); } else { /* - * Else scan current folder - */ + ** Else scan current folder + */ BuildFolderList(curfolder, 0); } } } /* - * Initial building of folder list for - * the top of our search tree. - */ +** Initial building of folder list for +** the top of our search tree. +*/ void BuildFolderList(char *dirName, int searchdepth) @@ -374,26 +374,26 @@ BuildFolderList(char *dirName, int searchdepth) return; /* - * If base directory, don't add it to the - * folder list. We just recurse into it. - */ + ** If base directory, don't add it to the + ** folder list. We just recurse into it. + */ if (!strcmp (dirName, ".")) { BuildFolderListRecurse (".", &st, 0); return; } /* - * Add this folder to the list. - * If recursing and directory has subfolders, - * then build folder list for subfolders. - */ + ** Add this folder to the list. + ** If recursing and directory has subfolders, + ** then build folder list for subfolders. + */ if (AddFolder(dirName, showzero) && (recurse || searchdepth) && st.st_nlink > 2) BuildFolderListRecurse(dirName, &st, searchdepth - 1); } /* - * Recursive building of folder list - */ +** Recursive building of folder list +*/ void BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth) @@ -406,21 +406,21 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth) struct stat st; /* - * Keep track of number of directories we've seen so we can - * stop stat'ing entries in this directory once we've seen - * them all. This optimization will fail if you have extra - * directories beginning with ".", since we don't bother to - * stat them. But that shouldn't generally be a problem. - */ + ** Keep track of number of directories we've seen so we can + ** stop stat'ing entries in this directory once we've seen + ** them all. This optimization will fail if you have extra + ** directories beginning with ".", since we don't bother to + ** stat them. But that shouldn't generally be a problem. + */ nlinks = s->st_nlink; if (!(dir = opendir(dirName))) adios(dirName, "can't open directory"); /* - * A hack so that we don't see a - * leading "./" in folder names. - */ + ** A hack so that we don't see a + ** leading "./" in folder names. + */ base = strcmp (dirName, ".") ? dirName : dirName + 1; while (nlinks && (dp = readdir(dir))) { @@ -431,8 +431,8 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth) if (dp->d_name[0] == '.') continue; /* Check to see if the name of the file is a number - * if it is, we assume it's a mail file and skip it - */ + ** if it is, we assume it's a mail file and skip it + */ for (n = dp->d_name; *n && isdigit(*n); n++); if (!*n) continue; @@ -442,14 +442,15 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth) strncat(name, dp->d_name, sizeof(name) - strlen(name) - 1); if ((stat(name, &st) != -1) && S_ISDIR(st.st_mode)) { /* - * Check if this was really a symbolic link pointing - * to a directory. If not, then decrement link count. - */ + ** Check if this was really a symbolic link pointing + ** to a directory. If not, then decrement link count. + */ if (lstat (name, &st) == -1) nlinks--; /* Add this folder to the list */ if (AddFolder(name, showzero) && - (recurse || searchdepth) && st.st_nlink > 2) + (recurse || searchdepth) && + st.st_nlink > 2) BuildFolderListRecurse(name, &st, searchdepth - 1); } } @@ -457,9 +458,9 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth) } /* - * Add this folder to our list, counting the total number of - * messages and the number of messages in each sequence. - */ +** Add this folder to our list, counting the total number of +** messages and the number of messages in each sequence. +*/ int AddFolder(char *name, int force) @@ -527,8 +528,8 @@ AddFolder(char *name, int force) } /* - * Print the folder/sequence information - */ +** Print the folder/sequence information +*/ void PrintFolders(void) @@ -545,8 +546,8 @@ PrintFolders(void) } /* - * Find the width we need for various fields - */ + ** Find the width we need for various fields + */ for (i = 0; i < nFolders; ++i) { /* find the length of longest folder name */ len = strlen(folders[i].name); @@ -604,8 +605,8 @@ PrintFolders(void) } /* - * Put them in priority order. - */ +** Put them in priority order. +*/ int CompareFolders(struct Folder *f1, struct Folder *f2) @@ -617,8 +618,8 @@ CompareFolders(struct Folder *f1, struct Folder *f2) } /* - * Make sure we have at least n folders allocated. - */ +** Make sure we have at least n folders allocated. +*/ void AllocFolders(struct Folder **f, int *nfa, int n) @@ -635,9 +636,9 @@ AllocFolders(struct Folder **f, int *nfa, int n) } /* - * Return the priority for a name. The highest comes from an exact match. - * After that, the longest match (then first) assigns the priority. - */ +** Return the priority for a name. The highest comes from an exact match. +** After that, the longest match (then first) assigns the priority. +*/ int AssignPriority(char *name) { @@ -668,8 +669,8 @@ AssignPriority(char *name) } /* - * Do the read only folders - */ +** Do the read only folders +*/ static void do_readonly_folders (void) diff --git a/uip/fmtdump.c b/uip/fmtdump.c index e6561ad..9b326a3 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -1,10 +1,10 @@ /* - * fmtdump.c -- compile format file and dump out instructions - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** fmtdump.c -- compile format file and dump out instructions +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -28,8 +28,8 @@ static struct format *lvec[128]; static int lused = 0; /* - * static prototypes - */ +** static prototypes +*/ static void fmt_dump (struct format *); static void dumpone(struct format *); static int findlabel(struct format *); @@ -97,8 +97,8 @@ main (int argc, char **argv) } /* - * Get new format string. Must be before chdir(). - */ + ** Get new format string. Must be before chdir(). + */ nfs = new_fs (form, format, FORMAT); ncomps = fmt_compile(nfs, &fmt); diff --git a/uip/folder.c b/uip/folder.c index 6f0f8b8..a5326c1 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -1,12 +1,12 @@ /* - * folder(s).c -- set/list the current message and/or folder - * -- push/pop a folder onto/from the folder stack - * -- list the folder stack - * - * This code is Copyright (c) 2002, 2008, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** folder(s).c -- set/list the current message and/or folder +** -- push/pop a folder onto/from the folder stack +** -- list the folder stack +** +** This code is Copyright (c) 2002, 2008, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -81,9 +81,9 @@ static char *stack = "Folder-Stack"; static char folder[BUFSIZ]; /* - * Structure to hold information about - * folders as we scan them. - */ +** Structure to hold information about +** folders as we scan them. +*/ struct FolderInfo { char *name; int nummsg; @@ -95,15 +95,15 @@ struct FolderInfo { }; /* - * Dynamically allocated space to hold - * all the folder information. - */ +** Dynamically allocated space to hold +** all the folder information. +*/ static struct FolderInfo *fi; static int maxFolderInfo; /* - * static prototypes - */ +** static prototypes +*/ static int get_folder_info (char *, char *); static crawl_callback_t get_folder_info_callback; static void print_folders (void); @@ -128,9 +128,9 @@ main (int argc, char **argv) context_read(); /* - * If program was invoked with name ending - * in `s', then add switch `-all'. - */ + ** If program was invoked with name ending + ** in `s', then add switch `-all'. + */ if (argv[0][strlen (argv[0]) - 1] == 's') all = 1; @@ -256,9 +256,9 @@ main (int argc, char **argv) nmhdir = concat (m_maildir (""), "/", NULL); /* - * If we aren't working with the folder stack - * (-push, -pop, -list) then the default is to print. - */ + ** If we aren't working with the folder stack + ** (-push, -pop, -list) then the default is to print. + */ if (pushsw == 0 && popsw == 0 && listsw == 0) printsw++; @@ -305,7 +305,8 @@ main (int argc, char **argv) cp = add (*ap, add (" ", cp)); context_replace (stack, cp); /* update folder stack */ } else { - context_del (stack); /* delete folder stack entry from context */ + /* delete folder stack entry from context */ + context_del (stack); } free (dp); } @@ -313,7 +314,8 @@ main (int argc, char **argv) cp = m_maildir(argfolder); if (access (cp, F_OK) == NOTOK) adios (cp, "unable to find folder"); - context_replace (pfolder, argfolder); /* update current folder */ + /* update current folder */ + context_replace (pfolder, argfolder); context_save (); /* save the context file */ argfolder = NULL; } @@ -338,13 +340,16 @@ main (int argc, char **argv) fi = mh_xmalloc (maxFolderInfo * sizeof(*fi)); /* - * Scan the folders - */ + ** Scan the folders + */ if (all || ftotal > 0) { /* - * If no folder is given, do them all - */ - /* change directory to base of nmh directory for crawl_folders */ + ** If no folder is given, do them all + */ + /* + ** change directory to base of nmh directory for + ** crawl_folders + */ if (chdir (nmhdir) == NOTOK) adios (nmhdir, "unable to change directory to"); if (!argfolder) { @@ -356,13 +361,14 @@ main (int argc, char **argv) } else { strncpy (folder, argfolder, sizeof(folder)); if (get_folder_info (argfolder, msg)) { - context_replace (pfolder, argfolder);/* update current folder */ - context_save (); /* save the context file */ + /* update current folder */ + context_replace (pfolder, argfolder); + context_save (); } /* - * Since recurse wasn't done in get_folder_info(), - * we still need to list all level-1 sub-folders. - */ + ** Since recurse wasn't done in get_folder_info(), + ** we still need to list all level-1 sub-folders. + */ if (!frecurse) crawl_folders (folder, get_folder_info_callback, NULL); } @@ -370,9 +376,9 @@ main (int argc, char **argv) strncpy (folder, argfolder ? argfolder : getfolder (1), sizeof(folder)); /* - * Check if folder exists. If not, then see if - * we should create it, or just exit. - */ + ** Check if folder exists. If not, then see if + ** we should create it, or just exit. + */ create_folder (m_maildir (folder), fcreat, done); if (get_folder_info (folder, msg) && argfolder) { @@ -382,11 +388,11 @@ main (int argc, char **argv) } /* - * Print out folder information - */ + ** Print out folder information + */ print_folders(); - context_save (); /* save the context file */ + context_save (); done (0); return 1; } @@ -400,9 +406,9 @@ get_folder_info_body (char *fold, char *msg, boolean *crawl_children) i = total_folders++; /* - * if necessary, reallocate the space - * for folder information - */ + ** if necessary, reallocate the space + ** for folder information + */ if (total_folders >= maxFolderInfo) { maxFolderInfo += CRAWL_NUMFOLDERS; fi = mh_xrealloc (fi, maxFolderInfo * sizeof(*fi)); @@ -418,8 +424,8 @@ get_folder_info_body (char *fold, char *msg, boolean *crawl_children) if ((ftotal > 0) || !fshort || msg || fpack) { /* - * create message structure and get folder info - */ + ** create message structure and get folder info + */ if (!(mp = folder_read (fold))) { admonish (NULL, "unable to read folder %s", fold); return 0; @@ -473,13 +479,12 @@ get_folder_info (char *fold, char *msg) if (crawl_children) { crawl_folders (fold, get_folder_info_callback, NULL); } - - return retval; +return retval; } /* - * Print folder information - */ +** Print folder information +*/ static void print_folders (void) @@ -492,9 +497,9 @@ print_folders (void) char tmpname[BUFSIZ]; /* - * compute a few values needed to for - * printing various fields - */ + ** compute a few values needed to for + ** printing various fields + */ for (i = 0; i < total_folders; i++) { /* length of folder name */ len = strlen (fi[i].name); @@ -539,8 +544,8 @@ print_folders (void) nummsgdigits = 2; /* - * Print the header - */ + ** Print the header + */ if (fheader > 0 || (all && !fshort && fheader >= 0)) printf ("%-*s %*s %-*s; %-*s %*s\n", maxlen+1, "FOLDER", @@ -550,8 +555,8 @@ print_folders (void) 9, "(OTHERS)"); /* - * Print folder information - */ + ** Print folder information + */ if (all || fshort || ftotal < 1) { for (i = 0; i < total_folders; i++) { if (fshort) { @@ -596,8 +601,8 @@ print_folders (void) } /* - * Print folder/message totals - */ + ** Print folder/message totals + */ if (ftotal > 0 || (all && !fshort && ftotal >= 0)) { if (all) printf ("\n"); @@ -610,8 +615,8 @@ print_folders (void) } /* - * Set the current message and sychronize sequences - */ +** Set the current message and sychronize sequences +*/ static int sfold (struct msgs *mp, char *msg) @@ -634,8 +639,8 @@ sfold (struct msgs *mp, char *msg) /* - * Do the read only folders - */ +** Do the read only folders +*/ static void readonly_folders (void) diff --git a/uip/forw.c b/uip/forw.c index 6e33dc3..5c71c55 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -1,10 +1,10 @@ /* - * forw.c -- forward a message, or group of messages. - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** forw.c -- forward a message, or group of messages. +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -81,8 +81,8 @@ static struct msgs *mp = NULL; /* used a lot */ /* - * static prototypes - */ +** static prototypes +*/ static void mhl_draft (int, char *, int, int, char *, char *, int); static void copy_draft (int, char *, char *, int, int, int); static void copy_mime_draft (int); @@ -256,13 +256,13 @@ main (int argc, char **argv) if (file) { /* - * Forwarding a file. - */ + ** Forwarding a file. + */ anot = 0; /* don't want to annotate a file */ } else { /* - * Forwarding a message. - */ + ** Forwarding a message. + */ if (!msgp) msgs[msgp++] = "cur"; if (!folder) @@ -291,8 +291,8 @@ main (int argc, char **argv) adios (filter, "unable to read"); /* - * Open form (component) file. - */ + ** Open form (component) file. + */ if (digest) { if (issue == 0) { snprintf (buf, sizeof(buf), IFORMAT, digest); @@ -316,8 +316,8 @@ main (int argc, char **argv) adios (drft, "unable to create"); /* - * copy the components into the draft - */ + ** copy the components into the draft + */ cpydata (in, out, form, drft); close (in); @@ -330,9 +330,9 @@ main (int argc, char **argv) close (out); } else { /* - * If filter file is defined, then format the - * messages into the draft using mhlproc. - */ + ** If filter file is defined, then format the + ** messages into the draft using mhlproc. + */ if (filter) mhl_draft (out, digest, volume, issue, drft, filter, dashstuff); else if (mime) @@ -366,10 +366,10 @@ main (int argc, char **argv) /* - * Filter the messages you are forwarding, into the - * draft calling the mhlproc, and reading its output - * from a pipe. - */ +** Filter the messages you are forwarding, into the +** draft calling the mhlproc, and reading its output +** from a pipe. +*/ static void mhl_draft (int out, char *digest, int volume, int issue, @@ -414,10 +414,10 @@ mhl_draft (int out, char *digest, int volume, int issue, } /* - * Are we dashstuffing (quoting) the lines that begin - * with `-'. We use the mhl default (don't add any flag) - * unless the user has specified a specific flag. - */ + ** Are we dashstuffing (quoting) the lines that begin + ** with `-'. We use the mhl default (don't add any + ** flag) unless the user has specified a specific flag. + */ if (dashstuff > 0) vec[i++] = "-dashstuffing"; else if (dashstuff < 0) @@ -428,12 +428,13 @@ mhl_draft (int out, char *digest, int volume, int issue, MAXARGS - i, vec[0]); /* - * Now add the message names to filter. We can only - * handle about 995 messages (because vec is fixed size), - * but that should be plenty. - */ - for (msgnum = mp->lowsel; msgnum <= mp->hghsel && i < sizeof(vec) - 1; - msgnum++) + ** Now add the message names to filter. We can only + ** handle about 995 messages (because vec is fixed + ** size), but that should be plenty. + */ + for (msgnum = mp->lowsel; + msgnum <= mp->hghsel && i < sizeof(vec) - 1; + msgnum++) if (is_selected (mp, msgnum)) vec[i++] = getcpy (m_name (msgnum)); vec[i] = NULL; @@ -454,13 +455,14 @@ mhl_draft (int out, char *digest, int volume, int issue, /* - * Copy the messages into the draft. The messages are - * not filtered through the mhlproc. Do dashstuffing if - * necessary. - */ +** Copy the messages into the draft. The messages are +** not filtered through the mhlproc. Do dashstuffing if +** necessary. +*/ static void -copy_draft (int out, char *digest, char *file, int volume, int issue, int dashstuff) +copy_draft (int out, char *digest, char *file, int volume, int issue, + int dashstuff) { int fd,i, msgcnt, msgnum; int len, buflen; @@ -503,9 +505,9 @@ copy_draft (int out, char *digest, char *file, int volume, int issue, int dashst } /* - * Copy the message. Add RFC934 quoting (dashstuffing) - * unless given the -nodashstuffing flag. - */ + ** Copy the message. Add RFC934 quoting (dashstuffing) + ** unless given the -nodashstuffing flag. + */ if (dashstuff >= 0) cpydgst (fd, out, msgnam, file); else @@ -538,8 +540,8 @@ copy_draft (int out, char *digest, char *file, int volume, int issue, int dashst /* - * Create a mhbuild composition file for forwarding message. - */ +** Create a mhbuild composition file for forwarding message. +*/ static void copy_mime_draft (int out) diff --git a/uip/ftpsbr.c b/uip/ftpsbr.c index 8295546..fb306f4 100644 --- a/uip/ftpsbr.c +++ b/uip/ftpsbr.c @@ -1,10 +1,10 @@ /* - * ftpsbr.c -- simple FTP client library - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** ftpsbr.c -- simple FTP client library +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -37,14 +37,15 @@ extern int v_verbose; connect ((fd), (struct sockaddr *) (sock), len) /* - * prototypes - */ +** prototypes +*/ int ftp_get (char *, char *, char *, char *, char *, char *, int, int); -int ftp_trans (char *, char *, char *, char *, char *, char *, char *, int, int); +int ftp_trans (char *, char *, char *, char *, char *, char *, char *, + int, int); /* - * static prototypes - */ +** static prototypes +*/ static int start_tcp_server (struct sockaddr_in *, int, int, int); static void _asnprintf (char *, int, char *, va_list); static int ftp_quit (void); diff --git a/uip/inc.c b/uip/inc.c index f9aae76..8947a66 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -1,28 +1,29 @@ /* - * inc.c -- incorporate messages from a maildrop into a folder - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** inc.c -- incorporate messages from a maildrop into a folder +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #ifdef MAILGROUP -/* Revised: Sat Apr 14 17:08:17 PDT 1990 (marvit@hplabs) - * Added hpux hacks to set and reset gid to be "mail" as needed. The reset - * is necessary so inc'ed mail is the group of the inc'er, rather than - * "mail". We setgid to egid only when [un]locking the mail file. This - * is also a major security precaution which will not be explained here. - * - * Fri Feb 7 16:04:57 PST 1992 John Romine - * NB: I'm not 100% sure that this setgid stuff is secure even now. - * - * See the *GROUPPRIVS() macros later. I'm reasonably happy with the setgid - * attribute. Running setuid root is probably not a terribly good idea, though. - * -- Peter Maydell , 04/1998 - * - * Peter Maydell's patch slightly modified for nmh 0.28-pre2. - * Ruud de Rooij Wed, 22 Jul 1998 13:24:22 +0200 - */ +/* +** Revised: Sat Apr 14 17:08:17 PDT 1990 (marvit@hplabs) +** Added hpux hacks to set and reset gid to be "mail" as needed. The reset +** is necessary so inc'ed mail is the group of the inc'er, rather than +** "mail". We setgid to egid only when [un]locking the mail file. This +** is also a major security precaution which will not be explained here. +** +** Fri Feb 7 16:04:57 PST 1992 John Romine +** NB: I'm not 100% sure that this setgid stuff is secure even now. +** +** See the *GROUPPRIVS() macros later. I'm reasonably happy with the setgid +** attribute. Running setuid root is probably not a terribly good idea, though. +** -- Peter Maydell , 04/1998 +** +** Peter Maydell's patch slightly modified for nmh 0.28-pre2. +** Ruud de Rooij Wed, 22 Jul 1998 13:24:22 +0200 +*/ #endif #include @@ -68,34 +69,35 @@ static struct swit switches[] = { { "help", 0 }, }; -/* This is an attempt to simplify things by putting all the - * privilege ops into macros. - * *GROUPPRIVS() is related to handling the setgid MAIL property, - * and only applies if MAILGROUP is defined. - * Basically, SAVEGROUPPRIVS() is called right at the top of main() - * to initialise things, and then DROPGROUPPRIVS() and GETGROUPPRIVS() - * do the obvious thing. TRYDROPGROUPPRIVS() has to be safe to call - * before DROPUSERPRIVS() is called [this is needed because setgid() - * sets both effective and real uids if euid is root.] - * - * There's probably a better implementation if we're allowed to use - * BSD-style setreuid() rather than using POSIX saved-ids. - * Anyway, if you're euid root it's a bit pointless to drop the group - * permissions... - * - * I'm pretty happy that the security is good provided we aren't setuid root. - * The only things we trust with group=mail privilege are lkfopen() - * and lkfclose(). - */ +/* +** This is an attempt to simplify things by putting all the +** privilege ops into macros. +** *GROUPPRIVS() is related to handling the setgid MAIL property, +** and only applies if MAILGROUP is defined. +** Basically, SAVEGROUPPRIVS() is called right at the top of main() +** to initialise things, and then DROPGROUPPRIVS() and GETGROUPPRIVS() +** do the obvious thing. TRYDROPGROUPPRIVS() has to be safe to call +** before DROPUSERPRIVS() is called [this is needed because setgid() +** sets both effective and real uids if euid is root.] +** +** There's probably a better implementation if we're allowed to use +** BSD-style setreuid() rather than using POSIX saved-ids. +** Anyway, if you're euid root it's a bit pointless to drop the group +** permissions... +** +** I'm pretty happy that the security is good provided we aren't setuid root. +** The only things we trust with group=mail privilege are lkfopen() +** and lkfclose(). +*/ /* - * For setting and returning to "mail" gid - */ +** For setting and returning to "mail" gid +*/ #ifdef MAILGROUP static int return_gid; -/* easy case; we're not setuid root, so can drop group privs - * immediately. - */ +/* +** easy case; we're not setuid root, so can drop group privs immediately. +*/ #define TRYDROPGROUPPRIVS() DROPGROUPPRIVS() #define DROPGROUPPRIVS() setgid(getgid()) #define GETGROUPPRIVS() setgid(return_gid) @@ -108,14 +110,17 @@ static int return_gid; #define SAVEGROUPPRIVS() #endif /* not MAILGROUP */ -/* these variables have to be globals so that done() can correctly clean up the lockfile */ +/* +** these variables have to be globals so that done() can correctly clean +** up the lockfile +*/ static int locked = 0; static char *newmail; static FILE *in; /* - * prototypes - */ +** prototypes +*/ char *map_name(char *); static void inc_done(int) NORETURN; @@ -127,7 +132,10 @@ main (int argc, char **argv) int chgflag = 1, trnflag = 1; int noisy = 1, width = 0; int hghnum = 0, msgnum = 0; - int incerr = 0; /* <0 if inc hits an error which means it should not truncate mailspool */ + int incerr = 0; /* + ** <0 if inc hits an error which means it should + ** not truncate mailspool + */ char *cp, *maildir = NULL, *folder = NULL; char *format = NULL, *form = NULL; char *audfile = NULL, *from = NULL; @@ -145,9 +153,10 @@ main (int argc, char **argv) done=inc_done; -/* absolutely the first thing we do is save our privileges, - * and drop them if we can. - */ +/* +** absolutely the first thing we do is save our privileges, +** and drop them if we can. +*/ SAVEGROUPPRIVS(); TRYDROPGROUPPRIVS(); @@ -197,12 +206,12 @@ main (int argc, char **argv) continue; /* - * The flag `trnflag' has the value: - * - * 2 if -truncate is given - * 1 by default (truncating is default) - * 0 if -notruncate is given - */ + ** The flag `trnflag' has the value: + ** + ** 2 if -truncate is given + ** 1 by default (truncating is default) + ** 0 if -notruncate is given + */ case TRNCSW: trnflag = 2; continue; @@ -216,9 +225,9 @@ main (int argc, char **argv) from = path (cp, TFILE); /* - * If the truncate file is in default state, - * change to not truncate. - */ + ** If the truncate file is in default state, + ** change to not truncate. + */ if (trnflag == 1) trnflag = 0; continue; @@ -258,16 +267,17 @@ main (int argc, char **argv) } } - /* NOTE: above this point you should use TRYDROPGROUPPRIVS(), - * not DROPGROUPPRIVS(). - */ + /* + ** NOTE: above this point you should use TRYDROPGROUPPRIVS(), + ** not DROPGROUPPRIVS(). + */ /* guarantee dropping group priveleges; we might not have done so earlier */ DROPGROUPPRIVS(); /* - * We will get the mail from a file - * (typically the standard maildrop) - */ + ** We will get the mail from a file + ** (typically the standard maildrop) + */ if (from) newmail = from; else if ((newmail = getenv ("MAILDROP")) && *newmail) @@ -295,9 +305,10 @@ main (int argc, char **argv) adios (maildir, "error allocating memory to copy maildir"); if (!folder_exists(maildir)) { - /* If the folder doesn't exist, and we're given the -silent flag, - * just fail. - */ + /* + ** If the folder doesn't exist, and we're given the -silent + ** flag, just fail. + */ if (noisy) create_folder(maildir, 0, done); else @@ -371,15 +382,15 @@ main (int argc, char **argv) } /* - * Get the mail from file (usually mail spool) - */ + ** Get the mail from file (usually mail spool) + */ m_unknown (in); /* the MAGIC invocation... */ hghnum = msgnum = mp->hghmsg; for (;;) { /* - * Check if we need to allocate more space for message status. - * If so, then add space for an additional 100 messages. - */ + ** Check if we need to allocate more space for message status. + ** If so, then add space for an additional 100 messages. + */ if (msgnum >= mp->hghoff && !(mp = folder_realloc (mp, mp->lowoff, mp->hghoff + 100))) { advise (NULL, "unable to allocate folder storage"); @@ -412,8 +423,8 @@ main (int argc, char **argv) case SCNMSG: case SCNENC: /* - * Run the external program hook on the message. - */ + ** Run the external program hook on the message. + */ (void)snprintf(b, sizeof (b), "%s/%d", maildir_copy, msgnum + 1); (void)ext_hook("add-hook", b, (char *)0); @@ -437,9 +448,10 @@ main (int argc, char **argv) mp->msgflags |= SEQMOD; continue; } - /* If we get here there was some sort of error from scan(), - * so stop processing anything more from the spool. - */ + /* + ** If we get here there was some sort of error from scan(), + ** so stop processing anything more from the spool. + */ break; } @@ -447,7 +459,10 @@ main (int argc, char **argv) if (locked) { GETGROUPPRIVS(); /* Be sure we can unlock mail file */ (void) lkfclose (in, newmail); in = NULL; - DROPGROUPPRIVS(); /* And then return us to normal privileges */ + DROPGROUPPRIVS(); /* + ** And then return us to normal + ** privileges + */ } else { fclose (in); in = NULL; } @@ -466,8 +481,8 @@ main (int argc, char **argv) fflush (stdout); /* - * truncate file we are incorporating from - */ + ** truncate file we are incorporating from + */ if (trnflag) { if (stat (newmail, &st) != NOTOK && s1.st_mtime != st.st_mtime) advise (NULL, "new messages have arrived!\007"); @@ -479,9 +494,8 @@ main (int argc, char **argv) admonish (newmail, "error zero'ing"); unlink(map_name(newmail)); } - } else { - if (noisy) - printf ("%s not zero'd\n", newmail); + } else if (noisy) { + printf ("%s not zero'd\n", newmail); } if (msgnum == hghnum) { @@ -498,8 +512,8 @@ main (int argc, char **argv) } /* - * unlock the mail spool - */ + ** unlock the mail spool + */ if (locked) { GETGROUPPRIVS(); /* Be sure we can unlock mail file */ (void) lkfclose (in, newmail); in = NULL; diff --git a/uip/install-mh.c b/uip/install-mh.c index 364cfb2..ce07d5d 100644 --- a/uip/install-mh.c +++ b/uip/install-mh.c @@ -1,10 +1,10 @@ /* - * install-mh.c -- initialize the nmh environment of a new user - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** install-mh.c -- initialize the nmh environment of a new user +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include /* mh internals */ #include @@ -23,8 +23,8 @@ static struct swit switches[] = { }; /* - * static prototypes - */ +** static prototypes +*/ static char *geta(void); @@ -80,10 +80,10 @@ main (int argc, char **argv) } /* - * 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') @@ -93,12 +93,12 @@ main (int argc, char **argv) } /* - * Find the user's profile. Check for the existence of an - * MH environment variable first with non-empty contents. - * Convert any relative path name found there to an absolute one. - * Look for the profile in the user's home directory if the MH - * environment variable isn't set. - */ + ** Find the user's profile. Check for the existence of an + ** MH environment variable first with non-empty contents. + ** Convert any relative path name found there to an absolute one. + ** Look for the profile in the user's home directory if the MH + ** environment variable isn't set. + */ if ((cp = getenv("MH")) && *cp != '\0') defpath = path(cp, TFILE); @@ -106,11 +106,11 @@ main (int argc, char **argv) defpath = concat(mypath, "/", mh_profile, NULL); /* - * Check for the existence of the profile file. It's an - * error if it exists and this isn't an installation check. - * An installation check fails if it does not exist, succeeds - * if it does. - */ + ** Check for the existence of the profile file. It's an + ** error if it exists and this isn't an installation check. + ** An installation check fails if it does not exist, succeeds + ** if it does. + */ if (stat (defpath, &st) != NOTOK) { if (check) @@ -179,8 +179,8 @@ query: } /* - * Add some initial elements to the profile/context list - */ + ** Add some initial elements to the profile/context list + */ m_defs = (struct node *) mh_xmalloc (sizeof *np); np = m_defs; np->n_name = getcpy ("Path"); @@ -189,9 +189,9 @@ query: np->n_next = NULL; /* - * If there is a default profile file in the - * nmh `etc' directory, then read it also. - */ + ** If there is a default profile file in the + ** nmh `etc' directory, then read it also. + */ if ((in = fopen (mh_defaults, "r"))) { readconfig (&np->n_next, in, mh_defaults, 0); fclose (in); @@ -204,8 +204,8 @@ query: context_save (); /* - * Now write out the initial .mh_profile - */ + ** Now write out the initial .mh_profile + */ if ((out = fopen (defpath, "w")) == NULL) adios (defpath, "unable to write"); for (np = m_defs; np; np = np->n_next) { diff --git a/uip/mark.c b/uip/mark.c index e4d078e..9cca0ad 100644 --- a/uip/mark.c +++ b/uip/mark.c @@ -1,12 +1,12 @@ /* - * mark.c -- add message(s) to sequences in given folder - * -- delete messages (s) from sequences in given folder - * -- list sequences in given folder - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mark.c -- add message(s) to sequences in given folder +** -- delete messages (s) from sequences in given folder +** -- list sequences in given folder +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -38,8 +38,8 @@ static struct swit switches[] = { }; /* - * static prototypes - */ +** static prototypes +*/ static void print_debug (struct msgs *); static void seq_printdebug (struct msgs *); @@ -68,8 +68,8 @@ main (int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -141,10 +141,10 @@ main (int argc, char **argv) } /* - * If we haven't specified -add, -delete, or -list, - * then use -add if a sequence was specified, else - * use -list. - */ + ** If we haven't specified -add, -delete, or -list, + ** then use -add if a sequence was specified, else + ** use -list. + */ if (!addsw && !deletesw && !listsw) { if (seqp) addsw++; @@ -184,9 +184,9 @@ main (int argc, char **argv) adios (NULL, "folder %s is read-only, so -public not allowed", folder); /* - * Make sure at least one sequence has been - * specified if we are adding or deleting. - */ + ** Make sure at least one sequence has been + ** specified if we are adding or deleting. + */ if (seqp == 0 && (addsw || deletesw)) adios (NULL, "-%s requires at least one -sequence argument", addsw ? "add" : "delete"); @@ -232,8 +232,8 @@ main (int argc, char **argv) /* - * Print general debugging info - */ +** Print general debugging info +*/ static void print_debug (struct msgs *mp) { @@ -257,9 +257,9 @@ print_debug (struct msgs *mp) /* - * Print debugging info about all the SELECTED - * messages and the sequences they are in. - */ +** Print debugging info about all the SELECTED +** messages and the sequences they are in. +*/ static void seq_printdebug (struct msgs *mp) { diff --git a/uip/md5.c b/uip/md5.c index a40d289..6737a3e 100644 --- a/uip/md5.c +++ b/uip/md5.c @@ -1,40 +1,40 @@ /* - * md5.c -- md5 message digest algorithm - * taken from RFC-1321/Appendix A.3 - */ +** md5.c -- md5 message digest algorithm +** taken from RFC-1321/Appendix A.3 +*/ /* - * MD5C.C -- RSA Data Security, Inc., MD5 message-digest algorithm - */ +** MD5C.C -- RSA Data Security, Inc., MD5 message-digest algorithm +*/ /* - * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - * rights reserved. - * - * License to copy and use this software is granted provided that it - * is identified as the "RSA Data Security, Inc. MD5 Message-Digest - * Algorithm" in all material mentioning or referencing this software - * or this function. - * - * License is also granted to make and use derivative works provided - * that such works are identified as "derived from the RSA Data - * Security, Inc. MD5 Message-Digest Algorithm" in all material - * mentioning or referencing the derived work. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software for any particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * - * These notices must be retained in any copies of any part of this - * documentation and/or software. - */ +** Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +** rights reserved. +** +** License to copy and use this software is granted provided that it +** is identified as the "RSA Data Security, Inc. MD5 Message-Digest +** Algorithm" in all material mentioning or referencing this software +** or this function. +** +** License is also granted to make and use derivative works provided +** that such works are identified as "derived from the RSA Data +** Security, Inc. MD5 Message-Digest Algorithm" in all material +** mentioning or referencing the derived work. +** +** RSA Data Security, Inc. makes no representations concerning either +** the merchantability of this software or the suitability of this +** software for any particular purpose. It is provided "as is" +** without express or implied warranty of any kind. +** +** These notices must be retained in any copies of any part of this +** documentation and/or software. +*/ #include /* - * Constants for MD5Transform routine. - */ +** Constants for MD5Transform routine. +*/ #define S11 7 #define S12 12 #define S13 17 @@ -62,20 +62,22 @@ static unsigned char PADDING[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -/* F, G, H and I are basic MD5 functions. - */ +/* +** F, G, H and I are basic MD5 functions. +*/ #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define I(x, y, z) ((y) ^ ((x) | (~z))) -/* ROTATE_LEFT rotates x left n bits. - */ +/* +** ROTATE_LEFT rotates x left n bits. +*/ #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. - * Rotation is separate from addition to prevent recomputation. - */ +** Rotation is separate from addition to prevent recomputation. +*/ #define FF(a, b, c, d, x, s, ac) { \ (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ @@ -97,24 +99,27 @@ static unsigned char PADDING[64] = { (a) += (b); \ } -/* MD5 initialization. Begins an MD5 operation, writing a new context. - */ +/* +** MD5 initialization. Begins an MD5 operation, writing a new context. +*/ void MD5Init (context) MD5_CTX *context; /* context */ { context->count[0] = context->count[1] = 0; - /* Load magic initialization constants. - */ + /* + ** Load magic initialization constants. + */ context->state[0] = 0x67452301; context->state[1] = 0xefcdab89; context->state[2] = 0x98badcfe; context->state[3] = 0x10325476; } -/* MD5 block update operation. Continues an MD5 message-digest - * operation, processing another message block, and updating the - * context. - */ +/* +** MD5 block update operation. Continues an MD5 message-digest +** operation, processing another message block, and updating the +** context. +*/ void MD5Update (context, input, inputLen) MD5_CTX *context; /* context */ unsigned char *input; /* input block */ @@ -149,9 +154,9 @@ unsigned int inputLen; /* length of input block */ } /* - * MD5 finalization. Ends an MD5 message-digest operation, writing the - * the message digest and zeroizing the context. - */ +** MD5 finalization. Ends an MD5 message-digest operation, writing the +** the message digest and zeroizing the context. +*/ void MD5Final (digest, context) unsigned char digest[16]; /* message digest */ MD5_CTX *context; /* context */ @@ -162,8 +167,7 @@ MD5_CTX *context; /* context */ /* Save number of bits */ Encode (bits, context->count, 8); - /* Pad out to 56 mod 64. - */ + /* Pad out to 56 mod 64. */ index = (unsigned int)((context->count[0] >> 3) & 0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); MD5Update (context, PADDING, padLen); @@ -177,8 +181,9 @@ MD5_CTX *context; /* context */ memset ((POINTER)context, 0, sizeof(*context)); } -/* MD5 basic transformation. Transforms state based on block. - */ +/* +** MD5 basic transformation. Transforms state based on block. +*/ static void MD5Transform (state, block) UINT4 state[4]; unsigned char block[64]; @@ -268,9 +273,10 @@ unsigned char block[64]; memset ((POINTER)x, 0, sizeof(x)); } -/* Encodes input (UINT4) into output (unsigned char). Assumes len is - * a multiple of 4. - */ +/* +** Encodes input (UINT4) into output (unsigned char). Assumes len is +** a multiple of 4. +*/ static void Encode (output, input, len) unsigned char *output; UINT4 *input; @@ -286,9 +292,10 @@ unsigned int len; } } -/* Decodes input (unsigned char) into output (UINT4). Assumes len is - * a multiple of 4. - */ +/* +** Decodes input (unsigned char) into output (UINT4). Assumes len is +** a multiple of 4. +*/ static void Decode (output, input, len) UINT4 *output; unsigned char *input; diff --git a/uip/mhbuild.c b/uip/mhbuild.c index dc71d83..cdec935 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -1,10 +1,10 @@ /* - * mhbuild.c -- expand/translate MIME composition files - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhbuild.c -- expand/translate MIME composition files +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -88,8 +88,8 @@ int rfc934sw = 0; int contentidsw = 1; /* - * Temporary files - */ +** Temporary files +*/ static char infile[BUFSIZ]; static int unlink_infile = 0; @@ -144,7 +144,7 @@ main (int argc, char **argv) adios (NULL, "cannot specify both standard input and a file"); else compfile = cp; - listsw = 0; /* turn off -list if using standard in/out */ + listsw = 0; /* turn off -list if using std in/out */ verbosw = 0; /* turn off -verbose listings */ break; } @@ -255,8 +255,8 @@ main (int argc, char **argv) listsw = 0; /* - * Check if we've specified an additional profile - */ + ** Check if we've specified an additional profile + */ if ((cp = getenv ("MHBUILD"))) { if ((fp = fopen (cp, "r"))) { readconfig ((struct node **) 0, fp, cp, 0); @@ -267,8 +267,8 @@ main (int argc, char **argv) } /* - * Read the standard profile setup - */ + ** Read the standard profile setup + */ if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) { readconfig ((struct node **) 0, fp, cp, 0); fclose (fp); @@ -284,10 +284,10 @@ main (int argc, char **argv) cache_private = getcpy (m_maildir (cache_private)); /* - * Check for storage directory. If defined, we - * will store temporary files there. Else we - * store them in standard nmh directory. - */ + ** Check for storage directory. If defined, we + ** will store temporary files there. Else we + ** store them in standard nmh directory. + */ if ((cp = context_find (nmhstorage)) && *cp) tmp = concat (cp, "/", invo_name, NULL); else @@ -301,8 +301,8 @@ main (int argc, char **argv) adios (NULL, "need to specify a %s composition file", invo_name); /* - * Process the composition file from standard input. - */ + ** Process the composition file from standard input. + */ if (compfile[0] == '-' && compfile[1] == '\0') { /* copy standard input to temporary file */ strncpy (infile, m_mktemp(invo_name, NULL, &fp), sizeof(infile)); @@ -342,8 +342,8 @@ main (int argc, char **argv) } /* - * Process the composition file from a file. - */ + ** Process the composition file from a file. + */ /* build the content structures for MIME message */ ct = build_mime (compfile); @@ -360,8 +360,8 @@ main (int argc, char **argv) fclose(fp_out); /* - * List the message info - */ + ** List the message info + */ if (listsw) list_all_messages (cts, headsw, sizesw, verbosw, debugsw); @@ -389,9 +389,8 @@ static void unlink_done (int status) { /* - * Check if we need to remove stray - * temporary files. - */ + ** Check if we need to remove stray temporary files. + */ if (unlink_infile) unlink (infile); if (unlink_outfile) diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 1ca8091..ca69fbe 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -1,18 +1,18 @@ /* - * mhbuildsbr.c -- routines to expand/translate MIME composition files - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhbuildsbr.c -- routines to expand/translate MIME composition files +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ /* - * This code was originally part of mhn.c. I split it into - * a separate program (mhbuild.c) and then later split it - * again (mhbuildsbr.c). But the code still has some of - * the mhn.c code in it. This program needs additional - * streamlining and removal of unneeded code. - */ +** This code was originally part of mhn.c. I split it into +** a separate program (mhbuild.c) and then later split it +** again (mhbuildsbr.c). But the code still has some of +** the mhn.c code in it. This program needs additional +** streamlining and removal of unneeded code. +*/ #include #include @@ -57,9 +57,9 @@ extern int rcachesw; /* mhcachesbr.c */ extern int wcachesw; /* mhcachesbr.c */ /* - * Directory to place tmp files. This must - * be set before these routines are called. - */ +** Directory to place tmp files. This must +** be set before these routines are called. +*/ char *tmp; pid_t xpid = 0; @@ -83,13 +83,13 @@ void free_ctinfo (CT); void free_encoding (CT, int); /* - * prototypes - */ +** prototypes +*/ CT build_mime (char *); /* - * static prototypes - */ +** static prototypes +*/ static int init_decoded_content (CT); static char *fgetstr (char *, int, FILE *); static int user_content (FILE *, char *, char *, CT *); @@ -101,13 +101,13 @@ static char *calculate_digest (CT, int); /* - * Main routine for translating composition file - * into valid MIME message. It translates the draft - * into a content structure (actually a tree of content - * structures). This message then can be manipulated - * in various ways, including being output via - * output_message(). - */ +** Main routine for translating composition file +** into valid MIME message. It translates the draft +** into a content structure (actually a tree of content +** structures). This message then can be manipulated +** in various ways, including being output via +** output_message(). +*/ CT build_mime (char *infile) @@ -127,23 +127,23 @@ build_mime (char *infile) adios (infile, "unable to open for reading"); /* - * Allocate space for primary (outside) content - */ + ** Allocate space for primary (outside) content + */ if ((ct = (CT) calloc (1, sizeof(*ct))) == NULL) adios (NULL, "out of memory"); /* - * Allocate structure for handling decoded content - * for this part. We don't really need this, but - * allocate it to remain consistent. - */ + ** Allocate structure for handling decoded content + ** for this part. We don't really need this, but + ** allocate it to remain consistent. + */ init_decoded_content (ct); /* - * Parse some of the header fields in the composition - * draft into the linked list of header fields for - * the new MIME message. - */ + ** Parse some of the header fields in the composition + ** draft into the linked list of header fields for + ** the new MIME message. + */ for (compnum = 1, state = FLD;;) { switch (state = m_getfld (state, name, buf, sizeof(buf), in)) { case FLD: @@ -155,14 +155,18 @@ build_mime (char *infile) if (!mh_strcasecmp (name, VRSN_FIELD)) adios (NULL, "draft shouldn't contain %s: field", VRSN_FIELD); - /* abort if draft has Content-Transfer-Encoding header field */ + /* + ** abort if draft has Content-Transfer-Encoding + ** header field + */ if (!mh_strcasecmp (name, ENCODING_FIELD)) adios (NULL, "draft shouldn't contain %s: field", ENCODING_FIELD); /* ignore any Content-Type fields in the header */ if (!mh_strcasecmp (name, TYPE_FIELD)) { while (state == FLDPLUS) - state = m_getfld (state, name, buf, sizeof(buf), in); + state = m_getfld (state, name, buf, + sizeof(buf), in); goto finish_field; } @@ -173,14 +177,14 @@ build_mime (char *infile) /* if necessary, get rest of field */ while (state == FLDPLUS) { state = m_getfld (state, name, buf, sizeof(buf), in); - vp = add (buf, vp); /* add to previous value */ + vp = add (buf, vp); /* add to prev value */ } /* Now add the header data to the list */ add_header (ct, np, vp); finish_field: - /* if this wasn't the last header field, then continue */ + /* if this wasn't the last hdr field, then continue */ if (state != FLDEOF) continue; /* else fall... */ @@ -196,7 +200,8 @@ finish_field: case LENERR: case FMTERR: - adios (NULL, "message format error in component #%d", compnum); + adios (NULL, "message format error in component #%d", + compnum); default: adios (NULL, "getfld() returned %d", state); @@ -205,18 +210,18 @@ finish_field: } /* - * Now add the MIME-Version header field - * to the list of header fields. - */ + ** Now add the MIME-Version header field + ** to the list of header fields. + */ np = add (VRSN_FIELD, NULL); vp = concat (" ", VRSN_VALUE, "\n", NULL); add_header (ct, np, vp); /* - * We initally assume we will find multiple contents in the - * draft. So create a multipart/mixed content to hold everything. - * We can remove this later, if it is not needed. - */ + ** We initally assume we will find multiple contents in the + ** draft. So create a multipart/mixed content to hold everything. + ** We can remove this later, if it is not needed. + */ if (get_ctinfo ("multipart/mixed", ct, 0) == NOTOK) done (1); ct->c_type = CT_MULTIPART; @@ -229,9 +234,9 @@ finish_field: pp = &m->mp_parts; /* - * read and parse the composition file - * and the directives it contains. - */ + ** read and parse the composition file + ** and the directives it contains. + */ while (fgetstr (buf, sizeof(buf) - 1, in)) { struct part *part; CT p; @@ -251,9 +256,9 @@ finish_field: } /* - * close the composition draft since - * it's not needed any longer. - */ + ** close the composition draft since + ** it's not needed any longer. + */ fclose (in); /* check if any contents were found */ @@ -261,9 +266,9 @@ finish_field: adios (NULL, "no content directives found"); /* - * If only one content was found, then remove and - * free the outer multipart content. - */ + ** If only one content was found, then remove and + ** free the outer multipart content. + */ if (!m->mp_parts->mp_next) { CT p; @@ -283,19 +288,19 @@ finish_field: } /* - * Fill out, or expand directives. Parse and execute - * commands specified by profile composition strings. - */ + ** Fill out, or expand directives. Parse and execute + ** commands specified by profile composition strings. + */ compose_content (ct); if ((cp = strchr(prefix, 'a')) == NULL) adios (NULL, "internal error(4)"); /* - * Scan the contents. Choose a transfer encoding, and - * check if prefix for multipart boundary clashes with - * any of the contents. - */ + ** Scan the contents. Choose a transfer encoding, and + ** check if prefix for multipart boundary clashes with + ** any of the contents. + */ while (scan_content (ct) == NOTOK) { if (*cp < 'z') { (*cp)++; @@ -315,9 +320,9 @@ finish_field: /* - * Set up structures for placing unencoded - * content when building parts. - */ +** Set up structures for placing unencoded +** content when building parts. +*/ static int init_decoded_content (CT ct) @@ -361,9 +366,9 @@ fgetstr (char *s, int n, FILE *stream) /* - * Parse the composition draft for text and directives. - * Do initial setup of Content structure. - */ +** Parse the composition draft for text and directives. +** Do initial setup of Content structure. +*/ static int user_content (FILE *in, char *file, char *buf, CT *ctp) @@ -398,13 +403,13 @@ user_content (FILE *in, char *file, char *buf, CT *ctp) set_id (ct, 0); /* - * Handle inline text. Check if line - * is one of the following forms: - * - * 1) doesn't begin with '#' (implicit directive) - * 2) begins with "##" (implicit directive) - * 3) begins with "#<" - */ + ** Handle inline text. Check if line + ** is one of the following forms: + ** + ** 1) doesn't begin with '#' (implicit directive) + ** 2) begins with "##" (implicit directive) + ** 3) begins with "#<" + */ if (buf[0] != '#' || buf[1] == '#' || buf[1] == '<') { int headers; int inlineD; @@ -414,7 +419,8 @@ user_content (FILE *in, char *file, char *buf, CT *ctp) char *cp; cp = m_mktemp2(NULL, invo_name, NULL, &out); - if (cp == NULL) adios("mhbuildsbr", "unable to create temporary file"); + if (cp == NULL) + adios("mhbuildsbr", "unable to create temporary file"); /* use a temp file to collect the plain text lines */ ce->ce_file = add (cp, NULL); @@ -436,7 +442,7 @@ user_content (FILE *in, char *file, char *buf, CT *ctp) int i; if (headers >= 0 && uprf (buffer, DESCR_FIELD) - && buffer[i = strlen (DESCR_FIELD)] == ':') { + && buffer[i = strlen (DESCR_FIELD)] == ':') { headers = 1; again_descr: @@ -515,8 +521,8 @@ rock_and_roll: s2i++; /* - * check type specified (possibly implicitly) - */ + ** check type specified (possibly implicitly) + */ switch (ct->c_type = s2i->si_val) { case CT_MESSAGE: if (!mh_strcasecmp (ci->ci_subtype, "rfc822")) { @@ -526,7 +532,8 @@ rock_and_roll: /* else fall... */ case CT_MULTIPART: adios (NULL, "it doesn't make sense to define an in-line %s content", - ct->c_type == CT_MESSAGE ? "message" : "multipart"); + ct->c_type == CT_MESSAGE ? "message" : + "multipart"); /* NOTREACHED */ default: @@ -542,9 +549,9 @@ call_init: } /* - * If we've reached this point, the next line - * must be some type of explicit directive. - */ + ** If we've reached this point, the next line + ** must be some type of explicit directive. + */ /* check if directive is external-type */ extrnal = (buf[1] == '@'); @@ -559,12 +566,12 @@ call_init: break; /* - * Check if the directive specified a valid type. - * This will happen if it was one of the following forms: - * - * #type/subtype (or) - * #@type/subtype - */ + ** Check if the directive specified a valid type. + ** This will happen if it was one of the following forms: + ** + ** #type/subtype (or) + ** #@type/subtype + */ if (s2i->si_key) { if (!ci->ci_subtype) adios (NULL, "missing subtype in \"#%s\"", ci->ci_type); @@ -595,8 +602,8 @@ use_forw: } /* - * #@type/subtype (external types directive) - */ + ** #@type/subtype (external types directive) + */ if (extrnal) { struct exbody *e; CT p; @@ -611,11 +618,12 @@ use_forw: ci->ci_magic = NULL; /* - * Since we are using the current Content structure to - * hold information about the type of the external - * reference, we need to create another Content structure - * for the message/external-body to wrap it in. - */ + ** Since we are using the current Content structure to + ** hold information about the type of the external + ** reference, we need to create another Content + ** structure for the message/external-body to wrap + ** it in. + */ if ((ct = (CT) calloc (1, sizeof(*ct))) == NULL) adios (NULL, "out of memory"); *ctp = ct; @@ -663,13 +671,14 @@ use_forw: } /* - * No [file] argument, so check profile for - * method to compose content. - */ + ** No [file] argument, so check profile for + ** method to compose content. + */ snprintf (buffer, sizeof(buffer), "%s-compose-%s/%s", invo_name, ci->ci_type, ci->ci_subtype); if ((cp = context_find (buffer)) == NULL || *cp == '\0') { - snprintf (buffer, sizeof(buffer), "%s-compose-%s", invo_name, ci->ci_type); + snprintf (buffer, sizeof(buffer), "%s-compose-%s", + invo_name, ci->ci_type); if ((cp = context_find (buffer)) == NULL || *cp == '\0') { content_error (NULL, ct, "don't know how to compose content"); done (1); @@ -680,12 +689,13 @@ use_forw: } if (extrnal) - adios (NULL, "external definition not allowed for \"#%s\"", ci->ci_type); + adios (NULL, "external definition not allowed for \"#%s\"", + ci->ci_type); /* - * Message directive - * #forw [+folder] [msgs] - */ + ** Message directive + ** #forw [+folder] [msgs] + */ if (!mh_strcasecmp (ci->ci_type, "forw")) { int msgnum; char *folder, *arguments[MAXARGS]; @@ -727,11 +737,11 @@ use_forw: free_ctinfo (ct); /* - * If there is more than one message to include, make this - * a content of type "multipart/digest" and insert each message - * as a subpart. If there is only one message, then make this - * a content of type "message/rfc822". - */ + ** If there is more than one message to include, make this + ** a content of type "multipart/digest" and insert each message + ** as a subpart. If there is only one message, then make this + ** a content of type "message/rfc822". + */ if (mp->numsel > 1) { /* we are forwarding multiple messages */ if (get_ctinfo ("multipart/digest", ct, 0) == NOTOK) @@ -790,8 +800,8 @@ use_forw: } /* - * #end - */ + ** #end + */ if (!mh_strcasecmp (ci->ci_type, "end")) { free_content (ct); *ctp = NULL; @@ -799,8 +809,8 @@ use_forw: } /* - * #begin [ alternative | parallel ] - */ + ** #begin [ alternative | parallel ] + */ if (!mh_strcasecmp (ci->ci_type, "begin")) { if (!ci->ci_magic) { vrsn = MULTI_MIXED; @@ -853,8 +863,8 @@ use_forw: } /* - * Unknown directive - */ + ** Unknown directive + */ adios (NULL, "unknown directive \"#%s\"", ci->ci_type); return NOTOK; /* NOT REACHED */ } @@ -917,10 +927,10 @@ static char ebcdicsafe[0x100] = { /* - * Fill out, or expand the various contents in the composition - * draft. Read-in any necessary files. Parse and execute any - * commands specified by profile composition strings. - */ +** Fill out, or expand the various contents in the composition +** draft. Read-in any necessary files. Parse and execute any +** commands specified by profile composition strings. +*/ static int compose_content (CT ct) @@ -944,7 +954,8 @@ compose_content (CT ct) } /* first, we call compose_content on all the subparts */ - for (part = m->mp_parts, partnum = 1; part; part = part->mp_next, partnum++) { + for (part = m->mp_parts, partnum = 1; part; + part = part->mp_next, partnum++) { CT p = part->mp_part; sprintf (pp, "%d", partnum); @@ -954,11 +965,11 @@ compose_content (CT ct) } /* - * If the -rfc934mode switch is given, then check all - * the subparts of a multipart/digest. If they are all - * message/rfc822, then mark this content and all - * subparts with the rfc934 compatibility mode flag. - */ + ** If the -rfc934mode switch is given, then check all + ** the subparts of a multipart/digest. If they are all + ** message/rfc822, then mark this content and all + ** subparts with the rfc934 compatibility mode flag. + */ if (rfc934sw && ct->c_subtype == MULTI_DIGEST) { int is934 = 1; @@ -995,8 +1006,8 @@ compose_content (CT ct) break; /* - * Discrete types (text/application/audio/image/video) - */ + ** Discrete types (text/application/audio/image/video) + */ default: if (!ce->ce_file) { pid_t child_id; @@ -1025,14 +1036,17 @@ compose_content (CT ct) buflen = sizeof(buffer); /* - * Parse composition string into buffer - */ + ** Parse composition string into buffer + */ for ( ; *cp; cp++) { if (*cp == '%') { switch (*++cp) { case 'a': { - /* insert parameters from directive */ + /* + ** insert parameters from + ** directive + */ char **ep; char *s = ""; @@ -1053,9 +1067,10 @@ compose_content (CT ct) case 'f': /* - * insert temporary filename where - * content should be written - */ + ** insert temporary filename + ** where content should be + ** written + */ snprintf (bp, buflen, "%s", ce->ce_file); break; @@ -1079,9 +1094,9 @@ compose_content (CT ct) buflen -= len; } else { raw: - *bp++ = *cp; - *bp = '\0'; - buflen--; + *bp++ = *cp; + *bp = '\0'; + buflen--; } } @@ -1139,17 +1154,17 @@ raw: /* - * Scan the content. - * - * 1) choose a transfer encoding. - * 2) check for clashes with multipart boundary string. - * 3) for text content, figure out which character set is being used. - * - * If there is a clash with one of the contents and the multipart boundary, - * this function will exit with NOTOK. This will cause the scanning process - * to be repeated with a different multipart boundary. It is possible - * (although highly unlikely) that this scan will be repeated multiple times. - */ +** Scan the content. +** +** 1) choose a transfer encoding. +** 2) check for clashes with multipart boundary string. +** 3) for text content, figure out which character set is being used. +** +** If there is a clash with one of the contents and the multipart boundary, +** this function will exit with NOTOK. This will cause the scanning process +** to be repeated with a different multipart boundary. It is possible +** (although highly unlikely) that this scan will be repeated multiple times. +*/ static int scan_content (CT ct) @@ -1166,9 +1181,9 @@ scan_content (CT ct) CE ce = ct->c_cefile; /* - * handle multipart by scanning all subparts - * and then checking their encoding. - */ + ** handle multipart by scanning all subparts + ** and then checking their encoding. + */ if (ct->c_type == CT_MULTIPART) { struct multipart *m = (struct multipart *) ct->c_ctparams; struct part *part; @@ -1182,7 +1197,10 @@ scan_content (CT ct) if (scan_content (p) == NOTOK) /* choose encoding for subpart */ return NOTOK; - /* if necessary, enlarge encoding for enclosing multipart */ + /* + ** if necessary, enlarge encoding for enclosing + ** multipart + */ if (p->c_encoding == CE_BINARY) ct->c_encoding = CE_BINARY; if (p->c_encoding == CE_8BIT && ct->c_encoding != CE_BINARY) @@ -1193,8 +1211,8 @@ scan_content (CT ct) } /* - * Decide what to check while scanning this content. - */ + ** Decide what to check while scanning this content. + */ switch (ct->c_type) { case CT_TEXT: check8bit = 1; @@ -1235,9 +1253,9 @@ scan_content (CT ct) case CT_IMAGE: case CT_VIDEO: /* - * Don't check anything for these types, - * since we are forcing use of base64. - */ + ** Don't check anything for these types, + ** since we are forcing use of base64. + */ check8bit = 0; checkebcdic = 0; checklinelen = 0; @@ -1247,8 +1265,8 @@ scan_content (CT ct) } /* - * Scan the unencoded content - */ + ** Scan the unencoded content + */ if (check8bit || checklinelen || checklinespace || checkboundary) { if ((in = fopen (ce->ce_file, "r")) == NULL) adios (ce->ce_file, "unable to open for reading"); @@ -1256,45 +1274,51 @@ scan_content (CT ct) while (fgets (buffer, sizeof(buffer) - 1, in)) { /* - * Check for 8bit data. - */ + ** Check for 8bit data. + */ if (check8bit) { for (cp = buffer; *cp; cp++) { if (!isascii (*cp)) { contains8bit = 1; - check8bit = 0; /* no need to keep checking */ + /* no need to keep checking */ + check8bit = 0; } /* - * Check if character is ebcdic-safe. We only check - * this if also checking for 8bit data. - */ + ** Check if character is ebcdic-safe. + ** We only check this if also checking + ** for 8bit data. + */ if (checkebcdic && !ebcdicsafe[*cp & 0xff]) { ebcdicunsafe = 1; - checkebcdic = 0; /* no need to keep checking */ + /* no need to keep checking */ + checkebcdic = 0; } } } /* - * Check line length. - */ + ** Check line length. + */ if (checklinelen && (strlen (buffer) > CPERLIN + 1)) { linelen = 1; checklinelen = 0; /* no need to keep checking */ } /* - * Check if line ends with a space. - */ - if (checklinespace && (cp = buffer + strlen (buffer) - 2) > buffer && isspace (*cp)) { + ** Check if line ends with a space. + */ + if (checklinespace && + (cp = buffer + strlen (buffer) - 2) > + buffer && isspace (*cp)) { linespace = 1; - checklinespace = 0; /* no need to keep checking */ + /* no need to keep checking */ + checklinespace = 0; } /* - * Check if content contains a line that clashes - * with our standard boundary for multipart messages. - */ + ** Check if content contains a line that clashes + ** with our standard boundary for multipart messages. + */ if (checkboundary && buffer[0] == '-' && buffer[1] == '-') { for (cp = buffer + strlen (buffer) - 1; cp >= buffer; cp--) if (!isspace (*cp)) @@ -1302,7 +1326,8 @@ scan_content (CT ct) *++cp = '\0'; if (!strncmp(buffer + 2, prefix, len) && isdigit(buffer[2 + len])) { boundaryclash = 1; - checkboundary = 0; /* no need to keep checking */ + /* no need to keep checking */ + checkboundary = 0; } } } @@ -1310,14 +1335,14 @@ scan_content (CT ct) } /* - * Decide which transfer encoding to use. - */ + ** Decide which transfer encoding to use. + */ switch (ct->c_type) { case CT_TEXT: /* - * If the text content didn't specify a character - * set, we need to figure out which one was used. - */ + ** If the text content didn't specify a character + ** set, we need to figure out which one was used. + */ t = (struct text *) ct->c_ctparams; if (t->tx_charset == CHARSET_UNSPECIFIED) { CI ci = &ct->c_ctinfo; @@ -1372,10 +1397,10 @@ scan_content (CT ct) /* - * Scan the content structures, and build header - * fields that will need to be output into the - * message. - */ +** Scan the content structures, and build header +** fields that will need to be output into the +** message. +*/ static int build_headers (CT ct) @@ -1386,9 +1411,9 @@ build_headers (CT ct) CI ci = &ct->c_ctinfo; /* - * If message is type multipart, then add the multipart - * boundary to the list of attribute/value pairs. - */ + ** If message is type multipart, then add the multipart + ** boundary to the list of attribute/value pairs. + */ if (ct->c_type == CT_MULTIPART) { char *cp; static int level = 0; /* store nesting level */ @@ -1403,18 +1428,18 @@ build_headers (CT ct) } /* - * Skip the output of Content-Type, parameters, content - * description and disposition, and Content-ID if the - * content is of type "message" and the rfc934 compatibility - * flag is set (which means we are inside multipart/digest - * and the switch -rfc934mode was given). - */ + ** Skip the output of Content-Type, parameters, content + ** description and disposition, and Content-ID if the + ** content is of type "message" and the rfc934 compatibility + ** flag is set (which means we are inside multipart/digest + ** and the switch -rfc934mode was given). + */ if (ct->c_type == CT_MESSAGE && ct->c_rfc934) goto skip_headers; /* - * output the content type and subtype - */ + ** output the content type and subtype + */ np = add (TYPE_FIELD, NULL); vp = concat (" ", ci->ci_type, "/", ci->ci_subtype, NULL); @@ -1427,9 +1452,9 @@ build_headers (CT ct) && ((struct exbody *) ct->c_ctparams)->eb_body; /* - * Append the attribute/value pairs to - * the end of the Content-Type line. - */ + ** Append the attribute/value pairs to + ** the end of the Content-Type line. + */ for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) { if (mailbody && !mh_strcasecmp (*ap, "body")) continue; @@ -1450,9 +1475,9 @@ build_headers (CT ct) } /* - * Append any RFC-822 comment to the end of - * the Content-Type line. - */ + ** Append any RFC-822 comment to the end of + ** the Content-Type line. + */ if (ci->ci_comment) { snprintf (buffer, sizeof(buffer), "(%s)", ci->ci_comment); if (len + 1 + (cc = 2 + strlen (ci->ci_comment)) >= CPERLIN) { @@ -1469,8 +1494,8 @@ build_headers (CT ct) add_header (ct, np, vp); /* - * output the Content-ID, unless disabled by -nocontentid - */ + ** output the Content-ID, unless disabled by -nocontentid + */ if (contentidsw && ct->c_id) { np = add (ID_FIELD, NULL); vp = concat (" ", ct->c_id, NULL); @@ -1478,8 +1503,8 @@ build_headers (CT ct) } /* - * output the Content-Description - */ + ** output the Content-Description + */ if (ct->c_descr) { np = add (DESCR_FIELD, NULL); vp = concat (" ", ct->c_descr, NULL); @@ -1487,8 +1512,8 @@ build_headers (CT ct) } /* - * output the Content-Disposition - */ + ** output the Content-Disposition + */ if (ct->c_dispo) { np = add (DISPO_FIELD, NULL); vp = concat (" ", ct->c_dispo, NULL); @@ -1497,16 +1522,16 @@ build_headers (CT ct) skip_headers: /* - * If this is the internal content structure for a - * "message/external", then we are done with the - * headers (since it has no body). - */ + ** If this is the internal content structure for a + ** "message/external", then we are done with the + ** headers (since it has no body). + */ if (ct->c_ctexbody) return OK; /* - * output the Content-MD5 - */ + ** output the Content-MD5 + */ if (checksw) { np = add (MD5_FIELD, NULL); vp = calculate_digest (ct, (ct->c_encoding == CE_QUOTED) ? 1 : 0); @@ -1514,8 +1539,8 @@ skip_headers: } /* - * output the Content-Transfer-Encoding - */ + ** output the Content-Transfer-Encoding + */ switch (ct->c_encoding) { case CE_7BIT: /* Nothing to output */ @@ -1568,8 +1593,8 @@ skip_headers: } /* - * Additional content specific header processing - */ + ** Additional content specific header processing + */ switch (ct->c_type) { case CT_MULTIPART: { @@ -1643,7 +1668,8 @@ calculate_digest (CT ct, int asciiP) } } else { while ((cc = fread (buffer, sizeof(*buffer), sizeof(buffer), in)) > 0) - MD5Update (&mdContext, (unsigned char *) buffer, (unsigned int) cc); + MD5Update (&mdContext, (unsigned char *) buffer, + (unsigned int) cc); } /* md5 finalization. Write digest and zero md5 context */ diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index 0cefa87..100f972 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -1,10 +1,10 @@ /* - * mhcachesbr.c -- routines to manipulate the MIME content cache - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhcachesbr.c -- routines to manipulate the MIME content cache +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -44,9 +44,9 @@ int rcachesw = CACHE_ASK; int wcachesw = CACHE_ASK; /* - * Location of public and private cache. These must - * be set before these routines are called. - */ +** Location of public and private cache. These must +** be set before these routines are called. +*/ char *cache_public; char *cache_private; @@ -62,23 +62,23 @@ void content_error (char *, CT, char *, ...); void flush_errors (void); /* - * prototypes - */ +** prototypes +*/ void cache_all_messages (CT *); int find_cache (CT, int, int *, char *, char *, int); /* - * static prototypes - */ +** static prototypes +*/ static void cache_content (CT); static int find_cache_aux (int, char *, char *, char *, int); static int find_cache_aux2 (char *, char *, char *, int); /* - * Top level entry point to cache content - * from a group of messages - */ +** Top level entry point to cache content +** from a group of messages +*/ void cache_all_messages (CT *cts) @@ -102,8 +102,8 @@ cache_all_messages (CT *cts) /* - * Entry point to cache content from external sources. - */ +** Entry point to cache content from external sources. +*/ static void cache_content (CT ct) @@ -147,7 +147,8 @@ cache_content (CT ct) FILE *fp; if (debugsw) - fprintf (stderr, "caching by copying %s...\n", ce->ce_file); + fprintf (stderr, "caching by copying %s...\n", + ce->ce_file); file = NULL; if ((*ct->c_ceopenfnx) (ct, &file) == NOTOK) @@ -176,7 +177,8 @@ cache_content (CT ct) } fclose (fp); } else - content_error (cachefile, ct, "unable to fopen for writing"); + content_error (cachefile, ct, + "unable to fopen for writing"); reset_umask: umask (mask); } else { @@ -201,8 +203,9 @@ find_cache (CT ct, int policy, int *writing, char *id, id = trimcpy (id); if (debugsw) - fprintf (stderr, "find_cache %s(%d) %s %s\n", caches[policy].sw, - policy, writing ? "writing" : "reading", id); + fprintf (stderr, "find_cache %s(%d) %s %s\n", + caches[policy].sw, policy, + writing ? "writing" : "reading", id); switch (policy) { case CACHE_NEVER: diff --git a/uip/mhfree.c b/uip/mhfree.c index b9f15aa..356a4d7 100644 --- a/uip/mhfree.c +++ b/uip/mhfree.c @@ -1,11 +1,11 @@ /* - * mhfree.c -- routines to free the data structures used to - * -- represent MIME messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhfree.c -- routines to free the data structures used to +** -- represent MIME messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -16,8 +16,8 @@ CT *cts = NULL; /* - * prototypes - */ +** prototypes +*/ void free_content (CT); void free_header (CT); void free_ctinfo (CT); @@ -25,8 +25,8 @@ void free_encoding (CT, int); void freects_done (int); /* - * static prototypes - */ +** static prototypes +*/ static void free_text (CT); static void free_multi (CT); static void free_partial (CT); @@ -34,8 +34,8 @@ static void free_external (CT); /* - * Primary routine to free a MIME content structure - */ +** Primary routine to free a MIME content structure +*/ void free_content (CT ct) @@ -44,8 +44,8 @@ free_content (CT ct) return; /* - * free all the header fields - */ + ** free all the header fields + */ free_header (ct); if (ct->c_partno) @@ -60,9 +60,9 @@ free_content (CT ct) free_ctinfo (ct); /* - * some of the content types have extra - * parts which need to be freed. - */ + ** some of the content types have extra + ** parts which need to be freed. + */ switch (ct->c_type) { case CT_MULTIPART: free_multi (ct); @@ -123,9 +123,9 @@ free_content (CT ct) /* - * Free the linked list of header fields - * for this content. - */ +** Free the linked list of header fields +** for this content. +*/ void free_header (CT ct) @@ -251,9 +251,9 @@ free_external (CT ct) /* - * Free data structures related to encoding/decoding - * Content-Transfer-Encodings. - */ +** Free data structures related to encoding/decoding +** Content-Transfer-Encodings. +*/ void free_encoding (CT ct, int toplevel) diff --git a/uip/mhl.c b/uip/mhl.c index 7914b5f..743f22b 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -1,10 +1,10 @@ /* - * mhl.c -- the nmh message listing program - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhl.c -- the nmh message listing program +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/uip/mhlist.c b/uip/mhlist.c index 1cd8357..91b11e7 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -1,10 +1,10 @@ /* - * mhlist.c -- list the contents of MIME messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhlist.c -- list the contents of MIME messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -56,8 +56,8 @@ static struct swit switches[] = { { "help", 0 }, /* - * switches for debugging - */ +** switches for debugging +*/ #define DEBUGSW 15 { "debug", -5 }, { NULL, 0 } @@ -81,9 +81,9 @@ extern char *types[NTYPES + 1]; extern int userrs; /* - * This is currently needed to keep mhparse happy. - * This needs to be changed. - */ +** This is currently needed to keep mhparse happy. +** This needs to be changed. +*/ pid_t xpid = 0; int debugsw = 0; @@ -109,8 +109,8 @@ extern CT *cts; void freects_done (int) NORETURN; /* - * static prototypes - */ +** static prototypes +*/ static RETSIGTYPE pipeser (int); @@ -140,8 +140,8 @@ main (int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -260,10 +260,10 @@ do_cache: cache_private = getcpy (m_maildir (cache_private)); /* - * Check for storage directory. If specified, - * then store temporary files there. Else we - * store them in standard nmh directory. - */ + ** Check for storage directory. If specified, + ** then store temporary files there. Else we + ** store them in standard nmh directory. + */ if ((cp = context_find (nmhstorage)) && *cp) tmp = concat (cp, "/", invo_name, NULL); else @@ -276,8 +276,8 @@ do_cache: adios (NULL, "cannot specify msg and file at same time!"); /* - * check if message is coming from file - */ + ** check if message is coming from file + */ if (file) { if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts)))) adios (NULL, "out of memory"); @@ -287,8 +287,8 @@ do_cache: *ctp++ = ct; } else { /* - * message(s) are coming from a folder - */ + ** message(s) are coming from a folder + */ if (!msgs.size) app_msgarg(&msgs, "cur"); if (!folder) @@ -312,7 +312,8 @@ do_cache: done (1); seq_setprev (mp); /* set the previous-sequence */ - if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts)))) + if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), + sizeof(*cts)))) adios (NULL, "out of memory"); ctp = cts; @@ -335,8 +336,8 @@ do_cache: SIGNAL (SIGPIPE, pipeser); /* - * Get the associated umask for the relevant contents. - */ + ** Get the associated umask for the relevant contents. + */ for (ctp = cts; *ctp; ctp++) { struct stat st; @@ -350,8 +351,8 @@ do_cache: } /* - * List the message content - */ + ** List the message content + */ list_all_messages (cts, headsw, sizesw, verbosw, debugsw); /* Now free all the structures for the content */ diff --git a/uip/mhlistsbr.c b/uip/mhlistsbr.c index e5fecd6..80c9ad6 100644 --- a/uip/mhlistsbr.c +++ b/uip/mhlistsbr.c @@ -1,11 +1,11 @@ /* - * mhlistsbr.c -- routines to list information about the - * -- contents of MIME messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhlistsbr.c -- routines to list information about the +** -- contents of MIME messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -24,15 +24,15 @@ int type_ok (CT, int); void flush_errors (void); /* - * prototypes - */ +** prototypes +*/ void list_all_messages (CT *, int, int, int, int); int list_switch (CT, int, int, int, int); int list_content (CT, int, int, int, int); /* - * static prototypes - */ +** static prototypes +*/ static void list_single_message (CT, int, int, int); static int list_debug (CT); static int list_multi (CT, int, int, int, int); @@ -43,8 +43,8 @@ static int list_encoding (CT); /* - * various formats for -list option - */ +** various formats for -list option +*/ #define LSTFMT1 "%4s %-5s %-24s %5s %-36s\n" #define LSTFMT2a "%4d " #define LSTFMT2b "%-5s %-24.24s " @@ -57,8 +57,8 @@ static int list_encoding (CT); /* - * Top level entry point to list group of messages - */ +** Top level entry point to list group of messages +*/ void list_all_messages (CT *cts, int headers, int realsize, int verbose, int debug) @@ -78,8 +78,8 @@ list_all_messages (CT *cts, int headers, int realsize, int verbose, int debug) /* - * Entry point to list a single message - */ +** Entry point to list a single message +*/ static void list_single_message (CT ct, int realsize, int verbose, int debug) @@ -98,8 +98,8 @@ list_single_message (CT ct, int realsize, int verbose, int debug) /* - * Primary switching routine to list information about a content - */ +** Primary switching routine to list information about a content +*/ int list_switch (CT ct, int toplevel, int realsize, int verbose, int debug) @@ -150,8 +150,8 @@ list_switch (CT ct, int toplevel, int realsize, int verbose, int debug) #define empty(s) ((s) ? (s) : "") /* - * Method for listing information about a simple/generic content - */ +** Method for listing information about a simple/generic content +*/ int list_content (CT ct, int toplevel, int realsize, int verbose, int debug) @@ -206,9 +206,9 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug) printf ("\n"); /* - * If verbose, print any RFC-822 comments in the - * Content-Type line. - */ + ** If verbose, print any RFC-822 comments in the + ** Content-Type line. + */ if (verbose && ci->ci_comment) { char *dp; @@ -227,8 +227,8 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug) /* - * Print debugging information about a content - */ +** Print debugging information about a content +*/ static int list_debug (CT ct) @@ -297,8 +297,8 @@ list_debug (CT ct) /* - * list content information for type "multipart" - */ +** list content information for type "multipart" +*/ static int list_multi (CT ct, int toplevel, int realsize, int verbose, int debug) @@ -322,8 +322,8 @@ list_multi (CT ct, int toplevel, int realsize, int verbose, int debug) /* - * list content information for type "message/partial" - */ +** list content information for type "message/partial" +*/ static int list_partial (CT ct, int toplevel, int realsize, int verbose, int debug) @@ -332,7 +332,8 @@ list_partial (CT ct, int toplevel, int realsize, int verbose, int debug) list_content (ct, toplevel, realsize, verbose, debug); if (verbose) { - printf ("\t [message %s, part %d", p->pm_partid, p->pm_partno); + printf ("\t [message %s, part %d", + p->pm_partid, p->pm_partno); if (p->pm_maxno) printf (" of %d", p->pm_maxno); printf ("]\n"); @@ -343,8 +344,8 @@ list_partial (CT ct, int toplevel, int realsize, int verbose, int debug) /* - * list content information for type "message/external" - */ +** list content information for type "message/external" +*/ static int list_external (CT ct, int toplevel, int realsize, int verbose, int debug) @@ -382,9 +383,9 @@ list_external (CT ct, int toplevel, int realsize, int verbose, int debug) } /* - * Now list the information for the external content - * to which this content points. - */ + ** Now list the information for the external content + ** to which this content points. + */ list_content (e->eb_content, 0, realsize, verbose, debug); return OK; @@ -392,8 +393,8 @@ list_external (CT ct, int toplevel, int realsize, int verbose, int debug) /* - * list content information for type "application" - */ +** list content information for type "application" +*/ static int list_application (CT ct, int toplevel, int realsize, int verbose, int debug) @@ -412,9 +413,9 @@ list_application (CT ct, int toplevel, int realsize, int verbose, int debug) /* - * list information about the Content-Transfer-Encoding - * used by a content. - */ +** list information about the Content-Transfer-Encoding +** used by a content. +*/ static int list_encoding (CT ct) diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index e7f34c2..fbd2503 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -1,10 +1,10 @@ /* - * mhlsbr.c -- main routines for nmh message lister - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhlsbr.c -- main routines for nmh message lister +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -16,23 +16,23 @@ #include /* - * MAJOR BUG: - * for a component containing addresses, ADDRFMT, if COMPRESS is also - * set, then addresses get split wrong (not at the spaces between commas). - * To fix this correctly, putstr() should know about "atomic" strings that - * must NOT be broken across lines. That's too difficult for right now - * (it turns out that there are a number of degernate cases), so in - * oneline(), instead of - * - * (*onelp == '\n' && !onelp[1]) - * - * being a terminating condition, - * - * (*onelp == '\n' && (!onelp[1] || (flags & ADDRFMT))) - * - * is used instead. This cuts the line prematurely, and gives us a much - * better chance of getting things right. - */ +** MAJOR BUG: +** for a component containing addresses, ADDRFMT, if COMPRESS is also +** set, then addresses get split wrong (not at the spaces between commas). +** To fix this correctly, putstr() should know about "atomic" strings that +** must NOT be broken across lines. That's too difficult for right now +** (it turns out that there are a number of degernate cases), so in +** oneline(), instead of +** +** (*onelp == '\n' && !onelp[1]) +** +** being a terminating condition, +** +** (*onelp == '\n' && (!onelp[1] || (flags & ADDRFMT))) +** +** is used instead. This cuts the line prematurely, and gives us a much +** better chance of getting things right. +*/ #define ONECOMP 0 #define TWOCOMP 1 @@ -245,15 +245,15 @@ static FILE *(*mhl_action) () = (FILE *(*) ()) 0; /* - * Redefine a couple of functions. - * These are undefined later in the code. - */ +** Redefine a couple of functions. +** These are undefined later in the code. +*/ #define adios mhladios #define done mhldone /* - * prototypes - */ +** prototypes +*/ static void mhl_format (char *, int, int); static int evalvar (struct mcomp *); static int ptoi (char *, int *); @@ -264,7 +264,8 @@ static void mhlfile (FILE *, char *, int, int); static int mcomp_flags (char *); static char *mcomp_add (long, char *, char *); static void mcomp_format (struct mcomp *, struct mcomp *); -static struct mcomp *add_queue (struct mcomp **, struct mcomp **, char *, char *, int); +static struct mcomp *add_queue (struct mcomp **, struct mcomp **, + char *, char *, int); static void free_queue (struct mcomp **, struct mcomp **); static void putcomp (struct mcomp *, struct mcomp *, int); static char *oneline (char *, long); @@ -557,10 +558,10 @@ mhl_format (char *file, int length, int width) case ',': case '=': /* - * Split this list of fields to ignore, - * and copy it to the end of the current - * "ignores" list. - */ + ** Split this list of fields to ignore, + ** and copy it to the end of the current + ** "ignores" list. + */ if (!mh_strcasecmp (name, "ignores")) { char **tmparray, **p; int n = 0; @@ -573,7 +574,10 @@ mhl_format (char *file, int length, int width) while (*p++) n++; - /* copy pointers to split fields to ignores array */ + /* + ** copy pointers to split fields + ** to ignores array + */ ip = copyip (tmparray, ip, MAXARGS - num_ignores); num_ignores += n; continue; @@ -1413,9 +1417,9 @@ putch (char ch) default: /* - * If we are forwarding this message, and the first - * column contains a dash, then add a dash and a space. - */ + ** If we are forwarding this message, and the first + ** column contains a dash, then add a dash and a space. + */ if (column == 0 && forwflg && (dashstuff >= 0) && ch == '-') { putchar ('-'); putchar (' '); @@ -1501,10 +1505,10 @@ face_format (struct mcomp *c1) /* - * faceproc is two elements defining the image agent's location: - * Internet host - * UDP port - */ +** faceproc is two elements defining the image agent's location: +** Internet host +** UDP port +*/ #include #include @@ -1568,9 +1572,9 @@ bad_faceproc: ; } /* - * COMMENTED OUT - * This version doesn't use sockets - */ +** COMMENTED OUT +** This version doesn't use sockets +*/ #if 0 static int @@ -1694,9 +1698,9 @@ mhlsbr (int argc, char **argv, FILE *(*action)()) mhl_action = action; /* - * If signal is at default action, then start ignoring - * it, else let it set to its current action. - */ + ** If signal is at default action, then start ignoring + ** it, else let it set to its current action. + */ if ((istat = SIGNAL (SIGINT, SIG_IGN)) != SIG_DFL) SIGNAL (SIGINT, istat); if ((qstat = SIGNAL (SIGQUIT, SIG_IGN)) != SIG_DFL) @@ -1707,7 +1711,10 @@ mhlsbr (int argc, char **argv, FILE *(*action)()) default: SIGNAL (SIGINT, istat); SIGNAL (SIGQUIT, qstat); - SIGNAL (SIGPIPE, SIG_IGN); /* should probably change to block instead */ + SIGNAL (SIGPIPE, SIG_IGN); /* + ** should probably change to block + ** instead + */ if (ontty == PITTY) m_pclose (); SIGNAL (SIGPIPE, pstat); diff --git a/uip/mhmail.c b/uip/mhmail.c index 4939b02..12a0bb5 100644 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@ -1,10 +1,10 @@ /* - * mhmail.c -- simple mail program - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhmail.c -- simple mail program +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -34,8 +34,8 @@ static struct swit switches[] = { static char tmpfil[BUFSIZ]; /* - * static prototypes - */ +** static prototypes +*/ static RETSIGTYPE intrser (int); @@ -147,7 +147,8 @@ main (int argc, char **argv) fputs ("\n", out); } else { for (somebody = 0; - (i = fread (buf, sizeof(*buf), sizeof(buf), stdin)) > 0; + (i = fread (buf, sizeof(*buf), sizeof(buf), + stdin)) > 0; somebody++) if (fwrite (buf, sizeof(*buf), i, out) != i) adios (tmpfil, "error writing"); diff --git a/uip/mhmisc.c b/uip/mhmisc.c index c32157f..869fe1c 100644 --- a/uip/mhmisc.c +++ b/uip/mhmisc.c @@ -1,10 +1,10 @@ /* - * mhparse.c -- misc routines to process MIME messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhparse.c -- misc routines to process MIME messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -15,8 +15,8 @@ extern int debugsw; /* - * limit actions to specified parts or content types - */ +** limit actions to specified parts or content types +*/ int npart = 0; int ntype = 0; char *parts[NPARTS + 1]; @@ -29,8 +29,8 @@ static char *errs = NULL; /* - * prototypes - */ +** prototypes +*/ int part_ok (CT, int); int type_ok (CT, int); void set_endian (void); @@ -133,8 +133,8 @@ losing_directory: /* - * Construct error message for content - */ +** Construct error message for content +*/ void content_error (char *what, CT ct, char *fmt, ...) diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index e354958..e0a8cfa 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -1,11 +1,11 @@ /* - * mhoutsbr.c -- routines to output MIME messages - * -- given a Content structure - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhoutsbr.c -- routines to output MIME messages +** -- given a Content structure +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -64,15 +64,15 @@ static char nib2b64[0x40+1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* - * prototypes - */ +** prototypes +*/ int output_message (CT, char *); int output_message_fp (CT, FILE *, char *); int writeBase64aux (FILE *, FILE *); /* - * static prototypes - */ +** static prototypes +*/ static int output_content (CT, FILE *); static void output_headers (CT, FILE *); static int writeExternalBody (CT, FILE *); @@ -82,10 +82,10 @@ static int writeBase64 (CT, FILE *); /* - * Main routine to output a MIME message contained - * in a Content structure, to a file. Any necessary - * transfer encoding is added. - */ +** Main routine to output a MIME message contained +** in a Content structure, to a file. Any necessary +** transfer encoding is added. +*/ int output_message_fp (CT ct, FILE *fp, char *file) @@ -117,8 +117,8 @@ output_message (CT ct, char *file) /* - * Output a Content structure to a file. - */ +** Output a Content structure to a file. +*/ static int output_content (CT ct, FILE *out) @@ -127,21 +127,21 @@ output_content (CT ct, FILE *out) CI ci = &ct->c_ctinfo; /* - * Output all header fields for this content - */ + ** Output all header fields for this content + */ output_headers (ct, out); /* - * If this is the internal content structure for a - * "message/external", then we are done with the - * headers (since it has no body). - */ + ** If this is the internal content structure for a + ** "message/external", then we are done with the + ** headers (since it has no body). + */ if (ct->c_ctexbody) return OK; /* - * Now output the content bodies. - */ + ** Now output the content bodies. + */ switch (ct->c_type) { case CT_MULTIPART: { @@ -181,8 +181,8 @@ output_content (CT ct, FILE *out) break; /* - * Handle discrete types (text/application/audio/image/video) - */ + ** Handle discrete types (text/application/audio/image/video) + */ default: switch (ct->c_encoding) { case CE_7BIT: @@ -223,8 +223,8 @@ output_content (CT ct, FILE *out) /* - * Output all the header fields for a content - */ +** Output all the header fields for a content +*/ static void output_headers (CT ct, FILE *out) @@ -240,8 +240,8 @@ output_headers (CT ct, FILE *out) /* - * Write the phantom body for access-type "mail-server". - */ +** Write the phantom body for access-type "mail-server". +*/ static int writeExternalBody (CT ct, FILE *out) @@ -309,8 +309,8 @@ writeExternalBody (CT ct, FILE *out) /* - * Output a content without any transfer encoding - */ +** Output a content without any transfer encoding +*/ static int write8Bit (CT ct, FILE *out) @@ -337,8 +337,8 @@ write8Bit (CT ct, FILE *out) /* - * Output a content using quoted-printable - */ +** Output a content using quoted-printable +*/ static int writeQuoted (CT ct, FILE *out) @@ -410,8 +410,8 @@ three_print: /* - * Output a content using base64 - */ +** Output a content using base64 +*/ static int writeBase64 (CT ct, FILE *out) diff --git a/uip/mhparam.c b/uip/mhparam.c index 4d00717..f92a3ec 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -1,13 +1,13 @@ /* - * mhparam.c -- print mh_profile values - * - * Originally contributed by - * Jeffrey C Honig - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhparam.c -- print mh_profile values +** +** Originally contributed by +** Jeffrey C Honig +** +** This code is 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 @@ -70,8 +70,8 @@ static struct proc procs [] = { /* - * static prototypes - */ +** static prototypes +*/ static char *p_find(char *); @@ -148,12 +148,13 @@ main(int argc, char **argv) struct proc *ps; /* - * Print the current value of everything in - * procs array. This will show their current - * value (as determined after context is read). - */ + ** Print the current value of everything in + ** procs array. This will show their current + ** value (as determined after context is read). + */ for (ps = procs; ps->p_name; ps++) - printf ("%s: %s\n", ps->p_name, *ps->p_field ? *ps->p_field : ""); + printf ("%s: %s\n", ps->p_name, + *ps->p_field ? *ps->p_field : ""); } else { if (components < 0) diff --git a/uip/mhparse.c b/uip/mhparse.c index c72c415..62fc765 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -1,10 +1,10 @@ /* - * mhparse.c -- routines to parse the contents of MIME messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhparse.c -- routines to parse the contents of MIME messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -37,14 +37,14 @@ extern int wcachesw; /* mhcachesbr.c */ int checksw = 0; /* check Content-MD5 field */ /* - * Directory to place temp files. This must - * be set before these routines are called. - */ +** Directory to place temp files. This must +** be set before these routines are called. +*/ char *tmp; /* - * Structures for TEXT messages - */ +** Structures for TEXT messages +*/ struct k2v SubText[] = { { "plain", TEXT_PLAIN }, { "richtext", TEXT_RICHTEXT }, /* defined in RFC-1341 */ @@ -59,8 +59,8 @@ struct k2v Charset[] = { }; /* - * Structures for MULTIPART messages - */ +** Structures for MULTIPART messages +*/ struct k2v SubMultiPart[] = { { "mixed", MULTI_MIXED }, { "alternative", MULTI_ALTERNATE }, @@ -70,8 +70,8 @@ struct k2v SubMultiPart[] = { }; /* - * Structures for MESSAGE messages - */ +** Structures for MESSAGE messages +*/ struct k2v SubMessage[] = { { "rfc822", MESSAGE_RFC822 }, { "partial", MESSAGE_PARTIAL }, @@ -80,8 +80,8 @@ struct k2v SubMessage[] = { }; /* - * Structure for APPLICATION messages - */ +** Structure for APPLICATION messages +*/ struct k2v SubApplication[] = { { "octet-stream", APPLICATION_OCTETS }, { "postscript", APPLICATION_POSTSCRIPT }, @@ -106,8 +106,8 @@ void free_content (CT); void free_encoding (CT, int); /* - * static prototypes - */ +** static prototypes +*/ static CT get_content (FILE *, char *, int); static int get_comment (CT, unsigned char **, int); @@ -156,10 +156,10 @@ struct str2init str2ces[] = { }; /* - * NOTE WELL: si_key MUST NOT have value of NOTOK - * - * si_key is 1 if access method is anonymous. - */ +** NOTE WELL: si_key MUST NOT have value of NOTOK +** +** si_key is 1 if access method is anonymous. +*/ struct str2init str2methods[] = { { "afs", 1, InitFile }, { "anon-ftp", 1, InitFTP }, @@ -184,10 +184,10 @@ pidcheck (int status) /* - * Main entry point for parsing a MIME message or file. - * It returns the Content structure for the top level - * entity in the file. - */ +** Main entry point for parsing a MIME message or file. +** It returns the Content structure for the top level +** entity in the file. +*/ CT parse_mime (char *file) { @@ -197,8 +197,8 @@ parse_mime (char *file) CT ct; /* - * Check if file is actually standard input - */ + ** Check if file is actually standard input + */ if ((is_stdin = !(strcmp (file, "-")))) { char *tfile = m_mktemp2(NULL, invo_name, NULL, &fp); if (tfile == NULL) { @@ -257,15 +257,15 @@ parse_mime (char *file) /* - * Main routine for reading/parsing the headers - * of a message content. - * - * toplevel = 1 # we are at the top level of the message - * toplevel = 0 # we are inside message type or multipart type - * # other than multipart/digest - * toplevel = -1 # we are inside multipart/digest - * NB: on failure we will fclose(in)! - */ +** Main routine for reading/parsing the headers +** of a message content. +** +** toplevel = 1 # we are at the top level of the message +** toplevel = 0 # we are inside message type or multipart type +** # other than multipart/digest +** toplevel = -1 # we are inside multipart/digest +** NB: on failure we will fclose(in)! +*/ static CT get_content (FILE *in, char *file, int toplevel) @@ -285,9 +285,9 @@ get_content (FILE *in, char *file, int toplevel) ct->c_begin = ftell (ct->c_fp) + 1; /* - * Parse the header fields for this - * content into a linked list. - */ + ** Parse the header fields for this + ** content into a linked list. + */ for (compnum = 1, state = FLD;;) { switch (state = m_getfld (state, name, buf, sizeof(buf), in)) { case FLD: @@ -337,11 +337,11 @@ get_content (FILE *in, char *file, int toplevel) } /* - * Read the content headers. We will parse the - * MIME related header fields into their various - * structures and set internal flags related to - * content type/subtype, etc. - */ + ** Read the content headers. We will parse the + ** MIME related header fields into their various + ** structures and set internal flags related to + ** content type/subtype, etc. + */ hp = ct->c_first_hf; /* start at first header field */ while (hp) { @@ -385,9 +385,9 @@ get_content (FILE *in, char *file, int toplevel) admonish (NULL, "message %s has unknown value for %s: field (%s)", ct->c_file, VRSN_FIELD, cp); } - } - else if (!mh_strcasecmp (hp->name, TYPE_FIELD)) { - /* Get Content-Type field */ + + } else if (!mh_strcasecmp (hp->name, TYPE_FIELD)) { + /* Get Content-Type field */ struct str2init *s2i; CI ci = &ct->c_ctinfo; @@ -403,9 +403,9 @@ get_content (FILE *in, char *file, int toplevel) goto out; /* - * Set the Init function and the internal - * flag for this content type. - */ + ** Set the Init function and the internal + ** flag for this content type. + */ for (s2i = str2cts; s2i->si_key; s2i++) if (!mh_strcasecmp (ci->ci_type, s2i->si_key)) break; @@ -413,17 +413,17 @@ get_content (FILE *in, char *file, int toplevel) s2i++; ct->c_type = s2i->si_val; ct->c_ctinitfnx = s2i->si_init; - } - else if (!mh_strcasecmp (hp->name, ENCODING_FIELD)) { - /* Get Content-Transfer-Encoding field */ + + } else if (!mh_strcasecmp (hp->name, ENCODING_FIELD)) { + /* Get Content-Transfer-Encoding field */ char c; unsigned char *cp, *dp; struct str2init *s2i; /* - * Check if we've already seen the - * Content-Transfer-Encoding field - */ + ** Check if we've already seen the + ** Content-Transfer-Encoding field + */ if (ct->c_celine) { advise (NULL, "message %s has multiple %s: fields", ct->c_file, ENCODING_FIELD); @@ -441,9 +441,9 @@ get_content (FILE *in, char *file, int toplevel) *dp = '\0'; /* - * Find the internal flag and Init function - * for this transfer encoding. - */ + ** Find the internal flag and Init function + ** for this transfer encoding. + */ for (s2i = str2ces; s2i->si_key; s2i++) if (!mh_strcasecmp (cp, s2i->si_key)) break; @@ -455,9 +455,9 @@ get_content (FILE *in, char *file, int toplevel) /* Call the Init function for this encoding */ if (s2i->si_init && (*s2i->si_init) (ct) == NOTOK) goto out; - } - else if (!mh_strcasecmp (hp->name, MD5_FIELD)) { - /* Get Content-MD5 field */ + + } else if (!mh_strcasecmp (hp->name, MD5_FIELD)) { + /* Get Content-MD5 field */ unsigned char *cp, *dp; char *ep; @@ -495,17 +495,17 @@ get_content (FILE *in, char *file, int toplevel) readDigest (ct, cp); free (ep); ct->c_digested++; - } - else if (!mh_strcasecmp (hp->name, ID_FIELD)) { - /* Get Content-ID field */ + + } else if (!mh_strcasecmp (hp->name, ID_FIELD)) { + /* Get Content-ID field */ ct->c_id = add (hp->value, ct->c_id); - } - else if (!mh_strcasecmp (hp->name, DESCR_FIELD)) { - /* Get Content-Description field */ + + } else if (!mh_strcasecmp (hp->name, DESCR_FIELD)) { + /* Get Content-Description field */ ct->c_descr = add (hp->value, ct->c_descr); - } - else if (!mh_strcasecmp (hp->name, DISPO_FIELD)) { - /* Get Content-Disposition field */ + + } else if (!mh_strcasecmp (hp->name, DISPO_FIELD)) { + /* Get Content-Disposition field */ ct->c_dispo = add (hp->value, ct->c_dispo); } @@ -514,15 +514,15 @@ next_header: } /* - * Check if we saw a Content-Type field. - * If not, then assign a default value for - * it, and the Init function. - */ + ** Check if we saw a Content-Type field. + ** If not, then assign a default value for + ** it, and the Init function. + */ if (!ct->c_ctline) { /* - * If we are inside a multipart/digest message, - * so default type is message/rfc822 - */ + ** If we are inside a multipart/digest message, + ** so default type is message/rfc822 + */ if (toplevel < 0) { if (get_ctinfo ("message/rfc822", ct, 0) == NOTOK) goto out; @@ -530,8 +530,8 @@ next_header: ct->c_ctinitfnx = InitMessage; } else { /* - * Else default type is text/plain - */ + ** Else default type is text/plain + */ if (get_ctinfo ("text/plain", ct, 0) == NOTOK) goto out; ct->c_type = CT_TEXT; @@ -554,8 +554,8 @@ out: /* - * small routine to add header field to list - */ +** small routine to add header field to list +*/ int add_header (CT ct, char *name, char *value) @@ -583,13 +583,15 @@ add_header (CT ct, char *name, char *value) } -/* Make sure that buf contains at least one appearance of name, - followed by =. If not, insert both name and value, just after - first semicolon, if any. Note that name should not contain a - trailing =. And quotes will be added around the value. Typical - usage: make sure that a Content-Disposition header contains - filename="foo". If it doesn't and value does, use value from - that. */ +/* +** Make sure that buf contains at least one appearance of name, +** followed by =. If not, insert both name and value, just after +** first semicolon, if any. Note that name should not contain a +** trailing =. And quotes will be added around the value. Typical +** usage: make sure that a Content-Disposition header contains +** filename="foo". If it doesn't and value does, use value from +** that. +*/ static char * incl_name_value (unsigned char *buf, char *name, char *value) { char *newbuf = buf; @@ -610,15 +612,19 @@ incl_name_value (unsigned char *buf, char *name, char *value) { *cp = '\0'; } - insertion = concat ("; ", name, "=", "\"", value, "\"", NULL); + insertion = concat ("; ", name, "=", "\"", value, "\"", + NULL); - /* Insert at first semicolon, if any. If none, append to - end. */ + /* + ** Insert at first semicolon, if any. + ** If none, append to end. + */ prefix = add (buf, NULL); if ((cp = strchr (prefix, ';'))) { suffix = concat (cp, NULL); *cp = '\0'; - newbuf = concat (prefix, insertion, suffix, "\n", NULL); + newbuf = concat (prefix, insertion, suffix, + "\n", NULL); free (suffix); } else { /* Append to end. */ @@ -636,9 +642,11 @@ incl_name_value (unsigned char *buf, char *name, char *value) { return newbuf; } -/* Extract just name_suffix="foo", if any, from value. If there isn't - one, return the entire value. Note that, for example, a name_suffix - of name will match filename="foo", and return foo. */ +/* +** Extract just name_suffix="foo", if any, from value. If there isn't +** one, return the entire value. Note that, for example, a name_suffix +** of name will match filename="foo", and return foo. +*/ static char * extract_name_value (char *name_suffix, char *value) { char *extracted_name_value = value; @@ -666,9 +674,9 @@ extract_name_value (char *name_suffix, char *value) { } /* - * Parse Content-Type line and (if `magic' is non-zero) mhbuild composition - * directives. Fills in the information of the CTinfo structure. - */ +** Parse Content-Type line and (if `magic' is non-zero) mhbuild composition +** directives. Fills in the information of the CTinfo structure. +*/ int get_ctinfo (unsigned char *cp, CT ct, int magic) { @@ -711,7 +719,7 @@ get_ctinfo (unsigned char *cp, CT ct, int magic) if (!*ci->ci_type) { advise (NULL, "invalid %s: field in message %s (empty type)", - TYPE_FIELD, ct->c_file); + TYPE_FIELD, ct->c_file); return NOTOK; } @@ -765,8 +773,8 @@ magic_skip: return NOTOK; /* - * Parse attribute/value pairs given with Content-Type - */ + ** Parse attribute/value pairs given with Content-Type + */ ep = (ap = ci->ci_attrs) + NPARMS; while (*cp == ';') { char *vp; @@ -862,8 +870,8 @@ bad_quote: } /* - * Get any given in buffer - */ + ** Get any given in buffer + */ if (magic && *cp == '<') { if (ct->c_id) { free (ct->c_id); @@ -887,8 +895,8 @@ bad_quote: } /* - * Get any [Content-Description] given in buffer. - */ + ** Get any [Content-Description] given in buffer. + */ if (magic && *cp == '[') { ct->c_descr = ++cp; for (dp = cp + strlen (cp) - 1; dp >= cp; dp--) @@ -914,8 +922,8 @@ bad_quote: } /* - * Get any {Content-Disposition} given in buffer. - */ + ** Get any {Content-Disposition} given in buffer. + */ if (magic && *cp == '{') { ct->c_dispo = ++cp; for (dp = cp + strlen (cp) - 1; dp >= cp; dp--) @@ -941,18 +949,18 @@ bad_quote: } /* - * Check if anything is left over - */ + ** Check if anything is left over + */ if (*cp) { if (magic) { ci->ci_magic = add (cp, NULL); /* - * If there is a Content-Disposition header and - * it doesn't have a *filename=, extract it from - * the magic contents. The r1bindex call skips - * any leading directory components. - */ + ** If there is a Content-Disposition header and + ** it doesn't have a *filename=, extract it from + ** the magic contents. The r1bindex call skips + ** any leading directory components. + */ if (ct->c_dispo) ct->c_dispo = incl_name_value (ct->c_dispo, "filename", r1bindex (extract_name_value ("name", ci->ci_magic), '/')); } else @@ -1029,11 +1037,11 @@ invalid: /* - * CONTENTS - * - * Handles content types audio, image, and video. - * There's not much to do right here. - */ +** CONTENTS +** +** Handles content types audio, image, and video. +** There's not much to do right here. +*/ static int InitGeneric (CT ct) @@ -1043,8 +1051,8 @@ InitGeneric (CT ct) /* - * TEXT - */ +** TEXT +*/ static int InitText (CT ct) @@ -1091,12 +1099,12 @@ InitText (CT ct) } /* - * If we can not handle character set natively, - * then check profile for string to modify the - * terminal or display method. - * - * termproc is for mhshow, though mhlist -debug prints it, too. - */ + ** If we can not handle character set natively, + ** then check profile for string to modify the + ** terminal or display method. + ** + ** termproc is for mhshow, though mhlist -debug prints it, too. + */ if (chset != NULL && !check_charset (chset, strlen (chset))) { snprintf (buffer, sizeof(buffer), "%s-charset-%s", invo_name, chset); if ((cp = context_find (buffer))) @@ -1108,8 +1116,8 @@ InitText (CT ct) /* - * MULTIPART - */ +** MULTIPART +*/ static int InitMultiPart (CT ct) @@ -1127,9 +1135,9 @@ InitMultiPart (CT ct) FILE *fp; /* - * The encoding for multipart messages must be either - * 7bit, 8bit, or binary (per RFC2045). - */ + ** The encoding for multipart messages must be either + ** 7bit, 8bit, or binary (per RFC2045). + */ if (ct->c_encoding != CE_7BIT && ct->c_encoding != CE_8BIT && ct->c_encoding != CE_BINARY) { admonish (NULL, @@ -1145,9 +1153,9 @@ InitMultiPart (CT ct) ct->c_subtype = kv->kv_value; /* - * Check for "boundary" parameter, which is - * required for multipart messages. - */ + ** Check for "boundary" parameter, which is + ** required for multipart messages. + */ bp = 0; for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) { if (!mh_strcasecmp (*ap, "boundary")) { @@ -1264,9 +1272,9 @@ last_part: reverse_parts (ct); /* - * label all subparts with part number, and - * then initialize the content of the subpart. - */ + ** label all subparts with part number, and + ** then initialize the content of the subpart. + */ { int partnum; char *pp; @@ -1302,8 +1310,8 @@ last_part: /* - * reverse the order of the parts of a multipart - */ +** reverse the order of the parts of a multipart +*/ static void reverse_parts (CT ct) @@ -1348,8 +1356,8 @@ reverse_parts (CT ct) /* - * MESSAGE - */ +** MESSAGE +*/ static int InitMessage (CT ct) @@ -1387,7 +1395,10 @@ InitMessage (CT ct) adios (NULL, "out of memory"); ct->c_ctparams = (void *) p; - /* scan for parameters "id", "number", and "total" */ + /* + ** scan for parameters "id", "number", + ** and "total" + */ for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) { if (!mh_strcasecmp (*ap, "id")) { p->pm_partid = add (*ep, NULL); @@ -1594,8 +1605,8 @@ params_external (CT ct, int composing) /* - * APPLICATION - */ +** APPLICATION +*/ static int InitApplication (CT ct) @@ -1614,8 +1625,8 @@ InitApplication (CT ct) /* - * TRANSFER ENCODINGS - */ +** TRANSFER ENCODINGS +*/ static int init_encoding (CT ct, OpenCEFunc openfnx) @@ -1689,8 +1700,8 @@ size_encoding (CT ct) /* - * BASE64 - */ +** BASE64 +*/ static unsigned char b642nib[0x80] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -1772,8 +1783,10 @@ openBase64 (CT ct, char **file) } if (cp != NULL && *cp != '\0') { if (ce->ce_unlink) { - // Temporary file already exists, so we rename to - // version with extension. + /* + ** Temporary file already exists, so we rename to + ** version with extension. + */ char *file_org = strdup(ce->ce_file); ce->ce_file = add (cp, ce->ce_file); if (rename(file_org, ce->ce_file)) { @@ -1912,8 +1925,8 @@ clean_up: /* - * QUOTED PRINTABLE - */ +** QUOTED PRINTABLE +*/ static char hex2nib[0x80] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1962,7 +1975,8 @@ openQuoted (CT ct, char **file) if (ce->ce_file) { if ((ce->ce_fp = fopen (ce->ce_file, "r")) == NULL) { - content_error (ce->ce_file, ct, "unable to fopen for reading"); + content_error (ce->ce_file, ct, + "unable to fopen for reading"); return NOTOK; } goto ready_to_go; @@ -1993,7 +2007,8 @@ openQuoted (CT ct, char **file) char *file_org = strdup(ce->ce_file); ce->ce_file = add (cp, ce->ce_file); if (rename(file_org, ce->ce_file)) { - adios (ce->ce_file, "unable to rename %s to ", file_org); + adios (ce->ce_file, "unable to rename %s to ", + file_org); } free(file_org); @@ -2003,12 +2018,14 @@ openQuoted (CT ct, char **file) } if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { - content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); + content_error (ce->ce_file, ct, + "unable to fopen for reading/writing"); return NOTOK; } if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { - content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); + content_error (ce->ce_file, ct, + "unable to fopen for reading/writing"); return NOTOK; } @@ -2063,9 +2080,10 @@ openQuoted (CT ct, char **file) content_error (ce->ce_file, ct, "error writing to"); goto clean_up; } - /* finished escape sequence; next may - * be literal or a new escape - * sequence */ + /* + ** finished escape sequence; next may + ** be literal or a new escape sequence + */ quoted = 0; } /* on to next byte */ @@ -2074,24 +2092,37 @@ openQuoted (CT ct, char **file) /* not in an escape sequence */ if (*cp == '=') { - /* starting an escape sequence, or invalid '='? */ + /* + ** starting an escape sequence, + ** or invalid '='? + */ if (cp + 1 < ep && cp[1] == '\n') { /* "=\n" soft line break, eat the \n */ cp++; continue; } if (cp + 1 >= ep || cp + 2 >= ep) { - /* We don't have 2 bytes left, so this is an invalid - * escape sequence; just show the raw bytes (below). */ + /* + ** We don't have 2 bytes left, + ** so this is an invalid escape + ** sequence; just show the raw bytes + ** (below). + */ } else if (isxdigit (cp[1]) && isxdigit (cp[2])) { - /* Next 2 bytes are hex digits, making this a valid escape - * sequence; let's decode it (above). */ + /* + ** Next 2 bytes are hex digits, + ** making this a valid escape + ** sequence; let's decode it (above). + */ quoted = 1; continue; } else { - /* One or both of the next 2 is out of range, making this - * an invalid escape sequence; just show the raw bytes - * (below). */ + /* + ** One or both of the next 2 is + ** out of range, making this an + ** invalid escape sequence; just + ** show the raw bytes (below). + */ } } @@ -2148,8 +2179,8 @@ clean_up: /* - * 7BIT - */ +** 7BIT +*/ static int Init7Bit (CT ct) @@ -2180,7 +2211,8 @@ open7Bit (CT ct, char **file) if (ce->ce_file) { if ((ce->ce_fp = fopen (ce->ce_file, "r")) == NULL) { - content_error (ce->ce_file, ct, "unable to fopen for reading"); + content_error (ce->ce_file, ct, + "unable to fopen for reading"); return NOTOK; } goto ready_to_go; @@ -2206,12 +2238,15 @@ open7Bit (CT ct, char **file) } if (cp != NULL && *cp != '\0') { if (ce->ce_unlink) { - // Temporary file already exists, so we rename to - // version with extension. + /* + ** Temporary file already exists, so we rename to + ** version with extension. + */ char *file_org = strdup(ce->ce_file); ce->ce_file = add (cp, ce->ce_file); if (rename(file_org, ce->ce_file)) { - adios (ce->ce_file, "unable to rename %s to ", file_org); + adios (ce->ce_file, "unable to rename %s to ", + file_org); } free(file_org); @@ -2221,7 +2256,8 @@ open7Bit (CT ct, char **file) } if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { - content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); + content_error (ce->ce_file, ct, + "unable to fopen for reading/writing"); return NOTOK; } @@ -2230,14 +2266,16 @@ open7Bit (CT ct, char **file) CI ci = &ct->c_ctinfo; len = 0; - fprintf (ce->ce_fp, "%s: %s/%s", TYPE_FIELD, ci->ci_type, ci->ci_subtype); + fprintf (ce->ce_fp, "%s: %s/%s", TYPE_FIELD, ci->ci_type, + ci->ci_subtype); len += strlen (TYPE_FIELD) + 2 + strlen (ci->ci_type) + 1 + strlen (ci->ci_subtype); for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) { putc (';', ce->ce_fp); len++; - snprintf (buffer, sizeof(buffer), "%s=\"%s\"", *ap, *ep); + snprintf (buffer, sizeof(buffer), "%s=\"%s\"", + *ap, *ep); if (len + 1 + (cc = strlen (buffer)) >= CPERLIN) { fputs ("\n\t", ce->ce_fp); @@ -2323,8 +2361,8 @@ clean_up: /* - * External - */ +** External +*/ static int openExternal (CT ct, CT cb, CE ce, char **file, int *fd) @@ -2338,7 +2376,8 @@ openExternal (CT ct, CT cb, CE ce, char **file, int *fd) if (ce->ce_file) { if ((ce->ce_fp = fopen (ce->ce_file, "r")) == NULL) { - content_error (ce->ce_file, ct, "unable to fopen for reading"); + content_error (ce->ce_file, ct, + "unable to fopen for reading"); return NOTOK; } goto ready_already; @@ -2364,8 +2403,8 @@ ready_already: } /* - * File - */ +** File +*/ static int InitFile (CT ct) @@ -2442,8 +2481,8 @@ openFile (CT ct, char **file) } /* - * FTP - */ +** FTP +*/ static int InitFTP (CT ct) @@ -2504,8 +2543,8 @@ openFTP (CT ct, char **file) buflen = sizeof(buffer); /* - * Construct the query message for user - */ + ** Construct the query message for user + */ snprintf (bp, buflen, "Retrieve %s", e->eb_name); len = strlen (bp); bp += len; @@ -2533,14 +2572,15 @@ openFTP (CT ct, char **file) snprintf (bp, buflen, "? "); /* - * Now, check the answer - */ + ** Now, check the answer + */ if (!getanswer (buffer)) return NOTOK; if (e->eb_flags) { user = "anonymous"; - snprintf (buffer, sizeof(buffer), "%s@%s", getusername (), LocalName ()); + snprintf (buffer, sizeof(buffer), "%s@%s", getusername (), + LocalName ()); pass = buffer; } else { ruserpass (e->eb_site, &username, &password); @@ -2552,8 +2592,8 @@ openFTP (CT ct, char **file) caching = 0; cachefile[0] = '\0'; if ((!e->eb_permission || mh_strcasecmp (e->eb_permission, "read-write")) - && find_cache (NULL, wcachesw, &cachetype, e->eb_content->c_id, - cachefile, sizeof(cachefile)) != NOTOK) { + && find_cache (NULL, wcachesw, &cachetype, e->eb_content->c_id, + cachefile, sizeof(cachefile)) != NOTOK) { if (*file == NULL) { ce->ce_unlink = 0; caching = 1; @@ -2665,8 +2705,8 @@ losing_ftp: /* - * Mail - */ +** Mail +*/ static int InitMail (CT ct) @@ -2773,8 +2813,10 @@ openMail (CT ct, char **file) return NOTOK; } - /* showproc is for mhshow and mhstore, though mhlist -debug - * prints it, too. */ + /* + ** showproc is for mhshow and mhstore, though mhlist -debug + ** prints it, too. + */ if (ct->c_showproc) free (ct->c_showproc); ct->c_showproc = add ("true", NULL); @@ -2837,7 +2879,8 @@ test_end: } if (bitno != 18) { if (debugsw) - fprintf (stderr, "premature ending (bitno %d)\n", bitno); + fprintf (stderr, "premature ending (bitno %d)\n", + bitno); return NOTOK; } diff --git a/uip/mhpath.c b/uip/mhpath.c index aa38bbe..b658f29 100644 --- a/uip/mhpath.c +++ b/uip/mhpath.c @@ -1,10 +1,10 @@ /* - * mhpath.c -- print full pathnames of nmh messages and folders - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhpath.c -- print full pathnames of nmh messages and folders +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -39,8 +39,8 @@ main(int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -90,11 +90,11 @@ main(int argc, char **argv) adios (NULL, "unable to read folder %s", folder); /* - * We need to make sure there is message status space - * for all the message numbers from 1 to "new" since - * mhpath can select empty slots. If we are adding - * space at the end, we go ahead and add 10 slots. - */ + ** We need to make sure there is message status space + ** for all the message numbers from 1 to "new" since + ** mhpath can select empty slots. If we are adding + ** space at the end, we go ahead and add 10 slots. + */ if (mp->hghmsg >= mp->hghoff) { if (!(mp = folder_realloc (mp, 1, mp->hghmsg + 10))) adios (NULL, "unable to allocate folder storage"); diff --git a/uip/mhshow.c b/uip/mhshow.c index bbb7fb8..d55f2c6 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -1,10 +1,10 @@ /* - * mhshow.c -- display the contents of MIME messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhshow.c -- display the contents of MIME messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -58,8 +58,8 @@ static struct swit switches[] = { { "help", 0 }, /* - * switches for moreproc/mhlproc - */ +** switches for moreproc/mhlproc +*/ #define PROGSW 16 { "moreproc program", -4 }, #define NPROGSW 17 @@ -70,8 +70,8 @@ static struct swit switches[] = { { "width columns", -4 }, /* - * switches for debugging - */ +** switches for debugging +*/ #define DEBUGSW 20 { "debug", -5 }, { NULL, 0 } @@ -125,8 +125,8 @@ extern CT *cts; void freects_done (int) NORETURN; /* - * static prototypes - */ +** static prototypes +*/ static RETSIGTYPE pipeser (int); @@ -156,8 +156,8 @@ main (int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -183,7 +183,8 @@ main (int argc, char **argv) icachesw = &wcachesw; do_cache: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); switch (*icachesw = smatch (cp, caches)) { case AMBIGSW: ambigsw (cp, caches); @@ -218,7 +219,8 @@ do_cache: case PARTSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); if (npart >= NPARTS) adios (NULL, "too many parts (starting with %s), %d max", cp, NPARTS); @@ -227,7 +229,8 @@ do_cache: case TYPESW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); if (ntype >= NTYPES) adios (NULL, "too many types (starting with %s), %d max", cp, NTYPES); @@ -236,24 +239,27 @@ do_cache: case FILESW: if (!(cp = *argp++) || (*cp == '-' && cp[1])) - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); file = *cp == '-' ? cp : path (cp, TFILE); continue; case FORMSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); if (formsw) free (formsw); formsw = getcpy (etcpath (cp)); continue; /* - * Switches for moreproc/mhlproc - */ + ** Switches for moreproc/mhlproc + */ case PROGSW: if (!(progsw = *argp++) || *progsw == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case NPROGSW: nomore++; @@ -262,7 +268,8 @@ do_cache: case LENSW: case WIDTHSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case VERBSW: @@ -297,20 +304,21 @@ do_cache: } /* - * Check if we've specified an additional profile - */ + ** Check if we've specified an additional profile + */ if ((cp = getenv ("MHSHOW"))) { if ((fp = fopen (cp, "r"))) { readconfig ((struct node **) 0, fp, cp, 0); fclose (fp); } else { - admonish ("", "unable to read $MHSHOW profile (%s)", cp); + admonish ("", "unable to read $MHSHOW profile (%s)", + cp); } } /* - * Read the standard profile setup - */ + ** Read the standard profile setup + */ if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) { readconfig ((struct node **) 0, fp, cp, 0); fclose (fp); @@ -326,10 +334,10 @@ do_cache: cache_private = getcpy (m_maildir (cache_private)); /* - * Check for storage directory. If specified, - * then store temporary files there. Else we - * store them in standard nmh directory. - */ + ** Check for storage directory. If specified, + ** then store temporary files there. Else we + ** store them in standard nmh directory. + */ if ((cp = context_find (nmhstorage)) && *cp) tmp = concat (cp, "/", invo_name, NULL); else @@ -342,8 +350,8 @@ do_cache: adios (NULL, "cannot specify msg and file at same time!"); /* - * check if message is coming from file - */ + ** check if message is coming from file + */ if (file) { if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts)))) adios (NULL, "out of memory"); @@ -353,8 +361,8 @@ do_cache: *ctp++ = ct; } else { /* - * message(s) are coming from a folder - */ + ** message(s) are coming from a folder + */ if (!msgs.size) app_msgarg(&msgs, "cur"); if (!folder) @@ -378,10 +386,10 @@ do_cache: done (1); /* - * Set the SELECT_UNSEEN bit for all the SELECTED messages, - * since we will use that as a tag to know which messages - * to remove from the "unseen" sequence. - */ + ** Set the SELECT_UNSEEN bit for all the SELECTED messages, + ** since we will use that as a tag to know which messages + ** to remove from the "unseen" sequence. + */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) if (is_selected(mp, msgnum)) set_unseen (mp, msgnum); @@ -389,13 +397,14 @@ do_cache: seq_setprev (mp); /* set the Previous-Sequence */ seq_setunseen (mp, 1); /* unset the Unseen-Sequence */ - if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts)))) + if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), + sizeof(*cts)))) adios (NULL, "out of memory"); ctp = cts; /* - * Parse all the SELECTED messages. - */ + ** Parse all the SELECTED messages. + */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { if (is_selected(mp, msgnum)) { char *msgnam; @@ -415,8 +424,8 @@ do_cache: SIGNAL (SIGPIPE, pipeser); /* - * Get the associated umask for the relevant contents. - */ + ** Get the associated umask for the relevant contents. + */ for (ctp = cts; *ctp; ctp++) { struct stat st; @@ -430,8 +439,8 @@ do_cache: } /* - * Show the message content - */ + ** Show the message content + */ show_all_messages (cts); /* Now free all the structures for the content */ diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index be03d96..68576f6 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -1,10 +1,10 @@ /* - * mhshowsbr.c -- routines to display the contents of MIME messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhshowsbr.c -- routines to display the contents of MIME messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -24,9 +24,9 @@ #endif /* - * Just use sigjmp/longjmp on older machines that - * don't have sigsetjmp/siglongjmp. - */ +** Just use sigjmp/longjmp on older machines that +** don't have sigsetjmp/siglongjmp. +*/ #ifndef HAVE_SIGSETJMP # define sigjmp_buf jmp_buf # define sigsetjmp(env,mask) setjmp(env) @@ -67,19 +67,20 @@ int list_switch (CT, int, int, int, int); int list_content (CT, int, int, int, int); /* - * prototypes - */ +** prototypes +*/ void show_all_messages (CT *); int show_content_aux (CT, int, int, char *, char *); /* - * static prototypes - */ +** static prototypes +*/ static void show_single_message (CT, char *); static void DisplayMsgHeader (CT, char *); static int show_switch (CT, int, int); static int show_content (CT, int, int); -static int show_content_aux2 (CT, int, int, char *, char *, int, int, int, int, int); +static int show_content_aux2 (CT, int, int, char *, char *, + int, int, int, int, int); static int show_text (CT, int, int); static int show_multi (CT, int, int); static int show_multi_internal (CT, int, int); @@ -91,8 +92,8 @@ static RETSIGTYPE intrser (int); /* - * Top level entry point to show/display a group of messages - */ +** Top level entry point to show/display a group of messages +*/ void show_all_messages (CT *cts) @@ -100,15 +101,15 @@ show_all_messages (CT *cts) CT ct, *ctp; /* - * If form is not specified, then get default form - * for showing headers of MIME messages. - */ + ** If form is not specified, then get default form + ** for showing headers of MIME messages. + */ if (!formsw) formsw = getcpy (etcpath ("mhl.headers")); /* - * If form is "mhl.null", suppress display of header. - */ + ** If form is "mhl.null", suppress display of header. + */ if (!strcmp (formsw, "mhl.null")) formsw = NULL; @@ -123,8 +124,8 @@ show_all_messages (CT *cts) /* - * Entry point to show/display a single message - */ +** Entry point to show/display a single message +*/ static void show_single_message (CT ct, char *form) @@ -137,14 +138,16 @@ show_single_message (CT ct, char *form) int status; #endif - /* Allow user executable bit so that temporary directories created by - * the viewer (e.g., lynx) are going to be accessible */ + /* + ** Allow user executable bit so that temporary directories created by + ** the viewer (e.g., lynx) are going to be accessible + */ umask (ct->c_umask & ~(0100)); /* - * If you have a format file, then display - * the message headers. - */ + ** If you have a format file, then display + ** the message headers. + */ if (form) DisplayMsgHeader(ct, form); else @@ -186,8 +189,8 @@ show_single_message (CT ct, char *form) /* - * Use the mhlproc to show the header fields - */ +** Use the mhlproc to show the header fields +*/ static void DisplayMsgHeader (CT ct, char *form) @@ -204,9 +207,9 @@ DisplayMsgHeader (CT ct, char *form) vec[vecp++] = ct->c_file; /* - * If we've specified -(no)moreproc, - * then just pass that along. - */ + ** If we've specified -(no)moreproc, + ** then just pass that along. + */ if (nomore) { vec[vecp++] = "-nomoreproc"; } else if (progsw) { @@ -240,9 +243,9 @@ DisplayMsgHeader (CT ct, char *form) /* - * Switching routine. Call the correct routine - * based on content type. - */ +** Switching routine. Call the correct routine +** based on content type. +*/ static int show_switch (CT ct, int serial, int alternate) @@ -290,8 +293,8 @@ show_switch (CT ct, int serial, int alternate) /* - * Generic method for displaying content - */ +** Generic method for displaying content +*/ static int show_content (CT ct, int serial, int alternate) @@ -322,8 +325,8 @@ show_content (CT ct, int serial, int alternate) /* - * Parse the display string for displaying generic content - */ +** Parse the display string for displaying generic content +*/ int show_content_aux (CT ct, int serial, int alternate, char *cp, char *cracked) @@ -335,7 +338,8 @@ show_content_aux (CT ct, int serial, int alternate, char *cp, char *cracked) if (!ct->c_ceopenfnx) { if (!alternate) - content_error (NULL, ct, "don't know how to decode content"); + content_error (NULL, ct, + "don't know how to decode content"); return NOTOK; } @@ -374,8 +378,10 @@ show_content_aux (CT ct, int serial, int alternate, char *cp, char *cracked) char **ap, **ep; char *s = ""; - for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) { - snprintf (bp, buflen, "%s%s=\"%s\"", s, *ap, *ep); + for (ap = ci->ci_attrs, ep = ci->ci_values; + *ap; ap++, ep++) { + snprintf (bp, buflen, "%s%s=\"%s\"", + s, *ap, *ep); len = strlen (bp); bp += len; buflen -= len; @@ -409,11 +415,13 @@ show_content_aux (CT ct, int serial, int alternate, char *cp, char *cracked) case 'f': /* insert filename containing content */ snprintf (bp, buflen, "'%s'", file); - /* since we've quoted the file argument, set things up - * to look past it, to avoid problems with the quoting - * logic below. (I know, I should figure out what's - * broken with the quoting logic, but..) - */ + /* + ** since we've quoted the file argument, + ** set things up to look past it, to avoid + ** problems with the quoting logic below. + ** (I know, I should figure out what's + ** broken with the quoting logic, but..) + */ len = strlen(bp); buflen -= len; bp += len; @@ -426,7 +434,9 @@ show_content_aux (CT ct, int serial, int alternate, char *cp, char *cracked) /* and fall... */ case 'l': - /* display listing prior to displaying content */ + /* + ** display listing prior to displaying content + */ xlist = !nolist; break; @@ -451,7 +461,10 @@ show_content_aux (CT ct, int serial, int alternate, char *cp, char *cracked) /* Did we actually insert something? */ if (bp != pp) { - /* Insert single quote if not inside quotes already */ + /* + ** Insert single quote if not inside quotes + ** already + */ if (!quoted && buflen) { len = strlen (pp); memmove (pp + 1, pp, len); @@ -469,7 +482,10 @@ show_content_aux (CT ct, int serial, int alternate, char *cp, char *cracked) buflen -= 3; bp += 3; } - /* If pp is still set, that means we ran out of space. */ + /* + ** If pp is still set, that means we ran + ** out of space. + */ if (pp) buflen = 0; if (!quoted && buflen) { @@ -490,10 +506,11 @@ raw: } if (buflen <= 0 || (ct->c_termproc && buflen <= strlen(ct->c_termproc))) { - /* content_error would provide a more useful error message - * here, except that if we got overrun, it probably would - * too. - */ + /* + ** content_error would provide a more useful error message + ** here, except that if we got overrun, it probably would + ** too. + */ fprintf(stderr, "Buffer overflow constructing show command!\n"); return NOTOK; } @@ -508,13 +525,13 @@ raw: got_command: return show_content_aux2 (ct, serial, alternate, cracked, buffer, - fd, xlist, xpause, xstdin, xtty); + fd, xlist, xpause, xstdin, xtty); } /* - * Routine to actually display the content - */ +** Routine to actually display the content +*/ static int show_content_aux2 (CT ct, int serial, int alternate, char *cracked, @@ -532,7 +549,8 @@ show_content_aux2 (CT ct, int serial, int alternate, char *cracked, if (ct->c_partno) fprintf (stderr, " part %s", ct->c_partno); if (cracked) - fprintf (stderr, " using command (cd %s; %s)\n", cracked, buffer); + fprintf (stderr, " using command (cd %s; %s)\n", + cracked, buffer); else fprintf (stderr, " using command %s\n", buffer); } @@ -620,8 +638,8 @@ show_content_aux2 (CT ct, int serial, int alternate, char *cracked, /* - * show content of type "text" - */ +** show content of type "text" +*/ static int show_text (CT ct, int serial, int alternate) @@ -641,9 +659,9 @@ show_text (CT ct, int serial, int alternate) return show_content_aux (ct, serial, alternate, cp, NULL); /* - * Use default method if content is text/plain, or if - * if it is not a text part of a multipart/alternative - */ + ** Use default method if content is text/plain, or if + ** if it is not a text part of a multipart/alternative + */ if (!alternate || ct->c_subtype == TEXT_PLAIN) { snprintf (buffer, sizeof(buffer), "%%p%s '%%F'", progsw ? progsw : moreproc && *moreproc ? moreproc : "more"); @@ -656,8 +674,8 @@ show_text (CT ct, int serial, int alternate) /* - * show message body of type "multipart" - */ +** show message body of type "multipart" +*/ static int show_multi (CT ct, int serial, int alternate) @@ -680,10 +698,10 @@ show_multi (CT ct, int serial, int alternate) return show_multi_aux (ct, serial, alternate, cp); /* - * Use default method to display this multipart content - * if it is not a (nested) part of a multipart/alternative, - * or if it is one of the known subtypes of multipart. - */ + ** Use default method to display this multipart content + ** if it is not a (nested) part of a multipart/alternative, + ** or if it is one of the known subtypes of multipart. + */ if (!alternate || ct->c_subtype != MULTI_UNKNOWN) return show_multi_internal (ct, serial, alternate); @@ -692,9 +710,9 @@ show_multi (CT ct, int serial, int alternate) /* - * show message body of subtypes of multipart that - * we understand directly (mixed, alternate, etc...) - */ +** show message body of subtypes of multipart that +** we understand directly (mixed, alternate, etc...) +*/ static int show_multi_internal (CT ct, int serial, int alternate) @@ -716,10 +734,10 @@ show_multi_internal (CT ct, int serial, int alternate) nowserial = serial; } else { /* - * multipart/mixed - * mutlipart/digest - * unknown subtypes of multipart (treat as mixed per rfc2046) - */ + ** multipart/mixed + ** mutlipart/digest + ** unknown subtypes of multipart (treat as mixed per rfc2046) + */ nowserial = serial; } @@ -734,9 +752,9 @@ show_multi_internal (CT ct, int serial, int alternate) } /* - * alternate -> we are a part inside an multipart/alternative - * alternating -> we are a multipart/alternative - */ +** alternate -> we are a part inside an multipart/alternative +** alternating -> we are a multipart/alternative +*/ result = alternate ? NOTOK : OK; @@ -832,9 +850,9 @@ out: /* - * Parse display string for multipart content - * and use external program to display it. - */ +** Parse display string for multipart content +** and use external program to display it. +*/ static int show_multi_aux (CT ct, int serial, int alternate, char *cp) @@ -891,8 +909,10 @@ show_multi_aux (CT ct, int serial, int alternate, char *cp) char **ap, **ep; char *s = ""; - for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) { - snprintf (bp, buflen, "%s%s=\"%s\"", s, *ap, *ep); + for (ap = ci->ci_attrs, ep = ci->ci_values; + *ap; ap++, ep++) { + snprintf (bp, buflen, "%s%s=\"%s\"", + s, *ap, *ep); len = strlen (bp); bp += len; buflen -= len; @@ -927,7 +947,8 @@ show_multi_aux (CT ct, int serial, int alternate, char *cp) { char *s = ""; - for (part = m->mp_parts; part; part = part->mp_next) { + for (part = m->mp_parts; part; + part = part->mp_next) { p = part->mp_part; snprintf (bp, buflen, "%s'%s'", s, p->c_storage); @@ -936,9 +957,11 @@ show_multi_aux (CT ct, int serial, int alternate, char *cp) buflen -= len; s = " "; } - /* set our starting pointer back to bp, to avoid - * requoting the filenames we just added - */ + /* + ** set our starting pointer back to bp, + ** to avoid requoting the filenames we + ** just added + */ pp = bp; } break; @@ -949,7 +972,9 @@ show_multi_aux (CT ct, int serial, int alternate, char *cp) /* and fall... */ case 'l': - /* display listing prior to displaying content */ + /* + ** display listing prior to displaying content + */ xlist = !nolist; break; @@ -974,7 +999,10 @@ show_multi_aux (CT ct, int serial, int alternate, char *cp) /* Did we actually insert something? */ if (bp != pp) { - /* Insert single quote if not inside quotes already */ + /* + ** Insert single quote if not inside quotes + ** already + */ if (!quoted && buflen) { len = strlen (pp); memmove (pp + 1, pp, len); @@ -992,7 +1020,10 @@ show_multi_aux (CT ct, int serial, int alternate, char *cp) buflen -= 3; bp += 3; } - /* If pp is still set, that means we ran out of space. */ + /* + ** If pp is still set, that means we ran + ** out of space. + */ if (pp) buflen = 0; if (!quoted && buflen) { @@ -1013,10 +1044,11 @@ raw: } if (buflen <= 0 || (ct->c_termproc && buflen <= strlen(ct->c_termproc))) { - /* content_error would provide a more useful error message - * here, except that if we got overrun, it probably would - * too. - */ + /* + ** content_error would provide a more useful error message + ** here, except that if we got overrun, it probably would + ** too. + */ fprintf(stderr, "Buffer overflow constructing show command!\n"); return NOTOK; } @@ -1030,13 +1062,13 @@ raw: } return show_content_aux2 (ct, serial, alternate, NULL, buffer, - NOTOK, xlist, xpause, 0, xtty); + NOTOK, xlist, xpause, 0, xtty); } /* - * show content of type "message/rfc822" - */ +** show content of type "message/rfc822" +*/ static int show_message_rfc822 (CT ct, int serial, int alternate) @@ -1073,8 +1105,8 @@ show_message_rfc822 (CT ct, int serial, int alternate) /* - * Show content of type "message/partial". - */ +** Show content of type "message/partial". +*/ static int show_partial (CT ct, int serial, int alternate) @@ -1086,10 +1118,10 @@ show_partial (CT ct, int serial, int alternate) /* - * Show content of type "message/external". - * - * THE ERROR CHECKING IN THIS ONE IS NOT DONE YET. - */ +** Show content of type "message/external". +** +** THE ERROR CHECKING IN THIS ONE IS NOT DONE YET. +*/ static int show_external (CT ct, int serial, int alternate) diff --git a/uip/mhstore.c b/uip/mhstore.c index 2b413d4..add5c02 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -1,10 +1,10 @@ /* - * mhstore.c -- store the contents of MIME messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhstore.c -- store the contents of MIME messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -52,8 +52,8 @@ static struct swit switches[] = { { "help", 0 }, /* - * switches for debugging - */ +** switches for debugging +*/ #define DEBUGSW 13 { "debug", -5 }, { NULL, 0 } @@ -103,8 +103,8 @@ extern CT *cts; void freects_done (int) NORETURN; /* - * static prototypes - */ +** static prototypes +*/ static RETSIGTYPE pipeser (int); @@ -134,8 +134,8 @@ main (int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -238,8 +238,8 @@ do_cache: set_endian (); /* - * Check if we've specified an additional profile - */ + ** Check if we've specified an additional profile + */ if ((cp = getenv ("MHSTORE"))) { if ((fp = fopen (cp, "r"))) { readconfig ((struct node **) 0, fp, cp, 0); @@ -250,8 +250,8 @@ do_cache: } /* - * Read the standard profile setup - */ + ** Read the standard profile setup + */ if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) { readconfig ((struct node **) 0, fp, cp, 0); fclose (fp); @@ -267,15 +267,15 @@ do_cache: cache_private = getcpy (m_maildir (cache_private)); /* - * Cache the current directory before we do any chdirs()'s. - */ + ** Cache the current directory before we do any chdirs()'s. + */ cwd = getcpy (pwd()); /* - * Check for storage directory. If specified, - * then store temporary files there. Else we - * store them in standard nmh directory. - */ + ** Check for storage directory. If specified, + ** then store temporary files there. Else we + ** store them in standard nmh directory. + */ if ((cp = context_find (nmhstorage)) && *cp) tmp = concat (cp, "/", invo_name, NULL); else @@ -288,8 +288,8 @@ do_cache: adios (NULL, "cannot specify msg and file at same time!"); /* - * check if message is coming from file - */ + ** check if message is coming from file + */ if (file) { if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts)))) adios (NULL, "out of memory"); @@ -299,8 +299,8 @@ do_cache: *ctp++ = ct; } else { /* - * message(s) are coming from a folder - */ + ** message(s) are coming from a folder + */ if (!msgs.size) app_msgarg(&msgs, "cur"); if (!folder) @@ -324,7 +324,8 @@ do_cache: done (1); seq_setprev (mp); /* set the previous-sequence */ - if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts)))) + if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), + sizeof(*cts)))) adios (NULL, "out of memory"); ctp = cts; @@ -347,8 +348,8 @@ do_cache: SIGNAL (SIGPIPE, pipeser); /* - * Get the associated umask for the relevant contents. - */ + ** Get the associated umask for the relevant contents. + */ for (ctp = cts; *ctp; ctp++) { struct stat st; @@ -362,8 +363,8 @@ do_cache: } /* - * Store the message content - */ + ** Store the message content + */ store_all_messages (cts); /* Now free all the structures for the content */ diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index 2683fae..e5b92e8 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -1,10 +1,10 @@ /* - * mhstoresbr.c -- routines to save/store the contents of MIME messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhstoresbr.c -- routines to save/store the contents of MIME messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -21,27 +21,27 @@ /* - * The list of top-level contents to display - */ +** The list of top-level contents to display +*/ extern CT *cts; int autosw = 0; /* - * Cache of current directory. This must be - * set before these routines are called. - */ +** Cache of current directory. This must be +** set before these routines are called. +*/ char *cwd; /* - * The directory in which to store the contents. - */ +** The directory in which to store the contents. +*/ static char *dir; /* - * Type for a compare function for qsort. This keeps - * the compiler happy. - */ +** Type for a compare function for qsort. This keeps +** the compiler happy. +*/ typedef int (*qsort_comp) (const void *, const void *); @@ -55,13 +55,13 @@ void flush_errors (void); int show_content_aux (CT, int, int, char *, char *); /* - * prototypes - */ +** prototypes +*/ void store_all_messages (CT *); /* - * static prototypes - */ +** static prototypes +*/ static void store_single_message (CT); static int store_switch (CT); static int store_generic (CT); @@ -79,9 +79,9 @@ static int copy_some_headers (FILE *, CT); /* - * Main entry point to store content - * from a collection of messages. - */ +** Main entry point to store content +** from a collection of messages. +*/ void store_all_messages (CT *cts) @@ -90,9 +90,9 @@ store_all_messages (CT *cts) char *cp; /* - * Check for the directory in which to - * store any contents. - */ + ** Check for the directory in which to + ** store any contents. + */ if (autosw) dir = getcpy (cwd); else if ((cp = context_find (nmhstorage)) && *cp) @@ -110,9 +110,9 @@ store_all_messages (CT *cts) /* - * Entry point to store the content - * in a (single) message - */ +** Entry point to store the content +** in a (single) message +*/ static void store_single_message (CT ct) @@ -131,8 +131,8 @@ store_single_message (CT ct) /* - * Switching routine to store different content types - */ +** Switching routine to store different content types +*/ static int store_switch (CT ct) @@ -179,18 +179,18 @@ store_switch (CT ct) /* - * Generic routine to store a MIME content. - * (audio, video, image, text, message/rfc922) - */ +** Generic routine to store a MIME content. +** (audio, video, image, text, message/rfc922) +*/ static int store_generic (CT ct) { /* - * Check if the content specifies a filename. - * Don't bother with this for type "message" - * (only "message/rfc822" will use store_generic). - */ + ** Check if the content specifies a filename. + ** Don't bother with this for type "message" + ** (only "message/rfc822" will use store_generic). + */ if (autosw && ct->c_type != CT_MESSAGE) get_storeproc (ct); @@ -199,8 +199,8 @@ store_generic (CT ct) /* - * Store content of type "application" - */ +** Store content of type "application" +*/ static int store_application (CT ct) @@ -213,10 +213,10 @@ store_application (CT ct) get_storeproc (ct); /* - * If storeproc is not defined, and the content is type - * "application/octet-stream", we also check for various - * attribute/value pairs which specify if this a tar file. - */ + ** If storeproc is not defined, and the content is type + ** "application/octet-stream", we also check for various + ** attribute/value pairs which specify if this a tar file. + */ if (!ct->c_storeproc && ct->c_subtype == APPLICATION_OCTETS) { int tarP = 0, zP = 0, gzP = 0; @@ -231,33 +231,31 @@ store_application (CT ct) } /* check for "conversions=compress" attribute */ - if ((!mh_strcasecmp (*ap, "conversions") || !mh_strcasecmp (*ap, "x-conversions")) - && (!mh_strcasecmp (*ep, "compress") || !mh_strcasecmp (*ep, "x-compress"))) { + if ((!mh_strcasecmp (*ap, "conversions") || + !mh_strcasecmp (*ap, "x-conversions")) + && (!mh_strcasecmp (*ep, "compress") || + !mh_strcasecmp (*ep, "x-compress"))) { zP = 1; continue; } /* check for "conversions=gzip" attribute */ - if ((!mh_strcasecmp (*ap, "conversions") || !mh_strcasecmp (*ap, "x-conversions")) - && (!mh_strcasecmp (*ep, "gzip") || !mh_strcasecmp (*ep, "x-gzip"))) { + if ((!mh_strcasecmp (*ap, "conversions") || + !mh_strcasecmp (*ap, "x-conversions")) + && (!mh_strcasecmp (*ep, "gzip") || + !mh_strcasecmp (*ep, "x-gzip"))) { gzP = 1; continue; } } if (tarP) { - ct->c_showproc = add (zP ? "%euncompress | tar tvf -" - : (gzP ? "%egzip -dc | tar tvf -" - : "%etar tvf -"), NULL); + ct->c_showproc = add (zP ? "%euncompress | tar tvf -" : (gzP ? "%egzip -dc | tar tvf -" : "%etar tvf -"), NULL); if (!ct->c_storeproc) { if (autosw) { - ct->c_storeproc = add (zP ? "| uncompress | tar xvpf -" - : (gzP ? "| gzip -dc | tar xvpf -" - : "| tar xvpf -"), NULL); + ct->c_storeproc = add (zP ? "| uncompress | tar xvpf -" : (gzP ? "| gzip -dc | tar xvpf -" : "| tar xvpf -"), NULL); ct->c_umask = 0022; } else { - ct->c_storeproc= add (zP ? "%m%P.tar.Z" - : (gzP ? "%m%P.tar.gz" - : "%m%P.tar"), NULL); + ct->c_storeproc= add (zP ? "%m%P.tar.Z" : (gzP ? "%m%P.tar.gz" : "%m%P.tar"), NULL); } } } @@ -268,8 +266,8 @@ store_application (CT ct) /* - * Store the content of a multipart message - */ +** Store the content of a multipart message +*/ static int store_multi (CT ct) @@ -294,9 +292,9 @@ store_multi (CT ct) /* - * Reassemble and store the contents of a collection - * of messages of type "message/partial". - */ +** Reassemble and store the contents of a collection +** of messages of type "message/partial". +*/ static int store_partial (CT ct) @@ -355,16 +353,12 @@ store_partial (CT ct) pm = (struct partial *) p->c_ctparams; if (pm->pm_marked != cur) { if (pm->pm_marked == cur - 1) { - admonish (NULL, - "duplicate part %d of %d part multipart message", - pm->pm_marked, hi); + admonish (NULL, "duplicate part %d of %d part multipart message", pm->pm_marked, hi); continue; } missing_part: - advise (NULL, - "missing %spart %d of %d part multipart message", - cur != hi ? "(at least) " : "", cur, hi); + advise (NULL, "missing %spart %d of %d part multipart message", cur != hi ? "(at least) " : "", cur, hi); goto losing; } else cur++; @@ -375,9 +369,9 @@ missing_part: } /* - * Now cycle through the sorted list of messages of type - * "message/partial" and save/append them to a file. - */ + ** Now cycle through the sorted list of messages of type + ** "message/partial" and save/append them to a file. + */ ctq = base; ct = *ctq++; @@ -399,8 +393,8 @@ losing: /* - * Store content from a message of type "message/external". - */ +** Store content from a message of type "message/external". +*/ static int store_external (CT ct) @@ -413,9 +407,9 @@ store_external (CT ct) return OK; /* - * Check if the parameters for the external body - * specified a filename. - */ + ** Check if the parameters for the external body + ** specified a filename. + */ if (autosw) { char *cp; @@ -433,11 +427,11 @@ store_external (CT ct) } /* - * Since we will let the Content structure for the - * external body substitute for the current content, - * we temporarily change its partno (number inside - * multipart), so everything looks right. - */ + ** Since we will let the Content structure for the + ** external body substitute for the current content, + ** we temporarily change its partno (number inside + ** multipart), so everything looks right. + */ p->c_partno = ct->c_partno; /* we probably need to check if content is really there */ @@ -449,9 +443,9 @@ store_external (CT ct) /* - * Compare the numbering from two different - * message/partials (needed for sorting). - */ +** Compare the numbering from two different +** message/partials (needed for sorting). +*/ static int ct_compar (CT *a, CT *b) @@ -464,15 +458,15 @@ ct_compar (CT *a, CT *b) /* - * Store contents of a message or message part to - * a folder, a file, the standard output, or pass - * the contents to a command. - * - * If the current content to be saved is a followup part - * to a collection of messages of type "message/partial", - * then field "p" is a pointer to the Content structure - * to the first message/partial in the group. - */ +** Store contents of a message or message part to +** a folder, a file, the standard output, or pass +** the contents to a command. +** +** If the current content to be saved is a followup part +** to a collection of messages of type "message/partial", +** then field "p" is a pointer to the Content structure +** to the first message/partial in the group. +*/ static int store_content (CT ct, CT p) @@ -483,18 +477,18 @@ store_content (CT ct, CT p) char *cp, buffer[BUFSIZ]; /* - * Do special processing for messages of - * type "message/partial". - * - * We first check if this content is of type - * "message/partial". If it is, then we need to check - * whether it is the first and/or last in the group. - * - * Then if "p" is a valid pointer, it points to the Content - * structure of the first partial in the group. So we copy - * the file name and/or folder name from that message. In - * this case, we also note that we will be appending. - */ + ** Do special processing for messages of + ** type "message/partial". + ** + ** We first check if this content is of type + ** "message/partial". If it is, then we need to check + ** whether it is the first and/or last in the group. + ** + ** Then if "p" is a valid pointer, it points to the Content + ** structure of the first partial in the group. So we copy + ** the file name and/or folder name from that message. In + ** this case, we also note that we will be appending. + */ if (ct->c_type == CT_MESSAGE && ct->c_subtype == MESSAGE_PARTIAL) { struct partial *pm = (struct partial *) ct->c_ctparams; @@ -508,11 +502,11 @@ store_content (CT ct, CT p) last_partial = 1; /* - * If "p" is a valid pointer, then it points to the - * Content structure for the first message in the group. - * So we just copy the filename or foldername information - * from the previous iteration of this function. - */ + ** If "p" is a valid pointer, then it points to the + ** Content structure for the first message in the group. + ** So we just copy the filename or foldername information + ** from the previous iteration of this function. + */ if (p) { appending = 1; ct->c_storage = add (p->c_storage, NULL); @@ -526,21 +520,22 @@ store_content (CT ct, CT p) } /* - * Get storage formatting string. - * - * 1) If we have storeproc defined, then use that - * 2) Else check for a mhstore-store-/ entry - * 3) Else check for a mhstore-store- entry - * 4) Else if content is "message", use "+" (current folder) - * 5) Else use string "%m%P.%s". - */ + ** Get storage formatting string. + ** + ** 1) If we have storeproc defined, then use that + ** 2) Else check for a mhstore-store-/ entry + ** 3) Else check for a mhstore-store- entry + ** 4) Else if content is "message", use "+" (current folder) + ** 5) Else use string "%m%P.%s". + */ if ((cp = ct->c_storeproc) == NULL || *cp == '\0') { CI ci = &ct->c_ctinfo; snprintf (buffer, sizeof(buffer), "%s-store-%s/%s", invo_name, ci->ci_type, ci->ci_subtype); if ((cp = context_find (buffer)) == NULL || *cp == '\0') { - snprintf (buffer, sizeof(buffer), "%s-store-%s", invo_name, ci->ci_type); + snprintf (buffer, sizeof(buffer), "%s-store-%s", + invo_name, ci->ci_type); if ((cp = context_find (buffer)) == NULL || *cp == '\0') { cp = ct->c_type == CT_MESSAGE ? "+" : "%m%P.%s"; } @@ -548,9 +543,9 @@ store_content (CT ct, CT p) } /* - * Check the beginning of storage formatting string - * to see if we are saving content to a folder. - */ + ** Check the beginning of storage formatting string + ** to see if we are saving content to a folder. + */ if (*cp == '+' || *cp == '@') { char *tmpfilenam, *folder; @@ -577,15 +572,15 @@ store_content (CT ct, CT p) } /* - * Parse and expand the storage formatting string - * in `cp' into `buffer'. - */ + ** Parse and expand the storage formatting string + ** in `cp' into `buffer'. + */ parse_format_string (ct, cp, buffer, sizeof(buffer), dir); /* - * If formatting begins with '|' or '!', then pass - * content to standard input of a command and return. - */ + ** If formatting begins with '|' or '!', then pass + ** content to standard input of a command and return. + */ if (buffer[0] == '|' || buffer[0] == '!') return show_content_aux (ct, 1, 0, buffer + 1, dir); @@ -601,10 +596,10 @@ got_filename: return NOTOK; /* - * If necessary, link the file into a folder and remove - * the temporary file. If this message is a partial, - * then only do this if it is the last one in the group. - */ + ** If necessary, link the file into a folder and remove + ** the temporary file. If this message is a partial, + ** then only do this if it is the last one in the group. + */ if (ct->c_folder && (!is_partial || last_partial)) { msgnum = output_content_folder (ct->c_folder, ct->c_storage); unlink (ct->c_storage); @@ -613,9 +608,9 @@ got_filename: } /* - * Now print out the name/number of the message - * that we are storing. - */ + ** Now print out the name/number of the message + ** that we are storing. + */ if (is_partial) { if (first_partial) fprintf (stderr, "reassembling partials "); @@ -630,10 +625,10 @@ got_filename: } /* - * Unless we are in the "middle" of group of message/partials, - * we now print the name of the file, folder, and/or message - * to which we are storing the content. - */ + ** Unless we are in the "middle" of group of message/partials, + ** we now print the name of the file, folder, and/or message + ** to which we are storing the content. + */ if (!is_partial || last_partial) { if (ct->c_folder) { fprintf (stderr, " to folder %s as message %d\n", ct->c_folder, msgnum); @@ -655,8 +650,8 @@ got_filename: /* - * Output content to a file - */ +** Output content to a file +*/ static int output_content_file (CT ct, int appending) @@ -667,9 +662,9 @@ output_content_file (CT ct, int appending) FILE *fp; /* - * If the pathname is absolute, make sure - * all the relevant directories exist. - */ + ** If the pathname is absolute, make sure + ** all the relevant directories exist. + */ if (strchr(ct->c_storage, '/') && make_intermediates (ct->c_storage) == NOTOK) return NOTOK; @@ -693,8 +688,8 @@ output_content_file (CT ct, int appending) } /* - * Send to standard output - */ + ** Send to standard output + */ if (!strcmp (ct->c_storage, "-")) { int gd; @@ -712,8 +707,8 @@ losing: } } else { /* - * Open output file - */ + ** Open output file + */ if ((fp = fopen (ct->c_storage, appending ? "a" : "w")) == NULL) { advise (ct->c_storage, "unable to fopen for %s", appending ? "appending" : "writing"); @@ -722,9 +717,9 @@ losing: } /* - * Filter the header fields of the initial enclosing - * message/partial into the file. - */ + ** Filter the header fields of the initial enclosing + ** message/partial into the file. + */ if (ct->c_type == CT_MESSAGE && ct->c_subtype == MESSAGE_PARTIAL) { struct partial *pm = (struct partial *) ct->c_ctparams; @@ -789,9 +784,9 @@ losing: } /* - * Copy a few of the header fields of the initial - * enclosing message/partial into the file. - */ + ** Copy a few of the header fields of the initial + ** enclosing message/partial into the file. + */ filterstate = 0; if (ct->c_type == CT_MESSAGE && ct->c_subtype == MESSAGE_PARTIAL) { struct partial *pm = (struct partial *) ct->c_ctparams; @@ -811,10 +806,10 @@ losing: buffer[diff] = '\0'; } /* - * If this is the first content of a group of - * message/partial contents, then we only copy a few - * of the header fields of the enclosed message. - */ + ** If this is the first content of a group of + ** message/partial contents, then we only copy a few + ** of the header fields of the enclosed message. + */ if (filterstate) { switch (buffer[0]) { case ' ': @@ -857,12 +852,12 @@ losing: /* - * Add a file to a folder. - * - * Return the new message number of the file - * when added to the folder. Return -1, if - * there is an error. - */ +** Add a file to a folder. +** +** Return the new message number of the file +** when added to the folder. Return -1, if +** there is an error. +*/ static int output_content_folder (char *folder, char *filename) @@ -883,17 +878,17 @@ output_content_folder (char *folder, char *filename) folder_free (mp); /* - * Return msgnum. We are relying on the fact that - * msgnum will be -1, if folder_addmsg() had an error. - */ + ** Return msgnum. We are relying on the fact that + ** msgnum will be -1, if folder_addmsg() had an error. + */ return msgnum; } /* - * Parse and expand the storage formatting string - * pointed to by "cp" into "buffer". - */ +** Parse and expand the storage formatting string +** pointed to by "cp" into "buffer". +*/ static int parse_format_string (CT ct, char *cp, char *buffer, int buflen, char *dir) @@ -903,9 +898,9 @@ parse_format_string (CT ct, char *cp, char *buffer, int buflen, char *dir) CI ci = &ct->c_ctinfo; /* - * If storage string is "-", just copy it, and - * return (send content to standard output). - */ + ** If storage string is "-", just copy it, and + ** return (send content to standard output). + */ if (cp[0] == '-' && cp[1] == '\0') { strncpy (buffer, cp, buflen); return 0; @@ -915,10 +910,10 @@ parse_format_string (CT ct, char *cp, char *buffer, int buflen, char *dir) bp[0] = '\0'; /* - * If formatting string is a pathname that doesn't - * begin with '/', then preface the path with the - * appropriate directory. - */ + ** If formatting string is a pathname that doesn't + ** begin with '/', then preface the path with the + ** appropriate directory. + */ if (*cp != '/' && *cp != '|' && *cp != '!') { snprintf (bp, buflen, "%s/", dir[1] ? dir : ""); len = strlen (bp); @@ -933,9 +928,9 @@ parse_format_string (CT ct, char *cp, char *buffer, int buflen, char *dir) switch (*++cp) { case 'a': /* - * Insert parameters from Content-Type. - * This is only valid for '|' commands. - */ + ** Insert parameters from Content-Type. + ** This is only valid for '|' commands. + */ if (buffer[0] != '|' && buffer[0] != '!') { *bp++ = *--cp; *bp = '\0'; @@ -1012,9 +1007,9 @@ raw: /* - * Check if the content specifies a filename - * in its MIME parameters. - */ +** Check if the content specifies a filename +** in its MIME parameters. +*/ static void get_storeproc (CT ct) @@ -1023,18 +1018,18 @@ get_storeproc (CT ct) CI ci = &ct->c_ctinfo; /* - * If the storeproc has already been defined, - * we just return (for instance, if this content - * is part of a "message/external". - */ + ** If the storeproc has already been defined, + ** we just return (for instance, if this content + ** is part of a "message/external". + */ if (ct->c_storeproc) return; /* - * Check the attribute/value pairs, for the attribute "name". - * If found, do a few sanity checks and copy the value into - * the storeproc. - */ + ** Check the attribute/value pairs, for the attribute "name". + ** If found, do a few sanity checks and copy the value into + ** the storeproc. + */ for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) { if (!mh_strcasecmp (*ap, "name") && *(cp = *ep) != '/' @@ -1050,9 +1045,9 @@ get_storeproc (CT ct) /* - * Copy some of the header fields of the initial message/partial - * message into the header of the reassembled message. - */ +** Copy some of the header fields of the initial message/partial +** message into the header of the reassembled message. +*/ static int copy_some_headers (FILE *out, CT ct) @@ -1063,9 +1058,9 @@ copy_some_headers (FILE *out, CT ct) while (hp) { /* - * A few of the header fields of the enclosing - * messages are not copied. - */ + ** A few of the header fields of the enclosing + ** messages are not copied. + */ if (!uprf (hp->name, XXX_FIELD_PRF) && mh_strcasecmp (hp->name, VRSN_FIELD) && mh_strcasecmp (hp->name, "Subject") diff --git a/uip/mhtest.c b/uip/mhtest.c index 9f21c01..f8e6e38 100644 --- a/uip/mhtest.c +++ b/uip/mhtest.c @@ -1,10 +1,10 @@ /* - * mhtest.c -- test harness for MIME routines - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhtest.c -- test harness for MIME routines +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -50,8 +50,8 @@ static struct swit switches[] = { { "help", 0 }, /* - * switches for debugging - */ +** switches for debugging +*/ #define DEBUGSW 12 { "debug", -5 }, { NULL, 0 } @@ -77,9 +77,9 @@ extern char *types[NTYPES + 1]; extern int userrs; /* - * This is currently needed to keep mhparse happy. - * This needs to be changed. - */ +** This is currently needed to keep mhparse happy. +** This needs to be changed. +*/ pid_t xpid = 0; int debugsw = 0; @@ -105,8 +105,8 @@ extern CT *cts; void freects_done (int) NORETURN; /* - * static prototypes - */ +** static prototypes +*/ static int write_content (CT *, char *); static RETSIGTYPE pipeser (int); @@ -136,8 +136,8 @@ main (int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -148,8 +148,7 @@ main (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", - invo_name); + snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -229,7 +228,7 @@ do_cache: else folder = pluspath (cp); } else - app_msgarg(&msgs, cp); + app_msgarg(&msgs, cp); } /* null terminate the list of acceptable parts/types */ @@ -251,10 +250,10 @@ do_cache: cache_private = getcpy (m_maildir (cache_private)); /* - * Check for storage directory. If specified, - * then store temporary files there. Else we - * store them in standard nmh directory. - */ + ** Check for storage directory. If specified, + ** then store temporary files there. Else we + ** store them in standard nmh directory. + */ if ((cp = context_find (nmhstorage)) && *cp) tmp = concat (cp, "/", invo_name, NULL); else @@ -267,8 +266,8 @@ do_cache: adios (NULL, "cannot specify msg and file at same time!"); /* - * check if message is coming from file - */ + ** check if message is coming from file + */ if (file) { if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts)))) adios (NULL, "out of memory"); @@ -278,8 +277,8 @@ do_cache: *ctp++ = ct; } else { /* - * message(s) are coming from a folder - */ + ** message(s) are coming from a folder + */ if (!msgs.size) app_msgarg(&msgs, "cur"); if (!folder) @@ -326,8 +325,8 @@ do_cache: SIGNAL (SIGPIPE, pipeser); /* - * Get the associated umask for the relevant contents. - */ + ** Get the associated umask for the relevant contents. + */ for (ctp = cts; *ctp; ctp++) { struct stat st; @@ -341,8 +340,8 @@ do_cache: } /* - * Write the content to a file - */ + ** Write the content to a file + */ write_content (cts, outfile); /* Now free all the structures for the content */ diff --git a/uip/msgchk.c b/uip/msgchk.c index 5f31685..0b2f3eb 100644 --- a/uip/msgchk.c +++ b/uip/msgchk.c @@ -1,10 +1,10 @@ /* - * msgchk.c -- check for mail - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** msgchk.c -- check for mail +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -27,9 +27,9 @@ static struct swit switches[] = { }; /* - * Maximum numbers of users we can check (plus - * one for the NULL vector at the end). - */ +** Maximum numbers of users we can check (plus +** one for the NULL vector at the end). +*/ #define MAXVEC 51 #define NT_NONE 0x0 @@ -47,8 +47,8 @@ static struct swit switches[] = { /* - * static prototypes - */ +** static prototypes +*/ static int donote (char *, int); static int checkmail (char *, char *, int, int, int); @@ -180,7 +180,8 @@ donote (char *cp, int ntflag) return NT_NMAI; } - return 0; /* Before 1999-07-15, garbage was returned if control got here. */ + /* Before 1999-07-15, garbage was returned if control got here. */ + return 0; } @@ -191,7 +192,9 @@ checkmail (char *user, char *home, int datesw, int notifysw, int personal) char buffer[BUFSIZ]; struct stat st; - snprintf (buffer, sizeof(buffer), "%s/%s", mmdfldir[0] ? mmdfldir : home, mmdflfil[0] ? mmdflfil : user); + snprintf (buffer, sizeof(buffer), "%s/%s", + mmdfldir[0] ? mmdfldir : home, + mmdflfil[0] ? mmdflfil : user); if (datesw) { st.st_size = 0; st.st_atime = st.st_mtime = 0; @@ -203,7 +206,8 @@ checkmail (char *user, char *home, int datesw, int notifysw, int personal) if (notifysw & NT_MAIL) { printf (personal ? "You have " : "%s has ", user); if (mf & UUCPOK) - printf ("%s old-style bell", mf & UUCPOLD ? "old" : "new"); + printf ("%s old-style bell", + mf & UUCPOLD ? "old" : "new"); if ((mf & UUCPOK) && (mf & MMDFOK)) printf (" and "); if (mf & MMDFOK) @@ -218,7 +222,8 @@ checkmail (char *user, char *home, int datesw, int notifysw, int personal) else { if (notifysw & NT_NMAI) printf (personal ? "You don't %s%s" : "%s doesn't %s", - personal ? "" : user, "have any mail waiting"); + personal ? "" : user, + "have any mail waiting"); else notifysw = 0; diff --git a/uip/new.c b/uip/new.c index 49840a1..cb2abc4 100644 --- a/uip/new.c +++ b/uip/new.c @@ -1,14 +1,14 @@ /* - * new.c -- as new, list all folders with unseen messages - * -- as fnext, move to next folder with unseen messages - * -- as fprev, move to previous folder with unseen messages - * -- as unseen, scan all unseen messages - * This code is Copyright (c) 2008, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - * - * Inspired by Luke Mewburn's new: http://www.mewburn.net/luke/src/new - */ +** new.c -- as new, list all folders with unseen messages +** -- as fnext, move to next folder with unseen messages +** -- as fprev, move to previous folder with unseen messages +** -- as unseen, scan all unseen messages +** This code is Copyright (c) 2008, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +** +** Inspired by Luke Mewburn's new: http://www.mewburn.net/luke/src/new +*/ #include @@ -34,8 +34,10 @@ static struct swit switches[] = { static enum { NEW, FNEXT, FPREV, UNSEEN } run_mode = NEW; -/* check_folders uses this to maintain state with both .folders list of - * folders and with crawl_folders. */ +/* +** check_folders uses this to maintain state with both .folders list of +** folders and with crawl_folders. +*/ struct list_state { struct node **first, **cur_node; size_t *maxlen; @@ -85,8 +87,10 @@ seq_in_list(char *name, char *sequences[]) return FALSE; } -/* Return the string list of message numbers from the sequences file, or NULL - * if none. */ +/* +** Return the string list of message numbers from the sequences file, +** or NULL if none. +*/ static char * get_msgnums(char *folder, char *sequences[]) { @@ -111,21 +115,26 @@ get_msgnums(char *folder, char *sequences[]) if (state == FLDPLUS) { cp = getcpy (field); while (state == FLDPLUS) { - state = m_getfld (state, name, field, - sizeof(field), fp); + state = m_getfld (state, name, + field, + sizeof(field), + fp); cp = add (field, cp); } - /* Here's where we differ from seq_public: if it's in a - * sequence we want, save the list of messages. */ + /* + ** Here's where we differ from + ** seq_public: if it's in a + ** sequence we want, save the list + ** of messages. + */ if (seq_in_list(name, sequences)) { this_msgnums = trimcpy(cp); if (msgnums == NULL) { msgnums = this_msgnums; } else { old_msgnums = msgnums; - msgnums = concat(old_msgnums, " ", - this_msgnums, (void *)NULL); + msgnums = concat(old_msgnums, " ", this_msgnums, (void *)NULL); free(old_msgnums); free(this_msgnums); } @@ -139,8 +148,7 @@ get_msgnums(char *folder, char *sequences[]) msgnums = this_msgnums; } else { old_msgnums = msgnums; - msgnums = concat(old_msgnums, " ", - this_msgnums, (void *)NULL); + msgnums = concat(old_msgnums, " ", this_msgnums, (void *)NULL); free(old_msgnums); free(this_msgnums); } @@ -170,8 +178,10 @@ get_msgnums(char *folder, char *sequences[]) return msgnums; } -/* Check `folder' (of length `len') for interesting messages, filling in the - * list in `b'. */ +/* +** Check `folder' (of length `len') for interesting messages, +** filling in the list in `b'. +*/ static void check_folder(char *folder, size_t len, struct list_state *b) { @@ -206,20 +216,21 @@ crawl_callback(char *folder, void *baton) return TRUE; } -/* Scan folders, returning: - * first -- list of nodes for all folders which have desired messages; - * if the current folder is listed in .folders, it is also in - * the list regardless of whether it has any desired messages - * last -- last node in list - * cur_node -- node of current folder, if listed in .folders - * maxlen -- length of longest folder name - * - * `cur' points to the name of the current folder, `folders' points to the - * name of a .folder (if NULL, crawl all folders), and `sequences' points to - * the array of sequences for which to look. - * - * An empty list is returned as first=last=NULL. - */ +/* +** Scan folders, returning: +** first -- list of nodes for all folders which have desired messages; +** if the current folder is listed in .folders, it is also in +** the list regardless of whether it has any desired messages +** last -- last node in list +** cur_node -- node of current folder, if listed in .folders +** maxlen -- length of longest folder name +** +** `cur' points to the name of the current folder, `folders' points to the +** name of a .folder (if NULL, crawl all folders), and `sequences' points to +** the array of sequences for which to look. +** +** An empty list is returned as first=last=NULL. +*/ static void check_folders(struct node **first, struct node **last, struct node **cur_node, size_t *maxlen, @@ -285,14 +296,15 @@ join_sequences(char *sequences[]) return result; } -/* Return a struct node for the folder to change to. This is the next - * (previous, if FPREV mode) folder with desired messages, or the current - * folder if no folders have desired. If NEW or UNSEEN mode, print the - * output but don't change folders. - * - * n_name is the folder to change to, and n_field is the string list of - * desired message numbers. - */ +/* +** Return a struct node for the folder to change to. This is the next +** (previous, if FPREV mode) folder with desired messages, or the current +** folder if no folders have desired. If NEW or UNSEEN mode, print the +** output but don't change folders. +** +** n_name is the folder to change to, and n_field is the string list of +** desired message numbers. +*/ static struct node * doit(char *cur, char *folders, char *sequences[]) { @@ -306,21 +318,26 @@ doit(char *cur, char *folders, char *sequences[]) } check_folders(&first, &last, &cur_node, &folder_len, cur, - folders, sequences); + folders, sequences); if (run_mode == FNEXT || run_mode == FPREV) { if (first == NULL) { /* No folders at all... */ return NULL; } else if (first->n_next == NULL) { - /* We have only one node; any desired messages in it? */ + /* + ** We have only one node; any desired messages in it? + */ if (first->n_field == NULL) { return NULL; } else { return first; } } else if (cur_node == NULL) { - /* Current folder is not listed in .folders, return first. */ + /* + ** Current folder is not listed in .folders, + ** return first. + */ return first; } } else if (run_mode == UNSEEN) { @@ -331,16 +348,20 @@ doit(char *cur, char *folders, char *sequences[]) node != NULL; prev = node, node = node->n_next) { if (run_mode == FNEXT) { - /* If we have a previous node and it is the current - * folder, return this node. */ + /* + ** If we have a previous node and it is the current + ** folder, return this node. + */ if (prev != NULL && strcmp(prev->n_name, cur) == 0) { return node; } } else if (run_mode == FPREV) { if (strcmp(node->n_name, cur) == 0) { - /* Found current folder in fprev mode; if we have a - * previous node in the list, return it; else return - * the last node. */ + /* + ** Found current folder in fprev mode; + ** if we have a previous node in the list, + ** return it; else return the last node. + */ if (prev == NULL) { return last; } @@ -362,9 +383,12 @@ doit(char *cur, char *folders, char *sequences[]) } fflush(stdout); - /* TODO: Split enough of scan.c out so that we can call it here. */ - command = concat("scan +", node->n_name, " ", sequences_s, - (void *)NULL); + /* + ** TODO: Split enough of scan.c out so that we can + ** call it here. + */ + command = concat("scan +", node->n_name, " ", + sequences_s, (void *)NULL); system(command); free(command); } else { @@ -383,8 +407,10 @@ doit(char *cur, char *folders, char *sequences[]) } } - /* If we're fnext, we haven't checked the last node yet. If it's the - * current folder, return the first node. */ + /* + ** If we're fnext, we haven't checked the last node yet. If it's the + ** current folder, return the first node. + */ if (run_mode == FNEXT && strcmp(last->n_name, cur) == 0) { return first; } @@ -419,8 +445,8 @@ main(int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -431,8 +457,9 @@ main(int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (help, sizeof(help), "%s [switches] [sequences]", - invo_name); + snprintf (help, sizeof(help), + "%s [switches] [sequences]", + invo_name); print_help (help, switches, 1); done (1); case VERSIONSW: @@ -441,11 +468,13 @@ main(int argc, char **argv) case FOLDERSSW: if (!(folders = *argp++) || *folders == '-') - adios(NULL, "missing argument to %s", argp[-2]); + adios(NULL, "missing argument to %s", + argp[-2]); continue; case MODESW: if (!(invo_name = *argp++) || *invo_name == '-') - adios(NULL, "missing argument to %s", argp[-2]); + adios(NULL, "missing argument to %s", + argp[-2]); invo_name = r1bindex(invo_name, '/'); continue; } @@ -491,11 +520,13 @@ main(int argc, char **argv) } if (run_mode == UNSEEN) { - /* All the scan(1)s it runs change the current folder, so we - * need to put it back. Unfortunately, context_replace lamely - * ignores the new value you give it if it is the same one it - * has in memory. So, we'll be lame, too. I'm not sure if i - * should just change context_replace... */ + /* + ** All the scan(1)s it runs change the current folder, so we + ** need to put it back. Unfortunately, context_replace lamely + ** ignores the new value you give it if it is the same one it + ** has in memory. So, we'll be lame, too. I'm not sure if i + ** should just change context_replace... + */ context_replace(pfolder, "defeat_context_replace_optimization"); } diff --git a/uip/packf.c b/uip/packf.c index cb7caf2..732be65 100644 --- a/uip/packf.c +++ b/uip/packf.c @@ -1,10 +1,10 @@ /* - * packf.c -- pack a nmh folder into a file - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** packf.c -- pack a nmh folder into a file +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -59,8 +59,8 @@ main (int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -71,8 +71,7 @@ main (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", - invo_name); + snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -101,7 +100,7 @@ main (int argc, char **argv) adios (NULL, "only one folder at a time!"); folder = pluspath (cp); } else - app_msgarg(&msgs, cp); + app_msgarg(&msgs, cp); } if (!file) @@ -109,9 +108,9 @@ main (int argc, char **argv) file = path (file, TFILE); /* - * Check if file to be created (or appended to) - * exists. If not, ask for confirmation. - */ + ** Check if file to be created (or appended to) + ** exists. If not, ask for confirmation. + */ if (stat (file, &st) == NOTOK) { if (errno != ENOENT) adios (file, "error on file"); @@ -150,18 +149,21 @@ main (int argc, char **argv) seq_setprev (mp); /* set the previous-sequence */ /* open and lock new maildrop file */ - if ((md = mbx_open(file, mbx_style, getuid(), getgid(), m_gmprot())) == NOTOK) + if ((md = mbx_open(file, mbx_style, getuid(), getgid(), m_gmprot())) + == NOTOK) adios (file, "unable to open"); /* copy all the SELECTED messages to the file */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) if (is_selected(mp, msgnum)) { - if ((fd = open (msgnam = m_name (msgnum), O_RDONLY)) == NOTOK) { + if ((fd = open (msgnam = m_name (msgnum), O_RDONLY)) + == NOTOK) { admonish (msgnam, "unable to read message"); break; } - if (mbx_copy (file, mbx_style, md, fd, mapping, NULL, 1) == NOTOK) + if (mbx_copy(file, mbx_style, md, fd, mapping, NULL, 1) + == NOTOK) adios (file, "error writing to file"); close (fd); diff --git a/uip/pick.c b/uip/pick.c index a4f61bd..95f99cd 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -1,10 +1,10 @@ /* - * pick.c -- search for messages by content - * - * This code is Copyright (c) 2002, 2008, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** pick.c -- search for messages by content +** +** This code is Copyright (c) 2002, 2008, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -107,8 +107,7 @@ main (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", - invo_name); + snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help (buf, switches, 1); listsw = 0; /* HACK */ done (1); @@ -128,8 +127,9 @@ main (int argc, char **argv) case SRCHSW: vec[vecp++] = --cp; pattern: - if (!(cp = *argp++))/* allow -xyz arguments */ - adios (NULL, "missing argument to %s", argp[-2]); + if (!(cp = *argp++)) /* allow -xyz arguments */ + adios (NULL, "missing argument to %s", + argp[-2]); vec[vecp++] = cp; continue; case OTHRSW: @@ -145,7 +145,8 @@ main (int argc, char **argv) case SEQSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); /* check if too many sequences specified */ if (seqp >= NUMATTRS) @@ -183,7 +184,7 @@ main (int argc, char **argv) else folder = pluspath (cp); } else - app_msgarg(&msgs, cp); + app_msgarg(&msgs, cp); } vec[vecp] = NULL; @@ -191,9 +192,9 @@ main (int argc, char **argv) free (path ("./", TFOLDER)); /* - * If we didn't specify which messages to search, - * then search the whole folder. - */ + ** If we didn't specify which messages to search, + ** then search the whole folder. + */ if (!msgs.size) app_msgarg(&msgs, "all"); @@ -219,14 +220,15 @@ main (int argc, char **argv) seq_setprev (mp); /* set the previous-sequence */ /* - * If we aren't saving the results to a sequence, - * we default to list the results. - */ + ** If we aren't saving the results to a sequence, + ** we default to list the results. + */ if (listsw == -1) listsw = !seqp; if (publicsw == 1 && is_readonly(mp)) - adios (NULL, "folder %s is read-only, so -public not allowed", folder); + adios (NULL, "folder %s is read-only, so -public not allowed", + folder); if (!pcompile (vec, NULL)) done (1); @@ -234,15 +236,17 @@ main (int argc, char **argv) lo = mp->lowsel; hi = mp->hghsel; - /* If printing message numbers to standard out, force line buffering on. - */ + /* + ** If printing message numbers to standard out, + ** force line buffering on. + */ if (listsw) setvbuf (stdout, NULL, _IOLBF, 0); /* - * Scan through all the SELECTED messages and check for a - * match. If the message does not match, then unselect it. - */ + ** Scan through all the SELECTED messages and check for a + ** match. If the message does not match, then unselect it. + */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { if (is_selected (mp, msgnum)) { if ((fp = fopen (cp = m_name (msgnum), "r")) == NULL) @@ -274,15 +278,15 @@ main (int argc, char **argv) seqs[seqp] = NULL; /* - * Add the matching messages to sequences - */ + ** Add the matching messages to sequences + */ for (seqp = 0; seqs[seqp]; seqp++) if (!seq_addsel (mp, seqs[seqp], publicsw, zerosw)) done (1); /* - * Print total matched if not printing each matched message number. - */ + ** Print total matched if not printing each matched message number. + */ if (!listsw) { printf ("%d hit%s\n", mp->numsel, mp->numsel == 1 ? "" : "s"); } diff --git a/uip/picksbr.c b/uip/picksbr.c index fd29c4c..c0692a8 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -1,10 +1,10 @@ /* - * picksbr.c -- routines to help pick along... - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** picksbr.c -- routines to help pick along... +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -59,15 +59,15 @@ static struct swit parswit[] = { /* DEFINITIONS FOR PATTERN MATCHING */ /* - * We really should be using re_comp() and re_exec() here. Unfortunately, - * pick advertises that lowercase characters matches characters of both - * cases. Since re_exec() doesn't exhibit this behavior, we are stuck - * with this version. Furthermore, we need to be able to save and restore - * the state of the pattern matcher in order to do things "efficiently". - * - * The matching power of this algorithm isn't as powerful as the re_xxx() - * routines (no \(xxx\) and \n constructs). Such is life. - */ +** We really should be using re_comp() and re_exec() here. Unfortunately, +** pick advertises that lowercase characters matches characters of both +** cases. Since re_exec() doesn't exhibit this behavior, we are stuck +** with this version. Furthermore, we need to be able to save and restore +** the state of the pattern matcher in order to do things "efficiently". +** +** The matching power of this algorithm isn't as powerful as the re_xxx() +** routines (no \(xxx\) and \n constructs). Such is life. +*/ #define CCHR 2 #define CDOT 4 @@ -122,8 +122,8 @@ static char cc[] = { }; /* - * DEFINITIONS FOR NEXUS - */ +** DEFINITIONS FOR NEXUS +*/ #define nxtarg() (*argp ? *argp++ : NULL) #define prvarg() argp-- @@ -178,14 +178,14 @@ static char **argp; static struct nexus *head; /* - * prototypes for date routines - */ +** prototypes for date routines +*/ static struct tws *tws_parse(); static struct tws *tws_special(); /* - * static prototypes - */ +** static prototypes +*/ static void PRaction(); static int gcompile(); static int advance(); @@ -409,28 +409,32 @@ nexp3 (void) strncpy(temp, parswit[i].sw, sizeof(temp)); temp[sizeof(temp) - 1] = '\0'; dp = *brkstring (temp, " ", NULL); - header: ; - if (!(cp = nxtarg ())) {/* allow -xyz arguments */ - padvise (NULL, "missing argument to %s", argp[-2]); +header: ; + if (!(cp = nxtarg ())) { /* allow -xyz arguments */ + padvise (NULL, "missing argument to %s", + argp[-2]); return NULL; } n = newnexus (GREPaction); n->n_header = 1; - snprintf (buffer, sizeof(buffer), "^%s[ \t]*:.*%s", dp, cp); + snprintf (buffer, sizeof(buffer), "^%s[ \t]*:.*%s", + dp, cp); dp = buffer; goto pattern; case PRSRCH: n = newnexus (GREPaction); n->n_header = 0; - if (!(cp = nxtarg ())) {/* allow -xyz arguments */ - padvise (NULL, "missing argument to %s", argp[-2]); + if (!(cp = nxtarg ())) { /* allow -xyz arguments */ + padvise (NULL, "missing argument to %s", + argp[-2]); return NULL; } dp = cp; - pattern: ; +pattern: ; if (!gcompile (n, dp)) { - padvise (NULL, "pattern error in %s %s", argp[-2], cp); + padvise (NULL, "pattern error in %s %s", + argp[-2], cp); return NULL; } n->n_patbuf = getcpy (dp); @@ -442,21 +446,24 @@ nexp3 (void) case PRDATF: if (!(datesw = nxtarg ()) || *datesw == '-') { - padvise (NULL, "missing argument to %s", argp[-2]); + padvise (NULL, "missing argument to %s", + argp[-2]); return NULL; } return nexp3 (); case PRAFTR: case PRBEFR: - if (!(cp = nxtarg ())) {/* allow -xyz arguments */ - padvise (NULL, "missing argument to %s", argp[-2]); + if (!(cp = nxtarg ())) { /* allow -xyz arguments */ + padvise (NULL, "missing argument to %s", + argp[-2]); return NULL; } n = newnexus (TWSaction); n->n_datef = datesw; if (!tcompile (cp, &n->n_tws, n->n_after = i == PRAFTR)) { - padvise (NULL, "unable to parse %s %s", argp[-2], cp); + padvise (NULL, "unable to parse %s %s", + argp[-2], cp); return NULL; } return n; @@ -949,7 +956,8 @@ plist free (bp), bp = NULL; bp = add (buf, NULL); while (state == FLDPLUS) { - state = m_getfld (state, name, buf, sizeof buf, fp); + state = m_getfld (state, name, buf, + sizeof buf, fp); bp = add (buf, bp); } if (!mh_strcasecmp (name, n->n_datef)) diff --git a/uip/prompter.c b/uip/prompter.c index f92eda1..88a56df 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -1,10 +1,10 @@ /* - * prompter.c -- simple prompting editor front-end - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** prompter.c -- simple prompting editor front-end +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -87,8 +87,8 @@ static int sigint = 0; static jmp_buf sigenv; /* - * prototypes - */ +** prototypes +*/ int getln (char *, int); static int chrcnv (char *); static void chrdsp (char *, char); @@ -128,8 +128,9 @@ main (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (buffer, sizeof(buffer), "%s [switches] file", - invo_name); + snprintf (buffer, sizeof(buffer), + "%s [switches] file", + invo_name); print_help (buffer, switches, 1); done (1); case VERSIONSW: @@ -173,9 +174,8 @@ main (int argc, char **argv) doteof = 0; continue; } - } else { - if (!drft) - drft = cp; + } else if (!drft) { + drft = cp; } if (!drft) @@ -184,13 +184,14 @@ main (int argc, char **argv) adios (drft, "unable to open"); tfile = m_mktemp2(NULL, invo_name, NULL, &out); - if (tfile == NULL) adios("prompter", "unable to create temporary file"); + if (tfile == NULL) + adios("prompter", "unable to create temporary file"); chmod (tmpfil, 0600); strncpy (tmpfil, tfile, sizeof(tmpfil)); /* - * Are we changing the kill or erase character? - */ + ** Are we changing the kill or erase character? + */ if (killp || erasep) { #ifdef HAVE_TERMIOS_H cc_t save_erase, save_kill; @@ -237,10 +238,10 @@ main (int argc, char **argv) fflush (stdout); /* - * We set the kill and erase character back to original - * setup in terminal structure so we can easily - * restore it upon exit. - */ + ** We set the kill and erase character back to original + ** setup in terminal structure so we can easily + ** restore it upon exit. + */ KILL = save_kill; ERASE = save_erase; } @@ -249,17 +250,17 @@ main (int argc, char **argv) SIGNAL2 (SIGINT, intrser); /* - * Loop through the lines of the draft skeleton. - */ + ** Loop through the lines of the draft skeleton. + */ for (state = FLD;;) { switch (state = m_getfld (state, name, field, sizeof(field), in)) { case FLD: case FLDEOF: case FLDPLUS: /* - * Check if the value of field contains anything - * other than space or tab. - */ + ** Check if the value of field contains + ** anything other than space or tab. + */ for (cp = field; *cp; cp++) if (*cp != ' ' && *cp != '\t') break; diff --git a/uip/rcvdist.c b/uip/rcvdist.c index 89ed029..53d7455 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -1,10 +1,10 @@ /* - * rcvdist.c -- asynchronously redistribute messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** rcvdist.c -- asynchronously redistribute messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -28,8 +28,8 @@ static char drft[BUFSIZ] = ""; static char tmpfil[BUFSIZ] = ""; /* - * prototypes - */ +** prototypes +*/ static void rcvdistout (FILE *, char *, char *); static void unlink_done (int) NORETURN; @@ -69,9 +69,7 @@ main (int argc, char **argv) continue; case HELPSW: - snprintf (buf, sizeof(buf), - "%s [switches] [switches for postproc] address ...", - invo_name); + snprintf (buf, sizeof(buf), "%s [switches] [switches for postproc] address ...", invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -88,8 +86,7 @@ main (int argc, char **argv) } if (addrs == NULL) - adios (NULL, "usage: %s [switches] [switches for postproc] address ...", - invo_name); + adios (NULL, "usage: %s [switches] [switches for postproc] address ...", invo_name); umask (~m_gmprot ()); @@ -180,9 +177,12 @@ rcvdistout (FILE *inb, char *form, char *addrs) cp = new_fs (form ? form : rcvdistcomps, NULL, NULL); format_len = strlen (cp); ncomps = fmt_compile (cp, &fmt) + 1; - if (!(nxtbuf = compbuffers = (char **) calloc ((size_t) ncomps, sizeof(char *)))) + if (!(nxtbuf = compbuffers = + (char **) calloc ((size_t) ncomps, sizeof(char *)))) adios (NULL, "unable to allocate component buffers"); - if (!(savecomp = used_buf = (struct comp **) calloc ((size_t) (ncomps + 1), sizeof(struct comp *)))) + if (!(savecomp = used_buf = + (struct comp **) calloc ((size_t) (ncomps + 1), + sizeof(struct comp *)))) adios (NULL, "unable to allocate component buffer stack"); savecomp += ncomps + 1; *--savecomp = 0; @@ -220,8 +220,7 @@ rcvdistout (FILE *inb, char *form, char *addrs) if (cptr->c_type & CT_ADDR) { cp[i] = 0; cp = add (",\n\t", cp); - } - else + } else cp = add ("\t", cp); } cptr->c_text = add (tmpbuf, cp); @@ -264,7 +263,8 @@ finished: ; fclose (out); free (scanl); - for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++); nxtbuf++, i--) + for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++); + nxtbuf++, i--) free (cptr->c_text); while (i-- > 0) free (*nxtbuf++); diff --git a/uip/rcvpack.c b/uip/rcvpack.c index b1bc518..a89d1fe 100644 --- a/uip/rcvpack.c +++ b/uip/rcvpack.c @@ -1,10 +1,10 @@ /* - * rcvpack.c -- append message to a file - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** rcvpack.c -- append message to a file +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -25,8 +25,8 @@ static struct swit switches[] = { }; /* - * default format in which to save messages - */ +** default format in which to save messages +*/ static int mbx_style = MBOX_FORMAT; @@ -60,7 +60,9 @@ main (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [switches] file", invo_name); + snprintf (buf, sizeof(buf), + "%s [switches] file", + invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -87,11 +89,13 @@ main (int argc, char **argv) rewind (stdin); /* open and lock the file */ - if ((md = mbx_open (file, mbx_style, getuid(), getgid(), m_gmprot())) == NOTOK) + if ((md = mbx_open (file, mbx_style, getuid(), getgid(), m_gmprot())) + == NOTOK) done (RCV_MBX); /* append the message */ - if (mbx_copy (file, mbx_style, md, fileno(stdin), 1, NULL, 0) == NOTOK) { + if (mbx_copy (file, mbx_style, md, fileno(stdin), 1, NULL, 0) + == NOTOK) { mbx_close (file, md); done (RCV_MBX); } diff --git a/uip/rcvstore.c b/uip/rcvstore.c index 2458852..40adf86 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -1,10 +1,10 @@ /* - * rcvstore.c -- asynchronously add mail to a folder - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** rcvstore.c -- asynchronously add mail to a folder +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -41,8 +41,8 @@ static struct swit switches[] = { /* - * name of temporary file to store incoming message - */ +** name of temporary file to store incoming message +*/ static char *tmpfilenam = NULL; static void unlink_done(int) NORETURN; @@ -137,7 +137,8 @@ main (int argc, char **argv) else folder = pluspath (cp); } else { - adios (NULL, "usage: %s [+folder] [switches]", invo_name); + adios (NULL, "usage: %s [+folder] [switches]", + invo_name); } } @@ -195,22 +196,23 @@ main (int argc, char **argv) } /* - * read folder and create message structure - */ + ** read folder and create message structure + */ if (!(mp = folder_read (folder))) adios (NULL, "unable to read folder %s", folder); /* - * Link message into folder, and possibly add - * to the Unseen-Sequence's. - */ - if ((msgnum = folder_addmsg (&mp, tmpfilenam, 0, unseensw, 0, 0, (char *)0)) == -1) + ** Link message into folder, and possibly add + ** to the Unseen-Sequence's. + */ + if ((msgnum = folder_addmsg (&mp, tmpfilenam, 0, unseensw, 0, 0, + (char *)0)) == -1) done (1); /* - * Add the message to any extra sequences - * that have been specified. - */ + ** Add the message to any extra sequences + ** that have been specified. + */ for (seqp = 0; seqs[seqp]; seqp++) { if (!seq_addmsg (mp, seqs[seqp], msgnum, publicsw, zerosw)) done (1); @@ -229,8 +231,8 @@ main (int argc, char **argv) } /* - * Clean up and exit - */ +** Clean up and exit +*/ static void unlink_done(int status) { diff --git a/uip/rcvtty.c b/uip/rcvtty.c index 577873f..b3c1d52 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -1,15 +1,15 @@ /* - * rcvtty.c -- a rcvmail program (a lot like rcvalert) handling IPC ttys - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** rcvtty.c -- a rcvmail program (a lot like rcvalert) handling IPC ttys +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ /* Changed to use getutent() and friends. Assumes that when getutent() exists, - * a number of other things also exist. Please check. - * Ruud de Rooij Sun, 28 May 2000 17:28:55 +0200 - */ +** a number of other things also exist. Please check. +** Ruud de Rooij Sun, 28 May 2000 17:28:55 +0200 +*/ #include #include @@ -70,13 +70,13 @@ static char *form = NULL; static char *format = NULL; /* - * external prototypes - */ +** external prototypes +*/ char *getusername(void); /* - * static prototypes - */ +** static prototypes +*/ static RETSIGTYPE alrmser (int); static int message_fd (char **); static int header_fd (void); @@ -119,7 +119,9 @@ main (int argc, char **argv) continue; case HELPSW: - snprintf (buf, sizeof(buf), "%s [command ...]", invo_name); + snprintf (buf, sizeof(buf), + "%s [command ...]", + invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -175,12 +177,11 @@ main (int argc, char **argv) while ((utp = getutent()) != NULL) { if ( #ifdef HAVE_STRUCT_UTMP_UT_TYPE - utp->ut_type == USER_PROCESS - && + utp->ut_type == USER_PROCESS && #endif - utp->ut_name[0] != 0 - && utp->ut_line[0] != 0 - && strncmp (user, utp->ut_name, sizeof(utp->ut_name)) == 0) { + utp->ut_name[0] != 0 && utp->ut_line[0] != 0 + && strncmp (user, utp->ut_name, + sizeof(utp->ut_name)) == 0) { strncpy (tty, utp->ut_line, sizeof(utp->ut_line)); alert (tty, md); } @@ -191,7 +192,8 @@ main (int argc, char **argv) exit (RCV_MBX); while (fread ((char *) &ut, sizeof(ut), 1, uf) == 1) if (ut.ut_name[0] != 0 - && strncmp (user, ut.ut_name, sizeof(ut.ut_name)) == 0) { + && strncmp (user, ut.ut_name, + sizeof(ut.ut_name)) == 0) { strncpy (tty, ut.ut_line, sizeof(ut.ut_line)); alert (tty, md); } @@ -239,7 +241,8 @@ message_fd (char **vec) /* parent process */ if (!setjmp (myctx)) { SIGNAL (SIGALRM, alrmser); - bytes = fstat(fileno (stdin), &st) != NOTOK ? (int) st.st_size : 100; + bytes = fstat(fileno (stdin), &st) != NOTOK ? + (int) st.st_size : 100; /* amount of time to wait depends on message size */ if (bytes <= 100) { @@ -259,9 +262,9 @@ message_fd (char **vec) return fd; } else { /* - * Ruthlessly kill the child and anything - * else in its process group. - */ + ** Ruthlessly kill the child and anything + ** else in its process group. + */ KILLPG(child_id, SIGKILL); } close (fd); @@ -316,9 +319,9 @@ alert (char *tty, int md) snprintf (ttyspec, sizeof(ttyspec), "/dev/%s", tty); /* - * The mask depends on whether we are checking for - * write permission based on `biff' or `mesg'. - */ + ** The mask depends on whether we are checking for + ** write permission based on `biff' or `mesg'. + */ mask = biff ? S_IEXEC : (S_IWRITE >> 3); if (stat (ttyspec, &st) == NOTOK || (st.st_mode & mask) == 0) return; diff --git a/uip/refile.c b/uip/refile.c index 2ac8916..b1c2aa9 100644 --- a/uip/refile.c +++ b/uip/refile.c @@ -1,11 +1,11 @@ /* - * refile.c -- move or link message(s) from a source folder - * -- into one or more destination folders - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** refile.c -- move or link message(s) from a source folder +** -- into one or more destination folders +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -48,8 +48,8 @@ struct st_fold { }; /* - * static prototypes - */ +** static prototypes +*/ static void opnfolds (struct st_fold *, int); static void clsfolds (struct st_fold *, int); static void remove_files (int, char **); @@ -82,8 +82,8 @@ main (int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -94,8 +94,7 @@ main (int argc, char **argv) adios (NULL, "-%s unknown\n", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [msgs] [switches] +folder ...", - invo_name); + snprintf (buf, sizeof(buf), "%s [msgs] [switches] +folder ...", invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -128,20 +127,25 @@ main (int argc, char **argv) adios (NULL, "only one source folder at a time!"); if (!(cp = *argp++) || *cp == '-') adios (NULL, "missing argument to %s", argp[-2]); - folder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp, - *cp != '@' ? TFOLDER : TSUBCWF); + folder = path (*cp == '+' || *cp == '@' ? + cp + 1 : cp, + *cp != '@' ? + TFOLDER : TSUBCWF); continue; case FILESW: if (filep > NFOLDERS) - adios (NULL, "only %d files allowed!", NFOLDERS); + adios (NULL, "only %d files allowed!", + NFOLDERS); if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); files[filep++] = path (cp, TFILE); continue; case RPROCSW: if (!(rmmproc = *argp++) || *rmmproc == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case NRPRCSW: rmmproc = NULL; @@ -150,7 +154,8 @@ main (int argc, char **argv) } if (*cp == '+' || *cp == '@') { if (foldp > NFOLDERS) - adios (NULL, "only %d folders allowed!", NFOLDERS); + adios (NULL, "only %d folders allowed!", + NFOLDERS); folders[foldp++].f_name = pluspath (cp); } else @@ -168,8 +173,8 @@ main (int argc, char **argv) #endif /* WHATNOW */ /* - * We are refiling a file to the folders - */ + ** We are refiling a file to the folders + */ if (filep > 0) { if (folder || msgs.size) adios (NULL, "use -file or some messages, not both"); @@ -210,11 +215,11 @@ main (int argc, char **argv) opnfolds (folders, foldp); /* Link all the selected messages into destination folders. - * - * This causes the add hook to be run for messages that are - * linked into another folder. The refile hook is run for - * messages that are moved to another folder. - */ + ** + ** This causes the add hook to be run for messages that are + ** linked into another folder. The refile hook is run for + ** messages that are moved to another folder. + */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { if (is_selected (mp, msgnum)) { cp = getcpy (m_name (msgnum)); @@ -225,22 +230,23 @@ main (int argc, char **argv) } /* - * This is a hack. If we are using an external rmmproc, - * then save the current folder to the context file, - * so the external rmmproc will remove files from the correct - * directory. This should be moved to folder_delmsgs(). - */ + ** This is a hack. If we are using an external rmmproc, + ** then save the current folder to the context file, + ** so the external rmmproc will remove files from the correct + ** directory. This should be moved to folder_delmsgs(). + */ if (rmmproc) { context_replace (pfolder, folder); context_save (); fflush (stdout); } - /* If -nolink, then "remove" messages from source folder. - * - * Note that folder_delmsgs does not call the delete hook - * because the message has already been handled above. - */ + /* + ** If -nolink, then "remove" messages from source folder. + ** + ** Note that folder_delmsgs does not call the delete hook + ** because the message has already been handled above. + */ if (!linkf) { folder_delmsgs (mp, unlink_msgs, 1); } @@ -261,9 +267,9 @@ main (int argc, char **argv) /* - * Read all the destination folders and - * create folder structures for all of them. - */ +** Read all the destination folders and +** create folder structures for all of them. +*/ static void opnfolds (struct st_fold *folders, int nfolders) @@ -292,9 +298,9 @@ opnfolds (struct st_fold *folders, int nfolders) /* - * Set the Previous-Sequence and then sychronize the - * sequence file, for each destination folder. - */ +** Set the Previous-Sequence and then sychronize the +** sequence file, for each destination folder. +*/ static void clsfolds (struct st_fold *folders, int nfolders) @@ -311,10 +317,10 @@ clsfolds (struct st_fold *folders, int nfolders) /* - * If you have a "rmmproc" defined, we called that - * to remove all the specified files. If "rmmproc" - * is not defined, then just unlink the files. - */ +** If you have a "rmmproc" defined, we called that +** to remove all the specified files. If "rmmproc" +** is not defined, then just unlink the files. +*/ static void remove_files (int filep, char **files) @@ -343,18 +349,21 @@ remove_files (int filep, char **files) /* - * Link (or copy) the message into each of - * the destination folders. - */ +** Link (or copy) the message into each of +** the destination folders. +*/ static int -m_file (char *msgfile, struct st_fold *folders, int nfolders, int preserve, int refile) +m_file (char *msgfile, struct st_fold *folders, int nfolders, int preserve, + int refile) { int msgnum; struct st_fold *fp, *ep; for (fp = folders, ep = folders + nfolders; fp < ep; fp++) { - if ((msgnum = folder_addmsg (&fp->f_mp, msgfile, 1, 0, preserve, nfolders == 1 && refile, maildir)) == -1) + if ((msgnum = folder_addmsg (&fp->f_mp, msgfile, 1, 0, + preserve, nfolders == 1 && refile, maildir)) + == -1) return 1; } return 0; diff --git a/uip/repl.c b/uip/repl.c index db41ebb..f6016de 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -1,10 +1,10 @@ /* - * repl.c -- reply to a message - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** repl.c -- reply to a message +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -97,8 +97,8 @@ char *fcc = NULL; /* folders to add to Fcc: header */ /* - * prototypes - */ +** prototypes +*/ void docc (char *, int); @@ -139,8 +139,7 @@ main (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s: [+folder] [msg] [switches]", - invo_name); + snprintf (buf, sizeof(buf), "%s: [+folder] [msg] [switches]", invo_name); print_help (buf, switches, 1); done (0); case VERSIONSW: @@ -182,7 +181,8 @@ main (int argc, char **argv) continue; case WHATSW: - if (!(whatnowproc = *argp++) || *whatnowproc == '-') + if (!(whatnowproc = *argp++) || + *whatnowproc == '-') adios (NULL, "missing argument to %s", argp[-2]); nwhat = 0; continue; @@ -199,7 +199,8 @@ main (int argc, char **argv) adios (NULL, "missing argument to %s", argp[-2]); dp = NULL; if (*cp == '@') - cp = dp = path (cp + 1, TSUBCWF); + cp = dp = path (cp + 1, + TSUBCWF); if (fcc) fcc = add (", ", fcc); fcc = add (cp, fcc); @@ -299,13 +300,13 @@ main (int argc, char **argv) if (file) { /* - * We are replying to a file. - */ + ** We are replying to a file. + */ anot = 0; /* we don't want to annotate a file */ } else { /* - * We are replying to a message. - */ + ** We are replying to a message. + */ if (!msg) msg = "cur"; if (!folder) @@ -331,7 +332,7 @@ main (int argc, char **argv) if (mp->numsel > 1) adios (NULL, "only one message at a time!"); - context_replace (pfolder, folder); /* update current folder */ + context_replace (pfolder, folder); /* update current folder */ seq_setcur (mp, mp->lowsel); /* update current message */ seq_save (mp); /* synchronize sequences */ context_save (); /* save the context file */ @@ -369,7 +370,8 @@ docc (char *cp, int ccflag) ambigsw (cp, ccswitches); done (1); case UNKWNSW: - adios (NULL, "-%scc %s unknown", ccflag ? "" : "no", cp); + adios (NULL, "-%scc %s unknown", + ccflag ? "" : "no", cp); case CTOSW: ccto = ccflag; diff --git a/uip/replsbr.c b/uip/replsbr.c index add1371..8e60a52 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -1,10 +1,10 @@ /* - * replsbr.c -- routines to help repl along... - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** replsbr.c -- routines to help repl along... +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -26,12 +26,12 @@ static char *dfhost = NULL; static struct mailname mq = { NULL }; /* - * Buffer size for content part of header fields. - * We want this to be large enough so that we don't - * do a lot of extra FLDPLUS calls on m_getfld but - * small enough so that we don't snarf the entire - * message body when we're not going to use any of it. - */ +** Buffer size for content part of header fields. +** We want this to be large enough so that we don't +** do a lot of extra FLDPLUS calls on m_getfld but +** small enough so that we don't snarf the entire +** message body when we're not going to use any of it. +*/ #define SBUFSIZ 256 static struct format *fmt; @@ -59,8 +59,8 @@ static char *addrcomps[] = { }; /* - * static prototypes - */ +** static prototypes +*/ static int insert (struct mailname *); static void replfilter (FILE *, FILE *, char *); @@ -115,8 +115,8 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, } /* - * ignore any components killed by command line switches - */ + ** ignore any components killed by command line switches + */ if (!ccto) { FINDCOMP (cptr, "to"); if (cptr) @@ -142,21 +142,21 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, ismymbox (NULL); /* - * pick any interesting stuff out of msg "inb" - */ + ** pick any interesting stuff out of msg "inb" + */ for (state = FLD;;) { state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb); switch (state) { case FLD: case FLDPLUS: /* - * if we're interested in this component, - * save a pointer to the component text, - * then start using our next free buffer - * as the component temp buffer (buffer - * switching saves an extra copy of the - * component text). - */ + ** if we're interested in this component, + ** save a pointer to the component text, + ** then start using our next free buffer + ** as the component temp buffer (buffer + ** switching saves an extra copy of the + ** component text). + */ if ((cptr = wantcomp[CHASH(name)])) do { if (!mh_strcasecmp(name, cptr->c_name)) { @@ -205,13 +205,13 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, } /* - * format and output the header lines. - */ + ** format and output the header lines. + */ finished: /* - * if there's a "Subject" component, strip any "Re:"s off it - */ + ** if there's a "Subject" component, strip any "Re:"s off it + */ FINDCOMP (cptr, "subject") if (cptr && (cp = cptr->c_text)) { register char *sp = cp; @@ -246,9 +246,9 @@ finished: } /* - * Check if we should filter the message - * or add mhbuild directives - */ + ** Check if we should filter the message + ** or add mhbuild directives + */ if (filter) { fflush(out); if (ferror (out)) @@ -256,8 +256,8 @@ finished: replfilter (inb, out, filter); } else if (mime && mp) { - fprintf (out, "#forw [original message] +%s %s\n", - mp->foldpath, m_name (mp->lowsel)); + fprintf (out, "#forw [original message] +%s %s\n", + mp->foldpath, m_name (mp->lowsel)); } fflush(out); @@ -267,7 +267,8 @@ finished: /* return dynamically allocated buffers */ free (scanl); - for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++); nxtbuf++, i--) + for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++); + nxtbuf++, i--) free (cptr->c_text); /* if not nxtbuf, nxtbuf already freed */ while ( i-- > 0) free (*nxtbuf++); /* free unused nxtbufs */ @@ -285,9 +286,9 @@ static unsigned int bufsiz=0; /* current size of buf */ #define CPY(s) { cp = (s); while ((*dst++ = *cp++)) ; --dst; } /* - * check if there's enough room in buf for str. - * add more mem if needed - */ +** check if there's enough room in buf for str. +** add more mem if needed +*/ #define CHECKMEM(str) \ if ((len = strlen (str)) >= bufend - dst) {\ int i = dst - buf;\ @@ -301,16 +302,16 @@ static unsigned int bufsiz=0; /* current size of buf */ /* - * fmt_scan will call this routine if the user includes the function - * "(formataddr {component})" in a format string. "orig" is the - * original contents of the string register. "str" is the address - * string to be formatted and concatenated onto orig. This routine - * returns a pointer to the concatenated address string. - * - * We try to not do a lot of malloc/copy/free's (which is why we - * don't call "getcpy") but still place no upper limit on the - * length of the result string. - */ +** fmt_scan will call this routine if the user includes the function +** "(formataddr {component})" in a format string. "orig" is the +** original contents of the string register. "str" is the address +** string to be formatted and concatenated onto orig. This routine +** returns a pointer to the concatenated address string. +** +** We try to not do a lot of malloc/copy/free's (which is why we +** don't call "getcpy") but still place no upper limit on the +** length of the result string. +*/ char * formataddr (char *orig, char *str) { @@ -330,9 +331,9 @@ 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) { @@ -347,7 +348,8 @@ formataddr (char *orig, char *str) /* concatenate all the new addresses onto 'buf' */ for (isgroup = 0; (cp = getname (str)); ) { if ((mp = getm (cp, dfhost, dftype, AD_NAME, error)) == NULL) { - snprintf (baddr, sizeof(baddr), "\t%s -- %s\n", cp, error); + snprintf (baddr, sizeof(baddr), "\t%s -- %s\n", + cp, error); badaddrs = add (baddr, badaddrs); continue; } @@ -392,14 +394,16 @@ insert (struct mailname *np) for (mp = &mq; mp->m_next; mp = mp->m_next) { if (!mh_strcasecmp (np->m_host, mp->m_next->m_host) - && !mh_strcasecmp (np->m_mbox, mp->m_next->m_mbox)) + && !mh_strcasecmp (np->m_mbox, + mp->m_next->m_mbox)) return 0; } if (!ccme && ismymbox (np)) return 0; if (querysw) { - snprintf (buffer, sizeof(buffer), "Reply to %s? ", adrformat (np)); + snprintf (buffer, sizeof(buffer), "Reply to %s? ", + adrformat (np)); if (!gans (buffer, anoyes)) return 0; } @@ -415,10 +419,10 @@ insert (struct mailname *np) /* - * Call the mhlproc - * - * This function expects that argument out has been fflushed by the caller. - */ +** Call the mhlproc +** +** This function expects that argument out has been fflushed by the caller. +*/ static void replfilter (FILE *in, FILE *out, char *filter) @@ -447,7 +451,8 @@ replfilter (FILE *in, FILE *out, char *filter) dup2 (fileno (out), fileno (stdout)); closefds (3); - execlp (mhlproc, mhl, "-form", filter, "-noclear", NULL); + execlp (mhlproc, mhl, "-form", filter, "-noclear", + NULL); errstr = strerror(errno); write(2, "unable to exec ", 15); write(2, mhlproc, strlen(mhlproc)); diff --git a/uip/rmf.c b/uip/rmf.c index f3c335e..050817b 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -1,10 +1,10 @@ /* - * rmf.c -- remove a folder - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** rmf.c -- remove a folder +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include @@ -21,8 +21,8 @@ static struct swit switches[] = { }; /* - * static prototypes - */ +** static prototypes +*/ static int rmf(char *); static void rma (char *); @@ -55,8 +55,7 @@ main (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [+folder] [switches]", - invo_name); + snprintf (buf, sizeof(buf), "%s [+folder] [switches]", invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -77,7 +76,8 @@ main (int argc, char **argv) else folder = pluspath (cp); } else { - adios (NULL, "usage: %s [+folder] [switches]", invo_name); + adios (NULL, "usage: %s [+folder] [switches]", + invo_name); } } @@ -94,7 +94,8 @@ main (int argc, char **argv) interactive = defolder; if (strchr (folder, '/') && (*folder != '/') && (*folder != '.')) { - for (cp = copy (folder, newfolder); cp > newfolder && *cp != '/'; cp--) + for (cp = copy (folder, newfolder); + cp > newfolder && *cp != '/'; cp--) continue; if (cp > newfolder) *cp = '\0'; @@ -115,7 +116,8 @@ main (int argc, char **argv) char *cfolder = context_find(pfolder); if (cfolder && strcmp (cfolder, newfolder)) { printf ("[+%s now current]\n", newfolder); - context_replace (pfolder, newfolder); /* update current folder */ + /* update current folder */ + context_replace (pfolder, newfolder); } } context_save (); /* save the context file */ @@ -134,7 +136,8 @@ rmf (char *folder) switch (i = chdir (maildir = m_maildir (folder))) { case OK: - if (access (".", W_OK) != NOTOK && access ("..", W_OK) != NOTOK) + if (access (".", W_OK) != NOTOK && + access ("..", W_OK) != NOTOK) break; /* fall otherwise */ case NOTOK: @@ -144,8 +147,7 @@ rmf (char *folder) printf ("[+%s de-referenced]\n", folder); return OK; } - advise (NULL, "you have no profile entry for the %s folder +%s", - i == NOTOK ? "unreadable" : "read-only", folder); + advise (NULL, "you have no profile entry for the %s folder +%s", i == NOTOK ? "unreadable" : "read-only", folder); return NOTOK; } @@ -154,8 +156,8 @@ rmf (char *folder) others = 0; /* - * Run the external delete hook program. - */ + ** Run the external delete hook program. + */ (void)ext_hook("del-hook", maildir, (char *)0); @@ -164,7 +166,8 @@ rmf (char *folder) switch (dp->d_name[0]) { case '.': if (strcmp (dp->d_name, ".") == 0 - || strcmp (dp->d_name, "..") == 0) + || strcmp (dp->d_name, "..") + == 0) continue; /* else fall */ case ',': @@ -181,7 +184,8 @@ rmf (char *folder) if (m_atoi (dp->d_name)) break; if (strcmp (dp->d_name, altmsglink) == 0 - || strncmp (dp->d_name, backup_prefix, j) == 0) + || strncmp (dp->d_name, + backup_prefix, j) == 0) break; admonish (NULL, "file \"%s/%s\" not deleted", @@ -198,9 +202,9 @@ rmf (char *folder) closedir (dd); /* - * Remove any relevant private sequences - * or attributes from context file. - */ + ** Remove any relevant private sequences + ** or attributes from context file. + */ rma (folder); chdir (".."); @@ -219,9 +223,9 @@ rmf (char *folder) /* - * Remove all the (private) sequence information for - * this folder from the profile/context list. - */ +** Remove all the (private) sequence information for +** this folder from the profile/context list. +*/ static void rma (char *folder) @@ -234,16 +238,17 @@ rma (char *folder) plen = strlen (cp = m_mailpath (folder)) + 1; /* - * Search context list for keys that look like - * "atr-something-folderpath", and remove them. - */ + ** Search context list for keys that look like + ** "atr-something-folderpath", and remove them. + */ for (np = m_defs, pp = NULL; np; np = np->n_next) { if (ssequal ("atr-", np->n_name) && (j = strlen (np->n_name) - plen) > alen && *(np->n_name + j) == '-' && strcmp (cp, np->n_name + j + 1) == 0) { if (!np->n_context) - admonish (NULL, "bug: context_del(key=\"%s\")", np->n_name); + admonish (NULL, "bug: context_del(key=\"%s\")", + np->n_name); if (pp) { pp->n_next = np->n_next; np = pp; diff --git a/uip/rmm.c b/uip/rmm.c index e04efaa..6e991b0 100644 --- a/uip/rmm.c +++ b/uip/rmm.c @@ -1,10 +1,10 @@ /* - * rmm.c -- remove a message(s) - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** rmm.c -- remove a message(s) +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -54,8 +54,7 @@ main (int argc, char **argv) adios (NULL, "-%s unknown\n", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", - invo_name); + snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -105,12 +104,12 @@ main (int argc, char **argv) seq_setprev (mp); /* set the previous-sequence */ /* - * This is hackish. If we are using a external rmmproc, - * then we need to update the current folder in the - * context so the external rmmproc will remove files - * from the correct directory. This should be moved to - * folder_delmsgs(). - */ + ** This is hackish. If we are using a external rmmproc, + ** then we need to update the current folder in the + ** context so the external rmmproc will remove files + ** from the correct directory. This should be moved to + ** folder_delmsgs(). + */ if (rmmproc) { context_replace (pfolder, folder); context_save (); diff --git a/uip/scan.c b/uip/scan.c index 52a40af..3a0e6c6 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -1,10 +1,10 @@ /* - * scan.c -- display a one-line "scan" listing of folder or messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** scan.c -- display a one-line "scan" listing of folder or messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -44,15 +44,15 @@ static struct swit switches[] = { /* - * global for sbr/formatsbr.c - yech! - */ +** global for sbr/formatsbr.c - yech! +*/ #ifdef LBL extern struct msgs *fmt_current_folder; #endif /* - * prototypes - */ +** prototypes +*/ void clear_screen(void); /* from termsbr.c */ @@ -83,8 +83,8 @@ main (int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -95,8 +95,7 @@ main (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", - invo_name); + snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -116,7 +115,8 @@ main (int argc, char **argv) format = NULL; continue; case FMTSW: - if (!(format = *argp++) || *format == '-') + if (!(format = *argp++) || + *format == '-') adios (NULL, "missing argument to %s", argp[-2]); form = NULL; continue; @@ -161,13 +161,13 @@ main (int argc, char **argv) free (path ("./", TFOLDER)); /* - * Get new format string. Must be before chdir(). - */ + ** Get new format string. Must be before chdir(). + */ nfs = new_fs (form, format, FORMAT); /* - * We are scanning a maildrop file - */ + ** We are scanning a maildrop file + */ if (file) { if (msgs.size) adios (NULL, "\"msgs\" not allowed with -file"); @@ -201,8 +201,8 @@ main (int argc, char **argv) } /* - * We are scanning a folder - */ + ** We are scanning a folder + */ if (!msgs.size) app_msgarg(&msgs, "all"); @@ -232,9 +232,9 @@ main (int argc, char **argv) context_save (); /* save the context file */ /* - * Get the sequence number for each sequence - * specified by Unseen-Sequence - */ + ** Get the sequence number for each sequence + ** specified by Unseen-Sequence + */ if ((cp = context_find (usequence)) && *cp) { char **ap, *dp; @@ -266,21 +266,23 @@ main (int argc, char **argv) admonish (cp, "unable to open message"); #if 0 else - printf ("%*d unreadable\n", DMAXFOLDER, msgnum); + printf ("%*d unreadable\n", + DMAXFOLDER, msgnum); #endif continue; } #ifndef JLR if (hdrflag) { - printf ("FOLDER %s\t%s\n", folder, dtimenow(1)); + printf ("FOLDER %s\t%s\n", folder, + dtimenow(1)); } #endif /* JLR */ /* - * Check if message is in any sequence given - * by Unseen-Sequence profile entry. - */ + ** Check if message is in any sequence given + ** by Unseen-Sequence profile entry. + */ unseen = 0; for (i = 0; i < num_unseen_seq; i++) { if (in_sequence(mp, seqnum[i], msgnum)) { @@ -298,13 +300,16 @@ main (int argc, char **argv) break; default: - adios (NULL, "scan() botch (%d)", state); + adios (NULL, "scan() botch (%d)", + state); case SCNEOF: #if 0 - printf ("%*d empty\n", DMAXFOLDER, msgnum); + printf ("%*d empty\n", DMAXFOLDER, + msgnum); #else - advise (NULL, "message %d: empty", msgnum); + advise (NULL, "message %d: empty", + msgnum); #endif break; } diff --git a/uip/scansbr.c b/uip/scansbr.c index 7c0d198..67fc5eb 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -1,10 +1,10 @@ /* - * scansbr.c -- routines to help scan along... - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** scansbr.c -- routines to help scan along... +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -28,12 +28,12 @@ #define MAXSCANL 256 /* longest possible scan line */ /* - * Buffer size for content part of header fields. We want this - * to be large enough so that we don't do a lot of extra FLDPLUS - * calls on m_getfld but small enough so that we don't snarf - * the entire message body when we're only going to display 30 - * characters of it. - */ +** Buffer size for content part of header fields. We want this +** to be large enough so that we don't do a lot of extra FLDPLUS +** calls on m_getfld but small enough so that we don't snarf +** the entire message body when we're only going to display 30 +** characters of it. +*/ #define SBUFSIZ 512 static struct format *fmt; @@ -59,8 +59,8 @@ char *scanl = 0; /* text of most recent scanline */ } /* - * prototypes - */ +** prototypes +*/ int sc_width (void); /* from termsbr.c */ static int mh_fputs(char *, FILE *); @@ -99,7 +99,8 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, width = MAXSCANL; } dat[3] = slwidth = width; - scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH * (slwidth + 2) ); + scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH * + (slwidth + 2) ); if (outnum) umask(~m_gmprot()); @@ -116,7 +117,8 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, cptr->c_text = folder; FINDCOMP(cptr, "encrypted"); if (!cptr) - if ((cptr = (struct comp *) calloc (1, sizeof(*cptr)))) { + if ((cptr = (struct comp *) calloc (1, + sizeof(*cptr)))) { cptr->c_name = "encrypted"; cptr->c_next = wantcomp[i = CHASH (cptr->c_name)]; wantcomp[i] = cptr; @@ -125,7 +127,8 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, FINDCOMP (cptr, "dtimenow"); if (cptr) cptr->c_text = getcpy(dtimenow (0)); - nxtbuf = compbuffers = (char **) calloc((size_t) ncomps, sizeof(char *)); + nxtbuf = compbuffers = (char **) calloc((size_t) ncomps, + sizeof(char *)); if (nxtbuf == NULL) adios (NULL, "unable to allocate component buffers"); used_buf = (struct comp **) calloc((size_t) (ncomps+1), @@ -139,8 +142,8 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, } /* - * each-message initialization - */ + ** each-message initialization + */ nxtbuf = compbuffers; savecomp = used_buf; tmpbuf = *nxtbuf++; @@ -149,9 +152,9 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, dat[4] = unseen; /* - * Get the first field. If the message is non-empty - * and we're doing an "inc", open the output file. - */ + ** Get the first field. If the message is non-empty + ** and we're doing an "inc", open the output file. + */ if ((state = m_getfld (FLD, name, tmpbuf, rlwidth, inb)) == FILEEOF) { if (ferror(inb)) { advise("read", "unable to"); /* "read error" */ @@ -173,9 +176,9 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, adios (scnmsg, "unable to write"); #ifdef RPATHS /* - * Add the Return-Path and Delivery-Date - * header fields to message. - */ + ** Add the Return-Path and Delivery-Date + ** header fields to message. + */ if (get_returnpath (returnpath, sizeof(returnpath), deliverydate, sizeof(deliverydate))) { FPUTS ("Return-Path: "); @@ -187,22 +190,26 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, } /* scan - main loop */ - for (compnum = 1; ; state = m_getfld (state, name, tmpbuf, rlwidth, inb)) { + for (compnum = 1; ; + state = m_getfld (state, name, tmpbuf, rlwidth, inb)) { switch (state) { case FLD: case FLDPLUS: compnum++; if (outnum) { FPUTS (name); - if ( putc (':', scnout) == EOF) DIEWRERR(); + if ( putc (':', scnout) == EOF) + DIEWRERR(); FPUTS (tmpbuf); } /* - * if we're interested in this component, save a pointer - * to the component text, then start using our next free - * buffer as the component temp buffer (buffer switching - * saves an extra copy of the component text). - */ + ** if we're interested in this component, + ** save a pointer to the component text, + ** then start using our next free buffer + ** as the component temp buffer (buffer + ** switching saves an extra copy of the + ** component text). + */ if ((cptr = wantcomp[CHASH(name)])) { do { if (!mh_strcasecmp(name, cptr->c_name)) { @@ -238,16 +245,18 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, if (putc ('\n', scnout) == EOF) DIEWRERR(); FPUTS (tmpbuf); /* - * performance hack: some people like to run "inc" on - * things like net.sources or large digests. We do a - * copy directly into the output buffer rather than - * going through an intermediate buffer. - * - * We need the amount of data m_getfld found & don't - * want to do a strlen on the long buffer so there's - * a hack in m_getfld to save the amount of data it - * returned in the global "msg_count". - */ + ** performance hack: some people like to + ** run "inc" on things like net.sources or + ** large digests. We do a copy directly + ** into the output buffer rather than + ** going through an intermediate buffer. + ** + ** We need the amount of data m_getfld + ** found & don't want to do a strlen on + ** the long buffer so there's a hack in + ** m_getfld to save the amount of data it + ** returned in the global "msg_count". + */ body:; while (state == BODY) { #ifdef LINUX_STDIO @@ -278,10 +287,7 @@ body:; case LENERR: case FMTERR: - fprintf (stderr, - innum ? "??Format error (message %d) in " - : "??Format error in ", - outnum ? outnum : innum); + fprintf (stderr, innum ? "??Format error (message %d) in " : "??Format error in ", outnum ? outnum : innum); fprintf (stderr, "component %d\n", compnum); if (outnum) { @@ -302,8 +308,8 @@ body:; } /* - * format and output the scan line. - */ + ** format and output the scan line. + */ finished: if (ferror(inb)) { advise("read", "unable to"); /* "read error" */ @@ -318,8 +324,7 @@ finished: if (size) dat[2] = size; - else if (outnum > 0) - { + else if (outnum > 0) { dat[2] = ftell(scnout); if (dat[2] == EOF) DIEWRERR(); } @@ -385,4 +390,3 @@ mh_fputs(char *s, FILE *stream) return(EOF); return (0); } - diff --git a/uip/send.c b/uip/send.c index 45b5e26..043e05e 100644 --- a/uip/send.c +++ b/uip/send.c @@ -1,10 +1,10 @@ /* - * send.c -- send a composed message - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** send.c -- send a composed message +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -139,7 +139,9 @@ main (int argc, char **argv) adios (NULL, "-%s unknown\n", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [file] [switches]", invo_name); + snprintf (buf, sizeof(buf), + "%s [file] [switches]", + invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -242,12 +244,13 @@ main (int argc, char **argv) } /* - * check for "Aliasfile:" profile entry - */ + ** check for "Aliasfile:" profile entry + */ if ((cp = context_find ("Aliasfile"))) { char *dp = NULL; - for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++) { + for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; + ap++) { vec[vecp++] = "-alias"; vec[vecp++] = *ap; } @@ -293,8 +296,8 @@ main (int argc, char **argv) #ifdef UCI else { snprintf (buf, sizeof(buf), "%s/.signature", mypath); - if ((fp = fopen (buf, "r")) != NULL - && fgets (buf, sizeof buf, fp) != NULL) { + if ((fp = fopen (buf, "r")) != NULL && + fgets(buf, sizeof buf, fp) != NULL) { fclose (fp); if (cp = strchr (buf, '\n')) *cp = 0; @@ -326,9 +329,11 @@ main (int argc, char **argv) && errno != EISREMOTE #endif /* EISREMOTE */ ) - adios (distfile, "unable to link %s to", altmsg); + adios (distfile, "unable to link %s to", + altmsg); free (distfile); - distfile = getcpy (m_mktemp2(NULL, invo_name, NULL, NULL)); + distfile = getcpy (m_mktemp2(NULL, invo_name, + NULL, NULL)); { int in, out; struct stat st; @@ -336,7 +341,9 @@ main (int argc, char **argv) if ((in = open (altmsg, O_RDONLY)) == NOTOK) adios (altmsg, "unable to open"); fstat(in, &st); - if ((out = creat (distfile, (int) st.st_mode & 0777)) == NOTOK) + if ((out = creat (distfile, + (int) st.st_mode & 0777)) + == NOTOK) adios (distfile, "unable to write"); cpydata (in, out, altmsg, distfile); close (in); @@ -361,7 +368,7 @@ main (int argc, char **argv) for (msgnum = 0; msgnum < msgp; msgnum++) { switch (sendsbr (vec, vecp, msgs[msgnum], &st, 1, attach, - attachformat)) { + attachformat)) { case DONE: done (++status); case NOTOK: diff --git a/uip/sendsbr.c b/uip/sendsbr.c index f7c2a08..0cae878 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -1,10 +1,10 @@ /* - * sendsbr.c -- routines to help WhatNow/Send along - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** sendsbr.c -- routines to help WhatNow/Send along +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -39,8 +39,10 @@ char *distfile = NULL; static jmp_buf env; -static char body_file_name[MAXPATHLEN + 1]; /* name of temporary file for body content */ -static char composition_file_name[MAXPATHLEN + 1]; /* name of mhbuild composition temporary file */ +/* name of temp file for body content */ +static char body_file_name[MAXPATHLEN + 1]; +/* name of mhbuild composition temporary file */ +static char composition_file_name[MAXPATHLEN + 1]; static int field_size; /* size of header field buffer */ static char *field; /* header field buffer */ static FILE *draft_file; /* draft file pointer */ @@ -48,14 +50,14 @@ static FILE *body_file; /* body file pointer */ static FILE *composition_file; /* composition file pointer */ /* - * external prototypes - */ +** external prototypes +*/ int sendsbr (char **, int, char *, struct stat *, int, char *, int); char *getusername (void); /* - * static prototypes - */ +** static prototypes +*/ static void armed_done (int) NORETURN; static void alert (char *, int); static int tmp_fd (void); @@ -70,8 +72,8 @@ static void make_mime_composition_file_entry(char *, int); /* - * Entry point into (back-end) routines to send message. - */ +** Entry point into (back-end) routines to send message. +*/ int sendsbr (char **vec, int vecp, char *drft, struct stat *st, @@ -83,26 +85,27 @@ sendsbr (char **vec, int vecp, char *drft, struct stat *st, char *p; /* string pointer for building file name */ /* - * Save the original name of the draft file. The name of the - * draft file is changed to a temporary file containing the built - * MIME message if there are attachments. We need the original - * name so that it can be renamed after the message is sent. - */ + ** Save the original name of the draft file. The name of the + ** draft file is changed to a temporary file containing the built + ** MIME message if there are attachments. We need the original + ** name so that it can be renamed after the message is sent. + */ original_draft = drft; /* - * There might be attachments if a header field name for - * attachments is supplied. Convert the draft to a MIME message. - * Use the mhbuild composition file for the draft if there was - * a successful conversion because that now contains the MIME - * message. A nice side effect of this is that it leaves the - * original draft file untouched so that it can be retrieved - * and modified if desired. - */ + ** There might be attachments if a header field name for + ** attachments is supplied. Convert the draft to a MIME message. + ** Use the mhbuild composition file for the draft if there was + ** a successful conversion because that now contains the MIME + ** message. A nice side effect of this is that it leaves the + ** original draft file untouched so that it can be retrieved + ** and modified if desired. + */ if (attachment_header_field_name != (char *)0) { - switch (attach(attachment_header_field_name, drft, attachformat)) { + switch (attach(attachment_header_field_name, drft, + attachformat)) { case OK: drft = composition_file_name; break; @@ -119,15 +122,16 @@ sendsbr (char **vec, int vecp, char *drft, struct stat *st, switch (setjmp (env)) { case OK: /* - * If given -push and -unique (which is undocumented), then - * rename the draft file. I'm not quite sure why. - */ + ** If given -push and -unique (which is undocumented), then + ** rename the draft file. I'm not quite sure why. + */ if (pushsw && unique) { char *cp = m_mktemp2(drft, invo_name, NULL, NULL); if (cp == NULL) { adios ("sendsbr", "unable to create temporary file"); } - if (rename (drft, strncpy(file, cp, sizeof(file))) == NOTOK) + if (rename (drft, strncpy(file, cp, sizeof(file))) + == NOTOK) adios (file, "unable to rename %s to", drft); drft = file; } @@ -150,20 +154,21 @@ sendsbr (char **vec, int vecp, char *drft, struct stat *st, unlink (distfile); /* - * Get rid of any temporary files that we created for attachments. - * Also get rid of the renamed composition file that mhbuild - * leaves as a turd. It looks confusing, but we use the body - * file name to help build the renamed composition file name. - */ + ** Get rid of any temporary files that we created for attachments. + ** Also get rid of the renamed composition file that mhbuild + ** leaves as a turd. It looks confusing, but we use the body + ** file name to help build the renamed composition file name. + */ if (drft == composition_file_name) { clean_up_temporary_files(); - if (strlen(composition_file_name) >= sizeof (composition_file_name) - 6) + if (strlen(composition_file_name) >= + sizeof (composition_file_name) - 6) advise((char *)0, "unable to remove original composition file."); else { - if ((p = strrchr(composition_file_name, '/')) == (char *)0) + if ((p = strrchr(composition_file_name, '/')) == NULL) p = composition_file_name; else p++; @@ -192,43 +197,45 @@ attach(char *attachment_header_field_name, char *draft_file_name, char *p; /* miscellaneous string pointer */ /* - * Open up the draft file. - */ + ** Open up the draft file. + */ if ((draft_file = fopen(draft_file_name, "r")) == (FILE *)0) - adios((char *)0, "can't open draft file `%s'.", draft_file_name); + adios((char *)0, "can't open draft file `%s'.", + draft_file_name); /* - * Allocate a buffer to hold the header components as they're read in. - * This buffer might need to be quite large, so we grow it as needed. - */ + ** Allocate a buffer to hold the header components as they're read in. + ** This buffer might need to be quite large, so we grow it as needed. + */ field = (char *)mh_xmalloc(field_size = 256); /* - * Scan the draft file for a header field name that matches the - * -attach argument. The existence of one indicates that the - * draft has attachments. Bail out if there are no attachments - * because we're done. Read to the end of the headers even if - * we have no attachments. - */ + ** Scan the draft file for a header field name that matches the + ** -attach argument. The existence of one indicates that the + ** draft has attachments. Bail out if there are no attachments + ** because we're done. Read to the end of the headers even if + ** we have no attachments. + */ length = strlen(attachment_header_field_name); has_attachment = 0; while (get_line() != EOF && *field != '\0' && *field != '-') - if (strncasecmp(field, attachment_header_field_name, length) == 0 && field[length] == ':') + if (strncasecmp(field, attachment_header_field_name, length) + == 0 && field[length] == ':') has_attachment = 1; if (has_attachment == 0) return (DONE); /* - * We have at least one attachment. Look for at least one - * non-blank line in the body of the message which indicates - * content in the body. - */ + ** We have at least one attachment. Look for at least one + ** non-blank line in the body of the message which indicates + ** content in the body. + */ has_body = 0; @@ -245,43 +252,45 @@ attach(char *attachment_header_field_name, char *draft_file_name, } /* - * Make names for the temporary files. - */ + ** Make names for the temporary files. + */ (void)strncpy(body_file_name, - m_mktemp(m_maildir(invo_name), NULL, NULL), - sizeof (body_file_name)); + m_mktemp(m_maildir(invo_name), NULL, NULL), + sizeof (body_file_name)); (void)strncpy(composition_file_name, - m_mktemp(m_maildir(invo_name), NULL, NULL), - sizeof (composition_file_name)); + m_mktemp(m_maildir(invo_name), NULL, NULL), + sizeof (composition_file_name)); if (has_body) body_file = fopen(body_file_name, "w"); composition_file = fopen(composition_file_name, "w"); - if ((has_body && body_file == (FILE *)0) || composition_file == (FILE *)0) { + if ((has_body && body_file == (FILE *)0) || + composition_file == (FILE *)0) { clean_up_temporary_files(); adios((char *)0, "unable to open all of the temporary files."); } /* - * Start at the beginning of the draft file. Copy all - * non-attachment header fields to the temporary composition file. - * Then add the dashed line separator. - */ + ** Start at the beginning of the draft file. Copy all + ** non-attachment header fields to the temporary composition file. + ** Then add the dashed line separator. + */ rewind(draft_file); while (get_line() != EOF && *field != '\0' && *field != '-') - if (strncasecmp(field, attachment_header_field_name, length) != 0 || field[length] != ':') + if (strncasecmp(field, attachment_header_field_name, length) + != 0 || field[length] != ':') (void)fprintf(composition_file, "%s\n", field); (void)fputs("--------\n", composition_file); /* - * Copy the message body to a temporary file. - */ + ** Copy the message body to a temporary file. + */ if (has_body) { while ((c = getc(draft_file)) != EOF) @@ -291,24 +300,26 @@ attach(char *attachment_header_field_name, char *draft_file_name, } /* - * Add a mhbuild MIME composition file line for the body if - * there was one. - */ + ** Add a mhbuild MIME composition file line for the body if + ** there was one. + */ if (has_body) make_mime_composition_file_entry(body_file_name, attachformat); /* - * Now, go back to the beginning of the draft file and look for - * header fields that specify attachments. Add a mhbuild MIME - * composition file for each. - */ + ** Now, go back to the beginning of the draft file and look for + ** header fields that specify attachments. Add a mhbuild MIME + ** composition file for each. + */ rewind(draft_file); while (get_line() != EOF && *field != '\0' && *field != '-') { - if (strncasecmp(field, attachment_header_field_name, length) == 0 && field[length] == ':') { - for (p = field + length + 1; *p == ' ' || *p == '\t'; p++) + if (strncasecmp(field, attachment_header_field_name, length) + == 0 && field[length] == ':') { + for (p = field + length + 1; *p == ' ' || *p == '\t'; + p++) ; make_mime_composition_file_entry(p, attachformat); @@ -318,9 +329,9 @@ attach(char *attachment_header_field_name, char *draft_file_name, (void)fclose(composition_file); /* - * We're ready to roll! Run mhbuild on the composition file. - * Note that mhbuild is in the context as buildmimeproc. - */ + ** We're ready to roll! Run mhbuild on the composition file. + ** Note that mhbuild is in the context as buildmimeproc. + */ (void)sprintf(buf, "%s %s", buildmimeproc, composition_file_name); @@ -349,11 +360,11 @@ get_line(void) char *p; /* buffer pointer */ /* - * Get a line from the input file, growing the field buffer as - * needed. We do this so that we can fit an entire line in the - * buffer making it easy to do a string comparison on both the - * field name and the field body which might be a long path name. - */ + ** Get a line from the input file, growing the field buffer as + ** needed. We do this so that we can fit an entire line in the + ** buffer making it easy to do a string comparison on both the + ** field name and the field body which might be a long path name. + */ for (n = 0, p = field; (c = getc(draft_file)) != EOF; *p++ = c) { if (c == '\n' && (c = getc(draft_file)) != ' ' && c != '\t') { @@ -369,10 +380,7 @@ get_line(void) } } - /* - * NUL-terminate the field.. - */ - + /* NUL-terminate the field. */ *p = '\0'; return (c); @@ -393,17 +401,19 @@ make_mime_composition_file_entry(char *file_name, int attachformat) content_type = (char *)0; /* - * Check the file name for a suffix. Scan the context for that - * suffix on a mhshow-suffix- entry. We use these entries to - * be compatible with mhshow, and there's no reason to make the - * user specify each suffix twice. Context entries of the form - * "mhshow-suffix-contenttype" in the name have the suffix in - * the field, including the dot. - */ + ** Check the file name for a suffix. Scan the context for that + ** suffix on a mhshow-suffix- entry. We use these entries to + ** be compatible with mhshow, and there's no reason to make the + ** user specify each suffix twice. Context entries of the form + ** "mhshow-suffix-contenttype" in the name have the suffix in + ** the field, including the dot. + */ if ((p = strrchr(file_name, '.')) != (char *)0) { for (np = m_defs; np; np = np->n_next) { - if (strncasecmp(np->n_name, "mhshow-suffix-", 14) == 0 && mh_strcasecmp(p, np->n_field) == 0) { + if (strncasecmp(np->n_name, "mhshow-suffix-", 14) == 0 + && mh_strcasecmp(p, np->n_field) == 0) + { content_type = np->n_name + 14; break; } @@ -411,16 +421,17 @@ make_mime_composition_file_entry(char *file_name, int attachformat) } /* - * No content type was found, either because there was no matching - * entry in the context or because the file name has no suffix. - * Open the file and check for non-ASCII characters. Choose the - * content type based on this check. - */ + ** No content type was found, either because there was no matching + ** entry in the context or because the file name has no suffix. + ** Open the file and check for non-ASCII characters. Choose the + ** content type based on this check. + */ if (content_type == (char *)0) { if ((fp = fopen(file_name, "r")) == (FILE *)0) { clean_up_temporary_files(); - adios((char *)0, "unable to access file \"%s\"", file_name); + adios((char *)0, "unable to access file \"%s\"", + file_name); } binary = 0; @@ -434,16 +445,17 @@ make_mime_composition_file_entry(char *file_name, int attachformat) (void)fclose(fp); - content_type = binary ? "application/octet-stream" : "text/plain"; + content_type = binary ? + "application/octet-stream" : "text/plain"; } /* - * Make sure that the attachment file exists and is readable. - * Append a mhbuild directive to the draft file. This starts with - * the content type. Append a file name attribute and a private - * x-unix-mode attribute. Also append a description obtained - * (if possible) by running the "file" command on the file. - */ + ** Make sure that the attachment file exists and is readable. + ** Append a mhbuild directive to the draft file. This starts with + ** the content type. Append a file name attribute and a private + ** x-unix-mode attribute. Also append a description obtained + ** (if possible) by running the "file" command on the file. + */ if (stat(file_name, &st) == -1 || access(file_name, R_OK) != 0) { clean_up_temporary_files(); @@ -453,26 +465,31 @@ make_mime_composition_file_entry(char *file_name, int attachformat) switch (attachformat) { case 0: /* Insert name, file mode, and Content-Id. */ - (void)fprintf(composition_file, "#%s; name=\"%s\"; x-unix-mode=0%.3ho", - content_type, ((p = strrchr(file_name, '/')) == (char *)0) ? file_name : p + 1, (unsigned short)(st.st_mode & 0777)); + (void)fprintf(composition_file, + "#%s; name=\"%s\"; x-unix-mode=0%.3ho", + content_type, ((p = strrchr(file_name, '/')) + == (char *)0) ? file_name : p + 1, + (unsigned short)(st.st_mode & 0777)); if (strlen(file_name) > MAXPATHLEN) { clean_up_temporary_files(); - adios((char *)0, "attachment file name `%s' too long.", file_name); + adios((char *)0, "attachment file name `%s' too long.", + file_name); } (void)sprintf(cmd, "file '%s'", file_name); - if ((fp = popen(cmd, "r")) != (FILE *)0 && fgets(cmd, sizeof (cmd), fp) != (char *)0) { + if ((fp = popen(cmd, "r")) != (FILE *)0 && + fgets(cmd, sizeof (cmd), fp) != (char *)0) { *strchr(cmd, '\n') = '\0'; /* - * The output of the "file" command is of the form - * - * file: description - * - * Strip off the "file:" and subsequent white space. - */ + ** The output of the "file" command is of the form + ** + ** file: description + ** + ** Strip off the "file:" and subsequent white space. + */ for (p = cmd; *p != '\0'; p++) { if (*p == ':') { @@ -495,14 +512,17 @@ make_mime_composition_file_entry(char *file_name, int attachformat) case 1: if (stringdex (m_maildir(invo_name), file_name) == 0) { /* - * Content had been placed by send into a temp file. - * Don't generate Content-Disposition header, because - * it confuses Microsoft Outlook, Build 10.0.6626, at - * least. - */ + ** Content had been placed by send into a temp file. + ** Don't generate Content-Disposition header, because + ** it confuses Microsoft Outlook, Build 10.0.6626, at + ** least. + */ (void) fprintf (composition_file, "#%s <>", content_type); } else { - /* Suppress Content-Id, insert simple Content-Disposition. */ + /* + ** Suppress Content-Id, insert simple + ** Content-Disposition. + */ (void) fprintf (composition_file, "#%s; name=\"%s\" <>{attachment}", content_type, @@ -514,17 +534,18 @@ make_mime_composition_file_entry(char *file_name, int attachformat) case 2: if (stringdex (m_maildir(invo_name), file_name) == 0) { /* - * Content had been placed by send into a temp file. - * Don't generate Content-Disposition header, because - * it confuses Microsoft Outlook, Build 10.0.6626, at - * least. - */ - (void) fprintf (composition_file, "#%s <>", content_type); + ** Content had been placed by send into a temp file. + ** Don't generate Content-Disposition header, because + ** it confuses Microsoft Outlook, Build 10.0.6626, at + ** least. + */ + (void) fprintf (composition_file, "#%s <>", + content_type); } else { /* - * Suppress Content-Id, insert Content-Disposition - * with modification date. - */ + ** Suppress Content-Id, insert Content-Disposition + ** with modification date. + */ (void) fprintf (composition_file, "#%s; name=\"%s\" <>{attachment; modification-date=\"%s\"}", content_type, @@ -538,8 +559,8 @@ make_mime_composition_file_entry(char *file_name, int attachformat) } /* - * Finish up with the file name. - */ + ** Finish up with the file name. + */ (void)fprintf(composition_file, " %s\n", file_name); @@ -547,9 +568,9 @@ make_mime_composition_file_entry(char *file_name, int attachformat) } /* - * Annotate original message, and - * call `postproc' to send message. - */ +** Annotate original message, and +** call `postproc' to send message. +*/ static int sendaux (char **vec, int vecp, char *drft, struct stat *st) @@ -586,11 +607,11 @@ sendaux (char **vec, int vecp, char *drft, struct stat *st) case 0: /* - * child process -- send it - * - * If fd is ok, then we are pushing and fd points to temp - * file, so capture anything on stdout and stderr there. - */ + ** child process -- send it + ** + ** If fd is ok, then we are pushing and fd points to temp + ** file, so capture anything on stdout and stderr there. + */ if (fd != NOTOK) { dup2 (fd, fileno (stdout)); dup2 (fd, fileno (stderr)); @@ -604,17 +625,17 @@ sendaux (char **vec, int vecp, char *drft, struct stat *st) default: /* - * parent process -- wait for it - */ + ** parent process -- wait for it + */ if ((status = pidwait(child_id, NOTOK)) == OK) { if (annotext && fd2 != NOTOK) anno (fd2, st); } else { /* - * If postproc failed, and we have good fd (which means - * we pushed), then mail error message (and possibly the - * draft) back to the user. - */ + ** If postproc failed, and we have good fd (which + ** means we pushed), then mail error message + ** (and possibly the draft) back to the user. + */ if (fd != NOTOK) { alert (drft, fd); close (fd); @@ -626,7 +647,8 @@ sendaux (char **vec, int vecp, char *drft, struct stat *st) if (distfile) { unlink (drft); if (rename (backup, drft) == NOTOK) - advise (drft, "unable to rename %s to", backup); + advise (drft, "unable to rename %s to", + backup); } } break; @@ -637,9 +659,9 @@ sendaux (char **vec, int vecp, char *drft, struct stat *st) /* - * Mail error notification (and possibly a copy of the - * message) back to the user, using the mailproc - */ +** Mail error notification (and possibly a copy of the +** message) back to the user, using the mailproc +*/ static void alert (char *file, int out) @@ -684,9 +706,11 @@ alert (char *file, int out) close (out); /* create subject for error notification */ snprintf (buf, sizeof(buf), "send failed on %s", - forwsw ? "enclosed draft" : file); + forwsw ? + "enclosed draft" : file); - execlp (mailproc, r1bindex (mailproc, '/'), getusername (), + execlp (mailproc, r1bindex (mailproc, '/'), + getusername (), "-subject", buf, NULL); fprintf (stderr, "unable to exec "); perror (mailproc); @@ -740,8 +764,7 @@ anno (int fd, struct stat *st) switch (child_id) { case NOTOK: /* oops */ if (!debugsw) - advise (NULL, - "unable to fork, so doing annotations by hand..."); + advise (NULL, "unable to fork, so doing annotations by hand..."); if (cwd == NULL) cwd = getcpy (pwd ()); diff --git a/uip/show.c b/uip/show.c index 413daeb..6c795ca 100644 --- a/uip/show.c +++ b/uip/show.c @@ -1,10 +1,10 @@ /* - * show.c -- show/list messages - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** show.c -- show/list messages +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -45,8 +45,8 @@ static struct swit switches[] = { }; /* - * static prototypes - */ +** static prototypes +*/ static int is_nontext(char *); /* prototype from mhlsbr.c */ @@ -96,9 +96,7 @@ main (int argc, char **argv) continue; case HELPSW: - snprintf (buf, sizeof(buf), - "%s [+folder] %s[switches] [switches for showproc]", - invo_name, mode == SHOW ? "[msgs] ": ""); + snprintf (buf, sizeof(buf), "%s [+folder] %s[switches] [switches for showproc]", invo_name, mode == SHOW ? "[msgs] ": ""); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -167,11 +165,10 @@ usage: adios (NULL, "only one folder at a time!"); else folder = pluspath (cp); + } else if (mode != SHOW) { + goto usage; } else { - if (mode != SHOW) - goto usage; - else - msgs[msgp++] = cp; + msgs[msgp++] = cp; } } procp = vecp; @@ -187,7 +184,8 @@ usage: } #ifdef WHATNOW - if (!msgp && !folder && mode == SHOW && (cp = getenv ("mhdraft")) && *cp) { + if (!msgp && !folder && mode == SHOW && + (cp = getenv ("mhdraft")) && *cp) { vec[vecp++] = cp; goto go_to_it; } @@ -228,10 +226,10 @@ usage: done (1); /* - * Set the SELECT_UNSEEN bit for all the SELECTED messages, - * since we will use that as a tag to know which messages - * to remove from the "unseen" sequence. - */ + ** Set the SELECT_UNSEEN bit for all the SELECTED messages, + ** since we will use that as a tag to know which messages + ** to remove from the "unseen" sequence. + */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) if (is_selected(mp, msgnum)) set_unseen (mp, msgnum); @@ -240,7 +238,8 @@ usage: seq_setunseen (mp, 1); /* unset the Unseen-Sequence */ if (mp->numsel > MAXARGS - 2) - adios (NULL, "more than %d messages for show exec", MAXARGS - 2); + adios (NULL, "more than %d messages for show exec", + MAXARGS - 2); for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) if (is_selected(mp, msgnum)) @@ -260,8 +259,8 @@ go_to_it: ; vec[vecp] = NULL; /* - * Decide which "proc" to use - */ + ** Decide which "proc" to use + */ mime = 0; if (nshow) { proc = catproc; @@ -269,8 +268,13 @@ go_to_it: ; /* check if any messages are non-text MIME messages */ if (checkmime && !getenv ("NOMHNPROC")) { if (!file) { - /* loop through selected messages and check for MIME */ - for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) + /* + ** loop through selected messages + ** and check for MIME + */ + for (msgnum = mp->lowsel; + msgnum <= mp->hghsel; + msgnum++) if (is_selected (mp, msgnum) && is_nontext (m_name (msgnum))) { mime = 1; break; @@ -293,10 +297,10 @@ go_to_it: ; m_putenv ("mhfolder", folder); /* - * For backward compatibility, if the "proc" is mhn, - * then add "-show" option. Add "-file" if showing - * file. - */ + ** For backward compatibility, if the "proc" is mhn, + ** then add "-show" option. Add "-file" if showing + ** file. + */ if (strcmp (r1bindex (proc, '/'), "mhn") == 0) { if (file) { vec[vecp] = vec[vecp - 1]; @@ -307,8 +311,7 @@ go_to_it: ; vec[vecp] = NULL; } - /* If the "proc" is "mhshow", add "-file" if showing file. - */ + /* If the "proc" is "mhshow", add "-file" if showing file. */ if (strcmp (r1bindex (proc, '/'), "mhshow") == 0 && file ) { vec[vecp] = vec[vecp - 1]; vec[vecp - 1] = "-file"; @@ -316,9 +319,9 @@ go_to_it: ; } /* - * If "proc" is mhl, then run it internally - * rather than exec'ing it. - */ + ** If "proc" is mhl, then run it internally + ** rather than exec'ing it. + */ if (strcmp (r1bindex (proc, '/'), "mhl") == 0) { vec[0] = "mhl"; mhl (vecp, vec); @@ -326,13 +329,14 @@ go_to_it: ; } /* - * If you are not using a nmh command as your "proc", then - * add the path to the message names. Currently, we are just - * checking for mhn here, since we've already taken care of mhl. - */ + ** If you are not using a nmh command as your "proc", then + ** add the path to the message names. Currently, we are just + ** checking for mhn here, since we've already taken care of mhl. + */ if (!strcmp (r1bindex (proc, '/'), "mhl") && !file - && chdir (maildir = concat (m_maildir (""), "/", NULL)) != NOTOK) { + && chdir (maildir = + concat (m_maildir (""), "/", NULL)) != NOTOK) { mp->foldpath = concat (mp->foldpath, "/", NULL); cp = ssequal (maildir, mp->foldpath) ? mp->foldpath + strlen (maildir) @@ -348,8 +352,8 @@ go_to_it: ; } /* - * Check if a message or file contains any non-text parts - */ +** Check if a message or file contains any non-text parts +*/ static int is_nontext (char *msgnam) { @@ -368,15 +372,16 @@ is_nontext (char *msgnam) case FLDPLUS: case FLDEOF: /* - * Check Content-Type field - */ + ** Check Content-Type field + */ if (!mh_strcasecmp (name, TYPE_FIELD)) { int passno; char c; cp = add (buf, NULL); while (state == FLDPLUS) { - state = m_getfld (state, name, buf, sizeof(buf), fp); + state = m_getfld (state, name, buf, + sizeof(buf), fp); cp = add (buf, cp); } bp = cp; @@ -425,13 +430,15 @@ invalid: if (!*bp) goto invalid; if (passno > 1) { - if ((result = (mh_strcasecmp (bp, "plain") != 0))) + if ((result = (mh_strcasecmp (bp, + "plain") != 0))) goto out; *dp = c; for (dp++; isspace (*dp); dp++) continue; if (*dp) { - if ((result = !uprf (dp, "charset"))) + if ((result = !uprf (dp, + "charset"))) goto out; dp += sizeof("charset") - 1; while (isspace (*dp)) @@ -474,8 +481,8 @@ out: } /* - * Check Content-Transfer-Encoding field - */ + ** Check Content-Transfer-Encoding field + */ if (!mh_strcasecmp (name, ENCODING_FIELD)) { cp = add (buf, NULL); while (state == FLDPLUS) { @@ -500,17 +507,18 @@ out: } /* - * Just skip the rest of this header - * field and go to next one. - */ + ** Just skip the rest of this header + ** field and go to next one. + */ while (state == FLDPLUS) - state = m_getfld (state, name, buf, sizeof(buf), fp); + state = m_getfld(state, name, buf, sizeof(buf), + fp); break; /* - * We've passed the message header, - * so message is just text. - */ + ** We've passed the message header, + ** so message is just text. + */ default: fclose (fp); return 0; diff --git a/uip/slocal.c b/uip/slocal.c index b82b5e2..52e323a 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -1,24 +1,24 @@ /* - * slocal.c -- asynchronously filter and deliver new mail - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** slocal.c -- asynchronously filter and deliver new mail +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ /* - * Under sendmail, users should add the line - * - * "| /usr/local/nmh/lib/slocal" - * - * to their $HOME/.forward file. - * - */ +** Under sendmail, users should add the line +** +** "| /usr/local/nmh/lib/slocal" +** +** to their $HOME/.forward file. +** +*/ /* Changed to use getutent() and friends. Assumes that when getutent() exists, - * a number of other things also exist. Please check. - * Ruud de Rooij Sun, 28 May 2000 17:28:55 +0200 - */ +** a number of other things also exist. Please check. +** Ruud de Rooij Sun, 28 May 2000 17:28:55 +0200 +*/ #include #include @@ -36,18 +36,21 @@ #ifdef INITGROUPS_HEADER #include INITGROUPS_HEADER #else -/* On AIX 4.1, initgroups() is defined and even documented (giving the parameter - types as char* and int), but doesn't have a prototype in any of the system - header files. AIX 4.3, SunOS 4.1.3, and ULTRIX 4.2A have the same - problem. */ +/* +** On AIX 4.1, initgroups() is defined and even documented (giving the +** parameter types as char* and int), but doesn't have a prototype in any +** of the system header files. AIX 4.3, SunOS 4.1.3, and ULTRIX 4.2A have +** the same problem. +*/ extern int initgroups(char*, int); #endif -/* This define is needed for Berkeley db v2 and above to - * make the header file expose the 'historical' ndbm APIs. - * We define it unconditionally because this is simple and - * harmless. - */ +/* +** This define is needed for Berkeley db v2 and above to +** make the header file expose the 'historical' ndbm APIs. +** We define it unconditionally because this is simple and +** harmless. +*/ #define DB_DBM_HSEARCH 1 #ifdef NDBM_HEADER #include NDBM_HEADER @@ -138,10 +141,10 @@ struct pair { #define NVEC 100 /* - * Lookup table for matching fields and patterns - * in messages. The rest of the table is added - * when the message is parsed. - */ +** Lookup table for matching fields and patterns +** in messages. The rest of the table is added +** when the message is parsed. +*/ static struct pair hdrs[NVEC + 1] = { { "source", NULL, P_HID }, { "addr", NULL, P_HID }, @@ -160,9 +163,9 @@ static struct pair hdrs[NVEC + 1] = { }; /* - * The list of builtin variables to expand in a string - * before it is executed by the "pipe" or "qpipe" action. - */ +** The list of builtin variables to expand in a string +** before it is executed by the "pipe" or "qpipe" action. +*/ static struct pair vars[] = { { "sender", NULL, P_NIL }, { "address", NULL, P_NIL }, @@ -175,8 +178,8 @@ static struct pair vars[] = { extern char **environ; /* - * static prototypes - */ +** static prototypes +*/ static int localmail (int, char *); static int usr_delivery (int, char *, int); static int split (char *, char **); @@ -241,15 +244,18 @@ main (int argc, char **argv) done (1); case ADDRSW: - if (!(addr = *argp++))/* allow -xyz arguments */ + if (!(addr = *argp++)) + /* allow -xyz arguments */ adios (NULL, "missing argument to %s", argp[-2]); continue; case INFOSW: - if (!(info = *argp++))/* allow -xyz arguments */ + if (!(info = *argp++)) + /* allow -xyz arguments */ adios (NULL, "missing argument to %s", argp[-2]); continue; case USERSW: - if (!(user = *argp++))/* allow -xyz arguments */ + if (!(user = *argp++)) + /* allow -xyz arguments */ adios (NULL, "missing argument to %s", argp[-2]); continue; case FILESW: @@ -257,7 +263,8 @@ main (int argc, char **argv) adios (NULL, "missing argument to %s", argp[-2]); continue; case SENDERSW: - if (!(sender = *argp++))/* allow -xyz arguments */ + if (!(sender = *argp++)) + /* allow -xyz arguments */ adios (NULL, "missing argument to %s", argp[-2]); continue; case MAILBOXSW: @@ -339,8 +346,8 @@ main (int argc, char **argv) snprintf (ddate, sizeof(ddate), "Delivery-Date: %s\n", dtimenow (0)); /* - * Copy the message to a temporary file - */ + ** Copy the message to a temporary file + */ if (file) { int tempfd; @@ -364,28 +371,29 @@ main (int argc, char **argv) debug_printf ("temporary file=\"%s\"\n", tmpfil); /* - * Delete the temp file now or a copy of every single message - * passed through slocal will be left in the /tmp directory until - * deleted manually! This unlink() used to be under an 'else' - * of the 'if (debug)' above, but since some people like to - * always run slocal with -debug and log the results, the /tmp - * directory would get choked over time. Of course, now that - * we always delete the temp file, the "temporary file=" message - * above is somewhat pointless -- someone watching debug output - * wouldn't have a chance to 'tail -f' or 'ln' the temp file - * before it's unlinked. The best thing would be to delay this - * unlink() until later if debug == 1, but I'll leave that for - * someone who cares about the temp-file-accessing functionality - * (they'll have to watch out for cases where we adios()). - */ + ** Delete the temp file now or a copy of every single message + ** passed through slocal will be left in the /tmp directory until + ** deleted manually! This unlink() used to be under an 'else' + ** of the 'if (debug)' above, but since some people like to + ** always run slocal with -debug and log the results, the /tmp + ** directory would get choked over time. Of course, now that + ** we always delete the temp file, the "temporary file=" message + ** above is somewhat pointless -- someone watching debug output + ** wouldn't have a chance to 'tail -f' or 'ln' the temp file + ** before it's unlinked. The best thing would be to delay this + ** unlink() until later if debug == 1, but I'll leave that for + ** someone who cares about the temp-file-accessing functionality + ** (they'll have to watch out for cases where we adios()). + */ unlink (tmpfil); if (!(fp = fdopen (fd, "r+"))) adios (NULL, "unable to access temporary file"); /* - * If no sender given, extract it - * from envelope information. */ + ** If no sender given, extract it + ** from envelope information. + */ if (sender == NULL) get_sender (envelope, &sender); @@ -403,7 +411,8 @@ main (int argc, char **argv) debug_printf ("user=\"%s\"\n", trim(user)); debug_printf ("info=\"%s\"\n", trim(info)); debug_printf ("sender=\"%s\"\n", trim(sender)); - debug_printf ("envelope=\"%s\"\n", envelope ? trim(envelope) : ""); + debug_printf ("envelope=\"%s\"\n", + envelope ? trim(envelope) : ""); debug_printf ("mbox=\"%s\"\n", trim(mbox)); debug_printf ("home=\"%s\"\n", trim(home)); debug_printf ("ddate=\"%s\"\n", trim(ddate)); @@ -419,15 +428,16 @@ main (int argc, char **argv) /* - * Main routine for delivering message. - */ +** Main routine for delivering message. +*/ static int localmail (int fd, char *mdlvr) { /* check if this message is a duplicate */ if (suppressdup && - suppress_duplicates(fd, mdlvr ? mdlvr : ".maildelivery") == DONE) + suppress_duplicates(fd, + mdlvr ? mdlvr : ".maildelivery") == DONE) return 0; /* delivery according to personal Maildelivery file */ @@ -453,8 +463,8 @@ localmail (int fd, char *mdlvr) #define matches(a,b) (stringdex (b, a) >= 0) /* - * Parse the delivery file, and process incoming message. - */ +** Parse the delivery file, and process incoming message. +*/ static int usr_delivery (int fd, char *delivery, int su) @@ -476,8 +486,7 @@ usr_delivery (int fd, char *delivery, int su) || (st.st_uid != 0 && (su || st.st_uid != pw->pw_uid)) || st.st_mode & (S_IWGRP|S_IWOTH)) { if (verbose) { - verbose_printf ("WARNING: %s has bad ownership/modes (su=%d,uid=%d,owner=%d,mode=0%o)\n", - delivery, su, (int) pw->pw_uid, (int) st.st_uid, (int) st.st_mode); + verbose_printf ("WARNING: %s has bad ownership/modes (su=%d,uid=%d,owner=%d,mode=0%o)\n", delivery, su, (int) pw->pw_uid, (int) st.st_uid, (int) st.st_mode); } return -1; } @@ -507,7 +516,8 @@ usr_delivery (int fd, char *delivery, int su) if (debug) { for (i = 0; vec[i]; i++) - debug_printf ("vec[%d]: \"%s\"\n", i, trim(vec[i])); + debug_printf ("vec[%d]: \"%s\"\n", + i, trim(vec[i])); } field = vec[0]; @@ -521,26 +531,27 @@ usr_delivery (int fd, char *delivery, int su) case 'N': case 'n': /* - * If previous condition failed, don't - * do this - else fall through - */ + ** If previous condition failed, don't + ** do this - else fall through + */ if (!next) continue; /* else fall */ case '?': /* - * If already delivered, skip this action. Else - * consider delivered if action is successful. - */ + ** If already delivered, skip this action. + ** Else consider delivered if action is + ** successful. + */ if (won) continue; /* else fall */ case 'A': case 'a': /* - * Take action, and consider delivered if - * action is successful. - */ + ** Take action, and consider delivered if + ** action is successful. + */ accept = 1; break; @@ -548,9 +559,9 @@ usr_delivery (int fd, char *delivery, int su) case 'r': default: /* - * Take action, but don't consider delivered, even - * if action is successful - */ + ** Take action, but don't consider delivered, + ** even if action is successful + */ accept = 0; break; } @@ -572,9 +583,9 @@ usr_delivery (int fd, char *delivery, int su) case 'd': /* - * "default" matches only if the message hasn't - * been delivered yet. - */ + ** "default" matches only if the message hasn't + ** been delivered yet. + */ if (!mh_strcasecmp (field, "default")) { if (won) continue; @@ -588,11 +599,13 @@ usr_delivery (int fd, char *delivery, int su) return -1; } /* - * find header field in lookup table, and - * see if the pattern matches. - */ - if ((p = lookup (hdrs, field)) && (p->p_value != NULL) - && matches (p->p_value, pattern)) { + ** find header field in lookup table, and + ** see if the pattern matches. + */ + if ((p = lookup (hdrs, field)) && + (p->p_value != NULL) && + matches (p->p_value, pattern) + ) { next = 1; } else { next = 0; @@ -624,13 +637,15 @@ usr_delivery (int fd, char *delivery, int su) expand (tmpbuf, string, fd); vec[4] = tmpbuf; vec[5] = NULL; - status = usr_pipe (fd, tmpbuf, "/bin/sh", vec + 2, 0); + status = usr_pipe (fd, tmpbuf, "/bin/sh", + vec + 2, 0); break; case 'f': /* mbox format */ if (!mh_strcasecmp (action, "file")) { - status = usr_file (fd, string, MBOX_FORMAT); + status = usr_file (fd, string, + MBOX_FORMAT); break; } /* deliver to nmh folder */ @@ -643,7 +658,8 @@ usr_delivery (int fd, char *delivery, int su) case 'm': /* mmdf format */ if (!mh_strcasecmp (action, "mmdf")) { - status = usr_file (fd, string, MMDF_FORMAT); + status = usr_file (fd, string, + MMDF_FORMAT); break; } /* mbox format */ @@ -677,9 +693,9 @@ usr_delivery (int fd, char *delivery, int su) #define QUOTE '\\' /* - * Split buffer into fields (delimited by whitespace or - * comma's). Return the number of fields found. - */ +** Split buffer into fields (delimited by whitespace or +** comma's). Return the number of fields found. +*/ static int split (char *cp, char **vec) @@ -705,9 +721,9 @@ split (char *cp, char **vec) if (*s == '"') { for (vec[i++] = ++s; *s && *s != '"'; s++) { /* - * Check for escaped double quote. We need - * to shift the string to remove slash. - */ + ** Check for escaped double quote. We need + ** to shift the string to remove slash. + */ if (*s == QUOTE) { if (*++s == '"') strcpy (s - 1, s); @@ -734,9 +750,9 @@ split (char *cp, char **vec) /* - * Parse the headers of a message, and build the - * lookup table for matching fields and patterns. - */ +** Parse the headers of a message, and build the +** lookup table for matching fields and patterns. +*/ static int parse (int fd) @@ -771,7 +787,8 @@ parse (int fd) * a lookup table. */ for (i = 0, state = FLD;;) { - switch (state = m_getfld (state, name, field, sizeof(field), in)) { + switch (state = m_getfld (state, name, field, sizeof(field), + in)) { case FLD: case FLDEOF: case FLDPLUS: @@ -852,9 +869,9 @@ parse (int fd) #define RPAREN ')' /* - * Expand any builtin variables such as $(sender), - * $(address), etc., in a string. - */ +** Expand any builtin variables such as $(sender), +** $(address), etc., in a string. +*/ static void expand (char *s1, char *s2, int fd) @@ -890,11 +907,11 @@ expand (char *s1, char *s2, int fd) /* - * Fill in the information missing from the "vars" - * table, which is necessary to expand any builtin - * variables in the string for a "pipe" or "qpipe" - * action. - */ +** Fill in the information missing from the "vars" +** table, which is necessary to expand any builtin +** variables in the string for a "pipe" or "qpipe" +** action. +*/ static void glob (int fd) @@ -927,9 +944,9 @@ glob (int fd) /* - * Find a matching name in a lookup table. If found, - * return the "pairs" entry, else return NULL. - */ +** Find a matching name in a lookup table. If found, +** return the "pairs" entry, else return NULL. +*/ static struct pair * lookup (struct pair *pairs, char *key) @@ -943,9 +960,9 @@ lookup (struct pair *pairs, char *key) /* - * Check utmp(x) file to see if user is currently - * logged in. - */ +** Check utmp(x) file to see if user is currently +** logged in. +*/ #ifdef HAVE_GETUTENT static int @@ -961,11 +978,11 @@ logged_in (void) while ((utp = getutent()) != NULL) { if ( #ifdef HAVE_STRUCT_UTMP_UT_TYPE - utp->ut_type == USER_PROCESS - && + utp->ut_type == USER_PROCESS && #endif - utp->ut_name[0] != 0 - && strncmp (user, utp->ut_name, sizeof(utp->ut_name)) == 0) { + utp->ut_name[0] != 0 && + strncmp (user, utp->ut_name, + sizeof(utp->ut_name)) == 0) { if (debug) continue; endutent(); @@ -990,8 +1007,9 @@ logged_in (void) return NOTOK; while (fread ((char *) &ut, sizeof(ut), 1, uf) == 1) { - if (ut.ut_name[0] != 0 - && strncmp (user, ut.ut_name, sizeof(ut.ut_name)) == 0) { + if (ut.ut_name[0] != 0 && + strncmp (user, ut.ut_name, sizeof(ut.ut_name)) + == 0) { if (debug) continue; fclose (uf); @@ -1030,8 +1048,8 @@ timely (char *t1, char *t2) /* - * Deliver message by appending to a file. - */ +** Deliver message by appending to a file. +*/ static int usr_file (int fd, char *mailbox, int mbx_style) @@ -1052,7 +1070,8 @@ usr_file (int fd, char *mailbox, int mbx_style) } /* open and lock the file */ - if ((md = mbx_open (mailbox, mbx_style, pw->pw_uid, pw->pw_gid, m_gmprot())) == -1) { + if ((md = mbx_open (mailbox, mbx_style, pw->pw_uid, pw->pw_gid, + m_gmprot())) == -1) { if (verbose) adorn ("", "unable to open:"); return -1; @@ -1061,7 +1080,8 @@ usr_file (int fd, char *mailbox, int mbx_style) lseek (fd, (off_t) 0, SEEK_SET); /* append message to file */ - if (mbx_copy (mailbox, mbx_style, md, fd, mapping, NULL, verbose) == -1) { + if (mbx_copy (mailbox, mbx_style, md, fd, mapping, NULL, verbose) + == -1) { if (verbose) adorn ("", "error writing to:"); return -1; @@ -1081,8 +1101,8 @@ usr_file (int fd, char *mailbox, int mbx_style) /* - * Deliver message to a nmh folder. - */ +** Deliver message to a nmh folder. +*/ static int usr_folder (int fd, char *string) @@ -1108,8 +1128,8 @@ usr_folder (int fd, char *string) #if 0 /* - * Currently, verbose status messages are handled by usr_pipe(). - */ + ** Currently, verbose status messages are handled by usr_pipe(). + */ if (verbose) { if (status == 0) verbose_printf (", success.\n"); @@ -1122,8 +1142,8 @@ usr_folder (int fd, char *string) } /* - * Deliver message to a process. - */ +** Deliver message to a process. +*/ static int usr_pipe (int fd, char *cmd, char *pgm, char **vec, int suppress) @@ -1164,7 +1184,8 @@ usr_pipe (int fd, char *cmd, char *pgm, char **vec, int suppress) } #endif /* TIOCNOTTY */ - setpgid ((pid_t) 0, getpid ()); /* put in own process group */ + /* put in own process group */ + setpgid ((pid_t) 0, getpid ()); *environ = NULL; m_putenv ("USER", pw->pw_name); @@ -1178,9 +1199,13 @@ usr_pipe (int fd, char *cmd, char *pgm, char **vec, int suppress) /* parent process */ if (!setjmp (myctx)) { SIGNAL (SIGALRM, alrmser); - bytes = fstat (fd, &st) != -1 ? (int) st.st_size : 100; + bytes = fstat (fd, &st) != -1 ? + (int) st.st_size : 100; - /* amount of time to wait depends on message size */ + /* + ** amount of time to wait depends on + ** message size + */ if (bytes <= 100) { /* give at least 5 minutes */ seconds = 300; @@ -1206,9 +1231,9 @@ usr_pipe (int fd, char *cmd, char *pgm, char **vec, int suppress) return (status == 0 ? 0 : -1); } else { /* - * Ruthlessly kill the child and anything - * else in its process group. - */ + ** Ruthlessly kill the child and anything + ** else in its process group. + */ KILLPG(child_id, SIGKILL); if (verbose) verbose_printf (", timed-out; terminated\n"); @@ -1230,9 +1255,9 @@ alrmser (int i) /* - * Get the `sender' from the envelope - * information ("From " line). - */ +** Get the `sender' from the envelope +** information ("From " line). +*/ static void get_sender (char *envelope, char **sender) @@ -1268,10 +1293,10 @@ get_sender (char *envelope, char **sender) /* - * Copy message into a temporary file. - * While copying, it will do some header processing - * including the extraction of the envelope information. - */ +** Copy message into a temporary file. +** While copying, it will do some header processing +** including the extraction of the envelope information. +*/ static int copy_message (int qd, char *tmpfil, int fold) @@ -1329,10 +1354,10 @@ you_lose: } /* - * copy message into temporary file - * and massage the headers. Save - * a copy of the "From " line for later. - */ + ** copy message into temporary file + ** and massage the headers. Save + ** a copy of the "From " line for later. + */ i = strlen ("From "); while (fgets (buffer, sizeof(buffer), qfp)) { if (first) { @@ -1341,11 +1366,17 @@ you_lose: #ifdef RPATHS char *fp, *cp, *hp, *ep; #endif - /* get copy of envelope information ("From " line) */ + /* + ** get copy of envelope information + ** ("From " line) + */ envelope = getcpy (buffer); #if 0 - /* First go ahead and put "From " line in message */ + /* + ** First go ahead and put "From " line + ** in message + */ fputs (buffer, ffp); if (ferror (ffp)) goto fputs_error; @@ -1353,9 +1384,9 @@ you_lose: #ifdef RPATHS /* - * Now create a "Return-Path:" line - * from the "From " line. - */ + ** Now create a "Return-Path:" line + ** from the "From " line. + */ hp = cp = strchr(fp = envelope + i, ' '); while ((hp = strchr(++hp, 'r'))) if (uprf (hp, "remote from")) { @@ -1363,14 +1394,18 @@ you_lose: break; } if (hp) { - /* return path for UUCP style addressing */ + /* + ** return path for UUCP style + ** addressing + */ ep = strchr(++hp, '\n'); - snprintf (buffer, sizeof(buffer), "Return-Path: %.*s!%.*s\n", - (int)(ep - hp), hp, (int)(cp - fp), fp); + snprintf (buffer, sizeof(buffer), "Return-Path: %.*s!%.*s\n", (int)(ep - hp), hp, (int)(cp - fp), fp); } else { - /* return path for standard domain addressing */ - snprintf (buffer, sizeof(buffer), "Return-Path: %.*s\n", - (int)(cp - fp), fp); + /* + ** return path for standard domain + ** addressing + */ + snprintf (buffer, sizeof(buffer), "Return-Path: %.*s\n", (int)(cp - fp), fp); } /* Add Return-Path header to message */ @@ -1411,8 +1446,8 @@ fputs_error: } /* - * Trim strings for pretty printing of debugging output - */ +** Trim strings for pretty printing of debugging output +*/ static char * trim (char *cp) @@ -1449,8 +1484,8 @@ trim (char *cp) } /* - * Function for printing `verbose' messages. - */ +** Function for printing `verbose' messages. +*/ static void verbose_printf (char *fmt, ...) @@ -1466,9 +1501,9 @@ verbose_printf (char *fmt, ...) /* - * Function for printing `verbose' delivery - * error messages. - */ +** Function for printing `verbose' delivery +** error messages. +*/ static void adorn (char *what, char *fmt, ...) @@ -1499,8 +1534,8 @@ adorn (char *what, char *fmt, ...) /* - * Function for printing `debug' messages. - */ +** Function for printing `debug' messages. +*/ static void debug_printf (char *fmt, ...) @@ -1514,11 +1549,11 @@ debug_printf (char *fmt, ...) /* - * Check ndbm/db file(s) to see if the Message-Id of this - * message matches the Message-Id of a previous message, - * so we can discard it. If it doesn't match, we add the - * Message-Id of this message to the ndbm/db file. - */ +** Check ndbm/db file(s) to see if the Message-Id of this +** message matches the Message-Id of a previous message, +** so we can discard it. If it doesn't match, we add the +** Message-Id of this message to the ndbm/db file. +*/ static int suppress_duplicates (int fd, char *file) { @@ -1566,12 +1601,12 @@ suppress_duplicates (int fd, char *file) return -1; } /* - * Since it is difficult to portable - * lock a ndbm file, we will open and - * lock the Maildelivery file instead. - * This will fail if your Maildelivery - * file doesn't exist. - */ + ** Since it is difficult to portable + ** lock a ndbm file, we will open and + ** lock the Maildelivery file instead. + ** This will fail if your Maildelivery + ** file doesn't exist. + */ if ((lockfd = lkopen(file, O_RDWR, 0)) == -1) { advise (file, "unable to perform file locking on"); free (cp); @@ -1581,8 +1616,7 @@ suppress_duplicates (int fd, char *file) value = dbm_fetch (db, key); if (value.dptr) { if (verbose) - verbose_printf ("Message-ID: %s\n already received on %s", - cp, value.dptr); + verbose_printf ("Message-ID: %s\n already received on %s", cp, value.dptr); result = DONE; } else { value.dptr = ddate + sizeof("Delivery-Date:"); diff --git a/uip/sortm.c b/uip/sortm.c index 4b63bb6..7d5a35c 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -1,10 +1,10 @@ /* - * sortm.c -- sort messages in a folder by date/time - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** sortm.c -- sort messages in a folder by date/time +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -52,8 +52,8 @@ int verbose; typedef int (*qsort_comp) (const void *, const void *); /* - * static prototypes - */ +** static prototypes +*/ static int read_hdrs (struct msgs *, char *); static int get_fields (char *, int, struct smsg *); static int dsort (struct smsg **, struct smsg **); @@ -87,8 +87,8 @@ main (int argc, char **argv) argp = arguments; /* - * Parse arguments - */ + ** Parse arguments + */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -99,8 +99,7 @@ main (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", - invo_name); + snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -111,14 +110,16 @@ main (int argc, char **argv) if (datesw) adios (NULL, "only one date field at a time"); if (!(datesw = *argp++) || *datesw == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case TEXTSW: if (subjsort) adios (NULL, "only one text field at a time"); if (!(subjsort = *argp++) || *subjsort == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case SUBJSW: @@ -160,7 +161,7 @@ main (int argc, char **argv) else folder = pluspath (cp); } else - app_msgarg(&msgs, cp); + app_msgarg(&msgs, cp); } if (!context_find ("path")) @@ -194,8 +195,8 @@ main (int argc, char **argv) adios (NULL, "no messages to sort"); /* - * sort a list of pointers to our "messages to be sorted". - */ + ** sort a list of pointers to our "messages to be sorted". + */ dlist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*dlist)); for (i = 0; i < nmsgs; i++) dlist[i] = &smsgs[i]; @@ -215,33 +216,36 @@ main (int argc, char **argv) (qsort_comp) (submajor && subjsort ? txtsort : dsort)); /* - * if we're sorting on subject, we need another list - * in subject order, then a merge pass to collate the - * two sorts. - */ + ** if we're sorting on subject, we need another list + ** in subject order, then a merge pass to collate the + ** two sorts. + */ if (!submajor && subjsort) { /* already date sorted */ struct smsg **slist, **flist; register struct smsg ***il, **fp, **dp; - slist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*slist)); + slist = (struct smsg **) + mh_xmalloc ((nmsgs+1) * sizeof(*slist)); memcpy((char *)slist, (char *)dlist, (nmsgs+1)*sizeof(*slist)); - qsort((char *)slist, nmsgs, sizeof(*slist), (qsort_comp) subsort); + qsort((char *)slist, nmsgs, sizeof(*slist), + (qsort_comp) subsort); /* - * make an inversion list so we can quickly find - * the collection of messages with the same subj - * given a message number. - */ + ** make an inversion list so we can quickly find + ** the collection of messages with the same subj + ** given a message number. + */ il = (struct smsg ***) calloc (mp->hghsel+1, sizeof(*il)); if (! il) adios (NULL, "couldn't allocate msg list"); for (i = 0; i < nmsgs; i++) il[slist[i]->s_msg] = &slist[i]; /* - * make up the final list, chronological but with - * all the same subjects grouped together. - */ - flist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*flist)); + ** make up the final list, chronological but with + ** all the same subjects grouped together. + */ + flist = (struct smsg **) + mh_xmalloc ((nmsgs+1) * sizeof(*flist)); fp = flist; for (dp = dlist; *dp;) { register struct smsg **s = il[(*dp++)->s_msg]; @@ -252,15 +256,12 @@ main (int argc, char **argv) *fp++ = *s++; /* - * take the next message(s) if there is one, - * its subject isn't null and its subject - * is the same as this one and it's not too - * far away in time. - */ - while (*s && (*s)->s_subj[0] && - strcmp((*s)->s_subj, s[-1]->s_subj) == 0 && - (datelimit == 0 || - (*s)->s_clock - s[-1]->s_clock <= datelimit)) { + ** take the next message(s) if there is one, + ** its subject isn't null and its subject + ** is the same as this one and it's not too + ** far away in time. + */ + while (*s && (*s)->s_subj[0] && strcmp((*s)->s_subj, s[-1]->s_subj) == 0 && (datelimit == 0 || (*s)->s_clock - s[-1]->s_clock <= datelimit)) { il[(*s)->s_msg] = 0; *fp++ = *s++; } @@ -272,9 +273,9 @@ main (int argc, char **argv) } /* - * At this point, dlist is a sorted array of pointers to smsg - * structures, each of which contains a message number. - */ + ** At this point, dlist is a sorted array of pointers to smsg + ** structures, each of which contains a message number. + */ rename_msgs (mp, dlist); @@ -316,9 +317,9 @@ read_hdrs (struct msgs *mp, char *datesw) /* - * Parse the message and get the data or subject field, - * if needed. - */ +** Parse the message and get the data or subject field, +** if needed. +*/ static int get_fields (char *datesw, int msg, struct smsg *smsg) @@ -343,15 +344,17 @@ get_fields (char *datesw, int msg, struct smsg *smsg) if (!mh_strcasecmp (nam, datesw)) { datecomp = add (buf, datecomp); while (state == FLDPLUS) { - state = m_getfld (state, nam, buf, sizeof(buf), in); + state = m_getfld (state, nam, buf, + sizeof(buf), in); datecomp = add (buf, datecomp); } if (!subjsort || subjcomp) break; - } else if (subjsort && !mh_strcasecmp (nam, subjsort)) { + } else if (subjsort && !mh_strcasecmp(nam, subjsort)) { subjcomp = add (buf, subjcomp); while (state == FLDPLUS) { - state = m_getfld (state, nam, buf, sizeof(buf), in); + state = m_getfld (state, nam, buf, + sizeof(buf), in); subjcomp = add (buf, subjcomp); } if (datecomp) @@ -359,7 +362,8 @@ get_fields (char *datesw, int msg, struct smsg *smsg) } else { /* just flush this guy */ while (state == FLDPLUS) - state = m_getfld (state, nam, buf, sizeof(buf), in); + state = m_getfld (state, nam, buf, + sizeof(buf), in); } continue; @@ -371,8 +375,7 @@ get_fields (char *datesw, int msg, struct smsg *smsg) case LENERR: case FMTERR: if (state == LENERR || state == FMTERR) - admonish (NULL, "format error in message %d (header #%d)", - msg, compnum); + admonish (NULL, "format error in message %d (header #%d)", msg, compnum); if (datecomp) free (datecomp); if (subjcomp) @@ -387,13 +390,14 @@ get_fields (char *datesw, int msg, struct smsg *smsg) } /* - * If no date component, then use the modification - * time of the file as its date - */ + ** If no date component, then use the modification + ** time of the file as its date + */ if (!datecomp || (tw = dparsetime (datecomp)) == NULL) { struct stat st; - admonish (NULL, "can't parse %s field in message %d", datesw, msg); + admonish (NULL, "can't parse %s field in message %d", + datesw, msg); fstat (fileno (in), &st); smsg->s_clock = st.st_mtime; } else { @@ -403,10 +407,10 @@ get_fields (char *datesw, int msg, struct smsg *smsg) if (subjsort) { if (subjcomp) { /* - * try to make the subject "canonical": delete - * leading "re:", everything but letters & smash - * letters to lower case. - */ + ** try to make the subject "canonical": delete + ** leading "re:", everything but letters & smash + ** letters to lower case. + */ register char *cp, *cp2; register unsigned char c; @@ -430,8 +434,7 @@ get_fields (char *datesw, int msg, struct smsg *smsg) } *cp2 = '\0'; - } - else + } else subjcomp = ""; smsg->s_subj = subjcomp; @@ -444,8 +447,8 @@ get_fields (char *datesw, int msg, struct smsg *smsg) } /* - * sort on dates. - */ +** sort on dates. +*/ static int dsort (struct smsg **a, struct smsg **b) { @@ -460,8 +463,8 @@ dsort (struct smsg **a, struct smsg **b) } /* - * sort on subjects. - */ +** sort on subjects. +*/ static int subsort (struct smsg **a, struct smsg **b) { @@ -503,8 +506,9 @@ rename_chain (struct msgs *mp, struct smsg **mlist, int msg, int endmsg) if (verbose) printf ("message %d becomes message %d\n", old, new); - (void)snprintf(oldname, sizeof (oldname), "%s/%d", mp->foldpath, old); - (void)snprintf(newbuf, sizeof (newbuf), "%s/%d", mp->foldpath, new); + snprintf(oldname, sizeof (oldname), "%s/%d", + mp->foldpath, old); + snprintf(newbuf, sizeof (newbuf), "%s/%d", mp->foldpath, new); ext_hook("ref-hook", oldname, newbuf); if (rename (oldname, newname) == NOTOK) @@ -543,25 +547,27 @@ rename_msgs (struct msgs *mp, struct smsg **mlist) continue; /* this one doesn't move */ /* - * the guy that was msg j is about to become msg i. - * rename 'j' to make a hole, then recursively rename - * guys to fill up the hole. - */ + ** the guy that was msg j is about to become msg i. + ** rename 'j' to make a hole, then recursively rename + ** guys to fill up the hole. + */ old = smsgs[j].s_msg; new = smsgs[i].s_msg; strncpy (f1, m_name (old), sizeof(f1)); if (verbose) - printf ("renaming message chain from %d to %d\n", old, new); + printf ("renaming message chain from %d to %d\n", + old, new); /* - * Run the external hook to refile the old message as the - * temporary message number that is off of the end of the - * messages in the folder. - */ + ** Run the external hook to refile the old message as the + ** temporary message number that is off of the end of the + ** messages in the folder. + */ (void)snprintf(f1, sizeof (f1), "%s/%d", mp->foldpath, old); - (void)snprintf(newbuf, sizeof (newbuf), "%s/%d", mp->foldpath, mp->hghmsg + 1); + (void)snprintf(newbuf, sizeof (newbuf), "%s/%d", + mp->foldpath, mp->hghmsg + 1); ext_hook("ref-hook", f1, newbuf); if (rename (f1, tmpfil) == NOTOK) @@ -572,9 +578,9 @@ rename_msgs (struct msgs *mp, struct smsg **mlist) rename_chain (mp, mlist, j, i); /* - * Run the external hook to refile the temorary message number - * to the real place. - */ + ** Run the external hook to refile the temorary message number + ** to the real place. + */ (void)snprintf(f1, sizeof (f1), "%s/%d", mp->foldpath, new); ext_hook("ref-hook", newbuf, f1); diff --git a/uip/spost.c b/uip/spost.c index 80c6183..63b49da 100644 --- a/uip/spost.c +++ b/uip/spost.c @@ -1,13 +1,13 @@ /* - * spost.c -- feed messages to sendmail - * - * This is a simpler, faster, replacement for "post" for use - * when "sendmail" is the transport system. - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** spost.c -- feed messages to sendmail +** +** This is a simpler, faster, replacement for "post" for use +** when "sendmail" is the transport system. +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -165,16 +165,16 @@ static FILE *out; /* output (temp) file */ extern char *sendmail; /* - * external prototypes - */ +** external prototypes +*/ extern char *getfullname (void); extern char *getusername (void); extern boolean draft_from_masquerading; /* defined in mts.c */ /* - * static prototypes - */ +** static prototypes +*/ static void putfmt (char *, char *, FILE *); static void start_headers (void); static void finish_headers (FILE *); @@ -238,7 +238,8 @@ main (int argc, char **argv) continue; case FILTSW: - if (!(filter = *argp++) || *filter == '-') + if (!(filter = *argp++) || + *filter == '-') adios (NULL, "missing argument to %s", argp[-2]); continue; case NFILTSW: @@ -283,12 +284,13 @@ main (int argc, char **argv) case ALIASW: if (!(cp = *argp++) || *cp == '-') adios (NULL, "missing argument to %s", argp[-2]); - if (aliasflg < 0) - alias (AliasFile);/* load default aka's */ + if (aliasflg < 0) { + /* load default aka's */ + alias (AliasFile); + } aliasflg = 1; if ((state = alias(cp)) != AK_OK) - adios (NULL, "aliasing error in file %s - %s", - cp, akerror(state) ); + adios (NULL, "aliasing error in file %s - %s", cp, akerror(state) ); continue; case NALIASW: aliasflg = 0; @@ -373,7 +375,8 @@ main (int argc, char **argv) finish_headers (out); fprintf (out, "\n%s", buf); while (state == BODY) { - state = m_getfld (state, name, buf, sizeof(buf), in); + state = m_getfld (state, name, buf, + sizeof(buf), in); fputs (buf, out); } break; @@ -384,8 +387,7 @@ main (int argc, char **argv) case LENERR: case FMTERR: - adios (NULL, "message format error in component #%d", - compnum); + adios (NULL, "message format error in component #%d", compnum); default: adios (NULL, "getfld() returned %d", state); @@ -409,9 +411,9 @@ main (int argc, char **argv) file (tmpfil); /* - * re-open the temp file, unlink it and exec sendmail, giving it - * the msg temp file as std in. - */ + ** re-open the temp file, unlink it and exec sendmail, giving it + ** the msg temp file as std in. + */ if ( freopen( tmpfil, "r", stdin) == NULL) adios (tmpfil, "can't reopen for sendmail"); if (rmflg) @@ -432,8 +434,9 @@ main (int argc, char **argv) sleep(5); switch (pid) { case NOTOK: - fprintf (verbose ? stdout : stderr, "%s: can't fork to %s\n", - invo_name, sendmail); + fprintf (verbose ? stdout : stderr, + "%s: can't fork to %s\n", + invo_name, sendmail); exit(-1); case OK: /* we're the child .. */ @@ -475,7 +478,8 @@ putfmt (char *name, char *str, FILE *out) msgflags |= hdr->set; if (hdr->flags & HSUB) - subject = subject ? add (str, add ("\t", subject)) : getcpy (str); + subject = subject ? add (str, add ("\t", subject)) : + getcpy (str); if (hdr->flags & HFCC) { if ((cp = strrchr(str, '\n'))) @@ -497,12 +501,13 @@ putfmt (char *name, char *str, FILE *out) if (*str != '\n' && *str != '\0') { if (aliasflg && hdr->flags & HTRY) { - /* this header contains address(es) that we have to do - * alias expansion on. Because of the saved state in - * getname we have to put all the addresses into a list. - * We then let putadr munch on that list, possibly - * expanding aliases. - */ + /* + ** this header contains address(es) that we have to do + ** alias expansion on. Because of the saved state in + ** getname we have to put all the addresses into a + ** list. We then let putadr munch on that list, + ** possibly expanding aliases. + **/ register struct mailname *f = 0; register struct mailname *mp = 0; @@ -521,24 +526,24 @@ putfmt (char *name, char *str, FILE *out) putadr( name, f ); } else { /* - * The author(s) of spost decided that alias - * substitution wasn't necessary for the non-HTRY - * headers. Unfortunately, one of those headers - * is "From:", and having alias substitution - * work on that is extremely useful for someone - * with a lot of POP3 email accounts or aliases. - * post supports aliasing of "From:"... - * - * Since "From:"-processing is incompletely - * implemented in this unsupported and - * undocumented spost backend, I'm not - * going to take the time to implement my new - * draft-From:-based email address masquerading. - * If I do ever implement it here, I'd almost - * certainly want to implement "From:" line - * alias processing as well. - * -- Dan Harkless - */ + ** The author(s) of spost decided that alias + ** substitution wasn't necessary for the non-HTRY + ** headers. Unfortunately, one of those headers + ** is "From:", and having alias substitution + ** work on that is extremely useful for someone + ** with a lot of POP3 email accounts or aliases. + ** post supports aliasing of "From:"... + ** + ** Since "From:"-processing is incompletely + ** implemented in this unsupported and + ** undocumented spost backend, I'm not + ** going to take the time to implement my new + ** draft-From:-based email address masquerading. + ** If I do ever implement it here, I'd almost + ** certainly want to implement "From:" line + ** alias processing as well. + ** -- Dan Harkless + */ fprintf (out, "%s: %s", name, str ); } } @@ -555,7 +560,8 @@ start_headers (void) if ((cp = getfullname ()) && *cp) { strncpy (sigbuf, cp, sizeof(sigbuf)); - snprintf (signature, sizeof(signature), "%s <%s>", sigbuf, from); + snprintf (signature, sizeof(signature), "%s <%s>", + sigbuf, from); } else snprintf (signature, sizeof(signature), "%s", from); } @@ -570,17 +576,20 @@ finish_headers (FILE *out) fprintf (out, "Date: %s\n", dtimenow (0)); if (msgflags & MFRM) { - /* There was already a From: in the draft. Don't add one. */ + /* + ** There was already a From: in the draft. + ** Don't add one. + */ if (!draft_from_masquerading) /* - * mts.conf didn't contain - * "masquerade:[...]draft_from[...]" - * so we'll reveal the user's - * actual account@thismachine - * address in a Sender: header - * (and use it as the envelope - * From: later). - */ + ** mts.conf didn't contain + ** "masquerade:[...]draft_from[...]" + ** so we'll reveal the user's + ** actual account@thismachine + ** address in a Sender: header + ** (and use it as the envelope + ** From: later). + */ fprintf (out, "Sender: %s\n", from); } else fprintf (out, "From: %s\n", signature); @@ -593,20 +602,25 @@ finish_headers (FILE *out) case resent: if (!(msgflags & MRDT)) - fprintf (out, "Resent-Date: %s\n", dtimenow(0)); + fprintf (out, "Resent-Date: %s\n", + dtimenow(0)); if (msgflags & MRFM) { - /* There was already a Resent-From: in draft. Don't add one. */ + /* + ** There was already a Resent-From: in draft. + ** Don't add one. + */ if (!draft_from_masquerading) /* - * mts.conf didn't contain - * "masquerade:[...]draft_from[...]" - * so we'll reveal the user's - * actual account@thismachine - * address in a Sender: header - * (and use it as the envelope - * From: later). - */ - fprintf (out, "Resent-Sender: %s\n", from); + ** mts.conf didn't contain + ** "masquerade:[...]draft_from[...]" + ** so we'll reveal the user's + ** actual account@thismachine + ** address in a Sender: header + ** (and use it as the envelope + ** From: later). + */ + fprintf (out, "Resent-Sender: %s\n", + from); } else /* Construct a Resent-From: header. */ fprintf (out, "Resent-From: %s\n", signature); @@ -636,10 +650,10 @@ get_header (char *header, struct headers *table) /* - * output the address list for header "name". The address list - * is a linked list of mailname structs. "nl" points to the head - * of the list. Alias substitution should be done on nl. - */ +** output the address list for header "name". The address list +** is a linked list of mailname structs. "nl" points to the head +** of the list. Alias substitution should be done on nl. +*/ static void putadr (char *name, struct mailname *nl) { @@ -654,15 +668,15 @@ putadr (char *name, struct mailname *nl) for (mp = nl; mp; ) { if (linepos > MAX_SM_FIELD) { - fprintf (out, "\n%s: ", name); - linepos = namelen; + fprintf (out, "\n%s: ", name); + linepos = namelen; } if (mp->m_nohost) { /* a local name - see if it's an alias */ cp = akvalue(mp->m_mbox); if (cp == mp->m_mbox) /* wasn't an alias - use what the user typed */ - linepos = putone( mp->m_text, linepos, namelen ); + linepos = putone(mp->m_text, linepos, namelen); else /* an alias - expand it */ while ((cp = getname(cp))) { @@ -703,8 +717,7 @@ putone (char *adr, int pos, int indent) fprintf ( out, ",\n%*s", indent, ""); linepos = indent; pos += indent + 2; - } - else { + } else { fputs( ", ", out ); linepos += 2; pos += 2; @@ -762,11 +775,11 @@ make_bcc_file (void) /* There was already a From: in the draft. Don't add one. */ if (!draft_from_masquerading) /* - * mts.conf didn't contain "masquerade:[...]draft_from[...]" - * so we'll reveal the user's actual account@thismachine - * address in a Sender: header (and use it as the envelope - * From: later). - */ + ** mts.conf didn't contain "masquerade:[...]draft_from[...]" + ** so we'll reveal the user's actual account@thismachine + ** address in a Sender: header (and use it as the envelope + ** From: later). + */ fprintf (out, "Sender: %s\n", from); } else /* Construct a From: header. */ @@ -805,7 +818,8 @@ make_bcc_file (void) default: if (status = pidwait(child_id, OK)) - admonish (NULL, "%s lost (status=0%o)", vec[0], status); + admonish (NULL, "%s lost (status=0%o)", + vec[0], status); break; } } @@ -876,8 +890,8 @@ fcc (char *file, char *folder) #if 0 /* - * TERMINATION - */ +** TERMINATION +*/ static void die (char *what, char *fmt, ...) diff --git a/uip/termsbr.c b/uip/termsbr.c index ce1420c..f2b0a53 100644 --- a/uip/termsbr.c +++ b/uip/termsbr.c @@ -1,10 +1,10 @@ /* - * termsbr.c -- termcap support - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** termsbr.c -- termcap support +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include @@ -42,9 +42,9 @@ #endif /* - * These variables are sometimes defined in, - * and needed by the termcap library. - */ +** These variables are sometimes defined in, +** and needed by the termcap library. +*/ #ifdef HAVE_OSPEED # ifdef MUST_DEFINE_OSPEED extern short ospeed; @@ -99,8 +99,8 @@ read_termcap(void) return; /* - * If possible, we let tgetent allocate its own termcap buffer - */ +** If possible, we let tgetent allocate its own termcap buffer +*/ #ifdef TGETENT_ACCEPTS_NULL if (tgetent (NULL, term) != TGETENT_SUCCESS) return; @@ -113,9 +113,11 @@ read_termcap(void) speedcode = cfgetospeed(&tio); #else # ifdef HAVE_TERMIO_H - speedcode = ioctl(fileno(stdout), TCGETA, &tio) != NOTOK ? tio.c_cflag & CBAUD : 0; + speedcode = ioctl(fileno(stdout), TCGETA, &tio) != NOTOK ? + tio.c_cflag & CBAUD : 0; # else - speedcode = ioctl(fileno(stdout), TIOCGETP, (char *) &tio) != NOTOK ? tio.sg_ospeed : 0; + speedcode = ioctl(fileno(stdout), TIOCGETP, (char *) &tio) != NOTOK ? + tio.sg_ospeed : 0; # endif #endif @@ -198,8 +200,8 @@ clear_screen (void) /* - * print in standout mode - */ +** print in standout mode +*/ int SOprintf (char *fmt, ...) { @@ -221,8 +223,8 @@ SOprintf (char *fmt, ...) } /* - * Is this a hardcopy terminal? - */ +** Is this a hardcopy terminal? +*/ int sc_hardcopy(void) diff --git a/uip/viamail.c b/uip/viamail.c index 25e65c2..3bf341d 100644 --- a/uip/viamail.c +++ b/uip/viamail.c @@ -1,10 +1,10 @@ /* - * viamail.c -- send multiple files in a MIME message - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** viamail.c -- send multiple files in a MIME message +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -59,8 +59,8 @@ void set_endian (void); int writeBase64aux (FILE *, FILE *); /* - * static prototypes - */ +** static prototypes +*/ static int via_mail (char *, char *, char *, char *, char *, char *); @@ -94,7 +94,8 @@ main (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [switches]", invo_name); + snprintf (buf, sizeof(buf), "%s [switches]", + invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: @@ -103,27 +104,33 @@ main (int argc, char **argv) case TOSW: if (!(f1 = *argp++)) - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case SUBJECTSW: if (!(f2 = *argp++)) - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case PARAMSW: if (!(f3 = *argp++)) - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case DESCRIPTSW: if (!(f4 = *argp++)) - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case COMMENTSW: if (!(f5 = *argp++)) - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case FROMSW: if (!(f7 = *argp++)) - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case VERBSW: @@ -151,8 +158,8 @@ main (int argc, char **argv) /* - * VIAMAIL - */ +** VIAMAIL +*/ static int via_mail (char *mailsw, char *subjsw, char *parmsw, char *descsw, diff --git a/uip/whatnow.c b/uip/whatnow.c index a6bb0f9..061c844 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -1,10 +1,10 @@ /* - * whatnow.c -- the nmh `WhatNow' shell - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** whatnow.c -- the nmh `WhatNow' shell +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include diff --git a/uip/whatnowproc.c b/uip/whatnowproc.c index 44146d7..9d4d06d 100644 --- a/uip/whatnowproc.c +++ b/uip/whatnowproc.c @@ -1,22 +1,22 @@ /* - * whatnowproc.c -- exec the "whatnowproc" - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** whatnowproc.c -- exec the "whatnowproc" +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include /* - * This routine is used by comp, repl, forw, and dist to exec - * the "whatnowproc". It first sets up all the environment - * variables that the "whatnowproc" will need to check, and - * then execs the command. As an optimization, if the - * "whatnowproc" is the nmh command "whatnow" (typical case), - * it will call this routine directly without exec'ing it. - */ +** This routine is used by comp, repl, forw, and dist to exec +** the "whatnowproc". It first sets up all the environment +** variables that the "whatnowproc" will need to check, and +** then execs the command. As an optimization, if the +** "whatnowproc" is the nmh command "whatnow" (typical case), +** it will call this routine directly without exec'ing it. +*/ /* from whatnowsbr.c */ int WhatNow (int, char **); @@ -44,7 +44,8 @@ what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist, if (mp == NULL || *altmsg == '/' || cwd == NULL) m_putenv ("mhaltmsg", altmsg); else { - snprintf (buffer, sizeof(buffer), "%s/%s", mp->foldpath, altmsg); + snprintf (buffer, sizeof(buffer), "%s/%s", + mp->foldpath, altmsg); m_putenv ("mhaltmsg", buffer); } } else { @@ -73,14 +74,17 @@ what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist, buflen = sizeof(buffer); for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) { if (is_selected(mp, msgnum)) { - snprintf (bp, buflen, "%s%s", found ? " " : "", m_name (msgnum)); + snprintf (bp, buflen, "%s%s", + found ? " " : "", + m_name (msgnum)); len = strlen (bp); bp += len; buflen -= len; for (k = msgnum + 1; k <= mp->hghmsg && is_selected(mp, k); k++) continue; if (--k > msgnum) { - snprintf (bp, buflen, "-%s", m_name (k)); + snprintf (bp, buflen, "-%s", + m_name (k)); len = strlen (bp); bp += len; buflen -= len; @@ -104,9 +108,9 @@ what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist, chdir (cwd); /* - * If the "whatnowproc" is the nmh command "whatnow", - * we run it internally, rather than exec'ing it. - */ + ** If the "whatnowproc" is the nmh command "whatnow", + ** we run it internally, rather than exec'ing it. + */ if (strcmp (vec[0], "whatnow") == 0) { WhatNow (vecp, vec); done (0); diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index f8b7223..0dfc3d7 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -1,41 +1,41 @@ /* - * whatnowsbr.c -- the WhatNow shell - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - * - * Several options have been added to ease the inclusion of attachments - * using the header field name mechanism added to anno and send. The - * -attach option is used to specify the header field name for attachments. - * - * Several commands have been added at the whatnow prompt: - * - * cd [ directory ] This option works just like the shell's - * cd command and lets the user change the - * directory from which attachments are - * taken so that long path names are not - * needed with every file. - * - * ls [ ls-options ] This option works just like the normal - * ls command and exists to allow the user - * to verify file names in the directory. - * - * pwd This option works just like the normal - * pwd command and exists to allow the user - * to verify the directory. - * - * attach files This option attaches the named files to - * the draft. - * - * alist [-ln] This option lists the attachments on the - * draft. -l gets long listings, -n gets - * numbered listings. - * - * detach files This option removes attachments from the - * detach -n numbers draft. This can be done by file name or - * by attachment number. - */ +** whatnowsbr.c -- the WhatNow shell +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +** +** Several options have been added to ease the inclusion of attachments +** using the header field name mechanism added to anno and send. The +** -attach option is used to specify the header field name for attachments. +** +** Several commands have been added at the whatnow prompt: +** +** cd [ directory ] This option works just like the shell's +** cd command and lets the user change the +** directory from which attachments are +** taken so that long path names are not +** needed with every file. +** +** ls [ ls-options ] This option works just like the normal +** ls command and exists to allow the user +** to verify file names in the directory. +** +** pwd This option works just like the normal +** pwd command and exists to allow the user +** to verify the directory. +** +** attach files This option attaches the named files to +** the draft. +** +** alist [-ln] This option lists the attachments on the +** draft. -l gets long listings, -n gets +** numbered listings. +** +** detach files This option removes attachments from the +** detach -n numbers draft. This can be done by file name or +** by attachment number. +*/ #include #include @@ -60,8 +60,8 @@ static struct swit whatnowswitches[] = { }; /* - * Options at the "whatnow" prompt - */ +** Options at the "whatnow" prompt +*/ static struct swit aleqs[] = { #define EDITSW 0 { "edit [ ]", 0 }, @@ -99,8 +99,8 @@ static struct swit aleqs[] = { static char *myprompt = "\nWhat now? "; /* - * static prototypes - */ +** static prototypes +*/ static int editfile (char **, char **, char *, int, struct msgs *, char *, char *, int); static int sendfile (char **, char *, int); @@ -145,8 +145,8 @@ WhatNow (int argc, char **argv) argp = arguments; /* - * Get the initial current working directory. - */ + ** Get the initial current working directory. + */ if (getcwd(cwd, sizeof (cwd)) == (char *)0) { adios("getcwd", "could not get working directory"); @@ -162,7 +162,9 @@ WhatNow (int argc, char **argv) adios (NULL, "-%s unknown", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [switches] [file]", invo_name); + snprintf (buf, sizeof(buf), + "%s [switches] [file]", + invo_name); print_help (buf, whatnowswitches, 1); done (1); case VERSIONSW: @@ -171,7 +173,8 @@ WhatNow (int argc, char **argv) case EDITRSW: if (!(ed = *argp++) || *ed == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); nedit = 0; continue; case NEDITSW: @@ -180,14 +183,16 @@ WhatNow (int argc, char **argv) case PRMPTSW: if (!(myprompt = *argp++) || *myprompt == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; case ATTACHSW: if (attach != (char *)0) adios(NULL, "only one attachment header field name at a time!"); if (!(attach = *argp++) || *attach == '-') - adios (NULL, "missing argument to %s", argp[-2]); + adios (NULL, "missing argument to %s", + argp[-2]); continue; } } @@ -197,7 +202,7 @@ WhatNow (int argc, char **argv) drft = cp; } - if ((drft == NULL && (drft = getenv ("mhdraft")) == NULL) || *drft == 0) + if ((drft == NULL && (drft = getenv("mhdraft")) == NULL) || *drft == 0) drft = getcpy (m_draft("cur")); msgnam = (cp = getenv ("mhaltmsg")) && *cp ? getcpy (cp) : NULL; @@ -211,7 +216,8 @@ WhatNow (int argc, char **argv) } /* start editing the draft, unless -noedit was given */ - if (!nedit && editfile (&ed, NULL, drft, use, NULL, msgnam, NULL, 1) < 0) + if (!nedit && editfile(&ed, NULL, drft, use, NULL, msgnam, NULL, 1) + < 0) done (1); snprintf (prompt, sizeof(prompt), myprompt, invo_name); @@ -222,7 +228,10 @@ WhatNow (int argc, char **argv) } switch (smatch (*argp, aleqs)) { case DISPSW: - /* display the message being replied to, or distributed */ + /* + ** display the message being replied to, + ** or distributed + */ if (msgnam) showfile (++argp, msgnam); else @@ -238,7 +247,8 @@ WhatNow (int argc, char **argv) /* Call an editor on the draft file */ if (*++argp) ed = *argp++; - if (editfile (&ed, argp, drft, NOUSE, NULL, msgnam, NULL, 1) == NOTOK) + if (editfile (&ed, argp, drft, NOUSE, NULL, + msgnam, NULL, 1) == NOTOK) done (1); break; @@ -254,7 +264,7 @@ WhatNow (int argc, char **argv) removefile (drft); } else { if (stat (drft, &st) != NOTOK) - advise (NULL, "draft left on %s", drft); + advise(NULL, "draft left on %s", drft); } done (1); @@ -282,13 +292,13 @@ WhatNow (int argc, char **argv) case CDCMDSW: /* - * Change the working directory for attachments - * - * Run the directory through the user's shell - * so that we can take advantage of any syntax - * that the user is accustomed to. Read back - * the absolute path. - */ + ** Change the working directory for attachments + ** + ** Run the directory through the user's shell + ** so that we can take advantage of any syntax + ** that the user is accustomed to. Read back + ** the absolute path. + */ if (*(argp+1) == (char *)0) { (void)sprintf(buf, "$SHELL -c \"cd;pwd\""); @@ -315,24 +325,24 @@ WhatNow (int argc, char **argv) case LSCMDSW: /* - * List files in the current attachment working - * directory - * - * Use the user's shell so that we can take - * advantage of any syntax that the user is - * accustomed to. - */ + ** List files in the current attachment working + ** directory + ** + ** Use the user's shell so that we can take + ** advantage of any syntax that the user is + ** accustomed to. + */ writelscmd(buf, sizeof(buf), argp); (void)system_in_dir(cwd, buf); break; case ALISTCMDSW: /* - * List attachments on current draft. Options are: - * - * -l long listing (full path names) - * -n numbers listing - */ + ** List attachments on current draft. Options are: + ** + ** -l long listing (full path names) + ** -n numbers listing + */ if (attach == (char *)0) { advise((char *)0, "can't list because no header field name was given."); @@ -349,7 +359,8 @@ WhatNow (int argc, char **argv) else if (strcmp(*argp, "-n") == 0) n = 1; - else if (strcmp(*argp, "-ln") == 0 || strcmp(*argp, "-nl") == 0) { + else if (strcmp(*argp, "-ln") == 0 || + strcmp(*argp, "-nl") == 0) { l = "/"; n = 1; } else { @@ -368,8 +379,8 @@ WhatNow (int argc, char **argv) case ATTACHCMDSW: /* - * Attach files to current draft. - */ + ** Attach files to current draft. + */ if (attach == (char *)0) { advise((char *)0, "can't attach because no header field name was given."); @@ -382,32 +393,36 @@ WhatNow (int argc, char **argv) } /* - * Build a command line that causes the user's - * shell to list the file name arguments. - * This handles and wildcard expansion, tilde - * expansion, etc. - */ + ** Build a command line that causes the user's + ** shell to list the file name arguments. + ** This handles and wildcard expansion, tilde + ** expansion, etc. + */ writelscmd(buf, sizeof(buf), argp); /* - * Read back the response from the shell, - * which contains a number of lines with one - * file name per line. Remove off the newline. - * Determine whether we have an absolute or - * relative path name. Prepend the current - * working directory to relative path names. - * Add the attachment annotation to the draft. - */ + ** Read back the response from the shell, + ** which contains a number of lines with one + ** file name per line. Remove off the newline. + ** Determine whether we have an absolute or + ** relative path name. Prepend the current + ** working directory to relative path names. + ** Add the attachment annotation to the draft. + */ if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) { - while (fgets(shell, sizeof (shell), f) != (char *)0) { + while (fgets(shell, sizeof (shell), f) + != (char *)0) { *(strchr(shell, '\n')) = '\0'; if (*shell == '/') - (void)annotate(drft, attach, shell, 1, 0, -2, 1); + annotate(drft, attach, shell, + 1, 0, -2, 1); else { - (void)sprintf(file, "%s/%s", cwd, shell); - (void)annotate(drft, attach, file, 1, 0, -2, 1); + sprintf(file, "%s/%s", cwd, + shell); + annotate(drft, attach, file, + 1, 0, -2, 1); } } @@ -420,8 +435,8 @@ WhatNow (int argc, char **argv) case DETACHCMDSW: /* - * Detach files from current draft. - */ + ** Detach files from current draft. + */ if (attach == (char *)0) { advise((char *)0, "can't detach because no header field name was given."); @@ -429,12 +444,14 @@ WhatNow (int argc, char **argv) } /* - * Scan the arguments for a -n. Mixed file - * names and numbers aren't allowed, so this - * catches a -n anywhere in the argument list. - */ - - for (n = 0, arguments = argp + 1; *arguments != (char *)0; arguments++) { + ** Scan the arguments for a -n. Mixed file + ** names and numbers aren't allowed, so this + ** catches a -n anywhere in the argument list. + */ + + for (n = 0, arguments = argp + 1; + *arguments != (char *)0; + arguments++) { if (strcmp(*arguments, "-n") == 0) { n = 1; break; @@ -442,21 +459,24 @@ WhatNow (int argc, char **argv) } /* - * A -n was found so interpret the arguments as - * attachment numbers. Decrement any remaining - * argument number that is greater than the one - * just processed after processing each one so - * that the numbering stays correct. - */ + ** A -n was found so interpret the arguments as + ** attachment numbers. Decrement any remaining + ** argument number that is greater than the one + ** just processed after processing each one so + ** that the numbering stays correct. + */ if (n == 1) { - for (arguments = argp + 1; *arguments != (char *)0; arguments++) { + for (arguments = argp + 1; + *arguments != (char *)0; + arguments++) { if (strcmp(*arguments, "-n") == 0) continue; if (**arguments != '\0') { n = atoi(*arguments); - (void)annotate(drft, attach, (char *)0, 1, 0, n, 1); + annotate(drft, attach, NULL, + 1, 0, n, 1); for (argp = arguments + 1; *argp != (char *)0; argp++) { if (atoi(*argp) > n) { @@ -471,22 +491,24 @@ WhatNow (int argc, char **argv) } /* - * The arguments are interpreted as file names. - * Run them through the user's shell for wildcard - * expansion and other goodies. Do this from - * the current working directory if the argument - * is not an absolute path name (does not begin - * with a /). - * - * We feed all the file names to the shell at - * once, otherwise you can't provide a file name - * with a space in it. - */ + ** The arguments are interpreted as file names. + ** Run them through the user's shell for wildcard + ** expansion and other goodies. Do this from + ** the current working directory if the argument + ** is not an absolute path name (does not begin + ** with a /). + ** + ** We feed all the file names to the shell at + ** once, otherwise you can't provide a file name + ** with a space in it. + */ writelscmd(buf, sizeof(buf), argp); if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) { - while (fgets(shell, sizeof (shell), f) != (char *)0) { + while (fgets(shell, sizeof (shell), f) + != NULL) { *(strchr(shell, '\n')) = '\0'; - (void)annotate(drft, attach, shell, 1, 0, 0, 1); + annotate(drft, attach, shell, + 1, 0, 0, 1); } pclose(f); } else { @@ -507,27 +529,30 @@ WhatNow (int argc, char **argv) /* - * Build a command line of the form $SHELL -c "cd 'cwd'; cmd argp ... ; - * trailcmd". - */ +** Build a command line of the form $SHELL -c "cd 'cwd'; cmd argp ... ; +** trailcmd". +*/ static void writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp) { char *cp; - /* Note that we do not quote -- the argp from the user - * is assumed to be quoted as they desire. (We can't treat - * it as pure literal as that would prevent them using ~, - * wildcards, etc.) The buffer produced by this function - * should be given to popen_in_dir() or system_in_dir() so - * that the current working directory is set correctly. - */ + /* + ** Note that we do not quote -- the argp from the user + ** is assumed to be quoted as they desire. (We can't treat + ** it as pure literal as that would prevent them using ~, + ** wildcards, etc.) The buffer produced by this function + ** should be given to popen_in_dir() or system_in_dir() so + ** that the current working directory is set correctly. + */ int ln = snprintf(buf, bufsz, "$SHELL -c \"%s", cmd); - /* NB that some snprintf() return -1 on overflow rather than the - * new C99 mandated 'number of chars that would have been written' - */ - /* length checks here and inside the loop allow for the - * trailing ';', trailcmd, '"' and NUL - */ + /* + ** NB that some snprintf() return -1 on overflow rather than the + ** new C99 mandated 'number of chars that would have been written' + */ + /* + ** length checks here and inside the loop allow for the + ** trailing ';', trailcmd, '"' and NUL + */ int trailln = strlen(trailcmd) + 3; if (ln < 0 || ln + trailln > bufsz) adios((char *)0, "arguments too long"); @@ -553,18 +578,19 @@ writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp) } /* - * Build a command line that causes the user's shell to list the file name - * arguments. This handles and wildcard expansion, tilde expansion, etc. - */ +** Build a command line that causes the user's shell to list the file name +** arguments. This handles and wildcard expansion, tilde expansion, etc. +*/ static void writelscmd(char *buf, int bufsz, char **argp) { writesomecmd(buf, bufsz, "ls", "", argp); } -/* Like system(), but run the command in directory dir. - * This assumes the program is single-threaded! - */ +/* +** Like system(), but run the command in directory dir. +** This assumes the program is single-threaded! +*/ static int system_in_dir(const char *dir, const char *cmd) { @@ -598,8 +624,8 @@ popen_in_dir(const char *dir, const char *cmd, const char *type) /* - * EDIT - */ +** EDIT +*/ static int reedit = 0; /* have we been here before? */ static char *edsave = NULL; /* the editor we used previously */ @@ -643,11 +669,13 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp, if (mp == NULL || *altmsg == '/' || cwd == NULL) strncpy (altpath, altmsg, sizeof(altpath)); else - snprintf (altpath, sizeof(altpath), "%s/%s", mp->foldpath, altmsg); + snprintf (altpath, sizeof(altpath), "%s/%s", + mp->foldpath, altmsg); if (cwd == NULL) strncpy (linkpath, altmsglink, sizeof(linkpath)); else - snprintf (linkpath, sizeof(linkpath), "%s/%s", cwd, altmsglink); + snprintf (linkpath, sizeof(linkpath), "%s/%s", + cwd, altmsglink); } if (altmsg) { @@ -656,7 +684,8 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp, if (link (altpath, linkpath) == NOTOK) { #if 0 /* I don't think permission on symlinks matters /JLR */ - oumask = umask(0044); /* PJS: else symlinks are world 'r' */ + /* PJS: else symlinks are world 'r' */ + oumask = umask(0044); #endif symlink (altpath, linkpath); #if 0 @@ -742,14 +771,13 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp, || link (linkpath, altpath) == NOTOK))) advise (linkpath, "unable to update %s from", altmsg); #else /* HAVE_LSTAT */ - if (altmsg - && mp - && !is_readonly(mp) + if (altmsg && mp && !is_readonly(mp) && stat (linkpath, &st) != NOTOK && st.st_nlink == 1 && (unlink (altpath) == NOTOK - || link (linkpath, altpath) == NOTOK)) - advise (linkpath, "unable to update %s from", altmsg); + || link (linkpath, altpath) == NOTOK)) + advise (linkpath, "unable to update %s from", + altmsg); #endif /* HAVE_LSTAT */ } @@ -795,8 +823,8 @@ copyf (char *ifile, char *ofile) /* - * SEND - */ +** SEND +*/ static int sendfile (char **arg, char *file, int pushsw) @@ -806,24 +834,21 @@ sendfile (char **arg, char *file, int pushsw) char *cp, *sp, *vec[MAXARGS]; /* Translate MIME composition file, if necessary */ - if ((cp = context_find ("automimeproc")) - && (!strcmp (cp, "1")) - && !getenv ("NOMHNPROC") - && check_draft (file) + if ((cp = context_find ("automimeproc")) && (!strcmp (cp, "1")) + && !getenv ("NOMHNPROC") && check_draft (file) && (buildfile (NULL, file) == NOTOK)) return 0; /* For backwards compatibility */ - if ((cp = context_find ("automhnproc")) - && !getenv ("NOMHNPROC") - && check_draft (file) - && (i = editfile (&cp, NULL, file, NOUSE, NULL, NULL, NULL, 0))) + if ((cp = context_find ("automhnproc")) && !getenv ("NOMHNPROC") + && check_draft (file) && (i = editfile (&cp, NULL, + file, NOUSE, NULL, NULL, NULL, 0))) return 0; /* - * If the sendproc is the nmh command `send', then we call - * those routines directly rather than exec'ing the command. - */ + ** If the sendproc is the nmh command `send', then we call + ** those routines directly rather than exec'ing the command. + */ if (strcmp (sp = r1bindex (sendproc, '/'), "send") == 0) { cp = invo_name; sendit (invo_name = sp, arg, file, pushsw); @@ -864,8 +889,8 @@ sendfile (char **arg, char *file, int pushsw) /* - * Translate MIME composition file (call buildmimeproc) - */ +** Translate MIME composition file (call buildmimeproc) +*/ static int buildfile (char **argp, char *file) @@ -884,9 +909,9 @@ buildfile (char **argp, char *file) args = (char **) mh_xmalloc((i + 2) * sizeof(char *)); /* - * For backward compatibility, we need to add -build - * if we are using mhn as buildmimeproc - */ + ** For backward compatibility, we need to add -build + ** if we are using mhn as buildmimeproc + */ i = 0; if (strcmp (r1bindex (ed, '/'), "mhn") == 0) args[i++] = "-build"; @@ -904,8 +929,8 @@ buildfile (char **argp, char *file) /* - * Check if draft is a mhbuild composition file - */ +** Check if draft is a mhbuild composition file +*/ static int check_draft (char *msgnam) @@ -922,16 +947,17 @@ check_draft (char *msgnam) case FLDPLUS: case FLDEOF: /* - * If draft already contains any of the - * Content-XXX fields, then assume it already - * been converted. - */ + ** If draft already contains any of the + ** Content-XXX fields, then assume it already + ** been converted. + */ if (uprf (name, XXX_FIELD_PRF)) { fclose (fp); return 0; } while (state == FLDPLUS) - state = m_getfld (state, name, buf, sizeof(buf), fp); + state = m_getfld (state, name, buf, + sizeof(buf), fp); break; case BODY: @@ -944,7 +970,8 @@ check_draft (char *msgnam) return 1; } - state = m_getfld (state, name, buf, sizeof(buf), fp); + state = m_getfld (state, name, buf, + sizeof(buf), fp); } while (state == BODY); /* and fall... */ @@ -1050,8 +1077,7 @@ sendit (char *sp, char **arg, char *file, int pushed) char **arguments, *vec[MAXARGS]; struct stat st; char *attach = (char *)0; /* attachment header field name */ - int attachformat = 0; /* mhbuild format specifier for - attachments */ + int attachformat = 0; /* mhbuild format specifier for attachments */ #ifndef lint int distsw = 0; @@ -1061,22 +1087,22 @@ sendit (char *sp, char **arg, char *file, int pushed) #endif /* - * Make sure these are defined. In particular, we need - * vec[1] to be NULL, in case "arg" is NULL below. It - * doesn't matter what is the value of vec[0], but we - * set it to NULL, to help catch "off-by-one" errors. - */ + ** Make sure these are defined. In particular, we need + ** vec[1] to be NULL, in case "arg" is NULL below. It + ** doesn't matter what is the value of vec[0], but we + ** set it to NULL, to help catch "off-by-one" errors. + */ vec[0] = NULL; vec[1] = NULL; /* - * Temporarily copy arg to vec, since the brkstring() call in - * getarguments() will wipe it out before it is merged in. - * Also, we skip the first element of vec, since getarguments() - * skips it. Then we count the number of arguments - * copied. The value of "n" will be one greater than - * this in order to simulate the standard argc/argv. - */ + ** Temporarily copy arg to vec, since the brkstring() call in + ** getarguments() will wipe it out before it is merged in. + ** Also, we skip the first element of vec, since getarguments() + ** skips it. Then we count the number of arguments + ** copied. The value of "n" will be one greater than + ** this in order to simulate the standard argc/argv. + */ if (arg) { char **bp; @@ -1087,9 +1113,9 @@ sendit (char *sp, char **arg, char *file, int pushed) } /* - * Merge any arguments from command line (now in vec) - * and arguments from profile. - */ + ** Merge any arguments from command line (now in vec) + ** and arguments from profile. + */ arguments = getarguments (sp, n, vec, 1); argp = arguments; @@ -1117,7 +1143,8 @@ sendit (char *sp, char **arg, char *file, int pushed) return; case SHELPSW: - snprintf (buf, sizeof(buf), "%s [switches]", sp); + snprintf (buf, sizeof(buf), + "%s [switches]", sp); print_help (buf, sendswitches, 1); return; case SVERSIONSW: @@ -1189,7 +1216,8 @@ sendit (char *sp, char **arg, char *file, int pushed) continue; case SNDATTACHSW: - if (!(attach = *argp++) || *attach == '-') { + if (!(attach = *argp++) || + *attach == '-') { advise (NULL, "missing argument to %s", argp[-2]); return; } @@ -1200,10 +1228,8 @@ sendit (char *sp, char **arg, char *file, int pushed) adios (NULL, "missing argument to %s", argp[-1]); else { attachformat = atoi (*argp); - if (attachformat < 0 || - attachformat > ATTACHFORMATS - 1) { - advise (NULL, "unsupported attachformat %d", - attachformat); + if (attachformat < 0 || attachformat > ATTACHFORMATS - 1) { + advise (NULL, "unsupported attachformat %d", attachformat); continue; } } @@ -1280,8 +1306,8 @@ sendit (char *sp, char **arg, char *file, int pushed) /* - * Remove the draft file - */ +** Remove the draft file +*/ static int removefile (char *drft)