struct home *h_next; /* next home in list */
};
-struct home *seek_home (char *);
+struct home *seek_home(char *);
/*
** prototypes
*/
-int alias (char *);
-int akvisible (void);
-void init_pw (void);
-char *akresult (struct aka *);
-char *akvalue (char *);
-char *akerror (int);
+int alias(char *);
+int akvisible(void);
+void init_pw(void);
+char *akresult(struct aka *);
+char *akvalue(char *);
+char *akerror(int);
/* codes returned by alias() */
** 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);
+void crawl_folders(char *dir, crawl_callback_t *callback, void *baton);
/*
** prototypes
*/
-int mbx_open (char *, int, uid_t, gid_t, mode_t);
-int mbx_read (FILE *, long, struct drop **, int);
+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);
-int mbx_copy (char *, int, int, int, int, char *, int);
-int mbx_size (int, off_t, off_t);
-int mbx_close (char *, int);
-char *map_name (char *);
-int map_read (char *, long, struct drop **, int);
-int map_write (char *, int, int, long, off_t, off_t, long, int, int);
-int map_chk (char *, int, struct drop *, long, int);
+int mbx_copy(char *, int, int, int, int, char *, int);
+int mbx_size(int, off_t, off_t);
+int mbx_close(char *, int);
+char *map_name(char *);
+int map_read(char *, long, struct drop **, int);
+int map_write(char *, int, int, long, off_t, off_t, long, int, int);
+int map_chk(char *, int, struct drop *, long, int);
/*
** prototypes
*/
-struct format *fmt_scan (struct format *, char *, int, int *);
-char *new_fs (char *, char *, char *);
-int fmt_compile (char *, struct format **);
+struct format *fmt_scan(struct format *, char *, int, int *);
+char *new_fs(char *, char *, char *);
+int fmt_compile(char *, struct format **);
/*
** prototypes
*/
-char *legal_person (char *);
-struct adrx *getadrx (char *);
+char *legal_person(char *);
+struct adrx *getadrx(char *);
** miscellaneous macros
*/
-#define pidXwait(pid,cp) pidstatus (pidwait (pid, NOTOK), stdout, cp)
+#define pidXwait(pid,cp) pidstatus(pidwait(pid, NOTOK), stdout, cp)
#ifndef max
# define max(a,b) ((a) > (b) ? (a) : (b))
/*
** prototypes
*/
-int pidcheck (int);
-CT parse_mime (char *);
-int add_header (CT, char *, char *);
-int get_ctinfo (unsigned char *, CT, int);
-int params_external (CT, int);
-int open7Bit (CT, char **);
-void close_encoding (CT);
+int pidcheck(int);
+CT parse_mime(char *);
+int add_header(CT, char *, char *);
+int get_ctinfo(unsigned char *, CT, int);
+int params_external(CT, int);
+int open7Bit(CT, char **);
+void close_encoding(CT);
extern int checksw; /* Add Content-MD5 field */
extern char *uucpldir;
extern char *uucplfil;
-#define MAILDIR (mmdfldir && *mmdfldir ? mmdfldir : getenv ("HOME"))
-#define MAILFIL (mmdflfil && *mmdflfil ? mmdflfil : getusername ())
-#define UUCPDIR (uucpldir && *uucpldir ? uucpldir : getenv ("HOME"))
-#define UUCPFIL (uucplfil && *uucplfil ? uucplfil : getusername ())
+#define MAILDIR (mmdfldir && *mmdfldir ? mmdfldir : getenv("HOME"))
+#define MAILFIL (mmdflfil && *mmdflfil ? mmdflfil : getusername())
+#define UUCPDIR (uucpldir && *uucpldir ? uucpldir : getenv("HOME"))
+#define UUCPFIL (uucplfil && *uucplfil ? uucplfil : getusername())
char *getusername(void);
char *getfullname(void);
extern char *mmdlm1;
extern char *mmdlm2;
-#define isdlm1(s) (strcmp (s, mmdlm1) == 0)
-#define isdlm2(s) (strcmp (s, mmdlm2) == 0)
+#define isdlm1(s) (strcmp(s, mmdlm1) == 0)
+#define isdlm2(s) (strcmp(s, mmdlm2) == 0)
/*
** Read mts.conf file
*/
-void mts_init (char *);
+void mts_init(char *);
/*
** Global MailDelivery File
#include <signal.h>
#define bcmp(b1,b2,length) memcmp(b1, b2, length)
-#define bcopy(b1,b2,length) memcpy (b2, b1, length)
-#define bcpy(b1,b2,length) memcmp (b1, b2, length)
-#define bzero(b,length) memset (b, 0, length)
+#define bcopy(b1,b2,length) memcpy(b2, b1, length)
+#define bcpy(b1,b2,length) memcmp(b1, b2, length)
+#define bzero(b,length) memset(b, 0, length)
#ifdef HAVE_KILLPG
# define KILLPG(pgrp,sig) killpg(pgrp,sig);
/*
** prototypes
*/
-int pcompile (char **, char *);
-int pmatches (FILE *, int, long, long);
+int pcompile(char **, char *);
+int pmatches(FILE *, int, long, long);
** missing system prototypes
*/
#ifndef HAVE_TERMCAP_H
-extern int tgetent (char *bp, char *name);
-extern int tgetnum (char *id);
-extern int tgetflag (char *id);
-extern char *tgetstr (char *id, char **area);
-extern char *tgoto (char *cm, int destcol, int destline);
-extern int tputs (char *cp, int affcnt, int (*outc) (int));
+extern int tgetent(char *bp, char *name);
+extern int tgetnum(char *id);
+extern int tgetflag(char *id);
+extern char *tgetstr(char *id, char **area);
+extern char *tgoto(char *cm, int destcol, int destline);
+extern int tputs(char *cp, int affcnt, int (*outc) (int));
#endif
/*
/*
** prototypes from the nmh subroutine library
*/
-void adios (char *, char *, ...) NORETURN;
-void admonish (char *, char *, ...);
-void advertise (char *, char *, char *, va_list);
-void advise (char *, char *, ...);
-void ambigsw (char *, struct swit *);
+void adios(char *, char *, ...) NORETURN;
+void admonish(char *, char *, ...);
+void advertise(char *, char *, char *, va_list);
+void advise(char *, char *, ...);
+void ambigsw(char *, struct swit *);
int atooi(char *);
-char **brkstring (char *, char *, char *);
-int check_charset (char *, int);
+char **brkstring(char *, char *, char *);
+int check_charset(char *, int);
void closefds(int);
-char *concat (char *, ...);
-int context_del (char *);
-char *context_find (char *);
-int context_foil (char *);
-void context_read (void);
-void context_replace (char *, char *);
-void context_save (void);
-char *copy (char *, char *);
-char **copyip (char **, char **, int);
-void cpydata (int, int, char *, char *);
-void cpydgst (int, int, char *, char *);
-int decode_rfc2047 (char *, char *, size_t);
-void discard (FILE *);
-int default_done (int);
+char *concat(char *, ...);
+int context_del(char *);
+char *context_find(char *);
+int context_foil(char *);
+void context_read(void);
+void context_replace(char *, char *);
+void context_save(void);
+char *copy(char *, char *);
+char **copyip(char **, char **, int);
+void cpydata(int, int, char *, char *);
+void cpydgst(int, int, char *, char *);
+int decode_rfc2047(char *, char *, size_t);
+void discard(FILE *);
+int default_done(int);
int ext_hook(char *, char *, char *);
-int fdcompare (int, int);
-int folder_addmsg (struct msgs **, char *, int, int, int, int, char *);
-int folder_delmsgs (struct msgs *, int, int);
-void folder_free (struct msgs *);
-int folder_pack (struct msgs **, int);
-struct msgs *folder_read (char *);
-struct msgs *folder_realloc (struct msgs *, int, int);
-int gans (char *, struct swit *);
-char **getans (char *, struct swit *);
-int getanswer (char *);
-char **getarguments (char *, int, char **, int);
+int fdcompare(int, int);
+int folder_addmsg(struct msgs **, char *, int, int, int, int, char *);
+int folder_delmsgs(struct msgs *, int, int);
+void folder_free(struct msgs *);
+int folder_pack(struct msgs **, int);
+struct msgs *folder_read(char *);
+struct msgs *folder_realloc(struct msgs *, int, int);
+int gans(char *, struct swit *);
+char **getans(char *, struct swit *);
+int getanswer(char *);
+char **getarguments(char *, int, char **, int);
char *get_charset();
-char *getcpy (char *);
+char *getcpy(char *);
char *getfolder(int);
int lkclose(int, char*);
int lkfclose(FILE *, char *);
FILE *lkfopen(char *, char *);
int lkopen(char *, int, mode_t);
-int m_atoi (char *);
-char *m_backup (char *);
-int m_convert (struct msgs *, char *);
-char *m_draft (char *);
-int m_getfld (int, unsigned char *, unsigned char *, int, FILE *);
-int m_gmprot (void);
-char *m_maildir (char *);
-char *m_mailpath (char *);
-char *m_name (int);
-int m_putenv (char *, char *);
+int m_atoi(char *);
+char *m_backup(char *);
+int m_convert(struct msgs *, char *);
+char *m_draft(char *);
+int m_getfld(int, unsigned char *, unsigned char *, int, FILE *);
+int m_gmprot(void);
+char *m_maildir(char *);
+char *m_mailpath(char *);
+char *m_name(int);
+int m_putenv(char *, char *);
char *m_mktemp(const char *, int *, FILE **);
char *m_mktemp2(const char *, const char *, int *, FILE **);
void m_unknown(FILE *);
-int makedir (char *);
+int makedir(char *);
char *nmh_getpass(const char *);
char *norm_charmap(char *);
-char *new_fs (char *, char *, char *);
+char *new_fs(char *, char *, char *);
char *path(char *, int);
int peekc(FILE *ib);
-int pidwait (pid_t, int);
-int pidstatus (int, FILE *, char *);
+int pidwait(pid_t, int);
+int pidstatus(int, FILE *, char *);
char *pluspath(char *);
-void print_help (char *, struct swit *, int);
-void print_sw (char *, struct swit *, char *, FILE *);
-void print_version (char *);
-void push (void);
-char *pwd (void);
+void print_help(char *, struct swit *, int);
+void print_sw(char *, struct swit *, char *, FILE *);
+void print_version(char *);
+void push(void);
+char *pwd(void);
char *r1bindex(char *, int);
-void readconfig (struct node **, FILE *, char *, int);
-int refile (char **, char *);
+void readconfig(struct node **, FILE *, char *, int);
+int refile(char **, char *);
void ruserpass(char *, char **, char **);
-int seq_addmsg (struct msgs *, char *, int, int, int);
-int seq_addsel (struct msgs *, char *, int, int);
-char *seq_bits (struct msgs *);
-int seq_delmsg (struct msgs *, char *, int);
-int seq_delsel (struct msgs *, char *, int, int);
-int seq_getnum (struct msgs *, char *);
-char *seq_list (struct msgs *, char *);
-int seq_nameok (unsigned char *);
-void seq_print (struct msgs *, char *);
-void seq_printall (struct msgs *);
-void seq_read (struct msgs *);
-void seq_save (struct msgs *);
-void seq_setcur (struct msgs *, int);
-void seq_setprev (struct msgs *);
-void seq_setunseen (struct msgs *, int);
-int showfile (char **, char *);
+int seq_addmsg(struct msgs *, char *, int, int, int);
+int seq_addsel(struct msgs *, char *, int, int);
+char *seq_bits(struct msgs *);
+int seq_delmsg(struct msgs *, char *, int);
+int seq_delsel(struct msgs *, char *, int, int);
+int seq_getnum(struct msgs *, char *);
+char *seq_list(struct msgs *, char *);
+int seq_nameok(unsigned char *);
+void seq_print(struct msgs *, char *);
+void seq_printall(struct msgs *);
+void seq_read(struct msgs *);
+void seq_save(struct msgs *);
+void seq_setcur(struct msgs *, int);
+void seq_setprev(struct msgs *);
+void seq_setunseen(struct msgs *, int);
+int showfile(char **, char *);
int smatch(char *, struct swit *);
-char *snprintb (char *, size_t, unsigned, char *);
-int ssequal (char *, char *);
-int stringdex (char *, char *);
-char *trimcpy (unsigned char *);
-int unputenv (char *);
-int uprf (char *, char *);
-int vfgets (FILE *, char **);
-char *write_charset_8bit (void);
+char *snprintb(char *, size_t, unsigned, char *);
+int ssequal(char *, char *);
+int stringdex(char *, char *);
+char *trimcpy(unsigned char *);
+int unputenv(char *);
+int uprf(char *, char *);
+int vfgets(FILE *, char **);
+char *write_charset_8bit(void);
#ifdef RPATHS
-int get_returnpath (char *, int, char *, int);
+int get_returnpath(char *, int, char *, int);
#endif
/*
** 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);
+int snprintf(char *, size_t, const char *, ...);
+int vsnprintf(char *, size_t, const char *, va_list);
#endif
-int mh_strcasecmp (const char *s1, const char *s2);
-int strncasecmp (const char *s1, const char *s2, size_t n);
+int mh_strcasecmp(const char *s1, const char *s2);
+int strncasecmp(const char *s1, const char *s2, size_t n);
/*
/*
** prototypes for some routines in uip
*/
-int annotate (char *, char *, char *, int, int, int, int);
+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 sendsbr (char **, int, char *, struct stat *, int, char *, int);
-int what_now (char *, int, int, char *, char *,
- int, struct msgs *, char *, int, char *);
+int distout(char *, char *, char *);
+void replout(FILE *, char *, char *, struct msgs *, int, 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 *);
/*
** prototypes
*/
-int scan (FILE *, int, int, char *, int, int, int, char *, long, int);
+int scan(FILE *, int, int, char *, int, int, int, char *, long, int);
/*
** prototypes
*/
-int SIGPROCMASK (int, const sigset_t *, sigset_t *);
-SIGNAL_HANDLER SIGNAL (int, SIGNAL_HANDLER);
-SIGNAL_HANDLER SIGNAL2 (int, SIGNAL_HANDLER);
+int SIGPROCMASK(int, const sigset_t *, sigset_t *);
+SIGNAL_HANDLER SIGNAL(int, SIGNAL_HANDLER);
+SIGNAL_HANDLER SIGNAL2(int, SIGNAL_HANDLER);
#define TW_YES 0x0040 /* yes, found */
#define TW_NO 0x0000 /* no, not found */
-#define dtwszone(tw) dtimezone (tw->tw_zone, tw->tw_flags)
+#define dtwszone(tw) dtimezone(tw->tw_zone, tw->tw_flags)
extern char *tw_dotw[];
extern char *tw_ldotw[];
/*
** prototypes
*/
-char *dtime (time_t *, int);
-char *dtimenow (int);
-char *dctime (struct tws *);
-struct tws *dlocaltimenow (void);
-struct tws *dlocaltime (time_t *);
-struct tws *dgmtime (time_t *);
-char *dasctime (struct tws *, int);
-char *dtimezone (int, int);
-void twscopy (struct tws *, struct tws *);
-int twsort (struct tws *, struct tws *);
-time_t dmktime (struct tws *);
-void set_dotw (struct tws *);
+char *dtime(time_t *, int);
+char *dtimenow(int);
+char *dctime(struct tws *);
+struct tws *dlocaltimenow(void);
+struct tws *dlocaltime(time_t *);
+struct tws *dgmtime(time_t *);
+char *dasctime(struct tws *, int);
+char *dtimezone(int, int);
+void twscopy(struct tws *, struct tws *);
+int twsort(struct tws *, struct tws *);
+time_t dmktime(struct tws *);
+void set_dotw(struct tws *);
-struct tws *dparsetime (char *);
+struct tws *dparsetime(char *);
/*
** external prototypes
*/
-char *getusername (void);
+char *getusername(void);
char *
-getname (char *addrs)
+getname(char *addrs)
{
struct adrx *ap;
pers = mbox = host = route = grp = note = NULL;
err[0] = '\0';
- if ((ap = getadrx (addrs ? addrs : "")) == NULL)
+ if ((ap = getadrx(addrs ? addrs : "")) == NULL)
return NULL;
- strncpy (adr, ap->text, sizeof(adr));
+ strncpy(adr, ap->text, sizeof(adr));
pers = ap->pers;
mbox = ap->mbox;
host = ap->host;
ingrp = ap->ingrp;
note = ap->note;
if (ap->err && *ap->err)
- strncpy (err, ap->err, sizeof(err));
+ strncpy(err, ap->err, sizeof(err));
return adr;
}
struct mailname *
-getm (char *str, char *dfhost, int dftype, int wanthost, char *eresult)
+getm(char *str, char *dfhost, int dftype, int wanthost, char *eresult)
{
char *pp;
struct mailname *mp;
if (err[0]) {
if (eresult)
- strcpy (eresult, err);
+ strcpy(eresult, err);
else
if (wanthost == AD_HOST)
- admonish (NULL, "bad address '%s' - %s", str, err);
+ admonish(NULL, "bad address '%s' - %s", str, err);
return NULL;
}
if (pers == NULL && mbox == NULL && host == NULL && route == NULL
&& grp == NULL) {
if (eresult)
- strcpy (eresult, "null address");
+ strcpy(eresult, "null address");
else
if (wanthost == AD_HOST)
- admonish (NULL, "null address '%s'", str);
+ admonish(NULL, "null address '%s'", str);
return NULL;
}
if (mbox == NULL && grp == NULL) {
if (eresult)
- strcpy (eresult, "no mailbox in address");
+ strcpy(eresult, "no mailbox in address");
else if (wanthost == AD_HOST)
- admonish (NULL, "no mailbox in address '%s'", str);
+ admonish(NULL, "no mailbox in address '%s'", str);
return NULL;
}
if (dfhost == NULL) {
- dfhost = LocalName ();
+ dfhost = LocalName();
dftype = LOCALHOST;
}
- mp = (struct mailname *) calloc ((size_t) 1, sizeof(*mp));
+ mp = (struct mailname *) calloc((size_t) 1, sizeof(*mp));
if (mp == NULL) {
if (eresult)
- strcpy (eresult, "insufficient memory to represent address");
+ strcpy(eresult, "insufficient memory to represent address");
else if (wanthost == AD_HOST)
- adios (NULL, "insufficient memory to represent address");
+ adios(NULL, "insufficient memory to represent address");
return NULL;
}
mp->m_next = NULL;
- mp->m_text = getcpy (str);
+ mp->m_text = getcpy(str);
if (pers)
- mp->m_pers = getcpy (pers);
+ mp->m_pers = getcpy(pers);
if (mbox == NULL) {
mp->m_type = BADHOST;
mp->m_nohost = 1;
mp->m_ingrp = ingrp;
- mp->m_gname = getcpy (grp);
+ mp->m_gname = getcpy(grp);
if (note)
- mp->m_note = getcpy (note);
+ mp->m_note = getcpy(note);
return mp;
}
if (host) {
- mp->m_mbox = getcpy (mbox);
- mp->m_host = getcpy (host);
+ mp->m_mbox = getcpy(mbox);
+ mp->m_host = getcpy(host);
} else {
if ((pp = strchr(mbox, '!'))) {
*pp++ = '\0';
- mp->m_mbox = getcpy (pp);
- mp->m_host = getcpy (mbox);
+ mp->m_mbox = getcpy(pp);
+ mp->m_host = getcpy(mbox);
mp->m_type = UUCPHOST;
} else {
mp->m_nohost = 1;
- mp->m_mbox = getcpy (mbox);
+ mp->m_mbox = getcpy(mbox);
#ifdef DUMB
if (route == NULL && dftype == LOCALHOST) {
mp->m_host = NULL;
} else
#endif /* DUMB */
{
- mp->m_host = route ? NULL : getcpy (dfhost);
+ mp->m_host = route ? NULL : getcpy(dfhost);
mp->m_type = route ? NETHOST : dftype;
}
}
}
if (wanthost == AD_NHST)
- mp->m_type = !mh_strcasecmp (LocalName (), mp->m_host)
+ mp->m_type = !mh_strcasecmp(LocalName(), mp->m_host)
? LOCALHOST : NETHOST;
#ifdef DUMB
else
- mp->m_type = mh_strcasecmp (LocalName(), mp->m_host) ? NETHOST : LOCALHOST;
+ mp->m_type = mh_strcasecmp(LocalName(), mp->m_host) ? NETHOST : LOCALHOST;
#else /* not DUMB */
else
- if (pp = OfficialName (mp->m_host)) {
+ if (pp = OfficialName(mp->m_host)) {
got_real_host: ;
free (mp->m_host);
- mp->m_host = getcpy (pp);
- mp->m_type = mh_strcasecmp (LocalName(), mp->m_host) ? NETHOST : LOCALHOST;
+ mp->m_host = getcpy(pp);
+ mp->m_type = mh_strcasecmp(LocalName(), mp->m_host) ? NETHOST : LOCALHOST;
} else {
if (dp = strchr(mp->m_host, '.')) {
*dp = NULL;
- if (pp = OfficialName (mp->m_host))
+ if (pp = OfficialName(mp->m_host))
goto got_real_host;
*dp = '.';
}
got_host: ;
if (route)
- mp->m_path = getcpy (route);
+ mp->m_path = getcpy(route);
mp->m_ingrp = ingrp;
if (grp)
- mp->m_gname = getcpy (grp);
+ mp->m_gname = getcpy(grp);
if (note)
- mp->m_note = getcpy (note);
+ mp->m_note = getcpy(note);
return mp;
}
void
-mnfree (struct mailname *mp)
+mnfree(struct mailname *mp)
{
if (!mp)
return;
if (mp->m_text)
- free (mp->m_text);
+ free(mp->m_text);
if (mp->m_pers)
- free (mp->m_pers);
+ free(mp->m_pers);
if (mp->m_mbox)
- free (mp->m_mbox);
+ free(mp->m_mbox);
if (mp->m_host)
- free (mp->m_host);
+ free(mp->m_host);
if (mp->m_path)
- free (mp->m_path);
+ free(mp->m_path);
if (mp->m_gname)
- free (mp->m_gname);
+ free(mp->m_gname);
if (mp->m_note)
- free (mp->m_note);
+ free(mp->m_note);
- free ((char *) mp);
+ free((char *) mp);
}
#define empty(s) ((s) ? (s) : "")
char *
-adrformat (struct mailname *mp)
+adrformat(struct mailname *mp)
{
static char addr[BUFSIZ];
static char buffer[BUFSIZ];
#ifdef DUMB
if (mp->m_nohost)
- strncpy (addr, mp->m_mbox ? mp->m_mbox : "", sizeof(addr));
+ strncpy(addr, mp->m_mbox ? mp->m_mbox : "", sizeof(addr));
else
#endif /* DUMB */
#ifndef BANG
if (mp->m_type != UUCPHOST)
- snprintf (addr, sizeof(addr), mp->m_host ? "%s%s@%s" : "%s%s",
+ snprintf(addr, sizeof(addr), mp->m_host ? "%s%s@%s" : "%s%s",
empty(mp->m_path), empty(mp->m_mbox), mp->m_host);
else
#endif /* not BANG */
- snprintf (addr, sizeof(addr), "%s!%s", mp->m_host, mp->m_mbox);
+ snprintf(addr, sizeof(addr), "%s!%s", mp->m_host, mp->m_mbox);
if (mp->m_pers || mp->m_path) {
if (mp->m_note)
- snprintf (buffer, sizeof(buffer), "%s %s <%s>",
- legal_person (mp->m_pers ? mp->m_pers : mp->m_mbox),
+ snprintf(buffer, sizeof(buffer), "%s %s <%s>",
+ legal_person(mp->m_pers ? mp->m_pers : mp->m_mbox),
mp->m_note, addr);
else
- snprintf (buffer, sizeof(buffer), "%s <%s>",
- legal_person (mp->m_pers ? mp->m_pers : mp->m_mbox),
+ snprintf(buffer, sizeof(buffer), "%s <%s>",
+ legal_person(mp->m_pers ? mp->m_pers : mp->m_mbox),
addr);
} else if (mp->m_note)
- snprintf (buffer, sizeof(buffer), "%s %s", addr, mp->m_note);
+ snprintf(buffer, sizeof(buffer), "%s %s", addr, mp->m_note);
else
- strncpy (buffer, addr, sizeof(buffer));
+ strncpy(buffer, addr, sizeof(buffer));
return buffer;
}
*/
int
-ismymbox (struct mailname *np)
+ismymbox(struct mailname *np)
{
int oops;
register int len, i;
*/
if (am == NULL) {
mq.m_next = NULL;
- mq.m_mbox = getusername ();
- if ((am = context_find ("alternate-mailboxes")) == NULL)
+ mq.m_mbox = getusername();
+ if ((am = context_find("alternate-mailboxes")) == NULL)
am = getusername();
else {
mp = &mq;
oops = 0;
- while ((cp = getname (am))) {
- if ((mp->m_next = getm (cp, NULL, 0, AD_NAME, NULL)) == NULL) {
- admonish (NULL, "illegal address: %s", cp);
+ while ((cp = getname(am))) {
+ if ((mp->m_next = getm(cp, NULL, 0, AD_NAME, NULL)) == NULL) {
+ admonish(NULL, "illegal address: %s", cp);
oops++;
} else {
mp = mp->m_next;
mp->m_type |= W_MBEG;
mp->m_mbox++;
}
- if (*(cp = mp->m_mbox + strlen (mp->m_mbox) - 1) == '*') {
+ if (*(cp = mp->m_mbox + strlen(mp->m_mbox) - 1) == '*') {
mp->m_type |= W_MEND;
*cp = '\0';
}
mp->m_type |= W_HBEG;
mp->m_host++;
}
- if (*(cp = mp->m_host + strlen (mp->m_host) - 1) == '*') {
+ if (*(cp = mp->m_host + strlen(mp->m_host) - 1) == '*') {
mp->m_type |= W_HEND;
*cp = '\0';
}
}
- if ((cp = getenv ("MHWDEBUG")) && *cp)
- fprintf (stderr, "mbox=\"%s\" host=\"%s\" %s\n",
+ if ((cp = getenv("MHWDEBUG")) && *cp)
+ fprintf(stderr, "mbox=\"%s\" host=\"%s\" %s\n",
mp->m_mbox, mp->m_host,
- snprintb (buffer, sizeof(buffer), (unsigned) mp->m_type, WBITS));
+ snprintb(buffer, sizeof(buffer), (unsigned) mp->m_type, WBITS));
}
}
if (oops)
- advise (NULL, "please fix the %s: entry in your %s file",
+ advise(NULL, "please fix the %s: entry in your %s file",
"alternate-mailboxes", mh_profile);
}
}
switch (np->m_type) {
case NETHOST:
- len = strlen (cp = LocalName ());
- if (!uprf (np->m_host, cp) || np->m_host[len] != '.')
+ len = strlen(cp = LocalName());
+ if (!uprf(np->m_host, cp) || np->m_host[len] != '.')
break;
goto local_test;
case UUCPHOST:
- if (mh_strcasecmp (np->m_host, SystemName()))
+ if (mh_strcasecmp(np->m_host, SystemName()))
break; /* fall */
case LOCALHOST:
local_test: ;
- if (!mh_strcasecmp (np->m_mbox, mq.m_mbox))
+ if (!mh_strcasecmp(np->m_mbox, mq.m_mbox))
return 1;
break;
mp = mp->m_next;
if (!np->m_mbox)
continue;
- if ((len = strlen (cp = np->m_mbox))
- < (i = strlen (pp = mp->m_mbox)))
+ if ((len = strlen(cp = np->m_mbox))
+ < (i = strlen(pp = mp->m_mbox)))
continue;
switch (mp->m_type & W_MBOX) {
case W_NIL:
- if (mh_strcasecmp (cp, pp))
+ if (mh_strcasecmp(cp, pp))
continue;
break;
case W_MBEG:
- if (mh_strcasecmp (cp + len - i, pp))
+ if (mh_strcasecmp(cp + len - i, pp))
continue;
break;
case W_MEND:
- if (!uprf (cp, pp))
+ if (!uprf(cp, pp))
continue;
break;
case W_MBEG | W_MEND:
- if (stringdex (pp, cp) < 0)
+ if (stringdex(pp, cp) < 0)
continue;
break;
}
return 1;
if (np->m_host == NULL)
continue;
- if ((len = strlen (cp = np->m_host))
- < (i = strlen (pp = mp->m_host)))
+ if ((len = strlen(cp = np->m_host))
+ < (i = strlen(pp = mp->m_host)))
continue;
switch (mp->m_type & W_HOST) {
case W_NIL:
- if (mh_strcasecmp (cp, pp))
+ if (mh_strcasecmp(cp, pp))
continue;
break;
case W_HBEG:
continue;
break;
case W_HEND:
- if (!uprf (cp, pp))
+ if (!uprf(cp, pp))
continue;
break;
case W_HBEG | W_HEND:
- if (stringdex (pp, cp) < 0)
+ if (stringdex(pp, cp) < 0)
continue;
break;
}
char *
-OfficialName (char *name)
+OfficialName(char *name)
{
unsigned char *p;
char *q, site[BUFSIZ];
static char buffer[BUFSIZ];
for (p = name, q = site; *p && (q - site < sizeof(site) - 1); p++, q++)
- *q = isupper (*p) ? tolower (*p) : *p;
+ *q = isupper(*p) ? tolower(*p) : *p;
*q = '\0';
q = site;
- if (!mh_strcasecmp (LocalName(), site))
+ if (!mh_strcasecmp(LocalName(), site))
return LocalName();
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
if (getaddrinfo(q, NULL, &hints, &res) == 0) {
- strncpy (buffer, res->ai_canonname, sizeof(buffer));
+ strncpy(buffer, res->ai_canonname, sizeof(buffer));
buffer[sizeof(buffer) - 1] = '\0';
freeaddrinfo(res);
return buffer;
}
- strncpy (buffer, site, sizeof(buffer));
+ strncpy(buffer, site, sizeof(buffer));
return buffer;
}
void
-ambigsw (char *arg, struct swit *swp)
+ambigsw(char *arg, struct swit *swp)
{
- advise (NULL, "-%s ambiguous. It matches", arg);
- print_sw (arg, swp, "-", stderr);
+ advise(NULL, "-%s ambiguous. It matches", arg);
+ print_sw(arg, swp, "-", stderr);
}
/*
** static prototypes
*/
-static int brkany (char, char *);
+static int brkany(char, char *);
char **
-brkstring (char *str, char *brksep, char *brkterm)
+brkstring(char *str, char *brksep, char *brkterm)
{
int i;
char c, *s;
/* allocate initial space for pointers on first call */
if (!broken) {
len = NUMBROKEN;
- broken = (char **) mh_xmalloc ((size_t) (len * sizeof(*broken)));
+ broken = (char **) mh_xmalloc((size_t) (len * sizeof(*broken)));
}
/*
/* enlarge pointer array, if necessary */
if (i >= len) {
len += NUMBROKEN;
- broken = mh_xrealloc (broken, (size_t) (len * sizeof(*broken)));
+ broken = mh_xrealloc(broken, (size_t) (len * sizeof(*broken)));
}
- while (brkany (c = *s, brksep))
+ while (brkany(c = *s, brksep))
*s++ = '\0';
/*
** we are either at the end of the string, or the
** terminator found has been found, so finish up.
*/
- if (!c || brkany (c, brkterm)) {
+ if (!c || brkany(c, brkterm)) {
*s = '\0';
broken[i] = NULL;
return broken;
/* set next start addr */
broken[i] = s;
- while ((c = *++s) && !brkany (c, brksep) && !brkany (c, brkterm))
+ while ((c = *++s) && !brkany(c, brksep) && !brkany(c, brkterm))
; /* empty body */
}
*/
static int
-brkany (char c, char *str)
+brkany(char c, char *str)
{
char *s;
** Get the current character set
*/
char *
-get_charset ()
+get_charset()
{
- char *charset = getenv ("MM_CHARSET");
+ char *charset = getenv("MM_CHARSET");
#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
if (!charset)
- charset = norm_charmap(nl_langinfo (CODESET));
+ charset = norm_charmap(nl_langinfo(CODESET));
#endif
return charset;
}
*/
int
-check_charset (char *str, int len)
+check_charset(char *str, int len)
{
static char *mm_charset = NULL;
static char *alt_charset = NULL;
/* Cache the name of our default character set */
if (!mm_charset) {
- if (!(mm_charset = get_charset ()))
+ if (!(mm_charset = get_charset()))
mm_charset = "US-ASCII";
- mm_len = strlen (mm_charset);
+ mm_len = strlen(mm_charset);
/* US-ASCII is a subset of the ISO-8859-X and UTF-8 character sets */
if (!strncasecmp("ISO-8859-", mm_charset, 9) ||
!mh_strcasecmp("UTF-8", mm_charset)) {
alt_charset = "US-ASCII";
- alt_len = strlen (alt_charset);
+ alt_len = strlen(alt_charset);
}
}
** using for 8bit text.
*/
char *
-write_charset_8bit (void)
+write_charset_8bit(void)
{
static char *mm_charset = NULL;
** Cache the name of the character set to
** use for 8bit text.
*/
- if (!mm_charset && !(mm_charset = get_charset ()))
+ if (!mm_charset && !(mm_charset = get_charset()))
mm_charset = "x-unknown";
return mm_charset;
int nbits = OPEN_MAX;
for (; i < nbits; i++)
- close (i);
+ close(i);
}
char *
-concat (char *s1, ...)
+concat(char *s1, ...)
{
char *cp, *dp, *sp;
size_t len;
va_list list;
- len = strlen (s1) + 1;
+ len = strlen(s1) + 1;
va_start(list, s1);
while ((cp = va_arg(list, char *)))
- len += strlen (cp);
+ len += strlen(cp);
va_end(list);
dp = sp = mh_xmalloc(len);
sp = copy(s1, sp);
va_start(list, s1);
- while ((cp = va_arg (list, char *)))
+ while ((cp = va_arg(list, char *)))
sp = copy(cp, sp);
va_end(list);
*/
int
-context_del (char *key)
+context_del(char *key)
{
register struct node *np, *pp;
for (np = m_defs, pp = NULL; np; pp = np, np = np->n_next) {
- if (!mh_strcasecmp (np->n_name, key)) {
+ if (!mh_strcasecmp(np->n_name, key)) {
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;
else
m_defs = np->n_next;
- free (np->n_name);
+ free(np->n_name);
if (np->n_field)
- free (np->n_field);
- free ((char *) np);
+ free(np->n_field);
+ free((char *) np);
ctxflags |= CTXMOD;
return 0;
}
char *
-context_find (char *str)
+context_find(char *str)
{
struct node *np;
for (np = m_defs; np; np = np->n_next)
- if (!mh_strcasecmp (np->n_name, str))
+ if (!mh_strcasecmp(np->n_name, str))
return (np->n_field);
return NULL;
*/
int
-context_foil (char *path)
+context_foil(char *path)
{
register struct node *np;
** If path is given, create a minimal profile/context list
*/
if (path) {
- m_defs = (struct node *) mh_xmalloc (sizeof(*np));
+ m_defs = (struct node *) mh_xmalloc(sizeof(*np));
np = m_defs;
- if (!(np->n_name = strdup ("Path"))) {
- advise (NULL, "strdup failed");
+ if (!(np->n_name = strdup("Path"))) {
+ advise(NULL, "strdup failed");
return -1;
}
- if (!(np->n_field = strdup (path))) {
- advise (NULL, "strdup failed");
+ if (!(np->n_field = strdup(path))) {
+ advise(NULL, "strdup failed");
return -1;
}
np->n_context = 0;
np->n_next = NULL;
- if (mypath == NULL && (mypath = getenv ("HOME")) != NULL)
- if (!(mypath = strdup (mypath))) {
- advise (NULL, "strdup failed");
+ if (mypath == NULL && (mypath = getenv("HOME")) != NULL)
+ if (!(mypath = strdup(mypath))) {
+ advise(NULL, "strdup failed");
return -1;
}
}
#include <pwd.h> /* structure for getpwuid() results */
void
-context_read (void)
+context_read(void)
{
char buf[BUFSIZ]; /* path name buffer */
char *cp; /* miscellaneous pointer */
cp = mh_profile;
}
- readconfig (&m_defs, ib, cp, 0);
- fclose (ib);
+ readconfig(&m_defs, ib, cp, 0);
+ fclose(ib);
/*
** Find the user's nmh directory, which is specified by the "path"
** one rooted in the home directory.
*/
- if ((cp = context_find ("path")) == (char *)0)
+ if ((cp = context_find("path")) == (char *)0)
adios(NULL, "Your %s file does not contain a path entry.", defpath);
if (*cp == '\0')
adios(NULL, "Your `%s' profile file does not contain a valid path entry.", defpath);
if (*cp != '/')
- (void)snprintf (nd = buf, sizeof(buf), "%s/%s", mypath, cp);
+ (void)snprintf(nd = buf, sizeof(buf), "%s/%s", mypath, cp);
else
nd = cp;
if (stat(nd, &st) == -1) {
if (errno != ENOENT)
- adios (nd, "error opening");
- cp = concat ("Your MH-directory \"", nd, "\" doesn't exist; Create it? ", NULL);
+ adios(nd, "error opening");
+ cp = concat("Your MH-directory \"", nd, "\" doesn't exist; Create it? ", NULL);
if (!getanswer(cp))
- adios (NULL, "unable to access MH-directory \"%s\"", nd);
- free (cp);
- if (!makedir (nd))
- adios (NULL, "unable to create %s", nd);
+ adios(NULL, "unable to access MH-directory \"%s\"", nd);
+ free(cp);
+ if (!makedir(nd))
+ adios(NULL, "unable to create %s", nd);
} else if ((st.st_mode & S_IFDIR) == 0)
- adios ((char *)0, "`%s' is not a directory", nd);
+ adios((char *)0, "`%s' is not a directory", nd);
/*
** Open and read user's context file. The name of the context
** environment variable.
*/
- if ((cp = getenv ("MHCONTEXT")) == (char *)0 || *cp == '\0')
+ if ((cp = getenv("MHCONTEXT")) == (char *)0 || *cp == '\0')
cp = context;
/*
return;
}
- ctxpath = getcpy (m_maildir (cp));
+ ctxpath = getcpy(m_maildir(cp));
- if ((ib = lkfopen (ctxpath, "r"))) {
- readconfig ((struct node **) 0, ib, cp, 1);
- lkfclose (ib, ctxpath);
+ if ((ib = lkfopen(ctxpath, "r"))) {
+ readconfig((struct node **) 0, ib, cp, 1);
+ lkfclose(ib, ctxpath);
}
return;
void
-context_replace (char *key, char *value)
+context_replace(char *key, char *value)
{
register struct node *np;
** If list is emtpy, allocate head of profile/context list.
*/
if (!m_defs) {
- m_defs = (struct node *) mh_xmalloc (sizeof(*np));
+ m_defs = (struct node *) mh_xmalloc(sizeof(*np));
np = m_defs;
- np->n_name = getcpy (key);
- np->n_field = getcpy (value);
+ np->n_name = getcpy(key);
+ np->n_field = getcpy(value);
np->n_context = 1;
np->n_next = NULL;
ctxflags |= CTXMOD;
** 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)) {
+ if (!mh_strcasecmp(np->n_name, key)) {
+ if (strcmp(value, np->n_field)) {
if (!np->n_context)
- admonish (NULL, "bug: context_replace(key=\"%s\",value=\"%s\")", key, value);
+ admonish(NULL, "bug: context_replace(key=\"%s\",value=\"%s\")", key, value);
if (np->n_field)
- free (np->n_field);
- np->n_field = getcpy (value);
+ free(np->n_field);
+ np->n_field = getcpy(value);
ctxflags |= CTXMOD;
}
return;
/*
** Else add this new entry at the end
*/
- np->n_next = (struct node *) mh_xmalloc (sizeof(*np));
+ np->n_next = (struct node *) mh_xmalloc(sizeof(*np));
np = np->n_next;
- np->n_name = getcpy (key);
- np->n_field = getcpy (value);
+ np->n_name = getcpy(key);
+ np->n_field = getcpy(value);
np->n_context = 1;
np->n_next = NULL;
ctxflags |= CTXMOD;
void
-context_save (void)
+context_save(void)
{
int action;
register struct node *np;
return;
ctxflags &= ~CTXMOD;
- if ((action = m_chkids ()) > 0)
+ if ((action = m_chkids()) > 0)
return; /* child did it for us */
/* block a few signals */
- sigemptyset (&set);
- sigaddset (&set, SIGHUP);
- sigaddset (&set, SIGINT);
- sigaddset (&set, SIGQUIT);
- sigaddset (&set, SIGTERM);
- SIGPROCMASK (SIG_BLOCK, &set, &oset);
-
- if (!(out = lkfopen (ctxpath, "w")))
- adios (ctxpath, "unable to write");
+ sigemptyset(&set);
+ sigaddset(&set, SIGHUP);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGQUIT);
+ sigaddset(&set, SIGTERM);
+ SIGPROCMASK(SIG_BLOCK, &set, &oset);
+
+ if (!(out = lkfopen(ctxpath, "w")))
+ adios(ctxpath, "unable to write");
for (np = m_defs; np; np = np->n_next)
if (np->n_context)
- fprintf (out, "%s: %s\n", np->n_name, np->n_field);
- lkfclose (out, ctxpath);
+ fprintf(out, "%s: %s\n", np->n_name, np->n_field);
+ lkfclose(out, ctxpath);
- SIGPROCMASK (SIG_SETMASK, &oset, &set); /* reset the signal mask */
+ SIGPROCMASK(SIG_SETMASK, &oset, &set); /* reset the signal mask */
if (action == 0)
- _exit (0); /* we are child, time to die */
+ _exit(0); /* we are child, time to die */
}
/*
*/
static int
-m_chkids (void)
+m_chkids(void)
{
int i;
pid_t pid;
- if (getuid () == geteuid ())
+ if (getuid() == geteuid())
return (-1);
- for (i = 0; (pid = fork ()) == -1 && i < 5; i++)
- sleep (5);
+ for (i = 0; (pid = fork()) == -1 && i < 5; i++)
+ sleep(5);
switch (pid) {
case -1:
break;
case 0:
- setgid (getgid ());
- setuid (getuid ());
+ setgid(getgid());
+ setuid(getuid());
break;
default:
- pidwait (pid, -1);
+ pidwait(pid, -1);
break;
}
char **
-copyip (char **p, char **q, int len_q)
+copyip(char **p, char **q, int len_q)
{
while (*p && --len_q > 0)
*q++ = *p++;
#include <h/mh.h>
void
-cpydata (int in, int out, char *ifile, char *ofile)
+cpydata(int in, int out, char *ifile, char *ofile)
{
int i;
char buffer[BUFSIZ];
#define S2 1
#define output(c) if (bp >= dp) {flush(); *bp++ = c;} else *bp++ = c
-#define flush() if ((j = bp - outbuf) && write (out, outbuf, j) != j) \
- adios (ofile, "error writing"); \
+#define flush() if ((j = bp - outbuf) && write(out, outbuf, j) != j) \
+ adios(ofile, "error writing"); \
else \
bp = outbuf
void
-cpydgst (int in, int out, char *ifile, char *ofile)
+cpydgst(int in, int out, char *ifile, char *ofile)
{
register int i, j, state;
register char *cp, *ep;
char buffer[BUFSIZ], outbuf[BUFSIZ];
dp = (bp = outbuf) + sizeof outbuf;
- for (state = S1; (i = read (in, buffer, sizeof buffer)) > 0;)
+ for (state = S1; (i = read(in, buffer, sizeof buffer)) > 0;)
for (ep = (cp = buffer) + i; cp < ep; cp++) {
if (*cp == '\0')
continue;
switch (state) {
case S1:
if (*cp == '-') {
- output ('-');
- output (' ');
+ output('-');
+ output(' ');
}
state = S2; /* fall */
case S2:
- output (*cp);
+ output(*cp);
if (*cp == '\n')
state = S1;
break;
}
if (i == -1)
- adios (ifile, "error reading");
+ adios(ifile, "error reading");
flush();
}
*/
static void
-add_folder (char *fold, struct crawl_context *crawl)
+add_folder(char *fold, struct crawl_context *crawl)
{
register int i, j;
/* if necessary, reallocate the space for folder names */
if (crawl->foldp >= crawl->max) {
crawl->max += CRAWL_NUMFOLDERS;
- crawl->folders = mh_xrealloc (crawl->folders,
+ crawl->folders = mh_xrealloc(crawl->folders,
crawl->max * sizeof(char *));
}
for (i = crawl->start; i < crawl->foldp; i++)
- if (strcmp (fold, crawl->folders[i]) < 0) {
+ if (strcmp(fold, crawl->folders[i]) < 0) {
for (j = crawl->foldp - 1; j >= i; j--)
crawl->folders[j + 1] = crawl->folders[j];
crawl->foldp++;
}
static void
-add_children (char *name, struct crawl_context *crawl)
+add_children(char *name, struct crawl_context *crawl)
{
char *prefix, *child;
struct stat st;
DIR * dd;
int child_is_folder;
- if (!(dd = opendir (name))) {
- admonish (name, "unable to read directory ");
+ if (!(dd = opendir(name))) {
+ admonish(name, "unable to read directory ");
return;
}
- if (strcmp (name, ".") == 0) {
- prefix = getcpy ("");
+ if (strcmp(name, ".") == 0) {
+ prefix = getcpy("");
} else {
- prefix = concat (name, "/", (void *)NULL);
+ prefix = concat(name, "/", (void *)NULL);
}
- while ((dp = readdir (dd))) {
+ while ((dp = readdir(dd))) {
/*
** If the system supports it, try to skip processing of
** children we know are not directories or symlinks.
continue;
}
#endif
- if (!strcmp (dp->d_name, ".") || !strcmp (dp->d_name, "..")) {
+ if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) {
continue;
}
- child = concat (prefix, dp->d_name, (void *)NULL);
+ 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 (child_is_folder == -1) {
- child_is_folder = (stat (child, &st) != -1 && S_ISDIR(st.st_mode));
+ child_is_folder = (stat(child, &st) != -1 && S_ISDIR(st.st_mode));
}
if (child_is_folder) {
/* add_folder saves child in the list, don't free it */
- add_folder (child, crawl);
+ add_folder(child, crawl);
} else {
- free (child);
+ free(child);
}
}
- closedir (dd);
+ closedir(dd);
free(prefix);
}
static void
-crawl_folders_body (struct crawl_context *crawl, char *dir,
+crawl_folders_body(struct crawl_context *crawl, char *dir,
crawl_callback_t *callback, void *baton)
{
int i;
crawl->start = crawl->foldp;
- add_children (dir, crawl);
+ add_children(dir, crawl);
for (i = crawl->start; i < crawl->foldp; i++) {
char *fold = crawl->folders[i];
int crawl_children = 1;
if (callback != NULL) {
- crawl_children = callback (fold, baton);
+ crawl_children = callback(fold, baton);
}
if (crawl_children) {
- crawl_folders_body (crawl, fold, callback, baton);
+ crawl_folders_body(crawl, fold, callback, baton);
}
}
}
void
-crawl_folders (char *dir, crawl_callback_t *callback, void *baton)
+crawl_folders(char *dir, crawl_callback_t *callback, void *baton)
{
- struct crawl_context *crawl = mh_xmalloc (sizeof(*crawl));
+ struct crawl_context *crawl = mh_xmalloc(sizeof(*crawl));
crawl->max = CRAWL_NUMFOLDERS;
crawl->total = crawl->start = crawl->foldp = 0;
- crawl->folders = mh_xmalloc (crawl->max * sizeof(*crawl->folders));
+ crawl->folders = mh_xmalloc(crawl->max * sizeof(*crawl->folders));
- crawl_folders_body (crawl, dir, callback, baton);
+ crawl_folders_body(crawl, dir, callback, baton);
/*
** Note that we "leak" the folder names, on the assumption that the
** caller is using them.
*/
- free (crawl->folders);
- free (crawl);
+ free(crawl->folders);
+ free(crawl);
}
void
-discard (FILE *io)
+discard(FILE *io)
{
#ifndef HAVE_TERMIOS_H
# ifdef HAVE_TERMIO_H
return;
#ifdef HAVE_TERMIOS_H
- tcflush (fileno(io), TCOFLUSH);
+ tcflush(fileno(io), TCOFLUSH);
#else
# ifdef HAVE_TERMIO_H
- if (ioctl (fileno(io), TCGETA, &tio) != -1)
- ioctl (fileno(io), TCSETA, &tio);
+ if (ioctl(fileno(io), TCGETA, &tio) != -1)
+ ioctl(fileno(io), TCSETA, &tio);
# else
- if (ioctl (fileno(io), TIOCGETP, (char *) &tio) != -1)
- ioctl (fileno(io), TIOCSETP, (char *) &tio);
+ if (ioctl(fileno(io), TIOCGETP, (char *) &tio) != -1)
+ ioctl(fileno(io), TIOCSETP, (char *) &tio);
# endif
#endif
#if defined(_FSTDIO) || defined(__DragonFly__)
- fpurge (io);
+ fpurge(io);
#else
# ifdef LINUX_STDIO
io->_IO_write_ptr = io->_IO_write_base;
*/
struct tws *
-dlocaltimenow (void)
+dlocaltimenow(void)
{
time_t clock;
- time (&clock);
- return dlocaltime (&clock);
+ time(&clock);
+ return dlocaltime(&clock);
}
*/
struct tws *
-dlocaltime (time_t *clock)
+dlocaltime(time_t *clock)
{
static struct tws tw;
struct tm *tm;
if (!clock)
return NULL;
- tm = localtime (clock);
+ tm = localtime(clock);
tw.tw_sec = tm->tm_sec;
tw.tw_min = tm->tm_min;
tzset();
tw.tw_zone = -(timezone / 60);
# else
- ftime (&tb);
+ ftime(&tb);
tw.tw_zone = -tb.timezone;
# endif
#endif
*/
struct tws *
-dgmtime (time_t *clock)
+dgmtime(time_t *clock)
{
static struct tws tw;
struct tm *tm;
if (!clock)
return NULL;
- tm = gmtime (clock);
+ tm = gmtime(clock);
tw.tw_sec = tm->tm_sec;
tw.tw_min = tm->tm_min;
*/
char *
-dctime (struct tws *tw)
+dctime(struct tws *tw)
{
static char buffer[26];
if (!tw)
return NULL;
- snprintf (buffer, sizeof(buffer), "%.3s %.3s %02d %02d:%02d:%02d %.4d\n",
+ snprintf(buffer, sizeof(buffer), "%.3s %.3s %02d %02d:%02d:%02d %.4d\n",
tw_dotw[tw->tw_wday], tw_moty[tw->tw_mon], tw->tw_mday,
tw->tw_hour, tw->tw_min, tw->tw_sec,
tw->tw_year < 100 ? tw->tw_year + 1900 : tw->tw_year);
*/
char *
-dtimenow (int alpha_timezone)
+dtimenow(int alpha_timezone)
{
time_t clock;
- time (&clock);
- return dtime (&clock, alpha_timezone);
+ time(&clock);
+ return dtime(&clock, alpha_timezone);
}
*/
char *
-dtime (time_t *clock, int alpha_timezone)
+dtime(time_t *clock, int alpha_timezone)
{
if (alpha_timezone)
/* use alpha-numeric timezones */
- return dasctime (dlocaltime (clock), TW_NULL);
+ return dasctime(dlocaltime(clock), TW_NULL);
else
/* use numeric timezones */
- return dasctime (dlocaltime (clock), TW_ZONE);
+ return dasctime(dlocaltime(clock), TW_ZONE);
}
*/
char *
-dasctime (struct tws *tw, int flags)
+dasctime(struct tws *tw, int flags)
{
char buffer[80];
static char result[80];
tw->tw_hour, tw->tw_min, tw->tw_sec, result);
if ((tw->tw_flags & TW_SDAY) == TW_SEXP)
- snprintf (result, sizeof(result), "%s, %s", tw_dotw[tw->tw_wday], buffer);
+ snprintf(result, sizeof(result), "%s, %s", tw_dotw[tw->tw_wday], buffer);
else
if ((tw->tw_flags & TW_SDAY) == TW_SNIL)
- strncpy (result, buffer, sizeof(result));
+ strncpy(result, buffer, sizeof(result));
else
- snprintf (result, sizeof(result), "%s (%s)", buffer, tw_dotw[tw->tw_wday]);
+ snprintf(result, sizeof(result), "%s (%s)", buffer, tw_dotw[tw->tw_wday]);
return result;
}
*/
char *
-dtimezone (int offset, int flags)
+dtimezone(int offset, int flags)
{
int hours, mins;
struct zone *z;
if (flags & TW_DST)
hours += 1;
#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */
- snprintf (buffer, sizeof(buffer), "%s%02d%02d",
- offset < 0 ? "-" : "+", abs (hours), abs (mins));
+ snprintf(buffer, sizeof(buffer), "%s%02d%02d",
+ offset < 0 ? "-" : "+", abs(hours), abs(mins));
return buffer;
}
*/
time_t
-dmktime (struct tws *tw)
+dmktime(struct tws *tw)
{
int i, sec, min, hour, mday, mon, year;
time_t result;
year += 100;
for (i = 1970; i < year; i++)
- result += dysize (i);
- if (dysize (year) == 366 && mon >= 3)
+ result += dysize(i);
+ if (dysize(year) == 366 && mon >= 3)
result++;
while (--mon)
result += dmsize[mon - 1];
*/
void
-set_dotw (struct tws *tw)
+set_dotw(struct tws *tw)
{
int month, day, year, century;
*/
void
-twscopy (struct tws *tb, struct tws *tw)
+twscopy(struct tws *tb, struct tws *tw)
{
*tb = *tw; /* struct copy */
*/
int
-twsort (struct tws *tw1, struct tws *tw2)
+twsort(struct tws *tw1, struct tws *tw2)
{
time_t c1, c2;
if (tw1->tw_clock == 0)
- dmktime (tw1);
+ dmktime(tw1);
if (tw2->tw_clock == 0)
- dmktime (tw2);
+ dmktime(tw2);
return ((c1 = tw1->tw_clock) > (c2 = tw2->tw_clock) ? 1
: c1 == c2 ? 0 : -1);
** print out error message
*/
void
-advise (char *what, char *fmt, ...)
+advise(char *what, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- advertise (what, NULL, fmt, ap);
+ advertise(what, NULL, fmt, ap);
va_end(ap);
}
** print out error message and exit
*/
void
-adios (char *what, char *fmt, ...)
+adios(char *what, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- advertise (what, NULL, fmt, ap);
+ advertise(what, NULL, fmt, ap);
va_end(ap);
- done (1);
+ done(1);
}
** admonish the user
*/
void
-admonish (char *what, char *fmt, ...)
+admonish(char *what, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- advertise (what, "continuing...", fmt, ap);
+ advertise(what, "continuing...", fmt, ap);
va_end(ap);
}
** sexy syscall()...
*/
void
-advertise (char *what, char *tail, char *fmt, va_list ap)
+advertise(char *what, char *tail, char *fmt, va_list ap)
{
int eindex = errno;
struct iovec iob[20], *iov;
#endif
- fflush (stdout);
+ fflush(stdout);
#ifdef HAVE_WRITEV
- fflush (stderr);
+ fflush(stderr);
iov = iob;
if (invo_name && *invo_name) {
- iov->iov_len = strlen (iov->iov_base = invo_name);
+ iov->iov_len = strlen(iov->iov_base = invo_name);
iov++;
- iov->iov_len = strlen (iov->iov_base = ": ");
+ iov->iov_len = strlen(iov->iov_base = ": ");
iov++;
}
- vsnprintf (buffer, sizeof(buffer), fmt, ap);
- iov->iov_len = strlen (iov->iov_base = buffer);
+ vsnprintf(buffer, sizeof(buffer), fmt, ap);
+ iov->iov_len = strlen(iov->iov_base = buffer);
iov++;
if (what) {
if (*what) {
- iov->iov_len = strlen (iov->iov_base = " ");
+ iov->iov_len = strlen(iov->iov_base = " ");
iov++;
- iov->iov_len = strlen (iov->iov_base = what);
+ iov->iov_len = strlen(iov->iov_base = what);
iov++;
- iov->iov_len = strlen (iov->iov_base = ": ");
+ iov->iov_len = strlen(iov->iov_base = ": ");
iov++;
}
- if (!(iov->iov_base = strerror (eindex))) {
+ if (!(iov->iov_base = strerror(eindex))) {
/* this shouldn't happen, but we'll test for it just in case */
- snprintf (err, sizeof(err), "Error %d", eindex);
+ snprintf(err, sizeof(err), "Error %d", eindex);
iov->iov_base = err;
}
- iov->iov_len = strlen (iov->iov_base);
+ iov->iov_len = strlen(iov->iov_base);
iov++;
}
if (tail && *tail) {
- iov->iov_len = strlen (iov->iov_base = ", ");
+ iov->iov_len = strlen(iov->iov_base = ", ");
iov++;
- iov->iov_len = strlen (iov->iov_base = tail);
+ iov->iov_len = strlen(iov->iov_base = tail);
iov++;
}
- iov->iov_len = strlen (iov->iov_base = "\n");
+ iov->iov_len = strlen(iov->iov_base = "\n");
iov++;
- writev (fileno (stderr), iob, iov - iob);
+ writev(fileno(stderr), iob, iov - iob);
#else
if (invo_name && *invo_name)
- fprintf (stderr, "%s: ", invo_name);
- vfprintf (stderr, fmt, ap);
+ fprintf(stderr, "%s: ", invo_name);
+ vfprintf(stderr, fmt, ap);
if (what) {
char *s;
if (*what)
- fprintf (stderr, " %s: ", what);
+ fprintf(stderr, " %s: ", what);
if ((s = strerror(eindex)))
- fprintf (stderr, "%s", s);
+ fprintf(stderr, "%s", s);
else
- fprintf (stderr, "Error %d", eindex);
+ fprintf(stderr, "Error %d", eindex);
}
if (tail)
- fprintf (stderr, ", %s", tail);
- fputc ('\n', stderr);
+ fprintf(stderr, ", %s", tail);
+ fputc('\n', stderr);
#endif
}
int
-fdcompare (int fd1, int fd2)
+fdcompare(int fd1, int fd2)
{
register int i, n1, n2, resp;
register char *c1, *c2;
char b1[BUFSIZ], b2[BUFSIZ];
resp = 1;
- while ((n1 = read (fd1, b1, sizeof(b1))) >= 0
- && (n2 = read (fd2, b2, sizeof(b2))) >= 0
+ while ((n1 = read(fd1, b1, sizeof(b1))) >= 0
+ && (n2 = read(fd2, b2, sizeof(b2))) >= 0
&& n1 == n2) {
c1 = b1;
c2 = b2;
resp = 0;
leave: ;
- lseek (fd1, (off_t) 0, SEEK_SET);
- lseek (fd2, (off_t) 0, SEEK_SET);
+ lseek(fd1, (off_t) 0, SEEK_SET);
+ lseek(fd2, (off_t) 0, SEEK_SET);
return resp;
}
/* check if there's enough room in buf for str. add more mem if needed */
#define CHECKMEM(str) \
- if ((len = strlen (str)) >= bufend - dst) {\
+ if ((len = strlen(str)) >= bufend - dst) {\
int i = dst - buf;\
int n = last_dst - buf;\
bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
- buf = mh_xrealloc (buf, bufsiz);\
+ buf = mh_xrealloc(buf, bufsiz);\
dst = buf + i;\
last_dst = buf + n;\
bufend = buf + bufsiz;\
*/
char *
-formataddr (char *orig, char *str)
+formataddr(char *orig, char *str)
{
register int len;
register int isgroup;
/* if we don't have a buffer yet, get one */
if (bufsiz == 0) {
- buf = mh_xmalloc (BUFINCR);
+ buf = mh_xmalloc(BUFINCR);
last_dst = buf; /* XXX */
bufsiz = BUFINCR - 6; /* leave some slop */
bufend = buf + bufsiz;
*dst = '\0';
} else {
dst = last_dst; /* XXX */
- CHECKMEM (orig);
- CPY (orig);
+ CHECKMEM(orig);
+ CPY(orig);
}
/* concatenate all the new addresses onto 'buf' */
- for (isgroup = 0; (cp = getname (str)); ) {
- if ((mp = getm (cp, NULL, 0, fmt_norm, NULL)) == NULL)
+ for (isgroup = 0; (cp = getname(str)); ) {
+ if ((mp = getm(cp, NULL, 0, fmt_norm, NULL)) == NULL)
continue;
if (isgroup && (mp->m_gname || !mp->m_ingrp)) {
*dst++ = ' ';
}
if (mp->m_gname) {
- CHECKMEM (mp->m_gname);
- CPY (mp->m_gname);
+ CHECKMEM(mp->m_gname);
+ CPY(mp->m_gname);
isgroup++;
}
- sp = adrformat (mp);
- CHECKMEM (sp);
- CPY (sp);
- mnfree (mp);
+ sp = adrformat(mp);
+ CHECKMEM(sp);
+ CPY(sp);
+ mnfree(mp);
}
if (isgroup)
static char *format_string;
static unsigned char *usr_fstring; /* for CERROR */
-#define CERROR(str) compile_error (str, cp)
+#define CERROR(str) compile_error(str, cp)
/*
** external prototypes
*/
static struct ftable *lookup(char *);
static void compile_error(char *, char *);
-static char *compile (char *);
+static char *compile(char *);
static char *do_spec(char *);
static char *do_name(char *, int);
static char *do_func(char *);
-static char *do_expr (char *, int);
+static char *do_expr(char *, int);
static char *do_loop(char *);
static char *do_if(char *);
register char c = *name;
while ((nm = t->name)) {
- if (*nm == c && strcmp (nm, name) == 0)
+ if (*nm == c && strcmp(nm, name) == 0)
return (ftbl = t);
t++;
advise(NULL, "\"%s\": format compile error - %s",
&usr_fstring[errpos-errctx], str);
- adios (NULL, "%*s", errctx+1, "^");
+ adios(NULL, "%*s", errctx+1, "^");
}
/*
int i;
if (format_string)
- free (format_string);
- format_string = getcpy (fstring);
+ free(format_string);
+ format_string = getcpy(fstring);
usr_fstring = fstring;
/* init the component hash table. */
i = strlen(fstring)/2 + 1;
if (i == 1)
i++;
- next_fp = formatvec = (struct format *)calloc ((size_t) i,
+ next_fp = formatvec = (struct format *)calloc((size_t) i,
sizeof(struct format));
if (next_fp == NULL)
- adios (NULL, "unable to allocate format storage");
+ adios(NULL, "unable to allocate format storage");
ncomp = 0;
infunction = 0;
}
static char *
-compile (char *sp)
+compile(char *sp)
{
register char *cp = sp;
register int c;
switch (c = *++cp) {
case '%':
- PUTC (*cp);
+ PUTC(*cp);
cp++;
break;
case FT_MYMBOX:
if (!primed) {
- ismymbox ((struct mailname *) 0);
+ ismymbox((struct mailname *) 0);
primed++;
}
/* fall through */
CERROR("'(', '{', ' ' or ')' expected");
}
cp[-1] = '\0';
- if ((t = lookup (sp)) == 0) {
+ if ((t = lookup(sp)) == 0) {
CERROR("unknown function");
}
if (isspace(c))
}
static char *
-do_expr (char *sp, int preprocess)
+do_expr(char *sp, int preprocess)
{
register char *cp = sp;
register int c;
if ((c = *cp++) == '{') {
- cp = do_name (cp, preprocess);
+ cp = do_name(cp, preprocess);
fp->f_type = FT_LS_COMP;
} else if (c == '(') {
- cp = do_func (cp);
+ cp = do_func(cp);
} else if (c == ')') {
return (--cp);
} else if (c == '%' && *cp == '<') {
- cp = do_if (cp+1);
+ cp = do_if(cp+1);
} else {
- CERROR ("'(', '{', '%<' or ')' expected");
+ CERROR("'(', '{', '%<' or ')' expected");
}
return (cp);
}
struct format *floop;
floop = next_fp;
- cp = compile (cp);
+ cp = compile(cp);
if (*cp++ != ']')
- CERROR ("']' expected");
+ CERROR("']' expected");
LV(FT_DONE, 1); /* not yet done */
LV(FT_GOTO, 0);
if ((c = *cp++) == '{') /*}*/{
cp = do_name(cp, 0);
fp->f_type = FT_LS_COMP;
- LV (FT_IF_S, 0);
+ LV(FT_IF_S, 0);
} else if (c == '(') {
cp = do_func(cp);
/* see if we can merge the load and the "if" */
** function 's return type is.
*/
if (ftbl->flags & TFL_PUTS) {
- LV (FT_IF_S, 0);
+ LV(FT_IF_S, 0);
} else {
- LV (FT_IF_V_NE, 0);
+ LV(FT_IF_V_NE, 0);
}
}
} else {
}
fexpr = fp; /* loc of [ELS]IF */
- cp = compile (cp); /* compile IF TRUE stmts */
+ cp = compile(cp); /* compile IF TRUE stmts */
if (fif)
fif->f_skip = next_fp - fif;
fexpr = (struct format *)NULL;/* no extra ENDIF */
- cp = compile (cp); /* compile ELSE stmts */
+ cp = compile(cp); /* compile ELSE stmts */
fif->f_skip = next_fp - fif;
c = *cp++;
} else if (c == '?') { /* another ELSIF */
/*
** static prototypes
*/
-static void normalize (char *);
+static void normalize(char *);
/*
*/
char *
-new_fs (char *form, char *format, char *default_fs)
+new_fs(char *form, char *format, char *default_fs)
{
struct stat st;
register FILE *fp;
if (formats)
- free (formats);
+ free(formats);
if (form) {
- if ((fp = fopen (etcpath (form), "r")) == NULL)
- adios (form, "unable to open format file");
+ if ((fp = fopen(etcpath(form), "r")) == NULL)
+ adios(form, "unable to open format file");
- if (fstat (fileno (fp), &st) == -1)
- adios (form, "unable to stat format file");
+ if (fstat(fileno(fp), &st) == -1)
+ adios(form, "unable to stat format file");
- formats = mh_xmalloc ((size_t) st.st_size + 1);
+ formats = mh_xmalloc((size_t) st.st_size + 1);
- if (read (fileno(fp), formats, (int) st.st_size) != st.st_size)
- adios (form, "error reading format file");
+ if (read(fileno(fp), formats, (int) st.st_size) != st.st_size)
+ adios(form, "error reading format file");
formats[st.st_size] = '\0';
- fclose (fp);
+ fclose(fp);
} else {
- formats = getcpy (format ? format : default_fs);
+ formats = getcpy(format ? format : default_fs);
}
- normalize (formats); /* expand escapes */
+ normalize(formats); /* expand escapes */
return formats;
}
*/
static void
-normalize (char *cp)
+normalize(char *cp)
{
char *dp;
#define char64(c) (((unsigned char) (c) > 127) ? -1 : index_64[(unsigned char) (c)])
static int
-unqp (unsigned char byte1, unsigned char byte2)
+unqp(unsigned char byte1, unsigned char byte2)
{
if (hexindex[byte1] == -1 || hexindex[byte2] == -1)
return -1;
#define ADDCHR(C) do { *q++ = (C); dstlen--; if (!dstlen) goto buffull; } while (0)
int
-decode_rfc2047 (char *str, char *dst, size_t dstlen)
+decode_rfc2047(char *str, char *dst, size_t dstlen)
{
char *p, *q, *pp;
char *startofmime, *endofmime;
** Do a quick and dirty check for the '=' character.
** This should quickly eliminate many cases.
*/
- if (!strchr (str, '='))
+ if (!strchr(str, '='))
return 0;
for (p = str, q = dst; *p; p++) {
if (quoted_printable) {
for (pp = startofmime; pp < endofmime; pp++) {
if (*pp == '=') {
- c = unqp (pp[1], pp[2]);
+ c = unqp(pp[1], pp[2]);
if (c == -1)
continue;
if (c != 0)
** which won't work if either
** encoding was stateful
*/
- iconv (cd, 0, 0, &saveq, &savedstlen);
+ iconv(cd, 0, 0, &saveq, &savedstlen);
if (!savedstlen)
break;
*saveq++ = '?';
#define NFMTS MAXARGS
-extern char *formataddr (); /* hook for custom address formatting */
+extern char *formataddr(); /* hook for custom address formatting */
#ifdef LBL
struct msgs *fmt_current_folder; /* current folder (set by main program) */
/*
** static prototypes
*/
-static int match (char *, char *);
-static char *get_x400_friendly (char *, char *, int);
-static int get_x400_comp (char *, char *, char *, int);
+static int match(char *, char *);
+static char *get_x400_friendly(char *, char *, int);
+static int get_x400_comp(char *, char *, char *, int);
/*
*/
static int
-match (char *str, char *sub)
+match(char *str, char *sub)
{
int c1, c2;
char *s1, *s2;
}
static void
-cpstripped (char **start, char *end, char *str)
+cpstripped(char **start, char *end, char *str)
{
int c;
char *s = str;
};
static char *
-get_x400_friendly (char *mbox, char *buffer, int buffer_len)
+get_x400_friendly(char *mbox, char *buffer, int buffer_len)
{
char given[BUFSIZ], surname[BUFSIZ];
if (*mbox != '/')
return NULL;
- if (get_x400_comp (mbox, "/PN=", buffer, buffer_len)) {
+ if (get_x400_comp(mbox, "/PN=", buffer, buffer_len)) {
for (mbox = buffer; (mbox = strchr(mbox, '.')); )
*mbox++ = ' ';
return buffer;
}
- if (!get_x400_comp (mbox, "/S=", surname, sizeof(surname)))
+ if (!get_x400_comp(mbox, "/S=", surname, sizeof(surname)))
return NULL;
- if (get_x400_comp (mbox, "/G=", given, sizeof(given)))
- snprintf (buffer, buffer_len, "%s %s", given, surname);
+ if (get_x400_comp(mbox, "/G=", given, sizeof(given)))
+ snprintf(buffer, buffer_len, "%s %s", given, surname);
else
- snprintf (buffer, buffer_len, "%s", surname);
+ snprintf(buffer, buffer_len, "%s", surname);
return buffer;
}
static int
-get_x400_comp (char *mbox, char *key, char *buffer, int buffer_len)
+get_x400_comp(char *mbox, char *key, char *buffer, int buffer_len)
{
int idx;
char *cp;
- if ((idx = stringdex (key, mbox)) < 0
- || !(cp = strchr(mbox += idx + strlen (key), '/')))
+ if ((idx = stringdex(key, mbox)) < 0
+ || !(cp = strchr(mbox += idx + strlen(key), '/')))
return 0;
- snprintf (buffer, buffer_len, "%*.*s", (int)(cp - mbox), (int)(cp - mbox), mbox);
+ snprintf(buffer, buffer_len, "%*.*s", (int)(cp - mbox), (int)(cp - mbox), mbox);
return 1;
}
struct format *
-fmt_scan (struct format *format, char *scanl, int width, int *dat)
+fmt_scan(struct format *format, char *scanl, int width, int *dat)
{
char *cp, *ep;
unsigned char *sp;
switch (fmt->f_type) {
case FT_COMP:
- cpstripped (&cp, ep, fmt->f_comp->c_text);
+ cpstripped(&cp, ep, fmt->f_comp->c_text);
break;
case FT_COMPF:
- cptrimmed (&cp, fmt->f_comp->c_text, fmt->f_width, fmt->f_fill, ep - cp);
+ cptrimmed(&cp, fmt->f_comp->c_text, fmt->f_width, fmt->f_fill, ep - cp);
break;
case FT_LIT:
break;
case FT_STR:
- cpstripped (&cp, ep, str);
+ cpstripped(&cp, ep, str);
break;
case FT_STRF:
- cptrimmed (&cp, str, fmt->f_width, fmt->f_fill, ep - cp);
+ cptrimmed(&cp, str, fmt->f_width, fmt->f_fill, ep - cp);
break;
case FT_STRFW:
- adios (NULL, "internal error (FT_STRFW)");
+ adios(NULL, "internal error (FT_STRFW)");
case FT_NUM:
n = snprintf(cp, ep - cp + 1, "%d", value);
}
break;
case FT_NUMF:
- cpnumber (&cp, value, fmt->f_width, fmt->f_fill, ep - cp);
+ cpnumber(&cp, value, fmt->f_width, fmt->f_fill, ep - cp);
break;
case FT_CHAR:
break;
case FT_IF_MATCH:
- if (!(value = (str && match (str, fmt->f_text)))) {
+ if (!(value = (str && match(str, fmt->f_text)))) {
fmt += fmt->f_skip;
continue;
}
case FT_V_MATCH:
if (str)
- value = match (str, fmt->f_text);
+ value = match(str, fmt->f_text);
else
value = 0;
break;
case FT_IF_AMATCH:
- if (!(value = (str && uprf (str, fmt->f_text)))) {
+ if (!(value = (str && uprf(str, fmt->f_text)))) {
fmt += fmt->f_skip;
continue;
}
break;
case FT_V_AMATCH:
- value = uprf (str, fmt->f_text);
+ value = uprf(str, fmt->f_text);
break;
case FT_S_NONNULL:
str = fmt->f_text;
break;
case FT_LS_GETENV:
- if (!(str = getenv (fmt->f_text)))
+ if (!(str = getenv(fmt->f_text)))
str = "";
break;
case FT_LS_CFIND:
- if (!(str = context_find (fmt->f_text)))
+ if (!(str = context_find(fmt->f_text)))
str = "";
break;
str = lmonth[fmt->f_comp->c_tws->tw_mon];
break;
case FT_LS_ZONE:
- str = dtwszone (fmt->f_comp->c_tws);
+ str = dtwszone(fmt->f_comp->c_tws);
break;
case FT_LV_YEAR:
value = fmt->f_comp->c_tws->tw_year;
break;
case FT_LV_WDAY:
if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
- set_dotw (tws);
+ set_dotw(tws);
value = tws->tw_wday;
break;
case FT_LS_DAY:
if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
- set_dotw (tws);
+ set_dotw(tws);
str = tw_dotw[tws->tw_wday];
break;
case FT_LS_WEEKDAY:
if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
- set_dotw (tws);
+ set_dotw(tws);
str = tw_ldotw[tws->tw_wday];
break;
case FT_LV_YDAY:
break;
case FT_LV_DAYF:
if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
- set_dotw (tws);
+ set_dotw(tws);
switch (fmt->f_comp->c_tws->tw_flags & TW_SDAY) {
case TW_SEXP:
value = 1; break;
value = fmt->f_comp->c_tws->tw_flags & TW_DST;
break;
case FT_LS_822DATE:
- str = dasctime (fmt->f_comp->c_tws , TW_ZONE);
+ str = dasctime(fmt->f_comp->c_tws , TW_ZONE);
break;
case FT_LS_PRETTY:
- str = dasctime (fmt->f_comp->c_tws, TW_NULL);
+ str = dasctime(fmt->f_comp->c_tws, TW_NULL);
break;
case FT_LS_PERS:
goto unfriendly;
if ((str = mn->m_pers) == NULL) {
if ((str = mn->m_note)) {
- strncpy (buffer, str, sizeof(buffer));
+ strncpy(buffer, str, sizeof(buffer));
buffer[sizeof(buffer)-1] = '\0';
str = buffer;
if (*str == '(')
else
break;
}
- } else if (!(str = get_x400_friendly (mn->m_mbox,
+ } else if (!(str = get_x400_friendly(mn->m_mbox,
buffer, sizeof(buffer)))) {
unfriendly: ;
switch (mn->m_type) {
str = mn->m_mbox;
break;
case UUCPHOST:
- snprintf (buffer, sizeof(buffer), "%s!%s",
+ snprintf(buffer, sizeof(buffer), "%s!%s",
mn->m_host, mn->m_mbox);
str = buffer;
break;
default:
if (mn->m_mbox) {
- snprintf (buffer, sizeof(buffer), "%s@%s",
+ snprintf(buffer, sizeof(buffer), "%s@%s",
mn->m_mbox, mn->m_host);
str= buffer;
} else
*comp->c_tws = *tws;
comp->c_flags &= ~CF_TRUE;
} else if ((comp->c_flags & CF_DATEFAB) == 0) {
- memset ((char *) comp->c_tws, 0, sizeof *comp->c_tws);
+ memset((char *) comp->c_tws, 0, sizeof *comp->c_tws);
comp->c_flags = CF_TRUE;
}
comp->c_flags |= CF_PARSED;
** hook for custom address list formatting
** (see replsbr.c)
*/
- str = formataddr (savestr, str);
+ str = formataddr(savestr, str);
break;
case FT_PUTADDR:
lp = str;
wid = value;
- len = strlen (str);
+ len = strlen(str);
sp = fmt->f_text;
- indent = strlen (sp);
+ indent = strlen(sp);
wid -= indent;
while( (c = *sp++) && cp < ep)
*cp++ = c;
*cp++ = ' ';
}
}
- cpstripped (&cp, ep, lp);
+ cpstripped(&cp, ep, lp);
}
break;
if (comp->c_flags & CF_PARSED)
break;
if (comp->c_mn != &fmt_mnull)
- mnfree (comp->c_mn);
+ mnfree(comp->c_mn);
if ((sp = comp->c_text) && (sp = getname(sp)) &&
- (mn = getm (sp, NULL, 0, fmt_norm, NULL))) {
+ (mn = getm(sp, NULL, 0, fmt_norm, NULL))) {
comp->c_mn = mn;
while (getname(""))
;
*/
comp = fmt->f_comp;
if (comp->c_mn != &fmt_mnull)
- mnfree (comp->c_mn);
+ mnfree(comp->c_mn);
if ((sp = comp->c_text) && (sp = getname(sp)) &&
- (mn = getm (sp, NULL, 0, AD_NAME, NULL))) {
+ (mn = getm(sp, NULL, 0, AD_NAME, NULL))) {
comp->c_mn = mn;
if (ismymbox(mn))
comp->c_flags |= CF_TRUE;
comp->c_flags &= ~CF_TRUE;
while ((sp = getname(sp)))
if ((comp->c_flags & CF_TRUE) == 0 &&
- (mn = getm (sp, NULL, 0, AD_NAME, NULL)))
+ (mn = getm(sp, NULL, 0, AD_NAME, NULL)))
if (ismymbox(mn))
comp->c_flags |= CF_TRUE;
} else {
*/
int
-folder_addmsg (struct msgs **mpp, char *msgfile, int selected,
+folder_addmsg(struct msgs **mpp, char *msgfile, int selected,
int unseen, int preserve, int deleting, char *from_dir)
{
int infd, outfd, linkerr, msgnum;
mp = *mpp;
/* should we preserve the numbering of the message? */
- if (preserve && (msgnum = m_atoi (msgfile)) > 0) {
+ if (preserve && (msgnum = m_atoi(msgfile)) > 0) {
;
} else if (mp->nummsg == 0) {
/* check if we are adding to empty folder */
** extend message status range to cover this message number.
*/
if (msgnum > mp->hghoff) {
- if ((mp = folder_realloc (mp, mp->lowoff, msgnum + 100)))
+ if ((mp = folder_realloc(mp, mp->lowoff, msgnum + 100)))
*mpp = mp;
else {
- advise (NULL, "unable to allocate folder storage");
+ advise(NULL, "unable to allocate folder storage");
return -1;
}
} else if (msgnum < mp->lowoff) {
- if ((mp = folder_realloc (mp, msgnum, mp->hghoff)))
+ if ((mp = folder_realloc(mp, msgnum, mp->hghoff)))
*mpp = mp;
else {
- advise (NULL, "unable to allocate folder storage");
+ advise(NULL, "unable to allocate folder storage");
return -1;
}
}
** If a message is already in that slot,
** then loop to next available slot.
*/
- if (does_exist (mp, msgnum))
+ if (does_exist(mp, msgnum))
continue;
/* setup the bit flags for this message */
- clear_msg_flags (mp, msgnum);
- set_exists (mp, msgnum);
+ clear_msg_flags(mp, msgnum);
+ set_exists(mp, msgnum);
/* should we set the SELECT_UNSEEN bit? */
if (unseen) {
- set_unseen (mp, msgnum);
+ set_unseen(mp, msgnum);
}
/* should we set the SELECTED bit? */
if (selected) {
- set_selected (mp, msgnum);
+ set_selected(mp, msgnum);
/* check if highest or lowest selected */
if (mp->numsel == 0) {
/* increment message count */
mp->nummsg++;
- nmsg = m_name (msgnum);
- snprintf (newmsg, sizeof(newmsg), "%s/%s", mp->foldpath, nmsg);
+ nmsg = m_name(msgnum);
+ snprintf(newmsg, sizeof(newmsg), "%s/%s", mp->foldpath, nmsg);
/*
** Now try to link message into folder. Then run the
** Run the add hook if the message is getting copied or
** linked somewhere else.
*/
- if (link (msgfile, newmsg) != -1) {
+ if (link(msgfile, newmsg) != -1) {
if (deleting) {
(void)snprintf(oldmsg, sizeof (oldmsg), "%s/%s", from_dir, msgfile);
** slot (hghmsg+1).
*/
if (linkerr == EEXIST) {
- if (stat (msgfile, &st2) == 0 && stat (newmsg, &st1) == 0
+ if (stat(msgfile, &st2) == 0 && stat(newmsg, &st1) == 0
&& st2.st_ino == st1.st_ino) {
return msgnum;
} else {
** error, else just copy the message.
*/
if (linkerr == EXDEV) {
- if (stat (newmsg, &st1) == 0) {
- advise (NULL, "message %s:%s already exists", mp->foldpath, newmsg);
+ if (stat(newmsg, &st1) == 0) {
+ advise(NULL, "message %s:%s already exists", mp->foldpath, newmsg);
return -1;
} else {
- if ((infd = open (msgfile, O_RDONLY)) == -1) {
- advise (msgfile, "unable to open message %s", msgfile);
+ if ((infd = open(msgfile, O_RDONLY)) == -1) {
+ advise(msgfile, "unable to open message %s", msgfile);
return -1;
}
- fstat (infd, &st1);
- if ((outfd = creat (newmsg, (int) st1.st_mode & 0777)) == -1) {
- advise (newmsg, "unable to create");
- close (infd);
+ fstat(infd, &st1);
+ if ((outfd = creat(newmsg, (int) st1.st_mode & 0777)) == -1) {
+ advise(newmsg, "unable to create");
+ close(infd);
return -1;
}
- cpydata (infd, outfd, msgfile, newmsg);
- close (infd);
- close (outfd);
+ cpydata(infd, outfd, msgfile, newmsg);
+ close(infd);
+ close(outfd);
if (deleting) {
(void)snprintf(oldmsg, sizeof (oldmsg), "%s/%s", from_dir, msgfile);
** Else, some other type of link error,
** so just return error.
*/
- advise (newmsg, "error linking %s to", msgfile);
+ advise(newmsg, "error linking %s to", msgfile);
return -1;
}
}
*/
int
-folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook)
+folder_delmsgs(struct msgs *mp, int unlink_msgs, int nohook)
{
pid_t pid;
int msgnum, vecp, retval = 0;
if (rmmproc) {
/* Unset the EXISTS flag for each message to be removed */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
- if (is_selected (mp, msgnum))
- unset_exists (mp, msgnum);
+ if (is_selected(mp, msgnum))
+ unset_exists(mp, msgnum);
}
/* Mark that the sequence information has changed */
mp->msgflags |= SEQMOD;
if (mp->numsel > MAXARGS - 2)
- adios (NULL, "more than %d messages for %s exec", MAXARGS - 2,
+ adios(NULL, "more than %d messages for %s exec", MAXARGS - 2,
rmmproc);
- vec = (char **) calloc ((size_t) (mp->numsel + 2), sizeof(*vec));
+ vec = (char **) calloc((size_t) (mp->numsel + 2), sizeof(*vec));
if (vec == NULL)
- adios (NULL, "unable to allocate exec vector");
+ adios(NULL, "unable to allocate exec vector");
vecp = 1;
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
- if (is_selected (mp, msgnum) &&
- !(vec[vecp++] = strdup (m_name (msgnum))))
- adios (NULL, "strdup failed");
+ if (is_selected(mp, msgnum) &&
+ !(vec[vecp++] = strdup(m_name(msgnum))))
+ adios(NULL, "strdup failed");
}
vec[vecp] = NULL;
- fflush (stdout);
- vec[0] = r1bindex (rmmproc, '/');
+ fflush(stdout);
+ vec[0] = r1bindex(rmmproc, '/');
switch (pid = vfork()) {
case -1:
- advise ("fork", "unable to");
+ advise("fork", "unable to");
return -1;
case 0:
- execvp (rmmproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (rmmproc);
- _exit (-1);
+ execvp(rmmproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(rmmproc);
+ _exit(-1);
default:
- return (pidwait (pid, -1));
+ return (pidwait(pid, -1));
}
}
** Either unlink or rename the SELECTED messages
*/
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
- if (is_selected (mp, msgnum)) {
+ if (is_selected(mp, msgnum)) {
/* unselect message */
- unset_selected (mp, msgnum);
+ unset_selected(mp, msgnum);
mp->numsel--;
/*
(void)ext_hook("del-hook", msgpath, (char *)0);
}
- dp = m_name (msgnum);
+ dp = m_name(msgnum);
if (unlink_msgs) {
/* just unlink the messages */
- if (unlink (dp) == -1) {
- admonish (dp, "unable to unlink");
+ if (unlink(dp) == -1) {
+ admonish(dp, "unable to unlink");
retval = -1;
continue;
}
} else {
/* or rename messages with standard prefix */
- strncpy (buf, m_backup (dp), sizeof(buf));
- if (rename (dp, buf) == -1) {
- admonish (buf, "unable to rename %s to", dp);
+ strncpy(buf, m_backup(dp), sizeof(buf));
+ if (rename(dp, buf) == -1) {
+ admonish(buf, "unable to rename %s to", dp);
retval = -1;
continue;
}
}
/* If removal was successful, decrement message count */
- unset_exists (mp, msgnum);
+ unset_exists(mp, msgnum);
mp->nummsg--;
}
}
/* Sanity check */
if (mp->numsel != 0)
- adios (NULL, "oops, mp->numsel should be 0");
+ adios(NULL, "oops, mp->numsel should be 0");
/* Mark that the sequence information has changed */
mp->msgflags |= SEQMOD;
void
-folder_free (struct msgs *mp)
+folder_free(struct msgs *mp)
{
int i;
return;
if (mp->foldpath)
- free (mp->foldpath);
+ free(mp->foldpath);
/* free the sequence names */
for (i = 0; mp->msgattrs[i]; i++)
- free (mp->msgattrs[i]);
+ free(mp->msgattrs[i]);
- free (mp->msgstats); /* free message status area */
- free (mp); /* free main folder structure */
+ free(mp->msgstats); /* free message status area */
+ free(mp); /* free main folder structure */
}
*/
int
-folder_pack (struct msgs **mpp, int verbose)
+folder_pack(struct msgs **mpp, int verbose)
{
int hole, msgnum, newcurrent = 0;
char newmsg[BUFSIZ], oldmsg[BUFSIZ];
** for all numbers from 1 to current high message.
*/
if (mp->lowoff > 1) {
- if ((mp = folder_realloc (mp, 1, mp->hghmsg)))
+ if ((mp = folder_realloc(mp, 1, mp->hghmsg)))
*mpp = mp;
else {
- advise (NULL, "unable to allocate folder storage");
+ advise(NULL, "unable to allocate folder storage");
return -1;
}
}
for (msgnum = mp->lowmsg, hole = 1; msgnum <= mp->hghmsg; msgnum++) {
- if (does_exist (mp, msgnum)) {
+ if (does_exist(mp, msgnum)) {
if (msgnum != hole) {
- strncpy (newmsg, m_name (hole), sizeof(newmsg));
- strncpy (oldmsg, m_name (msgnum), sizeof(oldmsg));
+ strncpy(newmsg, m_name(hole), sizeof(newmsg));
+ strncpy(oldmsg, m_name(msgnum), sizeof(oldmsg));
if (verbose)
- printf ("message %s becomes %s\n", oldmsg, newmsg);
+ printf("message %s becomes %s\n", oldmsg, newmsg);
/*
** Invoke the external refile hook for each
ext_hook("ref-hook", oldmsg, newmsg);
/* move the message file */
- if (rename (oldmsg, newmsg) == -1) {
- advise (newmsg, "unable to rename %s to", oldmsg);
+ if (rename(oldmsg, newmsg) == -1) {
+ advise(newmsg, "unable to rename %s to", oldmsg);
return -1;
}
newcurrent = hole;
/* copy the attribute flags for this message */
- copy_msg_flags (mp, hole, msgnum);
+ copy_msg_flags(mp, hole, msgnum);
if (msgnum == mp->lowsel)
mp->lowsel = hole;
/* update the "cur" sequence */
if (newcurrent != 0)
- seq_setcur (mp, newcurrent);
+ seq_setcur(mp, newcurrent);
return 0;
}
*/
struct msgs *
-folder_read (char *name)
+folder_read(char *name)
{
int msgnum, prefix_len, len, *mi;
struct msgs *mp;
struct dirent *dp;
DIR *dd;
- name = m_mailpath (name);
- if (!(dd = opendir (name))) {
- free (name);
+ name = m_mailpath(name);
+ if (!(dd = opendir(name))) {
+ free(name);
return NULL;
}
- if (stat (name, &st) == -1) {
- free (name);
+ if (stat(name, &st) == -1) {
+ free(name);
return NULL;
}
/* Allocate the main structure for folder information */
- mp = (struct msgs *) mh_xmalloc ((size_t) sizeof(*mp));
+ mp = (struct msgs *) mh_xmalloc((size_t) sizeof(*mp));
- clear_folder_flags (mp);
+ clear_folder_flags(mp);
mp->foldpath = name;
mp->lowmsg = 0;
mp->hghmsg = 0;
mp->numsel = 0;
mp->nummsg = 0;
- if (access (name, W_OK) == -1)
- set_readonly (mp);
+ if (access(name, W_OK) == -1)
+ set_readonly(mp);
prefix_len = strlen(backup_prefix);
/*
** name of the messages in this folder.
*/
len = NUMMSGS;
- mi = (int *) mh_xmalloc ((size_t) (len * sizeof(*mi)));
+ mi = (int *) mh_xmalloc((size_t) (len * sizeof(*mi)));
- while ((dp = readdir (dd))) {
- if ((msgnum = m_atoi (dp->d_name)) && msgnum > 0) {
+ 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.
*/
if (mp->nummsg >= len) {
len += NUMMSGS;
- mi = (int *) mh_xrealloc (mi, (size_t) (len * sizeof(*mi)));
+ mi = (int *) mh_xrealloc(mi, (size_t) (len * sizeof(*mi)));
}
/* Check if this is the first message we've seen */
** skip any files beginning with
** backup prefix
*/
- if (!strncmp (dp->d_name, backup_prefix, prefix_len))
+ if (!strncmp(dp->d_name, backup_prefix, prefix_len))
continue;
/* skip the altmsg link file */
- if (!strcmp (dp->d_name, altmsglink))
+ if (!strcmp(dp->d_name, altmsglink))
continue;
/*
** indicate that there are other
** files in folder
*/
- set_other_files (mp);
+ set_other_files(mp);
continue;
}
}
}
- closedir (dd);
- mp->lowoff = max (mp->lowmsg, 1);
+ closedir(dd);
+ mp->lowoff = max(mp->lowmsg, 1);
/* Go ahead and allocate space for 100 additional messages. */
mp->hghoff = mp->hghmsg + 100;
/* for testing, allocate minimal necessary space */
- /* mp->hghoff = max (mp->hghmsg, 1); */
+ /* mp->hghoff = max(mp->hghmsg, 1); */
/*
** Allocate space for status of each message.
*/
- mp->msgstats = mh_xmalloc (MSGSTATSIZE(mp, mp->lowoff, mp->hghoff));
+ mp->msgstats = mh_xmalloc(MSGSTATSIZE(mp, mp->lowoff, mp->hghoff));
/*
** 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);
+ clear_msg_flags(mp, msgnum);
/*
** Scan through the array of messages we've seen and
** newly allocated mp->msgstats area.
*/
for (msgnum = 0; msgnum < mp->nummsg; msgnum++)
- set_exists (mp, mi[msgnum]);
+ set_exists(mp, mi[msgnum]);
- free (mi); /* We don't need this anymore */
+ free(mi); /* We don't need this anymore */
/*
** Read and initialize the sequence information.
*/
- seq_read (mp);
+ seq_read(mp);
return mp;
}
*/
struct msgs *
-folder_realloc (struct msgs *mp, int lo, int hi)
+folder_realloc(struct msgs *mp, int lo, int hi)
{
int msgnum;
/* sanity checks */
if (lo < 1)
- adios (NULL, "BUG: called folder_realloc with lo (%d) < 1", lo);
+ adios(NULL, "BUG: called folder_realloc with lo (%d) < 1", lo);
if (hi < 1)
- adios (NULL, "BUG: called folder_realloc with hi (%d) < 1", hi);
+ adios(NULL, "BUG: called folder_realloc with hi (%d) < 1", hi);
if (mp->nummsg > 0 && lo > mp->lowmsg)
- adios (NULL, "BUG: called folder_realloc with lo (%d) > mp->lowmsg (%d)",
+ adios(NULL, "BUG: called folder_realloc with lo (%d) > mp->lowmsg (%d)",
lo, mp->lowmsg);
if (mp->nummsg > 0 && hi < mp->hghmsg)
- adios (NULL, "BUG: called folder_realloc with hi (%d) < mp->hghmsg (%d)",
+ adios(NULL, "BUG: called folder_realloc with hi (%d) < mp->hghmsg (%d)",
hi, mp->hghmsg);
/* Check if we really need to reallocate anything */
** 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));
+ mp->msgstats = mh_xrealloc(mp->msgstats, MSGSTATSIZE(mp, lo, hi));
} else {
/*
** We are changing the offset of the message status
seqset_t *tmpstats;
/* first allocate the new message status space */
- tmpstats = mh_xmalloc (MSGSTATSIZE(mp, lo, hi));
+ tmpstats = mh_xmalloc(MSGSTATSIZE(mp, lo, hi));
/* then copy messages status array with shift */
if (mp->nummsg > 0) {
*/
if (mp->nummsg > 0) {
for (msgnum = mp->lowoff; msgnum < mp->lowmsg; msgnum++)
- clear_msg_flags (mp, msgnum);
+ clear_msg_flags(mp, msgnum);
for (msgnum = mp->hghmsg + 1; msgnum <= mp->hghoff; msgnum++)
- clear_msg_flags (mp, msgnum);
+ clear_msg_flags(mp, msgnum);
} else {
/* no messages, so clear entire range */
for (msgnum = mp->lowoff; msgnum <= mp->hghoff; msgnum++)
- clear_msg_flags (mp, msgnum);
+ clear_msg_flags(mp, msgnum);
}
return mp;
int
-gans (char *prompt, struct swit *ansp)
+gans(char *prompt, struct swit *ansp)
{
register int i;
register char *cp;
char ansbuf[BUFSIZ];
for (;;) {
- printf ("%s", prompt);
- fflush (stdout);
+ printf("%s", prompt);
+ fflush(stdout);
cp = ansbuf;
- while ((i = getchar ()) != '\n') {
+ while ((i = getchar()) != '\n') {
if (i == EOF)
return 0;
if (cp < &ansbuf[sizeof ansbuf - 1]) {
}
*cp = '\0';
if (ansbuf[0] == '?' || cp == ansbuf) {
- printf ("Options are:\n");
+ printf("Options are:\n");
for (ap = ansp; ap->sw; ap++)
- printf (" %s\n", ap->sw);
+ printf(" %s\n", ap->sw);
continue;
}
- if ((i = smatch (ansbuf, ansp)) < 0) {
- printf ("%s: %s.\n", ansbuf, i == -1 ? "unknown" : "ambiguous");
+ if ((i = smatch(ansbuf, ansp)) < 0) {
+ printf("%s: %s.\n", ansbuf, i == -1 ? "unknown" : "ambiguous");
continue;
}
return i;
/*
** static prototypes
*/
-static RETSIGTYPE intrser (int);
+static RETSIGTYPE intrser(int);
char **
-getans (char *prompt, struct swit *ansp)
+getans(char *prompt, struct swit *ansp)
{
int i;
SIGNAL_HANDLER istat = NULL;
char *cp, **cpp;
- if (!(setjmp (sigenv))) {
- istat = SIGNAL (SIGINT, intrser);
+ if (!(setjmp(sigenv))) {
+ istat = SIGNAL(SIGINT, intrser);
} else {
- SIGNAL (SIGINT, istat);
+ SIGNAL(SIGINT, istat);
return NULL;
}
for (;;) {
- printf ("%s", prompt);
- fflush (stdout);
+ printf("%s", prompt);
+ fflush(stdout);
cp = ansbuf;
- while ((i = getchar ()) != '\n') {
+ while ((i = getchar()) != '\n') {
if (i == EOF)
- longjmp (sigenv, 1);
+ longjmp(sigenv, 1);
if (cp < &ansbuf[sizeof ansbuf - 1])
*cp++ = i;
}
*cp = '\0';
if (ansbuf[0] == '?' || cp == ansbuf) {
- printf ("Options are:\n");
- print_sw (ALL, ansp, "", stdout);
+ printf("Options are:\n");
+ print_sw(ALL, ansp, "", stdout);
continue;
}
- cpp = brkstring (ansbuf, " ", NULL);
- switch (smatch (*cpp, ansp)) {
+ cpp = brkstring(ansbuf, " ", NULL);
+ switch (smatch(*cpp, ansp)) {
case AMBIGSW:
- ambigsw (*cpp, ansp);
+ ambigsw(*cpp, ansp);
continue;
case UNKWNSW:
- printf (" -%s unknown. Hit <CR> for help.\n", *cpp);
+ printf(" -%s unknown. Hit <CR> for help.\n", *cpp);
continue;
default:
- SIGNAL (SIGINT, istat);
+ SIGNAL(SIGINT, istat);
return cpp;
}
}
static RETSIGTYPE
-intrser (int i)
+intrser(int i)
{
/*
** should this be siglongjmp?
*/
- longjmp (sigenv, 1);
+ longjmp(sigenv, 1);
}
int
-getanswer (char *prompt)
+getanswer(char *prompt)
{
static int interactive = -1;
if (interactive < 0)
- interactive = isatty (fileno (stdin)) ? 1 : 0;
+ interactive = isatty(fileno(stdin)) ? 1 : 0;
- return (interactive ? gans (prompt, anoyes) : 1);
+ return (interactive ? gans(prompt, anoyes) : 1);
}
#include <h/utils.h>
char **
-getarguments (char *invo_name, int argc, char **argv, int check_context)
+getarguments(char *invo_name, int argc, char **argv, int check_context)
{
char *cp = NULL, **ap = NULL, **bp = NULL, **arguments = NULL;
int n = 0;
/*
** 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 */
+ if (check_context && (cp = context_find(invo_name))) {
+ cp = getcpy(cp); /* make copy */
+ ap = brkstring(cp, " ", "\n"); /* split string */
/* Count number of arguments split */
bp = ap;
n++;
}
- arguments = (char **) mh_xmalloc ((argc + n) * sizeof(*arguments));
+ arguments = (char **) mh_xmalloc((argc + n) * sizeof(*arguments));
bp = arguments;
/* Copy any arguments from profile/context */
char *
-getcpy (char *str)
+getcpy(char *str)
{
char *cp;
size_t len;
if (str) {
len = strlen(str) + 1;
- cp = mh_xmalloc (len);
- memcpy (cp, str, len);
+ cp = mh_xmalloc(len);
+ memcpy(cp, str, len);
} else {
- cp = mh_xmalloc ((size_t) 1);
+ cp = mh_xmalloc((size_t) 1);
*cp = '\0';
}
return cp;
/*
** If wantcurrent == 1, then try the current folder first
*/
- if (wantcurrent && (folder = context_find (pfolder)) && *folder != '\0')
+ if (wantcurrent && (folder = context_find(pfolder)) && *folder != '\0')
return folder;
/*
** Else try the Inbox profile entry
*/
- if ((folder = context_find (inbox)) && *folder != '\0')
+ if ((folder = context_find(inbox)) && *folder != '\0')
return folder;
/*
** static prototypes
*/
#ifdef KERNEL_LOCKING
-static int lkopen_kernel (char *, int, mode_t);
+static int lkopen_kernel(char *, int, mode_t);
#endif
#ifdef DOT_LOCKING
-static int lkopen_dot (char *, int, mode_t);
-static void lockname (char *, struct lockinfo *, int);
-static void timerON (char *, int);
-static void timerOFF (int);
-static RETSIGTYPE alrmser (int);
+static int lkopen_dot(char *, int, mode_t);
+static void lockname(char *, struct lockinfo *, int);
+static void timerON(char *, int);
+static void timerOFF(int);
+static RETSIGTYPE alrmser(int);
#endif
#if !defined(HAVE_LIBLOCKFILE)
-static int lockit (struct lockinfo *);
+static int lockit(struct lockinfo *);
#endif
/*
*/
int
-lkopen (char *file, int access, mode_t mode)
+lkopen(char *file, int access, mode_t mode)
{
#ifdef KERNEL_LOCKING
return lkopen_kernel(file, access, mode);
*/
int
-lkclose (int fd, char *file)
+lkclose(int fd, char *file)
{
#ifdef FCNTL_LOCKING
struct flock buf;
#endif
#ifdef FLOCK_LOCKING
- flock (fd, LOCK_UN);
+ flock(fd, LOCK_UN);
#endif
#ifdef LOCKF_LOCKING
/* make sure we unlock the whole thing */
- lseek (fd, (off_t) 0, SEEK_SET);
- lockf (fd, F_ULOCK, 0L);
+ lseek(fd, (off_t) 0, SEEK_SET);
+ lockf(fd, F_ULOCK, 0L);
#endif
#ifdef DOT_LOCKING
- lockname (file, &lkinfo, 0); /* get name of lock file */
+ lockname(file, &lkinfo, 0); /* get name of lock file */
#if !defined(HAVE_LIBLOCKFILE)
- unlink (lkinfo.curlock); /* remove lock file */
+ unlink(lkinfo.curlock); /* remove lock file */
#else
lockfile_remove(lkinfo.curlock);
#endif /* HAVE_LIBLOCKFILE */
- timerOFF (fd); /* turn off lock timer */
+ timerOFF(fd); /* turn off lock timer */
#endif /* DOT_LOCKING */
- return (close (fd));
+ return (close(fd));
}
*/
FILE *
-lkfopen (char *file, char *mode)
+lkfopen(char *file, char *mode)
{
int fd, access;
FILE *fp;
- if (strcmp (mode, "r") == 0)
+ if (strcmp(mode, "r") == 0)
access = O_RDONLY;
- else if (strcmp (mode, "r+") == 0)
+ else if (strcmp(mode, "r+") == 0)
access = O_RDWR;
- else if (strcmp (mode, "w") == 0)
+ else if (strcmp(mode, "w") == 0)
access = O_WRONLY | O_CREAT | O_TRUNC;
- else if (strcmp (mode, "w+") == 0)
+ else if (strcmp(mode, "w+") == 0)
access = O_RDWR | O_CREAT | O_TRUNC;
- else if (strcmp (mode, "a") == 0)
+ else if (strcmp(mode, "a") == 0)
access = O_WRONLY | O_CREAT | O_APPEND;
- else if (strcmp (mode, "a+") == 0)
+ else if (strcmp(mode, "a+") == 0)
access = O_RDWR | O_CREAT | O_APPEND;
else {
errno = EINVAL;
return NULL;
}
- if ((fd = lkopen (file, access, 0666)) == -1)
+ if ((fd = lkopen(file, access, 0666)) == -1)
return NULL;
- if ((fp = fdopen (fd, mode)) == NULL) {
- close (fd);
+ if ((fp = fdopen(fd, mode)) == NULL) {
+ close(fd);
return NULL;
}
*/
int
-lkfclose (FILE *fp, char *file)
+lkfclose(FILE *fp, char *file)
{
#ifdef FCNTL_LOCKING
struct flock buf;
#endif
#ifdef FLOCK_LOCKING
- flock (fileno(fp), LOCK_UN);
+ flock(fileno(fp), LOCK_UN);
#endif
#ifdef LOCKF_LOCKING
/* make sure we unlock the whole thing */
- fseek (fp, 0L, SEEK_SET);
- lockf (fileno(fp), F_ULOCK, 0L);
+ fseek(fp, 0L, SEEK_SET);
+ lockf(fileno(fp), F_ULOCK, 0L);
#endif
#ifdef DOT_LOCKING
- lockname (file, &lkinfo, 0); /* get name of lock file */
+ lockname(file, &lkinfo, 0); /* get name of lock file */
#if !defined(HAVE_LIBLOCKFILE)
- unlink (lkinfo.curlock); /* remove lock file */
+ unlink(lkinfo.curlock); /* remove lock file */
#else
lockfile_remove(lkinfo.curlock);
#endif /* HAVE_LIBLOCKFILE */
- timerOFF (fileno(fp)); /* turn off lock timer */
+ timerOFF(fileno(fp)); /* turn off lock timer */
#endif /* DOT_LOCKING */
- return (fclose (fp));
+ return (fclose(fp));
}
*/
static int
-lkopen_kernel (char *file, int access, mode_t mode)
+lkopen_kernel(char *file, int access, mode_t mode)
{
int fd, i, j;
}
# endif /* LOCKF_LOCKING || FCNTL_LOCKING */
- if ((fd = open (file, access | O_NDELAY, mode)) == -1)
+ if ((fd = open(file, access | O_NDELAY, mode)) == -1)
return -1;
# ifdef FCNTL_LOCKING
buf.l_whence = SEEK_SET;
buf.l_start = 0;
buf.l_len = 0;
- if (fcntl (fd, F_SETLK, &buf) != -1)
+ if (fcntl(fd, F_SETLK, &buf) != -1)
return fd;
# endif
# ifdef FLOCK_LOCKING
- if (flock (fd, (((access & 03) == O_RDONLY) ? LOCK_SH :
+ if (flock(fd, (((access & 03) == O_RDONLY) ? LOCK_SH :
LOCK_EX) | LOCK_NB) != -1)
return fd;
# endif
# ifdef LOCKF_LOCKING
- if (lockf (fd, F_TLOCK, 0L) != -1) {
+ if (lockf(fd, F_TLOCK, 0L) != -1) {
/* see if we should be at the end */
if (j & O_APPEND)
- lseek (fd, (off_t) 0, SEEK_END);
+ lseek(fd, (off_t) 0, SEEK_END);
return fd;
}
# endif
j = errno;
- close (fd);
- sleep (5);
+ close(fd);
+ sleep(5);
}
- close (fd);
+ close(fd);
errno = j;
return -1;
}
*/
static int
-lkopen_dot (char *file, int access, mode_t mode)
+lkopen_dot(char *file, int access, mode_t mode)
{
int fd;
struct lockinfo lkinfo;
/* open the file */
- if ((fd = open (file, access, mode)) == -1)
+ if ((fd = open(file, access, mode)) == -1)
return -1;
/*
** Get the name of the eventual lock file, as well
** as a name for a temporary lock file.
*/
- lockname (file, &lkinfo, 1);
+ lockname(file, &lkinfo, 1);
#if !defined(HAVE_LIBLOCKFILE)
{
int i;
for (i = 0;;) {
/* attempt to create lock file */
- if (lockit (&lkinfo) == 0) {
+ if (lockit(&lkinfo) == 0) {
/* if successful, turn on timer and return */
- timerON (lkinfo.curlock, fd);
+ timerON(lkinfo.curlock, fd);
return fd;
} else {
/*
** lock file.
*/
struct stat st;
- if (stat (lkinfo.curlock, &st) == -1) {
+ if (stat(lkinfo.curlock, &st) == -1) {
if (i++ > 5)
return -1;
- sleep (5);
+ sleep(5);
} else {
time_t curtime;
i = 0;
- time (&curtime);
+ time(&curtime);
/*
** check for stale lockfile,
** else sleep
*/
if (curtime > st.st_ctime + RSECS)
- unlink (lkinfo.curlock);
+ unlink(lkinfo.curlock);
else
- sleep (5);
+ sleep(5);
}
- lockname (file, &lkinfo, 1);
+ lockname(file, &lkinfo, 1);
}
}
}
*/
static int
-lockit (struct lockinfo *li)
+lockit(struct lockinfo *li)
{
int fd;
char *curlock, *tmplock;
#if 0
/* write our process id into lock file */
- snprintf (buffer, sizeof(buffer), "nmh lock: pid %d\n", (int) getpid());
+ snprintf(buffer, sizeof(buffer), "nmh lock: pid %d\n", (int) getpid());
write(fd, buffer, strlen(buffer) + 1);
#endif
- close (fd);
+ close(fd);
/*
** Now try to create the real lock file
*/
static void
-lockname (char *file, struct lockinfo *li, int isnewlock)
+lockname(char *file, struct lockinfo *li, int isnewlock)
{
int bplen, tmplen;
char *bp, *cp;
struct stat st;
#endif
- if ((cp = strrchr (file, '/')) == NULL || *++cp == 0)
+ if ((cp = strrchr(file, '/')) == NULL || *++cp == 0)
cp = file;
bp = li->curlock;
bplen = 0;
#ifdef LOCKDIR
- snprintf (bp, sizeof(li->curlock), "%s/", lockdir);
- tmplen = strlen (bp);
+ snprintf(bp, sizeof(li->curlock), "%s/", lockdir);
+ tmplen = strlen(bp);
bp += tmplen;
bplen += tmplen;
#else
if (cp != file) {
- snprintf (bp, sizeof(li->curlock), "%.*s", (int)(cp - file), file);
- tmplen = strlen (bp);
+ snprintf(bp, sizeof(li->curlock), "%.*s", (int)(cp - file), file);
+ tmplen = strlen(bp);
bp += tmplen;
bplen += tmplen;
}
** If we start supporting mmdf style dot locking,
** we will need to change the return value of lockname
*/
- if (stat (file, &st) == -1)
+ if (stat(file, &st) == -1)
return -1;
- snprintf (bp, sizeof(li->curlock) - bplen, "LCK%05d.%05d",
+ snprintf(bp, sizeof(li->curlock) - bplen, "LCK%05d.%05d",
st.st_dev, st.st_ino);
#endif
- snprintf (bp, sizeof(li->curlock) - bplen, "%s.lock", cp);
+ snprintf(bp, sizeof(li->curlock) - bplen, "%s.lock", cp);
#if !defined(HAVE_LIBLOCKFILE)
/*
** the temporary lock file for lockit()
*/
if (isnewlock) {
- if ((cp = strrchr (li->curlock, '/')) == NULL || *++cp == 0)
- strncpy (li->tmplock, ",LCK.XXXXXX", sizeof(li->tmplock));
+ if ((cp = strrchr(li->curlock, '/')) == NULL || *++cp == 0)
+ strncpy(li->tmplock, ",LCK.XXXXXX", sizeof(li->tmplock));
else
- snprintf (li->tmplock, sizeof(li->tmplock), "%.*s,LCK.XXXXXX",
- (int)(cp - li->curlock), li->curlock);
+ snprintf(li->tmplock, sizeof(li->tmplock),
+ "%.*s,LCK.XXXXXX",
+ (int)(cp - li->curlock), li->curlock);
}
#endif
}
*/
static void
-timerON (char *curlock, int fd)
+timerON(char *curlock, int fd)
{
struct lock *lp;
size_t len;
- lp = (struct lock *) mh_xmalloc (sizeof(*lp));
+ lp = (struct lock *) mh_xmalloc(sizeof(*lp));
len = strlen(curlock) + 1;
lp->l_fd = fd;
- lp->l_lock = mh_xmalloc (len);
- memcpy (lp->l_lock, curlock, len);
+ lp->l_lock = mh_xmalloc(len);
+ memcpy(lp->l_lock, curlock, len);
lp->l_next = l_top;
if (!l_top) {
/* perhaps SIGT{STP,TIN,TOU} ? */
- SIGNAL (SIGALRM, alrmser);
- alarm (NSECS);
+ SIGNAL(SIGALRM, alrmser);
+ alarm(NSECS);
}
l_top = lp;
*/
static void
-timerOFF (int fd)
+timerOFF(int fd)
{
struct lock *pp, *lp;
else
pp->l_next = lp->l_next;
- free (lp->l_lock);
- free (lp);
+ free(lp->l_lock);
+ free(lp);
}
}
/* if there are locks left, restart timer */
if (l_top)
- alarm (NSECS);
+ alarm(NSECS);
}
*/
static RETSIGTYPE
-alrmser (int sig)
+alrmser(int sig)
{
char *lockfile;
struct lock *lp;
#ifndef RELIABLE_SIGNALS
- SIGNAL (SIGALRM, alrmser);
+ SIGNAL(SIGALRM, alrmser);
#endif
/* update the ctime of all the lock files */
#if !defined(HAVE_LIBLOCKFILE)
{
int j;
- if (*lockfile && (j = creat (lockfile, 0600)) != -1)
- close (j);
+ if (*lockfile && (j = creat(lockfile, 0600)) != -1)
+ close(j);
}
#else
lockfile_touch(lockfile);
}
/* restart the alarm */
- alarm (NSECS);
+ alarm(NSECS);
}
#endif /* DOT_LOCKING */
int
-m_atoi (char *str)
+m_atoi(char *str)
{
int i;
unsigned char *cp;
char *
-m_backup (char *file)
+m_backup(char *file)
{
char *cp;
static char buffer[BUFSIZ];
/*
** static prototypes
*/
-static int m_conv (struct msgs *, char *, int);
-static int attr (struct msgs *, char *);
+static int m_conv(struct msgs *, char *, int);
+static int attr(struct msgs *, char *);
int
-m_convert (struct msgs *mp, char *name)
+m_convert(struct msgs *mp, char *name)
{
int first, last, found, range, err;
unsigned char *bp;
char *cp;
/* check if user defined sequence */
- err = attr (mp, cp = name);
+ err = attr(mp, cp = name);
if (err == -1)
return 0;
** 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)
+ if ((mp->msgflags & ALLOW_NEW) && !strcmp(cp, "new")) {
+ if ((err = first = getnew(mp)) <= 0)
goto badmsg;
else
goto single;
}
- if (!strcmp (cp, "all"))
+ if (!strcmp(cp, "all"))
cp = "first-last";
- if ((err = first = m_conv (mp, cp, FIRST)) <= 0)
+ if ((err = first = m_conv(mp, cp, FIRST)) <= 0)
goto badmsg;
cp = delimp;
if (*cp != '\0' && *cp != '-' && *cp != ':') {
badelim:
- advise (NULL, "illegal argument delimiter: `%c'(0%o)",
+ advise(NULL, "illegal argument delimiter: `%c'(0%o)",
*delimp, *delimp);
return 0;
}
if (*cp == '-') {
cp++;
- if ((err = last = m_conv (mp, cp, LAST)) <= 0) {
+ if ((err = last = m_conv(mp, cp, LAST)) <= 0) {
badmsg:
switch (err) {
case BADMSG:
- advise (NULL, "no %s message", cp);
+ advise(NULL, "no %s message", cp);
break;
case BADNUM:
- advise (NULL, "message %s doesn't exist", cp);
+ advise(NULL, "message %s doesn't exist", cp);
break;
case BADRNG:
- advise (NULL, "message %s out of range 1-%d",
+ advise(NULL, "message %s out of range 1-%d",
cp, mp->hghmsg);
break;
case BADLST:
badlist:
- advise (NULL, "bad message list %s", name);
+ advise(NULL, "bad message list %s", name);
break;
case BADNEW:
- advise (NULL, "folder full, no %s message",
+ advise(NULL, "folder full, no %s message",
name);
break;
default:
- advise (NULL, "no messages match specification");
+ advise(NULL, "no messages match specification");
}
return 0;
}
goto badelim;
if (first > mp->hghmsg || last < mp->lowmsg) {
rangerr:
- advise (NULL, "no messages in range %s", name);
+ advise(NULL, "no messages in range %s", name);
return 0;
}
convdir = 1;
cp++;
}
- if ((range = atoi (bp = cp)) == 0)
+ if ((range = atoi(bp = cp)) == 0)
goto badlist;
- while (isdigit (*bp))
+ while (isdigit(*bp))
bp++;
if (*bp)
goto badelim;
for (last = first; last >= mp->lowmsg && last <= mp->hghmsg;
last += convdir)
- if (does_exist (mp, last))
+ if (does_exist(mp, last))
if (--range <= 0)
break;
if (last < mp->lowmsg)
** check if message is in-range and exists.
*/
if (mp->msgflags & ALLOW_NEW) {
- set_select_empty (mp, first);
+ set_select_empty(mp, first);
} else {
if (first > mp->hghmsg
|| first < mp->lowmsg
- || !(does_exist (mp, first))) {
- if (!strcmp (name, "cur") || !strcmp (name, "."))
- advise (NULL, "no %s message", name);
+ || !(does_exist(mp, first))) {
+ if (!strcmp(name, "cur") || !strcmp(name, "."))
+ advise(NULL, "no %s message", name);
else
- advise (NULL, "message %d doesn't exist", first);
+ advise(NULL, "message %d doesn't exist", first);
return 0;
}
}
** 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))) {
- if (!is_selected (mp, first)) {
- set_selected (mp, first);
+ if (does_exist(mp, first) ||
+ ((mp->msgflags & ALLOW_NEW) && is_select_empty(mp, first))) {
+ if (!is_selected(mp, first)) {
+ set_selected(mp, first);
mp->numsel++;
if (mp->lowsel == 0 || first < mp->lowsel)
mp->lowsel = first;
*/
static int
-m_conv (struct msgs *mp, char *str, int call)
+m_conv(struct msgs *mp, char *str, int call)
{
register int i;
register unsigned char *cp, *bp;
convdir = 1;
cp = bp = str;
- if (isdigit (*cp)) {
- while (isdigit (*bp))
+ if (isdigit(*cp)) {
+ while (isdigit(*bp))
bp++;
delimp = bp;
- i = atoi (cp);
+ i = atoi(cp);
if (i <= mp->hghmsg)
return i;
*bp++ = '\0';
delimp = cp;
- if (!strcmp (buf, "first"))
+ if (!strcmp(buf, "first"))
return (mp->hghmsg || !(mp->msgflags & ALLOW_NEW)
? mp->lowmsg : BADMSG);
- if (!strcmp (buf, "last")) {
+ if (!strcmp(buf, "last")) {
convdir = -1;
return (mp->hghmsg || !(mp->msgflags & ALLOW_NEW) ? mp->hghmsg : BADMSG);
}
- if (!strcmp (buf, "cur") || !strcmp (buf, "."))
+ if (!strcmp(buf, "cur") || !strcmp(buf, "."))
return (mp->curmsg > 0 ? mp->curmsg : BADMSG);
- if (!strcmp (buf, "prev")) {
+ if (!strcmp(buf, "prev")) {
convdir = -1;
for (i = (mp->curmsg <= mp->hghmsg) ? mp->curmsg - 1 : mp->hghmsg;
i >= mp->lowmsg; i--) {
- if (does_exist (mp, i))
+ if (does_exist(mp, i))
return i;
}
return BADMSG;
}
- if (!strcmp (buf, "next")) {
+ if (!strcmp(buf, "next")) {
for (i = (mp->curmsg >= mp->lowmsg) ? mp->curmsg + 1 : mp->lowmsg;
i <= mp->hghmsg; i++) {
- if (does_exist (mp, i))
+ if (does_exist(mp, i))
return i;
}
return BADMSG;
*/
static int
-attr (struct msgs *mp, char *cp)
+attr(struct msgs *mp, char *cp)
{
register unsigned char *dp;
char *bp = NULL;
int first = 0;
/* hack for "cur-name", "cur-n", etc. */
- if (!strcmp (cp, "cur"))
+ if (!strcmp(cp, "cur"))
return 0;
- if (ssequal ("cur:", cp)) /* this code need to be rewritten... */
+ if (ssequal("cur:", cp)) /* this code need to be rewritten... */
return 0;
/* Check for sequence negation */
- if ((dp = context_find (nsequence)) && *dp != '\0' && ssequal (dp, cp)) {
+ if ((dp = context_find(nsequence)) && *dp != '\0' && ssequal(dp, cp)) {
inverted = 1;
- cp += strlen (dp);
+ cp += strlen(dp);
}
convdir = 1; /* convert direction */
** seq:first (or)
** seq:last
*/
- if (isalpha (*dp)) {
- if (!strcmp (dp, "prev")) {
+ if (isalpha(*dp)) {
+ if (!strcmp(dp, "prev")) {
convdir = -1;
first = (mp->curmsg > 0) && (mp->curmsg <= mp->hghmsg)
? mp->curmsg - 1 : mp->hghmsg;
- } else if (!strcmp (dp, "next")) {
+ } else if (!strcmp(dp, "next")) {
convdir = 1;
first = (mp->curmsg >= mp->lowmsg)
? mp->curmsg + 1 : mp->lowmsg;
- } else if (!strcmp (dp, "first")) {
+ } else if (!strcmp(dp, "first")) {
convdir = 1;
- } else if (!strcmp (dp, "last")) {
+ } else if (!strcmp(dp, "last")) {
convdir = -1;
} else
return BADLST;
}
if ((range = atoi(dp)) == 0)
return BADLST;
- while (isdigit (*dp))
+ while (isdigit(*dp))
dp++;
if (*dp)
return BADLST;
*bp = '\0'; /* temporarily terminate sequence name */
}
- i = seq_getnum (mp, cp); /* get index of sequence */
+ i = seq_getnum(mp, cp); /* get index of sequence */
if (bp)
*bp = ':'; /* restore sequence name */
for (j = first ? first : (convdir > 0) ? mp->lowmsg : mp->hghmsg;
j >= mp->lowmsg && j <= mp->hghmsg; j += convdir) {
- if (does_exist (mp, j)
- && inverted ? !in_sequence (mp, i, j) : in_sequence (mp, i, j)) {
- if (!is_selected (mp, j)) {
- set_selected (mp, j);
+ if (does_exist(mp, j)
+ && inverted ? !in_sequence(mp, i, j) : in_sequence(mp, i, j)) {
+ if (!is_selected(mp, j)) {
+ set_selected(mp, j);
mp->numsel++;
if (mp->lowsel == 0 || j < mp->lowsel)
mp->lowsel = j;
if (first)
return BADMSG;
- advise (NULL, "sequence %s %s", cp, inverted ? "full" : "empty");
+ advise(NULL, "sequence %s %s", cp, inverted ? "full" : "empty");
return -1;
}
char *folder;
cp = draftfolder;
- folder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
+ folder = path(*cp == '+' || *cp == '@' ? cp + 1 : cp,
*cp != '@' ? TFOLDER : TSUBCWF);
- chdir (m_maildir (""));
- strncpy (buffer, m_maildir (folder), sizeof(buffer));
+ chdir(m_maildir(""));
+ strncpy(buffer, m_maildir(folder), sizeof(buffer));
- create_folder (buffer, 0, done);
+ create_folder(buffer, 0, done);
- if (chdir (buffer) == -1)
- adios (buffer, "unable to change directory to");
+ if (chdir(buffer) == -1)
+ adios(buffer, "unable to change directory to");
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/*
** Make sure we have enough message status space for all
** 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");
+ if (!(mp = folder_realloc(mp, 1, mp->hghmsg + 10)))
+ adios(NULL, "unable to allocate folder storage");
} else if (mp->lowoff > 1) {
- if (!(mp = folder_realloc (mp, 1, mp->hghoff)))
- adios (NULL, "unable to allocate folder storage");
+ if (!(mp = folder_realloc(mp, 1, mp->hghoff)))
+ adios(NULL, "unable to allocate folder storage");
}
mp->msgflags |= ALLOW_NEW; /* allow the "new" sequence */
** 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);
+ if (!m_convert(mp, which))
+ done(1);
+ seq_setprev(mp);
- snprintf (buffer, sizeof(buffer), "%s/%s", mp->foldpath,
- m_name (mp->lowsel));
- seq_setcur (mp, mp->lowsel);
- seq_save (mp);
- folder_free (mp);
+ snprintf(buffer, sizeof(buffer), "%s/%s", mp->foldpath,
+ m_name(mp->lowsel));
+ seq_setcur(mp, mp->lowsel);
+ seq_save(mp);
+ folder_free(mp);
return buffer;
}
** This worked fine, until one day: a message with no body portion arrived.
** Then the
**
-** while (eom (c = Getc (iob), iob))
+** while (eom(c = Getc(iob), iob))
** continue;
**
** loop caused m_getfld() to return FMTERR. So, that logic was changed to
/*
** static prototypes
*/
-static int m_Eom (int, FILE *);
+static int m_Eom(int, FILE *);
static unsigned char *matchc(int, char *, int, char *);
static unsigned char *locc(int, unsigned char *, unsigned char);
int
-m_getfld (int state, unsigned char *name, unsigned char *buf,
+m_getfld(int state, unsigned char *name, unsigned char *buf,
int bufsz, FILE *iob)
{
register unsigned char *bp, *cp, *ep, *sp;
*buf = 0;
return FILEEOF;
}
- if (eom (c, iob)) {
+ if (eom(c, iob)) {
if (! eom_action) {
/* flush null messages */
- while ((c = Getc(iob)) >= 0 && eom (c, iob))
+ while ((c = Getc(iob)) >= 0 && eom(c, iob))
;
if (c >= 0)
ungetc(c, iob);
while (c != '\n' && (c = Getc(iob)) >= 0)
;
- if (c < 0 || (c = Getc(iob)) < 0 || eom (c, iob)) {
+ if (c < 0 || (c = Getc(iob)) < 0 || eom(c, iob)) {
if (! eom_action) {
/* flush null messages */
- while ((c = Getc(iob)) >= 0 && eom (c, iob))
+ while ((c = Getc(iob)) >= 0 && eom(c, iob))
;
if (c >= 0)
ungetc(c, iob);
if (_filbuf(iob) == EOF) {
#endif
*cp = *buf = 0;
- advise (NULL, "eof encountered in field \"%s\"", name);
+ advise(NULL, "eof encountered in field \"%s\"", name);
return FMTERR;
}
#ifdef LINUX_STDIO
** guess we'll blow up.
*/
*cp = *buf = 0;
- advise (NULL, "eol encountered in field \"%s\"", name);
+ advise(NULL, "eol encountered in field \"%s\"", name);
state = FMTERR;
goto finish;
}
- memcpy (buf, name, j - 1);
+ memcpy(buf, name, j - 1);
buf[j - 1] = '\n';
buf[j] = '\0';
/*
** should be harmless enough, right?
** This is a corrupt message anyway.
*/
- fseek (iob, ftell (iob) - 2, SEEK_SET);
+ fseek(iob, ftell(iob) - 2, SEEK_SET);
return BODY;
}
if ((i -= j) <= 0) {
*cp = *buf = 0;
- advise (NULL, "field name \"%s\" exceeds %d bytes", name, NAMESZ - 2);
+ advise(NULL, "field name \"%s\" exceeds %d bytes", name, NAMESZ - 2);
state = LENERR;
goto finish;
}
}
- while (isspace (*--cp) && cp >= name)
+ while (isspace(*--cp) && cp >= name)
;
*++cp = 0;
/* fall through */
if ((j = *++ep) != ' ' && j != '\t') {
#ifdef LINUX_STDIO
j = ep - (unsigned char *) iob->_IO_read_ptr;
- memcpy (cp, iob->_IO_read_ptr, j);
+ memcpy(cp, iob->_IO_read_ptr, j);
iob->_IO_read_ptr = ep;
#elif defined(__DragonFly__)
j = ep - (unsigned char *) ((struct __FILE_public *)iob)->_p;
- memcpy (cp, ((struct __FILE_public *)iob)->_p, j);
+ memcpy(cp, ((struct __FILE_public *)iob)->_p, j);
((struct __FILE_public *)iob)->_p = ep;
((struct __FILE_public *)iob)->_r -= j;
#else
j = ep - (unsigned char *) iob->_ptr;
- memcpy (cp, iob->_ptr, j);
+ memcpy(cp, iob->_ptr, j);
iob->_ptr = ep;
iob->_cnt -= j;
#endif
*/
#ifdef LINUX_STDIO
c += bp - (unsigned char *) iob->_IO_read_ptr;
- memcpy( cp, iob->_IO_read_ptr, c);
+ memcpy(cp, iob->_IO_read_ptr, c);
#elif defined(__DragonFly__)
c += bp - (unsigned char *) ((struct __FILE_public *)iob)->_p;
- memcpy( cp, ((struct __FILE_public *)iob)->_p, c);
+ memcpy(cp, ((struct __FILE_public *)iob)->_p, c);
#else
c += bp - (unsigned char *) iob->_ptr;
- memcpy( cp, iob->_ptr, c);
+ memcpy(cp, iob->_ptr, c);
#endif
i -= c;
cp += c;
break;
default:
- adios (NULL, "m_getfld() called with bogus state of %d", state);
+ adios(NULL, "m_getfld() called with bogus state of %d", state);
}
finish:
*cp = 0;
msg_style = MS_UNKNOWN;
- pos = ftell (iob);
- if (fread (text, sizeof(*text), 5, iob) == 5
- && strncmp (text, "From ", 5) == 0) {
+ pos = ftell(iob);
+ if (fread(text, sizeof(*text), 5, iob) == 5
+ && strncmp(text, "From ", 5) == 0) {
msg_style = MS_MBOX;
delimstr = "\nFrom ";
#ifndef RPATHS
- while ((c = getc (iob)) != '\n' && c >= 0)
+ while ((c = getc(iob)) != '\n' && c >= 0)
;
#else /* RPATHS */
cp = unixbuf;
- while ((c = getc (iob)) != '\n' && cp - unixbuf < BUFSIZ - 1)
+ while ((c = getc(iob)) != '\n' && cp - unixbuf < BUFSIZ - 1)
*cp++ = c;
*cp = 0;
#endif /* RPATHS */
} else {
/* not a Unix style maildrop */
- fseek (iob, pos, SEEK_SET);
+ fseek(iob, pos, SEEK_SET);
if (mmdlm2 == NULL || *mmdlm2 == 0)
mmdlm2 = "\001\001\001\001\n";
delimstr = mmdlm2;
msg_style = MS_MMDF;
}
- c = strlen (delimstr);
+ c = strlen(delimstr);
fdelim = (unsigned char *) mh_xmalloc((size_t) (c + 3));
*fdelim++ = '\0';
*fdelim = '\n';
edelim = (unsigned char *)msg_delim+1;
fdelimlen = c + 1;
edelimlen = c - 1;
- strcpy (msg_delim, delimstr);
+ strcpy(msg_delim, delimstr);
delimend = (unsigned char *)msg_delim + edelimlen;
if (edelimlen <= 1)
- adios (NULL, "maildrop delimiter must be at least 2 bytes");
+ 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).
*/
- pat_map = (unsigned char **) calloc (256, sizeof(unsigned char *));
+ pat_map = (unsigned char **) calloc(256, sizeof(unsigned char *));
for (cp = (char *) fdelim + 1; cp < (char *) delimend; cp++ )
pat_map[(unsigned char)*cp] = (unsigned char *) cp;
if (msg_style == MS_MMDF) {
/* flush extra msg hdrs */
- while ((c = Getc(iob)) >= 0 && eom (c, iob))
+ while ((c = Getc(iob)) >= 0 && eom(c, iob))
;
if (c >= 0)
ungetc(c, iob);
*/
static int
-m_Eom (int c, FILE *iob)
+m_Eom(int c, FILE *iob)
{
register long pos = 0L;
register int i;
register char *cp;
#endif /* RPATHS */
- pos = ftell (iob);
- if ((i = fread (text, sizeof *text, edelimlen, iob)) != edelimlen
- || strncmp (text, (char *)edelim, edelimlen)) {
+ pos = ftell(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
return 1;
#if 0
- fseek (iob, pos, SEEK_SET);
+ fseek(iob, pos, SEEK_SET);
#endif
- fseek (iob, (long)(pos-1), SEEK_SET);
- getc (iob); /* should be OK */
+ fseek(iob, (long)(pos-1), SEEK_SET);
+ getc(iob); /* should be OK */
return 0;
}
if (msg_style == MS_MBOX) {
#ifndef RPATHS
- while ((c = getc (iob)) != '\n')
+ while ((c = getc(iob)) != '\n')
if (c < 0)
break;
#else /* RPATHS */
cp = unixbuf;
- while ((c = getc (iob)) != '\n' && c >= 0 && cp - unixbuf < BUFSIZ - 1)
+ while ((c = getc(iob)) != '\n' && c >= 0 && cp - unixbuf < BUFSIZ - 1)
*cp++ = c;
*cp = 0;
#endif /* RPATHS */
*/
int
-get_returnpath (char *rp, int rplen, char *dd, int ddlen)
+get_returnpath(char *rp, int rplen, char *dd, int ddlen)
{
char *ap, *bp, *cp, *dp;
** if this message uses UUCP style addressing
*/
while ((cp = strchr(++cp, 'r'))) {
- if (strncmp (cp, "remote from", 11) == 0) {
- cp = strrchr (cp, ' ');
+ if (strncmp(cp, "remote from", 11) == 0) {
+ cp = strrchr(cp, ' ');
break;
}
}
*/
if (cp) {
/* return path for UUCP style addressing */
- dp = strchr (++cp, '\n');
- snprintf (rp, rplen, "%.*s!%.*s\n", (int)(dp - cp), cp, (int)(bp - ap), ap);
+ dp = strchr(++cp, '\n');
+ snprintf(rp, rplen, "%.*s!%.*s\n", (int)(dp - cp), cp, (int)(bp - ap), ap);
} else {
/* return path for standard domain addressing */
- snprintf (rp, rplen, "%.*s\n", (int)(bp - ap), ap);
+ snprintf(rp, rplen, "%.*s\n", (int)(bp - ap), ap);
}
/*
bp++;
/* Now get delivery date from envelope */
- snprintf (dd, ddlen, "%.*s\n", 24, bp);
+ snprintf(dd, ddlen, "%.*s\n", 24, bp);
unixbuf[0] = 0;
return 1;
int
-m_gmprot (void)
+m_gmprot(void)
{
register char *cp;
- return atooi ((cp = context_find ("msg-protect")) && *cp ? cp : msgprot);
+ return atooi ((cp = context_find("msg-protect")) && *cp ? cp : msgprot);
}
/*
** static prototypes
*/
-static char *exmaildir (char *);
+static char *exmaildir(char *);
char *
-m_maildir (char *folder)
+m_maildir(char *folder)
{
register char *cp, *ep;
- if ((cp = exmaildir (folder))
- && (ep = cp + strlen (cp) - 1) > cp
+ if ((cp = exmaildir(folder))
+ && (ep = cp + strlen(cp) - 1) > cp
&& *ep == '/')
*ep = '\0';
char *
-m_mailpath (char *folder)
+m_mailpath(char *folder)
{
register char *cp;
char maildir[BUFSIZ];
if (*folder != '/'
- && strncmp (folder, CWD, NCWD)
- && strcmp (folder, DOT)
- && strcmp (folder, DOTDOT)
- && strncmp (folder, PWD, NPWD)) {
- strncpy (maildir, mailfold, sizeof(maildir)); /* preserve... */
- cp = getcpy (m_maildir (folder));
- strncpy (mailfold, maildir, sizeof(mailfold));
+ && strncmp(folder, CWD, NCWD)
+ && strcmp(folder, DOT)
+ && strcmp(folder, DOTDOT)
+ && strncmp(folder, PWD, NPWD)) {
+ strncpy(maildir, mailfold, sizeof(maildir)); /* preserve... */
+ cp = getcpy(m_maildir(folder));
+ strncpy(mailfold, maildir, sizeof(mailfold));
} else {
- cp = path (folder, TFOLDER);
+ cp = path(folder, TFOLDER);
}
return cp;
static char *
-exmaildir (char *folder)
+exmaildir(char *folder)
{
register char *cp, *pp;
if (folder == NULL)
folder = getfolder(1);
- if (!(*folder != '/'
- && strncmp (folder, CWD, NCWD)
- && strcmp (folder, DOT)
- && strcmp (folder, DOTDOT)
- && strncmp (folder, PWD, NPWD))) {
- strncpy (mailfold, folder, sizeof(mailfold));
+ if (!(*folder != '/' && strncmp(folder, CWD, NCWD)
+ && strcmp(folder, DOT) && strcmp(folder, DOTDOT)
+ && strncmp(folder, PWD, NPWD))) {
+ strncpy(mailfold, folder, sizeof(mailfold));
return mailfold;
}
cp = mailfold;
- if ((pp = context_find ("path")) && *pp) {
+ if ((pp = context_find("path")) && *pp) {
if (*pp != '/') {
- sprintf (cp, "%s/", mypath);
- cp += strlen (cp);
+ sprintf(cp, "%s/", mypath);
+ cp += strlen(cp);
}
- cp = copy (pp, cp);
+ cp = copy(pp, cp);
} else {
- cp = copy (path ("./", TFOLDER), cp);
+ cp = copy(path("./", TFOLDER), cp);
}
if (cp[-1] != '/')
*cp++ = '/';
- strcpy (cp, folder);
+ strcpy(cp, folder);
return mailfold;
}
** char *tmp_pathname = m_mktemp2(NULL, "mypre", ...);
*/
char *
-m_mktemp (
+m_mktemp(
const char *pfx_in, /* Pathname prefix for temporary file. */
int *fd_ret, /* (return,opt.) File descriptor to temp file. */
FILE **fp_ret /* (return,opt.) FILE pointer to temp file. */
** above) is used to create the temp file.
*/
char *
-m_mktemp2 (
+m_mktemp2(
const char *dir_in, /* Directory to place temp file. */
const char *pfx_in, /* Basename prefix for temp file. */
int *fd_ret, /* (return,opt.) File descriptor to temp file. */
return m_mktemp(buffer, fd_ret, fp_ret);
}
- if ((cp = r1bindex ((char *)dir_in, '/')) == dir_in) {
+ if ((cp = r1bindex((char *)dir_in, '/')) == dir_in) {
/* No directory component */
return m_mktemp(pfx_in, fd_ret, fp_ret);
}
char *
-m_name (int num)
+m_name(int num)
{
if (num <= 0)
return "?";
- snprintf (name, sizeof(name), "%d", num);
+ snprintf(name, sizeof(name), "%d", num);
return name;
}
#include <sys/file.h>
int
-makedir (char *dir)
+makedir(char *dir)
{
char path[PATH_MAX];
char* folder_perms_ASCII;
context_save(); /* save the context file */
fflush(stdout);
- if (!(folder_perms_ASCII = context_find ("folder-protect")))
+ if (!(folder_perms_ASCII = context_find("folder-protect")))
folder_perms_ASCII = foldprot; /* defaults to "700" */
/*
*/
saved_umask = umask(0);
- if (getuid () == geteuid ()) {
+ if (getuid() == geteuid()) {
c = strncpy(path, dir, sizeof(path));
while (!had_an_error && (c = strchr((c + 1), '/')) != NULL) {
*c = (char)0;
if (access(path, X_OK)) {
if (errno != ENOENT){
- advise (dir, "unable to create directory");
+ advise(dir, "unable to create directory");
had_an_error = 1;
}
/* Create an outer directory. */
if (mkdir(path, folder_perms)) {
- advise (dir, "unable to create directory");
+ advise(dir, "unable to create directory");
had_an_error = 1;
}
}
** 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");
+ if (mkdir(dir, folder_perms) == -1) {
+ advise(dir, "unable to create directory");
had_an_error = 1;
}
}
} else {
- /* Ummm, why do we want to avoid creating directories with the effective
- user ID? None of the nmh tools are installed such that the effective
- should be different from the real, and if some parent process made
- the two be different, I don't see why it should be our job to enforce
- the real UID. Also, why the heck do we call the mkdir executable
- rather than the library function in this case?? If we do want to
- call the mkdir executable, we should at least be giving it -p (and
- change the single chmod() call below) so it can successfully create
- nested directories like the above code can.
-
- -- Dan Harkless <dan-nmh@dilvish.speed.net> */
+ /*
+ ** Ummm, why do we want to avoid creating directories
+ ** with the effective user ID? None of the nmh tools are
+ ** installed such that the effective should be different
+ ** from the real, and if some parent process made the two
+ ** be different, I don't see why it should be our job to
+ ** enforce the real UID. Also, why the heck do we call
+ ** the mkdir executable rather than the library function in
+ ** this case?? If we do want to call the mkdir executable,
+ ** we should at least be giving it -p (and change the single
+ ** chmod() call below) so it can successfully create nested
+ ** directories like the above code can.
+ ** -- Dan Harkless <dan-nmh@dilvish.speed.net>
+ */
switch (pid = vfork()) {
case -1:
- advise ("fork", "unable to");
+ advise("fork", "unable to");
return 0;
case 0:
- setgid (getgid ());
- setuid (getuid ());
+ setgid(getgid());
+ setuid(getuid());
- execl ("/bin/mkdir", "mkdir", dir, NULL);
- execl ("/usr/bin/mkdir", "mkdir", dir, NULL);
- fprintf (stderr, "unable to exec ");
- perror ("mkdir");
- _exit (-1);
+ execl("/bin/mkdir", "mkdir", dir, NULL);
+ execl("/usr/bin/mkdir", "mkdir", dir, NULL);
+ fprintf(stderr, "unable to exec ");
+ perror("mkdir");
+ _exit(-1);
default:
if (pidXwait(pid, "mkdir"))
break;
}
- chmod (dir, folder_perms);
+ chmod(dir, folder_perms);
}
umask(saved_umask); /* put the user's umask back */
/*
** static prototypes
*/
-static char *getcpy (char *);
-static int isat (char *);
-static int parse_address (void);
-static int phrase (char *);
-static int route_addr (char *);
-static int local_part (char *);
-static int domain (char *);
-static int route (char *);
-static int my_lex (char *);
+static char *getcpy(char *);
+static int isat(char *);
+static int parse_address(void);
+static int phrase(char *);
+static int route_addr(char *);
+static int local_part(char *);
+static int domain(char *);
+static int route(char *);
+static int my_lex(char *);
static char *
-getcpy (char *s)
+getcpy(char *s)
{
register char *p;
for(;;)
pause();
}
- p = mh_xmalloc ((size_t) (strlen (s) + 2));
- strcpy (p, s);
+ p = mh_xmalloc((size_t) (strlen(s) + 2));
+ strcpy(p, s);
return p;
}
static int
-isat (char *p)
+isat(char *p)
{
- return (strncmp (p, " AT ", 4)
- && strncmp (p, " At ", 4)
- && strncmp (p, " aT ", 4)
- && strncmp (p, " at ", 4) ? FALSE : TRUE);
+ return (strncmp(p, " AT ", 4)
+ && strncmp(p, " At ", 4)
+ && strncmp(p, " aT ", 4)
+ && strncmp(p, " at ", 4) ? FALSE : TRUE);
}
struct adrx *
-getadrx (char *addrs)
+getadrx(char *addrs)
{
register char *bp;
register struct adrx *adrxp = &adrxs2;
if (pers)
- free (pers);
+ free(pers);
if (mbox)
- free (mbox);
+ free(mbox);
if (host)
- free (host);
+ free(host);
if (path)
- free (path);
+ free(path);
if (grp)
- free (grp);
+ free(grp);
if (note)
- free (note);
+ free(note);
pers = mbox = host = path = grp = note = NULL;
err[0] = 0;
if (dp == NULL) {
- dp = cp = getcpy (addrs ? addrs : "");
+ dp = cp = getcpy(addrs ? addrs : "");
glevel = 0;
} else if (cp == NULL) {
- free (dp);
+ free(dp);
dp = NULL;
return NULL;
}
- switch (parse_address ()) {
+ switch (parse_address()) {
case DONE:
- free (dp);
+ free(dp);
dp = cp = NULL;
return NULL;
default: /* catch trailing comments */
bp = cp;
- my_lex (adr);
+ my_lex(adr);
cp = bp;
break;
}
break;
default:
- my_lex (adr);
+ my_lex(adr);
continue;
}
break;
}
- while (isspace (*ap))
+ while (isspace(*ap))
ap++;
if (cp)
- sprintf (adr, "%.*s", (int)(cp - ap), ap);
+ sprintf(adr, "%.*s", (int)(cp - ap), ap);
else
- strcpy (adr, ap);
- bp = adr + strlen (adr) - 1;
+ strcpy(adr, ap);
+ bp = adr + strlen(adr) - 1;
if (*bp == ',' || *bp == ';' || *bp == '\n')
*bp = 0;
static int
-parse_address (void)
+parse_address(void)
{
char buffer[BUFSIZ];
again: ;
ap = cp;
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_ATOM:
case LX_QSTR:
- pers = getcpy (buffer);
+ pers = getcpy(buffer);
break;
case LX_SEMI:
if (glevel-- <= 0) {
- strcpy (err, "extraneous semi-colon");
+ strcpy(err, "extraneous semi-colon");
return NOTOK;
}
case LX_COMA:
if (note) {
- free (note);
+ free(note);
note = NULL;
}
goto again;
case LX_AT: /* sigh (3) */
cp = ap;
- if (route_addr (buffer) == NOTOK)
+ if (route_addr(buffer) == NOTOK)
return NOTOK;
return OK; /* why be choosy? */
default:
- sprintf (err, "illegal address construct (%s)", buffer);
+ sprintf(err, "illegal address construct (%s)", buffer);
return NOTOK;
}
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_ATOM:
case LX_QSTR:
- pers = add (buffer, add (" ", pers));
+ pers = add(buffer, add(" ", pers));
more_phrase: ; /* sigh (1) */
- if (phrase (buffer) == NOTOK)
+ if (phrase(buffer) == NOTOK)
return NOTOK;
switch (last_lex) {
case LX_LBRK:
get_addr: ;
- if (route_addr (buffer) == NOTOK)
+ if (route_addr(buffer) == NOTOK)
return NOTOK;
if (last_lex == LX_RBRK)
return OK;
- sprintf (err, "missing right-bracket (%s)", buffer);
+ sprintf(err, "missing right-bracket (%s)", buffer);
return NOTOK;
case LX_COLN:
get_group: ;
if (glevel++ > 0) {
- sprintf (err, "nested groups not allowed (%s)", pers);
+ sprintf(err, "nested groups not allowed (%s)", pers);
return NOTOK;
}
- grp = add (": ", pers);
+ grp = add(": ", pers);
pers = NULL;
{
char *pp = cp;
for (;;)
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_SEMI:
case LX_END: /* tsk, tsk */
glevel--;
default:
cp = pp;
- return parse_address ();
+ return parse_address();
}
}
case LX_DOT: /* sigh (1) */
- pers = add (".", pers);
+ pers = add(".", pers);
goto more_phrase;
default:
- sprintf (err, "no mailbox in address, only a phrase (%s%s)", pers, buffer);
+ sprintf(err, "no mailbox in address, only a phrase (%s%s)", pers, buffer);
return NOTOK;
}
goto get_group;
case LX_DOT:
- mbox = add (buffer, pers);
+ mbox = add(buffer, pers);
pers = NULL;
- if (route_addr (buffer) == NOTOK)
+ if (route_addr(buffer) == NOTOK)
return NOTOK;
goto check_end;
ingrp = glevel;
mbox = pers;
pers = NULL;
- if (domain (buffer) == NOTOK)
+ if (domain(buffer) == NOTOK)
return NOTOK;
check_end: ;
switch (last_lex) {
case LX_SEMI:
if (glevel-- <= 0) {
- strcpy (err, "extraneous semi-colon");
+ strcpy(err, "extraneous semi-colon");
return NOTOK;
}
case LX_COMA:
return OK;
default:
- sprintf (err, "junk after local@domain (%s)", buffer);
+ sprintf(err, "junk after local@domain (%s)", buffer);
return NOTOK;
}
case LX_END:
ingrp = glevel;
if (last_lex == LX_SEMI && glevel-- <= 0) {
- strcpy (err, "extraneous semi-colon");
+ strcpy(err, "extraneous semi-colon");
return NOTOK;
}
mbox = pers;
return OK;
default:
- sprintf (err, "missing mailbox (%s)", buffer);
+ sprintf(err, "missing mailbox (%s)", buffer);
return NOTOK;
}
}
static int
-phrase (char *buffer)
+phrase(char *buffer)
{
for (;;)
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_ATOM:
case LX_QSTR:
- pers = add (buffer, add (" ", pers));
+ pers = add(buffer, add(" ", pers));
continue;
default:
static int
-route_addr (char *buffer)
+route_addr(char *buffer)
{
register char *pp = cp;
- if (my_lex (buffer) == LX_AT) {
- if (route (buffer) == NOTOK)
+ if (my_lex(buffer) == LX_AT) {
+ if (route(buffer) == NOTOK)
return NOTOK;
}
else
cp = pp;
- if (local_part (buffer) == NOTOK)
+ if (local_part(buffer) == NOTOK)
return NOTOK;
switch (last_lex) {
case LX_AT:
- return domain (buffer);
+ return domain(buffer);
case LX_SEMI: /* if in group */
case LX_RBRK: /* no host */
return OK;
default:
- sprintf (err, "no at-sign after local-part (%s)", buffer);
+ sprintf(err, "no at-sign after local-part (%s)", buffer);
return NOTOK;
}
}
static int
-local_part (char *buffer)
+local_part(char *buffer)
{
ingrp = glevel;
for (;;) {
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_ATOM:
case LX_QSTR:
- mbox = add (buffer, mbox);
+ mbox = add(buffer, mbox);
break;
default:
- sprintf (err, "no mailbox in local-part (%s)",
+ sprintf(err, "no mailbox in local-part (%s)",
buffer);
return NOTOK;
}
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_DOT:
- mbox = add (buffer, mbox);
+ mbox = add(buffer, mbox);
continue;
default:
static int
-domain (char *buffer)
+domain(char *buffer)
{
for (;;) {
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_ATOM:
case LX_DLIT:
- host = add (buffer, host);
+ host = add(buffer, host);
break;
default:
- sprintf (err, "no sub-domain in domain-part of address (%s)", buffer);
+ sprintf(err, "no sub-domain in domain-part of address (%s)", buffer);
return NOTOK;
}
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_DOT:
- host = add (buffer, host);
+ host = add(buffer, host);
continue;
case LX_AT: /* sigh (0) */
- mbox = add (host, add ("%", mbox));
- free (host);
+ mbox = add(host, add("%", mbox));
+ free(host);
host = NULL;
continue;
static int
-route (char *buffer)
+route(char *buffer)
{
- path = getcpy ("@");
+ path = getcpy("@");
for (;;) {
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_ATOM:
case LX_DLIT:
- path = add (buffer, path);
+ path = add(buffer, path);
break;
default:
- sprintf (err, "no sub-domain in domain-part of address (%s)", buffer);
+ sprintf(err, "no sub-domain in domain-part of address (%s)", buffer);
return NOTOK;
}
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_COMA:
- path = add (buffer, path);
+ path = add(buffer, path);
for (;;) {
- switch (my_lex (buffer)) {
+ switch (my_lex(buffer)) {
case LX_COMA:
continue;
case LX_AT:
- path = add (buffer, path);
+ path = add(buffer, path);
break;
default:
- sprintf (err, "no at-sign found for next domain in route (%s)",
+ sprintf(err, "no at-sign found for next domain in route (%s)",
buffer);
}
break;
case LX_AT: /* XXX */
case LX_DOT:
- path = add (buffer, path);
+ path = add(buffer, path);
continue;
case LX_COLN:
- path = add (buffer, path);
+ path = add(buffer, path);
return OK;
default:
- sprintf (err, "no colon found to terminate route (%s)", buffer);
+ sprintf(err, "no colon found to terminate route (%s)", buffer);
return NOTOK;
}
}
static int
-my_lex (char *buffer)
+my_lex(char *buffer)
{
/* buffer should be at least BUFSIZ bytes long */
int i, gotat = 0;
if (!cp)
return (last_lex = LX_END);
- gotat = isat (cp);
+ gotat = isat(cp);
c = *cp++;
- while (isspace (c))
+ while (isspace(c))
c = *cp++;
if (c == 0) {
cp = NULL;
ADDCHR(c);
if (--i < 0) {
*bp = 0;
- note = note ? add (buffer, add (" ", note))
- : getcpy (buffer);
- return my_lex (buffer);
+ note = note ? add(buffer, add(" ", note)) : getcpy(buffer);
+ return my_lex(buffer);
}
}
}
if (c == special[i].lx_chr)
return (last_lex = special[i].lx_val);
- if (iscntrl (c))
+ if (iscntrl(c))
return (last_lex = LX_ERR);
for (;;) {
for (i = 0; special[i].lx_chr != 0; i++)
if (c == special[i].lx_chr)
goto got_atom;
- if (iscntrl (c) || isspace (c))
+ if (iscntrl(c) || isspace(c))
break;
ADDCHR(c);
}
char *
-legal_person (char *p)
+legal_person(char *p)
{
int i;
register char *cp;
for (cp = p; *cp; cp++)
for (i = 0; special[i].lx_chr; i++)
if (*cp == special[i].lx_chr) {
- sprintf (buffer, "\"%s\"", p);
+ sprintf(buffer, "\"%s\"", p);
return buffer;
}
/*
** static prototypes
*/
-static char *tailor_value (unsigned char *);
-static void getuserinfo (void);
+static char *tailor_value(unsigned char *);
+static void getuserinfo(void);
static const char *get_mtsconf_pathname(void);
static const char *get_mtsuserconf_pathname(void);
-static void mts_read_conf_file (FILE *fp);
+static void mts_read_conf_file(FILE *fp);
/*
** *mmdfldir and *uucpldir are the maildrop directories. If maildrops
*/
void
-mts_init (char *name)
+mts_init(char *name)
{
const char *cp;
FILE *fp;
static int inited = 0;
- if (inited++ || (fp = fopen (get_mtsconf_pathname(), "r")) == NULL)
+ if (inited++ || (fp = fopen(get_mtsconf_pathname(), "r")) == NULL)
return;
mts_read_conf_file(fp);
- fclose (fp);
+ fclose(fp);
cp = get_mtsuserconf_pathname();
if (cp != NULL &&
- ((fp = fopen (get_mtsuserconf_pathname(), "r")) != NULL)) {
+ ((fp = fopen(get_mtsuserconf_pathname(), "r")) != NULL)) {
mts_read_conf_file(fp);
- fclose (fp);
+ fclose(fp);
}
- Everyone = atoi (everyone);
+ Everyone = atoi(everyone);
if (strstr(masquerade, "draft_from") != NULL)
draft_from_masquerading = TRUE;
*/
static char *
-tailor_value (unsigned char *s)
+tailor_value(unsigned char *s)
{
int i, r;
char *bp;
break;
default:
- if (!isdigit (*s)) {
+ if (!isdigit(*s)) {
*bp++ = QUOTE;
*bp = *s;
}
r = *s != '0' ? 10 : 8;
- for (i = 0; isdigit (*s); s++)
+ for (i = 0; isdigit(*s); s++)
i = i * r + *s - '0';
s--;
- *bp = toascii (i);
+ *bp = toascii(i);
break;
}
}
}
*bp = 0;
- len = strlen (buffer) + 1;
- bp = mh_xmalloc (len);
- memcpy (bp, buffer, len);
+ len = strlen(buffer) + 1;
+ bp = mh_xmalloc(len);
+ memcpy(bp, buffer, len);
return bp;
}
*/
char *
-LocalName (void)
+LocalName(void)
{
static char buffer[BUFSIZ] = "";
struct addrinfo hints, *res;
if (buffer[0])
return buffer;
- mts_init ("mts");
+ mts_init("mts");
memset(buffer, 0, sizeof(buffer));
#ifdef HAVE_UNAME
/* first get our local name */
- uname (&name);
- strncpy (buffer, name.nodename, sizeof(buffer) - 1);
+ uname(&name);
+ strncpy(buffer, name.nodename, sizeof(buffer) - 1);
#else
/* first get our local name */
- gethostname (buffer, sizeof(buffer) - 1);
+ gethostname(buffer, sizeof(buffer) - 1);
#endif
/* now fully qualify our name */
*/
char *
-SystemName (void)
+SystemName(void)
{
static char buffer[BUFSIZ] = "";
if (buffer[0])
return buffer;
- mts_init ("mts");
+ mts_init("mts");
#ifdef HAVE_UNAME
- uname (&name);
- strncpy (buffer, name.nodename, sizeof(buffer));
+ uname(&name);
+ strncpy(buffer, name.nodename, sizeof(buffer));
#else
- gethostname (buffer, sizeof(buffer));
+ gethostname(buffer, sizeof(buffer));
#endif
return buffer;
*/
char *
-getusername (void)
+getusername(void)
{
if (username[0] == '\0')
getuserinfo();
*/
char *
-getfullname (void)
+getfullname(void)
{
if (username[0] == '\0')
getuserinfo();
*/
static void
-getuserinfo (void)
+getuserinfo(void)
{
register unsigned char *cp;
register char *np;
register struct passwd *pw;
- if ((pw = getpwuid (getuid ())) == NULL
+ if ((pw = getpwuid(getuid())) == NULL
|| pw->pw_name == NULL
|| *pw->pw_name == '\0') {
- strncpy (username, "unknown", sizeof(username));
- snprintf (fullname, sizeof(fullname), "The Unknown User-ID (%d)",
- (int) getuid ());
+ strncpy(username, "unknown", sizeof(username));
+ snprintf(fullname, sizeof(fullname), "The Unknown User-ID (%d)",
+ (int) getuid());
return;
}
for (cp = fullname;
*np != '\0' && *np != ',' && *np != '<';) {
if (*np == '&') { /* blech! */
- strcpy (cp, pw->pw_name);
+ strcpy(cp, pw->pw_name);
*cp = toupper(*cp);
while (*cp)
cp++;
*/
for (cp = fullname; *np != '\0' && *np != ',';) {
if (*np == '&') { /* blech! */
- strcpy (cp, pw->pw_name);
+ strcpy(cp, pw->pw_name);
*cp = toupper(*cp);
while (*cp)
cp++;
*cp = '\0';
}
if (!mmailid_masquerading || *np == '\0')
- strncpy (username, pw->pw_name, sizeof(username));
+ strncpy(username, pw->pw_name, sizeof(username));
/*
** The $SIGNATURE environment variable overrides the GECOS field's
** idea of your real name.
*/
- if ((cp = getenv ("SIGNATURE")) && *cp)
- strncpy (fullname, cp, sizeof(fullname));
+ if ((cp = getenv("SIGNATURE")) && *cp)
+ strncpy(fullname, cp, sizeof(fullname));
if (strchr(fullname, '.')) { /* quote any .'s */
char tmp[BUFSIZ];
/* should quote "'s too */
- snprintf (tmp, sizeof(tmp), "\"%s\"", fullname);
- strncpy (fullname, tmp, sizeof(fullname));
+ snprintf(tmp, sizeof(tmp), "\"%s\"", fullname);
+ strncpy(fullname, tmp, sizeof(fullname));
}
return;
}
static const char*
-get_mtsconf_pathname (void)
+get_mtsconf_pathname(void)
{
- const char *cp = getenv ( "MHMTSCONF ");
+ const char *cp = getenv( "MHMTSCONF ");
if (cp != NULL && *cp != '\0') {
return cp;
}
}
static const char*
-get_mtsuserconf_pathname (void)
+get_mtsuserconf_pathname(void)
{
- const char *cp = getenv ( "MHMTSUSERCONF" );
+ const char *cp = getenv( "MHMTSUSERCONF" );
if (cp != NULL && *cp != '\0') {
return cp;
}
}
static void
-mts_read_conf_file (FILE *fp)
+mts_read_conf_file(FILE *fp)
{
unsigned char *bp;
char *cp, buffer[BUFSIZ];
struct bind *b;
- while (fgets (buffer, sizeof(buffer), fp)) {
+ while (fgets(buffer, sizeof(buffer), fp)) {
if (!(cp = strchr(buffer, '\n')))
break;
*cp = 0;
if (!(bp = strchr(buffer, ':')))
break;
*bp++ = 0;
- while (isspace (*bp))
+ while (isspace(*bp))
*bp++ = 0;
for (b = binds; b->keyword; b++)
- if (!strcmp (buffer, b->keyword))
+ if (!strcmp(buffer, b->keyword))
break;
- if (b->keyword && (cp = tailor_value (bp)))
+ if (b->keyword && (cp = tailor_value(bp)))
*b->value = cp;
}
}
{
register char *cp, *ep;
- if ((cp = expath (name, flag))
- && (ep = cp + strlen (cp) - 1) > cp
+ if ((cp = expath(name, flag))
+ && (ep = cp + strlen(cp) - 1) > cp
&& *ep == '/')
*ep = '\0';
static char *
-expath (char *name, int flag)
+expath(char *name, int flag)
{
register char *cp, *ep;
char buffer[BUFSIZ];
if (flag == TSUBCWF) {
- snprintf (buffer, sizeof(buffer), "%s/%s", getfolder (1), name);
- name = m_mailpath (buffer);
- compath (name);
- snprintf (buffer, sizeof(buffer), "%s/", m_maildir (""));
- if (ssequal (buffer, name)) {
+ snprintf(buffer, sizeof(buffer), "%s/%s", getfolder(1), name);
+ name = m_mailpath(buffer);
+ compath(name);
+ snprintf(buffer, sizeof(buffer), "%s/", m_maildir(""));
+ if (ssequal(buffer, name)) {
cp = name;
- name = getcpy (name + strlen (buffer));
- free (cp);
+ name = getcpy(name + strlen(buffer));
+ free(cp);
}
flag = TFOLDER;
}
if (*name == '/' || (flag == TFOLDER
- && (strncmp (name, CWD, NCWD) && strcmp (name, DOT)
- && strcmp (name, DOTDOT) && strncmp (name, PWD, NPWD))))
- return getcpy (name);
+ && (strncmp(name, CWD, NCWD) && strcmp(name, DOT)
+ && strcmp(name, DOTDOT) && strncmp(name, PWD, NPWD))))
+ return getcpy(name);
if (pwds == NULL)
- pwds = pwd ();
+ pwds = pwd();
- if (strcmp (name, DOT) == 0 || strcmp (name, CWD) == 0)
- return getcpy (pwds);
+ if (strcmp(name, DOT) == 0 || strcmp(name, CWD) == 0)
+ return getcpy(pwds);
- ep = pwds + strlen (pwds);
+ ep = pwds + strlen(pwds);
if ((cp = strrchr(pwds, '/')) == NULL)
cp = ep;
else
if (cp == pwds)
cp++;
- if (strncmp (name, CWD, NCWD) == 0)
+ if (strncmp(name, CWD, NCWD) == 0)
name += NCWD;
- if (strcmp (name, DOTDOT) == 0 || strcmp (name, PWD) == 0) {
- snprintf (buffer, sizeof(buffer), "%.*s", (int)(cp - pwds), pwds);
- return getcpy (buffer);
+ if (strcmp(name, DOTDOT) == 0 || strcmp(name, PWD) == 0) {
+ snprintf(buffer, sizeof(buffer), "%.*s", (int)(cp - pwds), pwds);
+ return getcpy(buffer);
}
- if (strncmp (name, PWD, NPWD) == 0)
+ if (strncmp(name, PWD, NPWD) == 0)
name += NPWD;
else
cp = ep;
- snprintf (buffer, sizeof(buffer), "%.*s/%s", (int)(cp - pwds), pwds, name);
- return getcpy (buffer);
+ snprintf(buffer, sizeof(buffer), "%.*s/%s", (int)(cp - pwds), pwds, name);
+ return getcpy(buffer);
}
static void
-compath (char *f)
+compath(char *f)
{
register char *cp, *dp;
continue;
case '.':
- if (strcmp (cp, DOT) == 0) {
+ if (strcmp(cp, DOT) == 0) {
if (cp > f + 1)
cp--;
*cp = '\0';
break;
}
- if (strcmp (cp, DOTDOT) == 0) {
+ if (strcmp(cp, DOTDOT) == 0) {
for (cp -= 2; cp > f; cp--)
if (*cp == '/')
break;
*cp = '\0';
break;
}
- if (strncmp (cp, PWD, NPWD) == 0) {
+ if (strncmp(cp, PWD, NPWD) == 0) {
for (dp = cp - 2; dp > f; dp--)
if (*dp == '/')
break;
if (dp <= f)
dp = f;
- strcpy (dp, cp + NPWD - 1);
+ strcpy(dp, cp + NPWD - 1);
cp = dp;
continue;
}
- if (strncmp (cp, CWD, NCWD) == 0) {
- strcpy (cp - 1, cp + NCWD - 1);
+ if (strncmp(cp, CWD, NCWD) == 0) {
+ strcpy(cp - 1, cp + NCWD - 1);
cp--;
continue;
}
#endif
int
-pidstatus (int status, FILE *fp, char *cp)
+pidstatus(int status, FILE *fp, char *cp)
{
int signum;
if (WIFEXITED(status)) {
if ((signum = WEXITSTATUS(status))) {
if (cp)
- fprintf (fp, "%s: ", cp);
- fprintf (fp, "exit %d\n", signum);
+ fprintf(fp, "%s: ", cp);
+ fprintf(fp, "exit %d\n", signum);
}
} else if (WIFSIGNALED(status)) {
/* If child process terminated due to receipt of a signal */
signum = WTERMSIG(status);
if (signum != SIGINT) {
if (cp)
- fprintf (fp, "%s: ", cp);
- fprintf (fp, "signal %d", signum);
+ fprintf(fp, "%s: ", cp);
+ fprintf(fp, "signal %d", signum);
if (signum >= 0 && signum < sizeof(sigmsg) && sigmsg[signum] != NULL)
- fprintf (fp, " (%s%s)\n", sigmsg[signum],
+ fprintf(fp, " (%s%s)\n", sigmsg[signum],
WCOREDUMP(status) ? ", core dumped" : "");
else
- fprintf (fp, "%s\n", WCOREDUMP(status) ? " (core dumped)" : "");
+ fprintf(fp, "%s\n", WCOREDUMP(status) ? " (core dumped)" : "");
}
}
#endif
int
-pidwait (pid_t id, int sigsok)
+pidwait(pid_t id, int sigsok)
{
pid_t pid;
SIGNAL_HANDLER istat = NULL, qstat = NULL;
if (sigsok == -1) {
/* ignore a couple of signals */
- istat = SIGNAL (SIGINT, SIG_IGN);
- qstat = SIGNAL (SIGQUIT, SIG_IGN);
+ istat = SIGNAL(SIGINT, SIG_IGN);
+ qstat = SIGNAL(SIGQUIT, SIG_IGN);
}
#ifdef HAVE_WAITPID
if (sigsok == -1) {
/* reset the signal handlers */
- SIGNAL (SIGINT, istat);
- SIGNAL (SIGQUIT, qstat);
+ SIGNAL(SIGINT, istat);
+ SIGNAL(SIGQUIT, qstat);
}
#ifdef HAVE_UNION_WAIT
void
-print_help (char *str, struct swit *swp, int print_context)
+print_help(char *str, struct swit *swp, int print_context)
{
char *s;
/* print Usage string */
- printf ("Usage: %s\n", str);
+ printf("Usage: %s\n", str);
/* print all the switches */
- printf (" switches are:\n");
- print_sw (ALL, swp, "-", stdout);
+ printf(" switches are:\n");
+ print_sw(ALL, swp, "-", stdout);
/*
** check if we should print any profile entries
*/
- if (print_context && (s = context_find (invo_name)))
- printf ("\nProfile: %s\n", s);
+ if (print_context && (s = context_find(invo_name)))
+ printf("\nProfile: %s\n", s);
}
void
-print_sw (char *substr, struct swit *swp, char *prefix, FILE *fp)
+print_sw(char *substr, struct swit *swp, char *prefix, FILE *fp)
{
int len, optno;
register int i;
len = strlen(substr);
for (; swp->sw; swp++) {
/* null matches all strings */
- if (!*substr || (ssequal (substr, swp->sw) && len >= swp->minchars)) {
+ if (!*substr || (ssequal(substr, swp->sw) && len >= swp->minchars)) {
optno = 0;
/* next switch */
if ((sp = (&swp[1])->sw)) {
if (!*substr && sp[0] == 'n' && sp[1] == 'o' &&
- strcmp (&sp[2], swp->sw) == 0 && (
+ strcmp(&sp[2], swp->sw) == 0 && (
((&swp[1])->minchars == 0 && swp->minchars == 0) ||
((&swp[1])->minchars == (swp->minchars) + 2)))
optno++;
cp = buf;
*cp++ = '(';
if (optno) {
- strcpy (cp, "[no]");
- cp += strlen (cp);
+ strcpy(cp, "[no]");
+ cp += strlen(cp);
}
for (cp1 = swp->sw, i = 0; i < swp->minchars; i++)
*cp++ = *cp1++;
*cp++ = ')';
while ((*cp++ = *cp1++));
- fprintf (fp, " %s%s\n", prefix, buf);
+ fprintf(fp, " %s%s\n", prefix, buf);
} else {
if (!swp->minchars)
fprintf(fp, optno ? " %s[no]%s\n" : " %s%s\n",
void
-print_version (char *invo_name)
+print_version(char *invo_name)
{
printf("%s -- %s\n", invo_name, version_str);
}
int i;
for (i = 0; (pid = fork()) == -1 && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (pid) {
case -1:
/* fork error */
- advise (NULL, "unable to fork, so can't push...");
+ advise(NULL, "unable to fork, so can't push...");
break;
case 0:
/* child, block a few signals and continue */
- SIGNAL (SIGHUP, SIG_IGN);
- SIGNAL (SIGINT, SIG_IGN);
- SIGNAL (SIGQUIT, SIG_IGN);
- SIGNAL (SIGTERM, SIG_IGN);
+ SIGNAL(SIGHUP, SIG_IGN);
+ SIGNAL(SIGINT, SIG_IGN);
+ SIGNAL(SIGQUIT, SIG_IGN);
+ SIGNAL(SIGTERM, SIG_IGN);
#ifdef SIGTSTP
- SIGNAL (SIGTSTP, SIG_IGN);
- SIGNAL (SIGTTIN, SIG_IGN);
- SIGNAL (SIGTTOU, SIG_IGN);
+ SIGNAL(SIGTSTP, SIG_IGN);
+ SIGNAL(SIGTTIN, SIG_IGN);
+ SIGNAL(SIGTTOU, SIG_IGN);
#endif
- freopen ("/dev/null", "r", stdin);
- freopen ("/dev/null", "w", stdout);
+ freopen("/dev/null", "r", stdin);
+ freopen("/dev/null", "w", stdout);
break;
default:
/* parent, just exit */
- done (0);
+ done(0);
}
}
/*
** prototypes
*/
-int m_putenv (char *, char *);
-int unputenv (char *);
-static int nvmatch (char *, char *);
+int m_putenv(char *, char *);
+int unputenv(char *);
+static int nvmatch(char *, char *);
int
-m_putenv (char *name, char *value)
+m_putenv(char *name, char *value)
{
register int i;
register char **ep, **nep, *cp;
- cp = mh_xmalloc ((size_t) (strlen (name) + strlen (value) + 2));
+ cp = mh_xmalloc((size_t) (strlen(name) + strlen(value) + 2));
- sprintf (cp, "%s=%s", name, value);
+ sprintf(cp, "%s=%s", name, value);
for (ep = environ, i = 0; *ep; ep++, i++)
- if (nvmatch (name, *ep)) {
+ if (nvmatch(name, *ep)) {
*ep = cp;
return 0;
}
- nep = (char **) mh_xmalloc ((size_t) ((i + 2) * sizeof(*nep)));
+ nep = (char **) mh_xmalloc((size_t) ((i + 2) * sizeof(*nep)));
for (ep = environ, i = 0; *ep; nep[i++] = *ep++)
continue;
int
-unputenv (char *name)
+unputenv(char *name)
{
char **ep, **nep;
for (ep = environ; *ep; ep++)
- if (nvmatch (name, *ep))
+ if (nvmatch(name, *ep))
break;
if (*ep == NULL)
return 1;
static int
-nvmatch (char *s1, char *s2)
+nvmatch(char *s1, char *s2)
{
while (*s1 == *s2++)
if (*s1++ == '=')
void
-readconfig (struct node **npp, FILE *ib, char *file, int ctx)
+readconfig(struct node **npp, FILE *ib, char *file, int ctx)
{
register int state;
register char *cp;
register struct procstr *ps;
if (npp == NULL && (npp = opp) == NULL) {
- admonish (NULL, "bug: readconfig called but pump not primed");
+ admonish(NULL, "bug: readconfig called but pump not primed");
return;
}
for (state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), ib)) {
+ switch (state = m_getfld(state, name, field, sizeof(field), ib)) {
case FLD:
case FLDPLUS:
case FLDEOF:
- np = (struct node *) mh_xmalloc (sizeof(*np));
+ np = (struct node *) mh_xmalloc(sizeof(*np));
*npp = np;
*(npp = &np->n_next) = NULL;
- np->n_name = getcpy (name);
+ np->n_name = getcpy(name);
if (state == FLDPLUS) {
- cp = getcpy (field);
+ cp = getcpy(field);
while (state == FLDPLUS) {
- state = m_getfld (state, name, field, sizeof(field), ib);
- cp = add (field, cp);
+ state = m_getfld(state, name, field, sizeof(field), ib);
+ cp = add(field, cp);
}
- np->n_field = trimcpy (cp);
- free (cp);
+ np->n_field = trimcpy(cp);
+ free(cp);
} else {
- np->n_field = trimcpy (field);
+ np->n_field = trimcpy(field);
}
np->n_context = ctx;
** field value to the global variable.
*/
for (ps = procs; ps->procname; ps++)
- if (strcmp (np->n_name, ps->procname) == 0) {
+ if (strcmp(np->n_name, ps->procname) == 0) {
*ps->procnaddr = np->n_field;
break;
}
case BODY:
case BODYEOF:
- adios (NULL, "no blank lines are permitted in %s", file);
+ adios(NULL, "no blank lines are permitted in %s", file);
case FILEEOF:
break;
default:
- adios (NULL, "%s is poorly formatted", file);
+ adios(NULL, "%s is poorly formatted", file);
}
break;
}
int
-refile (char **arg, char *file)
+refile(char **arg, char *file)
{
pid_t pid;
register int vecp;
char *vec[MAXARGS];
vecp = 0;
- vec[vecp++] = r1bindex (fileproc, '/');
+ vec[vecp++] = r1bindex(fileproc, '/');
vec[vecp++] = "-nolink"; /* override bad .mh_profile defaults */
vec[vecp++] = "-nopreserve";
vec[vecp++] = "-file";
switch (pid = vfork()) {
case -1:
- advise ("fork", "unable to");
+ advise("fork", "unable to");
return -1;
case 0:
- execvp (fileproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (fileproc);
- _exit (-1);
+ execvp(fileproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(fileproc);
+ _exit(-1);
default:
- return (pidwait (pid, -1));
+ return (pidwait(pid, -1));
}
}
if ((myname = getlogin()) == NULL) {
struct passwd *pp;
- if ((pp = getpwuid (getuid())) != NULL)
+ if ((pp = getpwuid(getuid())) != NULL)
myname = pp->pw_name;
}
printf("Name (%s:%s): ", host, myname);
}
*aname = mh_xmalloc((size_t) strlen(myname) + 1);
- strcpy (*aname, myname);
+ strcpy(*aname, myname);
}
if (!*apass) {
}
*apass = mh_xmalloc((size_t) strlen(mypass) + 1);
- strcpy (*apass, mypass);
+ strcpy(*apass, mypass);
}
}
*/
int
-seq_addsel (struct msgs *mp, char *cp, int public, int zero)
+seq_addsel(struct msgs *mp, char *cp, int public, int zero)
{
int i, msgnum, new_seq = 1;
- if (!seq_nameok (cp))
+ if (!seq_nameok(cp))
return 0;
/*
** We keep mp->curmsg and "cur" sequence in sync.
** See seq_list() and seq_init().
*/
- if (!strcmp (current,cp))
+ if (!strcmp(current,cp))
mp->curmsg = mp->hghsel;
/*
** Get the number for this sequence
*/
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp (mp->msgattrs[i], cp)) {
+ if (!strcmp(mp->msgattrs[i], cp)) {
new_seq = 0;
break;
}
*/
if (new_seq) {
if (i >= NUMATTRS) {
- advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
+ advise(NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
return 0;
}
- if (!(mp->msgattrs[i] = strdup (cp))) {
- advise (NULL, "strdup failed");
+ if (!(mp->msgattrs[i] = strdup(cp))) {
+ advise(NULL, "strdup failed");
return 0;
}
mp->msgattrs[i + 1] = NULL;
*/
if (new_seq || zero) {
for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++)
- clear_sequence (mp, i, msgnum);
+ clear_sequence(mp, i, msgnum);
}
/*
** for all selected messages.
*/
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
- if (is_selected (mp, msgnum))
- add_sequence (mp, i, msgnum);
+ if (is_selected(mp, msgnum))
+ add_sequence(mp, i, msgnum);
/*
** Set the public/private bit for this sequence.
*/
if (public == 1)
- make_seq_public (mp, i);
+ make_seq_public(mp, i);
else if (public == 0)
- make_seq_private (mp, i);
+ make_seq_private(mp, i);
else if (new_seq) {
/*
** If public == -1, then only set the
** public/private bit for new sequences.
*/
- if (is_readonly (mp))
- make_seq_private (mp, i);
+ if (is_readonly(mp))
+ make_seq_private(mp, i);
else
- make_seq_public (mp, i);
+ make_seq_public(mp, i);
}
mp->msgflags |= SEQMOD;
*/
int
-seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero)
+seq_addmsg(struct msgs *mp, char *cp, int msgnum, int public, int zero)
{
int i, j, new_seq = 1;
- if (!seq_nameok (cp))
+ if (!seq_nameok(cp))
return 0;
/*
** keep mp->curmsg and msgattrs["cur"] in sync - see seq_list()
*/
- if (!strcmp (current,cp))
+ if (!strcmp(current,cp))
mp->curmsg = msgnum;
/*
** Get the number for this sequence
*/
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp (mp->msgattrs[i], cp)) {
+ if (!strcmp(mp->msgattrs[i], cp)) {
new_seq = 0;
break;
}
*/
if (new_seq) {
if (i >= NUMATTRS) {
- advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
+ advise(NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
return 0;
}
- if (!(mp->msgattrs[i] = strdup (cp))) {
- advise (NULL, "strdup failed");
+ if (!(mp->msgattrs[i] = strdup(cp))) {
+ advise(NULL, "strdup failed");
return 0;
}
mp->msgattrs[i + 1] = NULL;
*/
if (new_seq || zero) {
for (j = mp->lowmsg; j <= mp->hghmsg; j++)
- clear_sequence (mp, i, j);
+ clear_sequence(mp, i, j);
}
/*
** Now flip on the bit for this sequence
** for this particular message.
*/
- add_sequence (mp, i, msgnum);
+ add_sequence(mp, i, msgnum);
/*
** Set the public/private bit for this sequence.
*/
if (public == 1)
- make_seq_public (mp, i);
+ make_seq_public(mp, i);
else if (public == 0)
- make_seq_private (mp, i);
+ make_seq_private(mp, i);
else if (new_seq) {
/*
** If public == -1, then only set the
** public/private bit for new sequences.
*/
- if (is_readonly (mp))
- make_seq_private (mp, i);
+ if (is_readonly(mp))
+ make_seq_private(mp, i);
else
- make_seq_public (mp, i);
+ make_seq_public(mp, i);
}
mp->msgflags |= SEQMOD;
char *
-seq_bits (struct msgs *mp)
+seq_bits(struct msgs *mp)
{
int i;
size_t len;
static char buffer[BUFSIZ];
- strncpy (buffer, MBITS, sizeof(buffer));
+ strncpy(buffer, MBITS, sizeof(buffer));
for (i = 0; mp->msgattrs[i]; i++) {
- len = strlen (buffer);
- snprintf (buffer + len, sizeof(buffer) - len,
+ len = strlen(buffer);
+ snprintf(buffer + len, sizeof(buffer) - len,
"%c%s", FFATTRSLOT + 1 + i, mp->msgattrs[i]);
}
*/
int
-seq_delsel (struct msgs *mp, char *cp, int public, int zero)
+seq_delsel(struct msgs *mp, char *cp, int public, int zero)
{
int i, msgnum, new_seq = 1;
- if (!seq_nameok (cp))
+ if (!seq_nameok(cp))
return 0;
/*
** Get the number for this sequence
*/
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp (mp->msgattrs[i], cp)) {
+ if (!strcmp(mp->msgattrs[i], cp)) {
new_seq = 0;
break;
}
*/
if (new_seq) {
if (i >= NUMATTRS) {
- advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
+ advise(NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
return 0;
}
- if (!(mp->msgattrs[i] = strdup (cp))) {
- advise (NULL, "strdup failed");
+ if (!(mp->msgattrs[i] = strdup(cp))) {
+ advise(NULL, "strdup failed");
return 0;
}
mp->msgattrs[i + 1] = NULL;
** 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);
+ if (does_exist(mp, msgnum))
+ add_sequence(mp, i, msgnum);
else
- clear_sequence (mp, i, msgnum);
+ clear_sequence(mp, i, msgnum);
}
} else {
if (new_seq) {
- advise (NULL, "no such sequence as %s", cp);
+ advise(NULL, "no such sequence as %s", cp);
return 0;
}
}
** 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);
+ if (is_selected(mp, msgnum))
+ clear_sequence(mp, i, msgnum);
/*
** Set the public/private bit for this sequence.
*/
if (public == 1)
- make_seq_public (mp, i);
+ make_seq_public(mp, i);
else if (public == 0)
- make_seq_private (mp, i);
+ make_seq_private(mp, i);
else if (new_seq) {
/*
** If public == -1, then only set the
** public/private bit for new sequences.
*/
- if (is_readonly (mp))
- make_seq_private (mp, i);
+ if (is_readonly(mp))
+ make_seq_private(mp, i);
else
- make_seq_public (mp, i);
+ make_seq_public(mp, i);
}
mp->msgflags |= SEQMOD;
*/
int
-seq_delmsg (struct msgs *mp, char *cp, int msgnum)
+seq_delmsg(struct msgs *mp, char *cp, int msgnum)
{
int i;
- if (!seq_nameok (cp))
+ if (!seq_nameok(cp))
return 0;
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp (mp->msgattrs[i], cp)) {
- clear_sequence (mp, i, msgnum);
+ if (!strcmp(mp->msgattrs[i], cp)) {
+ clear_sequence(mp, i, msgnum);
mp->msgflags |= SEQMOD;
return 1;
}
}
- advise (NULL, "no such sequence as %s", cp);
+ advise(NULL, "no such sequence as %s", cp);
return 0;
}
int
-seq_getnum (struct msgs *mp, char *seqname)
+seq_getnum(struct msgs *mp, char *seqname)
{
int i;
for (i = 0; mp->msgattrs[i]; i++)
- if (!strcmp (mp->msgattrs[i], seqname))
+ if (!strcmp(mp->msgattrs[i], seqname))
return i;
return -1;
/* On first invocation, allocate initial buffer space */
if (!buffer) {
len = MAXBUFFER;
- buffer = mh_xmalloc ((size_t) len);
+ buffer = mh_xmalloc((size_t) len);
}
/*
** This is returned, even if message doesn't exist or the
** folder is empty.
*/
- if (!strcmp (current, seqname)) {
+ if (!strcmp(current, seqname)) {
if (mp->curmsg) {
sprintf(buffer, "%s", m_name(mp->curmsg));
return (buffer);
return NULL;
/* Get the index of the sequence */
- if ((seqnum = seq_getnum (mp, seqname)) == -1)
+ if ((seqnum = seq_getnum(mp, seqname)) == -1)
return NULL;
bp = buffer;
char *newbuf;
len += MAXBUFFER;
- newbuf = mh_xrealloc (buffer, (size_t) len);
+ newbuf = mh_xrealloc(buffer, (size_t) len);
bp = newbuf + (bp - buffer);
buffer = newbuf;
}
int
-seq_nameok (unsigned char *s)
+seq_nameok(unsigned char *s)
{
unsigned char *pp;
if (s == NULL || *s == '\0') {
- advise (NULL, "empty sequence name");
+ advise(NULL, "empty sequence name");
return 0;
}
** Make sure sequence name doesn't clash with one
** of the `reserved' sequence names.
*/
- if (!(strcmp (s, "new") &&
- strcmp (s, "all") &&
- strcmp (s, "first") &&
- strcmp (s, "last") &&
- strcmp (s, "prev") &&
- strcmp (s, "next"))) {
- advise (NULL, "illegal sequence name: %s", s);
+ if (!(strcmp(s, "new") &&
+ strcmp(s, "all") &&
+ strcmp(s, "first") &&
+ strcmp(s, "last") &&
+ strcmp(s, "prev") &&
+ strcmp(s, "next"))) {
+ advise(NULL, "illegal sequence name: %s", s);
return 0;
}
** First character in a sequence name must be
** an alphabetic character ...
*/
- if (!isalpha (*s)) {
- advise (NULL, "illegal sequence name: %s", s);
+ if (!isalpha(*s)) {
+ advise(NULL, "illegal sequence name: %s", s);
return 0;
}
** 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);
+ if (!isalnum(*pp)) {
+ advise(NULL, "illegal sequence name: %s", s);
return 0;
}
** Print all the sequences in a folder
*/
void
-seq_printall (struct msgs *mp)
+seq_printall(struct msgs *mp)
{
int i;
char *list;
for (i = 0; mp->msgattrs[i]; i++) {
- list = seq_list (mp, mp->msgattrs[i]);
- printf ("%s%s: %s\n", mp->msgattrs[i],
- is_seq_private (mp, i) ? " (private)" : "",
+ list = seq_list(mp, mp->msgattrs[i]);
+ printf("%s%s: %s\n", mp->msgattrs[i],
+ is_seq_private(mp, i) ? " (private)" : "",
empty(list));
}
}
** Print a particular sequence in a folder
*/
void
-seq_print (struct msgs *mp, char *seqname)
+seq_print(struct msgs *mp, char *seqname)
{
int i;
char *list;
/* get the index of sequence */
- i = seq_getnum (mp, seqname);
+ i = seq_getnum(mp, seqname);
/* get sequence information */
- list = seq_list (mp, seqname);
+ list = seq_list(mp, seqname);
- printf ("%s%s: %s\n", seqname, (i == -1) ? "" :
+ printf("%s%s: %s\n", seqname, (i == -1) ? "" :
is_seq_private(mp, i) ? " (private)" : "", empty(list));
}
/*
** static prototypes
*/
-static int seq_init (struct msgs *, char *, char *);
-static void seq_public (struct msgs *);
-static void seq_private (struct msgs *);
+static int seq_init(struct msgs *, char *, char *);
+static void seq_public(struct msgs *);
+static void seq_private(struct msgs *);
/*
*/
void
-seq_read (struct msgs *mp)
+seq_read(struct msgs *mp)
{
/*
** 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[0] = getcpy(current);
mp->msgattrs[1] = NULL;
- make_all_public (mp); /* initially, make all public */
+ make_all_public(mp); /* initially, make all public */
/* If folder is empty, don't scan for sequence information */
if (mp->nummsg == 0)
return;
/* Initialize the public sequences */
- seq_public (mp);
+ seq_public(mp);
/* Initialize the private sequences */
- seq_private (mp);
+ seq_private(mp);
}
*/
static void
-seq_public (struct msgs *mp)
+seq_public(struct msgs *mp)
{
int state;
char *cp, seqfile[PATH_MAX];
return;
/* get filename of sequence file */
- snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq);
+ snprintf(seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq);
- if ((fp = lkfopen (seqfile, "r")) == NULL)
+ if ((fp = lkfopen(seqfile, "r")) == NULL)
return;
/* Use m_getfld to scan sequence file */
for (state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
+ switch (state = m_getfld(state, name, field, sizeof(field), fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
if (state == FLDPLUS) {
- cp = getcpy (field);
+ cp = getcpy(field);
while (state == FLDPLUS) {
- state = m_getfld (state, name, field, sizeof(field), fp);
- cp = add (field, cp);
+ state = m_getfld(state, name, field, sizeof(field), fp);
+ cp = add(field, cp);
}
- seq_init (mp, getcpy (name), trimcpy (cp));
- free (cp);
+ seq_init(mp, getcpy(name), trimcpy(cp));
+ free(cp);
} else {
- seq_init (mp, getcpy (name), trimcpy (field));
+ seq_init(mp, getcpy(name), trimcpy(field));
}
if (state == FLDEOF)
break;
case BODY:
case BODYEOF:
- adios (NULL, "no blank lines are permitted in %s", seqfile);
+ adios(NULL, "no blank lines are permitted in %s", seqfile);
/* fall */
case FILEEOF:
break;
default:
- adios (NULL, "%s is poorly formatted", seqfile);
+ adios(NULL, "%s is poorly formatted", seqfile);
}
break; /* break from for loop */
}
- lkfclose (fp, seqfile);
+ lkfclose(fp, seqfile);
}
*/
static void
-seq_private (struct msgs *mp)
+seq_private(struct msgs *mp)
{
int i, j, alen, plen;
char *cp;
struct node *np;
- alen = strlen ("atr-");
- plen = strlen (mp->foldpath) + 1;
+ alen = strlen("atr-");
+ plen = strlen(mp->foldpath) + 1;
for (np = m_defs; np; np = np->n_next) {
- if (ssequal ("atr-", np->n_name)
- && (j = strlen (np->n_name) - plen) > alen
- && *(np->n_name + j) == '-'
- && strcmp (mp->foldpath, np->n_name + j + 1) == 0) {
- cp = getcpy (np->n_name + alen);
+ if (ssequal("atr-", np->n_name)
+ && (j = strlen(np->n_name) - plen) > alen
+ && *(np->n_name + j) == '-'
+ && strcmp(mp->foldpath, np->n_name + j + 1)
+ == 0) {
+ cp = getcpy(np->n_name + alen);
*(cp + j - alen) = '\0';
- if ((i = seq_init (mp, cp, getcpy (np->n_field))) != -1)
- make_seq_private (mp, i);
+ if ((i = seq_init(mp, cp, getcpy(np->n_field))) != -1)
+ make_seq_private(mp, i);
}
}
}
*/
static int
-seq_init (struct msgs *mp, char *name, char *field)
+seq_init(struct msgs *mp, char *name, char *field)
{
int i, j, k, is_current;
char *cp, **ap;
** Check if this is "cur" sequence,
** so we can do some special things.
*/
- is_current = !strcmp (current, name);
+ is_current = !strcmp(current, name);
/*
** Search for this sequence name to see if we've seen
** mesages in this folder.
*/
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp (mp->msgattrs[i], name)) {
+ if (!strcmp(mp->msgattrs[i], name)) {
for (j = mp->lowmsg; j <= mp->hghmsg; j++)
- clear_sequence (mp, i, j);
+ clear_sequence(mp, i, j);
break;
}
}
/* Return error, if too many sequences */
if (i >= NUMATTRS) {
- free (name);
- free (field);
+ free(name);
+ free(field);
return -1;
}
** name string. Else add it to the list of sequence names.
*/
if (mp->msgattrs[i]) {
- free (name);
+ free(name);
} else {
mp->msgattrs[i] = name;
mp->msgattrs[i + 1] = NULL;
/*
** Split up the different message ranges at whitespace
*/
- for (ap = brkstring (field, " ", "\n"); *ap; ap++) {
+ for (ap = brkstring(field, " ", "\n"); *ap; ap++) {
if ((cp = strchr(*ap, '-')))
*cp++ = '\0';
- if ((j = m_atoi (*ap)) > 0) {
- k = cp ? m_atoi (cp) : j;
+ if ((j = m_atoi(*ap)) > 0) {
+ k = cp ? m_atoi(cp) : j;
/*
** Keep mp->curmsg and "cur" sequence in synch. Unlike
** 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);
+ if (j >= mp->lowmsg && j <= mp->hghmsg &&
+ does_exist(mp, j))
+ add_sequence(mp, i, j);
}
}
}
- free (field); /* free string containing message ranges */
+ free(field); /* free string containing message ranges */
return i;
}
*/
void
-seq_save (struct msgs *mp)
+seq_save(struct msgs *mp)
{
int i;
char flags, *cp, attr[BUFSIZ], seqfile[PATH_MAX];
** is readonly. This will force all sequences to be private.
*/
if (mh_seq == NULL || *mh_seq == '\0')
- set_readonly (mp);
+ set_readonly(mp);
else
- snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath,
+ 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],
+ 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]))) {
- context_del (attr); /* delete sequence from context */
+ context_del(attr); /* delete sequence from context */
continue;
}
if (is_readonly(mp) || is_seq_private(mp, i)) {
priv:
/* sequence is private */
- context_replace (attr, cp); /* update sequence in context */
+ context_replace(attr, cp); /* update seq in ctx */
} else {
/* sequence is public */
- context_del (attr); /* delete sequence from context */
+ context_del(attr); /* delete sequence from context */
if (!fp) {
/*
** 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)) {
- admonish (attr, "unable to write");
+ if ((fp = lkfopen(seqfile, "w")) == NULL
+ && (unlink(seqfile) == -1 ||
+ (fp = lkfopen(seqfile, "w"))
+ == NULL)) {
+ admonish(attr, "unable to write");
goto priv;
}
/* block a few signals */
- sigemptyset (&set);
+ sigemptyset(&set);
sigaddset(&set, SIGHUP);
sigaddset(&set, SIGINT);
sigaddset(&set, SIGQUIT);
sigaddset(&set, SIGTERM);
- SIGPROCMASK (SIG_BLOCK, &set, &oset);
+ SIGPROCMASK(SIG_BLOCK, &set, &oset);
}
- fprintf (fp, "%s: %s\n", mp->msgattrs[i], cp);
+ fprintf(fp, "%s: %s\n", mp->msgattrs[i], cp);
}
}
if (fp) {
- lkfclose (fp, seqfile);
- SIGPROCMASK (SIG_SETMASK, &oset, &set); /* reset signal mask */
+ lkfclose(fp, seqfile);
+ 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 (!is_readonly(mp))
- unlink (seqfile);
+ unlink(seqfile);
}
/*
void
-seq_setcur (struct msgs *mp, int msgnum)
+seq_setcur(struct msgs *mp, int msgnum)
{
/*
** Just call seq_addmsg() to update the
** "cur" sequence.
*/
- seq_addmsg (mp, current, msgnum, -1, 1);
+ seq_addmsg(mp, current, msgnum, -1, 1);
}
*/
void
-seq_setprev (struct msgs *mp)
+seq_setprev(struct msgs *mp)
{
char **ap, *cp, *dp;
** 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) {
- free (dp);
+ if ((cp = context_find(psequence))) {
+ dp = getcpy(cp);
+ if (!(ap = brkstring(dp, " ", "\n")) || !*ap) {
+ free(dp);
return;
}
} else {
/* Now add all SELECTED messages to each sequence */
for (; *ap; ap++)
- seq_addsel (mp, *ap, -1, 1);
+ seq_addsel(mp, *ap, -1, 1);
- free (dp);
+ free(dp);
}
*/
void
-seq_setunseen (struct msgs *mp, int seen)
+seq_setunseen(struct msgs *mp, int seen)
{
int msgnum;
char **ap, *cp, *dp;
** 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) {
- free (dp);
+ if ((cp = context_find(usequence))) {
+ dp = getcpy(cp);
+ if (!(ap = brkstring(dp, " ", "\n")) || !*ap) {
+ free(dp);
return;
}
} else {
/* make sure sequence exists first */
if (seq_getnum(mp, *ap) != -1)
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
- if (is_unseen (mp, msgnum))
- seq_delmsg (mp, *ap, msgnum);
+ if (is_unseen(mp, msgnum))
+ seq_delmsg(mp, *ap, msgnum);
} else {
for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++)
- if (is_unseen (mp, msgnum))
- seq_addmsg (mp, *ap, msgnum, -1, 0);
+ if (is_unseen(mp, msgnum))
+ seq_addmsg(mp, *ap, msgnum, -1, 0);
}
}
- free (dp);
+ free(dp);
}
int
-showfile (char **arg, char *file)
+showfile(char **arg, char *file)
{
pid_t pid;
int isdraft, vecp;
** then really invoked the mhlproc instead
** (which is usually mhl anyway).
*/
- if (!strcmp (r1bindex (lproc, '/'), "mhl"))
+ if (!strcmp(r1bindex(lproc, '/'), "mhl"))
lproc = mhlproc;
switch (pid = vfork()) {
case -1:
/* fork error */
- advise ("fork", "unable to");
+ advise("fork", "unable to");
return 1;
case 0:
/* child */
vecp = 0;
- vec[vecp++] = r1bindex (lproc, '/');
+ vec[vecp++] = r1bindex(lproc, '/');
isdraft = 1;
if (arg) {
while (*arg) {
}
}
if (isdraft) {
- if (!strcmp (vec[0], "show"))
+ if (!strcmp(vec[0], "show"))
vec[vecp++] = "-file";
vec[vecp++] = file;
}
vec[vecp] = NULL;
- execvp (lproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (lproc);
- _exit (-1);
+ execvp(lproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(lproc);
+ _exit(-1);
default:
/* parent */
- return (pidwait (pid, -1) & 0377 ? 1 : 0);
+ return (pidwait(pid, -1) & 0377 ? 1 : 0);
}
return 1; /* NOT REACHED */
int
-SIGPROCMASK (int how, const sigset_t *set, sigset_t *oset)
+SIGPROCMASK(int how, const sigset_t *set, sigset_t *oset)
{
#ifdef POSIX_SIGNALS
return sigprocmask(how, set, oset);
*/
SIGNAL_HANDLER
-SIGNAL (int sig, SIGNAL_HANDLER func)
+SIGNAL(int sig, SIGNAL_HANDLER func)
{
#ifdef POSIX_SIGNALS
struct sigaction act, oact;
return (SIG_ERR);
return (oact.sa_handler);
#else
- return signal (sig, func);
+ return signal(sig, func);
#endif
}
** signals if available.
*/
SIGNAL_HANDLER
-SIGNAL2 (int sig, SIGNAL_HANDLER func)
+SIGNAL2(int sig, SIGNAL_HANDLER func)
{
#ifdef POSIX_SIGNALS
struct sigaction act, oact;
#else
SIGNAL_HANDLER ofunc;
- if ((ofunc = signal (sig, SIG_IGN)) != SIG_IGN)
- signal (sig, func);
+ if ((ofunc = signal(sig, SIG_IGN)) != SIG_IGN)
+ signal(sig, func);
return ofunc;
#endif
}
char *
-snprintb (char *buffer, size_t n, unsigned v, char *bits)
+snprintb(char *buffer, size_t n, unsigned v, char *bits)
{
register int i, j;
register char c, *bp;
- snprintf (buffer, n, bits && *bits == 010 ? "0%o" : "0x%x", v);
+ snprintf(buffer, n, bits && *bits == 010 ? "0%o" : "0x%x", v);
bp = buffer + strlen(buffer);
if (bits && *++bits) {
*/
int
-ssequal (char *s1, char *s2)
+ssequal(char *s1, char *s2)
{
if (!s1)
s1 = "";
*/
int
-mh_strcasecmp (const char *s1, const char *s2)
+mh_strcasecmp(const char *s1, const char *s2)
{
const unsigned char *us1, *us2;
char *
-strdup (const char *str)
+strdup(const char *str)
{
char *cp;
size_t len;
return NULL;
len = strlen(str) + 1;
- cp = mh_xmalloc (len);
- memcpy (cp, str, len);
+ cp = mh_xmalloc(len);
+ memcpy(cp, str, len);
return cp;
}
#include <h/mh.h>
int
-stringdex (char *p1, char *p2)
+stringdex(char *p1, char *p2)
{
char *p;
return -1;
for (p = p2; *p; p++)
- if (uprf (p, p1))
+ if (uprf(p, p1))
return (p - p2);
return -1;
char *
-trimcpy (unsigned char *cp)
+trimcpy(unsigned char *cp)
{
unsigned char *sp;
int
-uprf (char *c1, char *c2)
+uprf(char *c1, char *c2)
{
int c, mask;
register char *cp;
static char curwd[PATH_MAX];
- if (!getcwd (curwd, PATH_MAX)) {
- admonish (NULL, "unable to determine working directory");
+ if (!getcwd(curwd, PATH_MAX)) {
+ admonish(NULL, "unable to determine working directory");
if (!mypath || !*mypath
- || (strcpy (curwd, mypath), chdir (curwd)) == -1) {
- strcpy (curwd, "/");
- chdir (curwd);
+ || (strcpy(curwd, mypath), chdir(curwd)) == -1) {
+ strcpy(curwd, "/");
+ chdir(curwd);
}
return curwd;
}
- if ((cp = curwd + strlen (curwd) - 1) > curwd && *cp == '/')
+ if ((cp = curwd + strlen(curwd) - 1) > curwd && *cp == '/')
*cp = '\0';
return curwd;
** -- malloc'ed memory. Then free "s1".
*/
char *
-add (char *s2, char *s1)
+add(char *s2, char *s1)
{
char *cp;
size_t len1 = 0, len2 = 0;
if (s1)
- len1 = strlen (s1);
+ len1 = strlen(s1);
if (s2)
- len2 = strlen (s2);
+ len2 = strlen(s2);
- cp = mh_xmalloc (len1 + len2 + 1);
+ cp = mh_xmalloc(len1 + len2 + 1);
/* Copy s1 and free it */
if (s1) {
- memcpy (cp, s1, len1);
- free (s1);
+ memcpy(cp, s1, len1);
+ free(s1);
}
/* Copy s2 */
if (s2)
- memcpy (cp + len1, s2, len2);
+ memcpy(cp + len1, s2, len2);
/* Now NULL terminate the string */
cp[len1 + len2] = '\0';
struct stat st;
int exists = 0;
- if (stat (folder, &st) == -1) {
+ if (stat(folder, &st) == -1) {
/*
** The folder either doesn't exist, or we hit an error.
** Either way return a failure.
extern int errno;
char *cp;
- if (stat (folder, &st) == -1) {
+ if (stat(folder, &st) == -1) {
if (errno != ENOENT)
- adios (folder, "error on folder");
+ adios(folder, "error on folder");
if (autocreate == 0) {
/* ask before creating folder */
- cp = concat ("Create folder \"", folder, "\"? ", NULL);
- if (!getanswer (cp))
- done_callback (1);
- free (cp);
+ cp = concat("Create folder \"", folder, "\"? ", NULL);
+ if (!getanswer(cp))
+ done_callback(1);
+ free(cp);
} else if (autocreate == -1) {
/* do not create, so exit */
- done_callback (1);
+ done_callback(1);
}
- if (!makedir (folder))
- adios (NULL, "unable to create folder %s", folder);
+ if (!makedir(folder))
+ adios(NULL, "unable to create folder %s", folder);
}
}
** Return the number of digits in a nonnegative integer.
*/
int
-num_digits (int n)
+num_digits(int n)
{
int ndigits = 0;
/* Sanity check */
if (n < 0)
- adios (NULL, "oops, num_digits called with negative value");
+ adios(NULL, "oops, num_digits called with negative value");
if (n == 0)
return 1;
{
int in;
if (*form) {
- if ((in = open (etcpath (*form), O_RDONLY)) == NOTOK)
- adios (*form, "unable to open form file");
+ if ((in = open(etcpath(*form), O_RDONLY)) == NOTOK)
+ adios(*form, "unable to open form file");
} else {
- if ((in = open (etcpath (def), O_RDONLY)) == NOTOK)
- adios (def, "unable to open default components file");
+ if ((in = open(etcpath(def), O_RDONLY)) == NOTOK)
+ adios(def, "unable to open default components file");
*form = def;
}
return in;
int
-vfgets (FILE *in, char **bp)
+vfgets(FILE *in, char **bp)
{
int toggle;
char *cp, *dp, *ep, *fp;
static char *pp = NULL;
if (pp == NULL)
- pp = mh_xmalloc ((size_t) (len = BUFSIZ));
+ pp = mh_xmalloc((size_t) (len = BUFSIZ));
for (ep = (cp = pp) + len - 1;;) {
- if (fgets (cp, ep - cp + 1, in) == NULL) {
+ if (fgets(cp, ep - cp + 1, in) == NULL) {
if (cp != pp) {
*bp = pp;
return 0;
}
- return (ferror (in) && !feof (in) ? -1 : 1);
+ return (ferror(in) && !feof(in) ? -1 : 1);
}
- if ((dp = cp + strlen (cp) - 2) < cp || *dp != QUOTE) {
+ if ((dp = cp + strlen(cp) - 2) < cp || *dp != QUOTE) {
wrong_guess:
if (cp > ++dp)
- adios (NULL, "vfgets() botch -- you lose big");
+ adios(NULL, "vfgets() botch -- you lose big");
if (*dp == '\n') {
*bp = pp;
return 0;
if (cp >= ep) {
int curlen = cp - pp;
- dp = mh_xrealloc (pp, (size_t) (len += BUFSIZ));
+ dp = mh_xrealloc(pp, (size_t) (len += BUFSIZ));
cp = dp + curlen;
ep = (pp = dp) + len - 1;
}
/*
** prototypes
*/
-static void print_aka (char *, int, int);
-static void print_usr (char *, int, int);
+static void print_aka(char *, int, int);
+static void print_usr(char *, int, int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int i, vecp = 0, inverted = 0, list = 0;
int noalias = 0, normalize = AD_NHST;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] aliases ...",
+ snprintf(buf, sizeof(buf), "%s [switches] aliases ...",
invo_name);
- print_help (buf, switches, 1);
- done (1);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
- print_version (invo_name);
- done (1);
+ print_version(invo_name);
+ done(1);
case ALIASW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((i = alias (cp)) != AK_OK)
- adios (NULL, "aliasing error in %s - %s", cp, akerror (i));
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((i = alias(cp)) != AK_OK)
+ adios(NULL, "aliasing error in %s - %s", cp, akerror(i));
continue;
case NALIASW:
noalias++;
if (!noalias) {
/* allow Aliasfile: profile entry */
- if ((cp = context_find ("Aliasfile"))) {
+ if ((cp = context_find("Aliasfile"))) {
char *dp = NULL;
for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++)
- if ((i = alias (*ap)) != AK_OK)
- adios (NULL, "aliasing error in %s - %s", *ap, akerror (i));
+ if ((i = alias(*ap)) != AK_OK)
+ adios(NULL, "aliasing error in %s - %s", *ap, akerror(i));
if (dp)
free(dp);
}
- alias (AliasFile);
+ alias(AliasFile);
}
/*
*/
if (inverted) {
if (vecp == 0)
- adios (NULL, "usage: %s -user addresses ... (you forgot the addresses)",
+ adios(NULL, "usage: %s -user addresses ... (you forgot the addresses)",
invo_name);
for (i = 0; i < vecp; i++)
- print_usr (vec[i], list, normalize);
+ print_usr(vec[i], list, normalize);
- done (0);
+ done(0);
}
if (vecp) {
/* print specified aliases */
for (i = 0; i < vecp; i++)
- print_aka (akvalue (vec[i]), list, 0);
+ print_aka(akvalue(vec[i]), list, 0);
} else {
/* print them all */
for (ak = akahead; ak; ak = ak->ak_next) {
- printf ("%s: ", ak->ak_name);
- pos += strlen (ak->ak_name) + 1;
- print_aka (akresult (ak), list, pos);
+ printf("%s: ", ak->ak_name);
+ pos += strlen(ak->ak_name) + 1;
+ print_aka(akresult(ak), list, pos);
}
}
- done (0);
+ done(0);
return 1;
}
static void
-print_aka (char *p, int list, int margin)
+print_aka(char *p, int list, int margin)
{
char c;
if (p == NULL) {
- printf ("<empty>\n");
+ printf("<empty>\n");
return;
}
case ',':
if (*p) {
if (list)
- printf ("\n%*s", margin, "");
+ printf("\n%*s", margin, "");
else {
if (pos >= 68) {
- printf (",\n ");
+ printf(",\n ");
pos = 2;
} else {
- printf (", ");
+ printf(", ");
pos += 2;
}
}
default:
pos++;
- putchar (c);
+ putchar(c);
}
}
- putchar ('\n');
+ putchar('\n');
pos = 1;
}
static void
-print_usr (char *s, int list, int norm)
+print_usr(char *s, int list, int norm)
{
register char *cp, *pp, *vp;
register struct aka *ak;
register struct mailname *mp, *np;
- if ((pp = getname (s)) == NULL)
- adios (NULL, "no address in \"%s\"", s);
- if ((mp = getm (pp, NULL, 0, norm, NULL)) == NULL)
- adios (NULL, "bad address \"%s\"", s);
- while (getname (""))
+ if ((pp = getname(s)) == NULL)
+ adios(NULL, "no address in \"%s\"", s);
+ if ((mp = getm(pp, NULL, 0, norm, NULL)) == NULL)
+ adios(NULL, "bad address \"%s\"", s);
+ while (getname(""))
continue;
vp = NULL;
for (ak = akahead; ak; ak = ak->ak_next) {
- pp = akresult (ak);
- while ((cp = getname (pp))) {
- if ((np = getm (cp, NULL, 0, norm, NULL)) == NULL)
+ pp = akresult(ak);
+ while ((cp = getname(pp))) {
+ if ((np = getm(cp, NULL, 0, norm, NULL)) == NULL)
continue;
- if (!mh_strcasecmp (mp->m_host, np->m_host)
- && !mh_strcasecmp (mp->m_mbox, np->m_mbox)) {
- vp = vp ? add (ak->ak_name, add (",", vp))
- : getcpy (ak->ak_name);
- mnfree (np);
- while (getname (""))
+ if (!mh_strcasecmp(mp->m_host, np->m_host)
+ && !mh_strcasecmp(mp->m_mbox, np->m_mbox)) {
+ vp = vp ? add(ak->ak_name, add(",", vp))
+ : getcpy(ak->ak_name);
+ mnfree(np);
+ while (getname(""))
continue;
break;
}
- mnfree (np);
+ mnfree(np);
}
}
- mnfree (mp);
+ mnfree(mp);
#if 0
- printf ("%s: ", s);
- print_aka (vp ? vp : s, list, pos += strlen (s) + 1);
+ printf("%s: ", s);
+ print_aka(vp ? vp : s, list, pos += strlen(s) + 1);
#else
- print_aka (vp ? vp : s, list, 0);
+ print_aka(vp ? vp : s, list, 0);
#endif
if (vp)
- free (vp);
+ free(vp);
}
/*
** prototypes
*/
-int alias (char *);
-int akvisible (void);
-void init_pw (void);
-char *akresult (struct aka *);
-char *akvalue (char *);
-char *akerror (int);
-
-static char *akval (struct aka *, char *);
-static int aleq (char *, char *);
-static char *scanp (unsigned char *);
-static char *getp (char *);
-static char *seekp (char *, char *, char **);
-static int addfile (struct aka *, char *);
-static int addgroup (struct aka *, char *);
-static int addmember (struct aka *, char *);
-static int addall (struct aka *);
-static char *getalias (char *);
-static void add_aka (struct aka *, char *);
-static struct aka *akalloc (char *);
-static struct home *hmalloc (struct passwd *);
-struct home *seek_home (char *);
+int alias(char *);
+int akvisible(void);
+void init_pw(void);
+char *akresult(struct aka *);
+char *akvalue(char *);
+char *akerror(int);
+
+static char *akval(struct aka *, char *);
+static int aleq(char *, char *);
+static char *scanp(unsigned char *);
+static char *getp(char *);
+static char *seekp(char *, char *, char **);
+static int addfile(struct aka *, char *);
+static int addgroup(struct aka *, char *);
+static int addmember(struct aka *, char *);
+static int addall(struct aka *);
+static char *getalias(char *);
+static void add_aka(struct aka *, char *);
+static struct aka *akalloc(char *);
+static struct home *hmalloc(struct passwd *);
+struct home *seek_home(char *);
/* Do mh alias substitution on 's' and return the results. */
char *
-akvalue (char *s)
+akvalue(char *s)
{
register char *v;
if (akahead == NULL)
- alias (AliasFile);
+ alias(AliasFile);
akvis = -1;
- v = akval (akahead, s);
+ v = akval(akahead, s);
if (akvis == -1)
akvis = 0;
return v;
int
-akvisible (void)
+akvisible(void)
{
return akvis;
}
char *
-akresult (struct aka *ak)
+akresult(struct aka *ak)
{
register char *cp = NULL, *dp, *pp;
register struct adr *ad;
for (ad = ak->ak_addr; ad; ad = ad->ad_next) {
- pp = ad->ad_local ? akval (ak->ak_next, ad->ad_text)
- : getcpy (ad->ad_text);
+ pp = ad->ad_local ? akval(ak->ak_next, ad->ad_text)
+ : getcpy(ad->ad_text);
if (cp) {
dp = cp;
- cp = concat (cp, ",", pp, NULL);
- free (dp);
- free (pp);
+ cp = concat(cp, ",", pp, NULL);
+ free(dp);
+ free(pp);
} else
cp = pp;
}
static char *
-akval (struct aka *ak, char *s)
+akval(struct aka *ak, char *s)
{
if (!s)
return s; /* XXX */
for (; ak; ak = ak->ak_next)
- if (aleq (s, ak->ak_name))
- return akresult (ak);
+ if (aleq(s, ak->ak_name))
+ return akresult(ak);
- return getcpy (s);
+ return getcpy(s);
}
static int
-aleq (char *string, char *aliasent)
+aleq(char *string, char *aliasent)
{
register char c;
int
-alias (char *file)
+alias(char *file)
{
int i;
register char *bp, *cp, *pp;
register FILE *fp;
if (*file != '/'
- && (strncmp (file, "./", 2) && strncmp (file, "../", 3)))
- file = etcpath (file);
- if ((fp = fopen (file, "r")) == NULL) {
+ && (strncmp(file, "./", 2) && strncmp(file, "../", 3)))
+ file = etcpath(file);
+ if ((fp = fopen(file, "r")) == NULL) {
akerrst = file;
return AK_NOFILE;
}
- while (vfgets (fp, &ap) == OK) {
+ while (vfgets(fp, &ap) == OK) {
bp = ap;
- switch (*(pp = scanp (bp))) {
+ switch (*(pp = scanp(bp))) {
case '<': /* recurse a level */
- if (!*(cp = getp (pp + 1))) {
+ if (!*(cp = getp(pp + 1))) {
akerrst = "'<' without alias-file";
- fclose (fp);
+ fclose(fp);
return AK_ERROR;
}
- if ((i = alias (cp)) != AK_OK) {
- fclose (fp);
+ if ((i = alias(cp)) != AK_OK) {
+ fclose(fp);
return i;
}
}
akerrst = bp;
- if (!*(cp = seekp (pp, &lc, &ap))) {
- fclose (fp);
+ if (!*(cp = seekp(pp, &lc, &ap))) {
+ fclose(fp);
return AK_ERROR;
}
- if (!(ak = akalloc (cp))) {
- fclose (fp);
+ if (!(ak = akalloc(cp))) {
+ fclose(fp);
return AK_LIMIT;
}
switch (lc) {
break;
default:
- fclose (fp);
+ fclose(fp);
return AK_ERROR;
}
- switch (*(pp = scanp (ap))) {
+ switch (*(pp = scanp(ap))) {
case 0: /* EOL */
- fclose (fp);
+ fclose(fp);
return AK_ERROR;
case '<': /* read values from file */
- if (!*(cp = getp (pp + 1))) {
- fclose (fp);
+ if (!*(cp = getp(pp + 1))) {
+ fclose(fp);
return AK_ERROR;
}
- if (!addfile (ak, cp)) {
- fclose (fp);
+ if (!addfile(ak, cp)) {
+ fclose(fp);
return AK_NOFILE;
}
break;
case '=': /* UNIX group */
- if (!*(cp = getp (pp + 1))) {
- fclose (fp);
+ if (!*(cp = getp(pp + 1))) {
+ fclose(fp);
return AK_ERROR;
}
- if (!addgroup (ak, cp)) {
- fclose (fp);
+ if (!addgroup(ak, cp)) {
+ fclose(fp);
return AK_NOGROUP;
}
break;
case '+': /* UNIX group members */
- if (!*(cp = getp (pp + 1))) {
- fclose (fp);
+ if (!*(cp = getp(pp + 1))) {
+ fclose(fp);
return AK_ERROR;
}
- if (!addmember (ak, cp)) {
- fclose (fp);
+ if (!addmember(ak, cp)) {
+ fclose(fp);
return AK_NOGROUP;
}
break;
case '*': /* Everyone */
- addall (ak);
+ addall(ak);
break;
default: /* list */
- while ((cp = getalias (pp)))
- add_aka (ak, cp);
+ while ((cp = getalias(pp)))
+ add_aka(ak, cp);
break;
}
}
- fclose (fp);
+ fclose(fp);
return AK_OK;
}
char *
-akerror (int i)
+akerror(int i)
{
static char buffer[BUFSIZ];
switch (i) {
case AK_NOFILE:
- snprintf (buffer, sizeof(buffer), "unable to read '%s'", akerrst);
+ snprintf(buffer, sizeof(buffer), "unable to read '%s'", akerrst);
break;
case AK_ERROR:
- snprintf (buffer, sizeof(buffer), "error in line '%s'", akerrst);
+ snprintf(buffer, sizeof(buffer), "error in line '%s'", akerrst);
break;
case AK_LIMIT:
- snprintf (buffer, sizeof(buffer), "out of memory while on '%s'", akerrst);
+ snprintf(buffer, sizeof(buffer), "out of memory while on '%s'", akerrst);
break;
case AK_NOGROUP:
- snprintf (buffer, sizeof(buffer), "no such group as '%s'", akerrst);
+ snprintf(buffer, sizeof(buffer), "no such group as '%s'", akerrst);
break;
default:
- snprintf (buffer, sizeof(buffer), "unknown error (%d)", i);
+ snprintf(buffer, sizeof(buffer), "unknown error (%d)", i);
break;
}
static char *
-scanp (unsigned char *p)
+scanp(unsigned char *p)
{
- while (isspace (*p))
+ while (isspace(*p))
p++;
return p;
}
static char *
-getp (char *p)
+getp(char *p)
{
- register unsigned char *cp = scanp (p);
+ register unsigned char *cp = scanp(p);
p = cp;
- while (!isspace (*cp) && *cp)
+ while (!isspace(*cp) && *cp)
cp++;
*cp = 0;
static char *
-seekp (char *p, char *c, char **a)
+seekp(char *p, char *c, char **a)
{
register unsigned char *cp;
- p = cp = scanp (p);
- while (!isspace (*cp) && *cp && *cp != ':' && *cp != ';')
+ p = cp = scanp(p);
+ while (!isspace(*cp) && *cp && *cp != ':' && *cp != ';')
cp++;
*c = *cp;
*cp++ = 0;
static int
-addfile (struct aka *ak, char *file)
+addfile(struct aka *ak, char *file)
{
register char *cp;
char buffer[BUFSIZ];
register FILE *fp;
- if (!(fp = fopen (etcpath (file), "r"))) {
+ if (!(fp = fopen(etcpath(file), "r"))) {
akerrst = file;
return 0;
}
- while (fgets (buffer, sizeof buffer, fp))
- while ((cp = getalias (buffer)))
- add_aka (ak, cp);
+ while (fgets(buffer, sizeof buffer, fp))
+ while ((cp = getalias(buffer)))
+ add_aka(ak, cp);
- fclose (fp);
+ fclose(fp);
return 1;
}
static int
-addgroup (struct aka *ak, char *grp)
+addgroup(struct aka *ak, char *grp)
{
register char *gp;
- register struct group *gr = getgrnam (grp);
+ register struct group *gr = getgrnam(grp);
register struct home *hm = NULL;
if (!gr)
- gr = getgrgid (atoi (grp));
+ gr = getgrgid(atoi(grp));
if (!gr) {
akerrst = grp;
return 0;
#ifndef DBMPWD
if (homehead == NULL)
- init_pw ();
+ init_pw();
#endif /* DBMPWD */
while ((gp = *gr->gr_mem++))
struct passwd *pw;
#endif /* DBMPWD */
for (hm = homehead; hm; hm = hm->h_next)
- if (!strcmp (hm->h_name, gp)) {
- add_aka (ak, hm->h_name);
+ if (!strcmp(hm->h_name, gp)) {
+ add_aka(ak, hm->h_name);
break;
}
#ifdef DBMPWD
if ((pw = getpwnam(gp))) {
hmalloc(pw);
- add_aka (ak, gp);
+ add_aka(ak, gp);
}
}
#endif /* DBMPWD */
static int
-addmember (struct aka *ak, char *grp)
+addmember(struct aka *ak, char *grp)
{
gid_t gid;
- register struct group *gr = getgrnam (grp);
+ register struct group *gr = getgrnam(grp);
register struct home *hm = NULL;
if (gr)
gid = gr->gr_gid;
else {
- gid = atoi (grp);
- gr = getgrgid (gid);
+ gid = atoi(grp);
+ gr = getgrgid(gid);
}
if (!gr) {
akerrst = grp;
#ifndef DBMPWD
if (homehead == NULL)
#endif /* DBMPWD */
- init_pw ();
+ init_pw();
for (hm = homehead; hm; hm = hm->h_next)
if (hm->h_gid == gid)
- add_aka (ak, hm->h_name);
+ add_aka(ak, hm->h_name);
return 1;
}
static int
-addall (struct aka *ak)
+addall(struct aka *ak)
{
int noshell = NoShell == NULL || *NoShell == 0;
register struct home *hm;
#ifndef DBMPWD
if (homehead == NULL)
#endif /* DBMPWD */
- init_pw ();
+ init_pw();
if (Everyone < 0)
Everyone = EVERYONE;
for (hm = homehead; hm; hm = hm->h_next)
if (hm->h_uid > Everyone
- && (noshell || strcmp (hm->h_shell, NoShell)))
- add_aka (ak, hm->h_name);
+ && (noshell || strcmp(hm->h_shell, NoShell)))
+ add_aka(ak, hm->h_name);
return homehead != NULL;
}
static char *
-getalias (char *addrs)
+getalias(char *addrs)
{
register unsigned char *pp, *qp;
static char *cp = NULL;
if (*cp == 0)
return (cp = NULL);
- for (pp = cp; isspace (*pp); pp++)
+ for (pp = cp; isspace(*pp); pp++)
continue;
if (*pp == 0)
return (cp = NULL);
*qp++ = 0;
for (cp = qp, qp--; qp > pp; qp--)
if (*qp != 0) {
- if (isspace (*qp))
+ if (isspace(*qp))
*qp = 0;
else
break;
static void
-add_aka (struct aka *ak, char *pp)
+add_aka(struct aka *ak, char *pp)
{
register struct adr *ad, *ld;
for (ad = ak->ak_addr, ld = NULL; ad; ld = ad, ad = ad->ad_next)
- if (!strcmp (pp, ad->ad_text))
+ if (!strcmp(pp, ad->ad_text))
return;
- ad = (struct adr *) mh_xmalloc (sizeof(*ad));
- ad->ad_text = getcpy (pp);
+ ad = (struct adr *) mh_xmalloc(sizeof(*ad));
+ ad->ad_text = getcpy(pp);
ad->ad_local = strchr(pp, '@') == NULL && strchr(pp, '!') == NULL;
ad->ad_next = NULL;
if (ak->ak_addr)
void
-init_pw (void)
+init_pw(void)
{
register struct passwd *pw;
#ifdef DBMPWD
init++;
#endif /* DBMPWD */
- setpwent ();
+ setpwent();
- while ((pw = getpwent ()))
- if (!hmalloc (pw))
+ while ((pw = getpwent()))
+ if (!hmalloc(pw))
break;
- endpwent ();
+ endpwent();
#ifdef DBMPWD
}
#endif /* DBMPWD */
static struct aka *
-akalloc (char *id)
+akalloc(char *id)
{
register struct aka *p;
- p = (struct aka *) mh_xmalloc (sizeof(*p));
+ p = (struct aka *) mh_xmalloc(sizeof(*p));
- p->ak_name = getcpy (id);
+ p->ak_name = getcpy(id);
p->ak_visible = 0;
p->ak_addr = NULL;
p->ak_next = NULL;
static struct home *
-hmalloc (struct passwd *pw)
+hmalloc(struct passwd *pw)
{
register struct home *p;
- p = (struct home *) mh_xmalloc (sizeof(*p));
+ p = (struct home *) mh_xmalloc(sizeof(*p));
- p->h_name = getcpy (pw->pw_name);
+ p->h_name = getcpy(pw->pw_name);
p->h_uid = pw->pw_uid;
p->h_gid = pw->pw_gid;
- p->h_home = getcpy (pw->pw_dir);
- p->h_shell = getcpy (pw->pw_shell);
+ p->h_home = getcpy(pw->pw_dir);
+ p->h_shell = getcpy(pw->pw_shell);
p->h_ngrps = 0;
p->h_next = NULL;
if (hometail != NULL)
struct home *
-seek_home (char *name)
+seek_home(char *name)
{
register struct home *hp;
#ifdef DBMPWD
#else /* DBMPWD */
if (homehead == NULL)
- init_pw ();
+ init_pw();
#endif /* DBMPWD */
for (hp = homehead; hp; hp = hp->h_next)
- if (!mh_strcasecmp (name, hp->h_name))
+ if (!mh_strcasecmp(name, hp->h_name))
return hp;
#ifdef DBMPWD
for (c = name, c1 = lname; *c && (c1 - lname < sizeof(lname) - 1);
c++, c1++) {
if (isalpha(*c) && isupper(*c))
- *c1 = tolower (*c);
+ *c1 = tolower(*c);
else
*c1 = *c;
}
/*
** static prototypes
*/
-static void make_comp (unsigned char **);
+static void make_comp(unsigned char **);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int inplace = 1, datesw = 1;
int msgnum;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
invo_name);
- print_help (buf, switches, 1);
- done (1);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case COMPSW:
if (comp)
- adios (NULL, "only one component at a time!");
+ adios(NULL, "only one component at a time!");
if (!(comp = *argp++) || *comp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case DATESW:
case TEXTSW:
if (text)
- adios (NULL, "only one body at a time!");
+ adios(NULL, "only one body at a time!");
if (!(text = *argp++) || *text == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case DELETESW: /* delete annotations */
case NUMBERSW: /* number listing or delete by number */
if (number != 0)
- adios (NULL, "only one number at a time!");
+ adios(NULL, "only one number at a time!");
if (argp - arguments == argc - 1 || **argp == '-')
number = 1;
number = -1;
else if (!(number = atoi(*argp)))
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
argp++;
}
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
app_msgarg(&msgs, cp);
}
datesw = 0;
#endif /* UCI */
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
+ if (!m_convert(mp, msgs.msgs[msgnum]))
+ done(1);
- make_comp (&comp);
+ make_comp(&comp);
/* annotate all the SELECTED messages */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (list)
annolist(m_name(msgnum), comp, text, number);
else
- annotate (m_name (msgnum), comp, text, inplace, datesw, delete, append);
+ annotate(m_name(msgnum), comp, text, inplace, datesw, delete, append);
}
}
- context_replace (pfolder, folder); /* update current folder */
- seq_setcur (mp, mp->lowsel); /* update current message */
- seq_save (mp); /* synchronize message sequences */
- folder_free (mp); /* free folder/message structure */
- context_save (); /* save the context file */
- done (0);
+ context_replace(pfolder, folder); /* update current folder */
+ seq_setcur(mp, mp->lowsel); /* update current message */
+ seq_save(mp); /* synchronize message sequences */
+ folder_free(mp); /* free folder/message structure */
+ context_save(); /* save the context file */
+ done(0);
return 1;
}
static void
-make_comp (unsigned char **ap)
+make_comp(unsigned char **ap)
{
register unsigned char *cp;
char buffer[BUFSIZ];
if (*ap == NULL) {
- printf ("Enter component name: ");
- fflush (stdout);
+ printf("Enter component name: ");
+ fflush(stdout);
- if (fgets (buffer, sizeof buffer, stdin) == NULL)
- done (1);
- *ap = trimcpy (buffer);
+ if (fgets(buffer, sizeof buffer, stdin) == NULL)
+ done(1);
+ *ap = trimcpy(buffer);
}
- if ((cp = *ap + strlen (*ap) - 1) > *ap && *cp == ':')
+ if ((cp = *ap + strlen(*ap) - 1) > *ap && *cp == ':')
*cp = 0;
- if (strlen (*ap) == 0)
- adios (NULL, "null component name");
+ if (strlen(*ap) == 0)
+ adios(NULL, "null component name");
if (**ap == '-')
- adios (NULL, "invalid component name %s", *ap);
- if (strlen (*ap) >= NAMESZ)
- adios (NULL, "too large component name %s", *ap);
+ adios(NULL, "invalid component name %s", *ap);
+ if (strlen(*ap) >= NAMESZ)
+ adios(NULL, "too large component name %s", *ap);
for (cp = *ap; *cp; cp++)
- if (!isalnum (*cp) && *cp != '-')
- adios (NULL, "invalid component name %s", *ap);
+ if (!isalnum(*cp) && *cp != '-')
+ adios(NULL, "invalid component name %s", *ap);
}
/*
** static prototypes
*/
-static int annosbr (int, char *, char *, char *, int, int, int, int);
+static int annosbr(int, char *, char *, char *, int, int, int, int);
/*
** This "local" global and the annopreserve() function are a hack that
static int preserve_actime_and_modtime = 0;
int
-annotate (char *file, char *comp, char *text, int inplace, int datesw,
+annotate(char *file, char *comp, char *text, int inplace, int datesw,
int delete, int append)
{
int i, fd;
struct stat s;
/* open and lock the file to be annotated */
- if ((fd = lkopen (file, O_RDWR, 0)) == NOTOK) {
+ if ((fd = lkopen(file, O_RDWR, 0)) == NOTOK) {
switch (errno) {
case ENOENT:
break;
default:
- admonish (file, "unable to lock and open");
+ admonish(file, "unable to lock and open");
break;
}
return 1;
b.actime = s.st_atime;
b.modtime = s.st_mtime;
- i = annosbr (fd, file, comp, text, inplace, datesw, delete, append);
+ i = annosbr(fd, file, comp, text, inplace, datesw, delete, append);
if (preserve_actime_and_modtime && utime(file, &b) == -1)
advise("can't set access and modification times for %s", file);
- lkclose (fd, file);
+ lkclose(fd, file);
return i;
}
}
static int
-annosbr (int fd, char *file, char *comp, char *text, int inplace,
+annosbr(int fd, char *file, char *comp, char *text, int inplace,
int datesw, int delete, int append)
{
int mode, tmpfd;
int length; /* length of field name */
int n; /* number of bytes written */
- mode = fstat (fd, &st) != NOTOK ? (st.st_mode & 0777) : m_gmprot ();
+ mode = fstat(fd, &st) != NOTOK ? (st.st_mode & 0777) : m_gmprot();
- strncpy (tmpfil, m_mktemp2(file, "annotate", NULL, &tmp), sizeof(tmpfil));
- chmod (tmpfil, mode);
+ strncpy(tmpfil, m_mktemp2(file, "annotate", NULL, &tmp), sizeof(tmpfil));
+ chmod(tmpfil, mode);
/*
** We're going to need to copy some of the message file to the
}
if (datesw)
- fprintf (tmp, "%s: %s\n", comp, dtimenow (0));
+ fprintf(tmp, "%s: %s\n", comp, dtimenow(0));
if ((cp = text)) {
do {
while (*cp == ' ' || *cp == '\t')
while (*cp && *cp++ != '\n')
continue;
if (cp - sp)
- fprintf (tmp, "%s: %*.*s", comp, (int)(cp - sp), (int)(cp - sp), sp);
+ fprintf(tmp, "%s: %*.*s", comp, (int)(cp - sp), (int)(cp - sp), sp);
} while (*cp);
if (cp[-1] != '\n' && cp != text)
- putc ('\n', tmp);
+ putc('\n', tmp);
}
}
- fflush (tmp);
+ fflush(tmp);
/*
** We've been messing with the input file position. Move the
adios(NULL, "can't seek.");
}
- cpydata (fd, fileno (tmp), file, tmpfil);
- fclose (tmp);
+ cpydata(fd, fileno(tmp), file, tmpfil);
+ fclose(tmp);
if (inplace) {
- if ((tmpfd = open (tmpfil, O_RDONLY)) == NOTOK)
- adios (tmpfil, "unable to open for re-reading");
+ if ((tmpfd = open(tmpfil, O_RDONLY)) == NOTOK)
+ adios(tmpfil, "unable to open for re-reading");
- lseek (fd, (off_t) 0, SEEK_SET);
+ lseek(fd, (off_t) 0, SEEK_SET);
/*
** We're making the file shorter if we're deleting a
if (delete >= -1 && ftruncate(fd, 0) == -1)
adios(tmpfil, "unable to truncate.");
- cpydata (tmpfd, fd, tmpfil, file);
- close (tmpfd);
- unlink (tmpfil);
+ cpydata(tmpfd, fd, tmpfil, file);
+ close(tmpfd);
+ unlink(tmpfil);
} else {
- strncpy (buffer, m_backup (file), sizeof(buffer));
- if (rename (file, buffer) == NOTOK) {
+ strncpy(buffer, m_backup(file), sizeof(buffer));
+ if (rename(file, buffer) == NOTOK) {
switch (errno) {
case ENOENT: /* unlinked early - no annotations */
- unlink (tmpfil);
+ unlink(tmpfil);
break;
default:
- admonish (buffer, "unable to rename %s to", file);
+ admonish(buffer, "unable to rename %s to", file);
break;
}
return 1;
}
- if (rename (tmpfil, file) == NOTOK) {
- admonish (file, "unable to rename %s to", tmpfil);
+ if (rename(tmpfil, file) == NOTOK) {
+ admonish(file, "unable to rename %s to", tmpfil);
return 1;
}
}
/*
** prototypes
*/
-int sc_width (void); /* from termsbr.c */
+int sc_width(void); /* from termsbr.c */
/*
** static prototypes
*/
-static int process (char *, int, int);
+static int process(char *, int, int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int addrp = 0, normalize = AD_HOST;
int width = 0, status = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] addrs ...",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches] addrs ...", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
- print_version (invo_name);
- done (1);
+ print_version(invo_name);
+ done(1);
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
format = NULL;
continue;
case FMTSW:
if (!(format = *argp++) || *format == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
form = NULL;
continue;
case WIDTHSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- width = atoi (cp);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ width = atoi(cp);
continue;
case NORMSW:
}
}
if (addrp > NADDRS)
- adios (NULL, "more than %d addresses", NADDRS);
+ adios(NULL, "more than %d addresses", NADDRS);
else
addrs[addrp++] = cp;
}
addrs[addrp] = NULL;
if (addrp == 0)
- adios (NULL, "usage: %s [switches] addrs ...", invo_name);
+ adios(NULL, "usage: %s [switches] addrs ...", invo_name);
/* get new format string */
- nfs = new_fs (form, format, FORMAT);
+ nfs = new_fs(form, format, FORMAT);
if (width == 0) {
- if ((width = sc_width ()) < WIDTH / 2)
+ if ((width = sc_width()) < WIDTH / 2)
width = WIDTH / 2;
width -= 2;
}
if (width > WBUFSIZ)
width = WBUFSIZ;
fmt_norm = normalize;
- fmt_compile (nfs, &fmt);
+ fmt_compile(nfs, &fmt);
dat[0] = 0;
dat[1] = 0;
dat[4] = 0;
for (addrp = 0; addrs[addrp]; addrp++)
- status += process (addrs[addrp], width, normalize);
+ status += process(addrs[addrp], width, normalize);
- done (status);
+ done(status);
return 1;
}
static int
-process (char *arg, int length, int norm)
+process(char *arg, int length, int norm)
{
int status = 0;
register char *cp;
register struct mailname *mp;
(q = &pq)->pq_next = NULL;
- while ((cp = getname (arg))) {
- if ((p = (struct pqpair *) calloc ((size_t) 1, sizeof(*p))) == NULL)
- adios (NULL, "unable to allocate pqpair memory");
- if ((mp = getm (cp, NULL, 0, norm, error)) == NULL) {
- p->pq_text = getcpy (cp);
- p->pq_error = getcpy (error);
+ while ((cp = getname(arg))) {
+ if ((p = (struct pqpair *)
+ calloc((size_t) 1, sizeof(*p))) == NULL)
+ adios(NULL, "unable to allocate pqpair memory");
+ if ((mp = getm(cp, NULL, 0, norm, error)) == NULL) {
+ p->pq_text = getcpy(cp);
+ p->pq_error = getcpy(error);
status++;
} else {
- p->pq_text = getcpy (mp->m_text);
- mnfree (mp);
+ p->pq_text = getcpy(mp->m_text);
+ mnfree(mp);
}
q = (q->pq_next = p);
}
for (p = pq.pq_next; p; p = q) {
- FINDCOMP (cptr, "text");
+ FINDCOMP(cptr, "text");
if (cptr)
cptr->c_text = p->pq_text;
- FINDCOMP (cptr, "error");
+ FINDCOMP(cptr, "error");
if (cptr)
cptr->c_text = p->pq_error;
- fmt_scan (fmt, buffer, length, dat);
- fputs (buffer, stdout);
+ fmt_scan(fmt, buffer, length, dat);
+ fputs(buffer, stdout);
- free (p->pq_text);
+ free(p->pq_text);
if (p->pq_error)
- free (p->pq_error);
+ free(p->pq_error);
q = p->pq_next;
- free ((char *) p);
+ free((char *) p);
}
return status;
/*
** 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);
+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);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int inplace = 0, quietsw = 0, verbosw = 0;
int msgp = 0, hi, msgnum, numburst;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown\n", cp);
+ adios(NULL, "-%s unknown\n", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case INPLSW:
inplace++;
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else {
msgs[msgp++] = cp;
}
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (!msgp)
msgs[msgp++] = "cur";
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgp; msgnum++)
- if (!m_convert (mp, msgs[msgnum]))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msgs[msgnum]))
+ done(1);
+ seq_setprev(mp); /* set the previous-sequence */
smsgs = (struct smsg *)
- calloc ((size_t) (MAXFOLDER + 2), sizeof(*smsgs));
+ calloc((size_t) (MAXFOLDER + 2), sizeof(*smsgs));
if (smsgs == NULL)
- adios (NULL, "unable to allocate burst storage");
+ adios(NULL, "unable to allocate burst storage");
hi = mp->hghmsg + 1;
/* burst all the SELECTED messages */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
- if (is_selected (mp, msgnum)) {
- if ((numburst = find_delim (msgnum, smsgs)) >= 1) {
+ if (is_selected(mp, msgnum)) {
+ if ((numburst = find_delim(msgnum, smsgs)) >= 1) {
if (verbosw)
- printf ("%d message%s exploded from digest %d\n",
- numburst, numburst > 1 ? "s" : "", msgnum);
- burst (&mp, msgnum, smsgs, numburst, inplace, verbosw, maildir);
+ printf("%d message%s exploded from digest %d\n", numburst, numburst > 1 ? "s" : "", msgnum);
+ burst(&mp, msgnum, smsgs, numburst, inplace, verbosw, maildir);
} else {
if (numburst == 0) {
if (!quietsw)
- admonish (NULL, "message %d not in digest format",
- msgnum);
+ admonish(NULL, "message %d not in digest format", msgnum);
} /* this pair of braces was missing before 1999-07-15 */
else
- adios (NULL, "burst() botch -- you lose big");
+ adios(NULL, "burst() botch -- you lose big");
}
}
}
- free ((char *) smsgs);
- context_replace (pfolder, folder); /* update current folder */
+ free((char *) smsgs);
+ context_replace(pfolder, folder); /* update current folder */
/*
** If -inplace is given, then the first message burst becomes
*/
if (inplace) {
if (mp->lowsel != mp->curmsg)
- seq_setcur (mp, mp->lowsel);
+ seq_setcur(mp, mp->lowsel);
} else {
if (hi <= mp->hghmsg)
- seq_setcur (mp, hi);
+ seq_setcur(mp, hi);
}
- seq_save (mp); /* synchronize message sequences */
- context_save (); /* save the context file */
- folder_free (mp); /* free folder/message structure */
- done (0);
+ seq_save(mp); /* synchronize message sequences */
+ context_save(); /* save the context file */
+ folder_free(mp); /* free folder/message structure */
+ done(0);
return 1;
}
*/
static int
-find_delim (int msgnum, struct smsg *smsgs)
+find_delim(int msgnum, struct smsg *smsgs)
{
int ld3, wasdlm, msgp;
long pos;
char buffer[BUFSIZ];
FILE *in;
- ld3 = strlen (delim3);
+ ld3 = strlen(delim3);
- if ((in = fopen (msgnam = m_name (msgnum), "r")) == NULL)
- adios (msgnam, "unable to read message");
+ if ((in = fopen(msgnam = m_name(msgnum), "r")) == NULL)
+ adios(msgnam, "unable to read message");
for (msgp = 0, pos = 0L; msgp <= MAXFOLDER;) {
- while (fgets (buffer, sizeof(buffer), in) && buffer[0] == '\n')
- pos += (long) strlen (buffer);
- if (feof (in))
+ while (fgets(buffer, sizeof(buffer), in) && buffer[0] == '\n')
+ pos += (long) strlen(buffer);
+ if (feof(in))
break;
- fseek (in, pos, SEEK_SET);
+ fseek(in, pos, SEEK_SET);
smsgs[msgp].s_start = pos;
- for (c = 0; fgets (buffer, sizeof(buffer), in); c = buffer[0]) {
- if (strncmp (buffer, delim3, ld3) == 0
+ for (c = 0; fgets(buffer, sizeof(buffer), in); c = buffer[0]) {
+ if (strncmp(buffer, delim3, ld3) == 0
&& (msgp == 1 || c == '\n')
- && ((cc = peekc (in)) == '\n' || cc == EOF))
+ && ((cc = peekc(in)) == '\n' ||
+ cc == EOF))
break;
else
- pos += (long) strlen (buffer);
+ pos += (long) strlen(buffer);
}
- wasdlm = strncmp (buffer, delim3, ld3) == 0;
+ wasdlm = strncmp(buffer, delim3, ld3) == 0;
if (smsgs[msgp].s_start != pos)
- smsgs[msgp++].s_stop = (c == '\n' && wasdlm) ? pos - 1 : pos;
- if (feof (in)) {
+ smsgs[msgp++].s_stop = (c == '\n' && wasdlm) ?
+ pos - 1 : pos;
+ if (feof(in)) {
#if 0
if (wasdlm) {
- smsgs[msgp - 1].s_stop -= ((long) strlen (buffer) + 1);
+ smsgs[msgp - 1].s_stop -=
+ ((long) strlen(buffer) + 1);
msgp++; /* fake "End of XXX Digest" */
}
#endif
break;
}
- pos += (long) strlen (buffer);
+ pos += (long) strlen(buffer);
}
- fclose (in);
+ fclose(in);
return (msgp - 1); /* toss "End of XXX Digest" */
}
*/
static void
-burst (struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst,
+burst(struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst,
int inplace, int verbosw, char *maildir)
{
int i, j, mode;
struct stat st;
struct msgs *mp;
- if ((in = fopen (msgnam = m_name (msgnum), "r")) == NULL)
- adios (msgnam, "unable to read message");
+ if ((in = fopen(msgnam = m_name(msgnum), "r")) == NULL)
+ adios(msgnam, "unable to read message");
- mode = fstat (fileno(in), &st) != NOTOK ? (st.st_mode & 0777) : m_gmprot();
+ mode = fstat(fileno(in), &st) != NOTOK ?
+ (st.st_mode & 0777) : m_gmprot();
mp = *mpp;
/*
** structure for all the new messages.
*/
if ((mp->hghmsg + numburst > mp->hghoff) &&
- !(mp = folder_realloc (mp, mp->lowoff, mp->hghmsg + numburst)))
- adios (NULL, "unable to allocate folder storage");
+ !(mp = folder_realloc(mp, mp->lowoff, mp->hghmsg + numburst)))
+ adios(NULL, "unable to allocate folder storage");
*mpp = mp;
j = mp->hghmsg; /* old value */
*/
if (inplace) {
for (i = mp->hghmsg; j > msgnum; i--, j--) {
- strncpy (f1, m_name (i), sizeof(f1));
- strncpy (f2, m_name (j), sizeof(f2));
- if (does_exist (mp, j)) {
+ strncpy(f1, m_name(i), sizeof(f1));
+ strncpy(f2, m_name(j), sizeof(f2));
+ if (does_exist(mp, j)) {
if (verbosw)
- printf ("message %d becomes message %d\n", j, i);
+ printf("message %d becomes message %d\n", j, i);
- if (rename (f2, f1) == NOTOK)
- admonish (f1, "unable to rename %s to", f2);
+ if (rename(f2, f1) == NOTOK)
+ admonish(f1, "unable to rename %s to", f2);
- (void)snprintf(f1, sizeof (f1), "%s/%d", maildir, i);
- (void)snprintf(f2, sizeof (f2), "%s/%d", maildir, j);
+ snprintf(f1, sizeof (f1), "%s/%d", maildir, i);
+ snprintf(f2, sizeof (f2), "%s/%d", maildir, j);
ext_hook("ref-hook", f1, f2);
- copy_msg_flags (mp, i, j);
- clear_msg_flags (mp, j);
+ copy_msg_flags(mp, i, j);
+ clear_msg_flags(mp, j);
mp->msgflags |= SEQMOD;
}
}
}
- unset_selected (mp, msgnum);
+ unset_selected(mp, msgnum);
/* new hghmsg is hghmsg + numburst
**
i = inplace ? msgnum + numburst : mp->hghmsg;
for (j = numburst; j >= (inplace ? 0 : 1); i--, j--) {
- strncpy (f1, m_name (i), sizeof(f1));
- strncpy (f2, m_mktemp(invo_name, NULL, &out), sizeof(f2));
+ strncpy(f1, m_name(i), sizeof(f1));
+ strncpy(f2, m_mktemp(invo_name, NULL, &out), sizeof(f2));
if (verbosw && i != msgnum)
- printf ("message %d of digest %d becomes message %d\n", j, msgnum, i);
+ printf("message %d of digest %d becomes message %d\n",
+ j, msgnum, i);
- chmod (f2, mode);
- fseek (in, smsgs[j].s_start, SEEK_SET);
- cpybrst (in, out, msgnam, f2,
+ chmod(f2, mode);
+ fseek(in, smsgs[j].s_start, SEEK_SET);
+ cpybrst(in, out, msgnam, f2,
(int) (smsgs[j].s_stop - smsgs[j].s_start));
- fclose (out);
+ fclose(out);
if (i == msgnum) {
- strncpy (f3, m_backup (f1), sizeof(f3));
- if (rename (f1, f3) == NOTOK)
- admonish (f3, "unable to rename %s to", f1);
+ strncpy(f3, m_backup(f1), sizeof(f3));
+ if (rename(f1, f3) == NOTOK)
+ admonish(f3, "unable to rename %s to", f1);
(void)snprintf(f3, sizeof (f3), "%s/%d", maildir, i);
ext_hook("del-hook", f3, (char *)0);
}
- if (rename (f2, f1) == NOTOK)
- admonish (f1, "unable to rename %s to", f2);
+ if (rename(f2, f1) == NOTOK)
+ admonish(f1, "unable to rename %s to", f2);
(void)snprintf(f3, sizeof (f3), "%s/%d", maildir, i);
ext_hook("add-hook", f3, (char *)0);
- copy_msg_flags (mp, i, msgnum);
+ copy_msg_flags(mp, i, msgnum);
mp->msgflags |= SEQMOD;
}
- fclose (in);
+ fclose(in);
}
*/
static void
-cpybrst (FILE *in, FILE *out, char *ifile, char *ofile, int len)
+cpybrst(FILE *in, FILE *out, char *ifile, char *ofile, int len)
{
register int c, state;
- for (state = S1; (c = fgetc (in)) != EOF && len > 0; len--) {
+ for (state = S1; (c = fgetc(in)) != EOF && len > 0; len--) {
if (c == 0)
continue;
switch (state) {
default:
state = S2;
case '\n':
- fputc (c, out);
+ fputc(c, out);
break;
}
break;
case '\n':
state = S1;
default:
- fputc (c, out);
+ fputc(c, out);
break;
}
break;
default:
state = (c == '\n') ? S1 : S2;
- fputc ('-', out);
- fputc (c, out);
+ fputc('-', out);
+ fputc(c, out);
break;
}
break;
}
}
- if (ferror (in) && !feof (in))
- adios (ifile, "error reading");
- if (ferror (out))
- adios (ofile, "error writing");
+ if (ferror(in) && !feof(in))
+ adios(ifile, "error reading");
+ if (ferror(out))
+ adios(ofile, "error writing");
}
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int use = NOUSE, nedit = 0, nwhat = 0;
int i, in, out;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msg] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msg] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case EDITRSW:
if (!(ed = *argp++) || *ed == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
nedit = 0;
continue;
case NEDITSW:
case WHATSW:
if (!(whatnowproc = *argp++) || *whatnowproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
nwhat = 0;
continue;
case NWHATSW:
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case USESW:
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else {
if (msg)
- adios (NULL, "only one message at a time!");
+ adios(NULL, "only one message at a time!");
else
msg = cp;
}
}
- cwd = getcpy (pwd ());
+ cwd = getcpy(pwd());
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (form && (folder || msg))
- adios (NULL, "can't mix forms and folders/msgs");
+ adios(NULL, "can't mix forms and folders/msgs");
if (!use && (folder || msg)) {
/*
if (!msg)
msg = "cur";
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse the message range/sequence/name and set SELECTED */
- if (!m_convert (mp, msg))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msg))
+ done(1);
+ seq_setprev(mp); /* set the previous-sequence */
if (mp->numsel > 1)
- adios (NULL, "only one message at a time!");
+ adios(NULL, "only one message at a time!");
- if ((in = open (form = getcpy (m_name (mp->lowsel)),
+ if ((in = open(form = getcpy(m_name(mp->lowsel)),
O_RDONLY)) == NOTOK)
- adios (form, "unable to open message");
+ adios(form, "unable to open message");
} else
in = open_form(&form, components);
try_it_again:
- strncpy (drft, m_draft(use ? (msg?msg:"cur") : "new"), sizeof(drft));
+ strncpy(drft, m_draft(use ? (msg?msg:"cur") : "new"), sizeof(drft));
/*
** Check if we have an existing draft
*/
- if ((out = open (drft, O_RDONLY)) != NOTOK) {
- i = fdcompare (in, out);
- close (out);
+ if ((out = open(drft, O_RDONLY)) != NOTOK) {
+ i = fdcompare(in, out);
+ close(out);
/*
** If we have given -use flag, or if the
if (use || i)
goto edit_it;
- if (stat (drft, &st) == NOTOK)
- adios (drft, "unable to stat");
- printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size);
+ if (stat(drft, &st) == NOTOK)
+ adios(drft, "unable to stat");
+ printf("Draft \"%s\" exists (%ld bytes).",
+ drft, (long) st.st_size);
for (i = LISTDSW; i != YESW;) {
- if (!(argp = getans ("\nDisposition? ", aqrunl)))
- done (1);
- switch (i = smatch (*argp, aqrunl)) {
+ if (!(argp = getans("\nDisposition? ", aqrunl)))
+ done(1);
+ switch (i = smatch(*argp, aqrunl)) {
case NOSW:
- done (0);
+ done(0);
case NEWSW:
use = NOUSE;
goto try_it_again;
use++;
goto edit_it;
case LISTDSW:
- showfile (++argp, drft);
+ showfile(++argp, drft);
break;
case REFILSW:
- if (refile (++argp, drft) == 0)
+ if (refile(++argp, drft) == 0)
i = YESW;
break;
default:
- advise (NULL, "say what?");
+ advise(NULL, "say what?");
break;
}
}
} else if (use) {
- adios (drft, "unable to open");
+ adios(drft, "unable to open");
}
- if ((out = creat (drft, m_gmprot ())) == NOTOK)
- adios (drft, "unable to create");
- cpydata (in, out, form, drft);
- close (in);
- close (out);
+ if ((out = creat(drft, m_gmprot())) == NOTOK)
+ adios(drft, "unable to create");
+ cpydata(in, out, form, drft);
+ close(in);
+ close(out);
edit_it:
- context_save (); /* save the context file */
+ context_save(); /* save the context file */
if (nwhat)
- done (0);
- what_now (ed, nedit, use, drft, NULL, 0, NULLMP, NULL, 0, cwd);
- done (1);
+ done(0);
+ what_now(ed, nedit, use, drft, NULL, 0, NULLMP, NULL, 0, cwd);
+ done(1);
return 1;
}
/*
** prototypes
*/
-void alias_files (int, char **);
-void pwd_names (void);
-void grp_names (void);
-void grp_members (void);
-void grp_ids (void);
-void maildrops (void);
+void alias_files(int, char **);
+void pwd_names(void);
+void grp_names(void);
+void grp_members(void);
+void grp_ids(void);
+void maildrops(void);
void mdrop(char *);
-int check (char *);
-void setup (void);
+int check(char *);
+void setup(void);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int akp = 0, dp = 0;
char *cp, **argp, **arguments;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* foil search of user profile/context */
- if (context_foil (NULL) == -1)
- done (1);
+ if (context_foil(NULL) == -1)
+ done(1);
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 0);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 0);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] [aliasfiles ...]",
- invo_name);
- print_help (buf, switches, 0);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches] [aliasfiles ...]", invo_name);
+ print_help(buf, switches, 0);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case MAILSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
if (mail)
- adios (NULL, "mail to one address only");
+ adios(NULL, "mail to one address only");
else
mail = cp;
continue;
case SERCHSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
if (dp >= NDIRS)
- adios (NULL, "more than %d directories", NDIRS);
+ adios(NULL, "more than %d directories", NDIRS);
dirs[dp++] = cp;
continue;
}
if (akp == 0)
akv[akp++] = AliasFile;
if (!homehead)
- init_pw ();
+ init_pw();
if (!mail)
out = stdout;
dirs[dp] = NULL;
- alias_files (akp, akv);
- pwd_names ();
- grp_names ();
- grp_members ();
- grp_ids ();
+ alias_files(akp, akv);
+ pwd_names();
+ grp_names();
+ grp_members();
+ grp_ids();
#ifdef UCI
- ldr_names ();
- ldr_ship ();
+ ldr_names();
+ ldr_ship();
#endif /* UCI */
- maildrops ();
+ maildrops();
- done (0);
+ done(0);
return 1;
}
void
-alias_files (int akp, char **akv)
+alias_files(int akp, char **akv)
{
register int i, err;
for (i = 0; i < akp; i++)
- if ((err = alias (akv[i])) != AK_OK) {
- setup ();
- fprintf (out, "aliasing error in %s - %s\n", akv[i], akerror (err));
+ 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]);
+ fprintf(out, "alias file %s is ok\n", akv[i]);
}
void
-pwd_names (void)
+pwd_names(void)
{
int hit = 0;
register struct home *hm, *lm;
for (hm = homehead; hm; hm = hm->h_next)
for (lm = hm->h_next; lm; lm = lm->h_next)
- if (strcmp (hm->h_name, lm->h_name) == 0) {
- setup ();
- fprintf (out, "duplicate user %s(uid=%d)\n",
+ if (strcmp(hm->h_name, lm->h_name) == 0) {
+ setup();
+ fprintf(out, "duplicate user %s(uid=%d)\n",
lm->h_name, (int) lm->h_uid);
hit++;
}
if (!hit && out && !mail)
- fprintf (out, "no duplicate users\n");
+ fprintf(out, "no duplicate users\n");
}
void
-grp_names (void)
+grp_names(void)
{
int numgroups, maxgroups;
int i, hit = 0;
maxgroups = NGRPS;
grps = (char **) mh_xmalloc((size_t) (maxgroups * sizeof(*grps)));
- setgrent ();
- while ((gr = getgrent ())) {
+ setgrent();
+ while ((gr = getgrent())) {
for (i = 0; i < numgroups; i++)
- if (!strcmp (grps[i], gr->gr_name)) {
- setup ();
- fprintf (out, "duplicate group %s(gid=%d)\n",
+ if (!strcmp(grps[i], gr->gr_name)) {
+ setup();
+ fprintf(out, "duplicate group %s(gid=%d)\n",
gr->gr_name, (int) gr->gr_gid);
hit++;
break;
grps = (char **) mh_xrealloc(grps,
(size_t) (maxgroups * sizeof(*grps)));
}
- grps[numgroups++] = getcpy (gr->gr_name);
+ grps[numgroups++] = getcpy(gr->gr_name);
}
}
- endgrent ();
+ endgrent();
for (i = 0; i < numgroups; i++)
- free (grps[i]);
- free (grps);
+ free(grps[i]);
+ free(grps);
if (!hit && out && !mail)
- fprintf (out, "no duplicate groups\n");
+ fprintf(out, "no duplicate groups\n");
}
void
-grp_members (void)
+grp_members(void)
{
register int hit = 0;
register char **cp, **dp;
register struct group *gr;
register struct home *hm;
- setgrent ();
- while ((gr = getgrent ())) {
+ setgrent();
+ while ((gr = getgrent())) {
for (cp = gr->gr_mem; *cp; cp++) {
for (hm = homehead; hm; hm = hm->h_next)
- if (!strcmp (*cp, hm->h_name))
+ if (!strcmp(*cp, hm->h_name))
break;
if (hm == NULL) {
- setup ();
- fprintf (out, "group %s(gid=%d) has unknown member %s\n",
- gr->gr_name, (int) gr->gr_gid, *cp);
+ setup();
+ fprintf(out, "group %s(gid=%d) has unknown member %s\n", gr->gr_name, (int) gr->gr_gid, *cp);
hit++;
} else {
hm->h_ngrps++;
}
for (dp = cp + 1; *dp; dp++)
- if (strcmp (*cp, *dp) == 0) {
- setup ();
- fprintf (out, "group %s(gid=%d) has duplicate member %s\n",
- gr->gr_name, (int) gr->gr_gid, *cp);
+ if (strcmp(*cp, *dp) == 0) {
+ setup();
+ fprintf(out, "group %s(gid=%d) has duplicate member %s\n", gr->gr_name, (int) gr->gr_gid, *cp);
hit++;
}
}
}
- endgrent ();
+ endgrent();
for (hm = homehead; hm; hm = hm->h_next)
if (hm->h_ngrps > NGROUPS_MAX) {
- setup ();
- fprintf (out, "user %s is a member of %d groups (max %d)\n",
+ setup();
+ fprintf(out, "user %s is a member of %d groups (max %d)\n",
hm->h_name, hm->h_ngrps, NGROUPS_MAX);
hit++;
}
if (!hit && out && !mail)
- fprintf (out, "all group members accounted for\n");
+ fprintf(out, "all group members accounted for\n");
}
void
-grp_ids (void)
+grp_ids(void)
{ /* -DRAND not implemented at most places */
register int hit = 0;
register struct home *hm;
for (hm = homehead; hm; hm = hm->h_next)
- if (getgrgid (hm->h_gid) == NULL) {
- setup ();
- fprintf (out, "user %s(uid=%d) has unknown group-id %d\n",
- hm->h_name, (int) hm->h_uid, (int) hm->h_gid);
+ if (getgrgid(hm->h_gid) == NULL) {
+ setup();
+ fprintf(out, "user %s(uid=%d) has unknown group-id %d\n", hm->h_name, (int) hm->h_uid, (int) hm->h_gid);
hit++;
}
if (!hit && out && !mail)
- fprintf (out, "all group-id users accounted for\n");
+ fprintf(out, "all group-id users accounted for\n");
}
void
-maildrops (void)
+maildrops(void)
{
register int i;
if (mmdfldir && *mmdfldir)
- mdrop (mmdfldir);
+ mdrop(mmdfldir);
if (uucpldir && *uucpldir)
- mdrop (uucpldir);
+ mdrop(uucpldir);
for (i = 0; dirs[i]; i++)
- mdrop (dirs[i]);
+ mdrop(dirs[i]);
}
{
register int hit = 0;
register struct dirent *dp;
- register DIR *dd = opendir (drop);
+ register DIR *dd = opendir(drop);
if (!dd) {
- setup ();
- fprintf (out, "unable to open maildrop area %s\n", drop);
+ setup();
+ fprintf(out, "unable to open maildrop area %s\n", drop);
return;
}
- 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",
- dp->d_name, 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", dp->d_name, drop);
hit++;
}
- closedir (dd);
+ closedir(dd);
if (!hit && out && !mail)
- fprintf (out, "all maildrops accounted for in %s\n", drop);
+ fprintf(out, "all maildrops accounted for in %s\n", drop);
}
int
-check (char *s)
+check(char *s)
{
register struct home *hm;
for (hm = homehead; hm; hm = hm->h_next)
- if (!strcmp (s, hm->h_name))
+ if (!strcmp(s, hm->h_name))
return 1;
return 0;
}
void
-setup (void)
+setup(void)
{
int fd, pd[2];
return;
if (mail) {
- if (pipe (pd) == NOTOK)
- adios ("pipe", "unable to");
+ if (pipe(pd) == NOTOK)
+ adios("pipe", "unable to");
- switch (fork ()) {
+ switch (fork()) {
case NOTOK:
- adios ("fork", "unable to");
+ adios("fork", "unable to");
case OK:
- close (pd[1]);
+ close(pd[1]);
if (pd[0] != 0) {
- dup2 (pd[0], 0);
- close (pd[0]);
+ dup2(pd[0], 0);
+ close(pd[0]);
}
- if ((fd = open ("/dev/null", O_WRONLY)) != NOTOK)
+ if ((fd = open("/dev/null", O_WRONLY))
+ != NOTOK)
if (fd != 1) {
- dup2 (fd, 1);
- close (fd);
+ dup2(fd, 1);
+ close(fd);
}
- execlp (mailproc, r1bindex (mailproc, '/'),
- mail, "-subject", invo_name, NULL);
- adios (mailproc, "unable to exec ");
+ execlp(mailproc, r1bindex (mailproc, '/'),
+ mail, "-subject", invo_name,
+ NULL);
+ adios(mailproc, "unable to exec ");
default:
- close (pd[0]);
- out = fdopen (pd[1], "w");
- fprintf (out, "%s: the following is suspicious\n\n",
- invo_name);
+ close(pd[0]);
+ out = fdopen(pd[1], "w");
+ fprintf(out, "%s: the following is suspicious\n\n", invo_name);
}
}
}
char **gl_ldr;
};
-int setglent (), endglent ();
-struct grpldr *getglent (), *getglnam ();
+int setglent(), endglent();
+struct grpldr *getglent(), *getglnam();
/* taken from the getglent() routines */
setglent() {
if (glp == NULL)
- glp = fopen (GLDRS, "r");
+ glp = fopen(GLDRS, "r");
else
- rewind (glp);
+ rewind(glp);
return (glp != NULL);
}
endglent() {
if (glp != NULL) {
- fclose (glp);
+ fclose(glp);
glp = NULL;
}
return 1;
}
-struct grpldr *getglent () {
+struct grpldr *getglent() {
register char *cp, **q;
- if (glp == NULL && !setglent ())
+ if (glp == NULL && !setglent())
return NULL;
- if ((cp = fgets (line, BUFSIZ, glp)) == NULL)
+ if ((cp = fgets(line, BUFSIZ, glp)) == NULL)
return NULL;
grpldr.gl_name = cp;
grpldr.gl_ldr = q = gl_ldr;
while (*cp) {
- while (*cp && !isspace (*cp))
+ while (*cp && !isspace(*cp))
cp++;
- while (*cp && isspace (*cp))
+ while (*cp && isspace(*cp))
*cp++ = '\0';
if (*cp == '\0')
break;
return (&grpldr);
}
-struct grpldr *getglnam (name)
+struct grpldr *getglnam(name)
char *name;
{
register struct grpldr *gl = NULL;
- setglent ();
- while (gl = getglent ())
- if (strcmp (name, gl->gl_name) == 0)
+ setglent();
+ while (gl = getglent())
+ if (strcmp(name, gl->gl_name) == 0)
break;
- endglent ();
+ endglent();
return gl;
}
-ldr_names () {
+ldr_names() {
register int gp, hit = 0;
char *gldrs[NGRPS];
register struct grpldr *gl;
gldrs[0] = NULL;
- setglent ();
- while (gl = getglent ()) {
- if (getgrnam (gl->gl_name) == NULL) {
- setup ();
- fprintf (out, "unknown group %s in group leaders file\n",
+ setglent();
+ while (gl = getglent()) {
+ if (getgrnam(gl->gl_name) == NULL) {
+ setup();
+ fprintf(out, "unknown group %s in group leaders file\n",
gl->gl_name);
hit++;
}
for (gp = 0; gldrs[gp]; gp++)
- if (strcmp (gldrs[gp], gl->gl_name) == 0) {
- setup ();
- fprintf (out, "duplicate group %s in group leaders file\n",
- gl->gl_name);
+ if (strcmp(gldrs[gp], gl->gl_name) == 0) {
+ setup();
+ fprintf(out, "duplicate group %s in group leaders file\n", gl->gl_name);
hit++;
break;
}
if (gldrs[gp] == NULL)
if (gp < NGRPS) {
- gldrs[gp++] = getcpy (gl->gl_name);
+ gldrs[gp++] = getcpy(gl->gl_name);
gldrs[gp] = NULL;
} else {
- setup ();
- fprintf (out, "more than %d groups in group leaders file%s\n",
- " (time to recompile)", NGRPS - 1);
+ setup();
+ fprintf(out, "more than %d groups in group leaders file (time to recompile)\n", NGRPS - 1);
hit++;
}
}
- endglent ();
+ endglent();
for (gp = 0; gldrs[gp]; gp++)
- free (gldrs[gp]);
+ free(gldrs[gp]);
if (!hit && out && !mail)
- fprintf (out, "all groups in group leaders file accounted for\n");
+ fprintf(out, "all groups in group leaders file accounted for\n");
}
-ldr_ship () {
+ldr_ship() {
register int hit = 0;
register char **cp, **dp;
register struct grpldr *gl;
- setglent ();
- while (gl = getglent ())
+ setglent();
+ while (gl = getglent())
for (cp = gl->gl_ldr; *cp; cp++) {
- if (!check (*cp)) {
- setup ();
- fprintf (out, "group %s has unknown leader %s\n",
- gl->gl_name, *cp);
+ if (!check(*cp)) {
+ setup();
+ fprintf(out, "group %s has unknown leader %s\n", gl->gl_name, *cp);
hit++;
}
for (dp = cp + 1; *dp; dp++)
- if (strcmp (*cp, *dp) == 0) {
- setup ();
- fprintf (out, "group %s had duplicate leader %s\n",
- gl->gl_name, *cp);
+ if (strcmp(*cp, *dp) == 0) {
+ setup();
+ fprintf(out, "group %s had duplicate leader %s\n", gl->gl_name, *cp);
hit++;
}
}
- endglent ();
+ endglent();
if (!hit && out && !mail)
- fprintf (out, "all group leaders accounted for\n");
+ fprintf(out, "all group leaders accounted for\n");
}
#endif /* UCI */
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int anot = 0, inplace = 1, nedit = 0;
int nwhat = 0, in, out;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msg] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msg] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case ANNOSW:
anot++;
case EDITRSW:
if (!(ed = *argp++) || *ed == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
nedit = 0;
continue;
case NEDITSW:
case WHATSW:
if (!(whatnowproc = *argp++) || *whatnowproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
nwhat = 0;
continue;
case NWHATSW:
case FILESW:
if (file)
- adios (NULL, "only one file at a time!");
+ adios(NULL, "only one file at a time!");
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- file = path (cp, TFILE);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ file = path(cp, TFILE);
continue;
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case INPLSW:
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else {
if (msg)
- adios (NULL, "only one message at a time!");
+ adios(NULL, "only one message at a time!");
else
msg = cp;
}
}
- cwd = getcpy (pwd ());
+ cwd = getcpy(pwd());
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (file && (msg || folder))
- adios (NULL, "can't mix files and folders/msgs");
+ adios(NULL, "can't mix files and folders/msgs");
in = open_form(&form, distcomps);
- strncpy (drft, m_draft("new"), sizeof(drft));
+ strncpy(drft, m_draft("new"), sizeof(drft));
- if ((out = creat (drft, m_gmprot ())) == NOTOK)
- adios (drft, "unable to create");
+ if ((out = creat(drft, m_gmprot())) == NOTOK)
+ adios(drft, "unable to create");
- cpydata (in, out, form, drft);
- close (in);
- close (out);
+ cpydata(in, out, form, drft);
+ close(in);
+ close(out);
if (file) {
/*
if (!msg)
msg = "cur";
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse the message range/sequence/name and set SELECTED */
- if (!m_convert (mp, msg))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msg))
+ done(1);
+ seq_setprev(mp); /* set the previous-sequence */
if (mp->numsel > 1)
- adios (NULL, "only one message at a time!");
+ adios(NULL, "only one message at a time!");
}
- msgnam = file ? file : getcpy (m_name (mp->lowsel));
- if ((in = open (msgnam, O_RDONLY)) == NOTOK)
- adios (msgnam, "unable to open message");
+ msgnam = file ? file : getcpy(m_name(mp->lowsel));
+ if ((in = open(msgnam, O_RDONLY)) == NOTOK)
+ adios(msgnam, "unable to open message");
if (!file) {
- 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 */
+ 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 */
}
if (nwhat)
- done (0);
- what_now (ed, nedit, NOUSE, drft, msgnam, 1, mp,
- anot ? "Resent" : NULL, inplace, cwd);
- done (1);
+ done(0);
+ what_now(ed, nedit, NOUSE, drft, msgnam, 1, mp, anot ? "Resent" : NULL,
+ inplace, cwd);
+ done(1);
return 1;
}
static void ready_msg(char *);
int
-distout (char *drft, char *msgnam, char *backup)
+distout(char *drft, char *msgnam, char *backup)
{
int state;
register unsigned char *dp;
char name[NAMESZ], buffer[BUFSIZ];
register FILE *ifp, *ofp;
- if (rename (drft, strcpy (backup, m_backup (drft))) == NOTOK)
- adios (backup, "unable to rename %s to",drft);
- if ((ifp = fopen (backup, "r")) == NULL)
- adios (backup, "unable to read");
+ if (rename(drft, strcpy(backup, m_backup(drft))) == NOTOK)
+ adios(backup, "unable to rename %s to",drft);
+ if ((ifp = fopen(backup, "r")) == NULL)
+ adios(backup, "unable to read");
- if ((ofp = fopen (drft, "w")) == NULL)
- adios (drft, "unable to create temporary file");
- chmod (drft, m_gmprot ());
+ if ((ofp = fopen(drft, "w")) == NULL)
+ adios(drft, "unable to create temporary file");
+ chmod(drft, m_gmprot());
- ready_msg (msgnam);
- lseek (hdrfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
- cpydata (hdrfd, fileno (ofp), msgnam, drft);
+ ready_msg(msgnam);
+ lseek(hdrfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
+ cpydata(hdrfd, fileno(ofp), msgnam, drft);
for (state = FLD, resent = NULL;;)
- switch (state =
- m_getfld (state, name, buffer, sizeof buffer, ifp)) {
+ switch (state = m_getfld (state, name, buffer,
+ sizeof buffer, ifp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
- if (uprf (name, "distribute-"))
- snprintf (name, sizeof(name), "%s%s", "Resent", &name[10]);
- if (uprf (name, "distribution-"))
- snprintf (name, sizeof(name), "%s%s", "Resent", &name[12]);
- if (!uprf (name, "resent")) {
- advise (NULL, BADHDR, "draft", name);
+ if (uprf(name, "distribute-"))
+ snprintf(name, sizeof(name), "%s%s",
+ "Resent", &name[10]);
+ if (uprf(name, "distribution-"))
+ snprintf(name, sizeof(name), "%s%s",
+ "Resent", &name[12]);
+ if (!uprf(name, "resent")) {
+ advise(NULL, BADHDR, "draft", name);
goto leave_bad;
}
if (state == FLD)
- resent = add (":", add (name, resent));
- resent = add (buffer, resent);
- fprintf (ofp, "%s: %s", name, buffer);
+ resent = add(":", add(name, resent));
+ resent = add(buffer, resent);
+ fprintf(ofp, "%s: %s", name, buffer);
while (state == FLDPLUS) {
- state = m_getfld (state, name,
- buffer, sizeof buffer, ifp);
- resent = add (buffer, resent);
- fputs (buffer, ofp);
+ state = m_getfld(state, name, buffer,
+ sizeof buffer, ifp);
+ resent = add(buffer, resent);
+ fputs(buffer, ofp);
}
if (state == FLDEOF)
goto process;
case BODY:
case BODYEOF:
for (dp = buffer; *dp; dp++)
- if (!isspace (*dp)) {
- advise (NULL, BADTXT, "draft");
+ if (!isspace(*dp)) {
+ advise(NULL, BADTXT, "draft");
goto leave_bad;
}
case LENERR:
case FMTERR:
- advise (NULL, BADRFT, "draft");
+ advise(NULL, BADRFT, "draft");
leave_bad: ;
- fclose (ifp);
- fclose (ofp);
- unlink (drft);
- if (rename (backup, drft) == NOTOK)
- adios (drft, "unable to rename %s to", backup);
+ fclose(ifp);
+ fclose(ofp);
+ unlink(drft);
+ if (rename(backup, drft) == NOTOK)
+ adios(drft, "unable to rename %s to",
+ backup);
return NOTOK;
default:
- adios (NULL, "getfld() returned %d", state);
+ adios(NULL, "getfld() returned %d", state);
}
process: ;
- fclose (ifp);
- fflush (ofp);
+ fclose(ifp);
+ fflush(ofp);
if (!resent) {
- advise (NULL, BADMSG, "draft");
- fclose (ofp);
- unlink (drft);
- if (rename (backup, drft) == NOTOK)
- adios (drft, "unable to rename %s to", backup);
+ advise(NULL, BADMSG, "draft");
+ fclose(ofp);
+ unlink(drft);
+ if (rename(backup, drft) == NOTOK)
+ adios(drft, "unable to rename %s to", backup);
return NOTOK;
}
- free (resent);
+ free(resent);
if (txtfd != NOTOK) {
- lseek (txtfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
- cpydata (txtfd, fileno (ofp), msgnam, drft);
+ lseek(txtfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
+ cpydata(txtfd, fileno(ofp), msgnam, drft);
}
- fclose (ofp);
+ fclose(ofp);
return OK;
}
static void
-ready_msg (char *msgnam)
+ready_msg(char *msgnam)
{
int state, out;
char name[NAMESZ], buffer[BUFSIZ], tmpfil[BUFSIZ];
char *cp = NULL;
if (hdrfd != NOTOK)
- close (hdrfd), hdrfd = NOTOK;
+ close(hdrfd), hdrfd = NOTOK;
if (txtfd != NOTOK)
- close (txtfd), txtfd = NOTOK;
+ close(txtfd), txtfd = NOTOK;
- if ((ifp = fopen (msgnam, "r")) == NULL)
- adios (msgnam, "unable to open message");
+ if ((ifp = fopen(msgnam, "r")) == NULL)
+ adios(msgnam, "unable to open message");
cp = m_mktemp2(NULL, "dist", &hdrfd, NULL);
if (cp == NULL) {
}
fchmod(hdrfd, 0600);
strncpy(tmpfil, cp, sizeof(tmpfil));
- if ((out = dup (hdrfd)) == NOTOK
- || (ofp = fdopen (out, "w")) == NULL)
- adios (NULL, "no file descriptors -- you lose big");
- unlink (tmpfil);
+ if ((out = dup(hdrfd)) == NOTOK
+ || (ofp = fdopen(out, "w")) == NULL)
+ adios(NULL, "no file descriptors -- you lose big");
+ unlink(tmpfil);
for (state = FLD;;)
- switch (state =
- m_getfld (state, name, buffer, sizeof buffer, ifp)) {
+ switch (state = m_getfld (state, name, buffer, sizeof buffer,
+ ifp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
- if (uprf (name, "resent"))
- fprintf (ofp, "Prev-");
- fprintf (ofp, "%s: %s", name, buffer);
+ if (uprf(name, "resent"))
+ fprintf(ofp, "Prev-");
+ fprintf(ofp, "%s: %s", name, buffer);
while (state == FLDPLUS) {
- state = m_getfld (state, name,
- buffer, sizeof buffer, ifp);
- fputs (buffer, ofp);
+ state = m_getfld(state, name, buffer,
+ sizeof buffer, ifp);
+ fputs(buffer, ofp);
}
if (state == FLDEOF)
goto process;
case BODY:
case BODYEOF:
- fclose (ofp);
+ fclose(ofp);
cp = m_mktemp2(NULL, "dist", &txtfd, NULL);
if (cp == NULL) {
adios("distsbr", "unable to create temporary file");
}
fchmod(txtfd, 0600);
- strncpy (tmpfil, cp, sizeof(tmpfil));
- if ((out = dup (txtfd)) == NOTOK
- || (ofp = fdopen (out, "w")) == NULL)
- adios (NULL, "no file descriptors -- you lose big");
- unlink (tmpfil);
- fprintf (ofp, "\n%s", buffer);
+ strncpy(tmpfil, cp, sizeof(tmpfil));
+ if ((out = dup(txtfd)) == NOTOK
+ || (ofp = fdopen(out, "w"))
+ == NULL)
+ adios(NULL, "no file descriptors -- you lose big");
+ unlink(tmpfil);
+ fprintf(ofp, "\n%s", buffer);
while (state == BODY) {
- state = m_getfld (state, name,
- buffer, sizeof buffer, ifp);
- fputs (buffer, ofp);
+ state = m_getfld(state, name, buffer,
+ sizeof buffer, ifp);
+ fputs(buffer, ofp);
}
case FILEEOF:
goto process;
case LENERR:
case FMTERR:
- adios (NULL, "format error in message %s", msgnam);
+ adios(NULL, "format error in message %s",
+ msgnam);
default:
- adios (NULL, "getfld() returned %d", state);
+ adios(NULL, "getfld() returned %d", state);
}
process: ;
- fclose (ifp);
- fclose (ofp);
+ fclose(ifp);
+ fclose(ofp);
}
/*
** prototypes
*/
-int sc_width (void); /* from termsbr.c */
+int sc_width(void); /* from termsbr.c */
/*
** static prototypes
*/
-static int process (char *, int);
+static int process(char *, int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int datep = 0, width = 0, status = 0;
char *cp, *form = NULL, *format = NULL, *nfs;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] dates ...",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches] dates ...", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
format = NULL;
continue;
case FMTSW:
if (!(format = *argp++) || *format == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
form = NULL;
continue;
case WIDTHSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- width = atoi (cp);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ width = atoi(cp);
continue;
}
}
if (datep > NDATES)
- adios (NULL, "more than %d dates", NDATES);
+ adios(NULL, "more than %d dates", NDATES);
else
dates[datep++] = cp;
}
dates[datep] = NULL;
if (datep == 0)
- adios (NULL, "usage: %s [switches] dates ...", invo_name);
+ adios(NULL, "usage: %s [switches] dates ...", invo_name);
/* get new format string */
- nfs = new_fs (form, format, FORMAT);
+ nfs = new_fs(form, format, FORMAT);
if (width == 0) {
- if ((width = sc_width ()) < WIDTH / 2)
+ if ((width = sc_width()) < WIDTH / 2)
width = WIDTH / 2;
width -= 2;
}
if (width > WBUFSIZ)
width = WBUFSIZ;
- fmt_compile (nfs, &fmt);
+ fmt_compile(nfs, &fmt);
dat[0] = 0;
dat[1] = 0;
dat[4] = 0;
for (datep = 0; dates[datep]; datep++)
- status += process (dates[datep], width);
+ status += process(dates[datep], width);
- context_save (); /* save the context file */
- done (status);
+ context_save(); /* save the context file */
+ done(status);
return 1;
}
static int
-process (char *date, int length)
+process(char *date, int length)
{
int status = 0;
char buffer[WBUFSIZ + 1];
register struct comp *cptr;
- FINDCOMP (cptr, "text");
+ FINDCOMP(cptr, "text");
if (cptr)
cptr->c_text = date;
- fmt_scan (fmt, buffer, length, dat);
- fputs (buffer, stdout);
+ fmt_scan(fmt, buffer, length, dat);
+ fputs(buffer, stdout);
return status;
}
/*
** static prototypes
*/
-static int mbx_chk_mbox (int);
-static int mbx_chk_mmdf (int);
-static int map_open (char *, int);
+static int mbx_chk_mbox(int);
+static int mbx_chk_mmdf(int);
+static int map_open(char *, int);
/*
*/
int
-mbx_open (char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
+mbx_open(char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
{
int j, count, fd;
struct stat st;
/* attempt to open and lock file */
for (count = 4; count > 0; count--) {
- if ((fd = lkopen (file, O_RDWR | O_CREAT | O_NONBLOCK, mode)) == NOTOK) {
+ if ((fd = lkopen(file, O_RDWR | O_CREAT | O_NONBLOCK, mode))
+ == NOTOK) {
switch (errno) {
#if defined(FCNTL_LOCKING) || defined(LOCKF_LOCKING)
case EACCES:
#endif
case ETXTBSY:
j = errno;
- sleep (5);
+ sleep(5);
break;
default:
/*
** Do sanity checks on maildrop.
*/
- if (fstat (fd, &st) == NOTOK) {
+ if (fstat(fd, &st) == NOTOK) {
/*
** The stat failed. So we make sure file
** has right ownership/modes
*/
- chown (file, uid, gid);
- chmod (file, mode);
+ chown(file, uid, gid);
+ chmod(file, mode);
} else if (st.st_size > (off_t) 0) {
int status;
switch (mbx_style) {
case MMDF_FORMAT:
default:
- status = mbx_chk_mmdf (fd);
+ status = mbx_chk_mmdf(fd);
break;
case MBOX_FORMAT:
- status = mbx_chk_mbox (fd);
+ status = mbx_chk_mbox(fd);
break;
}
/* if error, attempt to close it */
if (status == NOTOK) {
- close (fd);
+ close(fd);
return NOTOK;
}
}
*/
static int
-mbx_chk_mbox (int fd)
+mbx_chk_mbox(int fd)
{
/* just seek to the end */
- if (lseek (fd, (off_t) 0, SEEK_END) == (off_t) NOTOK)
+ if (lseek(fd, (off_t) 0, SEEK_END) == (off_t) NOTOK)
return NOTOK;
return OK;
*/
static int
-mbx_chk_mmdf (int fd)
+mbx_chk_mmdf(int fd)
{
size_t count;
char ldelim[BUFSIZ];
- count = strlen (mmdlm2);
+ count = strlen(mmdlm2);
/* casting -count to off_t, seem to break FreeBSD 2.2.6 */
- if (lseek (fd, (long) (-count), SEEK_END) == (off_t) NOTOK)
+ if (lseek(fd, (long) (-count), SEEK_END) == (off_t) NOTOK)
return NOTOK;
- if (read (fd, ldelim, count) != count)
+ if (read(fd, ldelim, count) != count)
return NOTOK;
ldelim[count] = 0;
- if (strcmp (ldelim, mmdlm2)
- && write (fd, "\n", 1) != 1
- && write (fd, mmdlm2, count) != count)
+ if (strcmp(ldelim, mmdlm2) && write(fd, "\n", 1) != 1
+ && write(fd, mmdlm2, count) != count)
return NOTOK;
return OK;
int
-mbx_read (FILE *fp, long pos, struct drop **drops, int noisy)
+mbx_read(FILE *fp, long pos, struct drop **drops, int noisy)
{
register int len, size;
register long ld1, ld2;
char buffer[BUFSIZ];
register struct drop *cp, *dp, *ep, *pp;
- pp = (struct drop *) calloc ((size_t) (len = MAXFOLDER), sizeof(*dp));
+ pp = (struct drop *) calloc((size_t) (len = MAXFOLDER), sizeof(*dp));
if (pp == NULL) {
if (noisy)
- admonish (NULL, "unable to allocate drop storage");
+ admonish(NULL, "unable to allocate drop storage");
return NOTOK;
}
- ld1 = (long) strlen (mmdlm1);
- ld2 = (long) strlen (mmdlm2);
+ ld1 = (long) strlen(mmdlm1);
+ ld2 = (long) strlen(mmdlm2);
- fseek (fp, pos, SEEK_SET);
- for (ep = (dp = pp) + len - 1; fgets (buffer, sizeof(buffer), fp);) {
+ fseek(fp, pos, SEEK_SET);
+ for (ep = (dp = pp) + len - 1; fgets(buffer, sizeof(buffer), fp);) {
size = 0;
- if (strcmp (buffer, mmdlm1) == 0)
+ if (strcmp(buffer, mmdlm1) == 0)
pos += ld1, dp->d_start = (long) pos;
else {
- dp->d_start = (long)pos , pos += (long) strlen (buffer);
+ dp->d_start = (long)pos , pos += (long) strlen(buffer);
for (bp = buffer; *bp; bp++, size++)
if (*bp == '\n')
size++;
}
- while (fgets (buffer, sizeof(buffer), fp) != NULL)
- if (strcmp (buffer, mmdlm2) == 0)
+ while (fgets(buffer, sizeof(buffer), fp) != NULL)
+ if (strcmp(buffer, mmdlm2) == 0)
break;
else {
- pos += (long) strlen (buffer);
+ pos += (long) strlen(buffer);
for (bp = buffer; *bp; bp++, size++)
if (*bp == '\n')
size++;
if (dp >= ep) {
register int curlen = dp - pp;
- cp = (struct drop *) mh_xrealloc ((char *) pp,
- (size_t) (len += MAXFOLDER) * sizeof(*pp));
+ cp = (struct drop *) mh_xrealloc((char *) pp,
+ (size_t) (len += MAXFOLDER) *
+ sizeof(*pp));
dp = cp + curlen, ep = (pp = cp) + len - 1;
}
}
if (dp == pp)
- free ((char *) pp);
+ free((char *) pp);
else
*drops = pp;
- return (dp - pp);
+ return(dp - pp);
}
register char *cp;
char buffer[BUFSIZ];
- off = (long) lseek (md, (off_t) 0, SEEK_CUR);
- j = strlen (mmdlm1);
- if (write (md, mmdlm1, j) != j)
+ off = (long) lseek(md, (off_t) 0, SEEK_CUR);
+ j = strlen(mmdlm1);
+ if (write(md, mmdlm1, j) != j)
return NOTOK;
- start = lseek (md, (off_t) 0, SEEK_CUR);
+ start = lseek(md, (off_t) 0, SEEK_CUR);
size = 0;
- fseek (fp, pos, SEEK_SET);
- while (fgets (buffer, sizeof(buffer), fp) && (pos < stop)) {
- i = strlen (buffer);
- for (j = 0; (j = stringdex (mmdlm1, buffer)) >= 0; buffer[j]++)
+ fseek(fp, pos, SEEK_SET);
+ while (fgets(buffer, sizeof(buffer), fp) && (pos < stop)) {
+ i = strlen(buffer);
+ for (j = 0; (j = stringdex(mmdlm1, buffer)) >= 0; buffer[j]++)
continue;
- for (j = 0; (j = stringdex (mmdlm2, buffer)) >= 0; buffer[j]++)
+ for (j = 0; (j = stringdex(mmdlm2, buffer)) >= 0; buffer[j]++)
continue;
- if (write (md, buffer, i) != i)
+ if (write(md, buffer, i) != i)
return NOTOK;
pos += (long) i;
if (mapping)
size++;
}
- stop = lseek (md, (off_t) 0, SEEK_CUR);
- j = strlen (mmdlm2);
- if (write (md, mmdlm2, j) != j)
+ stop = lseek(md, (off_t) 0, SEEK_CUR);
+ j = strlen(mmdlm2);
+ if (write(md, mmdlm2, j) != j)
return NOTOK;
if (mapping)
- map_write (mailbox, md, id, last, start, stop, off, size, noisy);
+ map_write(mailbox, md, id, last, start, stop, off, size,
+ noisy);
return OK;
}
*/
int
-mbx_copy (char *mailbox, int mbx_style, int md, int fd,
- int mapping, char *text, int noisy)
+mbx_copy(char *mailbox, int mbx_style, int md, int fd, int mapping,
+ char *text, int noisy)
{
int i, j, size;
off_t start, stop;
char *cp, buffer[BUFSIZ];
FILE *fp;
- pos = (long) lseek (md, (off_t) 0, SEEK_CUR);
+ pos = (long) lseek(md, (off_t) 0, SEEK_CUR);
size = 0;
switch (mbx_style) {
case MMDF_FORMAT:
default:
- j = strlen (mmdlm1);
- if (write (md, mmdlm1, j) != j)
+ j = strlen(mmdlm1);
+ if (write(md, mmdlm1, j) != j)
return NOTOK;
- start = lseek (md, (off_t) 0, SEEK_CUR);
+ start = lseek(md, (off_t) 0, SEEK_CUR);
if (text) {
- i = strlen (text);
- if (write (md, text, i) != i)
+ i = strlen(text);
+ if (write(md, text, i) != i)
return NOTOK;
for (cp = text; *cp++; size++)
if (*cp == '\n')
size++;
}
- while ((i = read (fd, buffer, sizeof(buffer))) > 0) {
- for (j = 0;
- (j = stringdex (mmdlm1, buffer)) >= 0;
- buffer[j]++)
+ while ((i = read(fd, buffer, sizeof(buffer))) > 0) {
+ for (j = 0; (j = stringdex(mmdlm1, buffer)) >= 0; buffer[j]++)
continue;
- for (j = 0;
- (j = stringdex (mmdlm2, buffer)) >= 0;
- buffer[j]++)
+ for (j = 0; (j = stringdex(mmdlm2, buffer)) >= 0; buffer[j]++)
continue;
- if (write (md, buffer, i) != i)
+ if (write(md, buffer, i) != i)
return NOTOK;
if (mapping)
for (cp = buffer; i-- > 0; size++)
size++;
}
- stop = lseek (md, (off_t) 0, SEEK_CUR);
- j = strlen (mmdlm2);
- if (write (md, mmdlm2, j) != j)
+ stop = lseek(md, (off_t) 0, SEEK_CUR);
+ j = strlen(mmdlm2);
+ if (write(md, mmdlm2, j) != j)
return NOTOK;
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 (i != NOTOK ? OK : NOTOK);
case MBOX_FORMAT:
- if ((j = dup (fd)) == NOTOK)
+ if ((j = dup(fd)) == NOTOK)
return NOTOK;
- if ((fp = fdopen (j, "r")) == NULL) {
- close (j);
+ if ((fp = fdopen(j, "r")) == NULL) {
+ close(j);
return NOTOK;
}
- start = lseek (md, (off_t) 0, SEEK_CUR);
+ start = lseek(md, (off_t) 0, SEEK_CUR);
/* If text is given, we add it to top of message */
if (text) {
- i = strlen (text);
- if (write (md, text, i) != i)
+ i = strlen(text);
+ if (write(md, text, i) != i)
return NOTOK;
for (cp = text; *cp++; size++)
if (*cp == '\n')
size++;
}
- for (j = 0; fgets (buffer, sizeof(buffer), fp) != NULL; j++) {
+ for (j = 0; fgets(buffer, sizeof(buffer), fp) != NULL;
+ j++) {
/*
** Check the first line, and make some changes.
** Change the "Return-Path:" field
** (if in first line) back to "From ".
*/
- if (!strncmp (buffer, "Return-Path:", 12)) {
+ if (!strncmp(buffer, "Return-Path:",
+ 12)) {
char tmpbuffer[BUFSIZ];
char *tp, *ep, *fp;
if (!(fp = strchr(ep + 1, ' ')))
fp = strchr(ep + 1, '\n');
tp = dctime(dlocaltimenow());
- snprintf (buffer, sizeof(buffer), "From %.*s %s",
- (int)(fp - ep), ep, tp);
- } else if (!strncmp (buffer, "X-Envelope-From:", 16)) {
+ snprintf(buffer, sizeof(buffer), "From %.*s %s", (int)(fp - ep), ep, tp);
+ } else if (!strncmp(buffer, "X-Envelope-From:", 16)) {
/*
** Change the "X-Envelope-From:"
** field (if first line) back
strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
ep = tmpbuffer + 17;
- snprintf (buffer, sizeof(buffer), "From %s", ep);
- } else if (strncmp (buffer, "From ", 5)) {
+ snprintf(buffer, sizeof(buffer), "From %s", ep);
+ } else if (strncmp(buffer, "From ", 5)) {
/*
** If there is already a "From "
** line, then leave it alone.
strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
ep = "nobody@nowhere";
tp = dctime(dlocaltimenow());
- snprintf (buffer, sizeof(buffer), "From %s %s%s", ep, tp, tmpbuffer);
+ snprintf(buffer, sizeof(buffer), "From %s %s%s", ep, tp, tmpbuffer);
}
}
** 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);
+ if (j != 0 && strncmp(buffer, "From ", 5) == 0) {
+ write(md, ">", 1);
size++;
}
- i = strlen (buffer);
- if (write (md, buffer, i) != i) {
- fclose (fp);
+ i = strlen(buffer);
+ if (write(md, buffer, i) != i) {
+ fclose(fp);
return NOTOK;
}
if (mapping)
if (*cp++ == '\n')
size++;
}
- if (write (md, "\n", 1) != 1) {
- fclose (fp);
+ if (write(md, "\n", 1) != 1) {
+ fclose(fp);
return NOTOK;
}
if (mapping)
size += 2;
- fclose (fp);
- lseek (fd, (off_t) 0, SEEK_END);
- stop = lseek (md, (off_t) 0, SEEK_CUR);
+ fclose(fp);
+ 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,
+ map_write(mailbox, md, 0, (long) 0, start,
stop, pos, size, noisy);
return OK;
int
-mbx_size (int md, off_t start, off_t stop)
+mbx_size(int md, off_t start, off_t stop)
{
register int i, fd;
register long pos;
register FILE *fp;
- if ((fd = dup (md)) == NOTOK || (fp = fdopen (fd, "r")) == NULL) {
+ if ((fd = dup(md)) == NOTOK || (fp = fdopen(fd, "r")) == NULL) {
if (fd != NOTOK)
- close (fd);
+ close(fd);
return NOTOK;
}
- fseek (fp, start, SEEK_SET);
+ fseek(fp, start, SEEK_SET);
for (i = 0, pos = stop - start; pos-- > 0; i++)
- if (fgetc (fp) == '\n')
+ if (fgetc(fp) == '\n')
i++;
- fclose (fp);
+ fclose(fp);
return i;
}
*/
int
-mbx_close (char *mailbox, int md)
+mbx_close(char *mailbox, int md)
{
- if (lkclose (md, mailbox) == 0)
+ if (lkclose(md, mailbox) == 0)
return OK;
return NOTOK;
}
/*
** This function is performed implicitly by getbbent.c:
-** bb->bb_map = map_name (bb->bb_file);
+** bb->bb_map = map_name(bb->bb_file);
*/
char *
-map_name (char *file)
+map_name(char *file)
{
register char *cp, *dp;
static char buffer[BUFSIZ];
- if ((dp = strchr(cp = r1bindex (file, '/'), '.')) == NULL)
- dp = cp + strlen (cp);
+ if ((dp = strchr(cp = r1bindex(file, '/'), '.')) == NULL)
+ dp = cp + strlen(cp);
if (cp == file)
- snprintf (buffer, sizeof(buffer), ".%.*s%s", (int)(dp - cp), cp, ".map");
+ snprintf(buffer, sizeof(buffer), ".%.*s%s",
+ (int)(dp - cp), cp, ".map");
else
snprintf (buffer, sizeof(buffer), "%.*s.%.*s%s",
- (int)(cp - file), file, (int)(dp - cp), cp, ".map");
+ (int)(cp - file), file, (int)(dp - cp),
+ cp, ".map");
return buffer;
}
int
-map_read (char *file, long pos, struct drop **drops, int noisy)
+map_read(char *file, long pos, struct drop **drops, int noisy)
{
register int i, md, msgp;
register char *cp;
struct drop d;
register struct drop *mp, *dp;
- if ((md = open (cp = map_name (file), O_RDONLY)) == NOTOK
- || map_chk (cp, md, mp = &d, pos, noisy)) {
+ if ((md = open(cp = map_name(file), O_RDONLY)) == NOTOK
+ || map_chk(cp, md, mp = &d, pos, noisy)) {
if (md != NOTOK)
- close (md);
+ close(md);
return 0;
}
msgp = mp->d_id;
- dp = (struct drop *) calloc ((size_t) (msgp + 1), sizeof(*dp));
+ dp = (struct drop *) calloc((size_t) (msgp + 1), sizeof(*dp));
if (dp == NULL) {
- close (md);
+ close(md);
return 0;
}
memcpy((char *) dp, (char *) mp, sizeof(*dp));
- lseek (md, (off_t) sizeof(*mp), SEEK_SET);
- if ((i = read (md, (char *) (dp + 1), msgp * sizeof(*dp))) < sizeof(*dp)) {
+ lseek(md, (off_t) sizeof(*mp), SEEK_SET);
+ if ((i = read(md, (char *) (dp + 1), msgp * sizeof(*dp))) <
+ sizeof(*dp)) {
i = 0;
- free ((char *) dp);
+ free((char *) dp);
} else {
#ifdef NTOHLSWAP
register struct drop *tdp;
*drops = dp;
}
- close (md);
+ close(md);
return (i / sizeof(*dp));
}
int
-map_write (char *mailbox, int md, int id, long last, off_t start,
+map_write(char *mailbox, int md, int id, long last, off_t start,
off_t stop, long pos, int size, int noisy)
{
register int i;
register FILE *fp;
struct stat st;
- if ((fd = map_open (file = map_name (mailbox), md)) == NOTOK)
+ if ((fd = map_open(file = map_name(mailbox), md)) == NOTOK)
return NOTOK;
- if ((fstat (fd, &st) == OK) && (st.st_size > 0))
+ if ((fstat(fd, &st) == OK) && (st.st_size > 0))
clear = 0;
else
clear = 1;
- if (!clear && map_chk (file, fd, &d1, pos, noisy)) {
- unlink (file);
- mbx_close (file, fd);
- if ((fd = map_open (file, md)) == NOTOK)
+ if (!clear && map_chk(file, fd, &d1, pos, noisy)) {
+ unlink(file);
+ mbx_close(file, fd);
+ if ((fd = map_open(file, md)) == NOTOK)
return NOTOK;
clear++;
}
if (clear) {
- if ((td = dup (md)) == NOTOK || (fp = fdopen (td, "r")) == NULL) {
+ if ((td = dup(md)) == NOTOK ||
+ (fp = fdopen(td, "r")) == NULL) {
if (noisy)
- admonish (file, "unable to %s", td != NOTOK ? "fdopen" : "dup");
+ admonish(file, "unable to %s", td != NOTOK ?
+ "fdopen" : "dup");
if (td != NOTOK)
- close (td);
- mbx_close (file, fd);
+ close(td);
+ mbx_close(file, fd);
return NOTOK;
}
- switch (i = mbx_read (fp, 0, &rp, noisy)) {
+ switch (i = mbx_read(fp, 0, &rp, noisy)) {
case NOTOK:
- fclose (fp);
- mbx_close (file, fd);
+ fclose(fp);
+ mbx_close(file, fd);
return NOTOK;
case OK:
- fclose (fp);
+ fclose(fp);
break;
default:
for (dp = rp; i-- >0; dp++) {
if (dp->d_start == start)
dp->d_id = id;
- lseek (fd, (off_t) (++d1.d_id * sizeof(*dp)), SEEK_SET);
- if (write (fd, (char *) dp, sizeof(*dp)) != sizeof(*dp)) {
+ lseek(fd, (off_t) (++d1.d_id * sizeof(*dp)), SEEK_SET);
+ if (write(fd, (char *) dp, sizeof(*dp)) != sizeof(*dp)) {
if (noisy)
- admonish (file, "write error");
- mbx_close (file, fd);
- fclose (fp);
+ admonish(file, "write error");
+ mbx_close(file, fd);
+ fclose(fp);
return NOTOK;
}
}
- free ((char *) rp);
- fclose (fp);
+ free((char *) rp);
+ fclose(fp);
break;
}
}
last = d1.d_start;
dp = &d2;
dp->d_id = id;
- dp->d_size = (long) (size ? size : mbx_size (fd, start, stop));
+ dp->d_size = (long) (size ? size : mbx_size(fd, start, stop));
dp->d_start = start;
dp->d_stop = stop;
- lseek (fd, (off_t) (++d1.d_id * sizeof(*dp)), SEEK_SET);
- if (write (fd, (char *) dp, sizeof(*dp)) != sizeof(*dp)) {
+ lseek(fd, (off_t) (++d1.d_id * sizeof(*dp)), SEEK_SET);
+ if (write(fd, (char *) dp, sizeof(*dp)) != sizeof(*dp)) {
if (noisy)
- admonish (file, "write error");
- mbx_close (file, fd);
+ admonish(file, "write error");
+ mbx_close(file, fd);
return NOTOK;
}
}
dp = &d1;
dp->d_size = DRVRSN;
dp->d_start = (long) last;
- dp->d_stop = lseek (md, (off_t) 0, SEEK_CUR);
+ dp->d_stop = lseek(md, (off_t) 0, SEEK_CUR);
- lseek (fd, (off_t) 0, SEEK_SET);
- if (write (fd, (char *) dp, sizeof(*dp)) != sizeof(*dp)) {
+ lseek(fd, (off_t) 0, SEEK_SET);
+ if (write(fd, (char *) dp, sizeof(*dp)) != sizeof(*dp)) {
if (noisy)
- admonish (file, "write error");
- mbx_close (file, fd);
+ admonish(file, "write error");
+ mbx_close(file, fd);
return NOTOK;
}
- mbx_close (file, fd);
+ mbx_close(file, fd);
return OK;
}
static int
-map_open (char *file, int md)
+map_open(char *file, int md)
{
mode_t mode;
struct stat st;
- mode = fstat (md, &st) != NOTOK ? (mode_t) (st.st_mode & 0777) : m_gmprot ();
- return mbx_open (file, OTHER_FORMAT, st.st_uid, st.st_gid, mode);
+ mode = fstat(md, &st) != NOTOK ?
+ (mode_t) (st.st_mode & 0777) : m_gmprot();
+ return mbx_open(file, OTHER_FORMAT, st.st_uid, st.st_gid, mode);
}
int
-map_chk (char *file, int fd, struct drop *dp, long pos, int noisy)
+map_chk(char *file, int fd, struct drop *dp, long pos, int noisy)
{
long count;
struct drop d, tmpd;
register struct drop *dl;
- if (read (fd, (char *) &tmpd, sizeof(*dp)) != sizeof(*dp)) {
+ if (read(fd, (char *) &tmpd, sizeof(*dp)) != sizeof(*dp)) {
#ifdef notdef
- admonish (NULL, "%s: missing or partial index", file);
+ admonish(NULL, "%s: missing or partial index", file);
#endif /* notdef */
return NOTOK;
}
if (dp->d_size != DRVRSN) {
if (noisy)
- admonish (NULL, "%s: version mismatch (%d != %d)",
- file, dp->d_size, DRVRSN);
+ admonish(NULL, "%s: version mismatch (%d != %d)",
+ file, dp->d_size, DRVRSN);
return NOTOK;
}
if (dp->d_stop != pos) {
if (noisy && pos != (long) 0)
- admonish (NULL,
- "%s: pointer mismatch or incomplete index (%ld!=%ld)",
- file, dp->d_stop, (long) pos);
+ admonish(NULL, "%s: pointer mismatch or incomplete index (%ld!=%ld)", file, dp->d_stop, (long) pos);
return NOTOK;
}
- if ((long) ((dp->d_id + 1) * sizeof(*dp)) != (long) lseek (fd, (off_t) 0, SEEK_END)) {
+ if ((long) ((dp->d_id + 1) * sizeof(*dp)) != (long) lseek(fd, (off_t) 0, SEEK_END)) {
if (noisy)
- admonish (NULL, "%s: corrupt index(1)", file);
+ admonish(NULL, "%s: corrupt index(1)", file);
return NOTOK;
}
dl = &d;
- count = (long) strlen (mmdlm2);
- lseek (fd, (off_t) (dp->d_id * sizeof(*dp)), SEEK_SET);
- if (read (fd, (char *) dl, sizeof(*dl)) != sizeof(*dl)
+ count = (long) strlen(mmdlm2);
+ lseek(fd, (off_t) (dp->d_id * sizeof(*dp)), SEEK_SET);
+ if (read(fd, (char *) dl, sizeof(*dl)) != sizeof(*dl)
|| (ntohl(dl->d_stop) != dp->d_stop
&& ntohl(dl->d_stop) + count != dp->d_stop)) {
if (noisy)
- admonish (NULL, "%s: corrupt index(2)", file);
+ admonish(NULL, "%s: corrupt index(2)", file);
return NOTOK;
}
** If program was invoked with name ending
** in `s', then add switch `-all'.
*/
- if (argv[0][strlen (argv[0]) - 1] == 's')
+ if (argv[0][strlen(argv[0]) - 1] == 's')
all = TRUE;
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/* allocate the initial space to record the folder names */
numfolders = 0;
maxfolders = MAXFOLDERS;
- foldersToDo = (char **) mh_xmalloc ((size_t) (maxfolders * sizeof(*foldersToDo)));
+ foldersToDo = (char **) mh_xmalloc((size_t)
+ (maxfolders * sizeof(*foldersToDo)));
/* no sequences yet */
numsequences = 0;
adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf(buf, sizeof(buf), "%s [+folder1 [+folder2 ...]][switches]",
- invo_name);
+ snprintf(buf, sizeof(buf), "%s [+folder1 [+folder2 ...]][switches]", invo_name);
print_help(buf, switches, 1);
done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
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 (numsequences >= NUMATTRS)
- adios (NULL, "too many sequences (more than %d) specified", NUMATTRS);
+ adios(NULL, "too many sequences (more than %d) specified", NUMATTRS);
sequencesToDo[numsequences++] = cp;
break;
*/
if (numfolders >= maxfolders) {
maxfolders += MAXFOLDERS;
- foldersToDo = (char **) mh_xrealloc (foldersToDo,
- (size_t) (maxfolders * sizeof(*foldersToDo)));
+ foldersToDo = (char **) mh_xrealloc(foldersToDo, (size_t) (maxfolders * sizeof(*foldersToDo)));
}
if (*cp == '+' || *cp == '@') {
foldersToDo[numfolders++] =
- pluspath (cp);
+ pluspath(cp);
} else
foldersToDo[numfolders++] = cp;
}
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
/* get current folder */
- strncpy (curfolder, getfolder(1), sizeof(curfolder));
+ strncpy(curfolder, getfolder(1), sizeof(curfolder));
/* get nmh base directory */
- nmhdir = m_maildir ("");
+ nmhdir = m_maildir("");
/*
** If we didn't specify any sequences, we search
char **ap, *dp;
dp = getcpy(cp);
- ap = brkstring (dp, " ", "\n");
+ ap = brkstring(dp, " ", "\n");
for (; ap && *ap; ap++) {
if (numsequences >= NUMATTRS)
- adios (NULL, "too many sequences (more than %d) in %s profile entry",
- NUMATTRS, usequence);
+ adios(NULL, "too many sequences (more than %d) in %s profile entry", NUMATTRS, usequence);
else
sequencesToDo[numsequences++] = *ap;
}
} else {
- adios (NULL, "no sequence specified or %s profile entry found", usequence);
+ adios(NULL, "no sequence specified or %s profile entry found", usequence);
}
}
ScanFolders();
qsort(folders, nFolders, sizeof(struct Folder), (qsort_comp) CompareFolders);
PrintFolders();
- done (0);
+ done(0);
return 1;
}
/*
* change directory to base of nmh directory
*/
- if (chdir (nmhdir) == NOTOK)
- adios (nmhdir, "unable to change directory to");
+ if (chdir(nmhdir) == NOTOK)
+ adios(nmhdir, "unable to change directory to");
if (numfolders > 0) {
/* Update context */
- strncpy (curfolder, foldersToDo[numfolders - 1], sizeof(curfolder));
- context_replace (pfolder, curfolder);/* update current folder */
- context_save (); /* save the context file */
+ strncpy(curfolder, foldersToDo[numfolders - 1],
+ sizeof(curfolder));
+ context_replace(pfolder, curfolder);/* update current folder */
+ context_save(); /* save the context file */
/*
** Scan each given folder. If -all is given,
** If base directory, don't add it to the
** folder list. We just recurse into it.
*/
- if (!strcmp (dirName, ".")) {
- BuildFolderListRecurse (".", &st, 0);
+ if (!strcmp(dirName, ".")) {
+ BuildFolderListRecurse(".", &st, 0);
return;
}
** If recursing and directory has subfolders,
** then build folder list for subfolders.
*/
- if (AddFolder(dirName, showzero) && (recurse || searchdepth) && st.st_nlink > 2)
+ if (AddFolder(dirName, showzero) && (recurse || searchdepth) &&
+ st.st_nlink > 2)
BuildFolderListRecurse(dirName, &st, searchdepth - 1);
}
** A hack so that we don't see a
** leading "./" in folder names.
*/
- base = strcmp (dirName, ".") ? dirName : dirName + 1;
+ base = strcmp(dirName, ".") ? dirName : dirName + 1;
while (nlinks && (dp = readdir(dir))) {
if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) {
for (n = dp->d_name; *n && isdigit(*n); n++);
if (!*n)
continue;
- strncpy (name, base, sizeof(name) - 2);
+ strncpy(name, base, sizeof(name) - 2);
if (*base)
strcat(name, "/");
strncat(name, dp->d_name, sizeof(name) - strlen(name) - 1);
** Check if this was really a symbolic link pointing
** to a directory. If not, then decrement link count.
*/
- if (lstat (name, &st) == -1)
+ if (lstat(name, &st) == -1)
nlinks--;
/* Add this folder to the list */
if (AddFolder(name, showzero) &&
struct msgs *mp;
/* Read folder and create message structure */
- if (!(mp = folder_read (name))) {
+ if (!(mp = folder_read(name))) {
/* Oops, error occurred. Record it and continue. */
AllocFolders(&folders, &nFoldersAlloced, nFolders + 1);
f = &folders[nFolders++];
/* Now count messages in this sequence */
nSeq[i] = 0;
if (mp->nummsg > 0 && seqnum[i] != -1) {
- for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) {
+ for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg;
+ msgnum++) {
if (in_sequence(mp, seqnum[i], msgnum))
nSeq[i]++;
}
/* record the sequence information */
for (i = 0; i < numsequences; i++) {
f->nSeq[i] = nSeq[i];
- f->private[i] = (seqnum[i] != -1) ? is_seq_private(mp, seqnum[i]) : 0;
+ f->private[i] = (seqnum[i] != -1) ?
+ is_seq_private(mp, seqnum[i]) : 0;
}
}
- folder_free (mp); /* free folder/message structure */
+ folder_free(mp); /* free folder/message structure */
return 1;
}
for (j = 0; j < numsequences; j++) {
/* find maximum width of sequence name */
- len = strlen (sequencesToDo[j]);
- if ((folders[i].nSeq[j] > 0 || showzero) && (len > maxseqlen))
+ len = strlen(sequencesToDo[j]);
+ if ((folders[i].nSeq[j] > 0 || showzero) &&
+ (len > maxseqlen))
maxseqlen = len;
/* find the maximum number of messages in sequence */
if (folders[i].nSeq[j] > 0 || showzero) {
/* Add `+' to end of name of current folder */
if (strcmp(curfolder, folders[i].name))
- snprintf(tmpname, sizeof(tmpname), "%s", folders[i].name);
+ snprintf(tmpname, sizeof(tmpname),
+ "%s", folders[i].name);
else
- snprintf(tmpname, sizeof(tmpname), "%s+", folders[i].name);
+ snprintf(tmpname, sizeof(tmpname),
+ "%s+",
+ folders[i].name);
if (folders[i].error) {
- printf("%-*s is unreadable\n", maxfolderlen+1, tmpname);
+ printf("%-*s is unreadable\n",
+ maxfolderlen+1,
+ tmpname);
continue;
}
- printf("%-*s has %*d in sequence %-*s%s; out of %*d\n",
- maxfolderlen+1, tmpname,
- num_digits(maxseq), folders[i].nSeq[j],
- maxseqlen, sequencesToDo[j],
- !has_private ? "" : folders[i].private[j] ? " (private)" : " ",
- num_digits(maxnum), folders[i].nMsgs);
+ printf("%-*s has %*d in sequence %-*s%s; out of %*d\n", maxfolderlen+1, tmpname, num_digits(maxseq), folders[i].nSeq[j], maxseqlen, sequencesToDo[j], !has_private ? "" : folders[i].private[j] ? " (private)" : " ", num_digits(maxnum), folders[i].nMsgs);
}
}
}
return;
if (*f == NULL) {
*nfa = 10;
- *f = (struct Folder *) mh_xmalloc (*nfa * (sizeof(struct Folder)));
+ *f = (struct Folder *) mh_xmalloc(
+ *nfa * (sizeof(struct Folder)));
} else {
*nfa *= 2;
- *f = (struct Folder *) mh_xrealloc (*f, *nfa * (sizeof(struct Folder)));
+ *f = (struct Folder *) mh_xrealloc(
+ *f, *nfa * (sizeof(struct Folder)));
}
}
continue;
if (ol < bestLen)
continue;
- if (o->name[0] == '*' && !strcmp(o->name + 1, name + (nl - ol + 1))) {
+ if (o->name[0] == '*' && !strcmp(o->name + 1,
+ name + (nl - ol + 1))) {
best = o->priority;
bestLen = ol;
- } else if (o->name[ol - 1] == '*' && strncmp(o->name, name, ol - 1) == 0) {
+ } else if (o->name[ol - 1] == '*' &&
+ strncmp(o->name, name, ol - 1) == 0) {
best = o->priority;
bestLen = ol;
}
*/
static void
-do_readonly_folders (void)
+do_readonly_folders(void)
{
int atrlen;
char atrcur[BUFSIZ];
register struct node *np;
- snprintf (atrcur, sizeof(atrcur), "atr-%s-", current);
- atrlen = strlen (atrcur);
+ snprintf(atrcur, sizeof(atrcur), "atr-%s-", current);
+ atrlen = strlen(atrcur);
for (np = m_defs; np; np = np->n_next)
- if (ssequal (atrcur, np->n_name)
- && !ssequal (nmhdir, np->n_name + atrlen))
- BuildFolderList (np->n_name + atrlen, 0);
+ if (ssequal(atrcur, np->n_name)
+ && !ssequal(nmhdir, np->n_name + atrlen))
+ BuildFolderList(np->n_name + atrlen, 0);
}
/*
** static prototypes
*/
-static void fmt_dump (struct format *);
+static void fmt_dump(struct format *);
static void dumpone(struct format *);
static int findlabel(struct format *);
static void assignlabel(struct format *);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int ncomps;
char *cp, *form = NULL, *format = NULL;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches]", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
format = NULL;
continue;
case FMTSW:
if (!(format = *argp++) || *format == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
form = NULL;
continue;
}
}
if (form)
- adios (NULL, "only one form at a time!");
+ adios(NULL, "only one form at a time!");
else
form = cp;
}
/*
** Get new format string. Must be before chdir().
*/
- nfs = new_fs (form, format, FORMAT);
+ nfs = new_fs(form, format, FORMAT);
ncomps = fmt_compile(nfs, &fmt);
fmt_dump(fmt);
}
static void
-fmt_dump (struct format *fmth)
+fmt_dump(struct format *fmth)
{
- int i;
- register struct format *fmt, *addr;
-
- /* Assign labels */
- for (fmt = fmth; fmt; ++fmt) {
- i = fmt->f_type;
- if (i == FT_IF_S ||
- i == FT_IF_S_NULL ||
- i == FT_IF_V_EQ ||
- i == FT_IF_V_NE ||
- i == FT_IF_V_GT ||
- i == FT_IF_MATCH ||
- i == FT_IF_AMATCH ||
- i == FT_GOTO) {
- addr = fmt + fmt->f_skip;
- if (findlabel(addr) < 0)
- assignlabel(addr);
- }
- if (fmt->f_type == FT_DONE && fmt->f_value == 0)
- break;
+ int i;
+ register struct format *fmt, *addr;
+
+ /* Assign labels */
+ for (fmt = fmth; fmt; ++fmt) {
+ i = fmt->f_type;
+ if (i == FT_IF_S || i == FT_IF_S_NULL || i == FT_IF_V_EQ ||
+ i == FT_IF_V_NE || i == FT_IF_V_GT ||
+ i == FT_IF_MATCH || i == FT_IF_AMATCH ||
+ i == FT_GOTO) {
+ addr = fmt + fmt->f_skip;
+ if (findlabel(addr) < 0)
+ assignlabel(addr);
}
+ if (fmt->f_type == FT_DONE && fmt->f_value == 0)
+ break;
+ }
- /* Dump them out! */
- for (fmt = fmth; fmt; ++fmt) {
- dumpone(fmt);
- if (fmt->f_type == FT_DONE && fmt->f_value == 0)
- break;
- }
+ /* Dump them out! */
+ for (fmt = fmth; fmt; ++fmt) {
+ dumpone(fmt);
+ if (fmt->f_type == FT_DONE && fmt->f_value == 0)
+ break;
+ }
}
static void
dumpone(struct format *fmt)
{
- register int i;
-
- if ((i = findlabel(fmt)) >= 0)
- printf("L%d:", i);
- putchar('\t');
-
- fputs(f_typestr((int)fmt->f_type), stdout);
-
- switch (fmt->f_type) {
-
- case FT_COMP:
- case FT_LS_COMP:
- case FT_LV_COMPFLAG:
- case FT_LV_COMP:
- printf(", comp ");
- litputs(fmt->f_comp->c_name);
- if (fmt->f_comp->c_type)
- printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
- if (fmt->f_comp->c_flags)
- printf(", c_flags %s", c_flagsstr(fmt->f_comp->c_flags));
- break;
-
- case FT_LV_SEC:
- case FT_LV_MIN:
- case FT_LV_HOUR:
- case FT_LV_MDAY:
- case FT_LV_MON:
- case FT_LS_MONTH:
- case FT_LS_LMONTH:
- case FT_LS_ZONE:
- case FT_LV_YEAR:
- case FT_LV_WDAY:
- case FT_LS_DAY:
- case FT_LS_WEEKDAY:
- case FT_LV_YDAY:
- case FT_LV_ZONE:
- case FT_LV_CLOCK:
- case FT_LV_RCLOCK:
- case FT_LV_DAYF:
- case FT_LV_ZONEF:
- case FT_LV_DST:
- case FT_LS_822DATE:
- case FT_LS_PRETTY:
- case FT_LOCALDATE:
- case FT_GMTDATE:
- case FT_PARSEDATE:
- printf(", c_name ");
- litputs(fmt->f_comp->c_name);
- if (fmt->f_comp->c_type)
- printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
- if (fmt->f_comp->c_flags)
- printf(", c_flags %s", c_flagsstr(fmt->f_comp->c_flags));
- break;
-
- case FT_LS_ADDR:
- case FT_LS_PERS:
- case FT_LS_MBOX:
- case FT_LS_HOST:
- case FT_LS_PATH:
- case FT_LS_GNAME:
- case FT_LS_NOTE:
- case FT_LS_822ADDR:
- case FT_LV_HOSTTYPE:
- case FT_LV_INGRPF:
- case FT_LV_NOHOSTF:
- case FT_LS_FRIENDLY:
- case FT_PARSEADDR:
- case FT_MYMBOX:
- printf(", c_name ");
- litputs(fmt->f_comp->c_name);
- if (fmt->f_comp->c_type)
- printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
- if (fmt->f_comp->c_flags)
- printf(", c_flags %s", c_flagsstr(fmt->f_comp->c_flags));
- break;
-
- case FT_COMPF:
- printf(", width %d, fill '", fmt->f_width);
- litputc(fmt->f_fill);
- printf("' name ");
- litputs(fmt->f_comp->c_name);
- if (fmt->f_comp->c_type)
- printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
- if (fmt->f_comp->c_flags)
- printf(", c_flags %s", c_flagsstr(fmt->f_comp->c_flags));
- break;
-
- case FT_STRF:
- case FT_NUMF:
- printf(", width %d, fill '", fmt->f_width);
- litputc(fmt->f_fill);
- putchar('\'');
- break;
-
- case FT_LIT:
+ register int i;
+
+ if ((i = findlabel(fmt)) >= 0)
+ printf("L%d:", i);
+ putchar('\t');
+
+ fputs(f_typestr((int)fmt->f_type), stdout);
+
+ switch (fmt->f_type) {
+
+ case FT_COMP:
+ case FT_LS_COMP:
+ case FT_LV_COMPFLAG:
+ case FT_LV_COMP:
+ printf(", comp ");
+ litputs(fmt->f_comp->c_name);
+ if (fmt->f_comp->c_type)
+ printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
+ if (fmt->f_comp->c_flags)
+ printf(", c_flags %s",
+ c_flagsstr(fmt->f_comp->c_flags));
+ break;
+
+ case FT_LV_SEC:
+ case FT_LV_MIN:
+ case FT_LV_HOUR:
+ case FT_LV_MDAY:
+ case FT_LV_MON:
+ case FT_LS_MONTH:
+ case FT_LS_LMONTH:
+ case FT_LS_ZONE:
+ case FT_LV_YEAR:
+ case FT_LV_WDAY:
+ case FT_LS_DAY:
+ case FT_LS_WEEKDAY:
+ case FT_LV_YDAY:
+ case FT_LV_ZONE:
+ case FT_LV_CLOCK:
+ case FT_LV_RCLOCK:
+ case FT_LV_DAYF:
+ case FT_LV_ZONEF:
+ case FT_LV_DST:
+ case FT_LS_822DATE:
+ case FT_LS_PRETTY:
+ case FT_LOCALDATE:
+ case FT_GMTDATE:
+ case FT_PARSEDATE:
+ printf(", c_name ");
+ litputs(fmt->f_comp->c_name);
+ if (fmt->f_comp->c_type)
+ printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
+ if (fmt->f_comp->c_flags)
+ printf(", c_flags %s",
+ c_flagsstr(fmt->f_comp->c_flags));
+ break;
+
+ case FT_LS_ADDR:
+ case FT_LS_PERS:
+ case FT_LS_MBOX:
+ case FT_LS_HOST:
+ case FT_LS_PATH:
+ case FT_LS_GNAME:
+ case FT_LS_NOTE:
+ case FT_LS_822ADDR:
+ case FT_LV_HOSTTYPE:
+ case FT_LV_INGRPF:
+ case FT_LV_NOHOSTF:
+ case FT_LS_FRIENDLY:
+ case FT_PARSEADDR:
+ case FT_MYMBOX:
+ printf(", c_name ");
+ litputs(fmt->f_comp->c_name);
+ if (fmt->f_comp->c_type)
+ printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
+ if (fmt->f_comp->c_flags)
+ printf(", c_flags %s",
+ c_flagsstr(fmt->f_comp->c_flags));
+ break;
+
+ case FT_COMPF:
+ printf(", width %d, fill '", fmt->f_width);
+ litputc(fmt->f_fill);
+ printf("' name ");
+ litputs(fmt->f_comp->c_name);
+ if (fmt->f_comp->c_type)
+ printf(", c_type %s", c_typestr(fmt->f_comp->c_type));
+ if (fmt->f_comp->c_flags)
+ printf(", c_flags %s",
+ c_flagsstr(fmt->f_comp->c_flags));
+ break;
+
+ case FT_STRF:
+ case FT_NUMF:
+ printf(", width %d, fill '", fmt->f_width);
+ litputc(fmt->f_fill);
+ putchar('\'');
+ break;
+
+ case FT_LIT:
#ifdef FT_LIT_FORCE
- case FT_LIT_FORCE:
+ case FT_LIT_FORCE:
#endif
- putchar(' ');
- litputs(fmt->f_text);
- break;
-
- case FT_LITF:
- printf(", width %d, fill '", fmt->f_width);
- litputc(fmt->f_fill);
- printf("' ");
- litputs(fmt->f_text);
- break;
-
- case FT_CHAR:
- putchar(' ');
- putchar('\'');
- litputc(fmt->f_char);
- putchar('\'');
- break;
-
-
- case FT_IF_S:
- case FT_IF_S_NULL:
- case FT_IF_MATCH:
- case FT_IF_AMATCH:
- printf(" continue else goto");
- case FT_GOTO:
- i = findlabel(fmt + fmt->f_skip);
- printf(" L%d", i);
- break;
-
- case FT_IF_V_EQ:
- case FT_IF_V_NE:
- case FT_IF_V_GT:
- i = findlabel(fmt + fmt->f_skip);
- printf(" %d continue else goto L%d", fmt->f_value, i);
- break;
-
- case FT_V_EQ:
- case FT_V_NE:
- case FT_V_GT:
- case FT_LV_LIT:
- case FT_LV_PLUS_L:
- case FT_LV_MINUS_L:
- case FT_LV_DIVIDE_L:
- case FT_LV_MODULO_L:
- printf(" value %d", fmt->f_value);
- break;
-
- case FT_LS_LIT:
- printf(" str ");
- litputs(fmt->f_text);
- break;
-
- case FT_LS_GETENV:
- printf(" getenv ");
- litputs(fmt->f_text);
- break;
-
- case FT_LS_DECODECOMP:
- printf(", comp ");
- litputs(fmt->f_comp->c_name);
- break;
-
- case FT_LS_DECODE:
- break;
-
- case FT_LS_TRIM:
- printf(", width %d", fmt->f_width);
- break;
-
- case FT_LV_DAT:
- printf(", value dat[%d]", fmt->f_value);
- break;
- }
- putchar('\n');
+ putchar(' ');
+ litputs(fmt->f_text);
+ break;
+
+ case FT_LITF:
+ printf(", width %d, fill '", fmt->f_width);
+ litputc(fmt->f_fill);
+ printf("' ");
+ litputs(fmt->f_text);
+ break;
+
+ case FT_CHAR:
+ putchar(' ');
+ putchar('\'');
+ litputc(fmt->f_char);
+ putchar('\'');
+ break;
+
+
+ case FT_IF_S:
+ case FT_IF_S_NULL:
+ case FT_IF_MATCH:
+ case FT_IF_AMATCH:
+ printf(" continue else goto");
+ case FT_GOTO:
+ i = findlabel(fmt + fmt->f_skip);
+ printf(" L%d", i);
+ break;
+
+ case FT_IF_V_EQ:
+ case FT_IF_V_NE:
+ case FT_IF_V_GT:
+ i = findlabel(fmt + fmt->f_skip);
+ printf(" %d continue else goto L%d", fmt->f_value, i);
+ break;
+
+ case FT_V_EQ:
+ case FT_V_NE:
+ case FT_V_GT:
+ case FT_LV_LIT:
+ case FT_LV_PLUS_L:
+ case FT_LV_MINUS_L:
+ case FT_LV_DIVIDE_L:
+ case FT_LV_MODULO_L:
+ printf(" value %d", fmt->f_value);
+ break;
+
+ case FT_LS_LIT:
+ printf(" str ");
+ litputs(fmt->f_text);
+ break;
+
+ case FT_LS_GETENV:
+ printf(" getenv ");
+ litputs(fmt->f_text);
+ break;
+
+ case FT_LS_DECODECOMP:
+ printf(", comp ");
+ litputs(fmt->f_comp->c_name);
+ break;
+
+ case FT_LS_DECODE:
+ break;
+
+ case FT_LS_TRIM:
+ printf(", width %d", fmt->f_width);
+ break;
+
+ case FT_LV_DAT:
+ printf(", value dat[%d]", fmt->f_value);
+ break;
+ }
+ putchar('\n');
}
static int
findlabel(struct format *addr)
{
- register int i;
+ register int i;
- for (i = 0; i < lused; ++i)
- if (addr == lvec[i])
- return(i);
- return(-1);
+ for (i = 0; i < lused; ++i)
+ if (addr == lvec[i])
+ return(i);
+ return(-1);
}
static void
assignlabel(struct format *addr)
{
- lvec[lused++] = addr;
+ lvec[lused++] = addr;
}
static char *
f_typestr(int t)
{
- static char buf[32];
+ static char buf[32];
- switch (t) {
- case FT_COMP: return("COMP");
- case FT_COMPF: return("COMPF");
- case FT_LIT: return("LIT");
- case FT_LITF: return("LITF");
+ switch (t) {
+ case FT_COMP: return("COMP");
+ case FT_COMPF: return("COMPF");
+ case FT_LIT: return("LIT");
+ case FT_LITF: return("LITF");
#ifdef FT_LIT_FORCE
- case FT_LIT_FORCE: return("LIT_FORCE");
+ case FT_LIT_FORCE: return("LIT_FORCE");
#endif
- case FT_CHAR: return("CHAR");
- case FT_NUM: return("NUM");
- case FT_NUMF: return("NUMF");
- case FT_STR: return("STR");
- case FT_STRF: return("STRF");
- case FT_STRFW: return("STRFW");
- case FT_PUTADDR: return("PUTADDR");
- case FT_LS_COMP: return("LS_COMP");
- case FT_LS_LIT: return("LS_LIT");
- case FT_LS_GETENV: return("LS_GETENV");
- case FT_LS_DECODECOMP: return("FT_LS_DECODECOMP");
- case FT_LS_DECODE: return("FT_LS_DECODE");
- case FT_LS_TRIM: return("LS_TRIM");
- case FT_LV_COMP: return("LV_COMP");
- case FT_LV_COMPFLAG: return("LV_COMPFLAG");
- case FT_LV_LIT: return("LV_LIT");
- case FT_LV_DAT: return("LV_DAT");
- case FT_LV_STRLEN: return("LV_STRLEN");
- case FT_LV_PLUS_L: return("LV_PLUS_L");
- case FT_LV_MINUS_L: return("LV_MINUS_L");
- case FT_LV_DIVIDE_L: return("LV_DIVIDE_L");
- case FT_LV_MODULO_L: return("LV_MODULO_L");
- case FT_LV_CHAR_LEFT: return("LV_CHAR_LEFT");
- case FT_LS_MONTH: return("LS_MONTH");
- case FT_LS_LMONTH: return("LS_LMONTH");
- case FT_LS_ZONE: return("LS_ZONE");
- case FT_LS_DAY: return("LS_DAY");
- case FT_LS_WEEKDAY: return("LS_WEEKDAY");
- case FT_LS_822DATE: return("LS_822DATE");
- case FT_LS_PRETTY: return("LS_PRETTY");
- case FT_LV_SEC: return("LV_SEC");
- case FT_LV_MIN: return("LV_MIN");
- case FT_LV_HOUR: return("LV_HOUR");
- case FT_LV_MDAY: return("LV_MDAY");
- case FT_LV_MON: return("LV_MON");
- case FT_LV_YEAR: return("LV_YEAR");
- case FT_LV_YDAY: return("LV_YDAY");
- case FT_LV_WDAY: return("LV_WDAY");
- case FT_LV_ZONE: return("LV_ZONE");
- case FT_LV_CLOCK: return("LV_CLOCK");
- case FT_LV_RCLOCK: return("LV_RCLOCK");
- case FT_LV_DAYF: return("LV_DAYF");
- case FT_LV_DST: return("LV_DST");
- case FT_LV_ZONEF: return("LV_ZONEF");
- case FT_LS_ADDR: return("LS_ADDR");
- case FT_LS_PERS: return("LS_PERS");
- case FT_LS_MBOX: return("LS_MBOX");
- case FT_LS_HOST: return("LS_HOST");
- case FT_LS_PATH: return("LS_PATH");
- case FT_LS_GNAME: return("LS_GNAME");
- case FT_LS_NOTE: return("LS_NOTE");
- case FT_LS_822ADDR: return("LS_822ADDR");
- case FT_LS_FRIENDLY: return("LS_FRIENDLY");
- case FT_LV_HOSTTYPE: return("LV_HOSTTYPE");
- case FT_LV_INGRPF: return("LV_INGRPF");
- case FT_LV_NOHOSTF: return("LV_NOHOSTF");
- case FT_LOCALDATE: return("LOCALDATE");
- case FT_GMTDATE: return("GMTDATE");
- case FT_PARSEDATE: return("PARSEDATE");
- case FT_PARSEADDR: return("PARSEADDR");
- case FT_FORMATADDR: return("FORMATADDR");
- case FT_MYMBOX: return("MYMBOX");
+ case FT_CHAR: return("CHAR");
+ case FT_NUM: return("NUM");
+ case FT_NUMF: return("NUMF");
+ case FT_STR: return("STR");
+ case FT_STRF: return("STRF");
+ case FT_STRFW: return("STRFW");
+ case FT_PUTADDR: return("PUTADDR");
+ case FT_LS_COMP: return("LS_COMP");
+ case FT_LS_LIT: return("LS_LIT");
+ case FT_LS_GETENV: return("LS_GETENV");
+ case FT_LS_DECODECOMP: return("FT_LS_DECODECOMP");
+ case FT_LS_DECODE: return("FT_LS_DECODE");
+ case FT_LS_TRIM: return("LS_TRIM");
+ case FT_LV_COMP: return("LV_COMP");
+ case FT_LV_COMPFLAG: return("LV_COMPFLAG");
+ case FT_LV_LIT: return("LV_LIT");
+ case FT_LV_DAT: return("LV_DAT");
+ case FT_LV_STRLEN: return("LV_STRLEN");
+ case FT_LV_PLUS_L: return("LV_PLUS_L");
+ case FT_LV_MINUS_L: return("LV_MINUS_L");
+ case FT_LV_DIVIDE_L: return("LV_DIVIDE_L");
+ case FT_LV_MODULO_L: return("LV_MODULO_L");
+ case FT_LV_CHAR_LEFT: return("LV_CHAR_LEFT");
+ case FT_LS_MONTH: return("LS_MONTH");
+ case FT_LS_LMONTH: return("LS_LMONTH");
+ case FT_LS_ZONE: return("LS_ZONE");
+ case FT_LS_DAY: return("LS_DAY");
+ case FT_LS_WEEKDAY: return("LS_WEEKDAY");
+ case FT_LS_822DATE: return("LS_822DATE");
+ case FT_LS_PRETTY: return("LS_PRETTY");
+ case FT_LV_SEC: return("LV_SEC");
+ case FT_LV_MIN: return("LV_MIN");
+ case FT_LV_HOUR: return("LV_HOUR");
+ case FT_LV_MDAY: return("LV_MDAY");
+ case FT_LV_MON: return("LV_MON");
+ case FT_LV_YEAR: return("LV_YEAR");
+ case FT_LV_YDAY: return("LV_YDAY");
+ case FT_LV_WDAY: return("LV_WDAY");
+ case FT_LV_ZONE: return("LV_ZONE");
+ case FT_LV_CLOCK: return("LV_CLOCK");
+ case FT_LV_RCLOCK: return("LV_RCLOCK");
+ case FT_LV_DAYF: return("LV_DAYF");
+ case FT_LV_DST: return("LV_DST");
+ case FT_LV_ZONEF: return("LV_ZONEF");
+ case FT_LS_ADDR: return("LS_ADDR");
+ case FT_LS_PERS: return("LS_PERS");
+ case FT_LS_MBOX: return("LS_MBOX");
+ case FT_LS_HOST: return("LS_HOST");
+ case FT_LS_PATH: return("LS_PATH");
+ case FT_LS_GNAME: return("LS_GNAME");
+ case FT_LS_NOTE: return("LS_NOTE");
+ case FT_LS_822ADDR: return("LS_822ADDR");
+ case FT_LS_FRIENDLY: return("LS_FRIENDLY");
+ case FT_LV_HOSTTYPE: return("LV_HOSTTYPE");
+ case FT_LV_INGRPF: return("LV_INGRPF");
+ case FT_LV_NOHOSTF: return("LV_NOHOSTF");
+ case FT_LOCALDATE: return("LOCALDATE");
+ case FT_GMTDATE: return("GMTDATE");
+ case FT_PARSEDATE: return("PARSEDATE");
+ case FT_PARSEADDR: return("PARSEADDR");
+ case FT_FORMATADDR: return("FORMATADDR");
+ case FT_MYMBOX: return("MYMBOX");
#ifdef FT_ADDTOSEQ
- case FT_ADDTOSEQ: return("ADDTOSEQ");
+ case FT_ADDTOSEQ: return("ADDTOSEQ");
#endif
- case FT_SAVESTR: return("SAVESTR");
+ case FT_SAVESTR: return("SAVESTR");
#ifdef FT_PAUSE
- case FT_PAUSE: return ("PAUSE");
+ case FT_PAUSE: return ("PAUSE");
#endif
- case FT_DONE: return("DONE");
- case FT_NOP: return("NOP");
- case FT_GOTO: return("GOTO");
- case FT_IF_S_NULL: return("IF_S_NULL");
- case FT_IF_S: return("IF_S");
- case FT_IF_V_EQ: return("IF_V_EQ");
- case FT_IF_V_NE: return("IF_V_NE");
- case FT_IF_V_GT: return("IF_V_GT");
- case FT_IF_MATCH: return("IF_MATCH");
- case FT_IF_AMATCH: return("IF_AMATCH");
- case FT_S_NULL: return("S_NULL");
- case FT_S_NONNULL: return("S_NONNULL");
- case FT_V_EQ: return("V_EQ");
- case FT_V_NE: return("V_NE");
- case FT_V_GT: return("V_GT");
- case FT_V_MATCH: return("V_MATCH");
- case FT_V_AMATCH: return("V_AMATCH");
- default:
- printf(buf, "/* ??? #%d */", t);
- return(buf);
- }
+ case FT_DONE: return("DONE");
+ case FT_NOP: return("NOP");
+ case FT_GOTO: return("GOTO");
+ case FT_IF_S_NULL: return("IF_S_NULL");
+ case FT_IF_S: return("IF_S");
+ case FT_IF_V_EQ: return("IF_V_EQ");
+ case FT_IF_V_NE: return("IF_V_NE");
+ case FT_IF_V_GT: return("IF_V_GT");
+ case FT_IF_MATCH: return("IF_MATCH");
+ case FT_IF_AMATCH: return("IF_AMATCH");
+ case FT_S_NULL: return("S_NULL");
+ case FT_S_NONNULL: return("S_NONNULL");
+ case FT_V_EQ: return("V_EQ");
+ case FT_V_NE: return("V_NE");
+ case FT_V_GT: return("V_GT");
+ case FT_V_MATCH: return("V_MATCH");
+ case FT_V_AMATCH: return("V_AMATCH");
+ default:
+ printf(buf, "/* ??? #%d */", t);
+ return(buf);
+ }
}
#define FNORD(v, s) if (t & (v)) { \
if (i++ > 0) \
- strcat(buf, "|"); \
+ strcat(buf, "|"); \
strcat(buf, s); }
static char *
c_typestr(int t)
{
- register int i;
- static char buf[64];
-
- buf[0] = '\0';
- if (t & ~(CT_ADDR|CT_DATE))
- printf(buf, "0x%x ", t);
- strcat(buf, "<");
- i = 0;
- FNORD(CT_ADDR, "ADDR");
- FNORD(CT_DATE, "DATE");
- strcat(buf, ">");
- return(buf);
+ register int i;
+ static char buf[64];
+
+ buf[0] = '\0';
+ if (t & ~(CT_ADDR|CT_DATE))
+ printf(buf, "0x%x ", t);
+ strcat(buf, "<");
+ i = 0;
+ FNORD(CT_ADDR, "ADDR");
+ FNORD(CT_DATE, "DATE");
+ strcat(buf, ">");
+ return(buf);
}
static char *
c_flagsstr(int t)
{
- register int i;
- static char buf[64];
-
- buf[0] = '\0';
- if (t & ~(CF_TRUE|CF_PARSED|CF_DATEFAB))
- printf(buf, "0x%x ", t);
- strcat(buf, "<");
- i = 0;
- FNORD(CF_TRUE, "TRUE");
- FNORD(CF_PARSED, "PARSED");
- FNORD(CF_DATEFAB, "DATEFAB");
- strcat(buf, ">");
- return(buf);
+ register int i;
+ static char buf[64];
+
+ buf[0] = '\0';
+ if (t & ~(CF_TRUE|CF_PARSED|CF_DATEFAB))
+ printf(buf, "0x%x ", t);
+ strcat(buf, "<");
+ i = 0;
+ FNORD(CF_TRUE, "TRUE");
+ FNORD(CF_PARSED, "PARSED");
+ FNORD(CF_DATEFAB, "DATEFAB");
+ strcat(buf, ">");
+ return(buf);
}
#undef FNORD
static void
litputs(char *s)
{
- if (s) {
- putc('"', stdout);
- while (*s)
- litputc(*s++);
- putc('"', stdout);
- } else
- fputs("<nil>", stdout);
+ if (s) {
+ putc('"', stdout);
+ while (*s)
+ litputc(*s++);
+ putc('"', stdout);
+ } else
+ fputs("<nil>", stdout);
}
static void
litputc(char c)
{
- if (c & ~ 0177) {
- putc('M', stdout);
- putc('-', stdout);
- c &= 0177;
+ if (c & ~ 0177) {
+ putc('M', stdout);
+ putc('-', stdout);
+ c &= 0177;
+ }
+ if (c < 0x20 || c == 0177) {
+ if (c == '\b') {
+ putc('\\', stdout);
+ putc('b', stdout);
+ } else if (c == '\f') {
+ putc('\\', stdout);
+ putc('f', stdout);
+ } else if (c == '\n') {
+ putc('\\', stdout);
+ putc('n', stdout);
+ } else if (c == '\r') {
+ putc('\\', stdout);
+ putc('r', stdout);
+ } else if (c == '\t') {
+ putc('\\', stdout);
+ putc('t', stdout);
+ } else {
+ putc('^', stdout);
+ putc(c ^ 0x40, stdout);
+ /* DEL to ?, others to alpha */
}
- if (c < 0x20 || c == 0177) {
- if (c == '\b') {
- putc('\\', stdout);
- putc('b', stdout);
- } else if (c == '\f') {
- putc('\\', stdout);
- putc('f', stdout);
- } else if (c == '\n') {
- putc('\\', stdout);
- putc('n', stdout);
- } else if (c == '\r') {
- putc('\\', stdout);
- putc('r', stdout);
- } else if (c == '\t') {
- putc('\\', stdout);
- putc('t', stdout);
- } else {
- putc('^', stdout);
- putc(c ^ 0x40, stdout);
- /* DEL to ?, others to alpha */
- }
- } else
- putc(c, stdout);
+ } else
+ putc(c, stdout);
}
/*
** static prototypes
*/
-static int get_folder_info (char *, char *);
+static int get_folder_info(char *, char *);
static crawl_callback_t get_folder_info_callback;
-static void print_folders (void);
-static int sfold (struct msgs *, char *);
-static void readonly_folders (void);
+static void print_folders(void);
+static int sfold(struct msgs *, char *);
+static void readonly_folders(void);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int printsw = 0, listsw = 0;
int pushsw = 0, popsw = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
** If program was invoked with name ending
** in `s', then add switch `-all'.
*/
- if (argv[0][strlen (argv[0]) - 1] == 's')
+ if (argv[0][strlen(argv[0]) - 1] == 's')
all = 1;
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msg] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msg] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case ALLSW:
all = 1;
}
if (*cp == '+' || *cp == '@') {
if (argfolder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- argfolder = pluspath (cp);
+ argfolder = pluspath(cp);
} else {
if (msg)
- adios (NULL, "only one (current) message at a time!");
+ adios(NULL, "only one (current) message at a time!");
else
msg = cp;
}
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
- nmhdir = concat (m_maildir (""), "/", NULL);
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
+ nmhdir = concat(m_maildir(""), "/", NULL);
/*
** If we aren't working with the folder stack
if (!argfolder) {
/* If no folder is given, the current folder and */
/* the top of the folder stack are swapped. */
- if ((cp = context_find (stack))) {
- dp = getcpy (cp);
- ap = brkstring (dp, " ", "\n");
+ if ((cp = context_find(stack))) {
+ dp = getcpy(cp);
+ ap = brkstring(dp, " ", "\n");
argfolder = getcpy(*ap++);
} else {
- adios (NULL, "no other folder");
+ adios(NULL, "no other folder");
}
- for (cp = getcpy (getfolder (1)); *ap; ap++)
- cp = add (*ap, add (" ", cp));
- free (dp);
- context_replace (stack, cp); /* update folder stack */
+ for (cp = getcpy(getfolder(1)); *ap; ap++)
+ cp = add(*ap, add(" ", cp));
+ free(dp);
+ context_replace(stack, cp); /* update folder stack */
} else {
/* update folder stack */
- context_replace (stack,
- (cp = context_find (stack))
- ? concat (getfolder (1), " ", cp, NULL)
- : getcpy (getfolder (1)));
+ context_replace(stack, (cp = context_find (stack)) ?
+ concat(getfolder(1), " ", cp, NULL) :
+ getcpy(getfolder(1)));
}
}
/* Popping a folder off of the folder stack */
if (popsw) {
if (argfolder)
- adios (NULL, "sorry, no folders allowed with -pop");
- if ((cp = context_find (stack))) {
- dp = getcpy (cp);
- ap = brkstring (dp, " ", "\n");
+ adios(NULL, "sorry, no folders allowed with -pop");
+ if ((cp = context_find(stack))) {
+ dp = getcpy(cp);
+ ap = brkstring(dp, " ", "\n");
argfolder = getcpy(*ap++);
} else {
- adios (NULL, "folder stack empty");
+ adios(NULL, "folder stack empty");
}
if (*ap) {
/* if there's anything left in the stack */
- cp = getcpy (*ap++);
+ cp = getcpy(*ap++);
for (; *ap; ap++)
- cp = add (*ap, add (" ", cp));
- context_replace (stack, cp); /* update folder stack */
+ cp = add(*ap, add(" ", cp));
+ context_replace(stack, cp); /* update folder stack */
} else {
/* delete folder stack entry from context */
- context_del (stack);
+ context_del(stack);
}
- free (dp);
+ free(dp);
}
if (pushsw || popsw) {
cp = m_maildir(argfolder);
- if (access (cp, F_OK) == NOTOK)
- adios (cp, "unable to find folder");
+ if (access(cp, F_OK) == NOTOK)
+ adios(cp, "unable to find folder");
/* update current folder */
- context_replace (pfolder, argfolder);
- context_save (); /* save the context file */
+ context_replace(pfolder, argfolder);
+ context_save(); /* save the context file */
argfolder = NULL;
}
/* Listing the folder stack */
if (listsw) {
- printf ("%s", argfolder ? argfolder : getfolder (1));
- if ((cp = context_find (stack))) {
- dp = getcpy (cp);
- for (ap = brkstring (dp, " ", "\n"); *ap; ap++)
- printf (" %s", *ap);
- free (dp);
+ printf("%s", argfolder ? argfolder : getfolder(1));
+ if ((cp = context_find(stack))) {
+ dp = getcpy(cp);
+ for (ap = brkstring(dp, " ", "\n"); *ap; ap++)
+ printf(" %s", *ap);
+ free(dp);
}
- printf ("\n");
+ printf("\n");
if (!printsw)
- done (0);
+ done(0);
}
/* Allocate initial space to record folder information */
maxFolderInfo = CRAWL_NUMFOLDERS;
- fi = mh_xmalloc (maxFolderInfo * sizeof(*fi));
+ fi = mh_xmalloc(maxFolderInfo * sizeof(*fi));
/*
** Scan the folders
** change directory to base of nmh directory for
** crawl_folders
*/
- if (chdir (nmhdir) == NOTOK)
- adios (nmhdir, "unable to change directory to");
+ if (chdir(nmhdir) == NOTOK)
+ adios(nmhdir, "unable to change directory to");
if (!argfolder) {
if (msg)
- admonish (NULL, "no folder given for message %s", msg);
- readonly_folders (); /* do any readonly folders */
- strncpy (folder, (cp = context_find (pfolder)) ? cp : "", sizeof(folder));
- crawl_folders (".", get_folder_info_callback, NULL);
+ admonish(NULL, "no folder given for message %s", msg);
+ readonly_folders(); /* do any readonly folders */
+ strncpy(folder, (cp = context_find(pfolder)) ?
+ cp : "", sizeof(folder));
+ crawl_folders(".", get_folder_info_callback, NULL);
} else {
- strncpy (folder, argfolder, sizeof(folder));
- if (get_folder_info (argfolder, msg)) {
+ strncpy(folder, argfolder, sizeof(folder));
+ if (get_folder_info(argfolder, msg)) {
/* update current folder */
- context_replace (pfolder, argfolder);
- context_save ();
+ 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.
*/
if (!frecurse)
- crawl_folders (folder, get_folder_info_callback, NULL);
+ crawl_folders(folder, get_folder_info_callback,
+ NULL);
}
} else {
- strncpy (folder, argfolder ? argfolder : getfolder (1), sizeof(folder));
+ strncpy(folder, argfolder ? argfolder : getfolder (1),
+ sizeof(folder));
/*
** Check if folder exists. If not, then see if
** we should create it, or just exit.
*/
- create_folder (m_maildir (folder), fcreat, done);
+ create_folder(m_maildir(folder), fcreat, done);
- if (get_folder_info (folder, msg) && argfolder) {
+ if (get_folder_info(folder, msg) && argfolder) {
/* update current folder */
- context_replace (pfolder, argfolder);
+ context_replace(pfolder, argfolder);
}
}
*/
print_folders();
- context_save ();
- done (0);
+ context_save();
+ done(0);
return 1;
}
static int
-get_folder_info_body (char *fold, char *msg, boolean *crawl_children)
+get_folder_info_body(char *fold, char *msg, boolean *crawl_children)
{
int i, retval = 1;
struct msgs *mp = NULL;
*/
if (total_folders >= maxFolderInfo) {
maxFolderInfo += CRAWL_NUMFOLDERS;
- fi = mh_xrealloc (fi, maxFolderInfo * sizeof(*fi));
+ fi = mh_xrealloc(fi, maxFolderInfo * sizeof(*fi));
}
fi[i].name = fold;
/*
** create message structure and get folder info
*/
- if (!(mp = folder_read (fold))) {
- admonish (NULL, "unable to read folder %s", fold);
+ if (!(mp = folder_read(fold))) {
+ admonish(NULL, "unable to read folder %s", fold);
return 0;
}
/* set the current message */
- if (msg && !sfold (mp, msg))
+ if (msg && !sfold(mp, msg))
retval = 0;
if (fpack) {
- if (folder_pack (&mp, fverb) == -1)
- done (1);
- seq_save (mp); /* synchronize the sequences */
- context_save (); /* save the context file */
+ if (folder_pack(&mp, fverb) == -1)
+ done(1);
+ seq_save(mp); /* synchronize the sequences */
+ context_save(); /* save the context file */
}
/* record info for this folder */
fi[i].curmsg = mp->curmsg;
fi[i].lowmsg = mp->lowmsg;
fi[i].hghmsg = mp->hghmsg;
- fi[i].others = other_files (mp);
+ fi[i].others = other_files(mp);
}
- folder_free (mp); /* free folder/message structure */
+ folder_free(mp); /* free folder/message structure */
}
*crawl_children = (frecurse && (fshort || fi[i].others)
}
static boolean
-get_folder_info_callback (char *fold, void *baton)
+get_folder_info_callback(char *fold, void *baton)
{
boolean crawl_children;
- get_folder_info_body (fold, NULL, &crawl_children);
- fflush (stdout);
+ get_folder_info_body(fold, NULL, &crawl_children);
+ fflush(stdout);
return crawl_children;
}
static int
-get_folder_info (char *fold, char *msg)
+get_folder_info(char *fold, char *msg)
{
boolean crawl_children;
int retval;
- retval = get_folder_info_body (fold, msg, &crawl_children);
+ retval = get_folder_info_body(fold, msg, &crawl_children);
if (crawl_children) {
- crawl_folders (fold, get_folder_info_callback, NULL);
+ crawl_folders(fold, get_folder_info_callback, NULL);
}
return retval;
}
*/
static void
-print_folders (void)
+print_folders(void)
{
int i, len, hasempty = 0, curprinted;
int maxlen = 0, maxnummsg = 0, maxlowmsg = 0;
*/
for (i = 0; i < total_folders; i++) {
/* length of folder name */
- len = strlen (fi[i].name);
+ len = strlen(fi[i].name);
if (len > maxlen)
maxlen = len;
if (fi[i].nummsg == 0)
hasempty = 1;
}
- nummsgdigits = num_digits (maxnummsg);
- lowmsgdigits = num_digits (maxlowmsg);
- hghmsgdigits = num_digits (maxhghmsg);
- curmsgdigits = num_digits (maxcurmsg);
+ nummsgdigits = num_digits(maxnummsg);
+ lowmsgdigits = num_digits(maxlowmsg);
+ hghmsgdigits = num_digits(maxhghmsg);
+ curmsgdigits = num_digits(maxcurmsg);
if (hasempty && nummsgdigits < 2)
nummsgdigits = 2;
** Print the header
*/
if (fheader > 0 || (all && !fshort && fheader >= 0))
- printf ("%-*s %*s %-*s; %-*s %*s\n",
+ printf("%-*s %*s %-*s; %-*s %*s\n",
maxlen+1, "FOLDER",
nummsgdigits + 13, "# MESSAGES",
lowmsgdigits + hghmsgdigits + 4, " RANGE",
if (all || fshort || ftotal < 1) {
for (i = 0; i < total_folders; i++) {
if (fshort) {
- printf ("%s\n", fi[i].name);
+ printf("%s\n", fi[i].name);
continue;
}
/* Add `+' to end of name, if folder is current */
- if (strcmp (folder, fi[i].name))
- snprintf (tmpname, sizeof(tmpname), "%s", fi[i].name);
+ if (strcmp(folder, fi[i].name))
+ snprintf(tmpname, sizeof(tmpname), "%s",
+ fi[i].name);
else
- snprintf (tmpname, sizeof(tmpname), "%s+", fi[i].name);
+ snprintf(tmpname, sizeof(tmpname), "%s+",
+ fi[i].name);
if (fi[i].error) {
- printf ("%-*s is unreadable\n", maxlen+1, tmpname);
+ printf("%-*s is unreadable\n", maxlen+1,
+ tmpname);
continue;
}
- printf ("%-*s ", maxlen+1, tmpname);
+ printf("%-*s ", maxlen+1, tmpname);
curprinted = 0; /* remember if we print cur */
if (fi[i].nummsg == 0) {
- printf ("has %*s messages%*s",
- nummsgdigits, "no",
- fi[i].others ? lowmsgdigits + hghmsgdigits + 5 : 0, "");
+ printf("has %*s messages%*s", nummsgdigits, "no", fi[i].others ? lowmsgdigits + hghmsgdigits + 5 : 0, "");
} else {
- printf ("has %*d message%s (%*d-%*d)",
+ printf("has %*d message%s (%*d-%*d)",
nummsgdigits, fi[i].nummsg,
- (fi[i].nummsg == 1) ? " " : "s",
+ (fi[i].nummsg == 1) ?
+ " " : "s",
lowmsgdigits, fi[i].lowmsg,
hghmsgdigits, fi[i].hghmsg);
if (fi[i].curmsg >= fi[i].lowmsg && fi[i].curmsg <= fi[i].hghmsg) {
curprinted = 1;
- printf ("; cur=%*d", curmsgdigits, fi[i].curmsg);
+ printf("; cur=%*d", curmsgdigits,
+ fi[i].curmsg);
}
}
if (fi[i].others)
- printf (";%*s (others)", curprinted ? 0 : curmsgdigits + 6, "");
- printf (".\n");
+ printf(";%*s (others)", curprinted ?
+ 0 : curmsgdigits + 6, "");
+ printf(".\n");
}
}
*/
if (ftotal > 0 || (all && !fshort && ftotal >= 0)) {
if (all)
- printf ("\n");
- printf ("TOTAL = %d message%c in %d folder%s.\n",
+ printf("\n");
+ printf("TOTAL = %d message%c in %d folder%s.\n",
total_msgs, total_msgs != 1 ? 's' : ' ',
total_folders, total_folders != 1 ? "s" : "");
}
- fflush (stdout);
+ fflush(stdout);
}
/*
*/
static int
-sfold (struct msgs *mp, char *msg)
+sfold(struct msgs *mp, char *msg)
{
/* parse the message range/sequence/name and set SELECTED */
- if (!m_convert (mp, msg))
+ if (!m_convert(mp, msg))
return 0;
if (mp->numsel > 1) {
- admonish (NULL, "only one message at a time!");
+ admonish(NULL, "only one message at a time!");
return 0;
}
- seq_setprev (mp); /* set the previous-sequence */
- seq_setcur (mp, mp->lowsel); /* set current message */
- seq_save (mp); /* synchronize message sequences */
- context_save (); /* save the context file */
+ seq_setprev(mp); /* set the previous-sequence */
+ seq_setcur(mp, mp->lowsel); /* set current message */
+ seq_save(mp); /* synchronize message sequences */
+ context_save(); /* save the context file */
return 1;
}
*/
static void
-readonly_folders (void)
+readonly_folders(void)
{
int atrlen;
char atrcur[BUFSIZ];
register struct node *np;
- snprintf (atrcur, sizeof(atrcur), "atr-%s-", current);
- atrlen = strlen (atrcur);
+ snprintf(atrcur, sizeof(atrcur), "atr-%s-", current);
+ atrlen = strlen(atrcur);
for (np = m_defs; np; np = np->n_next)
- if (ssequal (atrcur, np->n_name)
- && !ssequal (nmhdir, np->n_name + atrlen))
- get_folder_info (np->n_name + atrlen, NULL);
+ if (ssequal(atrcur, np->n_name)
+ && !ssequal(nmhdir, np->n_name + atrlen))
+ get_folder_info(np->n_name + atrlen, NULL);
}
/*
** 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);
-static int build_form (char *, char *, int, int);
+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);
+static int build_form(char *, char *, int, int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int msgp = 0, anot = 0, inplace = 1, mime = 0;
int issue = 0, volume = 0, dashstuff = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case ANNOSW:
anot++;
case EDITRSW:
if (!(ed = *argp++) || *ed == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
nedit = 0;
continue;
case NEDITSW:
case WHATSW:
if (!(whatnowproc = *argp++) || *whatnowproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
nwhat = 0;
continue;
#ifdef MHE
case FILESW:
if (file)
- adios (NULL, "only one file at a time!");
+ adios(NULL, "only one file at a time!");
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- file = path (cp, TFILE);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ file = path(cp, TFILE);
continue;
case FILTSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- filter = getcpy (etcpath (cp));
+ adios(NULL, "missing argument to %s", argp[-2]);
+ filter = getcpy(etcpath(cp));
mime = 0;
continue;
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case FRMTSW:
- filter = getcpy (etcpath (mhlforward));
+ filter = getcpy(etcpath(mhlforward));
continue;
case NFRMTSW:
filter = NULL;
case DGSTSW:
if (!(digest = *argp++) || *digest == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
mime = 0;
continue;
case ISSUESW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((issue = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((issue = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s", argp[-2], cp);
continue;
case VOLUMSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((volume = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((volume = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s", argp[-2], cp);
continue;
case BITSTUFFSW:
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else {
msgs[msgp++] = cp;
}
}
- cwd = getcpy (pwd ());
+ cwd = getcpy(pwd());
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (file && (msgp || folder))
- adios (NULL, "can't mix files and folders/msgs");
+ adios(NULL, "can't mix files and folders/msgs");
#ifdef MHE
- strncpy (drft, buildsw ? m_maildir ("draft")
+ strncpy(drft, buildsw ? m_maildir("draft")
: m_draft("new"), sizeof(drft));
#else
- strncpy (drft, m_draft("new"), sizeof(drft));
+ strncpy(drft, m_draft("new"), sizeof(drft));
#endif /* MHE */
if (file) {
if (!msgp)
msgs[msgp++] = "cur";
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgp; msgnum++)
- if (!m_convert (mp, msgs[msgnum]))
- done (1);
- seq_setprev (mp); /* set the previous sequence */
+ if (!m_convert(mp, msgs[msgnum]))
+ done(1);
+ seq_setprev(mp); /* set the previous sequence */
}
- if (filter && access (filter, R_OK) == NOTOK)
- adios (filter, "unable to read");
+ if (filter && access(filter, R_OK) == NOTOK)
+ adios(filter, "unable to read");
/*
** Open form (component) file.
*/
if (digest) {
if (issue == 0) {
- snprintf (buf, sizeof(buf), IFORMAT, digest);
- if (volume == 0
- && (cp = context_find (buf))
- && ((issue = atoi (cp)) < 0))
+ snprintf(buf, sizeof(buf), IFORMAT, digest);
+ if (volume == 0 && (cp = context_find(buf))
+ && ((issue = atoi(cp)) < 0))
issue = 0;
issue++;
}
if (volume == 0)
- snprintf (buf, sizeof(buf), VFORMAT, digest);
- if ((cp = context_find (buf)) == NULL || (volume = atoi (cp)) <= 0)
+ snprintf(buf, sizeof(buf), VFORMAT, digest);
+ if ((cp = context_find(buf)) == NULL ||
+ (volume = atoi(cp)) <= 0)
volume = 1;
if (!form)
form = digestcomps;
- in = build_form (form, digest, volume, issue);
+ in = build_form(form, digest, volume, issue);
} else
in = open_form(&form, forwcomps);
- if ((out = creat (drft, m_gmprot ())) == NOTOK)
- adios (drft, "unable to create");
+ if ((out = creat(drft, m_gmprot())) == NOTOK)
+ adios(drft, "unable to create");
/*
** copy the components into the draft
*/
- cpydata (in, out, form, drft);
- close (in);
+ cpydata(in, out, form, drft);
+ close(in);
if (file) {
/* just copy the file into the draft */
- if ((in = open (file, O_RDONLY)) == NOTOK)
- adios (file, "unable to open");
- cpydata (in, out, file, drft);
- close (in);
- close (out);
+ if ((in = open(file, O_RDONLY)) == NOTOK)
+ adios(file, "unable to open");
+ cpydata(in, out, file, drft);
+ close(in);
+ close(out);
} else {
/*
** 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);
+ mhl_draft(out, digest, volume, issue, drft, filter,
+ dashstuff);
else if (mime)
- copy_mime_draft (out);
+ copy_mime_draft(out);
else
- copy_draft (out, digest, drft, volume, issue, dashstuff);
- close (out);
+ copy_draft(out, digest, drft, volume, issue,
+ dashstuff);
+ close(out);
if (digest) {
- snprintf (buf, sizeof(buf), IFORMAT, digest);
- snprintf (value, sizeof(value), "%d", issue);
- context_replace (buf, getcpy (value));
- snprintf (buf, sizeof(buf), VFORMAT, digest);
- snprintf (value, sizeof(value), "%d", volume);
- context_replace (buf, getcpy (value));
+ snprintf(buf, sizeof(buf), IFORMAT, digest);
+ snprintf(value, sizeof(value), "%d", issue);
+ context_replace(buf, getcpy(value));
+ snprintf(buf, sizeof(buf), VFORMAT, digest);
+ snprintf(value, sizeof(value), "%d", volume);
+ context_replace(buf, getcpy(value));
}
- 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 */
+ 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 */
}
if (nwhat)
- done (0);
- what_now (ed, nedit, NOUSE, drft, NULL, 0, mp,
+ done(0);
+ what_now(ed, nedit, NOUSE, drft, NULL, 0, mp,
anot ? "Forwarded" : NULL, inplace, cwd);
- done (1);
+ done(1);
return 1;
}
*/
static void
-mhl_draft (int out, char *digest, int volume, int issue,
+mhl_draft(int out, char *digest, int volume, int issue,
char *file, char *filter, int dashstuff)
{
pid_t child_id;
char buf1[BUFSIZ];
char buf2[BUFSIZ];
- if (pipe (pd) == NOTOK)
- adios ("pipe", "unable to create");
+ if (pipe(pd) == NOTOK)
+ adios("pipe", "unable to create");
- vec[0] = r1bindex (mhlproc, '/');
+ vec[0] = r1bindex(mhlproc, '/');
for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case NOTOK:
- adios ("fork", "unable to");
+ adios("fork", "unable to");
case OK:
- close (pd[0]);
- dup2 (pd[1], 1);
- close (pd[1]);
+ close(pd[0]);
+ dup2(pd[1], 1);
+ close(pd[1]);
i = 1;
vec[i++] = "-forwall";
vec[i++] = "-digest";
vec[i++] = digest;
vec[i++] = "-issue";
- snprintf (buf1, sizeof(buf1), "%d", issue);
+ snprintf(buf1, sizeof(buf1), "%d", issue);
vec[i++] = buf1;
vec[i++] = "-volume";
- snprintf (buf2, sizeof(buf2), "%d", volume);
+ snprintf(buf2, sizeof(buf2), "%d", volume);
vec[i++] = buf2;
}
vec[i++] = "-nodashstuffing";
if (mp->numsel >= MAXARGS - i)
- adios (NULL, "more than %d messages for %s exec",
- MAXARGS - i, vec[0]);
+ adios(NULL, "more than %d messages for %s exec", MAXARGS - i, vec[0]);
/*
** Now add the message names to filter. We can only
for (msgnum = mp->lowsel;
msgnum <= mp->hghsel && i < sizeof(vec) - 1;
msgnum++)
- if (is_selected (mp, msgnum))
- vec[i++] = getcpy (m_name (msgnum));
+ if (is_selected(mp, msgnum))
+ vec[i++] = getcpy(m_name(msgnum));
vec[i] = NULL;
- execvp (mhlproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (mhlproc);
- _exit (-1);
+ execvp(mhlproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(mhlproc);
+ _exit(-1);
default:
- close (pd[1]);
- cpydata (pd[0], out, vec[0], file);
- close (pd[0]);
+ close(pd[1]);
+ cpydata(pd[0], out, vec[0], file);
+ close(pd[0]);
pidXwait(child_id, mhlproc);
break;
}
*/
static void
-copy_draft (int out, char *digest, char *file, int volume, int issue,
+copy_draft(int out, char *digest, char *file, int volume, int issue,
int dashstuff)
{
int fd,i, msgcnt, msgnum;
msgcnt = 1;
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
- if (is_selected (mp, msgnum)) {
+ if (is_selected(mp, msgnum)) {
if (digest) {
- strncpy (buffer, msgnum == mp->lowsel ?
+ strncpy(buffer, msgnum == mp->lowsel ?
delim3 : delim4, sizeof(buffer));
} else {
/* Get buffer ready to go */
bp = buffer;
buflen = sizeof(buffer);
- strncpy (bp, "\n-------", buflen);
- len = strlen (bp);
+ strncpy(bp, "\n-------", buflen);
+ len = strlen(bp);
bp += len;
buflen -= len;
if (msgnum == mp->lowsel) {
- snprintf (bp, buflen, " Forwarded Message%s",
- mp->numsel > 1 ? "s" : "");
+ snprintf(bp, buflen, " Forwarded Message%s", mp->numsel > 1 ? "s" : "");
} else {
- snprintf (bp, buflen, " Message %d", msgcnt);
+ snprintf(bp, buflen, " Message %d", msgcnt);
}
- len = strlen (bp);
+ len = strlen(bp);
bp += len;
buflen -= len;
- strncpy (bp, "\n\n", buflen);
+ strncpy(bp, "\n\n", buflen);
}
- write (out, buffer, strlen (buffer));
+ write(out, buffer, strlen(buffer));
- if ((fd = open (msgnam = m_name (msgnum), O_RDONLY)) == NOTOK) {
- admonish (msgnam, "unable to read message");
+ if ((fd = open(msgnam = m_name (msgnum), O_RDONLY))
+ == NOTOK) {
+ admonish(msgnam, "unable to read message");
continue;
}
** unless given the -nodashstuffing flag.
*/
if (dashstuff >= 0)
- cpydgst (fd, out, msgnam, file);
+ cpydgst(fd, out, msgnam, file);
else
- cpydata (fd, out, msgnam, file);
+ cpydata(fd, out, msgnam, file);
- close (fd);
+ close(fd);
msgcnt++;
}
}
if (digest) {
- strncpy (buffer, delim4, sizeof(buffer));
+ strncpy(buffer, delim4, sizeof(buffer));
} else {
- snprintf (buffer, sizeof(buffer), "\n------- End of Forwarded Message%s\n\n",
+ snprintf(buffer, sizeof(buffer),
+ "\n------- End of Forwarded Message%s\n\n",
mp->numsel > 1 ? "s" : "");
}
- write (out, buffer, strlen (buffer));
+ write(out, buffer, strlen(buffer));
if (digest) {
- snprintf (buffer, sizeof(buffer), "End of %s Digest [Volume %d Issue %d]\n",
+ snprintf(buffer, sizeof(buffer),
+ "End of %s Digest [Volume %d Issue %d]\n",
digest, volume, issue);
- i = strlen (buffer);
+ i = strlen(buffer);
for (bp = buffer + i; i > 1; i--)
*bp++ = '*';
*bp++ = '\n';
*bp = 0;
- write (out, buffer, strlen (buffer));
+ write(out, buffer, strlen(buffer));
}
}
*/
static void
-copy_mime_draft (int out)
+copy_mime_draft(int out)
{
int msgnum;
char buffer[BUFSIZ];
- snprintf (buffer, sizeof(buffer), "#forw [forwarded message%s] +%s",
- mp->numsel == 1 ? "" : "s", mp->foldpath);
- write (out, buffer, strlen (buffer));
+ snprintf(buffer, sizeof(buffer), "#forw [forwarded message%s] +%s",
+ mp->numsel == 1 ? "" : "s", mp->foldpath);
+ write(out, buffer, strlen(buffer));
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
- if (is_selected (mp, msgnum)) {
- snprintf (buffer, sizeof(buffer), " %s", m_name (msgnum));
- write (out, buffer, strlen (buffer));
+ if (is_selected(mp, msgnum)) {
+ snprintf(buffer, sizeof(buffer), " %s",
+ m_name(msgnum));
+ write(out, buffer, strlen(buffer));
}
- write (out, "\n", 1);
+ write(out, "\n", 1);
}
static int
-build_form (char *form, char *digest, int volume, int issue)
+build_form(char *form, char *digest, int volume, int issue)
{
int in;
int fmtsize;
char *cp = NULL;
/* Get new format string */
- nfs = new_fs (form, NULL, NULL);
- fmtsize = strlen (nfs) + 256;
+ nfs = new_fs(form, NULL, NULL);
+ fmtsize = strlen(nfs) + 256;
/* Compile format string */
- fmt_compile (nfs, &fmt);
+ fmt_compile(nfs, &fmt);
- FINDCOMP (cptr, "digest");
+ FINDCOMP(cptr, "digest");
if (cptr)
cptr->c_text = digest;
- FINDCOMP (cptr, "date");
+ FINDCOMP(cptr, "date");
if (cptr)
- cptr->c_text = getcpy(dtimenow (0));
+ cptr->c_text = getcpy(dtimenow(0));
dat[0] = issue;
dat[1] = volume;
cp = m_mktemp2(NULL, invo_name, NULL, &tmp);
if (cp == NULL) adios("forw", "unable to create temporary file");
- strncpy (tmpfil, cp, sizeof(tmpfil));
- unlink (tmpfil);
- if ((in = dup (fileno (tmp))) == NOTOK)
- adios ("dup", "unable to");
-
- line = mh_xmalloc ((unsigned) fmtsize);
- fmt_scan (fmt, line, fmtsize, dat);
- fputs (line, tmp);
- free (line);
- if (fclose (tmp))
- adios (tmpfil, "error writing");
-
- lseek (in, (off_t) 0, SEEK_SET);
+ strncpy(tmpfil, cp, sizeof(tmpfil));
+ unlink(tmpfil);
+ if ((in = dup(fileno(tmp))) == NOTOK)
+ adios("dup", "unable to");
+
+ line = mh_xmalloc((unsigned) fmtsize);
+ fmt_scan(fmt, line, fmtsize, dat);
+ fputs(line, tmp);
+ free(line);
+ if (fclose(tmp))
+ adios(tmpfil, "error writing");
+
+ lseek(in, (off_t) 0, SEEK_SET);
return in;
}
#include <errno.h>
#define start_tcp_client(res) \
- socket (res->ai_family, res->ai_socktype, res->ai_protocol)
+ socket(res->ai_family, res->ai_socktype, res->ai_protocol)
#define join_tcp_server(fd, sock, len) \
- connect ((fd), (struct sockaddr *) (sock), len)
+ connect((fd), (struct sockaddr *) (sock), len)
/*
** prototypes
*/
-int ftp_get (char *, char *, char *, char *, char *, char *, int, int);
-int ftp_trans (char *, char *, char *, char *, char *, char *, char *,
+int ftp_get(char *, char *, char *, char *, char *, char *, int, int);
+int ftp_trans(char *, char *, char *, char *, char *, char *, char *,
int, int);
/*
** 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);
-static int ftp_read (char *, char *, char *, int);
-static int initconn (void);
-static int dataconn (void);
-static int command (int arg1, ...);
-static int vcommand (int, va_list);
-static int getreply (int, int);
+static int start_tcp_server(struct sockaddr_in *, int, int, int);
+static void _asnprintf(char *, int, char *, va_list);
+static int ftp_quit(void);
+static int ftp_read(char *, char *, char *, int);
+static int initconn(void);
+static int dataconn(void);
+static int command(int arg1, ...);
+static int vcommand(int, va_list);
+static int getreply(int, int);
static int
-start_tcp_server (struct sockaddr_in *sock, int backlog, int opt1, int opt2)
+start_tcp_server(struct sockaddr_in *sock, int backlog, int opt1, int opt2)
{
int eindex, sd;
- if ((sd = socket (AF_INET, SOCK_STREAM, 0)) == NOTOK)
+ if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == NOTOK)
return NOTOK;
- if (bind (sd, (struct sockaddr *) sock, sizeof *sock) == NOTOK) {
+ if (bind(sd, (struct sockaddr *) sock, sizeof *sock) == NOTOK) {
eindex = errno;
- close (sd);
+ close(sd);
errno = eindex;
} else {
- listen (sd, backlog);
+ listen(sd, backlog);
}
return sd;
static int __len__;
#define join_tcp_client(fd,sock) \
- accept ((fd), (struct sockaddr *) (sock), \
+ accept((fd), (struct sockaddr *) (sock), \
(__len__ = sizeof *(sock), &__len__))
#define read_tcp_socket read
#define close_tcp_socket close
static void
-_asnprintf (char *bp, int len_bp, char *what, va_list ap)
+_asnprintf(char *bp, int len_bp, char *what, va_list ap)
{
int eindex, len;
char *fmt;
eindex = errno;
*bp = '\0';
- fmt = va_arg (ap, char *);
+ fmt = va_arg(ap, char *);
if (fmt) {
vsnprintf(bp, len_bp, fmt, ap);
char *s;
if (*what) {
- snprintf (bp, len_bp, " %s: ", what);
- len = strlen (bp);
+ snprintf(bp, len_bp, " %s: ", what);
+ len = strlen(bp);
bp += len;
len_bp -= len;
}
if ((s = strerror(eindex)))
- strncpy (bp, s, len_bp);
+ strncpy(bp, s, len_bp);
else
- snprintf (bp, len_bp, "Error %d", eindex);
- bp += strlen (bp);
+ snprintf(bp, len_bp, "Error %d", eindex);
+ bp += strlen(bp);
}
errno = eindex;
int
-ftp_get (char *host, char *user, char *password, char *cwd,
+ftp_get(char *host, char *user, char *password, char *cwd,
char *remote, char *local, int ascii, int stayopen)
{
- return ftp_trans (host, user, password, cwd, remote, local,
+ return ftp_trans(host, user, password, cwd, remote, local,
"RETR", ascii, stayopen);
}
int
-ftp_trans (char *host, char *user, char *password, char *cwd, char *remote,
+ftp_trans(char *host, char *user, char *password, char *cwd, char *remote,
char *local, char *cmd, int ascii, int stayopen)
{
int result;
if (stayopen <= 0) {
- result = ftp_quit ();
+ result = ftp_quit();
if (host == NULL)
return result;
}
result = getaddrinfo(host, "ftp", &hints, &res);
if (result) {
- fprintf(stderr, "%s/ftp: %s\n", host, gai_strerror(result));
+ fprintf(stderr, "%s/ftp: %s\n",
+ host, gai_strerror(result));
return NOTOK;
}
- if ((ftp_fd = start_tcp_client (res)) == NOTOK) {
- perror (host);
+ if ((ftp_fd = start_tcp_client(res)) == NOTOK) {
+ perror(host);
freeaddrinfo(res);
return NOTOK;
}
- if (join_tcp_server (ftp_fd, res->ai_addr, res->ai_addrlen) == NOTOK) {
- perror (host);
+ if (join_tcp_server(ftp_fd, res->ai_addr, res->ai_addrlen)
+ == NOTOK) {
+ perror(host);
freeaddrinfo(res);
- close_tcp_socket (ftp_fd), ftp_fd = NOTOK;
+ close_tcp_socket(ftp_fd), ftp_fd = NOTOK;
return NOTOK;
}
freeaddrinfo(res);
- getreply (1, 0);
+ getreply(1, 0);
if (v_verbose) {
- fprintf (stdout, "Connected to %s\n", host);
- fflush (stdout);
+ fprintf(stdout, "Connected to %s\n", host);
+ fflush(stdout);
}
if (user) {
- if ((result = command (0, "USER %s", user)) == CONTINUE)
- result = command (1, "PASS %s", password);
+ if ((result = command (0, "USER %s", user))
+ == CONTINUE)
+ result = command(1, "PASS %s", password);
if (result != COMPLETE) {
result = NOTOK;
goto out;
}
if (cwd && ((result = command (0, "CWD %s", cwd)) != COMPLETE
- && result != CONTINUE)) {
+ && result != CONTINUE)) {
result = NOTOK;
goto out;
}
- if (command (1, ascii ? "TYPE A" : "TYPE I") != COMPLETE) {
+ if (command(1, ascii ? "TYPE A" : "TYPE I") != COMPLETE) {
result = NOTOK;
goto out;
}
- result = ftp_read (remote, local, cmd, ascii);
+ result = ftp_read(remote, local, cmd, ascii);
out: ;
if (result != OK || !stayopen)
- ftp_quit ();
+ ftp_quit();
return result;
}
static int
-ftp_quit (void)
+ftp_quit(void)
{
int n;
if (ftp_fd == NOTOK)
return OK;
- n = command (1, "QUIT");
- close_tcp_socket (ftp_fd), ftp_fd = NOTOK;
+ n = command(1, "QUIT");
+ close_tcp_socket(ftp_fd), ftp_fd = NOTOK;
return (n == 0 || n == COMPLETE ? OK : NOTOK);
}
static int
-ftp_read (char *remote, char *local, char *cmd, int ascii)
+ftp_read(char *remote, char *local, char *cmd, int ascii)
{
int istdio = 0, istore;
register int cc;
char buffer[BUFSIZ];
FILE *fp = NULL;
- if (initconn () == NOTOK)
+ if (initconn() == NOTOK)
goto bad;
v_noise = v_verbose;
- if (command (-1, *remote ? "%s %s" : "%s", cmd, remote) != PRELIM)
+ if (command(-1, *remote ? "%s %s" : "%s", cmd, remote) != PRELIM)
goto bad;
expectingreply++;
- if (dataconn () == NOTOK) {
+ if (dataconn() == NOTOK) {
bad: ;
if (fp && !istdio)
- fclose (fp);
+ fclose(fp);
if (data_fd != NOTOK)
- close_tcp_socket (data_fd), data_fd = NOTOK;
+ close_tcp_socket(data_fd), data_fd = NOTOK;
if (expectingreply)
- getreply (-2, 0);
+ getreply(-2, 0);
return NOTOK;
}
- istore = !strcmp (cmd, "STOR");
+ istore = !strcmp(cmd, "STOR");
- if ((istdio = !strcmp (local, "-")))
+ if ((istdio = !strcmp(local, "-")))
fp = istore ? stdin : stdout;
else
- if ((fp = fopen (local, istore ? "r" : "w")) == NULL) {
- perror (local);
+ if ((fp = fopen(local, istore ? "r" : "w")) == NULL) {
+ perror(local);
goto bad;
}
int c;
FILE *out;
- if (!(out = fdopen (data_fd, "w"))) {
- perror ("fdopen");
+ if (!(out = fdopen(data_fd, "w"))) {
+ perror("fdopen");
goto bad;
}
- while ((c = getc (fp)) != EOF) {
+ while ((c = getc(fp)) != EOF) {
if (c == '\n')
- putc ('\r', out);
- if (putc (c, out) == EOF) {
- perror ("putc");
- fclose (out);
+ putc('\r', out);
+ if (putc(c, out) == EOF) {
+ perror("putc");
+ fclose(out);
data_fd = NOTOK;
goto bad;
}
}
- fclose (out);
+ fclose(out);
data_fd = NOTOK;
} else {
- while ((cc = fread (buffer, sizeof *buffer, sizeof buffer, fp)) > 0)
- if (write_tcp_socket (data_fd, buffer, cc) != cc) {
- perror ("write_tcp_socket");
+ while ((cc = fread(buffer, sizeof *buffer,
+ sizeof buffer, fp)) > 0)
+ if (write_tcp_socket(data_fd, buffer, cc)
+ != cc) {
+ perror("write_tcp_socket");
goto bad;
}
- close_tcp_socket (data_fd), data_fd = NOTOK;
+ close_tcp_socket(data_fd), data_fd = NOTOK;
}
} else {
if (ascii) {
int c;
FILE *in;
- if (!(in = fdopen (data_fd, "r"))) {
- perror ("fdopen");
+ if (!(in = fdopen(data_fd, "r"))) {
+ perror("fdopen");
goto bad;
}
- while ((c = getc (in)) != EOF) {
+ while ((c = getc(in)) != EOF) {
if (c == '\r')
- switch (c = getc (in)) {
+ switch (c = getc(in)) {
case EOF:
case '\0':
c = '\r';
break;
default:
- putc ('\r', fp);
+ putc('\r', fp);
break;
}
- if (putc (c, fp) == EOF) {
- perror ("putc");
- fclose (in);
+ if (putc(c, fp) == EOF) {
+ perror("putc");
+ fclose(in);
data_fd = NOTOK;
goto bad;
}
}
- fclose (in);
+ fclose(in);
data_fd = NOTOK;
} else {
- while ((cc = read_tcp_socket (data_fd, buffer, sizeof buffer)) > 0)
- if (fwrite (buffer, sizeof *buffer, cc, fp) == 0) {
- perror ("fwrite");
+ while ((cc = read_tcp_socket(data_fd, buffer,
+ sizeof buffer)) > 0)
+ if (fwrite(buffer, sizeof *buffer, cc, fp)
+ == 0) {
+ perror("fwrite");
goto bad;
}
if (cc < 0) {
- perror ("read_tcp_socket");
+ perror("read_tcp_socket");
goto bad;
}
- close_tcp_socket (data_fd), data_fd = NOTOK;
+ close_tcp_socket(data_fd), data_fd = NOTOK;
}
}
if (!istdio)
- fclose (fp);
+ fclose(fp);
v_noise = v_verbose;
- return (getreply (1, 0) == COMPLETE ? OK : NOTOK);
+ return (getreply(1, 0) == COMPLETE ? OK : NOTOK);
}
#define UC(b) (((int) b) & 0xff)
static int
-initconn (void)
+initconn(void)
{
int len;
register char *a, *p;
struct sockaddr_in in_socket;
- if (getsockname (ftp_fd, (struct sockaddr *) &in_socket,
+ if (getsockname(ftp_fd, (struct sockaddr *) &in_socket,
(len = sizeof(in_socket), &len)) == NOTOK) {
- perror ("getsockname");
+ perror("getsockname");
return NOTOK;
}
in_socket.sin_port = 0;
- if ((data_fd = start_tcp_server (&in_socket, 1, 0, 0)) == NOTOK) {
- perror ("start_tcp_server");
+ if ((data_fd = start_tcp_server(&in_socket, 1, 0, 0)) == NOTOK) {
+ perror("start_tcp_server");
return NOTOK;
}
- if (getsockname (data_fd, (struct sockaddr *) &in_socket,
+ if (getsockname(data_fd, (struct sockaddr *) &in_socket,
(len = sizeof in_socket, &len)) == NOTOK) {
- perror ("getsockname");
+ perror("getsockname");
return NOTOK;
}
a = (char *) &in_socket.sin_addr;
p = (char *) &in_socket.sin_port;
- if (command (1, "PORT %d,%d,%d,%d,%d,%d",
- UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
- UC(p[0]), UC(p[1])) == COMPLETE)
+ if (command(1, "PORT %d,%d,%d,%d,%d,%d",
+ UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
+ UC(p[0]), UC(p[1])) == COMPLETE)
return OK;
return NOTOK;
}
static int
-dataconn (void)
+dataconn(void)
{
int fd;
struct sockaddr_in in_socket;
- if ((fd = join_tcp_client (data_fd, &in_socket)) == NOTOK) {
- perror ("join_tcp_client");
+ if ((fd = join_tcp_client(data_fd, &in_socket)) == NOTOK) {
+ perror("join_tcp_client");
return NOTOK;
}
- close_tcp_socket (data_fd);
+ close_tcp_socket(data_fd);
data_fd = fd;
return OK;
static int
-command (int arg1, ...)
+command(int arg1, ...)
{
int val;
va_list ap;
- va_start (ap, arg1);
- val = vcommand (arg1, ap);
- va_end (ap);
+ va_start(ap, arg1);
+ val = vcommand(arg1, ap);
+ va_end(ap);
return val;
}
static int
-vcommand (int complete, va_list ap)
+vcommand(int complete, va_list ap)
{
int len;
char buffer[BUFSIZ];
if (ftp_fd == NOTOK)
return NOTOK;
- _asnprintf (buffer, sizeof(buffer), NULL, ap);
+ _asnprintf(buffer, sizeof(buffer), NULL, ap);
if (v_debug)
- fprintf (stderr, "<--- %s\n", buffer);
+ fprintf(stderr, "<--- %s\n", buffer);
- strcat (buffer, "\r\n");
- len = strlen (buffer);
+ strcat(buffer, "\r\n");
+ len = strlen(buffer);
- if (write_tcp_socket (ftp_fd, buffer, len) != len) {
- perror ("write_tcp_socket");
+ if (write_tcp_socket(ftp_fd, buffer, len) != len) {
+ perror("write_tcp_socket");
return NOTOK;
}
- return (getreply (complete, !strcmp (buffer, "QUIT")));
+ return(getreply(complete, !strcmp(buffer, "QUIT")));
}
static int
-getreply (int complete, int expecteof)
+getreply(int complete, int expecteof)
{
for (;;) {
register int code, dig, n;
for (;;) {
unsigned char c;
- if (read_tcp_socket (ftp_fd, &c, 1) < 1) {
+ if (read_tcp_socket(ftp_fd, &c, 1) < 1) {
if (expecteof)
return OK;
- perror ("read_tcp_socket");
+ perror("read_tcp_socket");
return DONE;
}
if (c == '\n')
if (dig < 4) {
if (isdigit(c))
code = code * 10 + (c - '0');
- else if (isspace (c))
+ else if (isspace(c))
/* XXX: naughty FTP... */
continuation++;
} else
}
if (v_debug)
- fprintf (stderr, "---> %s\n", buffer);
+ fprintf(stderr, "---> %s\n", buffer);
if (continuation)
continue;
n -= '0';
if (v_noise) {
- fprintf (stdout, "%s\n", buffer);
- fflush (stdout);
+ fprintf(stdout, "%s\n", buffer);
+ fflush(stdout);
v_noise = 0;
} else
if ((complete == -1 && n != PRELIM)
|| (complete == 0 && n != CONTINUE && n != COMPLETE)
|| (complete == 1 && n != COMPLETE))
- fprintf (stderr, "%s\n", buffer);
+ fprintf(stderr, "%s\n", buffer);
return n;
}
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int chgflag = 1, trnflag = 1;
int noisy = 1, width = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [switches]", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case AUDSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- audfile = getcpy (m_maildir (cp));
+ adios(NULL, "missing argument to %s", argp[-2]);
+ audfile = getcpy(m_maildir(cp));
continue;
case NAUDSW:
audfile = NULL;
case FILESW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- from = path (cp, TFILE);
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ from = path(cp, TFILE);
/*
** If the truncate file is in default state,
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
format = NULL;
continue;
case FMTSW:
if (!(format = *argp++) || *format == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
form = NULL;
continue;
case WIDTHSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- width = atoi (cp);
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ width = atoi(cp);
continue;
}
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else {
- adios (NULL, "usage: %s [+folder] [switches]", invo_name);
+ adios(NULL, "usage: %s [+folder] [switches]",
+ invo_name);
}
}
*/
if (from)
newmail = from;
- else if ((newmail = getenv ("MAILDROP")) && *newmail)
- newmail = m_mailpath (newmail);
- else if ((newmail = context_find ("maildrop")) && *newmail)
- newmail = m_mailpath (newmail);
+ else if ((newmail = getenv("MAILDROP")) && *newmail)
+ newmail = m_mailpath(newmail);
+ else if ((newmail = context_find("maildrop")) && *newmail)
+ newmail = m_mailpath(newmail);
else {
- newmail = concat (MAILDIR, "/", MAILFIL, NULL);
+ newmail = concat(MAILDIR, "/", MAILFIL, NULL);
}
- if (stat (newmail, &s1) == NOTOK || s1.st_size == 0)
- adios (NULL, "no mail to incorporate");
+ if (stat(newmail, &s1) == NOTOK || s1.st_size == 0)
+ adios(NULL, "no mail to incorporate");
if ((cp = strdup(newmail)) == (char *)0)
- adios (NULL, "error allocating memory to copy newmail");
+ adios(NULL, "error allocating memory to copy newmail");
newmail = cp;
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (!folder)
- folder = getfolder (0);
- maildir = m_maildir (folder);
+ folder = getfolder(0);
+ maildir = m_maildir(folder);
if ((maildir_copy = strdup(maildir)) == (char *)0)
- adios (maildir, "error allocating memory to copy maildir");
+ adios(maildir, "error allocating memory to copy maildir");
if (!folder_exists(maildir)) {
/*
if (noisy)
create_folder(maildir, 0, done);
else
- done (1);
+ done(1);
}
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
- if (access (newmail, W_OK) != NOTOK) {
+ if (access(newmail, W_OK) != NOTOK) {
locked++;
if (trnflag) {
- SIGNAL (SIGHUP, SIG_IGN);
- SIGNAL (SIGINT, SIG_IGN);
- SIGNAL (SIGQUIT, SIG_IGN);
- SIGNAL (SIGTERM, SIG_IGN);
+ SIGNAL(SIGHUP, SIG_IGN);
+ SIGNAL(SIGINT, SIG_IGN);
+ SIGNAL(SIGQUIT, SIG_IGN);
+ SIGNAL(SIGTERM, SIG_IGN);
}
GETGROUPPRIVS(); /* Reset gid to lock mail file */
- in = lkfopen (newmail, "r");
+ in = lkfopen(newmail, "r");
DROPGROUPPRIVS();
if (in == NULL)
- adios (NULL, "unable to lock and fopen %s", newmail);
- fstat (fileno(in), &s1);
+ adios(NULL, "unable to lock and fopen %s", newmail);
+ fstat(fileno(in), &s1);
} else {
trnflag = 0;
- if ((in = fopen (newmail, "r")) == NULL)
- adios (newmail, "unable to read");
+ if ((in = fopen(newmail, "r")) == NULL)
+ adios(newmail, "unable to read");
}
/* This shouldn't be necessary but it can't hurt. */
if (audfile) {
int i;
- if ((i = stat (audfile, &st)) == NOTOK)
- advise (NULL, "Creating Receive-Audit: %s", audfile);
- if ((aud = fopen (audfile, "a")) == NULL)
- adios (audfile, "unable to append to");
+ if ((i = stat(audfile, &st)) == NOTOK)
+ advise(NULL, "Creating Receive-Audit: %s", audfile);
+ if ((aud = fopen(audfile, "a")) == NULL)
+ adios(audfile, "unable to append to");
else if (i == NOTOK)
- chmod (audfile, m_gmprot ());
+ chmod(audfile, m_gmprot());
- fprintf (aud, from ? "<<inc>> %s -ms %s\n" : "<<inc>> %s\n",
- dtimenow (0), from);
+ fprintf(aud, from ? "<<inc>> %s -ms %s\n" : "<<inc>> %s\n",
+ dtimenow(0), from);
}
#ifdef MHE
- if (context_find ("mhe")) {
+ if (context_find("mhe")) {
int i;
- cp = concat (maildir, "/++", NULL);
- i = stat (cp, &st);
- if ((mhe = fopen (cp, "a")) == NULL)
- admonish (cp, "unable to append to");
+ cp = concat(maildir, "/++", NULL);
+ i = stat(cp, &st);
+ if ((mhe = fopen(cp, "a")) == NULL)
+ admonish(cp, "unable to append to");
else
if (i == NOTOK)
- chmod (cp, m_gmprot ());
- free (cp);
+ chmod(cp, m_gmprot());
+ free(cp);
}
#endif /* MHE */
/* Get new format string */
- nfs = new_fs (form, format, FORMAT);
+ nfs = new_fs(form, format, FORMAT);
if (noisy) {
- printf ("Incorporating new mail into %s...\n\n", folder);
- fflush (stdout);
+ printf("Incorporating new mail into %s...\n\n", folder);
+ fflush(stdout);
}
/*
** Get the mail from file (usually mail spool)
*/
- m_unknown (in); /* the MAGIC invocation... */
+ 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.
*/
- if (msgnum >= mp->hghoff
- && !(mp = folder_realloc (mp, mp->lowoff, mp->hghoff + 100))) {
- advise (NULL, "unable to allocate folder storage");
+ if (msgnum >= mp->hghoff && !(mp = folder_realloc(mp, mp->lowoff, mp->hghoff + 100))) {
+ advise(NULL, "unable to allocate folder storage");
incerr = NOTOK;
break;
}
/* create scanline for new message */
- switch (incerr = scan (in, msgnum + 1, msgnum + 1, nfs, width,
+ switch (incerr = scan(in, msgnum + 1, msgnum + 1, nfs, width,
msgnum == hghnum && chgflag, 1, NULL, 0L, noisy)) {
case SCNFAT:
case SCNEOF:
case SCNERR:
if (aud)
- fputs ("inc aborted!\n", aud);
+ fputs("inc aborted!\n", aud);
/* doesn't clean up locks! */
- advise (NULL, "aborted!");
+ advise(NULL, "aborted!");
break;
case SCNNUM:
- advise (NULL, "BUG in %s, number out of range", invo_name);
+ advise(NULL, "BUG in %s, number out of range",
+ invo_name);
break;
default:
- advise (NULL, "BUG in %s, scan() botch (%d)", invo_name, incerr);
+ advise(NULL, "BUG in %s, scan() botch (%d)",
+ invo_name, incerr);
break;
case SCNMSG:
** 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);
+ snprintf(b, sizeof (b), "%s/%d", maildir_copy,
+ msgnum + 1);
+ ext_hook("add-hook", b, (char *)0);
if (aud)
- fputs (scanl, aud);
+ fputs(scanl, aud);
#ifdef MHE
if (mhe)
- fputs (scanl, mhe);
+ fputs(scanl, mhe);
#endif /* MHE */
if (noisy)
- fflush (stdout);
+ fflush(stdout);
msgnum++;
mp->hghmsg++;
mp->nummsg++;
if (mp->lowmsg == 0)
mp->lowmsg = 1;
- clear_msg_flags (mp, msgnum);
- set_exists (mp, msgnum);
- set_unseen (mp, msgnum);
+ clear_msg_flags(mp, msgnum);
+ set_exists(mp, msgnum);
+ set_unseen(mp, msgnum);
mp->msgflags |= SEQMOD;
continue;
}
if (incerr < 0) { /* error */
if (locked) {
GETGROUPPRIVS(); /* Be sure we can unlock mail file */
- (void) lkfclose (in, newmail); in = NULL;
+ (void) lkfclose(in, newmail); in = NULL;
DROPGROUPPRIVS(); /*
** And then return us to normal
** privileges
*/
} else {
- fclose (in); in = NULL;
+ fclose(in); in = NULL;
}
- adios (NULL, "failed");
+ adios(NULL, "failed");
}
if (aud)
- fclose (aud);
+ fclose(aud);
#ifdef MHE
if (mhe)
- fclose (mhe);
+ fclose(mhe);
#endif /* MHE */
if (noisy)
- fflush (stdout);
+ fflush(stdout);
/*
** 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");
+ if (stat(newmail, &st) != NOTOK && s1.st_mtime != st.st_mtime)
+ advise(NULL, "new messages have arrived!\007");
else {
int newfd;
- if ((newfd = creat (newmail, 0600)) != NOTOK)
- close (newfd);
+ if ((newfd = creat(newmail, 0600)) != NOTOK)
+ close(newfd);
else
- admonish (newmail, "error zero'ing");
+ admonish(newmail, "error zero'ing");
unlink(map_name(newmail));
}
} else if (noisy) {
- printf ("%s not zero'd\n", newmail);
+ printf("%s not zero'd\n", newmail);
}
if (msgnum == hghnum) {
- admonish (NULL, "no messages incorporated");
+ admonish(NULL, "no messages incorporated");
} else {
- context_replace (pfolder, folder); /* update current folder */
+ context_replace(pfolder, folder); /* update current folder */
if (chgflag)
mp->curmsg = hghnum + 1;
mp->hghmsg = msgnum;
if (mp->lowmsg == 0)
mp->lowmsg = 1;
if (chgflag) /* sigh... */
- seq_setcur (mp, mp->curmsg);
+ seq_setcur(mp, mp->curmsg);
}
/*
*/
if (locked) {
GETGROUPPRIVS(); /* Be sure we can unlock mail file */
- (void) lkfclose (in, newmail); in = NULL;
+ (void) lkfclose(in, newmail); in = NULL;
DROPGROUPPRIVS(); /* And then return us to normal privileges */
} else {
- fclose (in); in = NULL;
+ fclose(in); in = NULL;
}
- seq_setunseen (mp, 0); /* set the Unseen-Sequence */
- seq_save (mp); /* synchronize sequences */
- context_save (); /* save the context file */
- done (0);
+ seq_setunseen(mp, 0); /* set the Unseen-Sequence */
+ seq_save(mp); /* synchronize sequences */
+ context_save(); /* save the context file */
+ done(0);
return 1;
}
static void
-inc_done (int status)
+inc_done(int status)
{
if (locked) {
GETGROUPPRIVS();
lkfclose(in, newmail);
DROPGROUPPRIVS();
}
- exit (status);
+ exit(status);
}
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int autof = 0;
char *cp, *pathname, buf[BUFSIZ];
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
- arguments = getarguments (invo_name, argc, argv, 0);
+ invo_name = r1bindex(argv[0], '/');
+ arguments = getarguments(invo_name, argc, argv, 0);
argp = arguments;
check = 0;
while ((dp = *argp++)) {
if (*dp == '-') {
- switch (smatch (++dp, switches)) {
+ switch (smatch(++dp, switches)) {
case AMBIGSW:
- ambigsw (dp, switches);
- done (1);
+ ambigsw(dp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown\n", dp);
+ adios(NULL, "-%s unknown\n", dp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches]", invo_name);
- print_help (buf, switches, 0);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches]", invo_name);
+ print_help(buf, switches, 0);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case AUTOSW:
autof++;
continue;
}
} else {
- adios (NULL, "%s is invalid argument", dp);
+ adios(NULL, "%s is invalid argument", dp);
}
}
*/
if ((mypath = getenv("HOME")) == (char *)0) {
- if ((pw = getpwuid(getuid())) == (struct passwd *)0 || *pw->pw_dir == '\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 it does.
*/
- if (stat (defpath, &st) != NOTOK) {
+ if (stat(defpath, &st) != NOTOK) {
if (check)
done(0);
else if (autof)
- adios (NULL, "invocation error");
+ adios(NULL, "invocation error");
else
- adios (NULL, "You already have an nmh profile, use an editor to modify it");
+ adios(NULL, "You already have an nmh profile, use an editor to modify it");
} else if (check) {
done(1);
}
- if (!autof && gans ("Do you want help? ", anoyes)) {
+ if (!autof && gans("Do you want help? ", anoyes)) {
(void)printf(
"\n"
"Prior to using nmh, it is necessary to have a file in your login\n"
"\n", mypath, mh_profile, mypath);
}
- cp = concat (mypath, "/", "Mail", NULL);
- if (stat (cp, &st) != NOTOK) {
+ cp = concat(mypath, "/", "Mail", NULL);
+ if (stat(cp, &st) != NOTOK) {
if (S_ISDIR(st.st_mode)) {
- cp = concat ("You already have the standard nmh directory \"",
+ cp = concat("You already have the standard nmh directory \"",
cp, "\".\nDo you want to use it for nmh? ", NULL);
- if (gans (cp, anoyes))
+ if (gans(cp, anoyes))
pathname = "Mail";
else
goto query;
}
} else {
if (autof)
- printf ("I'm going to create the standard nmh path for you.\n");
+ printf("I'm going to create the standard nmh path for you.\n");
else
- cp = concat ("Do you want the standard nmh path \"",
+ cp = concat("Do you want the standard nmh path \"",
mypath, "/", "Mail\"? ", NULL);
- if (autof || gans (cp, anoyes))
+ if (autof || gans(cp, anoyes))
pathname = "Mail";
else {
query:
- if (gans ("Do you want a path below your login directory? ",
- anoyes)) {
- printf ("What is the path? %s/", mypath);
- pathname = geta ();
+ if (gans("Do you want a path below your login directory? ", anoyes)) {
+ printf("What is the path? %s/", mypath);
+ pathname = geta();
} else {
- printf ("What is the whole path? /");
- pathname = concat ("/", geta (), NULL);
+ printf("What is the whole path? /");
+ pathname = concat("/", geta(), NULL);
}
}
}
- chdir (mypath);
- if (chdir (pathname) == NOTOK) {
- cp = concat ("\"", pathname, "\" doesn't exist; Create it? ", NULL);
- if (autof || gans (cp, anoyes))
- if (makedir (pathname) == 0)
- adios (NULL, "unable to create %s", pathname);
+ chdir(mypath);
+ if (chdir(pathname) == NOTOK) {
+ cp = concat("\"", pathname, "\" doesn't exist; Create it? ",
+ NULL);
+ if (autof || gans(cp, anoyes))
+ if (makedir(pathname) == 0)
+ adios(NULL, "unable to create %s", pathname);
} else {
- printf ("[Using existing directory]\n");
+ printf("[Using existing directory]\n");
}
/*
** Add some initial elements to the profile/context list
*/
- m_defs = (struct node *) mh_xmalloc (sizeof *np);
+ m_defs = (struct node *) mh_xmalloc(sizeof *np);
np = m_defs;
- np->n_name = getcpy ("Path");
- np->n_field = getcpy (pathname);
+ np->n_name = getcpy("Path");
+ np->n_field = getcpy(pathname);
np->n_context = 0;
np->n_next = NULL;
** 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);
+ if ((in = fopen(mh_defaults, "r"))) {
+ readconfig(&np->n_next, in, mh_defaults, 0);
+ fclose(in);
}
- ctxpath = getcpy (m_maildir (context = "context"));
+ ctxpath = getcpy(m_maildir(context = "context"));
/* Initialize current folder to default */
- context_replace (pfolder, defaultfolder);
- context_save ();
+ context_replace(pfolder, defaultfolder);
+ context_save();
/*
** Now write out the initial .mh_profile
*/
- if ((out = fopen (defpath, "w")) == NULL)
- adios (defpath, "unable to write");
+ if ((out = fopen(defpath, "w")) == NULL)
+ adios(defpath, "unable to write");
for (np = m_defs; np; np = np->n_next) {
if (!np->n_context)
- fprintf (out, "%s: %s\n", np->n_name, np->n_field);
+ fprintf(out, "%s: %s\n", np->n_name, np->n_field);
}
- fclose (out);
- done (0);
+ fclose(out);
+ done(0);
return 1;
}
static char *
-geta (void)
+geta(void)
{
char *cp;
static char line[BUFSIZ];
fflush(stdout);
if (fgets(line, sizeof(line), stdin) == NULL)
- done (1);
+ done(1);
if ((cp = strchr(line, '\n')))
*cp = 0;
return line;
/*
** static prototypes
*/
-static void print_debug (struct msgs *);
-static void seq_printdebug (struct msgs *);
+static void print_debug(struct msgs *);
+static void seq_printdebug(struct msgs *);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int addsw = 0, deletesw = 0, debugsw = 0;
int listsw = 0, publicsw = -1, zerosw = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown\n", cp);
+ adios(NULL, "-%s unknown\n", cp);
case HELPSW:
- snprintf (buf, sizeof(buf),
- "%s [+folder] [msgs] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case ADDSW:
addsw++;
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)
- adios (NULL, "too many sequences (more than %d) specified", NUMATTRS);
+ adios(NULL, "too many sequences (more than %d) specified", NUMATTRS);
seqs[seqp++] = cp;
continue;
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
app_msgarg(&msgs, cp);
}
listsw++;
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (!msgs.size)
app_msgarg(&msgs, listsw ? "all" :"cur");
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* print some general debugging info */
if (debugsw)
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
+ if (!m_convert(mp, msgs.msgs[msgnum]))
+ done(1);
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);
/*
** 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");
+ adios(NULL, "-%s requires at least one -sequence argument",
+ addsw ? "add" : "delete");
seqs[seqp] = NULL;
/* Adding messages to sequences */
if (addsw) {
for (seqp = 0; seqs[seqp]; seqp++)
- if (!seq_addsel (mp, seqs[seqp], publicsw, zerosw))
- done (1);
+ if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw))
+ done(1);
}
/* Deleting messages from sequences */
if (deletesw) {
for (seqp = 0; seqs[seqp]; seqp++)
- if (!seq_delsel (mp, seqs[seqp], publicsw, zerosw))
- done (1);
+ if (!seq_delsel(mp, seqs[seqp], publicsw, zerosw))
+ done(1);
}
/* Listing messages in sequences */
if (seqp) {
/* print the sequences given */
for (seqp = 0; seqs[seqp]; seqp++)
- seq_print (mp, seqs[seqp]);
+ seq_print(mp, seqs[seqp]);
} else {
/* else print them all */
- seq_printall (mp);
+ seq_printall(mp);
}
/* print debugging info about SELECTED messages */
if (debugsw)
- seq_printdebug (mp);
+ seq_printdebug(mp);
}
- seq_save (mp); /* synchronize message sequences */
- context_replace (pfolder, folder); /* update current folder */
- context_save (); /* save the context file */
- folder_free (mp); /* free folder/message structure */
- done (0);
+ seq_save(mp); /* synchronize message sequences */
+ context_replace(pfolder, folder); /* update current folder */
+ context_save(); /* save the context file */
+ folder_free(mp); /* free folder/message structure */
+ done(0);
return 1;
}
** Print general debugging info
*/
static void
-print_debug (struct msgs *mp)
+print_debug(struct msgs *mp)
{
char buf[100];
- printf ("invo_name = %s\n", invo_name);
- printf ("mypath = %s\n", mypath);
- printf ("defpath = %s\n", defpath);
- printf ("ctxpath = %s\n", ctxpath);
- printf ("context flags = %s\n", snprintb (buf, sizeof(buf),
- (unsigned) ctxflags, DBITS));
- printf ("foldpath = %s\n", mp->foldpath);
- printf ("folder flags = %s\n\n", snprintb(buf, sizeof(buf),
- (unsigned) mp->msgflags, FBITS));
- printf ("lowmsg=%d hghmsg=%d nummsg=%d curmsg=%d\n",
- mp->lowmsg, mp->hghmsg, mp->nummsg, mp->curmsg);
- printf ("lowsel=%d hghsel=%d numsel=%d\n",
- mp->lowsel, mp->hghsel, mp->numsel);
- printf ("lowoff=%d hghoff=%d\n\n", mp->lowoff, mp->hghoff);
+ printf("invo_name = %s\n", invo_name);
+ printf("mypath = %s\n", mypath);
+ printf("defpath = %s\n", defpath);
+ printf("ctxpath = %s\n", ctxpath);
+ printf("context flags = %s\n", snprintb(buf, sizeof(buf),
+ (unsigned) ctxflags, DBITS));
+ printf("foldpath = %s\n", mp->foldpath);
+ printf("folder flags = %s\n\n", snprintb(buf, sizeof(buf),
+ (unsigned) mp->msgflags, FBITS));
+ printf("lowmsg=%d hghmsg=%d nummsg=%d curmsg=%d\n",
+ mp->lowmsg, mp->hghmsg, mp->nummsg, mp->curmsg);
+ printf("lowsel=%d hghsel=%d numsel=%d\n",
+ mp->lowsel, mp->hghsel, mp->numsel);
+ printf("lowoff=%d hghoff=%d\n\n", mp->lowoff, mp->hghoff);
}
** messages and the sequences they are in.
*/
static void
-seq_printdebug (struct msgs *mp)
+seq_printdebug(struct msgs *mp)
{
int msgnum;
char buf[100];
- printf ("\n");
+ printf("\n");
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
- if (is_selected (mp, msgnum))
- printf ("%*d: %s\n", DMAXFOLDER, msgnum,
- snprintb (buf, sizeof(buf),
- (unsigned) mp->msgstats[msgnum - mp->lowoff],
- seq_bits (mp)));
+ if (is_selected(mp, msgnum))
+ printf("%*d: %s\n", DMAXFOLDER, msgnum, snprintb(buf, sizeof(buf), (unsigned) mp->msgstats[msgnum - mp->lowoff], seq_bits(mp)));
}
}
static char outfile[BUFSIZ];
static int unlink_outfile = 0;
-static void unlink_done (int) NORETURN;
+static void unlink_done(int) NORETURN;
/* mhbuildsbr.c */
-CT build_mime (char *);
-int output_message (CT, char *);
-int output_message_fp (CT, FILE *, char*);
+CT build_mime(char *);
+int output_message(CT, char *);
+int output_message_fp(CT, FILE *, char*);
/* mhlistsbr.c */
-int list_all_messages (CT *, int, int, int, int);
+int list_all_messages(CT *, int, int, int, int);
/* mhmisc.c */
-void set_endian (void);
+void set_endian(void);
/* mhfree.c */
-void free_content (CT);
+void free_content(CT);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int sizesw = 1, headsw = 1;
int *icachesw;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (cp[0] == '-' && cp[1] == '\0') {
if (compfile)
- adios (NULL, "cannot specify both standard input and a file");
+ adios(NULL, "cannot specify both standard input and a file");
else
compfile = cp;
listsw = 0; /* turn off -list if using std in/out */
break;
}
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] file", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches] file", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case RCACHESW:
icachesw = &rcachesw;
icachesw = &wcachesw;
do_cache: ;
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- switch (*icachesw = smatch (cp, caches)) {
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ switch (*icachesw = smatch(cp, caches)) {
case AMBIGSW:
- ambigsw (cp, caches);
- done (1);
+ ambigsw(cp, caches);
+ done(1);
case UNKWNSW:
- adios (NULL, "%s unknown", cp);
+ adios(NULL, "%s unknown", cp);
default:
break;
}
}
}
if (compfile)
- adios (NULL, "only one composition file allowed");
+ adios(NULL, "only one composition file allowed");
else
compfile = cp;
}
- set_endian ();
+ set_endian();
- if ((cp = getenv ("MM_NOASK")) && !strcmp (cp, "1"))
+ if ((cp = getenv("MM_NOASK")) && !strcmp(cp, "1"))
listsw = 0;
/*
** Check if we've specified an additional profile
*/
- if ((cp = getenv ("MHBUILD"))) {
- if ((fp = fopen (cp, "r"))) {
- readconfig ((struct node **) 0, fp, cp, 0);
- fclose (fp);
+ if ((cp = getenv("MHBUILD"))) {
+ if ((fp = fopen(cp, "r"))) {
+ readconfig((struct node **) 0, fp, cp, 0);
+ fclose(fp);
} else {
- admonish ("", "unable to read $MHBUILD profile (%s)", cp);
+ admonish("", "unable to read $MHBUILD profile (%s)",
+ cp);
}
}
/*
** Read the standard profile setup
*/
- if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) {
- readconfig ((struct node **) 0, fp, cp, 0);
- fclose (fp);
+ if ((fp = fopen(cp = etcpath("mhn.defaults"), "r"))) {
+ readconfig((struct node **) 0, fp, cp, 0);
+ fclose(fp);
}
/* Check for public cache location */
- if ((cache_public = context_find (nmhcache)) && *cache_public != '/')
+ if ((cache_public = context_find(nmhcache)) && *cache_public != '/')
cache_public = NULL;
/* Check for private cache location */
- if (!(cache_private = context_find (nmhprivcache)))
+ if (!(cache_private = context_find(nmhprivcache)))
cache_private = ".cache";
- cache_private = getcpy (m_maildir (cache_private));
+ 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.
*/
- if ((cp = context_find (nmhstorage)) && *cp)
- tmp = concat (cp, "/", invo_name, NULL);
+ if ((cp = context_find(nmhstorage)) && *cp)
+ tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = add (m_maildir (invo_name), NULL);
+ tmp = add(m_maildir(invo_name), NULL);
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
/* Check if we have a file to process */
if (!compfile)
- adios (NULL, "need to specify a %s composition file", invo_name);
+ adios(NULL, "need to specify a %s composition file",
+ invo_name);
/*
** 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));
- while (fgets (buffer, BUFSIZ, stdin))
- fputs (buffer, fp);
- fclose (fp);
+ strncpy(infile, m_mktemp(invo_name, NULL, &fp),
+ sizeof(infile));
+ while (fgets(buffer, BUFSIZ, stdin))
+ fputs(buffer, fp);
+ fclose(fp);
unlink_infile = 1;
/* build the content structures for MIME message */
- ct = build_mime (infile);
+ ct = build_mime(infile);
cts[0] = ct;
cts[1] = NULL;
/* output MIME message to this temporary file */
- strncpy (outfile, m_mktemp(invo_name, NULL, &fp_out), sizeof(outfile));
+ strncpy(outfile, m_mktemp(invo_name, NULL, &fp_out),
+ sizeof(outfile));
unlink_outfile = 1;
/* output the message */
- output_message_fp (ct, fp_out, outfile);
+ output_message_fp(ct, fp_out, outfile);
fclose(fp_out);
/* output the temp file to standard output */
- if ((fp = fopen (outfile, "r")) == NULL)
- adios (outfile, "unable to open");
- while (fgets (buffer, BUFSIZ, fp))
- fputs (buffer, stdout);
- fclose (fp);
+ if ((fp = fopen(outfile, "r")) == NULL)
+ adios(outfile, "unable to open");
+ while (fgets(buffer, BUFSIZ, fp))
+ fputs(buffer, stdout);
+ fclose(fp);
- unlink (infile);
+ unlink(infile);
unlink_infile = 0;
- unlink (outfile);
+ unlink(outfile);
unlink_outfile = 0;
- free_content (ct);
- done (0);
+ free_content(ct);
+ done(0);
}
/*
*/
/* build the content structures for MIME message */
- ct = build_mime (compfile);
+ ct = build_mime(compfile);
cts[0] = ct;
cts[1] = NULL;
unlink_outfile = 1;
/* output the message */
- output_message_fp (ct, fp_out, outfile);
+ output_message_fp(ct, fp_out, outfile);
fclose(fp_out);
/*
** List the message info
*/
if (listsw)
- list_all_messages (cts, headsw, sizesw, verbosw, debugsw);
+ list_all_messages(cts, headsw, sizesw, verbosw, debugsw);
/* Rename composition draft */
- snprintf (buffer, sizeof(buffer), "%s.orig", m_backup (compfile));
- if (rename (compfile, buffer) == NOTOK) {
- adios (compfile, "unable to rename comp draft %s to", buffer);
+ snprintf(buffer, sizeof(buffer), "%s.orig", m_backup(compfile));
+ if (rename(compfile, buffer) == NOTOK) {
+ adios(compfile, "unable to rename comp draft %s to", buffer);
}
/* Rename output file to take its place */
- if (rename (outfile, compfile) == NOTOK) {
- advise (outfile, "unable to rename output %s to", compfile);
- rename (buffer, compfile);
- done (1);
+ if (rename(outfile, compfile) == NOTOK) {
+ advise(outfile, "unable to rename output %s to", compfile);
+ rename(buffer, compfile);
+ done(1);
}
unlink_outfile = 0;
- free_content (ct);
- done (0);
+ free_content(ct);
+ done(0);
return 1;
}
static void
-unlink_done (int status)
+unlink_done(int status)
{
/*
** Check if we need to remove stray temporary files.
*/
if (unlink_infile)
- unlink (infile);
+ unlink(infile);
if (unlink_outfile)
- unlink (outfile);
+ unlink(outfile);
- exit (status);
+ exit(status);
}
/* mhmisc.c */
-int make_intermediates (char *);
-void content_error (char *, CT, char *, ...);
+int make_intermediates(char *);
+void content_error(char *, CT, char *, ...);
/* mhcachesbr.c */
-int find_cache (CT, int, int *, char *, char *, int);
+int find_cache(CT, int, int *, char *, char *, int);
/* ftpsbr.c */
-int ftp_get (char *, char *, char *, char *, char *, char *, int, int);
+int ftp_get(char *, char *, char *, char *, char *, char *, int, int);
/* mhfree.c */
-void free_content (CT);
-void free_ctinfo (CT);
-void free_encoding (CT, int);
+void free_content(CT);
+void free_ctinfo(CT);
+void free_encoding(CT, int);
/*
** prototypes
*/
-CT build_mime (char *);
+CT build_mime(char *);
/*
** static prototypes
*/
-static int init_decoded_content (CT);
-static char *fgetstr (char *, int, FILE *);
-static int user_content (FILE *, char *, char *, CT *);
-static void set_id (CT, int);
-static int compose_content (CT);
-static int scan_content (CT);
-static int build_headers (CT);
-static char *calculate_digest (CT, int);
+static int init_decoded_content(CT);
+static char *fgetstr(char *, int, FILE *);
+static int user_content(FILE *, char *, char *, CT *);
+static void set_id(CT, int);
+static int compose_content(CT);
+static int scan_content(CT);
+static int build_headers(CT);
+static char *calculate_digest(CT, int);
/*
*/
CT
-build_mime (char *infile)
+build_mime(char *infile)
{
int compnum, state;
char buf[BUFSIZ], name[NAMESZ];
CT ct;
FILE *in;
- umask (~m_gmprot ());
+ umask(~m_gmprot());
/* open the composition draft */
- if ((in = fopen (infile, "r")) == NULL)
- adios (infile, "unable to open for reading");
+ if ((in = fopen(infile, "r")) == NULL)
+ adios(infile, "unable to open for reading");
/*
** Allocate space for primary (outside) content
*/
- if ((ct = (CT) calloc (1, sizeof(*ct))) == NULL)
- adios (NULL, "out of memory");
+ 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.
*/
- init_decoded_content (ct);
+ init_decoded_content(ct);
/*
** Parse some of the header fields in the composition
** the new MIME message.
*/
for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+ switch (state = m_getfld(state, name, buf, sizeof(buf), in)) {
case FLD:
case FLDPLUS:
case FLDEOF:
compnum++;
/* abort if draft has Mime-Version header field */
- if (!mh_strcasecmp (name, VRSN_FIELD))
- adios (NULL, "draft shouldn't contain %s: field", VRSN_FIELD);
+ 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
*/
- if (!mh_strcasecmp (name, ENCODING_FIELD))
- adios (NULL, "draft shouldn't contain %s: field", ENCODING_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)) {
+ if (!mh_strcasecmp(name, TYPE_FIELD)) {
while (state == FLDPLUS)
- state = m_getfld (state, name, buf,
+ state = m_getfld(state, name, buf,
sizeof(buf), in);
goto finish_field;
}
/* get copies of the buffers */
- np = add (name, NULL);
- vp = add (buf, NULL);
+ np = add(name, NULL);
+ vp = add(buf, NULL);
/* if necessary, get rest of field */
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
- vp = add (buf, vp); /* add to prev value */
+ state = m_getfld(state, name, buf,
+ sizeof(buf), in);
+ vp = add(buf, vp); /* add to prev value */
}
/* Now add the header data to the list */
- add_header (ct, np, vp);
+ add_header(ct, np, vp);
finish_field:
/* if this wasn't the last hdr field, then continue */
/* else fall... */
case FILEEOF:
- adios (NULL, "draft has empty body -- no directives!");
+ adios(NULL, "draft has empty body -- no directives!");
/* NOTREACHED */
case BODY:
case BODYEOF:
- fseek (in, (long) (-strlen (buf)), SEEK_CUR);
+ fseek(in, (long) (-strlen(buf)), SEEK_CUR);
break;
case LENERR:
case FMTERR:
- adios (NULL, "message format error in component #%d",
+ adios(NULL, "message format error in component #%d",
compnum);
default:
- adios (NULL, "getfld() returned %d", state);
+ adios(NULL, "getfld() returned %d", state);
}
break;
}
** 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);
+ 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.
*/
- if (get_ctinfo ("multipart/mixed", ct, 0) == NOTOK)
- done (1);
+ if (get_ctinfo("multipart/mixed", ct, 0) == NOTOK)
+ done(1);
ct->c_type = CT_MULTIPART;
ct->c_subtype = MULTI_MIXED;
- ct->c_file = add (infile, NULL);
+ ct->c_file = add(infile, NULL);
- if ((m = (struct multipart *) calloc (1, sizeof(*m))) == NULL)
- adios (NULL, "out of memory");
+ if ((m = (struct multipart *) calloc(1, sizeof(*m))) == NULL)
+ adios(NULL, "out of memory");
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
** read and parse the composition file
** and the directives it contains.
*/
- while (fgetstr (buf, sizeof(buf) - 1, in)) {
+ while (fgetstr(buf, sizeof(buf) - 1, in)) {
struct part *part;
CT p;
- if (user_content (in, infile, buf, &p) == DONE) {
- admonish (NULL, "ignoring spurious #end");
+ if (user_content(in, infile, buf, &p) == DONE) {
+ admonish(NULL, "ignoring spurious #end");
continue;
}
if (!p)
continue;
- if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
- adios (NULL, "out of memory");
+ if ((part = (struct part *) calloc(1, sizeof(*part))) == NULL)
+ adios(NULL, "out of memory");
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
** close the composition draft since
** it's not needed any longer.
*/
- fclose (in);
+ fclose(in);
/* check if any contents were found */
if (!m->mp_parts)
- adios (NULL, "no content directives found");
+ adios(NULL, "no content directives found");
/*
** If only one content was found, then remove and
ct->c_first_hf = NULL;
ct->c_last_hf = NULL;
- free_content (ct);
+ free_content(ct);
ct = p;
} else {
- set_id (ct, 1);
+ set_id(ct, 1);
}
/*
** Fill out, or expand directives. Parse and execute
** commands specified by profile composition strings.
*/
- compose_content (ct);
+ compose_content(ct);
if ((cp = strchr(prefix, 'a')) == NULL)
- adios (NULL, "internal error(4)");
+ 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.
*/
- while (scan_content (ct) == NOTOK) {
+ while (scan_content(ct) == NOTOK) {
if (*cp < 'z') {
(*cp)++;
} else {
if (*++cp == 0)
- adios (NULL, "giving up trying to find a unique delimiter string");
+ adios(NULL, "giving up trying to find a unique delimiter string");
else
(*cp)++;
}
}
/* Build the rest of the header field structures */
- build_headers (ct);
+ build_headers(ct);
return ct;
}
*/
static int
-init_decoded_content (CT ct)
+init_decoded_content(CT ct)
{
CE ce;
- if ((ce = (CE) calloc (1, sizeof(*ce))) == NULL)
- adios (NULL, "out of memory");
+ if ((ce = (CE) calloc(1, sizeof(*ce))) == NULL)
+ adios(NULL, "out of memory");
ct->c_cefile = ce;
ct->c_ceopenfnx = open7Bit; /* since unencoded */
static char *
-fgetstr (char *s, int n, FILE *stream)
+fgetstr(char *s, int n, FILE *stream)
{
char *cp, *ep;
for (ep = (cp = s) + n; cp < ep; ) {
int i;
- if (!fgets (cp, n, stream))
+ if (!fgets(cp, n, stream))
return (cp != s ? s : NULL);
if (cp == s && *cp != '#')
return s;
- cp += (i = strlen (cp)) - 1;
+ cp += (i = strlen(cp)) - 1;
if (i <= 1 || *cp-- != '\n' || *cp != '\\')
break;
*cp = '\0';
*/
static int
-user_content (FILE *in, char *file, char *buf, CT *ctp)
+user_content(FILE *in, char *file, char *buf, CT *ctp)
{
int extrnal, vrsn;
unsigned char *cp;
CT ct;
CE ce;
- if (buf[0] == '\n' || strcmp (buf, "#\n") == 0) {
+ if (buf[0] == '\n' || strcmp(buf, "#\n") == 0) {
*ctp = NULL;
return OK;
}
/* allocate basic Content structure */
- if ((ct = (CT) calloc (1, sizeof(*ct))) == NULL)
- adios (NULL, "out of memory");
+ if ((ct = (CT) calloc(1, sizeof(*ct))) == NULL)
+ adios(NULL, "out of memory");
*ctp = ct;
/* allocate basic structure for handling decoded content */
- init_decoded_content (ct);
+ init_decoded_content(ct);
ce = ct->c_cefile;
ci = &ct->c_ctinfo;
- set_id (ct, 0);
+ set_id(ct, 0);
/*
** Handle inline text. Check if line
adios("mhbuildsbr", "unable to create temporary file");
/* use a temp file to collect the plain text lines */
- ce->ce_file = add (cp, NULL);
+ ce->ce_file = add(cp, NULL);
ce->ce_unlink = 1;
if (buf[0] == '#' && buf[1] == '<') {
- strncpy (content, buf + 2, sizeof(content));
+ strncpy(content, buf + 2, sizeof(content));
inlineD = 1;
goto rock_and_roll;
} else {
}
/* the directive is implicit */
- strncpy (content, "text/plain", sizeof(content));
+ strncpy(content, "text/plain", sizeof(content));
headers = 0;
- strncpy (buffer, buf[0] != '#' ? buf : buf + 1, sizeof(buffer));
+ strncpy(buffer, buf[0] != '#' ? buf : buf + 1, sizeof(buffer));
for (;;) {
int i;
- if (headers >= 0 && uprf (buffer, DESCR_FIELD)
- && buffer[i = strlen (DESCR_FIELD)] == ':') {
+ if (headers >= 0 && uprf(buffer, DESCR_FIELD) &&
+ buffer[i=strlen(DESCR_FIELD)] == ':') {
headers = 1;
again_descr:
- ct->c_descr = add (buffer + i + 1, ct->c_descr);
- if (!fgetstr (buffer, sizeof(buffer) - 1, in))
- adios (NULL, "end-of-file after %s: field in plaintext", DESCR_FIELD);
+ ct->c_descr = add(buffer + i + 1, ct->c_descr);
+ if (!fgetstr(buffer, sizeof(buffer) - 1, in))
+ adios(NULL, "end-of-file after %s: field in plaintext", DESCR_FIELD);
switch (buffer[0]) {
case ' ':
case '\t':
goto again_descr;
case '#':
- adios (NULL, "#-directive after %s: field in plaintext", DESCR_FIELD);
+ adios(NULL, "#-directive after %s: field in plaintext", DESCR_FIELD);
/* NOTREACHED */
default:
}
}
- if (headers >= 0 && uprf (buffer, DISPO_FIELD)
- && buffer[i = strlen (DISPO_FIELD)] == ':') {
+ if (headers >= 0 && uprf(buffer, DISPO_FIELD)
+ && buffer[i = strlen(DISPO_FIELD)] == ':') {
headers = 1;
again_dispo:
- ct->c_dispo = add (buffer + i + 1, ct->c_dispo);
- if (!fgetstr (buffer, sizeof(buffer) - 1, in))
- adios (NULL, "end-of-file after %s: field in plaintext", DISPO_FIELD);
+ ct->c_dispo = add(buffer + i + 1, ct->c_dispo);
+ if (!fgetstr(buffer, sizeof(buffer) - 1, in))
+ adios(NULL, "end-of-file after %s: field in plaintext", DISPO_FIELD);
switch (buffer[0]) {
case ' ':
case '\t':
goto again_dispo;
case '#':
- adios (NULL, "#-directive after %s: field in plaintext", DISPO_FIELD);
+ adios(NULL, "#-directive after %s: field in plaintext", DISPO_FIELD);
/* NOTREACHED */
default:
}
if (headers != 1 || buffer[0] != '\n')
- fputs (buffer, out);
+ fputs(buffer, out);
rock_and_roll:
headers = -1;
- pos = ftell (in);
- if ((cp = fgetstr (buffer, sizeof(buffer) - 1, in)) == NULL)
+ pos = ftell(in);
+ if ((cp = fgetstr(buffer, sizeof(buffer) - 1, in))
+ == NULL)
break;
if (buffer[0] == '#') {
char *bp;
}
if (listsw)
- ct->c_end = ftell (out);
- fclose (out);
+ ct->c_end = ftell(out);
+ fclose(out);
/* parse content type */
- if (get_ctinfo (content, ct, inlineD) == NOTOK)
- done (1);
+ if (get_ctinfo(content, ct, inlineD) == NOTOK)
+ done(1);
for (s2i = str2cts; s2i->si_key; s2i++)
- if (!mh_strcasecmp (ci->ci_type, s2i->si_key))
+ if (!mh_strcasecmp(ci->ci_type, s2i->si_key))
break;
- if (!s2i->si_key && !uprf (ci->ci_type, "X-"))
+ if (!s2i->si_key && !uprf(ci->ci_type, "X-"))
s2i++;
/*
*/
switch (ct->c_type = s2i->si_val) {
case CT_MESSAGE:
- if (!mh_strcasecmp (ci->ci_subtype, "rfc822")) {
+ if (!mh_strcasecmp(ci->ci_subtype, "rfc822")) {
ct->c_encoding = CE_7BIT;
goto call_init;
}
/* else fall... */
case CT_MULTIPART:
- adios (NULL, "it doesn't make sense to define an in-line %s content",
+ adios(NULL, "it doesn't make sense to define an in-line %s content",
ct->c_type == CT_MESSAGE ? "message" :
"multipart");
/* NOTREACHED */
}
if (cp)
- fseek (in, pos, SEEK_SET);
+ fseek(in, pos, SEEK_SET);
return OK;
}
extrnal = (buf[1] == '@');
/* parse directive */
- if (get_ctinfo (buf + (extrnal ? 2 : 1), ct, 1) == NOTOK)
- done (1);
+ if (get_ctinfo(buf + (extrnal ? 2 : 1), ct, 1) == NOTOK)
+ done(1);
/* check directive against the list of MIME types */
for (s2i = str2cts; s2i->si_key; s2i++)
- if (!mh_strcasecmp (ci->ci_type, s2i->si_key))
+ if (!mh_strcasecmp(ci->ci_type, s2i->si_key))
break;
/*
*/
if (s2i->si_key) {
if (!ci->ci_subtype)
- adios (NULL, "missing subtype in \"#%s\"", ci->ci_type);
+ adios(NULL, "missing subtype in \"#%s\"", ci->ci_type);
switch (ct->c_type = s2i->si_val) {
case CT_MULTIPART:
- adios (NULL, "use \"#begin ... #end\" instead of \"#%s/%s\"",
- ci->ci_type, ci->ci_subtype);
+ adios(NULL, "use \"#begin ... #end\" instead of \"#%s/%s\"", ci->ci_type, ci->ci_subtype);
/* NOTREACHED */
case CT_MESSAGE:
- if (!mh_strcasecmp (ci->ci_subtype, "partial"))
- adios (NULL, "sorry, \"#%s/%s\" isn't supported",
- ci->ci_type, ci->ci_subtype);
- if (!mh_strcasecmp (ci->ci_subtype, "external-body"))
- adios (NULL, "use \"#@type/subtype ... [] ...\" instead of \"#%s/%s\"",
- ci->ci_type, ci->ci_subtype);
+ if (!mh_strcasecmp(ci->ci_subtype, "partial"))
+ adios(NULL, "sorry, \"#%s/%s\" isn't supported", ci->ci_type, ci->ci_subtype);
+ if (!mh_strcasecmp(ci->ci_subtype, "external-body"))
+ adios(NULL, "use \"#@type/subtype ... [] ...\" instead of \"#%s/%s\"", ci->ci_type, ci->ci_subtype);
use_forw:
- adios (NULL,
- "use \"#forw [+folder] [msgs]\" instead of \"#%s/%s\"",
- ci->ci_type, ci->ci_subtype);
+ adios(NULL, "use \"#forw [+folder] [msgs]\" instead of \"#%s/%s\"", ci->ci_type, ci->ci_subtype);
/* NOTREACHED */
default:
CT p;
if (!ci->ci_magic)
- adios (NULL, "need external information for \"#@%s/%s\"",
- ci->ci_type, ci->ci_subtype);
+ adios(NULL, "need external information for \"#@%s/%s\"", ci->ci_type, ci->ci_subtype);
p = ct;
- snprintf (buffer, sizeof(buffer), "message/external-body; %s", ci->ci_magic);
- free (ci->ci_magic);
+ snprintf(buffer, sizeof(buffer), "message/external-body; %s", ci->ci_magic);
+ free(ci->ci_magic);
ci->ci_magic = NULL;
/*
** structure for the message/external-body to wrap
** it in.
*/
- if ((ct = (CT) calloc (1, sizeof(*ct))) == NULL)
- adios (NULL, "out of memory");
+ if ((ct = (CT) calloc(1, sizeof(*ct))) == NULL)
+ adios(NULL, "out of memory");
*ctp = ct;
ci = &ct->c_ctinfo;
- if (get_ctinfo (buffer, ct, 0) == NOTOK)
- done (1);
+ if (get_ctinfo(buffer, ct, 0) == NOTOK)
+ done(1);
ct->c_type = CT_MESSAGE;
ct->c_subtype = MESSAGE_EXTERNAL;
- if ((e = (struct exbody *) calloc (1, sizeof(*e))) == NULL)
- adios (NULL, "out of memory");
+ if ((e = (struct exbody *)
+ calloc(1, sizeof(*e))) == NULL)
+ adios(NULL, "out of memory");
ct->c_ctparams = (void *) e;
e->eb_parent = ct;
e->eb_content = p;
p->c_ctexbody = e;
- if (params_external (ct, 1) == NOTOK)
- done (1);
+ if (params_external(ct, 1) == NOTOK)
+ done(1);
return OK;
}
if (ci->ci_magic) {
/* check if specifies command to execute */
if (*ci->ci_magic == '|' || *ci->ci_magic == '!') {
- for (cp = ci->ci_magic + 1; isspace (*cp); cp++)
+ for (cp = ci->ci_magic + 1; isspace(*cp); cp++)
continue;
if (!*cp)
- adios (NULL, "empty pipe command for #%s directive", ci->ci_type);
- cp = add (cp, NULL);
- free (ci->ci_magic);
+ adios(NULL, "empty pipe command for #%s directive", ci->ci_type);
+ cp = add(cp, NULL);
+ free(ci->ci_magic);
ci->ci_magic = cp;
} else {
/* record filename of decoded contents */
ce->ce_file = ci->ci_magic;
- if (access (ce->ce_file, R_OK) == NOTOK)
- adios ("reading", "unable to access %s for", ce->ce_file);
- if (listsw && stat (ce->ce_file, &st) != NOTOK)
+ if (access(ce->ce_file, R_OK) == NOTOK)
+ adios("reading", "unable to access %s for", ce->ce_file);
+ if (listsw && stat(ce->ce_file, &st) != NOTOK)
ct->c_end = (long) st.st_size;
ci->ci_magic = NULL;
}
** No [file] argument, so check profile for
** method to compose content.
*/
- snprintf (buffer, sizeof(buffer), "%s-compose-%s/%s",
+ 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",
+ if ((cp = context_find(buffer)) == NULL || *cp == '\0') {
+ snprintf(buffer, sizeof(buffer), "%s-compose-%s",
invo_name, ci->ci_type);
- if ((cp = context_find (buffer)) == NULL || *cp == '\0') {
- content_error (NULL, ct, "don't know how to compose content");
- done (1);
+ if ((cp = context_find(buffer)) == NULL ||
+ *cp == '\0') {
+ content_error(NULL, ct, "don't know how to compose content");
+ done(1);
}
}
- ci->ci_magic = add (cp, NULL);
+ ci->ci_magic = add(cp, NULL);
return OK;
}
if (extrnal)
- adios (NULL, "external definition not allowed for \"#%s\"",
+ adios(NULL, "external definition not allowed for \"#%s\"",
ci->ci_type);
/*
** Message directive
** #forw [+folder] [msgs]
*/
- if (!mh_strcasecmp (ci->ci_type, "forw")) {
+ if (!mh_strcasecmp(ci->ci_type, "forw")) {
int msgnum;
char *folder, *arguments[MAXARGS];
struct msgs *mp;
if (ci->ci_magic) {
- ap = brkstring (ci->ci_magic, " ", "\n");
- copyip (ap, arguments, MAXARGS);
+ ap = brkstring(ci->ci_magic, " ", "\n");
+ copyip(ap, arguments, MAXARGS);
} else {
arguments[0] = "cur";
arguments[1] = NULL;
cp = *ap;
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder per #forw directive");
+ adios(NULL, "only one folder per #forw directive");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
}
}
/* else, use the current folder */
if (!folder)
- folder = add (getfolder (1), NULL);
+ folder = add(getfolder(1), NULL);
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
for (ap = arguments; *ap; ap++) {
cp = *ap;
if (*cp != '+' && *cp != '@')
- if (!m_convert (mp, cp))
- done (1);
+ if (!m_convert(mp, cp))
+ done(1);
}
- free (folder);
- free_ctinfo (ct);
+ free(folder);
+ free_ctinfo(ct);
/*
** If there is more than one message to include, make this
*/
if (mp->numsel > 1) {
/* we are forwarding multiple messages */
- if (get_ctinfo ("multipart/digest", ct, 0) == NOTOK)
- done (1);
+ if (get_ctinfo("multipart/digest", ct, 0) == NOTOK)
+ done(1);
ct->c_type = CT_MULTIPART;
ct->c_subtype = MULTI_DIGEST;
- if ((m = (struct multipart *) calloc (1, sizeof(*m))) == NULL)
- adios (NULL, "out of memory");
+ if ((m = (struct multipart *)
+ calloc(1, sizeof(*m))) == NULL)
+ adios(NULL, "out of memory");
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
CT p;
CE pe;
- if ((p = (CT) calloc (1, sizeof(*p))) == NULL)
- adios (NULL, "out of memory");
- init_decoded_content (p);
+ if ((p = (CT) calloc(1, sizeof(*p)))
+ == NULL)
+ adios(NULL, "out of memory");
+ init_decoded_content(p);
pe = p->c_cefile;
- if (get_ctinfo ("message/rfc822", p, 0) == NOTOK)
- done (1);
+ if (get_ctinfo("message/rfc822", p, 0)
+ == NOTOK)
+ done(1);
p->c_type = CT_MESSAGE;
p->c_subtype = MESSAGE_RFC822;
- snprintf (buffer, sizeof(buffer), "%s/%d", mp->foldpath, msgnum);
- pe->ce_file = add (buffer, NULL);
- if (listsw && stat (pe->ce_file, &st) != NOTOK)
+ snprintf(buffer, sizeof(buffer),
+ "%s/%d", mp->foldpath,
+ msgnum);
+ pe->ce_file = add(buffer, NULL);
+ if (listsw && stat(pe->ce_file, &st)
+ != NOTOK)
p->c_end = (long) st.st_size;
- if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
- adios (NULL, "out of memory");
+ if ((part = (struct part *) calloc(1, sizeof(*part))) == NULL)
+ adios(NULL, "out of memory");
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
}
} else {
/* we are forwarding one message */
- if (get_ctinfo ("message/rfc822", ct, 0) == NOTOK)
- done (1);
+ if (get_ctinfo("message/rfc822", ct, 0) == NOTOK)
+ done(1);
ct->c_type = CT_MESSAGE;
ct->c_subtype = MESSAGE_RFC822;
msgnum = mp->lowsel;
- snprintf (buffer, sizeof(buffer), "%s/%d", mp->foldpath, msgnum);
- ce->ce_file = add (buffer, NULL);
- if (listsw && stat (ce->ce_file, &st) != NOTOK)
+ snprintf(buffer, sizeof(buffer), "%s/%d",
+ mp->foldpath, msgnum);
+ ce->ce_file = add(buffer, NULL);
+ if (listsw && stat(ce->ce_file, &st) != NOTOK)
ct->c_end = (long) st.st_size;
}
- folder_free (mp); /* free folder/message structure */
+ folder_free(mp); /* free folder/message structure */
return OK;
}
/*
** #end
*/
- if (!mh_strcasecmp (ci->ci_type, "end")) {
- free_content (ct);
+ if (!mh_strcasecmp(ci->ci_type, "end")) {
+ free_content(ct);
*ctp = NULL;
return DONE;
}
/*
** #begin [ alternative | parallel ]
*/
- if (!mh_strcasecmp (ci->ci_type, "begin")) {
+ if (!mh_strcasecmp(ci->ci_type, "begin")) {
if (!ci->ci_magic) {
vrsn = MULTI_MIXED;
cp = SubMultiPart[vrsn - 1].kv_key;
- } else if (!mh_strcasecmp (ci->ci_magic, "alternative")) {
+ } else if (!mh_strcasecmp(ci->ci_magic, "alternative")) {
vrsn = MULTI_ALTERNATE;
cp = SubMultiPart[vrsn - 1].kv_key;
- } else if (!mh_strcasecmp (ci->ci_magic, "parallel")) {
+ } else if (!mh_strcasecmp(ci->ci_magic, "parallel")) {
vrsn = MULTI_PARALLEL;
cp = SubMultiPart[vrsn - 1].kv_key;
- } else if (uprf (ci->ci_magic, "digest")) {
+ } else if (uprf(ci->ci_magic, "digest")) {
goto use_forw;
} else {
vrsn = MULTI_UNKNOWN;
cp = ci->ci_magic;
}
- free_ctinfo (ct);
- snprintf (buffer, sizeof(buffer), "multipart/%s", cp);
- if (get_ctinfo (buffer, ct, 0) == NOTOK)
- done (1);
+ free_ctinfo(ct);
+ snprintf(buffer, sizeof(buffer), "multipart/%s", cp);
+ if (get_ctinfo(buffer, ct, 0) == NOTOK)
+ done(1);
ct->c_type = CT_MULTIPART;
ct->c_subtype = vrsn;
- if ((m = (struct multipart *) calloc (1, sizeof(*m))) == NULL)
- adios (NULL, "out of memory");
+ if ((m = (struct multipart *) calloc(1, sizeof(*m))) == NULL)
+ adios(NULL, "out of memory");
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
- while (fgetstr (buffer, sizeof(buffer) - 1, in)) {
+ while (fgetstr(buffer, sizeof(buffer) - 1, in)) {
struct part *part;
CT p;
- if (user_content (in, file, buffer, &p) == DONE) {
+ if (user_content(in, file, buffer, &p) == DONE) {
if (!m->mp_parts)
- adios (NULL, "empty \"#begin ... #end\" sequence");
+ adios(NULL, "empty \"#begin ... #end\" sequence");
return OK;
}
if (!p)
continue;
- if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
- adios (NULL, "out of memory");
+ if ((part = (struct part *)
+ calloc(1, sizeof(*part))) == NULL)
+ adios(NULL, "out of memory");
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
}
- admonish (NULL, "premature end-of-file, missing #end");
+ admonish(NULL, "premature end-of-file, missing #end");
return OK;
}
/*
** Unknown directive
*/
- adios (NULL, "unknown directive \"#%s\"", ci->ci_type);
+ adios(NULL, "unknown directive \"#%s\"", ci->ci_type);
return NOTOK; /* NOT REACHED */
}
static void
-set_id (CT ct, int top)
+set_id(CT ct, int top)
{
char msgid[BUFSIZ];
static int partno;
static char *msgfmt;
if (clock == 0) {
- time (&clock);
- snprintf (msgid, sizeof(msgid), "<%d.%ld.%%d@%s>\n",
+ time(&clock);
+ snprintf(msgid, sizeof(msgid), "<%d.%ld.%%d@%s>\n",
(int) getpid(), (long) clock, LocalName());
partno = 0;
msgfmt = getcpy(msgid);
}
- snprintf (msgid, sizeof(msgid), msgfmt, top ? 0 : ++partno);
- ct->c_id = getcpy (msgid);
+ snprintf(msgid, sizeof(msgid), msgfmt, top ? 0 : ++partno);
+ ct->c_id = getcpy(msgid);
}
*/
static int
-compose_content (CT ct)
+compose_content(CT ct)
{
CE ce = ct->c_cefile;
struct part *part;
if (ct->c_partno) {
- snprintf (partnam, sizeof(partnam), "%s.", ct->c_partno);
- pp = partnam + strlen (partnam);
+ snprintf(partnam, sizeof(partnam), "%s.",
+ ct->c_partno);
+ pp = partnam + strlen(partnam);
} else {
pp = partnam;
}
part = part->mp_next, partnum++) {
CT p = part->mp_part;
- sprintf (pp, "%d", partnum);
- p->c_partno = add (partnam, NULL);
- if (compose_content (p) == NOTOK)
+ sprintf(pp, "%d", partnum);
+ p->c_partno = add(partnam, NULL);
+ if (compose_content(p) == NOTOK)
return NOTOK;
}
}
if (listsw) {
- ct->c_end = (partnum = strlen (prefix) + 2) + 2;
+ ct->c_end = (partnum = strlen(prefix) + 2) + 2;
if (ct->c_rfc934)
ct->c_end += 1;
char *tfile = NULL;
if (!(cp = ci->ci_magic))
- adios (NULL, "internal error(5)");
+ adios(NULL, "internal error(5)");
tfile = m_mktemp2(NULL, invo_name, NULL, NULL);
if (tfile == NULL) {
adios("mhbuildsbr", "unable to create temporary file");
}
- ce->ce_file = add (tfile, NULL);
+ ce->ce_file = add(tfile, NULL);
ce->ce_unlink = 1;
xstdout = 0;
char *s = "";
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
- snprintf (bp, buflen, "%s%s=\"%s\"", s, *ap, *ep);
- len = strlen (bp);
+ snprintf(bp, buflen, "%s%s=\"%s\"", s, *ap, *ep);
+ len = strlen(bp);
bp += len;
buflen -= len;
s = " ";
** where content should be
** written
*/
- snprintf (bp, buflen, "%s", ce->ce_file);
+ snprintf(bp, buflen, "%s", ce->ce_file);
break;
case 's':
/* insert content subtype */
- strncpy (bp, ci->ci_subtype, buflen);
+ strncpy(bp, ci->ci_subtype, buflen);
break;
case '%':
buflen--;
continue;
}
- len = strlen (bp);
+ len = strlen(bp);
bp += len;
buflen -= len;
} else {
}
if (verbosw)
- printf ("composing content %s/%s from command\n\t%s\n",
- ci->ci_type, ci->ci_subtype, buffer);
+ printf("composing content %s/%s from command\n\t%s\n", ci->ci_type, ci->ci_subtype, buffer);
- fflush (stdout); /* not sure if need for -noverbose */
+ fflush(stdout); /* not sure if need for -noverbose */
vec[0] = "/bin/sh";
vec[1] = "-c";
vec[2] = buffer;
vec[3] = NULL;
- if ((out = fopen (ce->ce_file, "w")) == NULL)
- adios (ce->ce_file, "unable to open for writing");
+ if ((out = fopen(ce->ce_file, "w")) == NULL)
+ adios(ce->ce_file, "unable to open for writing");
for (i = 0; (child_id = vfork()) == NOTOK && i > 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case NOTOK:
- adios ("fork", "unable to fork");
+ adios("fork", "unable to fork");
/* NOTREACHED */
case OK:
if (!xstdout)
- dup2 (fileno (out), 1);
- close (fileno (out));
- execvp ("/bin/sh", vec);
- fprintf (stderr, "unable to exec ");
- perror ("/bin/sh");
- _exit (-1);
+ dup2(fileno(out), 1);
+ close(fileno(out));
+ execvp("/bin/sh", vec);
+ fprintf(stderr, "unable to exec ");
+ perror("/bin/sh");
+ _exit(-1);
/* NOTREACHED */
default:
- fclose (out);
+ fclose(out);
if (pidXwait(child_id, NULL))
- done (1);
+ done(1);
break;
}
}
if (listsw && ct->c_end == 0L) {
struct stat st;
- if (stat (ce->ce_file, &st) != NOTOK)
+ if (stat(ce->ce_file, &st) != NOTOK)
ct->c_end = (long) st.st_size;
}
break;
*/
static int
-scan_content (CT ct)
+scan_content(CT ct)
{
int len;
int check8bit = 0, contains8bit = 0; /* check if contains 8bit data */
for (part = m->mp_parts; part; part = part->mp_next) {
CT p = part->mp_part;
- if (scan_content (p) == NOTOK) /* choose encoding for subpart */
+ if (scan_content(p) == NOTOK) {
+ /* choose encoding for subpart */
return NOTOK;
+ }
/*
** if necessary, enlarge encoding for enclosing
*/
if (p->c_encoding == CE_BINARY)
ct->c_encoding = CE_BINARY;
- if (p->c_encoding == CE_8BIT && ct->c_encoding != CE_BINARY)
+ if (p->c_encoding == CE_8BIT &&
+ ct->c_encoding != CE_BINARY)
ct->c_encoding = CE_8BIT;
}
** 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");
- len = strlen (prefix);
+ if ((in = fopen(ce->ce_file, "r")) == NULL)
+ adios(ce->ce_file, "unable to open for reading");
+ len = strlen(prefix);
- while (fgets (buffer, sizeof(buffer) - 1, in)) {
+ while (fgets(buffer, sizeof(buffer) - 1, in)) {
/*
** Check for 8bit data.
*/
if (check8bit) {
for (cp = buffer; *cp; cp++) {
- if (!isascii (*cp)) {
+ if (!isascii(*cp)) {
contains8bit = 1;
/* no need to keep checking */
check8bit = 0;
/*
** Check line length.
*/
- if (checklinelen && (strlen (buffer) > CPERLIN + 1)) {
+ 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)) {
+ (cp = buffer + strlen(buffer) - 2) >
+ buffer && isspace(*cp)) {
linespace = 1;
/* no need to keep checking */
checklinespace = 0;
** 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))
+ if (checkboundary && buffer[0] == '-' &&
+ buffer[1] == '-') {
+ for (cp = buffer + strlen(buffer) - 1;
+ cp >= buffer; cp--)
+ if (!isspace(*cp))
break;
*++cp = '\0';
- if (!strncmp(buffer + 2, prefix, len) && isdigit(buffer[2 + len])) {
+ if (!strncmp(buffer + 2, prefix, len) &&
+ isdigit(buffer[2 + len])) {
boundaryclash = 1;
/* no need to keep checking */
checkboundary = 0;
}
}
}
- fclose (in);
+ fclose(in);
}
/*
if (contains8bit) {
t->tx_charset = CHARSET_UNKNOWN;
- *ap = concat ("charset=", write_charset_8bit(), NULL);
+ *ap = concat("charset=", write_charset_8bit(),
+ NULL);
} else {
t->tx_charset = CHARSET_USASCII;
- *ap = add ("charset=us-ascii", NULL);
+ *ap = add("charset=us-ascii", NULL);
}
cp = strchr(*ap++, '=');
*ep = cp;
}
- if (contains8bit || ebcdicunsafe || linelen || linespace || checksw)
+ if (contains8bit || ebcdicunsafe || linelen || linespace ||
+ checksw)
ct->c_encoding = CE_QUOTED;
else
ct->c_encoding = CE_7BIT;
case CT_APPLICATION:
/* For application type, use base64, except when postscript */
- if (contains8bit || ebcdicunsafe || linelen || linespace || checksw)
- ct->c_encoding = (ct->c_subtype == APPLICATION_POSTSCRIPT)
- ? CE_QUOTED : CE_BASE64;
+ if (contains8bit || ebcdicunsafe || linelen || linespace ||
+ checksw)
+ ct->c_encoding = (ct->c_subtype ==
+ APPLICATION_POSTSCRIPT) ?
+ CE_QUOTED : CE_BASE64;
else
ct->c_encoding = CE_7BIT;
break;
*/
static int
-build_headers (CT ct)
+build_headers(CT ct)
{
int cc, mailbody, len;
char **ap, **ep;
ap = ci->ci_attrs;
ep = ci->ci_values;
- snprintf (buffer, sizeof(buffer), "boundary=%s%d", prefix, level++);
- cp = strchr(*ap++ = add (buffer, NULL), '=');
+ snprintf(buffer, sizeof(buffer), "boundary=%s%d",
+ prefix, level++);
+ cp = strchr(*ap++ = add(buffer, NULL), '=');
*ap = NULL;
*cp++ = '\0';
*ep = cp;
/*
** output the content type and subtype
*/
- np = add (TYPE_FIELD, NULL);
- vp = concat (" ", ci->ci_type, "/", ci->ci_subtype, NULL);
+ np = add(TYPE_FIELD, NULL);
+ vp = concat(" ", ci->ci_type, "/", ci->ci_subtype, NULL);
/* keep track of length of line */
- len = strlen (TYPE_FIELD) + strlen (ci->ci_type)
- + strlen (ci->ci_subtype) + 3;
+ len = strlen(TYPE_FIELD) + strlen(ci->ci_type) +
+ strlen(ci->ci_subtype) + 3;
- mailbody = ct->c_type == CT_MESSAGE
- && ct->c_subtype == MESSAGE_EXTERNAL
- && ((struct exbody *) ct->c_ctparams)->eb_body;
+ mailbody = ct->c_type == CT_MESSAGE &&
+ ct->c_subtype == MESSAGE_EXTERNAL &&
+ ((struct exbody *) ct->c_ctparams)->eb_body;
/*
** 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"))
+ if (mailbody && !mh_strcasecmp(*ap, "body"))
continue;
- vp = add (";", vp);
+ vp = add(";", vp);
len++;
- snprintf (buffer, sizeof(buffer), "%s=\"%s\"", *ap, *ep);
- if (len + 1 + (cc = strlen (buffer)) >= CPERLIN) {
- vp = add ("\n\t", vp);
+ snprintf(buffer, sizeof(buffer), "%s=\"%s\"", *ap, *ep);
+ if (len + 1 + (cc = strlen(buffer)) >= CPERLIN) {
+ vp = add("\n\t", vp);
len = 8;
} else {
- vp = add (" ", vp);
+ vp = add(" ", vp);
len++;
}
- vp = add (buffer, vp);
+ vp = add(buffer, vp);
len += cc;
}
** 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) {
- vp = add ("\n\t", vp);
+ snprintf(buffer, sizeof(buffer), "(%s)", ci->ci_comment);
+ if (len + 1 + (cc = 2 + strlen(ci->ci_comment)) >= CPERLIN) {
+ vp = add("\n\t", vp);
len = 8;
} else {
- vp = add (" ", vp);
+ vp = add(" ", vp);
len++;
}
- vp = add (buffer, vp);
+ vp = add(buffer, vp);
len += cc;
}
- vp = add ("\n", vp);
- add_header (ct, np, vp);
+ vp = add("\n", vp);
+ add_header(ct, np, vp);
/*
** output the Content-ID, unless disabled by -nocontentid
*/
if (contentidsw && ct->c_id) {
- np = add (ID_FIELD, NULL);
- vp = concat (" ", ct->c_id, NULL);
- add_header (ct, np, vp);
+ np = add(ID_FIELD, NULL);
+ vp = concat(" ", ct->c_id, NULL);
+ add_header(ct, np, vp);
}
/*
** output the Content-Description
*/
if (ct->c_descr) {
- np = add (DESCR_FIELD, NULL);
- vp = concat (" ", ct->c_descr, NULL);
- add_header (ct, np, vp);
+ np = add(DESCR_FIELD, NULL);
+ vp = concat(" ", ct->c_descr, NULL);
+ add_header(ct, np, vp);
}
/*
** output the Content-Disposition
*/
if (ct->c_dispo) {
- np = add (DISPO_FIELD, NULL);
- vp = concat (" ", ct->c_dispo, NULL);
- add_header (ct, np, vp);
+ np = add(DISPO_FIELD, NULL);
+ vp = concat(" ", ct->c_dispo, NULL);
+ add_header(ct, np, vp);
}
skip_headers:
** output the Content-MD5
*/
if (checksw) {
- np = add (MD5_FIELD, NULL);
- vp = calculate_digest (ct, (ct->c_encoding == CE_QUOTED) ? 1 : 0);
- add_header (ct, np, vp);
+ np = add(MD5_FIELD, NULL);
+ vp = calculate_digest(ct, (ct->c_encoding == CE_QUOTED) ?
+ 1 : 0);
+ add_header(ct, np, vp);
}
/*
case CE_7BIT:
/* Nothing to output */
#if 0
- np = add (ENCODING_FIELD, NULL);
- vp = concat (" ", "7bit", "\n", NULL);
- add_header (ct, np, vp);
+ np = add(ENCODING_FIELD, NULL);
+ vp = concat(" ", "7bit", "\n", NULL);
+ add_header(ct, np, vp);
#endif
break;
case CE_8BIT:
if (ct->c_type == CT_MESSAGE)
- adios (NULL, "internal error, invalid encoding");
+ adios(NULL, "internal error, invalid encoding");
- np = add (ENCODING_FIELD, NULL);
- vp = concat (" ", "8bit", "\n", NULL);
- add_header (ct, np, vp);
+ np = add(ENCODING_FIELD, NULL);
+ vp = concat(" ", "8bit", "\n", NULL);
+ add_header(ct, np, vp);
break;
case CE_QUOTED:
if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
- adios (NULL, "internal error, invalid encoding");
+ adios(NULL, "internal error, invalid encoding");
- np = add (ENCODING_FIELD, NULL);
- vp = concat (" ", "quoted-printable", "\n", NULL);
- add_header (ct, np, vp);
+ np = add(ENCODING_FIELD, NULL);
+ vp = concat(" ", "quoted-printable", "\n", NULL);
+ add_header(ct, np, vp);
break;
case CE_BASE64:
if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
- adios (NULL, "internal error, invalid encoding");
+ adios(NULL, "internal error, invalid encoding");
- np = add (ENCODING_FIELD, NULL);
- vp = concat (" ", "base64", "\n", NULL);
- add_header (ct, np, vp);
+ np = add(ENCODING_FIELD, NULL);
+ vp = concat(" ", "base64", "\n", NULL);
+ add_header(ct, np, vp);
break;
case CE_BINARY:
if (ct->c_type == CT_MESSAGE)
- adios (NULL, "internal error, invalid encoding");
+ adios(NULL, "internal error, invalid encoding");
- np = add (ENCODING_FIELD, NULL);
- vp = concat (" ", "binary", "\n", NULL);
- add_header (ct, np, vp);
+ np = add(ENCODING_FIELD, NULL);
+ vp = concat(" ", "binary", "\n", NULL);
+ add_header(ct, np, vp);
break;
default:
- adios (NULL, "unknown transfer encoding in content");
+ adios(NULL, "unknown transfer encoding in content");
break;
}
CT p;
p = part->mp_part;
- build_headers (p);
+ build_headers(p);
}
}
break;
struct exbody *e;
e = (struct exbody *) ct->c_ctparams;
- build_headers (e->eb_content);
+ build_headers(e->eb_content);
}
break;
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static char *
-calculate_digest (CT ct, int asciiP)
+calculate_digest(CT ct, int asciiP)
{
int cc;
char buffer[BUFSIZ], *vp, *op;
CE ce = ct->c_cefile;
/* open content */
- if ((in = fopen (ce->ce_file, "r")) == NULL)
- adios (ce->ce_file, "unable to open for reading");
+ if ((in = fopen(ce->ce_file, "r")) == NULL)
+ adios(ce->ce_file, "unable to open for reading");
/* Initialize md5 context */
- MD5Init (&mdContext);
+ MD5Init(&mdContext);
/* calculate md5 message digest */
if (asciiP) {
- while (fgets (buffer, sizeof(buffer) - 1, in)) {
+ while (fgets(buffer, sizeof(buffer) - 1, in)) {
char c, *cp;
- cp = buffer + strlen (buffer) - 1;
+ cp = buffer + strlen(buffer) - 1;
if ((c = *cp) == '\n')
*cp = '\0';
- MD5Update (&mdContext, (unsigned char *) buffer,
- (unsigned int) strlen (buffer));
+ MD5Update(&mdContext, (unsigned char *) buffer,
+ (unsigned int) strlen(buffer));
if (c == '\n')
- MD5Update (&mdContext, (unsigned char *) "\r\n", 2);
+ MD5Update(&mdContext, (unsigned char *) "\r\n",
+ 2);
}
} else {
- while ((cc = fread (buffer, sizeof(*buffer), sizeof(buffer), in)) > 0)
- MD5Update (&mdContext, (unsigned char *) buffer,
+ while ((cc = fread(buffer, sizeof(*buffer), sizeof(buffer),
+ in)) > 0)
+ MD5Update(&mdContext, (unsigned char *) buffer,
(unsigned int) cc);
}
/* md5 finalization. Write digest and zero md5 context */
- MD5Final (digest, &mdContext);
+ MD5Final(digest, &mdContext);
/* close content */
- fclose (in);
+ fclose(in);
/* print debugging info */
if (debugsw) {
unsigned char *ep;
- fprintf (stderr, "MD5 digest=");
+ fprintf(stderr, "MD5 digest=");
for (ep = (dp = digest) + sizeof(digest) / sizeof(digest[0]);
dp < ep; dp++)
- fprintf (stderr, "%02x", *dp & 0xff);
- fprintf (stderr, "\n");
+ fprintf(stderr, "%02x", *dp & 0xff);
+ fprintf(stderr, "\n");
}
/* encode the digest using base64 */
outbuf[24] = '\0';
/* now make copy and return string */
- vp = concat (" ", outbuf, "\n", NULL);
+ vp = concat(" ", outbuf, "\n", NULL);
return vp;
}
int pidcheck (int);
/* mhmisc.c */
-int part_ok (CT, int);
-int type_ok (CT, int);
-int make_intermediates (char *);
-void content_error (char *, CT, char *, ...);
-void flush_errors (void);
+int part_ok(CT, int);
+int type_ok(CT, int);
+int make_intermediates(char *);
+void content_error(char *, CT, char *, ...);
+void flush_errors(void);
/*
** prototypes
*/
-void cache_all_messages (CT *);
-int find_cache (CT, int, int *, char *, char *, int);
+void cache_all_messages(CT *);
+int find_cache(CT, int, int *, char *, char *, int);
/*
** 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);
+static void cache_content(CT);
+static int find_cache_aux(int, char *, char *, char *, int);
+static int find_cache_aux2(char *, char *, char *, int);
/*
*/
void
-cache_all_messages (CT *cts)
+cache_all_messages(CT *cts)
{
CT ct, *ctp;
for (ctp = cts; *ctp; ctp++) {
ct = *ctp;
- if (type_ok (ct, 1)) {
- cache_content (ct);
+ if (type_ok(ct, 1)) {
+ cache_content(ct);
if (ct->c_fp) {
- fclose (ct->c_fp);
+ fclose(ct->c_fp);
ct->c_fp = NULL;
}
if (ct->c_ceclosefnx)
(*ct->c_ceclosefnx) (ct);
}
}
- flush_errors ();
+ flush_errors();
}
*/
static void
-cache_content (CT ct)
+cache_content(CT ct)
{
int cachetype;
char *file, cachefile[BUFSIZ];
CE ce = ct->c_cefile;
if (!ct->c_id) {
- advise (NULL, "no %s: field in %s", ID_FIELD, ct->c_file);
+ advise(NULL, "no %s: field in %s", ID_FIELD, ct->c_file);
return;
}
if (!ce) {
- advise (NULL, "unable to decode %s", ct->c_file);
+ advise(NULL, "unable to decode %s", ct->c_file);
return;
}
/* THIS NEEDS TO BE FIXED */
#if 0
if (ct->c_ceopenfnx == openMail) {
- advise (NULL, "a radish may no know Greek, but I do...");
+ advise(NULL, "a radish may no know Greek, but I do...");
return;
}
#endif
- if (find_cache (NULL, wcachesw != CACHE_NEVER ? wcachesw : CACHE_ASK,
+ if (find_cache(NULL, wcachesw != CACHE_NEVER ? wcachesw : CACHE_ASK,
&cachetype, ct->c_id, cachefile, sizeof(cachefile))
== NOTOK) {
- advise (NULL, "unable to cache %s's contents", ct->c_file);
+ advise(NULL, "unable to cache %s's contents", ct->c_file);
return;
}
if (wcachesw != CACHE_NEVER && wcachesw != CACHE_ASK) {
- fflush (stdout);
- fprintf (stderr, "caching message %s as file %s\n", ct->c_file,
- cachefile);
+ fflush(stdout);
+ fprintf(stderr, "caching message %s as file %s\n", ct->c_file,
+ cachefile);
}
if (ce->ce_file) {
- int mask = umask (cachetype ? ~m_gmprot () : 0222);
+ int mask = umask(cachetype ? ~m_gmprot() : 0222);
FILE *fp;
if (debugsw)
- fprintf (stderr, "caching by copying %s...\n",
+ fprintf(stderr, "caching by copying %s...\n",
ce->ce_file);
file = NULL;
if ((*ct->c_ceopenfnx) (ct, &file) == NOTOK)
goto reset_umask;
- if ((fp = fopen (cachefile, "w"))) {
+ if ((fp = fopen(cachefile, "w"))) {
int cc;
char buffer[BUFSIZ];
FILE *gp = ce->ce_fp;
- fseek (gp, 0L, SEEK_SET);
+ fseek(gp, 0L, SEEK_SET);
- while ((cc = fread (buffer, sizeof(*buffer),
+ while ((cc = fread(buffer, sizeof(*buffer),
sizeof(buffer), gp)) > 0)
- fwrite (buffer, sizeof(*buffer), cc, fp);
- fflush (fp);
+ fwrite(buffer, sizeof(*buffer), cc, fp);
+ fflush(fp);
- if (ferror (gp)) {
- admonish (ce->ce_file, "error reading");
- unlink (cachefile);
+ if (ferror(gp)) {
+ admonish(ce->ce_file, "error reading");
+ unlink(cachefile);
} else {
- if (ferror (fp)) {
- admonish (cachefile, "error writing");
- unlink (cachefile);
+ if (ferror(fp)) {
+ admonish(cachefile, "error writing");
+ unlink(cachefile);
}
}
- fclose (fp);
+ fclose(fp);
} else
- content_error (cachefile, ct,
+ content_error(cachefile, ct,
"unable to fopen for writing");
reset_umask:
- umask (mask);
+ umask(mask);
} else {
if (debugsw)
- fprintf (stderr, "in place caching...\n");
+ fprintf(stderr, "in place caching...\n");
file = cachefile;
if ((*ct->c_ceopenfnx) (ct, &file) != NOTOK)
- chmod (cachefile, cachetype ? m_gmprot () : 0444);
+ chmod(cachefile, cachetype ? m_gmprot() : 0444);
}
}
int
-find_cache (CT ct, int policy, int *writing, char *id,
- char *buffer, int buflen)
+find_cache(CT ct, int policy, int *writing, char *id, char *buffer, int buflen)
{
int status = NOTOK;
if (id == NULL)
return NOTOK;
- id = trimcpy (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:
case CACHE_ASK:
case CACHE_PUBLIC:
- if (cache_private && !writing
- && find_cache_aux (writing ? 2 : 0,
- cache_private, id, buffer, buflen) == OK) {
- if (access (buffer, R_OK) != NOTOK) {
+ if (cache_private && !writing &&
+ find_cache_aux(writing ? 2 : 0,
+ cache_private, id, buffer, buflen)
+ == OK) {
+ if (access(buffer, R_OK) != NOTOK) {
got_private:
if (writing)
*writing = 1;
break;
}
}
- if (cache_public && find_cache_aux (writing ? 1 : 0,
- cache_public, id, buffer, buflen) == OK) {
- if (writing || access (buffer, R_OK) != NOTOK) {
+ if (cache_public && find_cache_aux(writing ? 1 : 0,
+ cache_public, id, buffer, buflen)
+ == OK) {
+ if (writing || access(buffer, R_OK) != NOTOK) {
if (writing)
*writing = 0;
goto got_it;
break;
case CACHE_PRIVATE:
- if (cache_private && find_cache_aux (writing ? 2 : 0,
- cache_private, id, buffer, buflen) == OK) {
- if (writing || access (buffer, R_OK) != NOTOK)
+ if (cache_private && find_cache_aux(writing ? 2 : 0,
+ cache_private, id, buffer, buflen)
+ == OK) {
+ if (writing || access(buffer, R_OK) != NOTOK)
goto got_private;
}
break;
if (xpid) {
if (xpid < 0)
xpid = -xpid;
- pidcheck (pidwait (xpid, NOTOK));
+ pidcheck(pidwait(xpid, NOTOK));
xpid = 0;
}
/* Now, construct query */
if (writing) {
- snprintf (bp, buflen, "Make cached, publically-accessible copy");
+ snprintf(bp, buflen, "Make cached, publically-accessible copy");
} else {
struct stat st;
- snprintf (bp, buflen, "Use cached copy");
- len = strlen (bp);
+ snprintf(bp, buflen, "Use cached copy");
+ len = strlen(bp);
bp += len;
buflen -= len;
if (ct->c_partno) {
- snprintf (bp, buflen, " of content %s", ct->c_partno);
- len = strlen (bp);
+ snprintf(bp, buflen, " of content %s",
+ ct->c_partno);
+ len = strlen(bp);
bp += len;
buflen -= len;
}
- stat (buffer, &st);
- snprintf (bp, buflen, " (size %lu octets)",
+ stat(buffer, &st);
+ snprintf(bp, buflen, " (size %lu octets)",
(unsigned long) st.st_size);
}
- len = strlen (bp);
+ len = strlen(bp);
bp += len;
buflen -= len;
- snprintf (bp, buflen, "\n in file %s? ", buffer);
+ snprintf(bp, buflen, "\n in file %s? ", buffer);
/* Now, check answer */
- if (!getanswer (query))
+ if (!getanswer(query))
status = NOTOK;
}
if (status == OK && writing) {
if (*writing && strchr(buffer, '/'))
- make_intermediates (buffer);
- unlink (buffer);
+ make_intermediates(buffer);
+ unlink(buffer);
}
- free (id);
+ free(id);
return status;
}
static int
-find_cache_aux (int writing, char *directory, char *id,
- char *buffer, int buflen)
+find_cache_aux(int writing, char *directory, char *id, char *buffer,
+ int buflen)
{
int mask, usemap;
char mapfile[BUFSIZ], mapname[BUFSIZ];
static time_t clock = 0;
#ifdef BSD42
- usemap = strchr (id, '/') ? 1 : 0;
+ usemap = strchr(id, '/') ? 1 : 0;
#else
usemap = 1;
#endif
if (debugsw)
- fprintf (stderr, "find_cache_aux %s usemap=%d\n", directory, usemap);
+ fprintf(stderr, "find_cache_aux %s usemap=%d\n",
+ directory, usemap);
- snprintf (mapfile, sizeof(mapfile), "%s/cache.map", directory);
- if (find_cache_aux2 (mapfile, id, mapname, sizeof(mapname)) == OK)
+ snprintf(mapfile, sizeof(mapfile), "%s/cache.map", directory);
+ if (find_cache_aux2(mapfile, id, mapname, sizeof(mapname)) == OK)
goto done_map;
if (!writing) {
return NOTOK;
use_raw:
- snprintf (buffer, buflen, "%s/%s", directory, id);
+ snprintf(buffer, buflen, "%s/%s", directory, id);
return OK;
}
- if (!usemap && access (mapfile, W_OK) == NOTOK)
+ if (!usemap && access(mapfile, W_OK) == NOTOK)
goto use_raw;
if (clock != 0) {
time_t now;
- time (&now);
+ time(&now);
if (now > clock)
clock = 0;
} else {
- pid = getpid ();
+ pid = getpid();
}
if (clock == 0) {
- time (&clock);
+ time(&clock);
partno = 0;
} else {
if (partno > 0xff) {
}
}
- snprintf (mapname, sizeof(mapname), "%08x%04x%02x",
- (unsigned int) (clock & 0xffffffff),
- (unsigned int) (pid & 0xffff),
- (unsigned int) (partno++ & 0xff));
+ snprintf(mapname, sizeof(mapname), "%08x%04x%02x",
+ (unsigned int) (clock & 0xffffffff),
+ (unsigned int) (pid & 0xffff),
+ (unsigned int) (partno++ & 0xff));
if (debugsw)
- fprintf (stderr, "creating mapping %s->%s\n", mapname, id);
+ fprintf(stderr, "creating mapping %s->%s\n", mapname, id);
- make_intermediates (mapfile);
- mask = umask (writing == 2 ? 0077 : 0);
- if (!(fp = lkfopen (mapfile, "a")) && errno == ENOENT) {
+ make_intermediates(mapfile);
+ mask = umask(writing == 2 ? 0077 : 0);
+ if (!(fp = lkfopen(mapfile, "a")) && errno == ENOENT) {
int fd;
- if ((fd = creat (mapfile, 0666)) != NOTOK) {
- close (fd);
- fp = lkfopen (mapfile, "a");
+ if ((fd = creat(mapfile, 0666)) != NOTOK) {
+ close(fd);
+ fp = lkfopen(mapfile, "a");
}
}
- umask (mask);
+ umask(mask);
if (!fp)
return NOTOK;
- fprintf (fp, "%s: %s\n", mapname, id);
- lkfclose (fp, mapfile);
+ fprintf(fp, "%s: %s\n", mapname, id);
+ lkfclose(fp, mapfile);
done_map:
if (*mapname == '/')
- strncpy (buffer, mapname, buflen);
+ strncpy(buffer, mapname, buflen);
else
- snprintf (buffer, buflen, "%s/%s", directory, mapname);
+ snprintf(buffer, buflen, "%s/%s", directory, mapname);
if (debugsw)
- fprintf (stderr, "use %s\n", buffer);
+ fprintf(stderr, "use %s\n", buffer);
return OK;
}
static int
-find_cache_aux2 (char *mapfile, char *id, char *mapname, int namelen)
+find_cache_aux2(char *mapfile, char *id, char *mapname, int namelen)
{
int state;
char buf[BUFSIZ], name[NAMESZ];
FILE *fp;
- if (!(fp = lkfopen (mapfile, "r")))
+ if (!(fp = lkfopen(mapfile, "r")))
return NOTOK;
for (state = FLD;;) {
int result;
char *cp, *dp;
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ switch (state = m_getfld(state, name, buf, sizeof(buf), fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
- strncpy (mapname, name, namelen);
+ strncpy(mapname, name, namelen);
if (state != FLDPLUS)
cp = buf;
else {
- cp = add (buf, NULL);
+ cp = add(buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
- cp = add (buf, cp);
+ state = m_getfld(state, name, buf, sizeof(buf), fp);
+ cp = add(buf, cp);
}
}
- dp = trimcpy (cp);
+ dp = trimcpy(cp);
if (cp != buf)
- free (cp);
+ free(cp);
if (debugsw)
- fprintf (stderr, "compare %s to %s <- %s\n", id, dp,
- mapname);
- result = strcmp (id, dp);
- free (dp);
+ fprintf(stderr, "compare %s to %s <- %s\n", id, dp, mapname);
+ result = strcmp(id, dp);
+ free(dp);
if (result == 0) {
- lkfclose (fp, mapfile);
+ lkfclose(fp, mapfile);
return OK;
}
if (state != FLDEOF)
break;
}
- lkfclose (fp, mapfile);
+ lkfclose(fp, mapfile);
return NOTOK;
}
/*
** prototypes
*/
-void free_content (CT);
-void free_header (CT);
-void free_ctinfo (CT);
-void free_encoding (CT, int);
-void freects_done (int);
+void free_content(CT);
+void free_header(CT);
+void free_ctinfo(CT);
+void free_encoding(CT, int);
+void freects_done(int);
/*
** static prototypes
*/
-static void free_text (CT);
-static void free_multi (CT);
-static void free_partial (CT);
-static void free_external (CT);
+static void free_text(CT);
+static void free_multi(CT);
+static void free_partial(CT);
+static void free_external(CT);
/*
*/
void
-free_content (CT ct)
+free_content(CT ct)
{
if (!ct)
return;
/*
** free all the header fields
*/
- free_header (ct);
+ free_header(ct);
if (ct->c_partno)
- free (ct->c_partno);
+ free(ct->c_partno);
if (ct->c_vrsn)
- free (ct->c_vrsn);
+ free(ct->c_vrsn);
if (ct->c_ctline)
- free (ct->c_ctline);
+ free(ct->c_ctline);
- free_ctinfo (ct);
+ free_ctinfo(ct);
/*
** some of the content types have extra
*/
switch (ct->c_type) {
case CT_MULTIPART:
- free_multi (ct);
+ free_multi(ct);
break;
case CT_MESSAGE:
switch (ct->c_subtype) {
case MESSAGE_PARTIAL:
- free_partial (ct);
+ free_partial(ct);
break;
case MESSAGE_EXTERNAL:
- free_external (ct);
+ free_external(ct);
break;
}
break;
case CT_TEXT:
- free_text (ct);
+ free_text(ct);
break;
}
if (ct->c_showproc)
- free (ct->c_showproc);
+ free(ct->c_showproc);
if (ct->c_termproc)
- free (ct->c_termproc);
+ free(ct->c_termproc);
if (ct->c_storeproc)
- free (ct->c_storeproc);
+ free(ct->c_storeproc);
if (ct->c_celine)
- free (ct->c_celine);
+ free(ct->c_celine);
/* free structures for content encodings */
- free_encoding (ct, 1);
+ free_encoding(ct, 1);
if (ct->c_id)
- free (ct->c_id);
+ free(ct->c_id);
if (ct->c_descr)
- free (ct->c_descr);
+ free(ct->c_descr);
if (ct->c_dispo)
- free (ct->c_dispo);
+ free(ct->c_dispo);
if (ct->c_file) {
if (ct->c_unlink)
- unlink (ct->c_file);
- free (ct->c_file);
+ unlink(ct->c_file);
+ free(ct->c_file);
}
if (ct->c_fp)
- fclose (ct->c_fp);
+ fclose(ct->c_fp);
if (ct->c_storage)
- free (ct->c_storage);
+ free(ct->c_storage);
if (ct->c_folder)
- free (ct->c_folder);
+ free(ct->c_folder);
- free (ct);
+ free(ct);
}
*/
void
-free_header (CT ct)
+free_header(CT ct)
{
HF hp1, hp2;
while (hp1) {
hp2 = hp1->next;
- free (hp1->name);
- free (hp1->value);
- free (hp1);
+ free(hp1->name);
+ free(hp1->value);
+ free(hp1);
hp1 = hp2;
}
void
-free_ctinfo (CT ct)
+free_ctinfo(CT ct)
{
char **ap;
CI ci;
ci = &ct->c_ctinfo;
if (ci->ci_type) {
- free (ci->ci_type);
+ free(ci->ci_type);
ci->ci_type = NULL;
}
if (ci->ci_subtype) {
- free (ci->ci_subtype);
+ free(ci->ci_subtype);
ci->ci_subtype = NULL;
}
for (ap = ci->ci_attrs; *ap; ap++) {
- free (*ap);
+ free(*ap);
*ap = NULL;
}
if (ci->ci_comment) {
- free (ci->ci_comment);
+ free(ci->ci_comment);
ci->ci_comment = NULL;
}
if (ci->ci_magic) {
- free (ci->ci_magic);
+ free(ci->ci_magic);
ci->ci_magic = NULL;
}
}
static void
-free_text (CT ct)
+free_text(CT ct)
{
struct text *t;
if (!(t = (struct text *) ct->c_ctparams))
return;
- free ((char *) t);
+ free((char *) t);
ct->c_ctparams = NULL;
}
static void
-free_multi (CT ct)
+free_multi(CT ct)
{
struct multipart *m;
struct part *part, *next;
return;
if (m->mp_start)
- free (m->mp_start);
+ free(m->mp_start);
if (m->mp_stop)
- free (m->mp_stop);
+ free(m->mp_stop);
for (part = m->mp_parts; part; part = next) {
next = part->mp_next;
- free_content (part->mp_part);
- free ((char *) part);
+ free_content(part->mp_part);
+ free((char *) part);
}
m->mp_parts = NULL;
- free ((char *) m);
+ free((char *) m);
ct->c_ctparams = NULL;
}
static void
-free_partial (CT ct)
+free_partial(CT ct)
{
struct partial *p;
return;
if (p->pm_partid)
- free (p->pm_partid);
+ free(p->pm_partid);
- free ((char *) p);
+ free((char *) p);
ct->c_ctparams = NULL;
}
static void
-free_external (CT ct)
+free_external(CT ct)
{
struct exbody *e;
if (!(e = (struct exbody *) ct->c_ctparams))
return;
- free_content (e->eb_content);
+ free_content(e->eb_content);
if (e->eb_body)
- free (e->eb_body);
+ free(e->eb_body);
- free ((char *) e);
+ free((char *) e);
ct->c_ctparams = NULL;
}
*/
void
-free_encoding (CT ct, int toplevel)
+free_encoding(CT ct, int toplevel)
{
CE ce;
return;
if (ce->ce_fp) {
- fclose (ce->ce_fp);
+ fclose(ce->ce_fp);
ce->ce_fp = NULL;
}
if (ce->ce_file) {
if (ce->ce_unlink)
- unlink (ce->ce_file);
- free (ce->ce_file);
+ unlink(ce->ce_file);
+ free(ce->ce_file);
ce->ce_file = NULL;
}
if (toplevel) {
- free ((char *) ce);
+ free((char *) ce);
ct->c_cefile = NULL;
} else {
ct->c_ceopenfnx = NULL;
void
-freects_done (int status)
+freects_done(int status)
{
CT *ctp;
if ((ctp = cts))
for (; *ctp; ctp++)
- free_content (*ctp);
+ free_content(*ctp);
- exit (status);
+ exit(status);
}
#include <h/mh.h>
/* prototype from mhlsbr.c */
-int mhl (int, char **);
+int mhl(int, char **);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- done (mhl (argc, argv));
+ done(mhl(argc, argv));
return 1;
}
#define quitser pipeser
/* mhparse.c */
-CT parse_mime (char *);
+CT parse_mime(char *);
/* mhmisc.c */
-int part_ok (CT, int);
-int type_ok (CT, int);
-void set_endian (void);
-void flush_errors (void);
+int part_ok(CT, int);
+int type_ok(CT, int);
+void set_endian(void);
+void flush_errors(void);
/* mhlistsbr.c */
-void list_all_messages (CT *, int, int, int, int);
+void list_all_messages(CT *, int, int, int, int);
/* mhfree.c */
-void free_content (CT);
+void free_content(CT);
extern CT *cts;
-void freects_done (int) NORETURN;
+void freects_done(int) NORETURN;
/*
** static prototypes
*/
-static RETSIGTYPE pipeser (int);
+static RETSIGTYPE pipeser(int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int sizesw = 1, headsw = 1;
int msgnum, *icachesw;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case RCACHESW:
icachesw = &rcachesw;
icachesw = &wcachesw;
do_cache:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- switch (*icachesw = smatch (cp, caches)) {
+ adios(NULL, "missing argument to %s", argp[-2]);
+ switch (*icachesw = smatch(cp, caches)) {
case AMBIGSW:
- ambigsw (cp, caches);
- done (1);
+ ambigsw(cp, caches);
+ done(1);
case UNKWNSW:
- adios (NULL, "%s unknown", cp);
+ adios(NULL, "%s unknown", cp);
default:
break;
}
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);
+ adios(NULL, "too many parts (starting with %s), %d max", cp, NPARTS);
parts[npart++] = cp;
continue;
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);
+ adios(NULL, "too many types (starting with %s), %d max", cp, NTYPES);
types[ntype++] = cp;
continue;
case FILESW:
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
- adios (NULL, "missing argument to %s", argp[-2]);
- file = *cp == '-' ? cp : path (cp, TFILE);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ file = *cp == '-' ? cp : path(cp, TFILE);
continue;
case VERBSW:
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
/* null terminate the list of acceptable parts/types */
parts[npart] = NULL;
types[ntype] = NULL;
- set_endian ();
+ set_endian();
/* Check for public cache location */
- if ((cache_public = context_find (nmhcache)) && *cache_public != '/')
+ if ((cache_public = context_find(nmhcache)) && *cache_public != '/')
cache_public = NULL;
/* Check for private cache location */
- if (!(cache_private = context_find (nmhprivcache)))
+ if (!(cache_private = context_find(nmhprivcache)))
cache_private = ".cache";
- cache_private = getcpy (m_maildir (cache_private));
+ 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.
*/
- if ((cp = context_find (nmhstorage)) && *cp)
- tmp = concat (cp, "/", invo_name, NULL);
+ if ((cp = context_find(nmhstorage)) && *cp)
+ tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = add (m_maildir (invo_name), NULL);
+ tmp = add(m_maildir(invo_name), NULL);
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (file && msgs.size)
- adios (NULL, "cannot specify msg and file at same time!");
+ adios(NULL, "cannot specify msg and file at same time!");
/*
** check if message is coming from file
*/
if (file) {
- if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
- adios (NULL, "out of memory");
+ if (!(cts = (CT *) calloc((size_t) 2, sizeof(*cts))))
+ adios(NULL, "out of memory");
ctp = cts;
- if ((ct = parse_mime (file)));
+ if ((ct = parse_mime(file)));
*ctp++ = ct;
} else {
/*
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
+ if (!m_convert(mp, msgs.msgs[msgnum]))
done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ seq_setprev(mp); /* set the previous-sequence */
- if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1),
+ if (!(cts = (CT *) calloc((size_t) (mp->numsel + 1),
sizeof(*cts))))
- adios (NULL, "out of memory");
+ adios(NULL, "out of memory");
ctp = cts;
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
char *msgnam;
- msgnam = m_name (msgnum);
- if ((ct = parse_mime (msgnam)))
+ msgnam = m_name(msgnum);
+ if ((ct = parse_mime(msgnam)))
*ctp++ = ct;
}
}
}
if (!*cts)
- done (1);
+ done(1);
userrs = 1;
- SIGNAL (SIGQUIT, quitser);
- SIGNAL (SIGPIPE, pipeser);
+ SIGNAL(SIGQUIT, quitser);
+ SIGNAL(SIGPIPE, pipeser);
/*
** Get the associated umask for the relevant contents.
struct stat st;
ct = *ctp;
- if (type_ok (ct, 1) && !ct->c_umask) {
- if (stat (ct->c_file, &st) != NOTOK)
+ if (type_ok(ct, 1) && !ct->c_umask) {
+ if (stat(ct->c_file, &st) != NOTOK)
ct->c_umask = ~(st.st_mode & 0777);
else
ct->c_umask = ~m_gmprot();
/*
** List the message content
*/
- list_all_messages (cts, headsw, sizesw, verbosw, debugsw);
+ list_all_messages(cts, headsw, sizesw, verbosw, debugsw);
/* Now free all the structures for the content */
for (ctp = cts; *ctp; ctp++)
- free_content (*ctp);
+ free_content(*ctp);
- free ((char *) cts);
+ free((char *) cts);
cts = NULL;
/* If reading from a folder, do some updating */
if (mp) {
- context_replace (pfolder, folder); /* update current folder */
- seq_setcur (mp, mp->hghsel); /* update current message */
- seq_save (mp); /* synchronize sequences */
- context_save (); /* save the context file */
+ context_replace(pfolder, folder); /* update current folder */
+ seq_setcur(mp, mp->hghsel); /* update current message */
+ seq_save(mp); /* synchronize sequences */
+ context_save(); /* save the context file */
}
- done (0);
+ done(0);
return 1;
}
static RETSIGTYPE
-pipeser (int i)
+pipeser(int i)
{
if (i == SIGQUIT) {
- unlink ("core");
- fflush (stdout);
- fprintf (stderr, "\n");
- fflush (stderr);
+ unlink("core");
+ fflush(stdout);
+ fprintf(stderr, "\n");
+ fflush(stderr);
}
- done (1);
+ done(1);
/* NOTREACHED */
}
#include <h/utils.h>
/* mhmisc.c */
-int part_ok (CT, int);
-int type_ok (CT, int);
-void flush_errors (void);
+int part_ok(CT, int);
+int type_ok(CT, int);
+void flush_errors(void);
/*
** 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);
+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 void list_single_message (CT, int, int, int);
-static int list_debug (CT);
-static int list_multi (CT, int, int, int, int);
-static int list_partial (CT, int, int, int, int);
-static int list_external (CT, int, int, int, int);
-static int list_application (CT, int, int, int, int);
-static int list_encoding (CT);
+static void list_single_message(CT, int, int, int);
+static int list_debug(CT);
+static int list_multi(CT, int, int, int, int);
+static int list_partial(CT, int, int, int, int);
+static int list_external(CT, int, int, int, int);
+static int list_application(CT, int, int, int, int);
+static int list_encoding(CT);
/*
*/
void
-list_all_messages (CT *cts, int headers, int realsize, int verbose, int debug)
+list_all_messages(CT *cts, int headers, int realsize, int verbose, int debug)
{
CT ct, *ctp;
if (headers)
- printf (LSTFMT1, "msg", "part", "type/subtype", "size", "description");
+ printf(LSTFMT1, "msg", "part", "type/subtype", "size",
+ "description");
for (ctp = cts; *ctp; ctp++) {
ct = *ctp;
- list_single_message (ct, realsize, verbose, debug);
+ list_single_message(ct, realsize, verbose, debug);
}
- flush_errors ();
+ flush_errors();
}
*/
static void
-list_single_message (CT ct, int realsize, int verbose, int debug)
+list_single_message(CT ct, int realsize, int verbose, int debug)
{
- if (type_ok (ct, 1)) {
- umask (ct->c_umask);
- list_switch (ct, 1, realsize, verbose, debug);
+ if (type_ok(ct, 1)) {
+ umask(ct->c_umask);
+ list_switch(ct, 1, realsize, verbose, debug);
if (ct->c_fp) {
- fclose (ct->c_fp);
+ fclose(ct->c_fp);
ct->c_fp = NULL;
}
if (ct->c_ceclosefnx)
*/
int
-list_switch (CT ct, int toplevel, int realsize, int verbose, int debug)
+list_switch(CT ct, int toplevel, int realsize, int verbose, int debug)
{
switch (ct->c_type) {
case CT_MULTIPART:
- return list_multi (ct, toplevel, realsize, verbose, debug);
+ return list_multi(ct, toplevel, realsize, verbose,
+ debug);
break;
case CT_MESSAGE:
switch (ct->c_subtype) {
case MESSAGE_PARTIAL:
- return list_partial (ct, toplevel, realsize, verbose, debug);
+ return list_partial(ct, toplevel,
+ realsize, verbose,
+ debug);
break;
case MESSAGE_EXTERNAL:
- return list_external (ct, toplevel, realsize, verbose, debug);
+ return list_external(ct, toplevel,
+ realsize, verbose,
+ debug);
break;
case MESSAGE_RFC822:
default:
- return list_content (ct, toplevel, realsize, verbose, debug);
+ return list_content(ct, toplevel,
+ realsize, verbose,
+ debug);
break;
}
break;
case CT_AUDIO:
case CT_IMAGE:
case CT_VIDEO:
- return list_content (ct, toplevel, realsize, verbose, debug);
+ return list_content(ct, toplevel, realsize, verbose,
+ debug);
break;
case CT_APPLICATION:
- return list_application (ct, toplevel, realsize, verbose, debug);
+ return list_application(ct, toplevel, realsize,
+ verbose, debug);
break;
default:
/* list_debug (ct); */
- adios (NULL, "unknown content type %d", ct->c_type);
+ adios(NULL, "unknown content type %d", ct->c_type);
break;
}
*/
int
-list_content (CT ct, int toplevel, int realsize, int verbose, int debug)
+list_content(CT ct, int toplevel, int realsize, int verbose, int debug)
{
unsigned long size;
char *cp, buffer[BUFSIZ];
CI ci = &ct->c_ctinfo;
- printf (toplevel > 0 ? LSTFMT2a : toplevel < 0 ? "part " : " ",
- atoi (r1bindex (empty (ct->c_file), '/')));
- snprintf (buffer, sizeof(buffer), "%s/%s", empty (ci->ci_type),
- empty (ci->ci_subtype));
- printf (LSTFMT2b, empty (ct->c_partno), buffer);
+ printf(toplevel > 0 ? LSTFMT2a : toplevel < 0 ? "part " : " ",
+ atoi(r1bindex(empty(ct->c_file), '/')));
+ snprintf(buffer, sizeof(buffer), "%s/%s", empty(ci->ci_type),
+ empty(ci->ci_subtype));
+ printf(LSTFMT2b, empty(ct->c_partno), buffer);
if (ct->c_cesizefnx && realsize)
size = (*ct->c_cesizefnx) (ct);
switch (*cp) {
case ' ':
if (size > 0 || ct->c_encoding != CE_EXTERNAL)
- printf (LSTFMT2c1, size);
+ printf(LSTFMT2c1, size);
else
- printf (LSTFMT2c4);
+ printf(LSTFMT2c4);
break;
default:
- printf (LSTFMT2c2, size, *cp);
+ printf(LSTFMT2c2, size, *cp);
break;
case '\0':
- printf (LSTFMT2c3);
+ printf(LSTFMT2c3);
}
/* print Content-Description */
if (ct->c_descr) {
char *dp;
- dp = trimcpy (cp = add (ct->c_descr, NULL));
- free (cp);
- printf (LSTFMT2d1, dp);
- free (dp);
+ dp = trimcpy(cp = add(ct->c_descr, NULL));
+ free(cp);
+ printf(LSTFMT2d1, dp);
+ free(dp);
}
- printf ("\n");
+ printf("\n");
/*
** If verbose, print any RFC-822 comments in the
if (verbose && ci->ci_comment) {
char *dp;
- dp = trimcpy (cp = add (ci->ci_comment, NULL));
- free (cp);
- snprintf (buffer, sizeof(buffer), "(%s)", dp);
- free (dp);
- printf (LSTFMT2d2, buffer);
+ dp = trimcpy(cp = add(ci->ci_comment, NULL));
+ free(cp);
+ snprintf(buffer, sizeof(buffer), "(%s)", dp);
+ free(dp);
+ printf(LSTFMT2d2, buffer);
}
if (debug)
- list_debug (ct);
+ list_debug(ct);
return OK;
}
*/
static int
-list_debug (CT ct)
+list_debug(CT ct)
{
char **ap, **ep;
CI ci = &ct->c_ctinfo;
- fflush (stdout);
- fprintf (stderr, " partno \"%s\"\n", empty (ct->c_partno));
+ fflush(stdout);
+ fprintf(stderr, " partno \"%s\"\n", empty(ct->c_partno));
/* print MIME-Version line */
if (ct->c_vrsn)
- fprintf (stderr, " %s:%s\n", VRSN_FIELD, ct->c_vrsn);
+ fprintf(stderr, " %s:%s\n", VRSN_FIELD, ct->c_vrsn);
/* print Content-Type line */
if (ct->c_ctline)
- fprintf (stderr, " %s:%s\n", TYPE_FIELD, ct->c_ctline);
+ fprintf(stderr, " %s:%s\n", TYPE_FIELD, ct->c_ctline);
/* print parsed elements of content type */
- fprintf (stderr, " type \"%s\"\n", empty (ci->ci_type));
- fprintf (stderr, " subtype \"%s\"\n", empty (ci->ci_subtype));
- fprintf (stderr, " comment \"%s\"\n", empty (ci->ci_comment));
- fprintf (stderr, " magic \"%s\"\n", empty (ci->ci_magic));
+ fprintf(stderr, " type \"%s\"\n", empty(ci->ci_type));
+ fprintf(stderr, " subtype \"%s\"\n", empty(ci->ci_subtype));
+ fprintf(stderr, " comment \"%s\"\n", empty(ci->ci_comment));
+ fprintf(stderr, " magic \"%s\"\n", empty(ci->ci_magic));
/* print parsed parameters attached to content type */
- fprintf (stderr, " parameters\n");
+ fprintf(stderr, " parameters\n");
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++)
- fprintf (stderr, " %s=\"%s\"\n", *ap, *ep);
+ fprintf(stderr, " %s=\"%s\"\n", *ap, *ep);
/* print internal flags for type/subtype */
- fprintf (stderr, " type 0x%x subtype 0x%x params 0x%x\n",
- ct->c_type, ct->c_subtype,
- (unsigned int)(unsigned long) ct->c_ctparams);
+ fprintf(stderr, " type 0x%x subtype 0x%x params 0x%x\n",
+ ct->c_type, ct->c_subtype,
+ (unsigned int)(unsigned long) ct->c_ctparams);
- fprintf (stderr, " showproc \"%s\"\n", empty (ct->c_showproc));
- fprintf (stderr, " termproc \"%s\"\n", empty (ct->c_termproc));
- fprintf (stderr, " storeproc \"%s\"\n", empty (ct->c_storeproc));
+ fprintf(stderr, " showproc \"%s\"\n", empty(ct->c_showproc));
+ fprintf(stderr, " termproc \"%s\"\n", empty(ct->c_termproc));
+ fprintf(stderr, " storeproc \"%s\"\n", empty(ct->c_storeproc));
/* print transfer encoding information */
if (ct->c_celine)
- fprintf (stderr, " %s:%s", ENCODING_FIELD, ct->c_celine);
+ fprintf(stderr, " %s:%s", ENCODING_FIELD, ct->c_celine);
/* print internal flags for transfer encoding */
- fprintf (stderr, " transfer encoding 0x%x params 0x%x\n",
- ct->c_encoding, (unsigned int)(unsigned long) ct->c_cefile);
+ fprintf(stderr, " transfer encoding 0x%x params 0x%x\n",
+ ct->c_encoding,
+ (unsigned int)(unsigned long) ct->c_cefile);
/* print Content-ID */
if (ct->c_id)
- fprintf (stderr, " %s:%s", ID_FIELD, ct->c_id);
+ fprintf(stderr, " %s:%s", ID_FIELD, ct->c_id);
/* print Content-Description */
if (ct->c_descr)
- fprintf (stderr, " %s:%s", DESCR_FIELD, ct->c_descr);
+ fprintf(stderr, " %s:%s", DESCR_FIELD, ct->c_descr);
- fprintf (stderr, " read fp 0x%x file \"%s\" begin %ld end %ld\n",
- (unsigned int)(unsigned long) ct->c_fp, empty (ct->c_file),
- ct->c_begin, ct->c_end);
+ fprintf(stderr, " read fp 0x%x file \"%s\" begin %ld end %ld\n",
+ (unsigned int)(unsigned long) ct->c_fp,
+ empty(ct->c_file), ct->c_begin, ct->c_end);
/* print more information about transfer encoding */
- list_encoding (ct);
+ list_encoding(ct);
return OK;
}
*/
static int
-list_multi (CT ct, int toplevel, int realsize, int verbose, int debug)
+list_multi(CT ct, int toplevel, int realsize, int verbose, int debug)
{
struct multipart *m = (struct multipart *) ct->c_ctparams;
struct part *part;
/* list the content for toplevel of this multipart */
- list_content (ct, toplevel, realsize, verbose, debug);
+ list_content(ct, toplevel, realsize, verbose, debug);
/* now list for all the subparts */
for (part = m->mp_parts; part; part = part->mp_next) {
CT p = part->mp_part;
- if (part_ok (p, 1) && type_ok (p, 1))
- list_switch (p, 0, realsize, verbose, debug);
+ if (part_ok(p, 1) && type_ok(p, 1))
+ list_switch(p, 0, realsize, verbose, debug);
}
return OK;
*/
static int
-list_partial (CT ct, int toplevel, int realsize, int verbose, int debug)
+list_partial(CT ct, int toplevel, int realsize, int verbose, int debug)
{
struct partial *p = (struct partial *) ct->c_ctparams;
- list_content (ct, toplevel, realsize, verbose, debug);
+ list_content(ct, toplevel, realsize, verbose, debug);
if (verbose) {
- printf ("\t [message %s, part %d",
+ printf("\t [message %s, part %d",
p->pm_partid, p->pm_partno);
if (p->pm_maxno)
- printf (" of %d", p->pm_maxno);
- printf ("]\n");
+ printf(" of %d", p->pm_maxno);
+ printf("]\n");
}
return OK;
*/
static int
-list_external (CT ct, int toplevel, int realsize, int verbose, int debug)
+list_external(CT ct, int toplevel, int realsize, int verbose, int debug)
{
struct exbody *e = (struct exbody *) ct->c_ctparams;
* First list the information for the
* message/external content itself.
*/
- list_content (ct, toplevel, realsize, verbose, debug);
+ list_content(ct, toplevel, realsize, verbose, debug);
if (verbose) {
if (e->eb_name)
- printf ("\t name=\"%s\"\n", e->eb_name);
+ printf("\t name=\"%s\"\n", e->eb_name);
if (e->eb_dir)
- printf ("\t directory=\"%s\"\n", e->eb_dir);
+ printf("\t directory=\"%s\"\n", e->eb_dir);
if (e->eb_site)
- printf ("\t site=\"%s\"\n", e->eb_site);
+ printf("\t site=\"%s\"\n", e->eb_site);
if (e->eb_server)
- printf ("\t server=\"%s\"\n", e->eb_server);
+ printf("\t server=\"%s\"\n", e->eb_server);
if (e->eb_subject)
- printf ("\t subject=\"%s\"\n", e->eb_subject);
+ printf("\t subject=\"%s\"\n", e->eb_subject);
/* This must be defined */
printf("\t access-type=\"%s\"\n", e->eb_access);
if (e->eb_mode)
- printf ("\t mode=\"%s\"\n", e->eb_mode);
+ printf("\t mode=\"%s\"\n", e->eb_mode);
if (e->eb_permission)
- printf ("\t permission=\"%s\"\n", e->eb_permission);
+ printf("\t permission=\"%s\"\n", e->eb_permission);
if (e->eb_flags == NOTOK)
- printf ("\t [service unavailable]\n");
+ printf("\t [service unavailable]\n");
}
/*
** Now list the information for the external content
** to which this content points.
*/
- list_content (e->eb_content, 0, realsize, verbose, debug);
+ list_content(e->eb_content, 0, realsize, verbose, debug);
return OK;
}
*/
static int
-list_application (CT ct, int toplevel, int realsize, int verbose, int debug)
+list_application(CT ct, int toplevel, int realsize, int verbose, int debug)
{
- list_content (ct, toplevel, realsize, verbose, debug);
+ list_content(ct, toplevel, realsize, verbose, debug);
if (verbose) {
char **ap, **ep;
CI ci = &ct->c_ctinfo;
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++)
- printf ("\t %s=\"%s\"\n", *ap, *ep);
+ printf("\t %s=\"%s\"\n", *ap, *ep);
}
return OK;
*/
static int
-list_encoding (CT ct)
+list_encoding(CT ct)
{
CE ce;
if ((ce = ct->c_cefile))
- fprintf (stderr, " decoded fp 0x%x file \"%s\"\n",
+ fprintf(stderr, " decoded fp 0x%x file \"%s\"\n",
(unsigned int)(unsigned long) ce->ce_fp,
ce->ce_file ? ce->ce_file : "");
/*
** prototypes
*/
-static void mhl_format (char *, int, int);
-static int evalvar (struct mcomp *);
-static int ptoi (char *, int *);
-static int ptos (char *, char **);
-static char *parse (void);
-static void process (char *, char *, int, int);
-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 **,
+static void mhl_format(char *, int, int);
+static int evalvar(struct mcomp *);
+static int ptoi(char *, int *);
+static int ptos(char *, char **);
+static char *parse(void);
+static void process(char *, char *, int, int);
+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 void free_queue (struct mcomp **, struct mcomp **);
-static void putcomp (struct mcomp *, struct mcomp *, int);
-static char *oneline (char *, long);
-static void putstr (char *);
-static void putch (char);
-static RETSIGTYPE intrser (int);
-static RETSIGTYPE pipeser (int);
-static RETSIGTYPE quitser (int);
-static void face_format (struct mcomp *);
-static int doface (struct mcomp *);
-static void mhladios (char *, char *, ...);
-static void mhldone (int);
-static void m_popen (char *);
-
-int mhl (int, char **);
-int mhlsbr (int, char **, FILE *(*)());
-void m_pclose (void);
-
-void clear_screen (void); /* from termsbr.c */
-int SOprintf (char *, ...); /* from termsbr.c */
-int sc_width (void); /* from termsbr.c */
-int sc_length (void); /* from termsbr.c */
-int sc_hardcopy (void); /* from termsbr.c */
+static void free_queue(struct mcomp **, struct mcomp **);
+static void putcomp(struct mcomp *, struct mcomp *, int);
+static char *oneline(char *, long);
+static void putstr(char *);
+static void putch(char);
+static RETSIGTYPE intrser(int);
+static RETSIGTYPE pipeser(int);
+static RETSIGTYPE quitser(int);
+static void face_format(struct mcomp *);
+static int doface(struct mcomp *);
+static void mhladios(char *, char *, ...);
+static void mhldone(int);
+static void m_popen(char *);
+
+int mhl(int, char **);
+int mhlsbr(int, char **, FILE *(*)());
+void m_pclose(void);
+
+void clear_screen(void); /* from termsbr.c */
+int SOprintf(char *, ...); /* from termsbr.c */
+int sc_width(void); /* from termsbr.c */
+int sc_length(void); /* from termsbr.c */
+int sc_hardcopy(void); /* from termsbr.c */
int
-mhl (int argc, char **argv)
+mhl(int argc, char **argv)
{
int length = 0, nomore = 0;
int i, width = 0, vecp = 0;
char buf[BUFSIZ], *files[MAXARGS];
char **argp, **arguments;
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
- if ((cp = getenv ("MHLDEBUG")) && *cp)
+ if ((cp = getenv("MHLDEBUG")) && *cp)
mhldebug++;
- if ((cp = getenv ("FACEPROC")))
+ if ((cp = getenv("FACEPROC")))
faceproc = cp;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, mhlswitches)) {
+ switch (smatch(++cp, mhlswitches)) {
case AMBIGSW:
- ambigsw (cp, mhlswitches);
- done (1);
+ ambigsw(cp, mhlswitches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown\n", cp);
+ adios(NULL, "-%s unknown\n", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] [files ...]", invo_name);
- print_help (buf, mhlswitches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches] [files ...]", invo_name);
+ print_help(buf, mhlswitches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case BELLSW:
bellflg = 1;
continue;
case FOLDSW:
- if (!(folder = *argp++) || *folder == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ if (!(folder = *argp++) ||
+ *folder == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case FACESW:
if (!(faceproc = *argp++) || *faceproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case NFACESW:
faceproc = NULL;
continue;
case SLEEPSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- sleepsw = atoi (cp);/* ZERO ok! */
+ adios(NULL, "missing argument to %s", argp[-2]);
+ sleepsw = atoi(cp); /* ZERO ok! */
continue;
case PROGSW:
if (!(moreproc = *argp++) || *moreproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case NPROGSW:
nomore++;
case LENSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((length = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((length = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s", argp[-2], cp);
continue;
case WIDTHSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((width = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((width = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s", argp[-2], cp);
continue;
case DGSTSW:
- if (!(digest = *argp++) || *digest == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ if (!(digest = *argp++) ||
+ *digest == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case ISSUESW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((issue = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((issue = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s", argp[-2], cp);
continue;
case VOLUMSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((volume = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((volume = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s", argp[-2], cp);
continue;
case FORW2SW:
}
if (!folder)
- folder = getenv ("mhfolder");
+ folder = getenv("mhfolder");
- if (isatty (fileno (stdout))) {
+ if (isatty(fileno(stdout))) {
if (!nomore && !sc_hardcopy() && moreproc && *moreproc != '\0') {
if (mhl_action) {
- SIGNAL (SIGINT, SIG_IGN);
- SIGNAL2 (SIGQUIT, quitser);
+ SIGNAL(SIGINT, SIG_IGN);
+ SIGNAL2(SIGQUIT, quitser);
}
- SIGNAL2 (SIGPIPE, pipeser);
- m_popen (moreproc);
+ SIGNAL2(SIGPIPE, pipeser);
+ m_popen(moreproc);
ontty = PITTY;
} else {
- SIGNAL (SIGINT, SIG_IGN);
- SIGNAL2 (SIGQUIT, quitser);
+ SIGNAL(SIGINT, SIG_IGN);
+ SIGNAL2(SIGQUIT, quitser);
ontty = ISTTY;
}
} else {
ontty = NOTTY;
}
- mhl_format (form ? form : mhlformat, length, width);
+ mhl_format(form ? form : mhlformat, length, width);
if (vecp == 0) {
- process (folder, NULL, 1, vecp = 1);
+ process(folder, NULL, 1, vecp = 1);
} else {
for (i = 0; i < vecp; i++)
- process (folder, files[i], i + 1, vecp);
+ process(folder, files[i], i + 1, vecp);
}
if (forwall) {
if (digest) {
- printf ("%s", delim4);
+ printf("%s", delim4);
if (volume == 0) {
- snprintf (buf, sizeof(buf),
+ snprintf(buf, sizeof(buf),
"End of %s Digest\n", digest);
} else {
- snprintf (buf, sizeof(buf),
- "End of %s Digest [Volume %d Issue %d]\n",
- digest, volume, issue);
+ snprintf(buf, sizeof(buf), "End of %s Digest [Volume %d Issue %d]\n", digest, volume, issue);
}
- i = strlen (buf);
+ i = strlen(buf);
for (cp = buf + i; i > 1; i--)
*cp++ = '*';
*cp++ = '\n';
*cp = 0;
- printf ("%s", buf);
+ printf("%s", buf);
} else
- printf ("\n------- End of Forwarded Message%s\n\n",
+ printf("\n------- End of Forwarded Message%s\n\n",
vecp > 1 ? "s" : "");
}
}
if (clearflg > 0 && ontty == NOTTY)
- clear_screen ();
+ clear_screen();
if (ontty == PITTY)
- m_pclose ();
+ m_pclose();
return exitstat;
}
static void
-mhl_format (char *file, int length, int width)
+mhl_format(char *file, int length, int width)
{
int i;
char *bp, *cp, **ip;
static time_t mtime = 0;
if (fmthd != NULL) {
- if (stat (etcpath (file), &st) != NOTOK
+ if (stat(etcpath(file), &st) != NOTOK
&& mtime == st.st_mtime
&& dev == st.st_dev
&& ino == st.st_ino)
goto out;
else
- free_queue (&fmthd, &fmttl);
+ free_queue(&fmthd, &fmttl);
}
- if ((fp = fopen (etcpath (file), "r")) == NULL)
- adios (file, "unable to open format file");
+ if ((fp = fopen(etcpath(file), "r")) == NULL)
+ adios(file, "unable to open format file");
- if (fstat (fileno (fp), &st) != NOTOK) {
+ if (fstat(fileno(fp), &st) != NOTOK) {
mtime = st.st_mtime;
dev = st.st_dev;
ino = st.st_ino;
global.c_fmt = NULL;
global.c_offset = 0;
global.c_ovoff = -1;
- if ((i = sc_width ()) > 5)
+ if ((i = sc_width()) > 5)
global.c_width = i;
global.c_cwidth = -1;
- if ((i = sc_length ()) > 5)
+ if ((i = sc_length()) > 5)
global.c_length = i - 1;
global.c_flags = BELL; /* BELL is default */
*(ip = ignores) = NULL;
- while (vfgets (fp, &ap) == OK) {
+ while (vfgets(fp, &ap) == OK) {
bp = ap;
if (*bp == ';')
continue;
*cp = 0;
if (*bp == ':') {
- c1 = add_queue (&fmthd, &fmttl, NULL, bp + 1, CLEARTEXT);
+ c1 = add_queue(&fmthd, &fmttl, NULL, bp + 1,
+ CLEARTEXT);
continue;
}
parptr = bp;
- strncpy (name, parse(), sizeof(name));
- switch (*parptr) {
+ strncpy(name, parse(), sizeof(name));
+ switch(*parptr) {
case '\0':
case ',':
case '=':
** and copy it to the end of the current
** "ignores" list.
*/
- if (!mh_strcasecmp (name, "ignores")) {
+ if (!mh_strcasecmp(name, "ignores")) {
char **tmparray, **p;
int n = 0;
/* split the fields */
- tmparray = brkstring (getcpy (++parptr), ",", NULL);
+ tmparray = brkstring(getcpy(++parptr),
+ ",", NULL);
/* count number of fields split */
p = tmparray;
** copy pointers to split fields
** to ignores array
*/
- ip = copyip (tmparray, ip, MAXARGS - num_ignores);
+ ip = copyip(tmparray, ip,
+ MAXARGS - num_ignores);
num_ignores += n;
continue;
}
parptr = bp;
while (*parptr) {
- if (evalvar (&global))
- adios (NULL, "format file syntax error: %s", bp);
+ if (evalvar(&global))
+ adios(NULL, "format file syntax error: %s", bp);
if (*parptr)
parptr++;
}
continue;
case ':':
- c1 = add_queue (&fmthd, &fmttl, name, NULL, INIT);
+ c1 = add_queue(&fmthd, &fmttl, name, NULL,
+ INIT);
while (*parptr == ':' || *parptr == ',') {
parptr++;
- if (evalvar (c1))
- adios (NULL, "format file syntax error: %s", bp);
+ if (evalvar(c1))
+ adios(NULL, "format file syntax error: %s", bp);
}
if (!c1->c_nfs && global.c_nfs) {
if (c1->c_flags & DATEFMT) {
if (global.c_flags & DATEFMT)
- c1->c_nfs = getcpy (global.c_nfs);
+ c1->c_nfs = getcpy(global.c_nfs);
}
else
if (c1->c_flags & ADDRFMT) {
if (global.c_flags & ADDRFMT)
- c1->c_nfs = getcpy (global.c_nfs);
+ c1->c_nfs = getcpy(global.c_nfs);
}
}
continue;
default:
- adios (NULL, "format file syntax error: %s", bp);
+ adios(NULL, "format file syntax error: %s",
+ bp);
}
}
- fclose (fp);
+ fclose(fp);
if (mhldebug) {
for (c1 = fmthd; c1; c1 = c1->c_next) {
- fprintf (stderr, "c1: name=\"%s\" text=\"%s\" ovtxt=\"%s\"\n",
- c1->c_name, c1->c_text, c1->c_ovtxt);
- fprintf (stderr, "\tnfs=0x%x fmt=0x%x\n",
- (unsigned int)(unsigned long) c1->c_nfs,
- (unsigned int)(unsigned long) c1->c_fmt);
- fprintf (stderr, "\toffset=%d ovoff=%d width=%d cwidth=%d length=%d\n",
- c1->c_offset, c1->c_ovoff, c1->c_width,
- c1->c_cwidth, c1->c_length);
- fprintf (stderr, "\tflags=%s\n",
- snprintb (buffer, sizeof(buffer), (unsigned) c1->c_flags, LBITS));
+ fprintf(stderr, "c1: name=\"%s\" text=\"%s\" ovtxt=\"%s\"\n", c1->c_name, c1->c_text, c1->c_ovtxt);
+ fprintf(stderr, "\tnfs=0x%x fmt=0x%x\n", (unsigned int)(unsigned long) c1->c_nfs, (unsigned int)(unsigned long) c1->c_fmt);
+ fprintf(stderr, "\toffset=%d ovoff=%d width=%d cwidth=%d length=%d\n", c1->c_offset, c1->c_ovoff, c1->c_width, c1->c_cwidth, c1->c_length);
+ fprintf (stderr, "\tflags=%s\n", snprintb(buffer, sizeof(buffer), (unsigned) c1->c_flags, LBITS));
}
}
static int
-evalvar (struct mcomp *c1)
+evalvar(struct mcomp *c1)
{
char *cp, name[NAMESZ];
struct triple *ap;
if (!*parptr)
return 0;
- strncpy (name, parse(), sizeof(name));
+ strncpy(name, parse(), sizeof(name));
- if (!mh_strcasecmp (name, "component")) {
- if (ptos (name, &c1->c_text))
+ if (!mh_strcasecmp(name, "component")) {
+ if (ptos(name, &c1->c_text))
return 1;
c1->c_flags &= ~NOCOMPONENT;
return 0;
}
- if (!mh_strcasecmp (name, "overflowtext"))
- return ptos (name, &c1->c_ovtxt);
+ if (!mh_strcasecmp(name, "overflowtext"))
+ return ptos(name, &c1->c_ovtxt);
- if (!mh_strcasecmp (name, "formatfield")) {
+ if (!mh_strcasecmp(name, "formatfield")) {
char *nfs;
- if (ptos (name, &cp))
+ if (ptos(name, &cp))
return 1;
- nfs = new_fs (NULL, NULL, cp);
- c1->c_nfs = getcpy (nfs);
+ nfs = new_fs(NULL, NULL, cp);
+ c1->c_nfs = getcpy(nfs);
c1->c_flags |= FORMAT;
return 0;
}
- if (!mh_strcasecmp (name, "decode")) {
+ if (!mh_strcasecmp(name, "decode")) {
char *nfs;
- nfs = new_fs (NULL, NULL, "%(decode{text})");
- c1->c_nfs = getcpy (nfs);
+ nfs = new_fs(NULL, NULL, "%(decode{text})");
+ c1->c_nfs = getcpy(nfs);
c1->c_flags |= FORMAT;
return 0;
}
- if (!mh_strcasecmp (name, "offset"))
- return ptoi (name, &c1->c_offset);
- if (!mh_strcasecmp (name, "overflowoffset"))
- return ptoi (name, &c1->c_ovoff);
- if (!mh_strcasecmp (name, "width"))
- return ptoi (name, &c1->c_width);
- if (!mh_strcasecmp (name, "compwidth"))
- return ptoi (name, &c1->c_cwidth);
- if (!mh_strcasecmp (name, "length"))
- return ptoi (name, &c1->c_length);
- if (!mh_strcasecmp (name, "nodashstuffing"))
+ if (!mh_strcasecmp(name, "offset"))
+ return ptoi(name, &c1->c_offset);
+ if (!mh_strcasecmp(name, "overflowoffset"))
+ return ptoi(name, &c1->c_ovoff);
+ if (!mh_strcasecmp(name, "width"))
+ return ptoi(name, &c1->c_width);
+ if (!mh_strcasecmp(name, "compwidth"))
+ return ptoi(name, &c1->c_cwidth);
+ if (!mh_strcasecmp(name, "length"))
+ return ptoi(name, &c1->c_length);
+ if (!mh_strcasecmp(name, "nodashstuffing"))
return (dashstuff = -1);
for (ap = triples; ap->t_name; ap++)
- if (!mh_strcasecmp (ap->t_name, name)) {
+ if (!mh_strcasecmp(ap->t_name, name)) {
c1->c_flags |= ap->t_on;
c1->c_flags &= ~ap->t_off;
return 0;
static int
-ptoi (char *name, int *i)
+ptoi(char *name, int *i)
{
char *cp;
- if (*parptr++ != '=' || !*(cp = parse ())) {
- advise (NULL, "missing argument to variable %s", name);
+ if (*parptr++ != '=' || !*(cp = parse())) {
+ advise(NULL, "missing argument to variable %s", name);
return 1;
}
- *i = atoi (cp);
+ *i = atoi(cp);
return 0;
}
static int
-ptos (char *name, char **s)
+ptos(char *name, char **s)
{
char c, *cp;
if (*parptr++ != '=') {
- advise (NULL, "missing argument to variable %s", name);
+ advise(NULL, "missing argument to variable %s", name);
return 1;
}
if (*parptr != '"') {
- for (cp = parptr;
- *parptr && *parptr != ':' && *parptr != ',';
+ for (cp = parptr; *parptr && *parptr != ':' && *parptr != ',';
parptr++)
continue;
} else {
}
c = *parptr;
*parptr = 0;
- *s = getcpy (cp);
+ *s = getcpy(cp);
if ((*parptr = c) == '"')
parptr++;
return 0;
static char *
-parse (void)
+parse(void)
{
int c;
char *cp;
for (cp = result; *parptr && (cp - result < NAMESZ); parptr++) {
c = *parptr;
- if (isalnum (c)
+ if (isalnum(c)
|| c == '.'
|| c == '-'
|| c == '_'
- || c =='['
+ || c == '['
|| c == ']')
*cp++ = c;
else
static void
-process (char *folder, char *fname, int ofilen, int ofilec)
+process(char *folder, char *fname, int ofilen, int ofilec)
{
char *cp = NULL;
FILE *fp = NULL;
struct mcomp *c1;
- switch (setjmp (env)) {
+ switch (setjmp(env)) {
case OK:
if (fname) {
- fp = mhl_action ? (*mhl_action) (fname) : fopen (fname, "r");
+ fp = mhl_action ? (*mhl_action) (fname) :
+ fopen(fname, "r");
if (fp == NULL) {
- advise (fname, "unable to open");
+ advise(fname, "unable to open");
exitstat++;
return;
}
fname = "(stdin)";
fp = stdin;
}
- cp = folder ? concat (folder, ":", fname, NULL) : getcpy (fname);
+ cp = folder ? concat(folder, ":", fname, NULL) :
+ getcpy(fname);
if (ontty != PITTY)
- SIGNAL (SIGINT, intrser);
- mhlfile (fp, cp, ofilen, ofilec); /* FALL THROUGH! */
+ SIGNAL(SIGINT, intrser);
+ mhlfile(fp, cp, ofilen, ofilec); /* FALL THROUGH! */
default:
if (ontty != PITTY)
- SIGNAL (SIGINT, SIG_IGN);
+ SIGNAL(SIGINT, SIG_IGN);
if (mhl_action == NULL && fp != stdin)
- fclose (fp);
- free (cp);
+ fclose(fp);
+ free(cp);
if (holder.c_text) {
- free (holder.c_text);
+ free(holder.c_text);
holder.c_text = NULL;
}
- free_queue (&msghd, &msgtl);
+ free_queue(&msghd, &msgtl);
for (c1 = fmthd; c1; c1 = c1->c_next)
c1->c_flags &= ~HDROUTPUT;
break;
static void
-mhlfile (FILE *fp, char *mname, int ofilen, int ofilec)
+mhlfile(FILE *fp, char *mname, int ofilen, int ofilec)
{
int state;
struct mcomp *c1, *c2, *c3;
if (forwall) {
if (digest)
- printf ("%s", ofilen == 1 ? delim3 : delim4);
+ printf("%s", ofilen == 1 ? delim3 : delim4);
else {
- printf ("\n-------");
+ printf("\n-------");
if (ofilen == 1)
- printf (" Forwarded Message%s", ofilec > 1 ? "s" : "");
+ printf(" Forwarded Message%s",
+ ofilec > 1 ? "s" : "");
else
- printf (" Message %d", ofilen);
- printf ("\n\n");
+ printf(" Message %d", ofilen);
+ printf("\n\n");
}
} else {
switch (ontty) {
if (ofilec > 1) {
if (ofilen > 1) {
if ((global.c_flags & CLEARSCR))
- clear_screen ();
+ clear_screen();
else
- printf ("\n\n\n");
+ printf("\n\n\n");
}
- printf (">>> %s\n\n", mname);
+ printf(">>> %s\n\n", mname);
}
break;
case ISTTY:
- strncpy (buf, "\n", sizeof(buf));
+ strncpy(buf, "\n", sizeof(buf));
if (ofilec > 1) {
- if (SOprintf ("Press <return> to list \"%s\"...", mname)) {
+ if (SOprintf("Press <return> to list \"%s\"...", mname)) {
if (ofilen > 1)
- printf ("\n\n\n");
- printf ("Press <return> to list \"%s\"...", mname);
+ printf("\n\n\n");
+ printf("Press <return> to list \"%s\"...", mname);
}
- fflush (stdout);
+ fflush(stdout);
buf[0] = 0;
- read (fileno (stdout), buf, sizeof(buf));
+ read(fileno(stdout), buf, sizeof(buf));
}
if (strchr(buf, '\n')) {
if ((global.c_flags & CLEARSCR))
- clear_screen ();
+ clear_screen();
}
else
- printf ("\n");
+ printf("\n");
break;
default:
if (ofilec > 1) {
if (ofilen > 1) {
- printf ("\n\n\n");
+ printf("\n\n\n");
if (clearflg > 0)
- clear_screen ();
+ clear_screen();
}
- printf (">>> %s\n\n", mname);
+ printf(">>> %s\n\n", mname);
}
break;
}
}
for (state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ switch (state = m_getfld(state, name, buf, sizeof(buf), fp)) {
case FLD:
case FLDPLUS:
for (ip = ignores; *ip; ip++)
- if (!mh_strcasecmp (name, *ip)) {
+ if (!mh_strcasecmp(name, *ip)) {
while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ state = m_getfld(state, name, buf, sizeof(buf), fp);
break;
}
if (*ip)
continue;
for (c2 = fmthd; c2; c2 = c2->c_next)
- if (!mh_strcasecmp (c2->c_name, name))
+ if (!mh_strcasecmp(c2->c_name, name))
break;
c1 = NULL;
if (!((c3 = c2 ? c2 : &global)->c_flags & SPLIT))
for (c1 = msghd; c1; c1 = c1->c_next)
- if (!mh_strcasecmp (c1->c_name, c3->c_name)) {
- c1->c_text =
- mcomp_add (c1->c_flags, buf, c1->c_text);
+ if (!mh_strcasecmp(c1->c_name, c3->c_name)) {
+ c1->c_text = mcomp_add (c1->c_flags, buf, c1->c_text);
break;
}
if (c1 == NULL)
- c1 = add_queue (&msghd, &msgtl, name, buf, 0);
+ c1 = add_queue(&msghd, &msgtl, name, buf, 0);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
- c1->c_text = add (buf, c1->c_text);
+ state = m_getfld(state, name, buf, sizeof(buf), fp);
+ c1->c_text = add(buf, c1->c_text);
}
if (c2 == NULL)
c1->c_flags |= EXTRA;
row = column = 0;
for (c1 = fmthd; c1; c1 = c1->c_next) {
if (c1->c_flags & CLEARTEXT) {
- putcomp (c1, c1, ONECOMP);
+ putcomp(c1, c1, ONECOMP);
continue;
}
- if (!mh_strcasecmp (c1->c_name, "messagename")) {
- holder.c_text = concat ("(Message ", mname, ")\n",
+ if (!mh_strcasecmp(c1->c_name, "messagename")) {
+ holder.c_text = concat("(Message ", mname, ")\n",
NULL);
- putcomp (c1, &holder, ONECOMP);
- free (holder.c_text);
+ putcomp(c1, &holder, ONECOMP);
+ free(holder.c_text);
holder.c_text = NULL;
continue;
}
- if (!mh_strcasecmp (c1->c_name, "extras")) {
+ if (!mh_strcasecmp(c1->c_name, "extras")) {
for (c2 = msghd; c2; c2 = c2->c_next)
if (c2->c_flags & EXTRA)
- putcomp (c1, c2, TWOCOMP);
+ putcomp(c1, c2, TWOCOMP);
continue;
}
- if (dobody && !mh_strcasecmp (c1->c_name, "body")) {
- holder.c_text = mh_xmalloc (sizeof(buf));
- strncpy (holder.c_text, buf, sizeof(buf));
+ if (dobody && !mh_strcasecmp(c1->c_name, "body")) {
+ holder.c_text = mh_xmalloc(sizeof(buf));
+ strncpy(holder.c_text, buf, sizeof(buf));
while (state == BODY) {
- putcomp (c1, &holder, BODYCOMP);
- state = m_getfld (state, name, holder.c_text,
- sizeof(buf), fp);
+ putcomp(c1, &holder, BODYCOMP);
+ state = m_getfld(state, name, holder.c_text, sizeof(buf), fp);
}
- free (holder.c_text);
+ free(holder.c_text);
holder.c_text = NULL;
continue;
}
for (c2 = msghd; c2; c2 = c2->c_next)
- if (!mh_strcasecmp (c2->c_name, c1->c_name)) {
- putcomp (c1, c2, ONECOMP);
+ if (!mh_strcasecmp(c2->c_name, c1->c_name)) {
+ putcomp(c1, c2, ONECOMP);
if (!(c1->c_flags & SPLIT))
break;
}
for (c2 = msghd; c2; c2 = c2->c_next)
if (c2->c_flags & FACEDFLT) {
if (c2->c_face == NULL)
- face_format (c2);
+ face_format(c2);
if ((holder.c_text = c2->c_face)) {
- putcomp (c1, &holder, ONECOMP);
+ putcomp(c1, &holder, ONECOMP);
holder.c_text = NULL;
}
break;
case LENERR:
case FMTERR:
- advise (NULL, "format error in message %s", mname);
+ advise(NULL, "format error in message %s",
+ mname);
exitstat++;
return;
default:
- adios (NULL, "getfld() returned %d", state);
+ adios(NULL, "getfld() returned %d", state);
}
}
}
static int
-mcomp_flags (char *name)
+mcomp_flags(char *name)
{
struct pair *ap;
for (ap = pairs; ap->p_name; ap++)
- if (!mh_strcasecmp (ap->p_name, name))
+ if (!mh_strcasecmp(ap->p_name, name))
return (ap->p_flags);
return 0;
static char *
-mcomp_add (long flags, char *s1, char *s2)
+mcomp_add(long flags, char *s1, char *s2)
{
char *dp;
if (!(flags & ADDRFMT))
- return add (s1, s2);
+ return add(s1, s2);
- if (s2 && *(dp = s2 + strlen (s2) - 1) == '\n')
+ if (s2 && *(dp = s2 + strlen(s2) - 1) == '\n')
*dp = 0;
- return add (s1, add (",\n", s2));
+ return add(s1, add(",\n", s2));
}
static void
-mcomp_format (struct mcomp *c1, struct mcomp *c2)
+mcomp_format(struct mcomp *c1, struct mcomp *c2)
{
int dat[5];
char *ap, *cp;
dat[2] = 0;
dat[3] = sizeof(buffer) - 1;
dat[4] = 0;
- fmt_compile (c1->c_nfs, &c1->c_fmt);
+ fmt_compile(c1->c_nfs, &c1->c_fmt);
if (!(c1->c_flags & ADDRFMT)) {
- FINDCOMP (cptr, "text");
+ FINDCOMP(cptr, "text");
if (cptr)
cptr->c_text = ap;
if ((cp = strrchr(ap, '\n'))) /* drop ending newline */
if (!cp[1])
*cp = 0;
- fmt_scan (c1->c_fmt, buffer, sizeof(buffer) - 1, dat);
+ fmt_scan(c1->c_fmt, buffer, sizeof(buffer) - 1, dat);
/* Don't need to append a newline, dctime() already did */
- c2->c_text = getcpy (buffer);
+ c2->c_text = getcpy(buffer);
- free (ap);
+ free(ap);
return;
}
(q = &pq)->pq_next = NULL;
- while ((cp = getname (ap))) {
- if ((p = (struct pqpair *) calloc ((size_t) 1, sizeof(*p))) == NULL)
- adios (NULL, "unable to allocate pqpair memory");
-
- if ((mp = getm (cp, NULL, 0, AD_NAME, error)) == NULL) {
- p->pq_text = getcpy (cp);
- p->pq_error = getcpy (error);
+ while ((cp = getname(ap))) {
+ if ((p = (struct pqpair *)
+ calloc((size_t) 1, sizeof(*p))) == NULL)
+ adios(NULL, "unable to allocate pqpair memory");
+
+ if ((mp = getm(cp, NULL, 0, AD_NAME, error)) == NULL) {
+ p->pq_text = getcpy(cp);
+ p->pq_error = getcpy(error);
} else {
if ((c1->c_flags & FACEDFLT) && c2->c_face == NULL) {
char *h, *o;
if ((h = mp->m_host) == NULL)
- h = LocalName ();
- if ((o = OfficialName (h)))
+ h = LocalName();
+ if ((o = OfficialName(h)))
h = o;
- c2->c_face = concat ("address ", h, " ",
- mp->m_mbox, NULL);
+ c2->c_face = concat("address ", h, " ",
+ mp->m_mbox, NULL);
}
- p->pq_text = getcpy (mp->m_text);
- mnfree (mp);
+ p->pq_text = getcpy(mp->m_text);
+ mnfree(mp);
}
q = (q->pq_next = p);
}
for (p = pq.pq_next; p; p = q) {
- FINDCOMP (cptr, "text");
+ FINDCOMP(cptr, "text");
if (cptr)
cptr->c_text = p->pq_text;
- FINDCOMP (cptr, "error");
+ FINDCOMP(cptr, "error");
if (cptr)
cptr->c_text = p->pq_error;
- fmt_scan (c1->c_fmt, buffer, sizeof(buffer) - 1, dat);
+ fmt_scan(c1->c_fmt, buffer, sizeof(buffer) - 1, dat);
if (*buffer) {
if (c2->c_text)
- c2->c_text = add (",\n", c2->c_text);
- if (*(cp = buffer + strlen (buffer) - 1) == '\n')
+ c2->c_text = add(",\n", c2->c_text);
+ if (*(cp = buffer + strlen(buffer) - 1) == '\n')
*cp = 0;
- c2->c_text = add (buffer, c2->c_text);
+ c2->c_text = add(buffer, c2->c_text);
}
- free (p->pq_text);
+ free(p->pq_text);
if (p->pq_error)
- free (p->pq_error);
+ free(p->pq_error);
q = p->pq_next;
- free ((char *) p);
+ free((char *) p);
}
- c2->c_text = add ("\n", c2->c_text);
+ c2->c_text = add("\n", c2->c_text);
free (ap);
}
static struct mcomp *
-add_queue (struct mcomp **head, struct mcomp **tail, char *name,
- char *text, int flags)
+add_queue(struct mcomp **head, struct mcomp **tail, char *name,
+ char *text, int flags)
{
struct mcomp *c1;
- if ((c1 = (struct mcomp *) calloc ((size_t) 1, sizeof(*c1))) == NULL)
- adios (NULL, "unable to allocate comp memory");
+ if ((c1 = (struct mcomp *) calloc((size_t) 1, sizeof(*c1))) == NULL)
+ adios(NULL, "unable to allocate comp memory");
c1->c_flags = flags & ~INIT;
- if ((c1->c_name = name ? getcpy (name) : NULL))
- c1->c_flags |= mcomp_flags (c1->c_name);
- c1->c_text = text ? getcpy (text) : NULL;
+ if ((c1->c_name = name ? getcpy(name) : NULL))
+ c1->c_flags |= mcomp_flags(c1->c_name);
+ c1->c_text = text ? getcpy(text) : NULL;
if (flags & INIT) {
if (global.c_ovtxt)
- c1->c_ovtxt = getcpy (global.c_ovtxt);
+ c1->c_ovtxt = getcpy(global.c_ovtxt);
c1->c_offset = global.c_offset;
c1->c_ovoff = global. c_ovoff;
c1->c_width = c1->c_length = 0;
static void
-free_queue (struct mcomp **head, struct mcomp **tail)
+free_queue(struct mcomp **head, struct mcomp **tail)
{
struct mcomp *c1, *c2;
for (c1 = *head; c1; c1 = c2) {
c2 = c1->c_next;
if (c1->c_name)
- free (c1->c_name);
+ free(c1->c_name);
if (c1->c_text)
- free (c1->c_text);
+ free(c1->c_text);
if (c1->c_ovtxt)
- free (c1->c_ovtxt);
+ free(c1->c_ovtxt);
if (c1->c_nfs)
- free (c1->c_nfs);
+ free(c1->c_nfs);
if (c1->c_fmt)
- free ((char *) c1->c_fmt);
+ free((char *) c1->c_fmt);
if (c1->c_face)
- free (c1->c_face);
- free ((char *) c1);
+ free(c1->c_face);
+ free((char *) c1);
}
*head = *tail = NULL;
static void
-putcomp (struct mcomp *c1, struct mcomp *c2, int flag)
+putcomp(struct mcomp *c1, struct mcomp *c2, int flag)
{
int count, cchdr;
unsigned char *cp;
llim = c1->c_length ? c1->c_length : -1;
wid = c1->c_width ? c1->c_width : global.c_width;
ovoff = (c1->c_ovoff >= 0 ? c1->c_ovoff : global.c_ovoff)
- + c1->c_offset;
+ + c1->c_offset;
if ((ovtxt = c1->c_ovtxt ? c1->c_ovtxt : global.c_ovtxt) == NULL)
ovtxt = "";
- if (wid < ovoff + strlen (ovtxt) + 5)
- adios (NULL, "component: %s width(%d) too small for overflow(%d)",
- c1->c_name, wid, ovoff + strlen (ovtxt) + 5);
+ if (wid < ovoff + strlen(ovtxt) + 5)
+ adios(NULL, "component: %s width(%d) too small for overflow(%d)", c1->c_name, wid, ovoff + strlen(ovtxt) + 5);
onelp = NULL;
if (c1->c_flags & CLEARTEXT) {
- putstr (c1->c_text);
- putstr ("\n");
+ putstr(c1->c_text);
+ putstr("\n");
return;
}
if (c1->c_flags & FACEFMT)
- switch (doface (c2)) {
+ switch (doface(c2)) {
case NOTOK: /* error */
case OK: /* async faceproc */
return;
}
if (c1->c_nfs && (c1->c_flags & (ADDRFMT | DATEFMT | FORMAT)))
- mcomp_format (c1, c2);
+ mcomp_format(c1, c2);
if (c1->c_flags & CENTER) {
count = (c1->c_width ? c1->c_width : global.c_width)
- - c1->c_offset - strlen (c2->c_text);
+ - c1->c_offset - strlen(c2->c_text);
if (!(c1->c_flags & HDROUTPUT) && !(c1->c_flags & NOCOMPONENT))
- count -= strlen (c1->c_text ? c1->c_text : c1->c_name) + 2;
+ count -= strlen(c1->c_text ? c1->c_text : c1->c_name)
+ + 2;
lm = c1->c_offset + (count / 2);
} else {
if (c1->c_offset)
if (!(c1->c_flags & HDROUTPUT) && !(c1->c_flags & NOCOMPONENT)) {
if (c1->c_flags & UPPERCASE) /* uppercase component also */
for (cp = (c1->c_text ? c1->c_text : c1->c_name); *cp; cp++)
- if (islower (*cp))
- *cp = toupper (*cp);
- putstr (c1->c_text ? c1->c_text : c1->c_name);
+ if (islower(*cp))
+ *cp = toupper(*cp);
+ putstr(c1->c_text ? c1->c_text : c1->c_name);
if (flag != BODYCOMP) {
- putstr (": ");
+ putstr(": ");
if (!(c1->c_flags & SPLIT))
c1->c_flags |= HDROUTPUT;
cchdr++;
if ((count = c1->c_cwidth -
- strlen (c1->c_text ? c1->c_text : c1->c_name) - 2) > 0)
+ strlen(c1->c_text ? c1->c_text : c1->c_name) - 2) > 0)
while (count--)
- putstr (" ");
+ putstr(" ");
} else
c1->c_flags |= HDROUTPUT; /* for BODYCOMP */
}
&& !(c2->c_flags & NOCOMPONENT)) {
if (c1->c_flags & UPPERCASE)
for (cp = c2->c_name; *cp; cp++)
- if (islower (*cp))
- *cp = toupper (*cp);
- putstr (c2->c_name);
- putstr (": ");
+ if (islower(*cp))
+ *cp = toupper(*cp);
+ putstr(c2->c_name);
+ putstr(": ");
if (!(c1->c_flags & SPLIT))
c2->c_flags |= HDROUTPUT;
cchdr++;
- if ((count = c1->c_cwidth - strlen (c2->c_name) - 2) > 0)
+ if ((count = c1->c_cwidth - strlen(c2->c_name) - 2) > 0)
while (count--)
- putstr (" ");
+ putstr(" ");
}
if (c1->c_flags & UPPERCASE)
for (cp = c2->c_text; *cp; cp++)
- if (islower (*cp))
- *cp = toupper (*cp);
+ if (islower(*cp))
+ *cp = toupper(*cp);
count = 0;
if (cchdr) {
if (flag == TWOCOMP)
- count = (c1->c_cwidth >= 0) ? c1->c_cwidth
- : strlen (c2->c_name) + 2;
+ count = (c1->c_cwidth >= 0) ?
+ c1->c_cwidth : strlen(c2->c_name) + 2;
else
- count = (c1->c_cwidth >= 0) ? c1->c_cwidth
- : strlen (c1->c_text ? c1->c_text : c1->c_name) + 2;
+ count = (c1->c_cwidth >= 0) ?
+ c1->c_cwidth : strlen(c1->c_text ?
+ c1->c_text : c1->c_name) + 2;
}
count += c1->c_offset;
- if ((cp = oneline (c2->c_text, c1->c_flags)))
+ if ((cp = oneline(c2->c_text, c1->c_flags)))
putstr(cp);
if (term == '\n')
- putstr ("\n");
- while ((cp = oneline (c2->c_text, c1->c_flags))) {
+ putstr("\n");
+ while ((cp = oneline(c2->c_text, c1->c_flags))) {
lm = count;
if (flag == BODYCOMP && !(c1->c_flags & NOCOMPONENT))
- putstr (c1->c_text ? c1->c_text : c1->c_name);
+ putstr(c1->c_text ? c1->c_text : c1->c_name);
if (*cp)
- putstr (cp);
+ putstr(cp);
if (term == '\n')
- putstr ("\n");
+ putstr("\n");
}
if (flag == BODYCOMP && term == '\n')
c1->c_flags &= ~HDROUTPUT; /* Buffer ended on a newline */
static char *
-oneline (char *stuff, long flags)
+oneline(char *stuff, long flags)
{
int spc;
char *cp, *ret;
term = 0;
if (flags & COMPRESS) {
for (spc = 1, cp = ret; *onelp; onelp++)
- if (isspace (*onelp)) {
- if (*onelp == '\n' && (!onelp[1] || (flags & ADDRFMT))) {
+ if (isspace(*onelp)) {
+ if (*onelp == '\n' &&
+ (!onelp[1] ||
+ (flags & ADDRFMT))) {
term = '\n';
*onelp++ = 0;
break;
static void
-putstr (char *string)
+putstr(char *string)
{
if (!column && lm > 0) {
while (lm > 0)
if (lm >= 8) {
- putch ('\t');
+ putch('\t');
lm -= 8;
} else {
- putch (' ');
+ putch(' ');
lm--;
}
}
lm = 0;
while (*string)
- putch (*string++);
+ putch(*string++);
}
static void
-putch (char ch)
+putch(char ch)
{
char buf[BUFSIZ];
if (ontty != ISTTY || row != global.c_length)
break;
if (global.c_flags & BELL)
- putchar ('\007');
- fflush (stdout);
+ putchar('\007');
+ fflush(stdout);
buf[0] = 0;
- read (fileno (stdout), buf, sizeof(buf));
+ read(fileno(stdout), buf, sizeof(buf));
if (strchr(buf, '\n')) {
if (global.c_flags & CLEARSCR)
- clear_screen ();
+ clear_screen();
row = 0;
} else {
- putchar ('\n');
+ putchar('\n');
row = global.c_length / 3;
}
return;
** column contains a dash, then add a dash and a space.
*/
if (column == 0 && forwflg && (dashstuff >= 0) && ch == '-') {
- putchar ('-');
- putchar (' ');
+ putchar('-');
+ putchar(' ');
}
if (ch >= ' ')
column++;
}
if (column >= wid) {
- putch ('\n');
+ putch('\n');
if (ovoff > 0)
lm = ovoff;
- putstr (ovtxt ? ovtxt : "");
- putch (ch);
+ putstr(ovtxt ? ovtxt : "");
+ putch(ch);
return;
}
- putchar (ch);
+ putchar(ch);
}
static RETSIGTYPE
-intrser (int i)
+intrser(int i)
{
#ifndef RELIABLE_SIGNALS
- SIGNAL (SIGINT, intrser);
+ SIGNAL(SIGINT, intrser);
#endif
- discard (stdout);
- putchar ('\n');
- longjmp (env, DONE);
+ discard(stdout);
+ putchar('\n');
+ longjmp(env, DONE);
}
static RETSIGTYPE
-pipeser (int i)
+pipeser(int i)
{
#ifndef RELIABLE_SIGNALS
- SIGNAL (SIGPIPE, pipeser);
+ SIGNAL(SIGPIPE, pipeser);
#endif
- done (NOTOK);
+ done(NOTOK);
}
static RETSIGTYPE
-quitser (int i)
+quitser(int i)
{
#ifndef RELIABLE_SIGNALS
- SIGNAL (SIGQUIT, quitser);
+ SIGNAL(SIGQUIT, quitser);
#endif
- putchar ('\n');
- fflush (stdout);
- done (NOTOK);
+ putchar('\n');
+ fflush(stdout);
+ done(NOTOK);
}
static void
-face_format (struct mcomp *c1)
+face_format(struct mcomp *c1)
{
char *cp;
struct mailname *mp;
if ((cp = c1->c_text) == NULL)
return;
- if ((cp = getname (cp))) {
- if ((mp = getm (cp, NULL, 0, AD_NAME, NULL))) {
+ if ((cp = getname(cp))) {
+ if ((mp = getm(cp, NULL, 0, AD_NAME, NULL))) {
char *h, *o;
if ((h = mp->m_host) == NULL)
- h = LocalName ();
- if ((o = OfficialName (h)))
+ h = LocalName();
+ if ((o = OfficialName(h)))
h = o;
- c1->c_face = concat ("address ", h, " ", mp->m_mbox, NULL);
+ c1->c_face = concat("address ", h, " ", mp->m_mbox,
+ NULL);
}
- while ((cp = getname (cp)))
+ while ((cp = getname(cp)))
continue;
}
}
#endif
static int
-doface (struct mcomp *c1)
+doface(struct mcomp *c1)
{
int result, sd;
static int inited = OK;
if (inited == OK) {
char *cp;
- char **ap = brkstring (cp = getcpy (faceproc), " ", "\n");
+ char **ap = brkstring(cp = getcpy(faceproc), " ", "\n");
struct addrinfo hints, *res;
if (ap[0] == NULL || ap[1] == NULL) {
bad_faceproc: ;
- free (cp);
+ free(cp);
return (inited = NOTOK);
}
if (inited == NOTOK)
return NOTOK;
- if ((sd = socket (ss.ss_family, socktype, protocol)) == NOTOK)
+ if ((sd = socket(ss.ss_family, socktype, protocol)) == NOTOK)
return NOTOK;
- result = sendto (sd, c1->c_text, strlen (c1->c_text), 0,
- (struct sockaddr *) &ss, socklen);
+ result = sendto(sd, c1->c_text, strlen(c1->c_text), 0,
+ (struct sockaddr *) &ss, socklen);
- close (sd);
+ close(sd);
return (result != NOTOK ? OK : NOTOK);
}
#if 0
static int
-doface (struct mcomp *c1)
+doface(struct mcomp *c1)
{
int i, len, vecp;
pid_t child_id;
char *bp, *cp;
char buffer[BUFSIZ], *vec[10];
- if (pipe (pdi) == NOTOK)
+ if (pipe(pdi) == NOTOK)
return NOTOK;
- if (pipe (pdo) == NOTOK) {
- close (pdi[0]);
- close (pdi[1]);
+ if (pipe(pdo) == NOTOK) {
+ close(pdi[0]);
+ close(pdi[1]);
return NOTOK;
}
for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case NOTOK:
case OK:
/* child process */
- SIGNAL (SIGINT, SIG_IGN);
- SIGNAL (SIGQUIT, SIG_IGN);
- if (pdi[0] != fileno (stdin)) {
- dup2 (pdi[0], fileno (stdin));
- close (pdi[0]);
+ SIGNAL(SIGINT, SIG_IGN);
+ SIGNAL(SIGQUIT, SIG_IGN);
+ if (pdi[0] != fileno(stdin)) {
+ dup2(pdi[0], fileno(stdin));
+ close(pdi[0]);
}
- close (pdi[1]);
- close (pdo[0]);
- if (pdo[1] != fileno (stdout)) {
- dup2 (pdo[1], fileno (stdout));
- close (pdo[1]);
+ close(pdi[1]);
+ close(pdo[0]);
+ if (pdo[1] != fileno(stdout)) {
+ dup2(pdo[1], fileno(stdout));
+ close(pdo[1]);
}
vecp = 0;
- vec[vecp++] = r1bindex (faceproc, '/');
+ vec[vecp++] = r1bindex(faceproc, '/');
vec[vecp++] = "-e";
if (sleepsw != NOTOK) {
vec[vecp++] = "-s";
- snprintf (buffer, sizeof(buffer), "%d", sleepsw);
+ snprintf(buffer, sizeof(buffer), "%d",
+ sleepsw);
vec[vecp++] = buffer;
}
vec[vecp] = NULL;
- execvp (faceproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (faceproc);
- _exit (-1); /* NOTREACHED */
+ execvp(faceproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(faceproc);
+ _exit(-1); /* NOTREACHED */
default:
/* parent process */
- close (pdi[0]);
- i = strlen (c1->c_text);
- if (write (pdi[1], c1->c_text, i) != i)
- adios ("pipe", "error writing to");
- free (c1->c_text), c1->c_text = NULL;
- close (pdi[1]);
-
- close (pdo[1]);
+ close(pdi[0]);
+ i = strlen(c1->c_text);
+ if (write(pdi[1], c1->c_text, i) != i)
+ adios("pipe", "error writing to");
+ free(c1->c_text), c1->c_text = NULL;
+ close(pdi[1]);
+
+ close(pdo[1]);
cp = NULL, len = 0;
result = DONE;
- while ((i = read (pdo[0], buffer, strlen (buffer))) > 0) {
+ while ((i=read(pdo[0], buffer, strlen(buffer))) > 0) {
if (cp) {
int j;
char *dp;
- dp = mh_xrealloc (cp, (unsigned) (j = len + i));
+ dp = mh_xrealloc(cp, (unsigned) (j = len + i));
memcpy(dp + len, buffer, i);
cp = dp, len = j;
} else {
- cp = mh_xmalloc ((unsigned) i);
+ cp = mh_xmalloc((unsigned) i);
memcpy(cp, buffer, i);
len = i;
}
if (result == DONE)
for (bp = buffer + i - 1; bp >= buffer; bp--)
- if (!isascii (*bp) || iscntrl (*bp)) {
+ if (!isascii(*bp) ||
+ iscntrl(*bp)) {
result = OK;
break;
}
}
- close (pdo[0]);
+ close(pdo[0]);
/* no waiting for child... */
if (result == OK) { /* binary */
- if (write (1, cp, len) != len)
- adios ("writing", "error");
- free (cp);
+ if (write(1, cp, len) != len)
+ adios("writing", "error");
+ free(cp);
}
else /* empty */
if ((c1->c_text = cp) == NULL)
int
-mhlsbr (int argc, char **argv, FILE *(*action)())
+mhlsbr(int argc, char **argv, FILE *(*action)())
{
SIGNAL_HANDLER istat = NULL, pstat = NULL, qstat = NULL;
char *cp = NULL;
struct mcomp *c1;
- switch (setjmp (mhlenv)) {
+ switch (setjmp(mhlenv)) {
case OK:
cp = invo_name;
sleepsw = 0; /* XXX */
** 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)
- SIGNAL (SIGQUIT, qstat);
- pstat = SIGNAL (SIGPIPE, pipeser);
- mhl (argc, argv); /* FALL THROUGH! */
+ if ((istat = SIGNAL(SIGINT, SIG_IGN)) != SIG_DFL)
+ SIGNAL(SIGINT, istat);
+ if ((qstat = SIGNAL(SIGQUIT, SIG_IGN)) != SIG_DFL)
+ SIGNAL(SIGQUIT, qstat);
+ pstat = SIGNAL(SIGPIPE, pipeser);
+ mhl(argc, argv); /* FALL THROUGH! */
default:
- SIGNAL (SIGINT, istat);
- SIGNAL (SIGQUIT, qstat);
- SIGNAL (SIGPIPE, SIG_IGN); /*
+ SIGNAL(SIGINT, istat);
+ SIGNAL(SIGQUIT, qstat);
+ SIGNAL(SIGPIPE, SIG_IGN); /*
** should probably change to block
** instead
*/
if (ontty == PITTY)
- m_pclose ();
- SIGNAL (SIGPIPE, pstat);
+ m_pclose();
+ SIGNAL(SIGPIPE, pstat);
invo_name = cp;
if (holder.c_text) {
- free (holder.c_text);
+ free(holder.c_text);
holder.c_text = NULL;
}
- free_queue (&msghd, &msgtl);
+ free_queue(&msghd, &msgtl);
for (c1 = fmthd; c1; c1 = c1->c_next)
c1->c_flags &= ~HDROUTPUT;
return exitstat;
#undef done
static void
-mhladios (char *what, char *fmt, ...)
+mhladios(char *what, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- advertise (what, NULL, fmt, ap);
+ advertise(what, NULL, fmt, ap);
va_end(ap);
- mhldone (1);
+ mhldone(1);
}
static void
-mhldone (int status)
+mhldone(int status)
{
exitstat = status;
if (mhl_action)
- longjmp (mhlenv, DONE);
+ longjmp(mhlenv, DONE);
else
- done (exitstat);
+ done(exitstat);
}
static int sd = NOTOK;
static void
-m_popen (char *name)
+m_popen(char *name)
{
int pd[2];
- if (mhl_action && (sd = dup (fileno (stdout))) == NOTOK)
- adios ("standard output", "unable to dup()");
+ if (mhl_action && (sd = dup(fileno(stdout))) == NOTOK)
+ adios("standard output", "unable to dup()");
- if (pipe (pd) == NOTOK)
- adios ("pipe", "unable to");
+ if (pipe(pd) == NOTOK)
+ adios("pipe", "unable to");
- switch (m_pid = vfork ()) {
+ switch (m_pid = vfork()) {
case NOTOK:
- adios ("fork", "unable to");
+ adios("fork", "unable to");
case OK:
- SIGNAL (SIGINT, SIG_DFL);
- SIGNAL (SIGQUIT, SIG_DFL);
+ SIGNAL(SIGINT, SIG_DFL);
+ SIGNAL(SIGQUIT, SIG_DFL);
- close (pd[1]);
- if (pd[0] != fileno (stdin)) {
- dup2 (pd[0], fileno (stdin));
- close (pd[0]);
+ close(pd[1]);
+ if (pd[0] != fileno(stdin)) {
+ dup2(pd[0], fileno(stdin));
+ close(pd[0]);
}
- execlp (name, r1bindex (name, '/'), NULL);
- fprintf (stderr, "unable to exec ");
- perror (name);
- _exit (-1);
+ execlp(name, r1bindex(name, '/'), NULL);
+ fprintf(stderr, "unable to exec ");
+ perror(name);
+ _exit(-1);
default:
- close (pd[0]);
- if (pd[1] != fileno (stdout)) {
- dup2 (pd[1], fileno (stdout));
- close (pd[1]);
+ close(pd[0]);
+ if (pd[1] != fileno(stdout)) {
+ dup2(pd[1], fileno(stdout));
+ close(pd[1]);
}
}
}
void
-m_pclose (void)
+m_pclose(void)
{
if (m_pid == NOTOK)
return;
if (sd != NOTOK) {
- fflush (stdout);
- if (dup2 (sd, fileno (stdout)) == NOTOK)
- adios ("standard output", "unable to dup2()");
+ fflush(stdout);
+ if (dup2(sd, fileno(stdout)) == NOTOK)
+ adios("standard output", "unable to dup2()");
- clearerr (stdout);
- close (sd);
+ clearerr(stdout);
+ close(sd);
sd = NOTOK;
}
else
- fclose (stdout);
+ fclose(stdout);
- pidwait (m_pid, OK);
+ pidwait(m_pid, OK);
m_pid = NOTOK;
}
/*
** static prototypes
*/
-static RETSIGTYPE intrser (int);
+static RETSIGTYPE intrser(int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
pid_t child_id;
int status, i, iscc = 0, nvec;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* foil search of user profile/context */
- if (context_foil (NULL) == -1)
- done (1);
+ if (context_foil(NULL) == -1)
+ done(1);
/* If no arguments, just incorporate new mail */
if (argc == 1) {
- execlp (incproc, r1bindex (incproc, '/'), NULL);
- adios (incproc, "unable to exec");
+ execlp(incproc, r1bindex(incproc, '/'), NULL);
+ adios(incproc, "unable to exec");
}
- arguments = getarguments (invo_name, argc, argv, 0);
+ arguments = getarguments(invo_name, argc, argv, 0);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [addrs ... [switches]]",
- invo_name);
- print_help (buf, switches, 0);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [addrs ... [switches]]", invo_name);
+ print_help(buf, switches, 0);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case FROMSW:
if (!(from = *argp++) || *from == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case BODYSW:
if (!(body = *argp++) || *body == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case CCSW:
case SUBJSW:
if (!(subject = *argp++) || *subject == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case RESNDSW:
}
}
if (iscc)
- cclist = cclist ? add (cp, add (", ", cclist)) : getcpy (cp);
+ cclist = cclist ? add(cp, add(", ", cclist)) :
+ getcpy(cp);
else
- tolist = tolist ? add (cp, add (", ", tolist)) : getcpy (cp);
+ tolist = tolist ? add(cp, add(", ", tolist)) :
+ getcpy(cp);
}
if (tolist == NULL)
- adios (NULL, "usage: %s addrs ... [switches]", invo_name);
+ adios(NULL, "usage: %s addrs ... [switches]", invo_name);
tfile = m_mktemp2(NULL, invo_name, NULL, &out);
- if (tfile == NULL) adios("mhmail", "unable to create temporary file");
+ if (tfile == NULL)
+ adios("mhmail", "unable to create temporary file");
chmod(tfile, 0600);
- strncpy (tmpfil, tfile, sizeof(tmpfil));
+ strncpy(tmpfil, tfile, sizeof(tmpfil));
- SIGNAL2 (SIGINT, intrser);
+ SIGNAL2(SIGINT, intrser);
- fprintf (out, "%sTo: %s\n", resent ? "Resent-" : "", tolist);
+ fprintf(out, "%sTo: %s\n", resent ? "Resent-" : "", tolist);
if (cclist)
- fprintf (out, "%scc: %s\n", resent ? "Resent-" : "", cclist);
+ fprintf(out, "%scc: %s\n", resent ? "Resent-" : "", cclist);
if (subject)
- fprintf (out, "%sSubject: %s\n", resent ? "Resent-" : "", subject);
+ fprintf(out, "%sSubject: %s\n", resent ? "Resent-" : "", subject);
if (from)
- fprintf (out, "%sFrom: %s\n", resent ? "Resent-" : "", from);
+ fprintf(out, "%sFrom: %s\n", resent ? "Resent-" : "", from);
if (!resent)
- fputs ("\n", out);
+ fputs("\n", out);
if (body) {
- fprintf (out, "%s", body);
- if (*body && *(body + strlen (body) - 1) != '\n')
- fputs ("\n", out);
+ fprintf(out, "%s", body);
+ if (*body && *(body + strlen(body) - 1) != '\n')
+ fputs("\n", out);
} else {
- for (somebody = 0;
- (i = fread (buf, sizeof(*buf), sizeof(buf),
- stdin)) > 0;
- somebody++)
- if (fwrite (buf, sizeof(*buf), i, out) != i)
- adios (tmpfil, "error writing");
+ for (somebody = 0; (i = fread(buf, sizeof(*buf), sizeof(buf),
+ stdin)) > 0; somebody++)
+ if (fwrite(buf, sizeof(*buf), i, out) != i)
+ adios(tmpfil, "error writing");
if (!somebody) {
- unlink (tmpfil);
- done (1);
+ unlink(tmpfil);
+ done(1);
}
}
- fclose (out);
+ fclose(out);
nvec = 0;
- vec[nvec++] = r1bindex (postproc, '/');
+ vec[nvec++] = r1bindex(postproc, '/');
vec[nvec++] = tmpfil;
if (resent)
vec[nvec++] = "-dist";
vec[nvec] = NULL;
for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
- sleep (5);
+ sleep(5);
if (child_id == NOTOK) {
/* report failure and then send it */
- adios (NULL, "unable to fork");
+ adios(NULL, "unable to fork");
} else if (child_id) {
/* parent process */
if ((status = pidXwait(child_id, postproc))) {
- fprintf (stderr, "Letter saved in dead.letter\n");
- execl ("/bin/mv", "mv", tmpfil, "dead.letter", NULL);
- execl ("/usr/bin/mv", "mv", tmpfil, "dead.letter", NULL);
- perror ("mv");
- _exit (-1);
+ fprintf(stderr, "Letter saved in dead.letter\n");
+ execl("/bin/mv", "mv", tmpfil, "dead.letter", NULL);
+ execl("/usr/bin/mv", "mv", tmpfil, "dead.letter",
+ NULL);
+ perror("mv");
+ _exit(-1);
}
- unlink (tmpfil);
- done (status ? 1 : 0);
+ unlink(tmpfil);
+ done(status ? 1 : 0);
} else {
/* child process */
- execvp (postproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (postproc);
- _exit (-1);
+ execvp(postproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(postproc);
+ _exit(-1);
}
return 0; /* dead code to satisfy the compiler */
static RETSIGTYPE
-intrser (int i)
+intrser(int i)
{
#ifndef RELIABLE_SIGNALS
if (i)
- SIGNAL (i, SIG_IGN);
+ SIGNAL(i, SIG_IGN);
#endif
- unlink (tmpfil);
- done (i != 0 ? 1 : 0);
+ unlink(tmpfil);
+ done(i != 0 ? 1 : 0);
}
/*
** prototypes
*/
-int part_ok (CT, int);
-int type_ok (CT, int);
-void set_endian (void);
-int make_intermediates (char *);
-void content_error (char *, CT, char *, ...);
-void flush_errors (void);
+int part_ok(CT, int);
+int type_ok(CT, int);
+void set_endian(void);
+int make_intermediates(char *);
+void content_error(char *, CT, char *, ...);
+void flush_errors(void);
int
-part_ok (CT ct, int sP)
+part_ok(CT ct, int sP)
{
char **ap;
int len;
- if (npart == 0 || (ct->c_type == CT_MULTIPART && (sP || ct->c_subtype)))
+ if (npart == 0 || (ct->c_type == CT_MULTIPART &&
+ (sP || ct->c_subtype)))
return 1;
for (ap = parts; *ap; ap++) {
len = strlen(*ap);
- if (!strncmp (*ap, ct->c_partno, len) &&
- (!ct->c_partno[len] || ct->c_partno[len] == '.' ))
+ if (!strncmp(*ap, ct->c_partno, len) &&
+ (!ct->c_partno[len] ||
+ ct->c_partno[len] == '.' ))
return 1;
}
int
-type_ok (CT ct, int sP)
+type_ok(CT ct, int sP)
{
char **ap;
char buffer[BUFSIZ];
CI ci = &ct->c_ctinfo;
- if (ntype == 0 || (ct->c_type == CT_MULTIPART && (sP || ct->c_subtype)))
+ if (ntype == 0 || (ct->c_type == CT_MULTIPART &&
+ (sP || ct->c_subtype)))
return 1;
- snprintf (buffer, sizeof(buffer), "%s/%s", ci->ci_type, ci->ci_subtype);
+ snprintf(buffer, sizeof(buffer), "%s/%s", ci->ci_type, ci->ci_subtype);
for (ap = types; *ap; ap++)
- if (!mh_strcasecmp (*ap, ci->ci_type) || !mh_strcasecmp (*ap, buffer))
+ if (!mh_strcasecmp(*ap, ci->ci_type) ||
+ !mh_strcasecmp(*ap, buffer))
return 1;
return 0;
void
-set_endian (void)
+set_endian(void)
{
union {
long l;
un.l = 1;
endian = un.c[0] ? -1 : 1;
if (debugsw)
- fprintf (stderr, "%s endian architecture\n",
+ fprintf(stderr, "%s endian architecture\n",
endian > 0 ? "big" : "little");
}
int
-make_intermediates (char *file)
+make_intermediates(char *file)
{
char *cp;
struct stat st;
*cp = '\0';
- if (stat (file, &st) == NOTOK) {
+ if (stat(file, &st) == NOTOK) {
int answer;
char *ep;
if (errno != ENOENT) {
- advise (file, "error on directory");
+ advise(file, "error on directory");
losing_directory:
*cp = '/';
return NOTOK;
}
- ep = concat ("Create directory \"", file, "\"? ", NULL);
- answer = getanswer (ep);
- free (ep);
+ ep = concat("Create directory \"", file, "\"? ", NULL);
+ answer = getanswer(ep);
+ free(ep);
if (!answer)
goto losing_directory;
- if (!makedir (file)) {
- advise (NULL, "unable to create directory %s", file);
+ if (!makedir(file)) {
+ advise(NULL, "unable to create directory %s",
+ file);
goto losing_directory;
}
}
*/
void
-content_error (char *what, CT ct, char *fmt, ...)
+content_error(char *what, CT ct, char *fmt, ...)
{
va_list arglist;
int i, len, buflen;
buflen = sizeof(buffer);
if (userrs && invo_name && *invo_name) {
- snprintf (bp, buflen, "%s: ", invo_name);
- len = strlen (bp);
+ snprintf(bp, buflen, "%s: ", invo_name);
+ len = strlen(bp);
bp += len;
buflen -= len;
}
- va_start (arglist, fmt);
+ va_start(arglist, fmt);
- vsnprintf (bp, buflen, fmt, arglist);
- len = strlen (bp);
+ vsnprintf(bp, buflen, fmt, arglist);
+ len = strlen(bp);
bp += len;
buflen -= len;
char *s;
if (*what) {
- snprintf (bp, buflen, " %s: ", what);
- len = strlen (bp);
+ snprintf(bp, buflen, " %s: ", what);
+ len = strlen(bp);
bp += len;
buflen -= len;
}
- if ((s = strerror (errno)))
- snprintf (bp, buflen, "%s", s);
+ if ((s = strerror(errno)))
+ snprintf(bp, buflen, "%s", s);
else
- snprintf (bp, buflen, "Error %d", errno);
+ snprintf(bp, buflen, "Error %d", errno);
- len = strlen (bp);
+ len = strlen(bp);
bp += len;
buflen -= len;
}
- i = strlen (invo_name) + 2;
+ i = strlen(invo_name) + 2;
/* Now add content type and subtype */
- snprintf (bp, buflen, "\n%*.*s(content %s/%s", i, i, "",
- ci->ci_type, ci->ci_subtype);
- len = strlen (bp);
+ snprintf(bp, buflen, "\n%*.*s(content %s/%s", i, i, "",
+ ci->ci_type, ci->ci_subtype);
+ len = strlen(bp);
bp += len;
buflen -= len;
/* Now add the message/part number */
if (ct->c_file) {
- snprintf (bp, buflen, " in message %s", ct->c_file);
- len = strlen (bp);
+ snprintf(bp, buflen, " in message %s", ct->c_file);
+ len = strlen(bp);
bp += len;
buflen -= len;
if (ct->c_partno) {
- snprintf (bp, buflen, ", part %s", ct->c_partno);
- len = strlen (bp);
+ snprintf(bp, buflen, ", part %s", ct->c_partno);
+ len = strlen(bp);
bp += len;
buflen -= len;
}
}
- snprintf (bp, buflen, ")");
- len = strlen (bp);
+ snprintf(bp, buflen, ")");
+ len = strlen(bp);
bp += len;
buflen -= len;
*bp = '\0';
buflen--;
- errs = add (buffer, errs);
+ errs = add(buffer, errs);
} else {
- advise (NULL, "%s", buffer);
+ advise(NULL, "%s", buffer);
}
}
void
-flush_errors (void)
+flush_errors(void)
{
if (errs) {
- fflush (stdout);
- fprintf (stderr, "%s", errs);
- free (errs);
+ fflush(stdout);
+ fprintf(stderr, "%s", errs);
+ free(errs);
errs = NULL;
}
}
/*
** prototypes
*/
-int output_message (CT, char *);
-int output_message_fp (CT, FILE *, char *);
-int writeBase64aux (FILE *, FILE *);
+int output_message(CT, char *);
+int output_message_fp(CT, FILE *, char *);
+int writeBase64aux(FILE *, FILE *);
/*
** static prototypes
*/
-static int output_content (CT, FILE *);
-static void output_headers (CT, FILE *);
-static int writeExternalBody (CT, FILE *);
-static int write8Bit (CT, FILE *);
-static int writeQuoted (CT, FILE *);
-static int writeBase64 (CT, FILE *);
+static int output_content(CT, FILE *);
+static void output_headers(CT, FILE *);
+static int writeExternalBody(CT, FILE *);
+static int write8Bit(CT, FILE *);
+static int writeQuoted(CT, FILE *);
+static int writeBase64(CT, FILE *);
/*
*/
int
-output_message_fp (CT ct, FILE *fp, char *file)
+output_message_fp(CT ct, FILE *fp, char *file)
{
- if (output_content (ct, fp) == NOTOK)
+ if (output_content(ct, fp) == NOTOK)
return NOTOK;
- if (fflush (fp)) {
- advise ((file?file:"<FILE*>"), "error writing to");
+ if (fflush(fp)) {
+ advise((file?file:"<FILE*>"), "error writing to");
return NOTOK;
}
return OK;
}
int
-output_message (CT ct, char *file)
+output_message(CT ct, char *file)
{
FILE *fp;
int status;
- if ((fp = fopen (file, "w")) == NULL) {
- advise (file, "unable to open for writing");
+ if ((fp = fopen(file, "w")) == NULL) {
+ advise(file, "unable to open for writing");
return NOTOK;
}
status = output_message_fp(ct, fp, file);
*/
static int
-output_content (CT ct, FILE *out)
+output_content(CT ct, FILE *out)
{
int result = 0;
CI ci = &ct->c_ctinfo;
/*
** Output all header fields for this content
*/
- output_headers (ct, out);
+ output_headers(ct, out);
/*
** If this is the internal content structure for a
struct part *part;
if (ct->c_rfc934)
- putc ('\n', out);
+ putc('\n', out);
m = (struct multipart *) ct->c_ctparams;
for (part = m->mp_parts; part; part = part->mp_next) {
CT p = part->mp_part;
- fprintf (out, "\n--%s\n", ci->ci_values[0]);
- if (output_content (p, out) == NOTOK)
+ fprintf(out, "\n--%s\n", ci->ci_values[0]);
+ if (output_content(p, out) == NOTOK)
return NOTOK;
}
- fprintf (out, "\n--%s--\n", ci->ci_values[0]);
+ fprintf(out, "\n--%s--\n", ci->ci_values[0]);
}
break;
case CT_MESSAGE:
- putc ('\n', out);
+ putc('\n', out);
if (ct->c_subtype == MESSAGE_EXTERNAL) {
struct exbody *e;
e = (struct exbody *) ct->c_ctparams;
- if (output_content (e->eb_content, out) == NOTOK)
+ if (output_content(e->eb_content, out) == NOTOK)
return NOTOK;
/* output phantom body for access-type "mail-server" */
if (e->eb_body)
- writeExternalBody (ct, out);
+ writeExternalBody(ct, out);
} else {
- result = write8Bit (ct, out);
+ result = write8Bit(ct, out);
}
break;
default:
switch (ct->c_encoding) {
case CE_7BIT:
- putc ('\n', out);
- result = write8Bit (ct, out);
+ putc('\n', out);
+ result = write8Bit(ct, out);
break;
case CE_8BIT:
- putc ('\n', out);
- result = write8Bit (ct, out);
+ putc('\n', out);
+ result = write8Bit(ct, out);
break;
case CE_QUOTED:
- putc ('\n', out);
- result = writeQuoted (ct, out);
+ putc('\n', out);
+ result = writeQuoted(ct, out);
break;
case CE_BASE64:
- putc ('\n', out);
- result = writeBase64 (ct, out);
+ putc('\n', out);
+ result = writeBase64(ct, out);
break;
case CE_BINARY:
- advise (NULL, "can't handle binary transfer encoding in content");
+ advise(NULL, "can't handle binary transfer encoding in content");
result = NOTOK;
break;
default:
- advise (NULL, "unknown transfer encoding in content");
+ advise(NULL, "unknown transfer encoding in content");
result = NOTOK;
break;
}
*/
static void
-output_headers (CT ct, FILE *out)
+output_headers(CT ct, FILE *out)
{
HF hp;
hp = ct->c_first_hf;
while (hp) {
- fprintf (out, "%s:%s", hp->name, hp->value);
+ fprintf(out, "%s:%s", hp->name, hp->value);
hp = hp->next;
}
}
*/
static int
-writeExternalBody (CT ct, FILE *out)
+writeExternalBody(CT ct, FILE *out)
{
char **ap, **ep, *cp;
struct exbody *e = (struct exbody *) ct->c_ctparams;
- putc ('\n', out);
+ putc('\n', out);
for (cp = e->eb_body; *cp; cp++) {
CT ct2 = e->eb_content;
CI ci2 = &ct2->c_ctinfo;
switch (*++cp) {
case 'I':
if (ct2->c_id) {
- char *dp = trimcpy (ct2->c_id);
+ char *dp = trimcpy(ct2->c_id);
- fputs (dp, out);
- free (dp);
+ fputs(dp, out);
+ free(dp);
}
continue;
case 'N':
- for (ap = ci2->ci_attrs, ep = ci2->ci_values; *ap; ap++, ep++)
- if (!mh_strcasecmp (*ap, "name")) {
- fprintf (out, "%s", *ep);
+ for (ap = ci2->ci_attrs, ep = ci2->ci_values;
+ *ap; ap++, ep++)
+ if (!mh_strcasecmp(*ap, "name")) {
+ fprintf(out, "%s", *ep);
break;
}
continue;
case 'T':
- fprintf (out, "%s/%s", ci2->ci_type, ci2->ci_subtype);
- for (ap = ci2->ci_attrs, ep = ci2->ci_values; *ap; ap++, ep++)
- fprintf (out, "; %s=\"%s\"", *ap, *ep);
+ fprintf(out, "%s/%s", ci2->ci_type,
+ ci2->ci_subtype);
+ for (ap = ci2->ci_attrs, ep = ci2->ci_values;
+ *ap; ap++, ep++)
+ fprintf(out, "; %s=\"%s\"", *ap, *ep);
continue;
case 'n':
- putc ('\n', out);
+ putc('\n', out);
continue;
case 't':
- putc ('\t', out);
+ putc('\t', out);
continue;
case '\0':
break;
default:
- putc ('\\', out);
+ putc('\\', out);
break;
}
}
- putc (*cp, out);
+ putc(*cp, out);
}
- putc ('\n', out);
+ putc('\n', out);
return OK;
}
*/
static int
-write8Bit (CT ct, FILE *out)
+write8Bit(CT ct, FILE *out)
{
int fd;
char c, *file, buffer[BUFSIZ];
return NOTOK;
c = '\n';
- while (fgets (buffer, sizeof(buffer) - 1, ce->ce_fp)) {
- c = buffer[strlen (buffer) - 1];
- fputs (buffer, out);
+ while (fgets(buffer, sizeof(buffer) - 1, ce->ce_fp)) {
+ c = buffer[strlen(buffer) - 1];
+ fputs(buffer, out);
}
if (c != '\n')
- putc ('\n', out);
+ putc('\n', out);
(*ct->c_ceclosefnx) (ct);
return OK;
*/
static int
-writeQuoted (CT ct, FILE *out)
+writeQuoted(CT ct, FILE *out)
{
int fd;
char *cp, *file;
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return NOTOK;
- while (fgets (buffer, sizeof(buffer) - 1, ce->ce_fp)) {
+ while (fgets(buffer, sizeof(buffer) - 1, ce->ce_fp)) {
int n;
- cp = buffer + strlen (buffer) - 1;
+ cp = buffer + strlen(buffer) - 1;
if ((c = *cp) == '\n')
*cp = '\0';
- if (strncmp (cp = buffer, "From ", sizeof("From ") - 1) == 0) {
- fprintf (out, "=%02X", *cp++ & 0xff);
+ if (strncmp(cp = buffer, "From ", sizeof("From ") - 1) == 0) {
+ fprintf(out, "=%02X", *cp++ & 0xff);
n = 3;
} else {
n = 0;
}
for (; *cp; cp++) {
if (n > CPERLIN - 3) {
- fputs ("=\n", out);
+ fputs("=\n", out);
n = 0;
}
switch (*cp) {
case ' ':
case '\t':
- putc (*cp, out);
+ putc(*cp, out);
n++;
break;
default:
- if (*cp < '!' || *cp > '~'
- || (ebcdicsw && !ebcdicsafe[*cp & 0xff]))
+ if (*cp < '!' || *cp > '~' || (ebcdicsw && !ebcdicsafe[*cp & 0xff]))
goto three_print;
- putc (*cp, out);
+ putc(*cp, out);
n++;
break;
case '=':
three_print:
- fprintf (out, "=%02X", *cp & 0xff);
+ fprintf(out, "=%02X", *cp & 0xff);
n += 3;
break;
}
if (c == '\n') {
if (cp > buffer && (*--cp == ' ' || *cp == '\t'))
- fputs ("=\n", out);
+ fputs("=\n", out);
- putc ('\n', out);
+ putc('\n', out);
} else {
- fputs ("=\n", out);
+ fputs("=\n", out);
}
}
*/
static int
-writeBase64 (CT ct, FILE *out)
+writeBase64(CT ct, FILE *out)
{
int fd, result;
char *file;
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return NOTOK;
- result = writeBase64aux (ce->ce_fp, out);
+ result = writeBase64aux(ce->ce_fp, out);
(*ct->c_ceclosefnx) (ct);
return result;
}
int
-writeBase64aux (FILE *in, FILE *out)
+writeBase64aux(FILE *in, FILE *out)
{
int cc, n;
char inbuf[3];
n = BPERLIN;
- while ((cc = fread (inbuf, sizeof(*inbuf), sizeof(inbuf), in)) > 0) {
+ while ((cc = fread(inbuf, sizeof(*inbuf), sizeof(inbuf), in)) > 0) {
unsigned long bits;
char *bp;
char outbuf[4];
outbuf[2] = '=';
}
- fwrite (outbuf, sizeof(*outbuf), sizeof(outbuf), out);
+ fwrite(outbuf, sizeof(*outbuf), sizeof(outbuf), out);
if (cc < sizeof(inbuf)) {
- putc ('\n', out);
+ putc('\n', out);
return OK;
}
if (--n <= 0) {
n = BPERLIN;
- putc ('\n', out);
+ putc('\n', out);
}
}
if (n != BPERLIN)
- putc ('\n', out);
+ putc('\n', out);
return OK;
}
char *cp, buf[BUFSIZ], **argp;
char **arguments, *comps[MAXARGS];
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [profile-components] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [profile-components] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case COMPSW:
components = 1;
if (components >= 0)
advise(NULL, "-%scomponents ignored with -all",
- components ? "" : "no");
+ components ? "" : "no");
/* print all entries in context/profile list */
for (np = m_defs; np; np = np->n_next)
** value (as determined after context is read).
*/
for (ps = procs; ps->p_name; ps++)
- printf ("%s: %s\n", ps->p_name,
+ printf("%s: %s\n", ps->p_name,
*ps->p_field ? *ps->p_field : "");
} else {
for (i = 0; i < compp; i++) {
register char *value;
- value = context_find (comps[i]);
+ value = context_find(comps[i]);
if (!value)
- value = p_find (comps[i]);
+ value = p_find(comps[i]);
if (value) {
if (components)
printf("%s: ", comps[i]);
}
}
- done (missed);
+ done(missed);
return 1;
}
struct proc *ps;
for (ps = procs; ps->p_name; ps++)
- if (!mh_strcasecmp (ps->p_name, str))
+ if (!mh_strcasecmp(ps->p_name, str))
return (*ps->p_field);
return NULL;
/* ftpsbr.c */
-int ftp_get (char *, char *, char *, char *, char *, char *, int, int);
+int ftp_get(char *, char *, char *, char *, char *, char *, int, int);
/* mhcachesbr.c */
-int find_cache (CT, int, int *, char *, char *, int);
+int find_cache(CT, int, int *, char *, char *, int);
/* mhmisc.c */
-int part_ok (CT, int);
-int type_ok (CT, int);
-int make_intermediates (char *);
-void content_error (char *, CT, char *, ...);
+int part_ok(CT, int);
+int type_ok(CT, int);
+int make_intermediates(char *);
+void content_error(char *, CT, char *, ...);
/* mhfree.c */
-void free_content (CT);
-void free_encoding (CT, int);
+void free_content(CT);
+void free_encoding(CT, int);
/*
** static prototypes
*/
-static CT get_content (FILE *, char *, int);
-static int get_comment (CT, unsigned char **, int);
-
-static int InitGeneric (CT);
-static int InitText (CT);
-static int InitMultiPart (CT);
-static void reverse_parts (CT);
-static int InitMessage (CT);
-static int InitApplication (CT);
-static int init_encoding (CT, OpenCEFunc);
-static unsigned long size_encoding (CT);
-static int InitBase64 (CT);
-static int openBase64 (CT, char **);
-static int InitQuoted (CT);
-static int openQuoted (CT, char **);
-static int Init7Bit (CT);
-static int openExternal (CT, CT, CE, char **, int *);
-static int InitFile (CT);
-static int openFile (CT, char **);
-static int InitFTP (CT);
-static int openFTP (CT, char **);
-static int InitMail (CT);
-static int openMail (CT, char **);
-static int readDigest (CT, char *);
+static CT get_content(FILE *, char *, int);
+static int get_comment(CT, unsigned char **, int);
+
+static int InitGeneric(CT);
+static int InitText(CT);
+static int InitMultiPart(CT);
+static void reverse_parts(CT);
+static int InitMessage(CT);
+static int InitApplication(CT);
+static int init_encoding(CT, OpenCEFunc);
+static unsigned long size_encoding(CT);
+static int InitBase64(CT);
+static int openBase64(CT, char **);
+static int InitQuoted(CT);
+static int openQuoted(CT, char **);
+static int Init7Bit(CT);
+static int openExternal(CT, CT, CE, char **, int *);
+static int InitFile(CT);
+static int openFile(CT, char **);
+static int InitFTP(CT);
+static int openFTP(CT, char **);
+static int InitMail(CT);
+static int openMail(CT, char **);
+static int readDigest(CT, char *);
struct str2init str2cts[] = {
{ "application", CT_APPLICATION, InitApplication },
int
-pidcheck (int status)
+pidcheck(int status)
{
if ((status & 0xff00) == 0xff00 || (status & 0x007f) != SIGQUIT)
return status;
- fflush (stdout);
- fflush (stderr);
- done (1);
+ fflush(stdout);
+ fflush(stderr);
+ done(1);
return 1;
}
** entity in the file.
*/
CT
-parse_mime (char *file)
+parse_mime(char *file)
{
int is_stdin;
char buffer[BUFSIZ];
/*
** Check if file is actually standard input
*/
- if ((is_stdin = !(strcmp (file, "-")))) {
+ if ((is_stdin = !(strcmp(file, "-")))) {
char *tfile = m_mktemp2(NULL, invo_name, NULL, &fp);
if (tfile == NULL) {
advise("mhparse", "unable to create temporary file");
return NULL;
}
- file = add (tfile, NULL);
- chmod (file, 0600);
+ file = add(tfile, NULL);
+ chmod(file, 0600);
- while (fgets (buffer, sizeof(buffer), stdin))
- fputs (buffer, fp);
- fflush (fp);
+ while (fgets(buffer, sizeof(buffer), stdin))
+ fputs(buffer, fp);
+ fflush(fp);
- if (ferror (stdin)) {
- unlink (file);
- advise ("stdin", "error reading");
+ if (ferror(stdin)) {
+ unlink(file);
+ advise("stdin", "error reading");
return NULL;
}
- if (ferror (fp)) {
- unlink (file);
- advise (file, "error writing");
+ if (ferror(fp)) {
+ unlink(file);
+ advise(file, "error writing");
return NULL;
}
- fseek (fp, 0L, SEEK_SET);
- } else if ((fp = fopen (file, "r")) == NULL) {
- advise (file, "unable to read");
+ fseek(fp, 0L, SEEK_SET);
+ } else if ((fp = fopen(file, "r")) == NULL) {
+ advise(file, "unable to read");
return NULL;
}
- if (!(ct = get_content (fp, file, 1))) {
+ if (!(ct = get_content(fp, file, 1))) {
if (is_stdin)
- unlink (file);
- advise (NULL, "unable to decode %s", file);
+ unlink(file);
+ advise(NULL, "unable to decode %s", file);
return NULL;
}
ct->c_fp = NULL;
if (ct->c_end == 0L) {
- fseek (fp, 0L, SEEK_END);
- ct->c_end = ftell (fp);
+ fseek(fp, 0L, SEEK_END);
+ ct->c_end = ftell(fp);
}
if (ct->c_ctinitfnx && (*ct->c_ctinitfnx) (ct) == NOTOK) {
- fclose (fp);
- free_content (ct);
+ fclose(fp);
+ free_content(ct);
return NULL;
}
- fclose (fp);
+ fclose(fp);
return ct;
}
*/
static CT
-get_content (FILE *in, char *file, int toplevel)
+get_content(FILE *in, char *file, int toplevel)
{
int compnum, state;
char buf[BUFSIZ], name[NAMESZ];
HF hp;
/* allocate the content structure */
- if (!(ct = (CT) calloc (1, sizeof(*ct))))
- adios (NULL, "out of memory");
+ if (!(ct = (CT) calloc(1, sizeof(*ct))))
+ adios(NULL, "out of memory");
ct->c_fp = in;
- ct->c_file = add (file, NULL);
- ct->c_begin = ftell (ct->c_fp) + 1;
+ ct->c_file = add(file, NULL);
+ ct->c_begin = ftell(ct->c_fp) + 1;
/*
** 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)) {
+ switch (state = m_getfld(state, name, buf, sizeof(buf), in)) {
case FLD:
case FLDPLUS:
case FLDEOF:
compnum++;
/* get copies of the buffers */
- np = add (name, NULL);
- vp = add (buf, NULL);
+ np = add(name, NULL);
+ vp = add(buf, NULL);
/* 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 */
+ state = m_getfld(state, name, buf,
+ sizeof(buf), in);
+ vp = add(buf, vp); /* add to previous value */
}
/* Now add the header data to the list */
- add_header (ct, np, vp);
+ add_header(ct, np, vp);
/* continue, if this isn't the last header field */
if (state != FLDEOF) {
- ct->c_begin = ftell (in) + 1;
+ ct->c_begin = ftell(in) + 1;
continue;
}
/* else fall... */
case BODY:
case BODYEOF:
- ct->c_begin = ftell (in) - strlen (buf);
+ ct->c_begin = ftell(in) - strlen(buf);
break;
case FILEEOF:
- ct->c_begin = ftell (in);
+ ct->c_begin = ftell(in);
break;
case LENERR:
case FMTERR:
- adios (NULL, "message format error in component #%d", compnum);
+ adios(NULL, "message format error in component #%d",
+ compnum);
default:
- adios (NULL, "getfld() returned %d", state);
+ adios(NULL, "getfld() returned %d", state);
}
/* break out of the loop */
hp = ct->c_first_hf; /* start at first header field */
while (hp) {
/* Get MIME-Version field */
- if (!mh_strcasecmp (hp->name, VRSN_FIELD)) {
+ if (!mh_strcasecmp(hp->name, VRSN_FIELD)) {
int ucmp;
char c;
unsigned char *cp, *dp;
if (ct->c_vrsn) {
- advise (NULL, "message %s has multiple %s: fields",
- ct->c_file, VRSN_FIELD);
+ advise(NULL, "message %s has multiple %s: fields", ct->c_file, VRSN_FIELD);
goto next_header;
}
- ct->c_vrsn = add (hp->value, NULL);
+ ct->c_vrsn = add(hp->value, NULL);
/* Now, cleanup this field */
cp = ct->c_vrsn;
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
for (dp = strchr(cp, '\n'); dp; dp = strchr(dp, '\n'))
*dp++ = ' ';
- for (dp = cp + strlen (cp) - 1; dp >= cp; dp--)
- if (!isspace (*dp))
+ for (dp = cp + strlen(cp) - 1; dp >= cp; dp--)
+ if (!isspace(*dp))
break;
*++dp = '\0';
if (debugsw)
- fprintf (stderr, "%s: %s\n", VRSN_FIELD, cp);
+ fprintf(stderr, "%s: %s\n", VRSN_FIELD, cp);
- if (*cp == '(' && get_comment (ct, &cp, 0) == NOTOK)
+ if (*cp == '(' && get_comment(ct, &cp, 0) == NOTOK)
goto out;
- for (dp = cp; istoken (*dp); dp++)
+ for (dp = cp; istoken(*dp); dp++)
continue;
c = *dp;
*dp = '\0';
- ucmp = !mh_strcasecmp (cp, VRSN_VALUE);
+ ucmp = !mh_strcasecmp(cp, VRSN_VALUE);
*dp = c;
if (!ucmp) {
- admonish (NULL, "message %s has unknown value for %s: field (%s)",
- ct->c_file, VRSN_FIELD, cp);
+ 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)) {
+ } else if (!mh_strcasecmp(hp->name, TYPE_FIELD)) {
/* Get Content-Type field */
struct str2init *s2i;
CI ci = &ct->c_ctinfo;
/* Check if we've already seen a Content-Type header */
if (ct->c_ctline) {
- advise (NULL, "message %s has multiple %s: fields",
- ct->c_file, TYPE_FIELD);
+ advise(NULL, "message %s has multiple %s: fields", ct->c_file, TYPE_FIELD);
goto next_header;
}
/* Parse the Content-Type field */
- if (get_ctinfo (hp->value, ct, 0) == NOTOK)
+ if (get_ctinfo(hp->value, ct, 0) == NOTOK)
goto out;
/*
** flag for this content type.
*/
for (s2i = str2cts; s2i->si_key; s2i++)
- if (!mh_strcasecmp (ci->ci_type, s2i->si_key))
+ if (!mh_strcasecmp(ci->ci_type, s2i->si_key))
break;
- if (!s2i->si_key && !uprf (ci->ci_type, "X-"))
+ if (!s2i->si_key && !uprf(ci->ci_type, "X-"))
s2i++;
ct->c_type = s2i->si_val;
ct->c_ctinitfnx = s2i->si_init;
- } else if (!mh_strcasecmp (hp->name, ENCODING_FIELD)) {
+ } else if (!mh_strcasecmp(hp->name, ENCODING_FIELD)) {
/* Get Content-Transfer-Encoding field */
char c;
unsigned char *cp, *dp;
** Content-Transfer-Encoding field
*/
if (ct->c_celine) {
- advise (NULL, "message %s has multiple %s: fields",
- ct->c_file, ENCODING_FIELD);
+ advise(NULL, "message %s has multiple %s: fields", ct->c_file, ENCODING_FIELD);
goto next_header;
}
/* get copy of this field */
- ct->c_celine = cp = add (hp->value, NULL);
+ ct->c_celine = cp = add(hp->value, NULL);
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
- for (dp = cp; istoken (*dp); dp++)
+ for (dp = cp; istoken(*dp); dp++)
continue;
c = *dp;
*dp = '\0';
** for this transfer encoding.
*/
for (s2i = str2ces; s2i->si_key; s2i++)
- if (!mh_strcasecmp (cp, s2i->si_key))
+ if (!mh_strcasecmp(cp, s2i->si_key))
break;
- if (!s2i->si_key && !uprf (cp, "X-"))
+ if (!s2i->si_key && !uprf(cp, "X-"))
s2i++;
*dp = c;
ct->c_encoding = s2i->si_val;
if (s2i->si_init && (*s2i->si_init) (ct) == NOTOK)
goto out;
- } else if (!mh_strcasecmp (hp->name, MD5_FIELD)) {
+ } else if (!mh_strcasecmp(hp->name, MD5_FIELD)) {
/* Get Content-MD5 field */
unsigned char *cp, *dp;
char *ep;
goto next_header;
if (ct->c_digested) {
- advise (NULL, "message %s has multiple %s: fields",
- ct->c_file, MD5_FIELD);
+ advise(NULL, "message %s has multiple %s: fields", ct->c_file, MD5_FIELD);
goto next_header;
}
- ep = cp = add (hp->value, NULL); /* get a copy */
+ ep = cp = add(hp->value, NULL); /* get a copy */
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
for (dp = strchr(cp, '\n'); dp; dp = strchr(dp, '\n'))
*dp++ = ' ';
- for (dp = cp + strlen (cp) - 1; dp >= cp; dp--)
- if (!isspace (*dp))
+ for (dp = cp + strlen(cp) - 1; dp >= cp; dp--)
+ if (!isspace(*dp))
break;
*++dp = '\0';
if (debugsw)
- fprintf (stderr, "%s: %s\n", MD5_FIELD, cp);
+ fprintf(stderr, "%s: %s\n", MD5_FIELD, cp);
- if (*cp == '(' && get_comment (ct, &cp, 0) == NOTOK) {
- free (ep);
+ if (*cp == '(' && get_comment(ct, &cp, 0) == NOTOK) {
+ free(ep);
goto out;
}
- for (dp = cp; *dp && !isspace (*dp); dp++)
+ for (dp = cp; *dp && !isspace(*dp); dp++)
continue;
*dp = '\0';
- readDigest (ct, cp);
- free (ep);
+ readDigest(ct, cp);
+ free(ep);
ct->c_digested++;
- } else if (!mh_strcasecmp (hp->name, ID_FIELD)) {
+ } else if (!mh_strcasecmp(hp->name, ID_FIELD)) {
/* Get Content-ID field */
- ct->c_id = add (hp->value, ct->c_id);
+ ct->c_id = add(hp->value, ct->c_id);
- } else if (!mh_strcasecmp (hp->name, DESCR_FIELD)) {
+ } else if (!mh_strcasecmp(hp->name, DESCR_FIELD)) {
/* Get Content-Description field */
- ct->c_descr = add (hp->value, ct->c_descr);
+ ct->c_descr = add(hp->value, ct->c_descr);
- } else if (!mh_strcasecmp (hp->name, DISPO_FIELD)) {
+ } else if (!mh_strcasecmp(hp->name, DISPO_FIELD)) {
/* Get Content-Disposition field */
- ct->c_dispo = add (hp->value, ct->c_dispo);
+ ct->c_dispo = add(hp->value, ct->c_dispo);
}
next_header:
** so default type is message/rfc822
*/
if (toplevel < 0) {
- if (get_ctinfo ("message/rfc822", ct, 0) == NOTOK)
+ if (get_ctinfo("message/rfc822", ct, 0) == NOTOK)
goto out;
ct->c_type = CT_MESSAGE;
ct->c_ctinitfnx = InitMessage;
/*
** Else default type is text/plain
*/
- if (get_ctinfo ("text/plain", ct, 0) == NOTOK)
+ if (get_ctinfo("text/plain", ct, 0) == NOTOK)
goto out;
ct->c_type = CT_TEXT;
ct->c_ctinitfnx = InitText;
/* Use default Transfer-Encoding, if necessary */
if (!ct->c_celine) {
ct->c_encoding = CE_7BIT;
- Init7Bit (ct);
+ Init7Bit(ct);
}
return ct;
out:
- free_content (ct);
+ free_content(ct);
return NULL;
}
*/
int
-add_header (CT ct, char *name, char *value)
+add_header(CT ct, char *name, char *value)
{
HF hp;
/* allocate header field structure */
- hp = mh_xmalloc (sizeof(*hp));
+ hp = mh_xmalloc(sizeof(*hp));
/* link data into header structure */
hp->name = name;
** that.
*/
static char *
-incl_name_value (unsigned char *buf, char *name, char *value) {
+incl_name_value(unsigned char *buf, char *name, char *value) {
char *newbuf = buf;
/* Assume that name is non-null. */
if (buf && value) {
- char *name_plus_equal = concat (name, "=", NULL);
+ char *name_plus_equal = concat(name, "=", NULL);
- if (! strstr (buf, name_plus_equal)) {
+ if (!strstr(buf, name_plus_equal)) {
char *insertion;
unsigned char *cp;
char *prefix, *suffix;
/* Trim trailing space, esp. newline. */
- for (cp = &buf[strlen (buf) - 1];
- cp >= buf && isspace (*cp);
- --cp) {
+ for (cp = &buf[strlen(buf) - 1];
+ cp >= buf && isspace(*cp); --cp) {
*cp = '\0';
}
- insertion = concat ("; ", name, "=", "\"", value, "\"",
+ insertion = concat("; ", name, "=", "\"", value, "\"",
NULL);
/*
** Insert at first semicolon, if any.
** If none, append to end.
*/
- prefix = add (buf, NULL);
- if ((cp = strchr (prefix, ';'))) {
- suffix = concat (cp, NULL);
+ prefix = add(buf, NULL);
+ if ((cp = strchr(prefix, ';'))) {
+ suffix = concat(cp, NULL);
*cp = '\0';
- newbuf = concat (prefix, insertion, suffix,
+ newbuf = concat(prefix, insertion, suffix,
"\n", NULL);
- free (suffix);
+ free(suffix);
} else {
/* Append to end. */
- newbuf = concat (buf, insertion, "\n", NULL);
+ newbuf = concat(buf, insertion, "\n", NULL);
}
- free (prefix);
- free (insertion);
- free (buf);
+ free(prefix);
+ free(insertion);
+ free(buf);
}
- free (name_plus_equal);
+ free(name_plus_equal);
}
return newbuf;
** of name will match filename="foo", and return foo.
*/
static char *
-extract_name_value (char *name_suffix, char *value) {
+extract_name_value(char *name_suffix, char *value) {
char *extracted_name_value = value;
- char *name_suffix_plus_quote = concat (name_suffix, "=\"", NULL);
- char *name_suffix_equals = strstr (value, name_suffix_plus_quote);
+ char *name_suffix_plus_quote = concat(name_suffix, "=\"", NULL);
+ char *name_suffix_equals = strstr(value, name_suffix_plus_quote);
char *cp;
- free (name_suffix_plus_quote);
+ free(name_suffix_plus_quote);
if (name_suffix_equals) {
char *name_suffix_begin;
/* Find first \". */
- for (cp = name_suffix_equals; *cp != '"'; ++cp) /* empty */;
+ for (cp = name_suffix_equals; *cp != '"'; ++cp)
+ ;
name_suffix_begin = ++cp;
/* Find second \". */
- for (; *cp != '"'; ++cp) /* empty */;
+ for (; *cp != '"'; ++cp)
+ ;
- extracted_name_value = mh_xmalloc (cp - name_suffix_begin + 1);
- memcpy (extracted_name_value, name_suffix_begin,
- cp - name_suffix_begin);
+ extracted_name_value = mh_xmalloc(cp - name_suffix_begin + 1);
+ memcpy(extracted_name_value, name_suffix_begin,
+ cp - name_suffix_begin);
extracted_name_value[cp - name_suffix_begin] = '\0';
}
** directives. Fills in the information of the CTinfo structure.
*/
int
-get_ctinfo (unsigned char *cp, CT ct, int magic)
+get_ctinfo(unsigned char *cp, CT ct, int magic)
{
int i;
unsigned char *dp;
CI ci;
ci = &ct->c_ctinfo;
- i = strlen (invo_name) + 2;
+ i = strlen(invo_name) + 2;
/* store copy of Content-Type line */
- cp = ct->c_ctline = add (cp, NULL);
+ cp = ct->c_ctline = add(cp, NULL);
- while (isspace (*cp)) /* trim leading spaces */
+ while (isspace(*cp)) /* trim leading spaces */
cp++;
/* change newlines to spaces */
*dp++ = ' ';
/* trim trailing spaces */
- for (dp = cp + strlen (cp) - 1; dp >= cp; dp--)
- if (!isspace (*dp))
+ for (dp = cp + strlen(cp) - 1; dp >= cp; dp--)
+ if (!isspace(*dp))
break;
*++dp = '\0';
if (debugsw)
- fprintf (stderr, "%s: %s\n", TYPE_FIELD, cp);
+ fprintf(stderr, "%s: %s\n", TYPE_FIELD, cp);
- if (*cp == '(' && get_comment (ct, &cp, 1) == NOTOK)
+ if (*cp == '(' && get_comment(ct, &cp, 1) == NOTOK)
return NOTOK;
- for (dp = cp; istoken (*dp); dp++)
+ for (dp = cp; istoken(*dp); dp++)
continue;
c = *dp, *dp = '\0';
- ci->ci_type = add (cp, NULL); /* store content type */
+ ci->ci_type = add(cp, NULL); /* store content type */
*dp = c, cp = dp;
if (!*ci->ci_type) {
- advise (NULL, "invalid %s: field in message %s (empty type)",
+ advise(NULL, "invalid %s: field in message %s (empty type)",
TYPE_FIELD, ct->c_file);
return NOTOK;
}
/* down case the content type string */
for (dp = ci->ci_type; *dp; dp++)
- if (isalpha(*dp) && isupper (*dp))
- *dp = tolower (*dp);
+ if (isalpha(*dp) && isupper(*dp))
+ *dp = tolower(*dp);
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
- if (*cp == '(' && get_comment (ct, &cp, 1) == NOTOK)
+ if (*cp == '(' && get_comment(ct, &cp, 1) == NOTOK)
return NOTOK;
if (*cp != '/') {
if (!magic)
- ci->ci_subtype = add ("", NULL);
+ ci->ci_subtype = add("", NULL);
goto magic_skip;
}
cp++;
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
- if (*cp == '(' && get_comment (ct, &cp, 1) == NOTOK)
+ if (*cp == '(' && get_comment(ct, &cp, 1) == NOTOK)
return NOTOK;
- for (dp = cp; istoken (*dp); dp++)
+ for (dp = cp; istoken(*dp); dp++)
continue;
c = *dp, *dp = '\0';
- ci->ci_subtype = add (cp, NULL); /* store the content subtype */
+ ci->ci_subtype = add(cp, NULL); /* store the content subtype */
*dp = c, cp = dp;
if (!*ci->ci_subtype) {
- advise (NULL,
- "invalid %s: field in message %s (empty subtype for \"%s\")",
- TYPE_FIELD, ct->c_file, ci->ci_type);
+ advise(NULL, "invalid %s: field in message %s (empty subtype for \"%s\")", TYPE_FIELD, ct->c_file, ci->ci_type);
return NOTOK;
}
/* down case the content subtype string */
for (dp = ci->ci_subtype; *dp; dp++)
- if (isalpha(*dp) && isupper (*dp))
- *dp = tolower (*dp);
+ if (isalpha(*dp) && isupper(*dp))
+ *dp = tolower(*dp);
magic_skip:
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
- if (*cp == '(' && get_comment (ct, &cp, 1) == NOTOK)
+ if (*cp == '(' && get_comment(ct, &cp, 1) == NOTOK)
return NOTOK;
/*
unsigned char *up;
if (ap >= ep) {
- advise (NULL,
- "too many parameters in message %s's %s: field (%d max)",
- ct->c_file, TYPE_FIELD, NPARMS);
+ advise(NULL, "too many parameters in message %s's %s: field (%d max)", ct->c_file, TYPE_FIELD, NPARMS);
return NOTOK;
}
cp++;
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
- if (*cp == '(' && get_comment (ct, &cp, 1) == NOTOK)
+ if (*cp == '(' && get_comment(ct, &cp, 1) == NOTOK)
return NOTOK;
if (*cp == 0) {
- advise (NULL,
- "extraneous trailing ';' in message %s's %s: parameter list",
- ct->c_file, TYPE_FIELD);
+ advise (NULL, "extraneous trailing ';' in message %s's %s: parameter list", ct->c_file, TYPE_FIELD);
return OK;
}
/* down case the attribute name */
- for (dp = cp; istoken (*dp); dp++)
- if (isalpha(*dp) && isupper (*dp))
- *dp = tolower (*dp);
+ for (dp = cp; istoken(*dp); dp++)
+ if (isalpha(*dp) && isupper(*dp))
+ *dp = tolower(*dp);
- for (up = dp; isspace (*dp);)
+ for (up = dp; isspace(*dp);)
dp++;
if (dp == cp || *dp != '=') {
- advise (NULL,
- "invalid parameter in message %s's %s: field\n%*.*sparameter %s (error detected at offset %d)",
- ct->c_file, TYPE_FIELD, i, i, "", cp, dp - cp);
+ advise(NULL, "invalid parameter in message %s's %s: field\n%*.*sparameter %s (error detected at offset %d)", ct->c_file, TYPE_FIELD, i, i, "", cp, dp - cp);
return NOTOK;
}
- vp = (*ap = add (cp, NULL)) + (up - cp);
+ vp = (*ap = add(cp, NULL)) + (up - cp);
*vp = '\0';
- for (dp++; isspace (*dp);)
+ for (dp++; isspace(*dp);)
dp++;
/* now add the attribute value */
switch (c = *cp++) {
case '\0':
bad_quote:
- advise (NULL,
- "invalid quoted-string in message %s's %s: field\n%*.*s(parameter %s)",
- ct->c_file, TYPE_FIELD, i, i, "", *ap);
+ advise(NULL, "invalid quoted-string in message %s's %s: field\n%*.*s(parameter %s)", ct->c_file, TYPE_FIELD, i, i, "", *ap);
return NOTOK;
case '\\':
break;
}
} else {
- for (cp = dp, dp = vp; istoken (*cp); cp++, dp++)
+ for (cp = dp, dp = vp; istoken(*cp); cp++, dp++)
continue;
*dp = '\0';
}
if (!*vp) {
- advise (NULL,
- "invalid parameter in message %s's %s: field\n%*.*s(parameter %s)",
- ct->c_file, TYPE_FIELD, i, i, "", *ap);
+ advise(NULL, "invalid parameter in message %s's %s: field\n%*.*s(parameter %s)", ct->c_file, TYPE_FIELD, i, i, "", *ap);
return NOTOK;
}
ap++;
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
- if (*cp == '(' && get_comment (ct, &cp, 1) == NOTOK)
+ if (*cp == '(' && get_comment(ct, &cp, 1) == NOTOK)
return NOTOK;
}
*/
if (magic && *cp == '<') {
if (ct->c_id) {
- free (ct->c_id);
+ free(ct->c_id);
ct->c_id = NULL;
}
if (!(dp = strchr(ct->c_id = ++cp, '>'))) {
- advise (NULL, "invalid ID in message %s", ct->c_file);
+ advise(NULL, "invalid ID in message %s", ct->c_file);
return NOTOK;
}
c = *dp;
*dp = '\0';
if (*ct->c_id)
- ct->c_id = concat ("<", ct->c_id, ">\n", NULL);
+ ct->c_id = concat("<", ct->c_id, ">\n", NULL);
else
ct->c_id = NULL;
*dp++ = c;
cp = dp;
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
}
*/
if (magic && *cp == '[') {
ct->c_descr = ++cp;
- for (dp = cp + strlen (cp) - 1; dp >= cp; dp--)
+ for (dp = cp + strlen(cp) - 1; dp >= cp; dp--)
if (*dp == ']')
break;
if (dp < cp) {
- advise (NULL, "invalid description in message %s", ct->c_file);
+ advise(NULL, "invalid description in message %s",
+ ct->c_file);
ct->c_descr = NULL;
return NOTOK;
}
c = *dp;
*dp = '\0';
if (*ct->c_descr)
- ct->c_descr = concat (ct->c_descr, "\n", NULL);
+ ct->c_descr = concat(ct->c_descr, "\n", NULL);
else
ct->c_descr = NULL;
*dp++ = c;
cp = dp;
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
}
*/
if (magic && *cp == '{') {
ct->c_dispo = ++cp;
- for (dp = cp + strlen (cp) - 1; dp >= cp; dp--)
+ for (dp = cp + strlen(cp) - 1; dp >= cp; dp--)
if (*dp == '}')
break;
if (dp < cp) {
- advise (NULL, "invalid disposition in message %s", ct->c_file);
+ advise(NULL, "invalid disposition in message %s",
+ ct->c_file);
ct->c_dispo = NULL;
return NOTOK;
}
c = *dp;
*dp = '\0';
if (*ct->c_dispo)
- ct->c_dispo = concat (ct->c_dispo, "\n", NULL);
+ ct->c_dispo = concat(ct->c_dispo, "\n", NULL);
else
ct->c_dispo = NULL;
*dp++ = c;
cp = dp;
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
}
*/
if (*cp) {
if (magic) {
- ci->ci_magic = add (cp, NULL);
+ ci->ci_magic = add(cp, NULL);
/*
** If there is a Content-Disposition header and
** 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), '/'));
+ ct->c_dispo = incl_name_value(ct->c_dispo, "filename", r1bindex(extract_name_value("name", ci->ci_magic), '/'));
} else
- advise (NULL,
- "extraneous information in message %s's %s: field\n%*.*s(%s)",
- ct->c_file, TYPE_FIELD, i, i, "", cp);
+ advise(NULL, "extraneous information in message %s's %s: field\n%*.*s(%s)", ct->c_file, TYPE_FIELD, i, i, "", cp);
}
return OK;
static int
-get_comment (CT ct, unsigned char **ap, int istype)
+get_comment(CT ct, unsigned char **ap, int istype)
{
int i;
char *bp;
switch (c = *cp++) {
case '\0':
invalid:
- advise (NULL, "invalid comment in message %s's %s: field",
+ advise(NULL, "invalid comment in message %s's %s: field",
ct->c_file, istype ? TYPE_FIELD : VRSN_FIELD);
return NOTOK;
if (istype) {
if ((dp = ci->ci_comment)) {
- ci->ci_comment = concat (dp, " ", buffer, NULL);
- free (dp);
+ ci->ci_comment = concat(dp, " ", buffer, NULL);
+ free(dp);
} else {
- ci->ci_comment = add (buffer, NULL);
+ ci->ci_comment = add(buffer, NULL);
}
}
- while (isspace (*cp))
+ while (isspace(*cp))
cp++;
*ap = cp;
*/
static int
-InitGeneric (CT ct)
+InitGeneric(CT ct)
{
return OK; /* not much to do here */
}
*/
static int
-InitText (CT ct)
+InitText(CT ct)
{
char buffer[BUFSIZ];
char *chset = NULL;
/* check for missing subtype */
if (!*ci->ci_subtype)
- ci->ci_subtype = add ("plain", ci->ci_subtype);
+ ci->ci_subtype = add("plain", ci->ci_subtype);
/* match subtype */
for (kv = SubText; kv->kv_key; kv++)
- if (!mh_strcasecmp (ci->ci_subtype, kv->kv_key))
+ if (!mh_strcasecmp(ci->ci_subtype, kv->kv_key))
break;
ct->c_subtype = kv->kv_value;
/* allocate text character set structure */
- if ((t = (struct text *) calloc (1, sizeof(*t))) == NULL)
- adios (NULL, "out of memory");
+ if ((t = (struct text *) calloc(1, sizeof(*t))) == NULL)
+ adios(NULL, "out of memory");
ct->c_ctparams = (void *) t;
/* scan for charset parameter */
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++)
- if (!mh_strcasecmp (*ap, "charset"))
+ if (!mh_strcasecmp(*ap, "charset"))
break;
/* check if content specified a character set */
if (*ap) {
/* match character set or set to CHARSET_UNKNOWN */
for (kv = Charset; kv->kv_key; kv++) {
- if (!mh_strcasecmp (*ep, kv->kv_key)) {
+ if (!mh_strcasecmp(*ep, kv->kv_key)) {
chset = *ep;
break;
}
**
** 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)))
- ct->c_termproc = getcpy (cp);
+ if (chset != NULL && !check_charset(chset, strlen(chset))) {
+ snprintf(buffer, sizeof(buffer), "%s-charset-%s",
+ invo_name, chset);
+ if ((cp = context_find(buffer)))
+ ct->c_termproc = getcpy(cp);
}
return OK;
*/
static int
-InitMultiPart (CT ct)
+InitMultiPart(CT ct)
{
int inout;
long last, pos;
*/
if (ct->c_encoding != CE_7BIT && ct->c_encoding != CE_8BIT
&& ct->c_encoding != CE_BINARY) {
- admonish (NULL,
- "\"%s/%s\" type in message %s must be encoded in 7bit, 8bit, or binary",
- ci->ci_type, ci->ci_subtype, ct->c_file);
+ admonish(NULL, "\"%s/%s\" type in message %s must be encoded in 7bit, 8bit, or binary", ci->ci_type, ci->ci_subtype, ct->c_file);
return NOTOK;
}
/* match subtype */
for (kv = SubMultiPart; kv->kv_key; kv++)
- if (!mh_strcasecmp (ci->ci_subtype, kv->kv_key))
+ if (!mh_strcasecmp(ci->ci_subtype, kv->kv_key))
break;
ct->c_subtype = kv->kv_value;
*/
bp = 0;
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
- if (!mh_strcasecmp (*ap, "boundary")) {
+ if (!mh_strcasecmp(*ap, "boundary")) {
bp = *ep;
break;
}
/* complain if boundary parameter is missing */
if (!*ap) {
- advise (NULL,
- "a \"boundary\" parameter is mandatory for \"%s/%s\" type in message %s's %s: field",
- ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD);
+ advise (NULL, "a \"boundary\" parameter is mandatory for \"%s/%s\" type in message %s's %s: field", ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD);
return NOTOK;
}
/* allocate primary structure for multipart info */
- if ((m = (struct multipart *) calloc (1, sizeof(*m))) == NULL)
- adios (NULL, "out of memory");
+ if ((m = (struct multipart *) calloc(1, sizeof(*m))) == NULL)
+ adios(NULL, "out of memory");
ct->c_ctparams = (void *) m;
/* check if boundary parameter contains only whitespace characters */
- for (cp = bp; isspace (*cp); cp++)
+ for (cp = bp; isspace(*cp); cp++)
continue;
if (!*cp) {
- advise (NULL, "invalid \"boundary\" parameter for \"%s/%s\" type in message %s's %s: field",
- ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD);
+ advise(NULL, "invalid \"boundary\" parameter for \"%s/%s\" type in message %s's %s: field", ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD);
return NOTOK;
}
/* remove trailing whitespace from boundary parameter */
- for (cp = bp, dp = cp + strlen (cp) - 1; dp > cp; dp--)
- if (!isspace (*dp))
+ for (cp = bp, dp = cp + strlen(cp) - 1; dp > cp; dp--)
+ if (!isspace(*dp))
break;
*++dp = '\0';
/* record boundary separators */
- m->mp_start = concat (bp, "\n", NULL);
- m->mp_stop = concat (bp, "--\n", NULL);
+ m->mp_start = concat(bp, "\n", NULL);
+ m->mp_stop = concat(bp, "--\n", NULL);
- if (!ct->c_fp && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
- advise (ct->c_file, "unable to open for reading");
+ if (!ct->c_fp && (ct->c_fp = fopen(ct->c_file, "r")) == NULL) {
+ advise(ct->c_file, "unable to open for reading");
return NOTOK;
}
- fseek (fp = ct->c_fp, pos = ct->c_begin, SEEK_SET);
+ fseek(fp = ct->c_fp, pos = ct->c_begin, SEEK_SET);
last = ct->c_end;
next = &m->mp_parts;
part = NULL;
inout = 1;
- while (fgets (buffer, sizeof(buffer) - 1, fp)) {
+ while (fgets(buffer, sizeof(buffer) - 1, fp)) {
if (pos > last)
break;
- pos += strlen (buffer);
+ pos += strlen(buffer);
if (buffer[0] != '-' || buffer[1] != '-')
continue;
if (inout) {
- if (strcmp (buffer + 2, m->mp_start))
+ if (strcmp(buffer + 2, m->mp_start))
continue;
next_part:
- if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
- adios (NULL, "out of memory");
+ if ((part = (struct part *) calloc(1, sizeof(*part)))
+ == NULL)
+ adios(NULL, "out of memory");
*next = part;
next = &part->mp_next;
- if (!(p = get_content (fp, ct->c_file,
+ if (!(p = get_content(fp, ct->c_file,
ct->c_subtype == MULTI_DIGEST ? -1 : 0))) {
ct->c_fp = NULL;
return NOTOK;
p->c_fp = NULL;
part->mp_part = p;
pos = p->c_begin;
- fseek (fp, pos, SEEK_SET);
+ fseek(fp, pos, SEEK_SET);
inout = 0;
} else {
- if (strcmp (buffer + 2, m->mp_start) == 0) {
+ if (strcmp(buffer + 2, m->mp_start) == 0) {
inout = 1;
end_part:
p = part->mp_part;
goto next_part;
goto last_part;
} else {
- if (strcmp (buffer + 2, m->mp_stop) == 0)
+ if (strcmp(buffer + 2, m->mp_stop) == 0)
goto end_part;
}
}
}
- advise (NULL, "bogus multipart content in message %s", ct->c_file);
+ advise(NULL, "bogus multipart content in message %s", ct->c_file);
if (!inout && part) {
p = part->mp_part;
p->c_end = ct->c_end;
next = &((*next)->mp_next))
continue;
*next = NULL;
- free_content (p);
- free ((char *) part);
+ free_content(p);
+ free((char *) part);
}
}
last_part:
/* reverse the order of the parts for multipart/alternative */
if (ct->c_subtype == MULTI_ALTERNATE)
- reverse_parts (ct);
+ reverse_parts(ct);
/*
** label all subparts with part number, and
char partnam[BUFSIZ];
if (ct->c_partno) {
- snprintf (partnam, sizeof(partnam), "%s.", ct->c_partno);
- pp = partnam + strlen (partnam);
+ snprintf(partnam, sizeof(partnam), "%s.",
+ ct->c_partno);
+ pp = partnam + strlen(partnam);
} else {
pp = partnam;
}
part = part->mp_next, partnum++) {
p = part->mp_part;
- sprintf (pp, "%d", partnum);
- p->c_partno = add (partnam, NULL);
+ sprintf(pp, "%d", partnum);
+ p->c_partno = add(partnam, NULL);
/* initialize the content of the subparts */
if (p->c_ctinitfnx && (*p->c_ctinitfnx) (p) == NOTOK) {
- fclose (ct->c_fp);
+ fclose(ct->c_fp);
ct->c_fp = NULL;
return NOTOK;
}
}
}
- fclose (ct->c_fp);
+ fclose(ct->c_fp);
ct->c_fp = NULL;
return OK;
}
*/
static void
-reverse_parts (CT ct)
+reverse_parts(CT ct)
{
int i;
struct multipart *m;
i++;
/* allocate array of pointers to the parts */
- if (!(base = (struct part **) calloc ((size_t) (i + 1), sizeof(*base))))
- adios (NULL, "out of memory");
+ if (!(base = (struct part **) calloc((size_t) (i + 1), sizeof(*base))))
+ adios(NULL, "out of memory");
bmp = base;
/* point at all the parts */
*next = NULL;
/* free array of pointers */
- free ((char *) base);
+ free((char *) base);
}
*/
static int
-InitMessage (CT ct)
+InitMessage(CT ct)
{
struct k2v *kv;
CI ci = &ct->c_ctinfo;
if ((ct->c_encoding != CE_7BIT) && (ct->c_encoding != CE_8BIT)) {
- admonish (NULL,
- "\"%s/%s\" type in message %s should be encoded in 7bit or 8bit",
- ci->ci_type, ci->ci_subtype, ct->c_file);
+ admonish(NULL, "\"%s/%s\" type in message %s should be encoded in 7bit or 8bit", ci->ci_type, ci->ci_subtype, ct->c_file);
return NOTOK;
}
/* check for missing subtype */
if (!*ci->ci_subtype)
- ci->ci_subtype = add ("rfc822", ci->ci_subtype);
+ ci->ci_subtype = add("rfc822", ci->ci_subtype);
/* match subtype */
for (kv = SubMessage; kv->kv_key; kv++)
- if (!mh_strcasecmp (ci->ci_subtype, kv->kv_key))
+ if (!mh_strcasecmp(ci->ci_subtype, kv->kv_key))
break;
ct->c_subtype = kv->kv_value;
char **ap, **ep;
struct partial *p;
- if ((p = (struct partial *) calloc (1, sizeof(*p))) == NULL)
- adios (NULL, "out of memory");
+ if ((p = (struct partial *)
+ calloc(1, sizeof(*p))) == NULL)
+ adios(NULL, "out of memory");
ct->c_ctparams = (void *) p;
/*
** 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);
+ if (!mh_strcasecmp(*ap, "id")) {
+ p->pm_partid = add(*ep, NULL);
continue;
}
- if (!mh_strcasecmp (*ap, "number")) {
- if (sscanf (*ep, "%d", &p->pm_partno) != 1
- || p->pm_partno < 1) {
+ if (!mh_strcasecmp(*ap, "number")) {
+ if (sscanf(*ep, "%d", &p->pm_partno) != 1 || p->pm_partno < 1) {
invalid_param:
- advise (NULL,
- "invalid %s parameter for \"%s/%s\" type in message %s's %s field",
- *ap, ci->ci_type, ci->ci_subtype,
- ct->c_file, TYPE_FIELD);
+ advise(NULL, "invalid %s parameter for \"%s/%s\" type in message %s's %s field", *ap, ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD);
return NOTOK;
}
continue;
}
- if (!mh_strcasecmp (*ap, "total")) {
- if (sscanf (*ep, "%d", &p->pm_maxno) != 1
- || p->pm_maxno < 1)
+ if (!mh_strcasecmp(*ap, "total")) {
+ if (sscanf(*ep, "%d", &p->pm_maxno) != 1 || p->pm_maxno < 1)
goto invalid_param;
continue;
}
if (!p->pm_partid || !p->pm_partno
|| (p->pm_maxno && p->pm_partno > p->pm_maxno)) {
- advise (NULL,
- "invalid parameters for \"%s/%s\" type in message %s's %s field",
- ci->ci_type, ci->ci_subtype,
- ct->c_file, TYPE_FIELD);
+ advise(NULL, "invalid parameters for \"%s/%s\" type in message %s's %s field", ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD);
return NOTOK;
}
}
CT p;
FILE *fp;
- if ((e = (struct exbody *) calloc (1, sizeof(*e))) == NULL)
- adios (NULL, "out of memory");
+ if ((e = (struct exbody *)
+ calloc(1, sizeof(*e))) == NULL)
+ adios(NULL, "out of memory");
ct->c_ctparams = (void *) e;
- if (!ct->c_fp && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
- advise (ct->c_file, "unable to open for reading");
+ if (!ct->c_fp && (ct->c_fp = fopen(ct->c_file, "r")) == NULL) {
+ advise(ct->c_file, "unable to open for reading");
return NOTOK;
}
- fseek (fp = ct->c_fp, ct->c_begin, SEEK_SET);
+ fseek(fp = ct->c_fp, ct->c_begin, SEEK_SET);
- if (!(p = get_content (fp, ct->c_file, 0))) {
+ if (!(p = get_content(fp, ct->c_file, 0))) {
ct->c_fp = NULL;
return NOTOK;
}
e->eb_parent = ct;
e->eb_content = p;
p->c_ctexbody = e;
- if ((exresult = params_external (ct, 0)) != NOTOK
- && p->c_ceopenfnx == openMail) {
+ if ((exresult = params_external(ct, 0))
+ != NOTOK &&
+ p->c_ceopenfnx == openMail) {
int cc, size;
char *bp;
if ((size = ct->c_end - p->c_begin) <= 0) {
if (!e->eb_subject)
- content_error (NULL, ct, "empty body for access-type=mail-server");
+ content_error(NULL, ct, "empty body for access-type=mail-server");
goto no_body;
}
- e->eb_body = bp = mh_xmalloc ((unsigned) size);
- fseek (p->c_fp, p->c_begin, SEEK_SET);
+ e->eb_body = bp = mh_xmalloc((unsigned) size);
+ fseek(p->c_fp, p->c_begin, SEEK_SET);
while (size > 0)
- switch (cc = fread (bp, sizeof(*bp), size, p->c_fp)) {
+ switch (cc = fread(bp, sizeof(*bp), size, p->c_fp)) {
case NOTOK:
- adios ("failed", "fread");
+ adios("failed", "fread");
case OK:
- adios (NULL, "unexpected EOF from fread");
+ adios(NULL, "unexpected EOF from fread");
default:
bp += cc, size -= cc;
p->c_fp = NULL;
p->c_end = p->c_begin;
- fclose (ct->c_fp);
+ fclose(ct->c_fp);
ct->c_fp = NULL;
if (exresult == NOTOK)
int
-params_external (CT ct, int composing)
+params_external(CT ct, int composing)
{
char **ap, **ep;
struct exbody *e = (struct exbody *) ct->c_ctparams;
CI ci = &ct->c_ctinfo;
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
- if (!mh_strcasecmp (*ap, "access-type")) {
+ if (!mh_strcasecmp(*ap, "access-type")) {
struct str2init *s2i;
CT p = e->eb_content;
for (s2i = str2methods; s2i->si_key; s2i++)
- if (!mh_strcasecmp (*ep, s2i->si_key))
+ if (!mh_strcasecmp(*ep, s2i->si_key))
break;
if (!s2i->si_key) {
e->eb_access = *ep;
return NOTOK;
continue;
}
- if (!mh_strcasecmp (*ap, "name")) {
+ if (!mh_strcasecmp(*ap, "name")) {
e->eb_name = *ep;
continue;
}
- if (!mh_strcasecmp (*ap, "permission")) {
+ if (!mh_strcasecmp(*ap, "permission")) {
e->eb_permission = *ep;
continue;
}
- if (!mh_strcasecmp (*ap, "site")) {
+ if (!mh_strcasecmp(*ap, "site")) {
e->eb_site = *ep;
continue;
}
- if (!mh_strcasecmp (*ap, "directory")) {
+ if (!mh_strcasecmp(*ap, "directory")) {
e->eb_dir = *ep;
continue;
}
- if (!mh_strcasecmp (*ap, "mode")) {
+ if (!mh_strcasecmp(*ap, "mode")) {
e->eb_mode = *ep;
continue;
}
- if (!mh_strcasecmp (*ap, "size")) {
- sscanf (*ep, "%lu", &e->eb_size);
+ if (!mh_strcasecmp(*ap, "size")) {
+ sscanf(*ep, "%lu", &e->eb_size);
continue;
}
- if (!mh_strcasecmp (*ap, "server")) {
+ if (!mh_strcasecmp(*ap, "server")) {
e->eb_server = *ep;
continue;
}
- if (!mh_strcasecmp (*ap, "subject")) {
+ if (!mh_strcasecmp(*ap, "subject")) {
e->eb_subject = *ep;
continue;
}
- if (composing && !mh_strcasecmp (*ap, "body")) {
- e->eb_body = getcpy (*ep);
+ if (composing && !mh_strcasecmp(*ap, "body")) {
+ e->eb_body = getcpy(*ep);
continue;
}
}
if (!e->eb_access) {
- advise (NULL,
- "invalid parameters for \"%s/%s\" type in message %s's %s field",
- ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD);
+ advise(NULL, "invalid parameters for \"%s/%s\" type in message %s's %s field", ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD);
return NOTOK;
}
*/
static int
-InitApplication (CT ct)
+InitApplication(CT ct)
{
struct k2v *kv;
CI ci = &ct->c_ctinfo;
/* match subtype */
for (kv = SubApplication; kv->kv_key; kv++)
- if (!mh_strcasecmp (ci->ci_subtype, kv->kv_key))
+ if (!mh_strcasecmp(ci->ci_subtype, kv->kv_key))
break;
ct->c_subtype = kv->kv_value;
*/
static int
-init_encoding (CT ct, OpenCEFunc openfnx)
+init_encoding(CT ct, OpenCEFunc openfnx)
{
CE ce;
- if ((ce = (CE) calloc (1, sizeof(*ce))) == NULL)
- adios (NULL, "out of memory");
+ if ((ce = (CE) calloc(1, sizeof(*ce))) == NULL)
+ adios(NULL, "out of memory");
ct->c_cefile = ce;
ct->c_ceopenfnx = openfnx;
void
-close_encoding (CT ct)
+close_encoding(CT ct)
{
CE ce;
return;
if (ce->ce_fp) {
- fclose (ce->ce_fp);
+ fclose(ce->ce_fp);
ce->ce_fp = NULL;
}
}
static unsigned long
-size_encoding (CT ct)
+size_encoding(CT ct)
{
int fd;
unsigned long size;
if (!(ce = ct->c_cefile))
return (ct->c_end - ct->c_begin);
- if (ce->ce_fp && fstat (fileno (ce->ce_fp), &st) != NOTOK)
+ if (ce->ce_fp && fstat(fileno(ce->ce_fp), &st) != NOTOK)
return (long) st.st_size;
if (ce->ce_file) {
- if (stat (ce->ce_file, &st) != NOTOK)
+ if (stat(ce->ce_file, &st) != NOTOK)
return (long) st.st_size;
else
return 0L;
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return (ct->c_end - ct->c_begin);
- if (fstat (fd, &st) != NOTOK)
+ if (fstat(fd, &st) != NOTOK)
size = (long) st.st_size;
else
size = 0L;
static int
-InitBase64 (CT ct)
+InitBase64(CT ct)
{
- return init_encoding (ct, openBase64);
+ return init_encoding(ct, openBase64);
}
static int
-openBase64 (CT ct, char **file)
+openBase64(CT ct, char **file)
{
int bitno, cc, digested;
int fd, len, skip;
ce = ct->c_cefile;
if (ce->ce_fp) {
- fseek (ce->ce_fp, 0L, SEEK_SET);
+ fseek(ce->ce_fp, 0L, SEEK_SET);
goto ready_to_go;
}
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");
+ if ((ce->ce_fp = fopen(ce->ce_file, "r")) == NULL) {
+ content_error(ce->ce_file, ct,
+ "unable to fopen for reading");
return NOTOK;
}
goto ready_to_go;
}
if (*file == NULL) {
- ce->ce_file = add (m_mktemp(tmp, NULL, NULL), NULL);
+ ce->ce_file = add(m_mktemp(tmp, NULL, NULL), NULL);
ce->ce_unlink = 1;
} else {
- ce->ce_file = add (*file, NULL);
+ ce->ce_file = add(*file, NULL);
ce->ce_unlink = 0;
}
/* sbeck@cise.ufl.edu -- handle suffixes */
ci = &ct->c_ctinfo;
- snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s",
- invo_name, ci->ci_type, ci->ci_subtype);
- cp = context_find (buffer);
+ snprintf(buffer, sizeof(buffer), "%s-suffix-%s/%s",
+ invo_name, ci->ci_type, ci->ci_subtype);
+ cp = context_find(buffer);
if (cp == NULL || *cp == '\0') {
- snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
+ snprintf(buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
ci->ci_type);
- cp = context_find (buffer);
+ cp = context_find(buffer);
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
** version with extension.
*/
char *file_org = strdup(ce->ce_file);
- ce->ce_file = add (cp, 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);
} else {
- ce->ce_file = add (cp, ce->ce_file);
+ ce->ce_file = add(cp, ce->ce_file);
}
}
- if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
+ if ((ce->ce_fp = fopen(ce->ce_file, "w+")) == NULL) {
+ content_error(ce->ce_file, ct,
+ "unable to fopen for reading/writing");
return NOTOK;
}
if ((len = ct->c_end - ct->c_begin) < 0)
- adios (NULL, "internal error(1)");
+ adios(NULL, "internal error(1)");
- if (!ct->c_fp && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
- content_error (ct->c_file, ct, "unable to open for reading");
+ if (!ct->c_fp && (ct->c_fp = fopen(ct->c_file, "r")) == NULL) {
+ content_error(ct->c_file, ct, "unable to open for reading");
return NOTOK;
}
if ((digested = ct->c_digested))
- MD5Init (&mdContext);
+ MD5Init(&mdContext);
bitno = 18;
bits = 0L;
skip = 0;
- lseek (fd = fileno (ct->c_fp), (off_t) ct->c_begin, SEEK_SET);
+ lseek(fd = fileno(ct->c_fp), (off_t) ct->c_begin, SEEK_SET);
while (len > 0) {
- switch (cc = read (fd, buffer, sizeof(buffer) - 1)) {
+ switch (cc = read(fd, buffer, sizeof(buffer) - 1)) {
case NOTOK:
- content_error (ct->c_file, ct, "error reading from");
+ content_error(ct->c_file, ct, "error reading from");
goto clean_up;
case OK:
- content_error (NULL, ct, "premature eof");
+ content_error(NULL, ct, "premature eof");
goto clean_up;
default:
for (ep = (cp = buffer) + cc; cp < ep; cp++) {
switch (*cp) {
default:
- if (isspace (*cp))
+ if (isspace(*cp))
break;
- if (skip || (*cp & 0x80)
- || (value = b642nib[*cp & 0x7f]) > 0x3f) {
+ if (skip || (*cp & 0x80) || (value = b642nib[*cp & 0x7f]) > 0x3f) {
if (debugsw) {
- fprintf (stderr, "*cp=0x%x pos=%ld skip=%d\n", *cp, (long) (lseek (fd, (off_t) 0, SEEK_CUR) - (ep - cp)), skip);
+ fprintf(stderr, "*cp=0x%x pos=%ld skip=%d\n", *cp, (long) (lseek(fd, (off_t) 0, SEEK_CUR) - (ep - cp)), skip);
}
- content_error (NULL, ct,
- "invalid BASE64 encoding -- continuing");
+ content_error(NULL, ct, "invalid BASE64 encoding -- continuing");
continue;
}
bits |= value << bitno;
test_end:
if ((bitno -= 6) < 0) {
- putc ((char) *b1, ce->ce_fp);
+ putc((char) *b1, ce->ce_fp);
if (digested)
- MD5Update (&mdContext, b1, 1);
+ MD5Update(&mdContext, b1, 1);
if (skip < 2) {
- putc ((char) *b2, ce->ce_fp);
+ putc((char) *b2, ce->ce_fp);
if (digested)
- MD5Update (&mdContext, b2, 1);
+ MD5Update(&mdContext, b2, 1);
if (skip < 1) {
- putc ((char) *b3, ce->ce_fp);
+ putc((char) *b3, ce->ce_fp);
if (digested)
- MD5Update (&mdContext, b3, 1);
+ MD5Update(&mdContext, b3, 1);
}
}
- if (ferror (ce->ce_fp)) {
- content_error (ce->ce_file, ct,
+ if (ferror(ce->ce_fp)) {
+ content_error(ce->ce_file, ct,
"error writing to");
goto clean_up;
}
if (bitno != 18) {
if (debugsw)
- fprintf (stderr, "premature ending (bitno %d)\n", bitno);
+ fprintf(stderr, "premature ending (bitno %d)\n",
+ bitno);
- content_error (NULL, ct, "invalid BASE64 encoding");
+ content_error(NULL, ct, "invalid BASE64 encoding");
goto clean_up;
}
self_delimiting:
- fseek (ct->c_fp, 0L, SEEK_SET);
+ fseek(ct->c_fp, 0L, SEEK_SET);
- if (fflush (ce->ce_fp)) {
- content_error (ce->ce_file, ct, "error writing to");
+ if (fflush(ce->ce_fp)) {
+ content_error(ce->ce_file, ct, "error writing to");
goto clean_up;
}
if (digested) {
unsigned char digest[16];
- MD5Final (digest, &mdContext);
+ MD5Final(digest, &mdContext);
if (memcmp((char *) digest, (char *) ct->c_digest,
sizeof(digest) / sizeof(digest[0])))
- content_error (NULL, ct, "content integrity suspect (digest mismatch) -- continuing");
+ content_error(NULL, ct, "content integrity suspect (digest mismatch) -- continuing");
else if (debugsw)
- fprintf (stderr, "content integrity confirmed\n");
+ fprintf(stderr, "content integrity confirmed\n");
}
- fseek (ce->ce_fp, 0L, SEEK_SET);
+ fseek(ce->ce_fp, 0L, SEEK_SET);
ready_to_go:
*file = ce->ce_file;
- return fileno (ce->ce_fp);
+ return fileno(ce->ce_fp);
clean_up:
- free_encoding (ct, 0);
+ free_encoding(ct, 0);
return NOTOK;
}
static int
-InitQuoted (CT ct)
+InitQuoted(CT ct)
{
- return init_encoding (ct, openQuoted);
+ return init_encoding(ct, openQuoted);
}
static int
-openQuoted (CT ct, char **file)
+openQuoted(CT ct, char **file)
{
int cc, digested, len, quoted;
unsigned char *cp, *ep;
ce = ct->c_cefile;
if (ce->ce_fp) {
- fseek (ce->ce_fp, 0L, SEEK_SET);
+ fseek(ce->ce_fp, 0L, SEEK_SET);
goto ready_to_go;
}
if (ce->ce_file) {
- if ((ce->ce_fp = fopen (ce->ce_file, "r")) == NULL) {
- content_error (ce->ce_file, ct,
+ if ((ce->ce_fp = fopen(ce->ce_file, "r")) == NULL) {
+ content_error(ce->ce_file, ct,
"unable to fopen for reading");
return NOTOK;
}
}
if (*file == NULL) {
- ce->ce_file = add (m_mktemp(tmp, NULL, NULL), NULL);
+ ce->ce_file = add(m_mktemp(tmp, NULL, NULL), NULL);
ce->ce_unlink = 1;
} else {
- ce->ce_file = add (*file, NULL);
+ ce->ce_file = add(*file, NULL);
ce->ce_unlink = 0;
}
/* sbeck@cise.ufl.edu -- handle suffixes */
ci = &ct->c_ctinfo;
- snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s",
- invo_name, ci->ci_type, ci->ci_subtype);
- cp = context_find (buffer);
+ snprintf(buffer, sizeof(buffer), "%s-suffix-%s/%s",
+ invo_name, ci->ci_type, ci->ci_subtype);
+ cp = context_find(buffer);
if (cp == NULL || *cp == '\0') {
- snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
- ci->ci_type);
- cp = context_find (buffer);
+ snprintf(buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
+ ci->ci_type);
+ cp = context_find(buffer);
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
// 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);
+ ce->ce_file = add(cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
- adios (ce->ce_file, "unable to rename %s to ",
+ adios(ce->ce_file, "unable to rename %s to ",
file_org);
}
free(file_org);
} else {
- ce->ce_file = add (cp, ce->ce_file);
+ ce->ce_file = add(cp, ce->ce_file);
}
}
- if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
- content_error (ce->ce_file, ct,
+ if ((ce->ce_fp = fopen(ce->ce_file, "w+")) == NULL) {
+ 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,
+ if ((ce->ce_fp = fopen(ce->ce_file, "w+")) == NULL) {
+ content_error(ce->ce_file, ct,
"unable to fopen for reading/writing");
return NOTOK;
}
if ((len = ct->c_end - ct->c_begin) < 0)
- adios (NULL, "internal error(2)");
+ adios(NULL, "internal error(2)");
- if (!ct->c_fp && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
- content_error (ct->c_file, ct, "unable to open for reading");
+ if (!ct->c_fp && (ct->c_fp = fopen(ct->c_file, "r")) == NULL) {
+ content_error(ct->c_file, ct, "unable to open for reading");
return NOTOK;
}
if ((digested = ct->c_digested))
- MD5Init (&mdContext);
+ MD5Init(&mdContext);
quoted = 0;
#ifdef lint
mask = 0;
#endif
- fseek (ct->c_fp, ct->c_begin, SEEK_SET);
+ fseek(ct->c_fp, ct->c_begin, SEEK_SET);
while (len > 0) {
- if (fgets (buffer, sizeof(buffer) - 1, ct->c_fp) == NULL) {
- content_error (NULL, ct, "premature eof");
+ if (fgets(buffer, sizeof(buffer) - 1, ct->c_fp) == NULL) {
+ content_error(NULL, ct, "premature eof");
goto clean_up;
}
- if ((cc = strlen (buffer)) > len)
+ if ((cc = strlen(buffer)) > len)
cc = len;
len -= cc;
for (ep = (cp = buffer) + cc - 1; cp <= ep; ep--)
- if (!isspace (*ep))
+ if (!isspace(*ep))
break;
*++ep = '\n', ep++;
/* at byte 2 of an escape sequence */
mask <<= 4;
mask |= hex2nib[*cp & 0x7f];
- putc (mask, ce->ce_fp);
+ putc(mask, ce->ce_fp);
if (digested)
- MD5Update (&mdContext, &mask, 1);
- if (ferror (ce->ce_fp)) {
- content_error (ce->ce_file, ct, "error writing to");
+ MD5Update(&mdContext, &mask, 1);
+ if (ferror(ce->ce_fp)) {
+ content_error(ce->ce_file, ct, "error writing to");
goto clean_up;
}
/*
** sequence; just show the raw bytes
** (below).
*/
- } else if (isxdigit (cp[1]) && isxdigit (cp[2])) {
+ } else if (isxdigit(cp[1]) && isxdigit(cp[2])) {
/*
** Next 2 bytes are hex digits,
** making this a valid escape
}
/* Just show the raw byte. */
- putc (*cp, ce->ce_fp);
+ putc(*cp, ce->ce_fp);
if (digested) {
if (*cp == '\n') {
- MD5Update (&mdContext, (unsigned char *) "\r\n",2);
+ MD5Update(&mdContext, (unsigned char *) "\r\n",2);
} else {
- MD5Update (&mdContext, (unsigned char *) cp, 1);
+ MD5Update(&mdContext, (unsigned char *) cp, 1);
}
}
- if (ferror (ce->ce_fp)) {
- content_error (ce->ce_file, ct, "error writing to");
+ if (ferror(ce->ce_fp)) {
+ content_error(ce->ce_file, ct,
+ "error writing to");
goto clean_up;
}
}
}
if (quoted) {
- content_error (NULL, ct,
- "invalid QUOTED-PRINTABLE encoding -- end-of-content while still quoting");
+ content_error(NULL, ct, "invalid QUOTED-PRINTABLE encoding -- end-of-content while still quoting");
goto clean_up;
}
- fseek (ct->c_fp, 0L, SEEK_SET);
+ fseek(ct->c_fp, 0L, SEEK_SET);
- if (fflush (ce->ce_fp)) {
- content_error (ce->ce_file, ct, "error writing to");
+ if (fflush(ce->ce_fp)) {
+ content_error(ce->ce_file, ct, "error writing to");
goto clean_up;
}
if (digested) {
unsigned char digest[16];
- MD5Final (digest, &mdContext);
+ MD5Final(digest, &mdContext);
if (memcmp((char *) digest, (char *) ct->c_digest,
sizeof(digest) / sizeof(digest[0])))
- content_error (NULL, ct,
- "content integrity suspect (digest mismatch) -- continuing");
+ content_error(NULL, ct, "content integrity suspect (digest mismatch) -- continuing");
else if (debugsw)
- fprintf (stderr, "content integrity confirmed\n");
+ fprintf(stderr, "content integrity confirmed\n");
}
- fseek (ce->ce_fp, 0L, SEEK_SET);
+ fseek(ce->ce_fp, 0L, SEEK_SET);
ready_to_go:
*file = ce->ce_file;
- return fileno (ce->ce_fp);
+ return fileno(ce->ce_fp);
clean_up:
- free_encoding (ct, 0);
+ free_encoding(ct, 0);
return NOTOK;
}
*/
static int
-Init7Bit (CT ct)
+Init7Bit(CT ct)
{
- if (init_encoding (ct, open7Bit) == NOTOK)
+ if (init_encoding(ct, open7Bit) == NOTOK)
return NOTOK;
ct->c_cesizefnx = NULL; /* no need to decode for real size */
int
-open7Bit (CT ct, char **file)
+open7Bit(CT ct, char **file)
{
int cc, fd, len;
char buffer[BUFSIZ];
ce = ct->c_cefile;
if (ce->ce_fp) {
- fseek (ce->ce_fp, 0L, SEEK_SET);
+ fseek(ce->ce_fp, 0L, SEEK_SET);
goto ready_to_go;
}
if (ce->ce_file) {
- if ((ce->ce_fp = fopen (ce->ce_file, "r")) == NULL) {
- content_error (ce->ce_file, ct,
+ if ((ce->ce_fp = fopen(ce->ce_file, "r")) == NULL) {
+ content_error(ce->ce_file, ct,
"unable to fopen for reading");
return NOTOK;
}
}
if (*file == NULL) {
- ce->ce_file = add (m_mktemp(tmp, NULL, NULL), NULL);
+ ce->ce_file = add(m_mktemp(tmp, NULL, NULL), NULL);
ce->ce_unlink = 1;
} else {
- ce->ce_file = add (*file, NULL);
+ ce->ce_file = add(*file, NULL);
ce->ce_unlink = 0;
}
/* sbeck@cise.ufl.edu -- handle suffixes */
ci = &ct->c_ctinfo;
- snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s",
- invo_name, ci->ci_type, ci->ci_subtype);
- cp = context_find (buffer);
+ snprintf(buffer, sizeof(buffer), "%s-suffix-%s/%s",
+ invo_name, ci->ci_type, ci->ci_subtype);
+ cp = context_find(buffer);
if (cp == NULL || *cp == '\0') {
- snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
+ snprintf(buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
ci->ci_type);
- cp = context_find (buffer);
+ cp = context_find(buffer);
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
** version with extension.
*/
char *file_org = strdup(ce->ce_file);
- ce->ce_file = add (cp, 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 ",
+ adios(ce->ce_file, "unable to rename %s to ",
file_org);
}
free(file_org);
} else {
- ce->ce_file = add (cp, ce->ce_file);
+ ce->ce_file = add(cp, ce->ce_file);
}
}
- if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
- content_error (ce->ce_file, ct,
+ if ((ce->ce_fp = fopen(ce->ce_file, "w+")) == NULL) {
+ content_error(ce->ce_file, ct,
"unable to fopen for reading/writing");
return NOTOK;
}
CI ci = &ct->c_ctinfo;
len = 0;
- fprintf (ce->ce_fp, "%s: %s/%s", TYPE_FIELD, ci->ci_type,
+ 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);
+ 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);
+ putc(';', ce->ce_fp);
len++;
- snprintf (buffer, sizeof(buffer), "%s=\"%s\"",
+ snprintf(buffer, sizeof(buffer), "%s=\"%s\"",
*ap, *ep);
- if (len + 1 + (cc = strlen (buffer)) >= CPERLIN) {
- fputs ("\n\t", ce->ce_fp);
+ if (len + 1 + (cc = strlen(buffer)) >= CPERLIN) {
+ fputs("\n\t", ce->ce_fp);
len = 8;
} else {
- putc (' ', ce->ce_fp);
+ putc(' ', ce->ce_fp);
len++;
}
- fprintf (ce->ce_fp, "%s", buffer);
+ fprintf(ce->ce_fp, "%s", buffer);
len += cc;
}
if (ci->ci_comment) {
- if (len + 1 + (cc = 2 + strlen (ci->ci_comment)) >= CPERLIN) {
- fputs ("\n\t", ce->ce_fp);
+ if (len + 1 + (cc = 2 + strlen(ci->ci_comment))
+ >= CPERLIN) {
+ fputs("\n\t", ce->ce_fp);
len = 8;
- }
- else {
- putc (' ', ce->ce_fp);
+ } else {
+ putc(' ', ce->ce_fp);
len++;
}
- fprintf (ce->ce_fp, "(%s)", ci->ci_comment);
+ fprintf(ce->ce_fp, "(%s)", ci->ci_comment);
len += cc;
}
- fprintf (ce->ce_fp, "\n");
+ fprintf(ce->ce_fp, "\n");
if (ct->c_id)
- fprintf (ce->ce_fp, "%s:%s", ID_FIELD, ct->c_id);
+ fprintf(ce->ce_fp, "%s:%s", ID_FIELD, ct->c_id);
if (ct->c_descr)
- fprintf (ce->ce_fp, "%s:%s", DESCR_FIELD, ct->c_descr);
+ fprintf(ce->ce_fp, "%s:%s", DESCR_FIELD, ct->c_descr);
if (ct->c_dispo)
- fprintf (ce->ce_fp, "%s:%s", DISPO_FIELD, ct->c_dispo);
- fprintf (ce->ce_fp, "\n");
+ fprintf(ce->ce_fp, "%s:%s", DISPO_FIELD, ct->c_dispo);
+ fprintf(ce->ce_fp, "\n");
}
if ((len = ct->c_end - ct->c_begin) < 0)
- adios (NULL, "internal error(3)");
+ adios(NULL, "internal error(3)");
- if (!ct->c_fp && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
- content_error (ct->c_file, ct, "unable to open for reading");
+ if (!ct->c_fp && (ct->c_fp = fopen(ct->c_file, "r")) == NULL) {
+ content_error(ct->c_file, ct, "unable to open for reading");
return NOTOK;
}
- lseek (fd = fileno (ct->c_fp), (off_t) ct->c_begin, SEEK_SET);
+ lseek(fd = fileno(ct->c_fp), (off_t) ct->c_begin, SEEK_SET);
while (len > 0)
- switch (cc = read (fd, buffer, sizeof(buffer) - 1)) {
+ switch (cc = read(fd, buffer, sizeof(buffer) - 1)) {
case NOTOK:
- content_error (ct->c_file, ct, "error reading from");
+ content_error(ct->c_file, ct, "error reading from");
goto clean_up;
case OK:
- content_error (NULL, ct, "premature eof");
+ content_error(NULL, ct, "premature eof");
goto clean_up;
default:
cc = len;
len -= cc;
- fwrite (buffer, sizeof(*buffer), cc, ce->ce_fp);
- if (ferror (ce->ce_fp)) {
- content_error (ce->ce_file, ct, "error writing to");
+ fwrite(buffer, sizeof(*buffer), cc, ce->ce_fp);
+ if (ferror(ce->ce_fp)) {
+ content_error(ce->ce_file, ct,
+ "error writing to");
goto clean_up;
}
}
- fseek (ct->c_fp, 0L, SEEK_SET);
+ fseek(ct->c_fp, 0L, SEEK_SET);
- if (fflush (ce->ce_fp)) {
- content_error (ce->ce_file, ct, "error writing to");
+ if (fflush(ce->ce_fp)) {
+ content_error(ce->ce_file, ct, "error writing to");
goto clean_up;
}
- fseek (ce->ce_fp, 0L, SEEK_SET);
+ fseek(ce->ce_fp, 0L, SEEK_SET);
ready_to_go:
*file = ce->ce_file;
- return fileno (ce->ce_fp);
+ return fileno(ce->ce_fp);
clean_up:
- free_encoding (ct, 0);
+ free_encoding(ct, 0);
return NOTOK;
}
*/
static int
-openExternal (CT ct, CT cb, CE ce, char **file, int *fd)
+openExternal(CT ct, CT cb, CE ce, char **file, int *fd)
{
char cachefile[BUFSIZ];
if (ce->ce_fp) {
- fseek (ce->ce_fp, 0L, SEEK_SET);
+ fseek(ce->ce_fp, 0L, SEEK_SET);
goto ready_already;
}
if (ce->ce_file) {
- if ((ce->ce_fp = fopen (ce->ce_file, "r")) == NULL) {
- content_error (ce->ce_file, ct,
+ if ((ce->ce_fp = fopen(ce->ce_file, "r")) == NULL) {
+ content_error(ce->ce_file, ct,
"unable to fopen for reading");
return NOTOK;
}
goto ready_already;
}
- if (find_cache (ct, rcachesw, (int *) 0, cb->c_id,
- cachefile, sizeof(cachefile)) != NOTOK) {
- if ((ce->ce_fp = fopen (cachefile, "r"))) {
- ce->ce_file = getcpy (cachefile);
+ if (find_cache(ct, rcachesw, (int *) 0, cb->c_id,
+ cachefile, sizeof(cachefile)) != NOTOK) {
+ if ((ce->ce_fp = fopen(cachefile, "r"))) {
+ ce->ce_file = getcpy(cachefile);
ce->ce_unlink = 0;
goto ready_already;
} else {
- admonish (cachefile, "unable to fopen for reading");
+ admonish(cachefile, "unable to fopen for reading");
}
}
ready_already:
*file = ce->ce_file;
- *fd = fileno (ce->ce_fp);
+ *fd = fileno(ce->ce_fp);
return DONE;
}
*/
static int
-InitFile (CT ct)
+InitFile(CT ct)
{
- return init_encoding (ct, openFile);
+ return init_encoding(ct, openFile);
}
static int
-openFile (CT ct, char **file)
+openFile(CT ct, char **file)
{
int fd, cachetype;
char cachefile[BUFSIZ];
struct exbody *e = ct->c_ctexbody;
CE ce = ct->c_cefile;
- switch (openExternal (e->eb_parent, e->eb_content, ce, file, &fd)) {
+ switch (openExternal(e->eb_parent, e->eb_content, ce, file, &fd)) {
case NOTOK:
return NOTOK;
}
if (!e->eb_name) {
- content_error (NULL, ct, "missing name parameter");
+ content_error(NULL, ct, "missing name parameter");
return NOTOK;
}
- ce->ce_file = getcpy (e->eb_name);
+ ce->ce_file = getcpy(e->eb_name);
ce->ce_unlink = 0;
- if ((ce->ce_fp = fopen (ce->ce_file, "r")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading");
+ if ((ce->ce_fp = fopen(ce->ce_file, "r")) == NULL) {
+ content_error(ce->ce_file, ct, "unable to fopen for reading");
return NOTOK;
}
- 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) {
+ 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) {
int mask;
FILE *fp;
- mask = umask (cachetype ? ~m_gmprot () : 0222);
- if ((fp = fopen (cachefile, "w"))) {
+ mask = umask(cachetype ? ~m_gmprot() : 0222);
+ if ((fp = fopen(cachefile, "w"))) {
int cc;
char buffer[BUFSIZ];
FILE *gp = ce->ce_fp;
- fseek (gp, 0L, SEEK_SET);
+ fseek(gp, 0L, SEEK_SET);
- while ((cc = fread (buffer, sizeof(*buffer), sizeof(buffer), gp)) > 0)
- fwrite (buffer, sizeof(*buffer), cc, fp);
- fflush (fp);
+ while ((cc = fread(buffer, sizeof(*buffer),
+ sizeof(buffer), gp)) > 0)
+ fwrite(buffer, sizeof(*buffer), cc, fp);
+ fflush(fp);
- if (ferror (gp)) {
- admonish (ce->ce_file, "error reading");
- unlink (cachefile);
- } else if (ferror (fp)) {
- admonish (cachefile, "error writing");
- unlink (cachefile);
+ if (ferror(gp)) {
+ admonish(ce->ce_file, "error reading");
+ unlink(cachefile);
+ } else if (ferror(fp)) {
+ admonish(cachefile, "error writing");
+ unlink(cachefile);
}
- fclose (fp);
+ fclose(fp);
}
- umask (mask);
+ umask(mask);
}
- fseek (ce->ce_fp, 0L, SEEK_SET);
+ fseek(ce->ce_fp, 0L, SEEK_SET);
*file = ce->ce_file;
- return fileno (ce->ce_fp);
+ return fileno(ce->ce_fp);
}
/*
*/
static int
-InitFTP (CT ct)
+InitFTP(CT ct)
{
- return init_encoding (ct, openFTP);
+ return init_encoding(ct, openFTP);
}
static int
-openFTP (CT ct, char **file)
+openFTP(CT ct, char **file)
{
int cachetype, caching, fd;
int len, buflen;
e = ct->c_ctexbody;
ce = ct->c_cefile;
- if ((ftp = context_find (nmhaccessftp)) && !*ftp)
+ if ((ftp = context_find(nmhaccessftp)) && !*ftp)
ftp = NULL;
#ifndef BUILTIN_FTP
return NOTOK;
#endif
- switch (openExternal (e->eb_parent, e->eb_content, ce, file, &fd)) {
+ switch (openExternal(e->eb_parent, e->eb_content, ce, file, &fd)) {
case NOTOK:
return NOTOK;
}
if (!e->eb_name || !e->eb_site) {
- content_error (NULL, ct, "missing %s parameter",
- e->eb_name ? "site": "name");
+ content_error(NULL, ct, "missing %s parameter",
+ e->eb_name ? "site": "name");
return NOTOK;
}
if (xpid) {
if (xpid < 0)
xpid = -xpid;
- pidcheck (pidwait (xpid, NOTOK));
+ pidcheck(pidwait(xpid, NOTOK));
xpid = 0;
}
/*
** Construct the query message for user
*/
- snprintf (bp, buflen, "Retrieve %s", e->eb_name);
- len = strlen (bp);
+ snprintf(bp, buflen, "Retrieve %s", e->eb_name);
+ len = strlen(bp);
bp += len;
buflen -= len;
if (e->eb_partno) {
- snprintf (bp, buflen, " (content %s)", e->eb_partno);
- len = strlen (bp);
+ snprintf(bp, buflen, " (content %s)", e->eb_partno);
+ len = strlen(bp);
bp += len;
buflen -= len;
}
- snprintf (bp, buflen, "\n using %sFTP from site %s",
- e->eb_flags ? "anonymous " : "", e->eb_site);
- len = strlen (bp);
+ snprintf(bp, buflen, "\n using %sFTP from site %s",
+ e->eb_flags ? "anonymous " : "", e->eb_site);
+ len = strlen(bp);
bp += len;
buflen -= len;
if (e->eb_size > 0) {
- snprintf (bp, buflen, " (%lu octets)", e->eb_size);
- len = strlen (bp);
+ snprintf(bp, buflen, " (%lu octets)", e->eb_size);
+ len = strlen(bp);
bp += len;
buflen -= len;
}
- snprintf (bp, buflen, "? ");
+ snprintf(bp, buflen, "? ");
/*
** Now, check the answer
*/
- if (!getanswer (buffer))
+ 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);
+ ruserpass(e->eb_site, &username, &password);
user = username;
pass = password;
}
ce->ce_unlink = (*file == NULL);
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) {
+ 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) {
if (*file == NULL) {
ce->ce_unlink = 0;
caching = 1;
}
if (*file)
- ce->ce_file = add (*file, NULL);
+ ce->ce_file = add(*file, NULL);
else if (caching)
- ce->ce_file = add (cachefile, NULL);
+ ce->ce_file = add(cachefile, NULL);
else
- ce->ce_file = add (m_mktemp(tmp, NULL, NULL), NULL);
+ ce->ce_file = add(m_mktemp(tmp, NULL, NULL), NULL);
- if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
+ if ((ce->ce_fp = fopen(ce->ce_file, "w+")) == NULL) {
+ content_error (ce->ce_file, ct,
+ "unable to fopen for reading/writing");
return NOTOK;
}
char *vec[9];
vecp = 0;
- vec[vecp++] = r1bindex (ftp, '/');
+ vec[vecp++] = r1bindex(ftp, '/');
vec[vecp++] = e->eb_site;
vec[vecp++] = user;
vec[vecp++] = pass;
vec[vecp++] = e->eb_dir;
vec[vecp++] = e->eb_name;
vec[vecp++] = ce->ce_file,
- vec[vecp++] = e->eb_mode && !mh_strcasecmp (e->eb_mode, "ascii")
- ? "ascii" : "binary";
+ vec[vecp++] = e->eb_mode &&
+ !mh_strcasecmp(e->eb_mode, "ascii") ?
+ "ascii" : "binary";
vec[vecp] = NULL;
- fflush (stdout);
+ fflush(stdout);
- for (i = 0; (child_id = vfork ()) == NOTOK && i < 5; i++)
- sleep (5);
+ for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
+ sleep(5);
switch (child_id) {
case NOTOK:
- adios ("fork", "unable to");
+ adios("fork", "unable to");
/* NOTREACHED */
case OK:
- close (fileno (ce->ce_fp));
- execvp (ftp, vec);
- fprintf (stderr, "unable to exec ");
- perror (ftp);
- _exit (-1);
+ close(fileno(ce->ce_fp));
+ execvp(ftp, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(ftp);
+ _exit(-1);
/* NOTREACHED */
default:
- if (pidXwait (child_id, NULL)) {
+ if (pidXwait(child_id, NULL)) {
#ifdef BUILTIN_FTP
losing_ftp:
#endif
}
}
#ifdef BUILTIN_FTP
- else if (ftp_get (e->eb_site, user, pass, e->eb_dir, e->eb_name,
- ce->ce_file, e->eb_mode && !mh_strcasecmp (e->eb_mode, "ascii"), 0)
- == NOTOK)
- goto losing_ftp;
+ else if (ftp_get(e->eb_site, user, pass, e->eb_dir, e->eb_name,
+ ce->ce_file, e->eb_mode && !mh_strcasecmp(e->eb_mode,
+ "ascii"), 0) == NOTOK)
+ goto losing_ftp;
#endif
if (cachefile[0]) {
if (caching)
- chmod (cachefile, cachetype ? m_gmprot () : 0444);
+ chmod(cachefile, cachetype ? m_gmprot() : 0444);
else {
int mask;
FILE *fp;
- mask = umask (cachetype ? ~m_gmprot () : 0222);
- if ((fp = fopen (cachefile, "w"))) {
+ mask = umask(cachetype ? ~m_gmprot() : 0222);
+ if ((fp = fopen(cachefile, "w"))) {
int cc;
FILE *gp = ce->ce_fp;
- fseek (gp, 0L, SEEK_SET);
+ fseek(gp, 0L, SEEK_SET);
- while ((cc= fread (buffer, sizeof(*buffer), sizeof(buffer), gp)) > 0)
- fwrite (buffer, sizeof(*buffer), cc, fp);
- fflush (fp);
+ while ((cc= fread(buffer, sizeof(*buffer),
+ sizeof(buffer), gp)) > 0)
+ fwrite(buffer, sizeof(*buffer), cc, fp);
+ fflush(fp);
- if (ferror (gp)) {
- admonish (ce->ce_file, "error reading");
- unlink (cachefile);
- } else if (ferror (fp)) {
- admonish (cachefile, "error writing");
- unlink (cachefile);
+ if (ferror(gp)) {
+ admonish(ce->ce_file, "error reading");
+ unlink(cachefile);
+ } else if (ferror(fp)) {
+ admonish(cachefile, "error writing");
+ unlink(cachefile);
}
- fclose (fp);
+ fclose(fp);
}
- umask (mask);
+ umask(mask);
}
}
- fseek (ce->ce_fp, 0L, SEEK_SET);
+ fseek(ce->ce_fp, 0L, SEEK_SET);
*file = ce->ce_file;
- return fileno (ce->ce_fp);
+ return fileno(ce->ce_fp);
}
*/
static int
-InitMail (CT ct)
+InitMail(CT ct)
{
- return init_encoding (ct, openMail);
+ return init_encoding(ct, openMail);
}
static int
-openMail (CT ct, char **file)
+openMail(CT ct, char **file)
{
int child_id, fd, i, vecp;
int len, buflen;
struct exbody *e = ct->c_ctexbody;
CE ce = ct->c_cefile;
- switch (openExternal (e->eb_parent, e->eb_content, ce, file, &fd)) {
+ switch (openExternal(e->eb_parent, e->eb_content, ce, file, &fd)) {
case NOTOK:
return NOTOK;
}
if (!e->eb_server) {
- content_error (NULL, ct, "missing server parameter");
+ content_error(NULL, ct, "missing server parameter");
return NOTOK;
}
if (xpid) {
if (xpid < 0)
xpid = -xpid;
- pidcheck (pidwait (xpid, NOTOK));
+ pidcheck(pidwait(xpid, NOTOK));
xpid = 0;
}
buflen = sizeof(buffer);
/* Now, construct query message */
- snprintf (bp, buflen, "Retrieve content");
- len = strlen (bp);
+ snprintf(bp, buflen, "Retrieve content");
+ len = strlen(bp);
bp += len;
buflen -= len;
if (e->eb_partno) {
- snprintf (bp, buflen, " %s", e->eb_partno);
- len = strlen (bp);
+ snprintf(bp, buflen, " %s", e->eb_partno);
+ len = strlen(bp);
bp += len;
buflen -= len;
}
- snprintf (bp, buflen, " by asking %s\n\n%s\n? ", e->eb_server,
- e->eb_subject ? e->eb_subject : e->eb_body);
+ snprintf(bp, buflen, " by asking %s\n\n%s\n? ", e->eb_server,
+ e->eb_subject ? e->eb_subject : e->eb_body);
/* Now, check answer */
- if (!getanswer (buffer))
+ if (!getanswer(buffer))
return NOTOK;
vecp = 0;
- vec[vecp++] = r1bindex (mailproc, '/');
+ vec[vecp++] = r1bindex(mailproc, '/');
vec[vecp++] = e->eb_server;
vec[vecp++] = "-subject";
vec[vecp++] = e->eb_subject ? e->eb_subject : "mail-server request";
vec[vecp++] = e->eb_body;
vec[vecp] = NULL;
- for (i = 0; (child_id = vfork ()) == NOTOK && i < 5; i++)
- sleep (5);
+ for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
+ sleep(5);
switch (child_id) {
case NOTOK:
- advise ("fork", "unable to");
+ advise("fork", "unable to");
return NOTOK;
case OK:
- execvp (mailproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (mailproc);
- _exit (-1);
+ execvp(mailproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(mailproc);
+ _exit(-1);
/* NOTREACHED */
default:
- if (pidXwait (child_id, NULL) == OK)
- advise (NULL, "request sent");
+ if (pidXwait(child_id, NULL) == OK)
+ advise(NULL, "request sent");
break;
}
if (*file == NULL) {
- ce->ce_file = add (m_mktemp(tmp, NULL, NULL), NULL);
+ ce->ce_file = add(m_mktemp(tmp, NULL, NULL), NULL);
ce->ce_unlink = 1;
} else {
- ce->ce_file = add (*file, NULL);
+ ce->ce_file = add(*file, NULL);
ce->ce_unlink = 0;
}
- if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
+ if ((ce->ce_fp = fopen(ce->ce_file, "w+")) == NULL) {
+ content_error(ce->ce_file, ct,
+ "unable to fopen for reading/writing");
return NOTOK;
}
** prints it, too.
*/
if (ct->c_showproc)
- free (ct->c_showproc);
- ct->c_showproc = add ("true", NULL);
+ free(ct->c_showproc);
+ ct->c_showproc = add("true", NULL);
- fseek (ce->ce_fp, 0L, SEEK_SET);
+ fseek(ce->ce_fp, 0L, SEEK_SET);
*file = ce->ce_file;
- return fileno (ce->ce_fp);
+ return fileno(ce->ce_fp);
}
static int
-readDigest (CT ct, char *cp)
+readDigest(CT ct, char *cp)
{
int bitno, skip;
unsigned long bits;
+ sizeof(ct->c_digest) / sizeof(ct->c_digest[0]); *cp; cp++)
switch (*cp) {
default:
- if (skip || (*cp & 0x80)
- || (value = b642nib[*cp & 0x7f]) > 0x3f) {
+ if (skip || (*cp & 0x80) ||
+ (value = b642nib[*cp & 0x7f])
+ > 0x3f) {
if (debugsw)
- fprintf (stderr, "invalid BASE64 encoding\n");
+ fprintf(stderr, "invalid BASE64 encoding\n");
return NOTOK;
}
}
if (bitno != 18) {
if (debugsw)
- fprintf (stderr, "premature ending (bitno %d)\n",
+ fprintf(stderr, "premature ending (bitno %d)\n",
bitno);
return NOTOK;
if (debugsw) {
while (*cp)
cp++;
- fprintf (stderr, "invalid MD5 digest (got %d octets)\n",
+ fprintf(stderr, "invalid MD5 digest (got %d octets)\n",
(int)(cp - bp));
}
}
if (debugsw) {
- fprintf (stderr, "MD5 digest=");
+ fprintf(stderr, "MD5 digest=");
for (dp = ct->c_digest; dp < ep; dp++)
- fprintf (stderr, "%02x", *dp & 0xff);
- fprintf (stderr, "\n");
+ fprintf(stderr, "%02x", *dp & 0xff);
+ fprintf(stderr, "\n");
}
return OK;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
}
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
/* If no messages are given, print folder pathname */
if (!msgs.size) {
- printf ("%s\n", maildir);
- done (0);
+ printf("%s\n", maildir);
+ done(0);
}
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/*
** We need to make sure there is message status space
** 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");
+ if (!(mp = folder_realloc(mp, 1, mp->hghmsg + 10)))
+ adios(NULL, "unable to allocate folder storage");
} else if (mp->lowoff > 1) {
- if (!(mp = folder_realloc (mp, 1, mp->hghoff)))
- adios (NULL, "unable to allocate folder storage");
+ if (!(mp = folder_realloc(mp, 1, mp->hghoff)))
+ adios(NULL, "unable to allocate folder storage");
}
mp->msgflags |= ALLOW_NEW; /* allow the "new" sequence */
/* parse all the message ranges/sequences and set SELECTED */
for (i = 0; i < msgs.size; i++)
- if (!m_convert (mp, msgs.msgs[i]))
- done (1);
+ if (!m_convert(mp, msgs.msgs[i]))
+ done(1);
- seq_setprev (mp); /* set the previous-sequence */
+ seq_setprev(mp); /* set the previous-sequence */
/* print the path of all selected messages */
for (i = mp->lowsel; i <= mp->hghsel; i++)
- if (is_selected (mp, i))
- printf ("%s/%s\n", mp->foldpath, m_name (i));
+ if (is_selected(mp, i))
+ printf("%s/%s\n", mp->foldpath, m_name(i));
- seq_save (mp); /* synchronize message sequences */
- context_save (); /* save the context file */
- folder_free (mp); /* free folder/message structure */
- done (0);
+ seq_save(mp); /* synchronize message sequences */
+ context_save(); /* save the context file */
+ folder_free(mp); /* free folder/message structure */
+ done(0);
return 1;
}
#define quitser pipeser
/* mhparse.c */
-CT parse_mime (char *);
+CT parse_mime(char *);
/* mhmisc.c */
-int part_ok (CT, int);
-int type_ok (CT, int);
-void set_endian (void);
-void flush_errors (void);
+int part_ok(CT, int);
+int type_ok(CT, int);
+void set_endian(void);
+void flush_errors(void);
/* mhshowsbr.c */
-void show_all_messages (CT *);
+void show_all_messages(CT *);
/* mhfree.c */
-void free_content (CT);
+void free_content(CT);
extern CT *cts;
-void freects_done (int) NORETURN;
+void freects_done(int) NORETURN;
/*
** static prototypes
*/
-static RETSIGTYPE pipeser (int);
+static RETSIGTYPE pipeser(int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int msgnum, *icachesw;
char *cp, *file = NULL, *folder = NULL;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case RCACHESW:
icachesw = &rcachesw;
icachesw = &wcachesw;
do_cache:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
- switch (*icachesw = smatch (cp, caches)) {
+ switch (*icachesw = smatch(cp, caches)) {
case AMBIGSW:
- ambigsw (cp, caches);
- done (1);
+ ambigsw(cp, caches);
+ done(1);
case UNKWNSW:
- adios (NULL, "%s unknown", cp);
+ adios(NULL, "%s unknown", cp);
default:
break;
}
case PARTSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
if (npart >= NPARTS)
- adios (NULL, "too many parts (starting with %s), %d max",
- cp, NPARTS);
+ adios(NULL, "too many parts (starting with %s), %d max", cp, NPARTS);
parts[npart++] = cp;
continue;
case TYPESW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
if (ntype >= NTYPES)
- adios (NULL, "too many types (starting with %s), %d max",
- cp, NTYPES);
+ adios(NULL, "too many types (starting with %s), %d max", cp, NTYPES);
types[ntype++] = cp;
continue;
case FILESW:
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : path (cp, TFILE);
+ file = *cp == '-' ? cp : path(cp, TFILE);
continue;
case FORMSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
if (formsw)
- free (formsw);
- formsw = getcpy (etcpath (cp));
+ free(formsw);
+ formsw = getcpy(etcpath(cp));
continue;
/*
*/
case PROGSW:
if (!(progsw = *argp++) || *progsw == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
case NPROGSW:
case LENSW:
case WIDTHSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
/* null terminate the list of acceptable parts/types */
parts[npart] = NULL;
types[ntype] = NULL;
- set_endian ();
+ set_endian();
- if ((cp = getenv ("MM_NOASK")) && !strcmp (cp, "1")) {
+ if ((cp = getenv("MM_NOASK")) && !strcmp(cp, "1")) {
nolist = 1;
pausesw = 0;
}
/*
** 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);
+ 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)",
+ admonish("", "unable to read $MHSHOW profile (%s)",
cp);
}
}
/*
** Read the standard profile setup
*/
- if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) {
- readconfig ((struct node **) 0, fp, cp, 0);
- fclose (fp);
+ if ((fp = fopen(cp = etcpath("mhn.defaults"), "r"))) {
+ readconfig((struct node **) 0, fp, cp, 0);
+ fclose(fp);
}
/* Check for public cache location */
- if ((cache_public = context_find (nmhcache)) && *cache_public != '/')
+ if ((cache_public = context_find(nmhcache)) && *cache_public != '/')
cache_public = NULL;
/* Check for private cache location */
- if (!(cache_private = context_find (nmhprivcache)))
+ if (!(cache_private = context_find(nmhprivcache)))
cache_private = ".cache";
- cache_private = getcpy (m_maildir (cache_private));
+ 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.
*/
- if ((cp = context_find (nmhstorage)) && *cp)
- tmp = concat (cp, "/", invo_name, NULL);
+ if ((cp = context_find(nmhstorage)) && *cp)
+ tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = add (m_maildir (invo_name), NULL);
+ tmp = add(m_maildir(invo_name), NULL);
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (file && msgs.size)
- adios (NULL, "cannot specify msg and file at same time!");
+ adios(NULL, "cannot specify msg and file at same time!");
/*
** check if message is coming from file
*/
if (file) {
- if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
- adios (NULL, "out of memory");
+ if (!(cts = (CT *) calloc((size_t) 2, sizeof(*cts))))
+ adios(NULL, "out of memory");
ctp = cts;
- if ((ct = parse_mime (file)));
+ if ((ct = parse_mime(file)));
*ctp++ = ct;
} else {
/*
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
+ if (!m_convert(mp, msgs.msgs[msgnum]))
+ done(1);
/*
** Set the SELECT_UNSEEN bit for all the SELECTED messages,
*/
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
if (is_selected(mp, msgnum))
- set_unseen (mp, msgnum);
+ set_unseen(mp, msgnum);
- seq_setprev (mp); /* set the Previous-Sequence */
- seq_setunseen (mp, 1); /* unset the Unseen-Sequence */
+ seq_setprev(mp); /* set the Previous-Sequence */
+ seq_setunseen(mp, 1); /* unset the Unseen-Sequence */
- if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1),
+ if (!(cts = (CT *) calloc((size_t) (mp->numsel + 1),
sizeof(*cts))))
- adios (NULL, "out of memory");
+ adios(NULL, "out of memory");
ctp = cts;
/*
if (is_selected(mp, msgnum)) {
char *msgnam;
- msgnam = m_name (msgnum);
- if ((ct = parse_mime (msgnam)))
+ msgnam = m_name(msgnum);
+ if ((ct = parse_mime(msgnam)))
*ctp++ = ct;
}
}
}
if (!*cts)
- done (1);
+ done(1);
userrs = 1;
- SIGNAL (SIGQUIT, quitser);
- SIGNAL (SIGPIPE, pipeser);
+ SIGNAL(SIGQUIT, quitser);
+ SIGNAL(SIGPIPE, pipeser);
/*
** Get the associated umask for the relevant contents.
struct stat st;
ct = *ctp;
- if (type_ok (ct, 1) && !ct->c_umask) {
- if (stat (ct->c_file, &st) != NOTOK)
+ if (type_ok(ct, 1) && !ct->c_umask) {
+ if (stat(ct->c_file, &st) != NOTOK)
ct->c_umask = ~(st.st_mode & 0777);
else
ct->c_umask = ~m_gmprot();
/*
** Show the message content
*/
- show_all_messages (cts);
+ show_all_messages(cts);
/* Now free all the structures for the content */
for (ctp = cts; *ctp; ctp++)
- free_content (*ctp);
+ free_content(*ctp);
- free ((char *) cts);
+ free((char *) cts);
cts = NULL;
/* If reading from a folder, do some updating */
if (mp) {
- context_replace (pfolder, folder); /* update current folder */
- seq_setcur (mp, mp->hghsel); /* update current message */
- seq_save (mp); /* synchronize sequences */
- context_save (); /* save the context file */
+ context_replace(pfolder, folder); /* update current folder */
+ seq_setcur(mp, mp->hghsel); /* update current message */
+ seq_save(mp); /* synchronize sequences */
+ context_save(); /* save the context file */
}
- done (0);
+ done(0);
return 1;
}
static RETSIGTYPE
-pipeser (int i)
+pipeser(int i)
{
if (i == SIGQUIT) {
- unlink ("core");
- fflush (stdout);
- fprintf (stderr, "\n");
- fflush (stderr);
+ unlink("core");
+ fflush(stdout);
+ fprintf(stderr, "\n");
+ fflush(stderr);
}
- done (1);
+ done(1);
/* NOTREACHED */
}
/* termsbr.c */
-int SOprintf (char *, ...);
+int SOprintf(char *, ...);
/* mhparse.c */
-int pidcheck (int);
+int pidcheck(int);
/* mhmisc.c */
-int part_ok (CT, int);
-int type_ok (CT, int);
-void content_error (char *, CT, char *, ...);
-void flush_errors (void);
+int part_ok(CT, int);
+int type_ok(CT, int);
+void content_error(char *, CT, char *, ...);
+void flush_errors(void);
/* mhlistsbr.c */
-int list_switch (CT, int, int, int, int);
-int list_content (CT, int, int, int, int);
+int list_switch(CT, int, int, int, int);
+int list_content(CT, int, int, int, int);
/*
** prototypes
*/
-void show_all_messages (CT *);
-int show_content_aux (CT, int, int, char *, char *);
+void show_all_messages(CT *);
+int show_content_aux(CT, int, int, char *, char *);
/*
** 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 *,
+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_text (CT, int, int);
-static int show_multi (CT, int, int);
-static int show_multi_internal (CT, int, int);
-static int show_multi_aux (CT, int, int, char *);
-static int show_message_rfc822 (CT, int, int);
-static int show_partial (CT, int, int);
-static int show_external (CT, int, int);
-static RETSIGTYPE intrser (int);
+static int show_text(CT, int, int);
+static int show_multi(CT, int, int);
+static int show_multi_internal(CT, int, int);
+static int show_multi_aux(CT, int, int, char *);
+static int show_message_rfc822(CT, int, int);
+static int show_partial(CT, int, int);
+static int show_external(CT, int, int);
+static RETSIGTYPE intrser(int);
/*
*/
void
-show_all_messages (CT *cts)
+show_all_messages(CT *cts)
{
CT ct, *ctp;
** for showing headers of MIME messages.
*/
if (!formsw)
- formsw = getcpy (etcpath ("mhl.headers"));
+ formsw = getcpy(etcpath("mhl.headers"));
/*
** If form is "mhl.null", suppress display of header.
*/
- if (!strcmp (formsw, "mhl.null"))
+ if (!strcmp(formsw, "mhl.null"))
formsw = NULL;
for (ctp = cts; *ctp; ctp++) {
ct = *ctp;
/* if top-level type is ok, then display message */
- if (type_ok (ct, 1))
- show_single_message (ct, formsw);
+ if (type_ok(ct, 1))
+ show_single_message(ct, formsw);
}
}
*/
static void
-show_single_message (CT ct, char *form)
+show_single_message(CT ct, char *form)
{
sigset_t set, oset;
** 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));
+ umask(ct->c_umask & ~(0100));
/*
** If you have a format file, then display
xpid = 0;
/* Show the body of the message */
- show_switch (ct, 1, 0);
+ show_switch(ct, 1, 0);
if (ct->c_fp) {
- fclose (ct->c_fp);
+ fclose(ct->c_fp);
ct->c_fp = NULL;
}
if (ct->c_ceclosefnx)
(*ct->c_ceclosefnx) (ct);
/* block a few signals */
- sigemptyset (&set);
- sigaddset (&set, SIGHUP);
- sigaddset (&set, SIGINT);
- sigaddset (&set, SIGQUIT);
- sigaddset (&set, SIGTERM);
- SIGPROCMASK (SIG_BLOCK, &set, &oset);
-
- while (wait (&status) != NOTOK) {
+ sigemptyset(&set);
+ sigaddset(&set, SIGHUP);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGQUIT);
+ sigaddset(&set, SIGTERM);
+ SIGPROCMASK(SIG_BLOCK, &set, &oset);
+
+ while (wait(&status) != NOTOK) {
#ifdef HAVE_UNION_WAIT
- pidcheck (status.w_status);
+ pidcheck(status.w_status);
#else
- pidcheck (status);
+ pidcheck(status);
#endif
continue;
}
/* reset the signal mask */
- SIGPROCMASK (SIG_SETMASK, &oset, &set);
+ SIGPROCMASK(SIG_SETMASK, &oset, &set);
xpid = 0;
- flush_errors ();
+ flush_errors();
}
*/
static void
-DisplayMsgHeader (CT ct, char *form)
+DisplayMsgHeader(CT ct, char *form)
{
pid_t child_id;
int i, vecp;
char *vec[8];
vecp = 0;
- vec[vecp++] = r1bindex (mhlproc, '/');
+ vec[vecp++] = r1bindex(mhlproc, '/');
vec[vecp++] = "-form";
vec[vecp++] = form;
vec[vecp++] = "-nobody";
}
vec[vecp] = NULL;
- fflush (stdout);
+ fflush(stdout);
for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case NOTOK:
- adios ("fork", "unable to");
+ adios("fork", "unable to");
/* NOTREACHED */
case OK:
- execvp (mhlproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (mhlproc);
- _exit (-1);
+ execvp(mhlproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(mhlproc);
+ _exit(-1);
/* NOTREACHED */
default:
*/
static int
-show_switch (CT ct, int serial, int alternate)
+show_switch(CT ct, int serial, int alternate)
{
switch (ct->c_type) {
case CT_MULTIPART:
- return show_multi (ct, serial, alternate);
+ return show_multi(ct, serial, alternate);
break;
case CT_MESSAGE:
switch (ct->c_subtype) {
case MESSAGE_PARTIAL:
- return show_partial (ct, serial, alternate);
+ return show_partial(ct, serial,
+ alternate);
break;
case MESSAGE_EXTERNAL:
- return show_external (ct, serial, alternate);
+ return show_external(ct, serial,
+ alternate);
break;
case MESSAGE_RFC822:
default:
- return show_message_rfc822 (ct, serial, alternate);
+ return show_message_rfc822(ct, serial,
+ alternate);
break;
}
break;
case CT_TEXT:
- return show_text (ct, serial, alternate);
+ return show_text(ct, serial, alternate);
break;
case CT_AUDIO:
case CT_IMAGE:
case CT_VIDEO:
case CT_APPLICATION:
- return show_content (ct, serial, alternate);
+ return show_content(ct, serial, alternate);
break;
default:
- adios (NULL, "unknown content type %d", ct->c_type);
+ adios(NULL, "unknown content type %d", ct->c_type);
break;
}
*/
static int
-show_content (CT ct, int serial, int alternate)
+show_content(CT ct, int serial, int alternate)
{
char *cp, buffer[BUFSIZ];
CI ci = &ct->c_ctinfo;
/* Check for mhshow-show-type/subtype */
- snprintf (buffer, sizeof(buffer), "%s-show-%s/%s",
+ snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
invo_name, ci->ci_type, ci->ci_subtype);
- if ((cp = context_find (buffer)) && *cp != '\0')
- return show_content_aux (ct, serial, alternate, cp, NULL);
+ if ((cp = context_find(buffer)) && *cp != '\0')
+ return show_content_aux(ct, serial, alternate, cp, NULL);
/* Check for mhshow-show-type */
- snprintf (buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
- if ((cp = context_find (buffer)) && *cp != '\0')
- return show_content_aux (ct, serial, alternate, cp, NULL);
+ snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
+ if ((cp = context_find(buffer)) && *cp != '\0')
+ return show_content_aux(ct, serial, alternate, cp, NULL);
if ((cp = ct->c_showproc))
- return show_content_aux (ct, serial, alternate, cp, NULL);
+ return show_content_aux(ct, serial, alternate, cp, NULL);
/* complain if we are not a part of a multipart/alternative */
if (!alternate)
- content_error (NULL, ct, "don't know how to display content");
+ content_error(NULL, ct, "don't know how to display content");
return NOTOK;
}
*/
int
-show_content_aux (CT ct, int serial, int alternate, char *cp, char *cracked)
+show_content_aux(CT ct, int serial, int alternate, char *cp, char *cracked)
{
int fd, len, buflen, quoted;
int xstdin, xlist, xpause, xtty;
if (!ct->c_ceopenfnx) {
if (!alternate)
- content_error (NULL, ct,
+ content_error(NULL, ct,
"don't know how to decode content");
return NOTOK;
file = NULL;
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return NOTOK;
- if (ct->c_showproc && !strcmp (ct->c_showproc, "true"))
+ if (ct->c_showproc && !strcmp(ct->c_showproc, "true"))
return (alternate ? DONE : OK);
xlist = 0;
xtty = 0;
if (cracked) {
- strncpy (buffer, cp, sizeof(buffer));
+ strncpy(buffer, cp, sizeof(buffer));
goto got_command;
}
for (ap = ci->ci_attrs, ep = ci->ci_values;
*ap; ap++, ep++) {
- snprintf (bp, buflen, "%s%s=\"%s\"",
+ snprintf(bp, buflen, "%s%s=\"%s\"",
s, *ap, *ep);
- len = strlen (bp);
+ len = strlen(bp);
bp += len;
buflen -= len;
s = " ";
if (ct->c_descr) {
char *s;
- s = trimcpy (ct->c_descr);
- strncpy (bp, s, buflen);
- free (s);
+ s = trimcpy(ct->c_descr);
+ strncpy(bp, s, buflen);
+ free(s);
}
break;
case 'f':
/* insert filename containing content */
- snprintf (bp, buflen, "'%s'", file);
+ snprintf(bp, buflen, "'%s'", file);
/*
** since we've quoted the file argument,
** set things up to look past it, to avoid
case 's':
/* insert subtype of content */
- strncpy (bp, ci->ci_subtype, buflen);
+ strncpy(bp, ci->ci_subtype, buflen);
break;
case '%':
buflen--;
continue;
}
- len = strlen (bp);
+ len = strlen(bp);
bp += len;
buflen -= len;
** already
*/
if (!quoted && buflen) {
- len = strlen (pp);
- memmove (pp + 1, pp, len);
+ len = strlen(pp);
+ memmove(pp + 1, pp, len);
*pp++ = '\'';
buflen--;
bp++;
}
/* Escape existing quotes */
- while ((pp = strchr (pp, '\'')) && buflen > 3) {
- len = strlen (pp++);
- memmove (pp + 3, pp, len);
+ while ((pp = strchr(pp, '\'')) && buflen > 3) {
+ len = strlen(pp++);
+ memmove(pp + 3, pp, len);
*pp++ = '\\';
*pp++ = '\'';
*pp++ = '\'';
if (ct->c_termproc) {
char term[BUFSIZ];
- strncpy (term, buffer, sizeof(term));
- snprintf (buffer, sizeof(buffer), ct->c_termproc, term);
+ strncpy(term, buffer, sizeof(term));
+ snprintf(buffer, sizeof(buffer), ct->c_termproc, term);
}
got_command:
- return show_content_aux2 (ct, serial, alternate, cracked, buffer,
+ return show_content_aux2(ct, serial, alternate, cracked, buffer,
fd, xlist, xpause, xstdin, xtty);
}
*/
static int
-show_content_aux2 (CT ct, int serial, int alternate, char *cracked,
+show_content_aux2(CT ct, int serial, int alternate, char *cracked,
char *buffer, int fd, int xlist, int xpause, int xstdin, int xtty)
{
pid_t child_id;
char *vec[4], exec[BUFSIZ + sizeof "exec "];
if (debugsw || cracked) {
- fflush (stdout);
+ fflush(stdout);
- fprintf (stderr, "%s msg %s", cracked ? "storing" : "show",
+ fprintf(stderr, "%s msg %s", cracked ? "storing" : "show",
ct->c_file);
if (ct->c_partno)
- fprintf (stderr, " part %s", ct->c_partno);
+ fprintf(stderr, " part %s", ct->c_partno);
if (cracked)
- fprintf (stderr, " using command (cd %s; %s)\n",
+ fprintf(stderr, " using command (cd %s; %s)\n",
cracked, buffer);
else
- fprintf (stderr, " using command %s\n", buffer);
+ fprintf(stderr, " using command %s\n", buffer);
}
if (xpid < 0 || (xtty && xpid)) {
if (xpid < 0)
xpid = -xpid;
- pidcheck(pidwait (xpid, NOTOK));
+ pidcheck(pidwait(xpid, NOTOK));
xpid = 0;
}
char prompt[BUFSIZ];
if (ct->c_type == CT_MULTIPART)
- list_content (ct, -1, 1, 0, 0);
+ list_content(ct, -1, 1, 0, 0);
else
- list_switch (ct, -1, 1, 0, 0);
+ list_switch(ct, -1, 1, 0, 0);
- if (xpause && SOprintf ("Press <return> to show content..."))
- printf ("Press <return> to show content...");
+ if (xpause && SOprintf("Press <return> to show content..."))
+ printf("Press <return> to show content...");
if (xpause) {
int intr;
SIGNAL_HANDLER istat;
- istat = SIGNAL (SIGINT, intrser);
- if ((intr = sigsetjmp (intrenv, 1)) == OK) {
- fflush (stdout);
+ istat = SIGNAL(SIGINT, intrser);
+ if ((intr = sigsetjmp(intrenv, 1)) == OK) {
+ fflush(stdout);
prompt[0] = 0;
- read (fileno (stdout), prompt, sizeof(prompt));
+ read(fileno(stdout), prompt, sizeof(prompt));
}
- SIGNAL (SIGINT, istat);
+ SIGNAL(SIGINT, istat);
if (intr != OK || prompt[0] == 'n') {
(*ct->c_ceclosefnx) (ct);
return (alternate ? DONE : NOTOK);
}
}
- snprintf (exec, sizeof(exec), "exec %s", buffer);
+ snprintf(exec, sizeof(exec), "exec %s", buffer);
vec[0] = "/bin/sh";
vec[1] = "-c";
vec[2] = exec;
vec[3] = NULL;
- fflush (stdout);
+ fflush(stdout);
- for (i = 0; (child_id = vfork ()) == NOTOK && i < 5; i++)
- sleep (5);
+ for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
+ sleep(5);
switch (child_id) {
case NOTOK:
- advise ("fork", "unable to");
+ advise("fork", "unable to");
(*ct->c_ceclosefnx) (ct);
return NOTOK;
case OK:
if (cracked)
- chdir (cracked);
+ chdir(cracked);
if (!xstdin)
- dup2 (fd, 0);
- close (fd);
- execvp ("/bin/sh", vec);
- fprintf (stderr, "unable to exec ");
- perror ("/bin/sh");
- _exit (-1);
+ dup2(fd, 0);
+ close(fd);
+ execvp("/bin/sh", vec);
+ fprintf(stderr, "unable to exec ");
+ perror("/bin/sh");
+ _exit(-1);
/* NOTREACHED */
default:
if (xtty)
xpid = child_id;
} else {
- pidcheck (pidXwait (child_id, NULL));
+ pidcheck(pidXwait(child_id, NULL));
}
if (fd != NOTOK)
*/
static int
-show_text (CT ct, int serial, int alternate)
+show_text(CT ct, int serial, int alternate)
{
char *cp, buffer[BUFSIZ];
CI ci = &ct->c_ctinfo;
/* Check for mhshow-show-type/subtype */
- snprintf (buffer, sizeof(buffer), "%s-show-%s/%s",
- invo_name, ci->ci_type, ci->ci_subtype);
- if ((cp = context_find (buffer)) && *cp != '\0')
- return show_content_aux (ct, serial, alternate, cp, NULL);
+ snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
+ invo_name, ci->ci_type, ci->ci_subtype);
+ if ((cp = context_find(buffer)) && *cp != '\0')
+ return show_content_aux(ct, serial, alternate, cp, NULL);
/* Check for mhshow-show-type */
- snprintf (buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
- if ((cp = context_find (buffer)) && *cp != '\0')
- return show_content_aux (ct, serial, alternate, cp, NULL);
+ snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
+ if ((cp = context_find(buffer)) && *cp != '\0')
+ 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
*/
if (!alternate || ct->c_subtype == TEXT_PLAIN) {
- snprintf (buffer, sizeof(buffer), "%%p%s '%%F'", progsw ? progsw :
- moreproc && *moreproc ? moreproc : "more");
- cp = (ct->c_showproc = add (buffer, NULL));
- return show_content_aux (ct, serial, alternate, cp, NULL);
+ snprintf(buffer, sizeof(buffer), "%%p%s '%%F'",
+ progsw ? progsw : moreproc && *moreproc ?
+ moreproc : "more");
+ cp = (ct->c_showproc = add(buffer, NULL));
+ return show_content_aux(ct, serial, alternate, cp, NULL);
}
return NOTOK;
*/
static int
-show_multi (CT ct, int serial, int alternate)
+show_multi(CT ct, int serial, int alternate)
{
char *cp, buffer[BUFSIZ];
CI ci = &ct->c_ctinfo;
/* Check for mhshow-show-type/subtype */
- snprintf (buffer, sizeof(buffer), "%s-show-%s/%s",
- invo_name, ci->ci_type, ci->ci_subtype);
- if ((cp = context_find (buffer)) && *cp != '\0')
- return show_multi_aux (ct, serial, alternate, cp);
+ snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
+ invo_name, ci->ci_type, ci->ci_subtype);
+ if ((cp = context_find(buffer)) && *cp != '\0')
+ return show_multi_aux(ct, serial, alternate, cp);
/* Check for mhshow-show-type */
- snprintf (buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
- if ((cp = context_find (buffer)) && *cp != '\0')
- return show_multi_aux (ct, serial, alternate, cp);
+ snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
+ if ((cp = context_find(buffer)) && *cp != '\0')
+ return show_multi_aux(ct, serial, alternate, cp);
if ((cp = ct->c_showproc))
- return show_multi_aux (ct, serial, alternate, cp);
+ return show_multi_aux(ct, serial, alternate, cp);
/*
** Use default method to display this multipart content
** 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);
+ return show_multi_internal(ct, serial, alternate);
return NOTOK;
}
*/
static int
-show_multi_internal (CT ct, int serial, int alternate)
+show_multi_internal(CT ct, int serial, int alternate)
{
int alternating, nowalternate, nowserial, result;
struct multipart *m = (struct multipart *) ct->c_ctparams;
/* block a few signals */
if (!nowserial) {
- sigemptyset (&set);
- sigaddset (&set, SIGHUP);
- sigaddset (&set, SIGINT);
- sigaddset (&set, SIGQUIT);
- sigaddset (&set, SIGTERM);
- SIGPROCMASK (SIG_BLOCK, &set, &oset);
+ sigemptyset(&set);
+ sigaddset(&set, SIGHUP);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGQUIT);
+ sigaddset(&set, SIGTERM);
+ SIGPROCMASK(SIG_BLOCK, &set, &oset);
}
/*
for (part = m->mp_parts; part; part = part->mp_next) {
p = part->mp_part;
- if (part_ok (p, 0) && type_ok (p, 0)) {
+ if (part_ok(p, 0) && type_ok(p, 0)) {
int inneresult;
- inneresult = show_switch (p, nowserial, nowalternate);
+ inneresult = show_switch(p, nowserial, nowalternate);
switch (inneresult) {
case NOTOK:
if (alternate && !alternating) {
if (alternating && !part) {
if (!alternate)
- content_error (NULL, ct, "don't know how to display any of the contents");
+ content_error(NULL, ct, "don't know how to display any of the contents");
result = NOTOK;
goto out;
}
p = part->mp_part;
if (p->c_pid > OK) {
- if (kill (p->c_pid, 0) == NOTOK)
+ if (kill(p->c_pid, 0) == NOTOK)
p->c_pid = 0;
else
kids++;
}
}
- while (kids > 0 && (pid = wait (&status)) != NOTOK) {
+ while (kids > 0 && (pid = wait(&status)) != NOTOK) {
#ifdef HAVE_UNION_WAIT
- pidcheck (status.w_status);
+ pidcheck(status.w_status);
#else
- pidcheck (status);
+ pidcheck(status);
#endif
for (part = m->mp_parts; part; part = part->mp_next) {
out:
if (!nowserial) {
/* reset the signal mask */
- SIGPROCMASK (SIG_SETMASK, &oset, &set);
+ SIGPROCMASK(SIG_SETMASK, &oset, &set);
}
return result;
*/
static int
-show_multi_aux (CT ct, int serial, int alternate, char *cp)
+show_multi_aux(CT ct, int serial, int alternate, char *cp)
{
int len, buflen, quoted;
int xlist, xpause, xtty;
if (!p->c_ceopenfnx) {
if (!alternate)
- content_error (NULL, p, "don't know how to decode content");
+ content_error(NULL, p, "don't know how to decode content");
return NOTOK;
}
return NOTOK;
/* I'm not sure if this is necessary? */
- p->c_storage = add (file, NULL);
+ p->c_storage = add(file, NULL);
- if (p->c_showproc && !strcmp (p->c_showproc, "true"))
+ if (p->c_showproc && !strcmp(p->c_showproc, "true"))
return (alternate ? DONE : OK);
(*p->c_ceclosefnx) (p);
}
for (ap = ci->ci_attrs, ep = ci->ci_values;
*ap; ap++, ep++) {
- snprintf (bp, buflen, "%s%s=\"%s\"",
+ snprintf(bp, buflen, "%s%s=\"%s\"",
s, *ap, *ep);
- len = strlen (bp);
+ len = strlen(bp);
bp += len;
buflen -= len;
s = " ";
if (ct->c_descr) {
char *s;
- s = trimcpy (ct->c_descr);
- strncpy (bp, s, buflen);
- free (s);
+ s = trimcpy(ct->c_descr);
+ strncpy(bp, s, buflen);
+ free(s);
}
break;
part = part->mp_next) {
p = part->mp_part;
- snprintf (bp, buflen, "%s'%s'", s, p->c_storage);
- len = strlen (bp);
+ snprintf(bp, buflen, "%s'%s'",
+ s, p->c_storage);
+ len = strlen(bp);
bp += len;
buflen -= len;
s = " ";
case 's':
/* insert subtype of content */
- strncpy (bp, ci->ci_subtype, buflen);
+ strncpy(bp, ci->ci_subtype, buflen);
break;
case '%':
buflen--;
continue;
}
- len = strlen (bp);
+ len = strlen(bp);
bp += len;
buflen -= len;
** already
*/
if (!quoted && buflen) {
- len = strlen (pp);
- memmove (pp + 1, pp, len);
+ len = strlen(pp);
+ memmove(pp + 1, pp, len);
*pp++ = '\'';
buflen--;
bp++;
}
/* Escape existing quotes */
- while ((pp = strchr (pp, '\'')) && buflen > 3) {
- len = strlen (pp++);
- memmove (pp + 3, pp, len);
+ while ((pp = strchr(pp, '\'')) && buflen > 3) {
+ len = strlen(pp++);
+ memmove(pp + 3, pp, len);
*pp++ = '\\';
*pp++ = '\'';
*pp++ = '\'';
}
}
- if (buflen <= 0 || (ct->c_termproc && buflen <= strlen(ct->c_termproc))) {
+ 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
if (ct->c_termproc) {
char term[BUFSIZ];
- strncpy (term, buffer, sizeof(term));
- snprintf (buffer, sizeof(buffer), ct->c_termproc, term);
+ strncpy(term, buffer, sizeof(term));
+ snprintf(buffer, sizeof(buffer), ct->c_termproc, term);
}
- return show_content_aux2 (ct, serial, alternate, NULL, buffer,
+ return show_content_aux2(ct, serial, alternate, NULL, buffer,
NOTOK, xlist, xpause, 0, xtty);
}
*/
static int
-show_message_rfc822 (CT ct, int serial, int alternate)
+show_message_rfc822(CT ct, int serial, int alternate)
{
char *cp, buffer[BUFSIZ];
CI ci = &ct->c_ctinfo;
/* Check for mhshow-show-type/subtype */
- snprintf (buffer, sizeof(buffer), "%s-show-%s/%s",
+ snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
invo_name, ci->ci_type, ci->ci_subtype);
- if ((cp = context_find (buffer)) && *cp != '\0')
- return show_content_aux (ct, serial, alternate, cp, NULL);
+ if ((cp = context_find(buffer)) && *cp != '\0')
+ return show_content_aux(ct, serial, alternate, cp, NULL);
/* Check for mhshow-show-type */
- snprintf (buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
- if ((cp = context_find (buffer)) && *cp != '\0')
- return show_content_aux (ct, serial, alternate, cp, NULL);
+ snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
+ if ((cp = context_find(buffer)) && *cp != '\0')
+ return show_content_aux(ct, serial, alternate, cp, NULL);
if ((cp = ct->c_showproc))
- return show_content_aux (ct, serial, alternate, cp, NULL);
+ return show_content_aux(ct, serial, alternate, cp, NULL);
/* default method for message/rfc822 */
if (ct->c_subtype == MESSAGE_RFC822) {
- cp = (ct->c_showproc = add ("%pshow -file '%F'", NULL));
- return show_content_aux (ct, serial, alternate, cp, NULL);
+ cp = (ct->c_showproc = add("%pshow -file '%F'", NULL));
+ return show_content_aux(ct, serial, alternate, cp, NULL);
}
/* complain if we are not a part of a multipart/alternative */
if (!alternate)
- content_error (NULL, ct, "don't know how to display content");
+ content_error(NULL, ct, "don't know how to display content");
return NOTOK;
}
*/
static int
-show_partial (CT ct, int serial, int alternate)
+show_partial(CT ct, int serial, int alternate)
{
- content_error (NULL, ct,
+ content_error(NULL, ct,
"in order to display this message, you must reassemble it");
return NOTOK;
}
*/
static int
-show_external (CT ct, int serial, int alternate)
+show_external(CT ct, int serial, int alternate)
{
struct exbody *e = (struct exbody *) ct->c_ctparams;
CT p = e->eb_content;
- if (!type_ok (p, 0))
+ if (!type_ok(p, 0))
return OK;
- return show_switch (p, serial, alternate);
+ return show_switch(p, serial, alternate);
#if 0
- content_error (NULL, p, "don't know how to display content");
+ content_error(NULL, p, "don't know how to display content");
return NOTOK;
#endif
}
static RETSIGTYPE
-intrser (int i)
+intrser(int i)
{
#ifndef RELIABLE_SIGNALS
- SIGNAL (SIGINT, intrser);
+ SIGNAL(SIGINT, intrser);
#endif
- putchar ('\n');
- siglongjmp (intrenv, DONE);
+ putchar('\n');
+ siglongjmp(intrenv, DONE);
}
#define quitser pipeser
/* mhparse.c */
-CT parse_mime (char *);
+CT parse_mime(char *);
/* mhmisc.c */
-int part_ok (CT, int);
-int type_ok (CT, int);
-void set_endian (void);
-void flush_errors (void);
+int part_ok(CT, int);
+int type_ok(CT, int);
+void set_endian(void);
+void flush_errors(void);
/* mhstoresbr.c */
-void store_all_messages (CT *);
+void store_all_messages(CT *);
/* mhfree.c */
-void free_content (CT);
+void free_content(CT);
extern CT *cts;
-void freects_done (int) NORETURN;
+void freects_done(int) NORETURN;
/*
** static prototypes
*/
-static RETSIGTYPE pipeser (int);
+static RETSIGTYPE pipeser(int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int msgnum, *icachesw;
char *cp, *file = NULL, *folder = NULL;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case AUTOSW:
autosw++;
icachesw = &wcachesw;
do_cache:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- switch (*icachesw = smatch (cp, caches)) {
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ switch (*icachesw = smatch(cp, caches)) {
case AMBIGSW:
- ambigsw (cp, caches);
- done (1);
+ ambigsw(cp, caches);
+ done(1);
case UNKWNSW:
- adios (NULL, "%s unknown", cp);
+ adios(NULL, "%s unknown", cp);
default:
break;
}
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);
+ adios(NULL, "too many parts (starting with %s), %d max", cp, NPARTS);
parts[npart++] = cp;
continue;
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);
+ adios(NULL, "too many types (starting with %s), %d max", cp, NTYPES);
types[ntype++] = cp;
continue;
case FILESW:
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
- adios (NULL, "missing argument to %s", argp[-2]);
- file = *cp == '-' ? cp : path (cp, TFILE);
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ file = *cp == '-' ? cp : path(cp, TFILE);
continue;
case VERBSW:
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
app_msgarg(&msgs, cp);
}
parts[npart] = NULL;
types[ntype] = NULL;
- set_endian ();
+ set_endian();
/*
** Check if we've specified an additional profile
*/
- if ((cp = getenv ("MHSTORE"))) {
- if ((fp = fopen (cp, "r"))) {
- readconfig ((struct node **) 0, fp, cp, 0);
- fclose (fp);
+ if ((cp = getenv("MHSTORE"))) {
+ if ((fp = fopen(cp, "r"))) {
+ readconfig((struct node **) 0, fp, cp, 0);
+ fclose(fp);
} else {
- admonish ("", "unable to read $MHSTORE profile (%s)", cp);
+ admonish("", "unable to read $MHSTORE profile (%s)",
+ cp);
}
}
/*
** Read the standard profile setup
*/
- if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) {
- readconfig ((struct node **) 0, fp, cp, 0);
- fclose (fp);
+ if ((fp = fopen(cp = etcpath("mhn.defaults"), "r"))) {
+ readconfig((struct node **) 0, fp, cp, 0);
+ fclose(fp);
}
/* Check for public cache location */
- if ((cache_public = context_find (nmhcache)) && *cache_public != '/')
+ if ((cache_public = context_find(nmhcache)) && *cache_public != '/')
cache_public = NULL;
/* Check for private cache location */
- if (!(cache_private = context_find (nmhprivcache)))
+ if (!(cache_private = context_find(nmhprivcache)))
cache_private = ".cache";
- cache_private = getcpy (m_maildir (cache_private));
+ cache_private = getcpy(m_maildir(cache_private));
/*
** Cache the current directory before we do any chdirs()'s.
*/
- cwd = getcpy (pwd());
+ cwd = getcpy(pwd());
/*
** 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);
+ if ((cp = context_find(nmhstorage)) && *cp)
+ tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = add (m_maildir (invo_name), NULL);
+ tmp = add(m_maildir(invo_name), NULL);
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (file && msgs.size)
- adios (NULL, "cannot specify msg and file at same time!");
+ adios(NULL, "cannot specify msg and file at same time!");
/*
** check if message is coming from file
*/
if (file) {
- if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
- adios (NULL, "out of memory");
+ if (!(cts = (CT *) calloc((size_t) 2, sizeof(*cts))))
+ adios(NULL, "out of memory");
ctp = cts;
- if ((ct = parse_mime (file)));
+ if ((ct = parse_mime(file)));
*ctp++ = ct;
} else {
/*
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msgs.msgs[msgnum]))
+ done(1);
+ seq_setprev(mp); /* set the previous-sequence */
- if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1),
+ if (!(cts = (CT *) calloc((size_t) (mp->numsel + 1),
sizeof(*cts))))
- adios (NULL, "out of memory");
+ adios(NULL, "out of memory");
ctp = cts;
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
char *msgnam;
- msgnam = m_name (msgnum);
- if ((ct = parse_mime (msgnam)))
+ msgnam = m_name(msgnum);
+ if ((ct = parse_mime(msgnam)))
*ctp++ = ct;
}
}
}
if (!*cts)
- done (1);
+ done(1);
userrs = 1;
- SIGNAL (SIGQUIT, quitser);
- SIGNAL (SIGPIPE, pipeser);
+ SIGNAL(SIGQUIT, quitser);
+ SIGNAL(SIGPIPE, pipeser);
/*
** Get the associated umask for the relevant contents.
struct stat st;
ct = *ctp;
- if (type_ok (ct, 1) && !ct->c_umask) {
- if (stat (ct->c_file, &st) != NOTOK)
+ if (type_ok(ct, 1) && !ct->c_umask) {
+ if (stat(ct->c_file, &st) != NOTOK)
ct->c_umask = ~(st.st_mode & 0777);
else
ct->c_umask = ~m_gmprot();
/*
** Store the message content
*/
- store_all_messages (cts);
+ store_all_messages(cts);
/* Now free all the structures for the content */
for (ctp = cts; *ctp; ctp++)
- free_content (*ctp);
+ free_content(*ctp);
- free ((char *) cts);
+ free((char *) cts);
cts = NULL;
/* If reading from a folder, do some updating */
if (mp) {
- context_replace (pfolder, folder); /* update current folder */
- seq_setcur (mp, mp->hghsel); /* update current message */
- seq_save (mp); /* synchronize sequences */
- context_save (); /* save the context file */
+ context_replace(pfolder, folder); /* update current folder */
+ seq_setcur(mp, mp->hghsel); /* update current message */
+ seq_save(mp); /* synchronize sequences */
+ context_save(); /* save the context file */
}
- done (0);
+ done(0);
return 1;
}
static RETSIGTYPE
-pipeser (int i)
+pipeser(int i)
{
if (i == SIGQUIT) {
- unlink ("core");
- fflush (stdout);
- fprintf (stderr, "\n");
- fflush (stderr);
+ unlink("core");
+ fflush(stdout);
+ fprintf(stderr, "\n");
+ fflush(stderr);
}
- done (1);
+ done(1);
/* NOTREACHED */
}
/* mhmisc.c */
-int part_ok (CT, int);
-int type_ok (CT, int);
-int make_intermediates (char *);
-void flush_errors (void);
+int part_ok(CT, int);
+int type_ok(CT, int);
+int make_intermediates(char *);
+void flush_errors(void);
/* mhshowsbr.c */
-int show_content_aux (CT, int, int, char *, char *);
+int show_content_aux(CT, int, int, char *, char *);
/*
** prototypes
*/
-void store_all_messages (CT *);
+void store_all_messages(CT *);
/*
** static prototypes
*/
-static void store_single_message (CT);
-static int store_switch (CT);
-static int store_generic (CT);
-static int store_application (CT);
-static int store_multi (CT);
-static int store_partial (CT);
-static int store_external (CT);
-static int ct_compar (CT *, CT *);
-static int store_content (CT, CT);
-static int output_content_file (CT, int);
-static int output_content_folder (char *, char *);
-static int parse_format_string (CT, char *, char *, int, char *);
-static void get_storeproc (CT);
-static int copy_some_headers (FILE *, CT);
+static void store_single_message(CT);
+static int store_switch(CT);
+static int store_generic(CT);
+static int store_application(CT);
+static int store_multi(CT);
+static int store_partial(CT);
+static int store_external(CT);
+static int ct_compar(CT *, CT *);
+static int store_content(CT, CT);
+static int output_content_file(CT, int);
+static int output_content_folder(char *, char *);
+static int parse_format_string(CT, char *, char *, int, char *);
+static void get_storeproc(CT);
+static int copy_some_headers(FILE *, CT);
/*
*/
void
-store_all_messages (CT *cts)
+store_all_messages(CT *cts)
{
CT ct, *ctp;
char *cp;
** store any contents.
*/
if (autosw)
- dir = getcpy (cwd);
- else if ((cp = context_find (nmhstorage)) && *cp)
- dir = getcpy (cp);
+ dir = getcpy(cwd);
+ else if ((cp = context_find(nmhstorage)) && *cp)
+ dir = getcpy(cp);
else
- dir = getcpy (cwd);
+ dir = getcpy(cwd);
for (ctp = cts; *ctp; ctp++) {
ct = *ctp;
- store_single_message (ct);
+ store_single_message(ct);
}
- flush_errors ();
+ flush_errors();
}
*/
static void
-store_single_message (CT ct)
+store_single_message(CT ct)
{
- if (type_ok (ct, 1)) {
- umask (ct->c_umask);
- store_switch (ct);
+ if (type_ok(ct, 1)) {
+ umask(ct->c_umask);
+ store_switch(ct);
if (ct->c_fp) {
- fclose (ct->c_fp);
+ fclose(ct->c_fp);
ct->c_fp = NULL;
}
if (ct->c_ceclosefnx)
*/
static int
-store_switch (CT ct)
+store_switch(CT ct)
{
switch (ct->c_type) {
case CT_MULTIPART:
- return store_multi (ct);
+ return store_multi(ct);
break;
case CT_MESSAGE:
switch (ct->c_subtype) {
case MESSAGE_PARTIAL:
- return store_partial (ct);
+ return store_partial(ct);
break;
case MESSAGE_EXTERNAL:
- return store_external (ct);
+ return store_external(ct);
case MESSAGE_RFC822:
default:
- return store_generic (ct);
+ return store_generic(ct);
break;
}
break;
case CT_APPLICATION:
- return store_application (ct);
+ return store_application(ct);
break;
case CT_TEXT:
case CT_AUDIO:
case CT_IMAGE:
case CT_VIDEO:
- return store_generic (ct);
+ return store_generic(ct);
break;
default:
- adios (NULL, "unknown content type %d", ct->c_type);
+ adios(NULL, "unknown content type %d", ct->c_type);
break;
}
*/
static int
-store_generic (CT ct)
+store_generic(CT ct)
{
/*
** Check if the content specifies a filename.
** (only "message/rfc822" will use store_generic).
*/
if (autosw && ct->c_type != CT_MESSAGE)
- get_storeproc (ct);
+ get_storeproc(ct);
- return store_content (ct, NULL);
+ return store_content(ct, NULL);
}
*/
static int
-store_application (CT ct)
+store_application(CT ct)
{
char **ap, **ep;
CI ci = &ct->c_ctinfo;
/* Check if the content specifies a filename */
if (autosw)
- get_storeproc (ct);
+ get_storeproc(ct);
/*
** If storeproc is not defined, and the content is type
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
/* check for "type=tar" attribute */
- if (!mh_strcasecmp (*ap, "type")) {
- if (mh_strcasecmp (*ep, "tar"))
+ if (!mh_strcasecmp(*ap, "type")) {
+ if (mh_strcasecmp(*ep, "tar"))
break;
tarP = 1;
}
/* 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);
}
}
}
}
- return store_content (ct, NULL);
+ return store_content(ct, NULL);
}
*/
static int
-store_multi (CT ct)
+store_multi(CT ct)
{
int result;
struct multipart *m = (struct multipart *) ct->c_ctparams;
for (part = m->mp_parts; part; part = part->mp_next) {
CT p = part->mp_part;
- if (part_ok (p, 1) && type_ok (p, 1)) {
- result = store_switch (p);
+ if (part_ok(p, 1) && type_ok(p, 1)) {
+ result = store_switch(p);
if (result == OK && ct->c_subtype == MULTI_ALTERNATE)
break;
}
*/
static int
-store_partial (CT ct)
+store_partial(CT ct)
{
int cur, hi, i;
CT p, *ctp, *ctq;
p = *ctp;
if (p->c_type == CT_MESSAGE && p->c_subtype == ct->c_subtype) {
pm = (struct partial *) p->c_ctparams;
- if (!pm->pm_stored
- && strcmp (qm->pm_partid, pm->pm_partid) == 0) {
+ if (!pm->pm_stored &&
+ strcmp(qm->pm_partid, pm->pm_partid)
+ == 0) {
pm->pm_marked = pm->pm_partno;
if (pm->pm_maxno)
hi = pm->pm_maxno;
}
if (hi == 0) {
- advise (NULL, "missing (at least) last part of multipart message");
+ advise(NULL, "missing (at least) last part of multipart message");
return NOTOK;
}
- if ((base = (CT *) calloc ((size_t) (i + 1), sizeof(*base))) == NULL)
- adios (NULL, "out of memory");
+ if ((base = (CT *) calloc((size_t) (i + 1), sizeof(*base))) == NULL)
+ adios(NULL, "out of memory");
ctq = base;
for (ctp = cts; *ctp; ctp++) {
*ctq = NULL;
if (i > 1)
- qsort ((char *) base, i, sizeof(*base), (qsort_comp) ct_compar);
+ qsort((char *) base, i, sizeof(*base), (qsort_comp) ct_compar);
cur = 1;
for (ctq = base; *ctq; ctq++) {
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;
}
ctq = base;
ct = *ctq++;
- if (store_content (ct, NULL) == NOTOK) {
+ if (store_content(ct, NULL) == NOTOK) {
losing:
- free ((char *) base);
+ free((char *) base);
return NOTOK;
}
for (; *ctq; ctq++) {
p = *ctq;
- if (store_content (p, ct) == NOTOK)
+ if (store_content(p, ct) == NOTOK)
goto losing;
}
- free ((char *) base);
+ free((char *) base);
return OK;
}
*/
static int
-store_external (CT ct)
+store_external(CT ct)
{
int result = NOTOK;
struct exbody *e = (struct exbody *) ct->c_ctparams;
CT p = e->eb_content;
- if (!type_ok (p, 1))
+ if (!type_ok(p, 1))
return OK;
/*
if (autosw) {
char *cp;
- if ((cp = e->eb_name)
- && *cp != '/'
- && *cp != '.'
- && *cp != '|'
- && *cp != '!'
- && !strchr (cp, '%')) {
+ if ((cp = e->eb_name) && *cp != '/' && *cp != '.' &&
+ *cp != '|' && *cp != '!' && !strchr(cp, '%')) {
if (!ct->c_storeproc)
- ct->c_storeproc = add (cp, NULL);
+ ct->c_storeproc = add(cp, NULL);
if (!p->c_storeproc)
- p->c_storeproc = add (cp, NULL);
+ p->c_storeproc = add(cp, NULL);
}
}
p->c_partno = ct->c_partno;
/* we probably need to check if content is really there */
- result = store_switch (p);
+ result = store_switch(p);
p->c_partno = NULL;
return result;
*/
static int
-ct_compar (CT *a, CT *b)
+ct_compar(CT *a, CT *b)
{
struct partial *am = (struct partial *) ((*a)->c_ctparams);
struct partial *bm = (struct partial *) ((*b)->c_ctparams);
*/
static int
-store_content (CT ct, CT p)
+store_content(CT ct, CT p)
{
int appending = 0, msgnum = 0;
int is_partial = 0, first_partial = 0;
*/
if (p) {
appending = 1;
- ct->c_storage = add (p->c_storage, NULL);
+ ct->c_storage = add(p->c_storage, NULL);
/* record the folder name */
if (p->c_folder) {
- ct->c_folder = add (p->c_folder, NULL);
+ ct->c_folder = add(p->c_folder, NULL);
}
goto got_filename;
}
if ((cp = ct->c_storeproc) == NULL || *cp == '\0') {
CI ci = &ct->c_ctinfo;
- snprintf (buffer, sizeof(buffer), "%s-store-%s/%s",
+ 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",
+ if ((cp = context_find(buffer)) == NULL || *cp == '\0') {
+ 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";
+ if ((cp = context_find(buffer)) == NULL ||
+ *cp == '\0') {
+ cp = ct->c_type == CT_MESSAGE ?
+ "+" : "%m%P.%s";
}
}
}
/* Store content in temporary file for now */
tmpfilenam = m_mktemp(invo_name, NULL, NULL);
- ct->c_storage = add (tmpfilenam, NULL);
+ ct->c_storage = add(tmpfilenam, NULL);
/* Get the folder name */
if (cp[1])
- folder = pluspath (cp);
+ folder = pluspath(cp);
else
- folder = getfolder (1);
+ folder = getfolder(1);
/* Check if folder exists */
create_folder(m_mailpath(folder), 0, exit);
/* Record the folder name */
- ct->c_folder = add (folder, NULL);
+ ct->c_folder = add(folder, NULL);
if (cp[1])
- free (folder);
+ free(folder);
goto got_filename;
}
** Parse and expand the storage formatting string
** in `cp' into `buffer'.
*/
- parse_format_string (ct, cp, buffer, sizeof(buffer), dir);
+ 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 (buffer[0] == '|' || buffer[0] == '!')
- return show_content_aux (ct, 1, 0, buffer + 1, dir);
+ return show_content_aux(ct, 1, 0, buffer + 1, dir);
/* record the filename */
- ct->c_storage = add (buffer, NULL);
+ ct->c_storage = add(buffer, NULL);
got_filename:
/* flush the output stream */
- fflush (stdout);
+ fflush(stdout);
/* Now save or append the content to a file */
- if (output_content_file (ct, appending) == NOTOK)
+ if (output_content_file(ct, appending) == NOTOK)
return NOTOK;
/*
** 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);
+ msgnum = output_content_folder(ct->c_folder, ct->c_storage);
+ unlink(ct->c_storage);
if (msgnum == NOTOK)
return NOTOK;
}
*/
if (is_partial) {
if (first_partial)
- fprintf (stderr, "reassembling partials ");
+ fprintf(stderr, "reassembling partials ");
if (last_partial)
- fprintf (stderr, "%s", ct->c_file);
+ fprintf(stderr, "%s", ct->c_file);
else
- fprintf (stderr, "%s,", ct->c_file);
+ fprintf(stderr, "%s,", ct->c_file);
} else {
- fprintf (stderr, "storing message %s", ct->c_file);
+ fprintf(stderr, "storing message %s", ct->c_file);
if (ct->c_partno)
- fprintf (stderr, " part %s", ct->c_partno);
+ fprintf(stderr, " part %s", ct->c_partno);
}
/*
*/
if (!is_partial || last_partial) {
if (ct->c_folder) {
- fprintf (stderr, " to folder %s as message %d\n", ct->c_folder, msgnum);
+ fprintf(stderr, " to folder %s as message %d\n",
+ ct->c_folder, msgnum);
} else if (!strcmp(ct->c_storage, "-")) {
- fprintf (stderr, " to stdout\n");
+ fprintf(stderr, " to stdout\n");
} else {
int cwdlen;
- cwdlen = strlen (cwd);
- fprintf (stderr, " as file %s\n",
- strncmp (ct->c_storage, cwd, cwdlen)
- || ct->c_storage[cwdlen] != '/'
- ? ct->c_storage : ct->c_storage + cwdlen + 1);
+ cwdlen = strlen(cwd);
+ fprintf(stderr, " as file %s\n",
+ strncmp(ct->c_storage, cwd, cwdlen) ||
+ ct->c_storage[cwdlen] != '/' ?
+ ct->c_storage :
+ ct->c_storage + cwdlen + 1);
}
}
*/
static int
-output_content_file (CT ct, int appending)
+output_content_file(CT ct, int appending)
{
int filterstate;
char *file, buffer[BUFSIZ];
** If the pathname is absolute, make sure
** all the relevant directories exist.
*/
- if (strchr(ct->c_storage, '/')
- && make_intermediates (ct->c_storage) == NOTOK)
+ if (strchr(ct->c_storage, '/') && make_intermediates(ct->c_storage)
+ == NOTOK)
return NOTOK;
if (ct->c_encoding != CE_7BIT) {
int cc, fd;
if (!ct->c_ceopenfnx) {
- advise (NULL, "don't know how to decode part %s of message %s",
- ct->c_partno, ct->c_file);
+ advise(NULL, "don't know how to decode part %s of message %s", ct->c_partno, ct->c_file);
return NOTOK;
}
- file = appending || !strcmp (ct->c_storage, "-") ? NULL
- : ct->c_storage;
+ file = appending || !strcmp(ct->c_storage, "-") ?
+ NULL : ct->c_storage;
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return NOTOK;
- if (!strcmp (file, ct->c_storage)) {
+ if (!strcmp(file, ct->c_storage)) {
(*ct->c_ceclosefnx) (ct);
return OK;
}
/*
** Send to standard output
*/
- if (!strcmp (ct->c_storage, "-")) {
+ if (!strcmp(ct->c_storage, "-")) {
int gd;
- if ((gd = dup (fileno (stdout))) == NOTOK) {
- advise ("stdout", "unable to dup");
+ if ((gd = dup(fileno(stdout))) == NOTOK) {
+ advise("stdout", "unable to dup");
losing:
(*ct->c_ceclosefnx) (ct);
return NOTOK;
}
- if ((fp = fdopen (gd, appending ? "a" : "w")) == NULL) {
- advise ("stdout", "unable to fdopen (%d, \"%s\") from", gd,
- appending ? "a" : "w");
- close (gd);
+ if ((fp = fdopen(gd, appending ? "a" : "w")) == NULL) {
+ advise("stdout", "unable to fdopen (%d, \"%s\") from", gd, appending ? "a" : "w");
+ close(gd);
goto losing;
}
} else {
/*
** 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");
+ if ((fp = fopen(ct->c_storage, appending ? "a" : "w"))
+ == NULL) {
+ advise(ct->c_storage, "unable to fopen for %s",
+ appending ?
+ "appending" : "writing");
goto losing;
}
}
struct partial *pm = (struct partial *) ct->c_ctparams;
if (pm->pm_partno == 1)
- copy_some_headers (fp, ct);
+ copy_some_headers(fp, ct);
}
for (;;) {
- switch (cc = read (fd, buffer, sizeof(buffer))) {
+ switch (cc = read(fd, buffer, sizeof(buffer))) {
case NOTOK:
- advise (file, "error reading content from");
+ advise(file, "error reading content from");
break;
case OK:
break;
default:
- fwrite (buffer, sizeof(*buffer), cc, fp);
+ fwrite(buffer, sizeof(*buffer),
+ cc, fp);
continue;
}
break;
(*ct->c_ceclosefnx) (ct);
- if (cc != NOTOK && fflush (fp))
- advise (ct->c_storage, "error writing to");
+ if (cc != NOTOK && fflush(fp))
+ advise(ct->c_storage, "error writing to");
- fclose (fp);
+ fclose(fp);
return (cc != NOTOK ? OK : NOTOK);
}
- if (!ct->c_fp && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
- advise (ct->c_file, "unable to open for reading");
+ if (!ct->c_fp && (ct->c_fp = fopen(ct->c_file, "r")) == NULL) {
+ advise(ct->c_file, "unable to open for reading");
return NOTOK;
}
pos = ct->c_begin;
last = ct->c_end;
- fseek (ct->c_fp, pos, SEEK_SET);
+ fseek(ct->c_fp, pos, SEEK_SET);
- if (!strcmp (ct->c_storage, "-")) {
+ if (!strcmp(ct->c_storage, "-")) {
int gd;
- if ((gd = dup (fileno (stdout))) == NOTOK) {
- advise ("stdout", "unable to dup");
+ if ((gd = dup(fileno(stdout))) == NOTOK) {
+ advise("stdout", "unable to dup");
return NOTOK;
}
- if ((fp = fdopen (gd, appending ? "a" : "w")) == NULL) {
- advise ("stdout", "unable to fdopen (%d, \"%s\") from", gd,
- appending ? "a" : "w");
- close (gd);
+ if ((fp = fdopen(gd, appending ? "a" : "w")) == NULL) {
+ advise("stdout", "unable to fdopen (%d, \"%s\") from",
+ gd, appending ? "a" : "w");
+ close(gd);
return NOTOK;
}
} else {
- if ((fp = fopen (ct->c_storage, appending ? "a" : "w")) == NULL) {
- advise (ct->c_storage, "unable to fopen for %s",
+ if ((fp = fopen(ct->c_storage, appending ? "a" : "w"))
+ == NULL) {
+ advise(ct->c_storage, "unable to fopen for %s",
appending ? "appending" : "writing");
return NOTOK;
}
struct partial *pm = (struct partial *) ct->c_ctparams;
if (pm->pm_partno == 1) {
- copy_some_headers (fp, ct);
+ copy_some_headers(fp, ct);
filterstate = 1;
}
}
- while (fgets (buffer, sizeof(buffer) - 1, ct->c_fp)) {
- if ((pos += strlen (buffer)) > last) {
+ while (fgets(buffer, sizeof(buffer) - 1, ct->c_fp)) {
+ if ((pos += strlen(buffer)) > last) {
int diff;
- diff = strlen (buffer) - (pos - last);
+ diff = strlen(buffer) - (pos - last);
if (diff >= 0)
buffer[diff] = '\0';
}
break;
default:
- if (!uprf (buffer, XXX_FIELD_PRF)
- && !uprf (buffer, VRSN_FIELD)
- && !uprf (buffer, "Subject:")
- && !uprf (buffer, "Encrypted:")
- && !uprf (buffer, "Message-ID:")) {
+ if (!uprf(buffer, XXX_FIELD_PRF) && !uprf(buffer, VRSN_FIELD) && !uprf(buffer, "Subject:") && !uprf(buffer, "Encrypted:") && !uprf(buffer, "Message-ID:")) {
filterstate = -1;
buffer[0] = 0;
break;
break;
}
}
- fputs (buffer, fp);
+ fputs(buffer, fp);
if (pos >= last)
break;
}
- if (fflush (fp))
- advise (ct->c_storage, "error writing to");
+ if (fflush(fp))
+ advise(ct->c_storage, "error writing to");
- fclose (fp);
- fclose (ct->c_fp);
+ fclose(fp);
+ fclose(ct->c_fp);
ct->c_fp = NULL;
return OK;
}
*/
static int
-output_content_folder (char *folder, char *filename)
+output_content_folder(char *folder, char *filename)
{
int msgnum;
struct msgs *mp;
/* Read the folder. */
- if ((mp = folder_read (folder))) {
+ if ((mp = folder_read(folder))) {
/* Link file into folder */
- msgnum = folder_addmsg (&mp, filename, 0, 0, 0, 0, (char *)0);
+ msgnum = folder_addmsg(&mp, filename, 0, 0, 0, 0, (char *)0);
} else {
- advise (NULL, "unable to read folder %s", folder);
+ advise(NULL, "unable to read folder %s", folder);
return NOTOK;
}
/* free folder structure */
- folder_free (mp);
+ folder_free(mp);
/*
** Return msgnum. We are relying on the fact that
*/
static int
-parse_format_string (CT ct, char *cp, char *buffer, int buflen, char *dir)
+parse_format_string(CT ct, char *cp, char *buffer, int buflen, char *dir)
{
int len;
char *bp;
** return (send content to standard output).
*/
if (cp[0] == '-' && cp[1] == '\0') {
- strncpy (buffer, cp, buflen);
+ strncpy(buffer, cp, buflen);
return 0;
}
** appropriate directory.
*/
if (*cp != '/' && *cp != '|' && *cp != '!') {
- snprintf (bp, buflen, "%s/", dir[1] ? dir : "");
- len = strlen (bp);
+ snprintf(bp, buflen, "%s/", dir[1] ? dir : "");
+ len = strlen(bp);
bp += len;
buflen -= len;
}
for (ap = ci->ci_attrs, ep = ci->ci_values;
*ap; ap++, ep++) {
- snprintf (bp, buflen, "%s%s=\"%s\"", s, *ap, *ep);
- len = strlen (bp);
+ snprintf(bp, buflen, "%s%s=\"%s\"", s, *ap, *ep);
+ len = strlen(bp);
bp += len;
buflen -= len;
s = " ";
case 'm':
/* insert message number */
- snprintf (bp, buflen, "%s", r1bindex (ct->c_file, '/'));
+ snprintf(bp, buflen, "%s", r1bindex(ct->c_file, '/'));
break;
case 'P':
/* insert part number with leading dot */
if (ct->c_partno)
- snprintf (bp, buflen, ".%s", ct->c_partno);
+ snprintf(bp, buflen, ".%s", ct->c_partno);
break;
case 'p':
/* insert part number withouth leading dot */
if (ct->c_partno)
- strncpy (bp, ct->c_partno, buflen);
+ strncpy(bp, ct->c_partno, buflen);
break;
case 't':
/* insert content type */
- strncpy (bp, ci->ci_type, buflen);
+ strncpy(bp, ci->ci_type, buflen);
break;
case 's':
/* insert content subtype */
- strncpy (bp, ci->ci_subtype, buflen);
+ strncpy(bp, ci->ci_subtype, buflen);
break;
case '%':
}
/* Advance bp and decrement buflen */
- len = strlen (bp);
+ len = strlen(bp);
bp += len;
buflen -= len;
*/
static void
-get_storeproc (CT ct)
+get_storeproc(CT ct)
{
char **ap, **ep, *cp;
CI ci = &ct->c_ctinfo;
** the storeproc.
*/
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
- if (!mh_strcasecmp (*ap, "name")
- && *(cp = *ep) != '/'
- && *cp != '.'
- && *cp != '|'
- && *cp != '!'
- && !strchr (cp, '%')) {
- ct->c_storeproc = add (cp, NULL);
+ if (!mh_strcasecmp(*ap, "name") && *(cp = *ep) != '/' &&
+ *cp != '.' && *cp != '|' && *cp != '!' &&
+ !strchr(cp, '%')) {
+ ct->c_storeproc = add(cp, NULL);
return;
}
}
*/
static int
-copy_some_headers (FILE *out, CT ct)
+copy_some_headers(FILE *out, CT ct)
{
HF hp;
** 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")
- && mh_strcasecmp (hp->name, "Encrypted")
- && mh_strcasecmp (hp->name, "Message-ID"))
- fprintf (out, "%s:%s", hp->name, hp->value);
+ if (!uprf(hp->name, XXX_FIELD_PRF) &&
+ mh_strcasecmp(hp->name, VRSN_FIELD) &&
+ mh_strcasecmp(hp->name, "Subject") &&
+ mh_strcasecmp(hp->name, "Encrypted") &&
+ mh_strcasecmp(hp->name, "Message-ID"))
+ fprintf(out, "%s:%s", hp->name, hp->value);
hp = hp->next; /* next header field */
}
#define quitser pipeser
/* mhparse.c */
-CT parse_mime (char *);
+CT parse_mime(char *);
/* mhoutsbr.c */
-int output_message (CT, char *);
+int output_message(CT, char *);
/* mhmisc.c */
-int part_ok (CT, int);
-int type_ok (CT, int);
-void set_endian (void);
-void flush_errors (void);
+int part_ok(CT, int);
+int type_ok(CT, int);
+void set_endian(void);
+void flush_errors(void);
/* mhfree.c */
-void free_content (CT);
+void free_content(CT);
extern CT *cts;
-void freects_done (int) NORETURN;
+void freects_done(int) NORETURN;
/*
** static prototypes
*/
-static int write_content (CT *, char *);
-static RETSIGTYPE pipeser (int);
+static int write_content(CT *, char *);
+static RETSIGTYPE pipeser(int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int msgnum, *icachesw;
char *cp, *file = NULL, *folder = NULL;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case RCACHESW:
icachesw = &rcachesw;
icachesw = &wcachesw;
do_cache:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- switch (*icachesw = smatch (cp, caches)) {
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ switch (*icachesw = smatch(cp, caches)) {
case AMBIGSW:
- ambigsw (cp, caches);
- done (1);
+ ambigsw(cp, caches);
+ done(1);
case UNKWNSW:
- adios (NULL, "%s unknown", cp);
+ adios(NULL, "%s unknown", cp);
default:
break;
}
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);
+ adios(NULL, "too many parts (starting with %s), %d max", cp, NPARTS);
parts[npart++] = cp;
continue;
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",
+ adios(NULL, "too many types (starting with %s), %d max",
cp, NTYPES);
types[ntype++] = cp;
continue;
case FILESW:
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
- adios (NULL, "missing argument to %s", argp[-2]);
- file = *cp == '-' ? cp : path (cp, TFILE);
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ file = *cp == '-' ? cp : path(cp, TFILE);
continue;
case OUTFILESW:
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
- adios (NULL, "missing argument to %s", argp[-2]);
- outfile = *cp == '-' ? cp : path (cp, TFILE);
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ outfile = *cp == '-' ? cp : path(cp, TFILE);
continue;
case VERBSW:
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
app_msgarg(&msgs, cp);
}
parts[npart] = NULL;
types[ntype] = NULL;
- set_endian ();
+ set_endian();
if (outfile == NULL)
- adios (NULL, "must specify output file");
+ adios(NULL, "must specify output file");
/* Check for public cache location */
- if ((cache_public = context_find (nmhcache)) && *cache_public != '/')
+ if ((cache_public = context_find(nmhcache)) && *cache_public != '/')
cache_public = NULL;
/* Check for private cache location */
- if (!(cache_private = context_find (nmhprivcache)))
+ if (!(cache_private = context_find(nmhprivcache)))
cache_private = ".cache";
- cache_private = getcpy (m_maildir (cache_private));
+ 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.
*/
- if ((cp = context_find (nmhstorage)) && *cp)
- tmp = concat (cp, "/", invo_name, NULL);
+ if ((cp = context_find(nmhstorage)) && *cp)
+ tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = add (m_maildir (invo_name), NULL);
+ tmp = add(m_maildir(invo_name), NULL);
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (file && msgs.size)
- adios (NULL, "cannot specify msg and file at same time!");
+ adios(NULL, "cannot specify msg and file at same time!");
/*
** check if message is coming from file
*/
if (file) {
- if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts))))
- adios (NULL, "out of memory");
+ if (!(cts = (CT *) calloc((size_t) 2, sizeof(*cts))))
+ adios(NULL, "out of memory");
ctp = cts;
- if ((ct = parse_mime (file)));
+ if ((ct = parse_mime(file)));
*ctp++ = ct;
} else {
/*
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msgs.msgs[msgnum]))
+ done(1);
+ seq_setprev(mp); /* set the previous-sequence */
- if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts))))
- adios (NULL, "out of memory");
+ if (!(cts = (CT *) calloc((size_t) (mp->numsel + 1),
+ sizeof(*cts))))
+ adios(NULL, "out of memory");
ctp = cts;
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
char *msgnam;
- msgnam = m_name (msgnum);
- if ((ct = parse_mime (msgnam)))
+ msgnam = m_name(msgnum);
+ if ((ct = parse_mime(msgnam)))
*ctp++ = ct;
}
}
}
if (!*cts)
- done (1);
+ done(1);
userrs = 1;
- SIGNAL (SIGQUIT, quitser);
- SIGNAL (SIGPIPE, pipeser);
+ SIGNAL(SIGQUIT, quitser);
+ SIGNAL(SIGPIPE, pipeser);
/*
** Get the associated umask for the relevant contents.
struct stat st;
ct = *ctp;
- if (type_ok (ct, 1) && !ct->c_umask) {
- if (stat (ct->c_file, &st) != NOTOK)
+ if (type_ok(ct, 1) && !ct->c_umask) {
+ if (stat(ct->c_file, &st) != NOTOK)
ct->c_umask = ~(st.st_mode & 0777);
else
ct->c_umask = ~m_gmprot();
/*
** Write the content to a file
*/
- write_content (cts, outfile);
+ write_content(cts, outfile);
/* Now free all the structures for the content */
for (ctp = cts; *ctp; ctp++)
- free_content (*ctp);
+ free_content(*ctp);
- free ((char *) cts);
+ free((char *) cts);
cts = NULL;
/* If reading from a folder, do some updating */
if (mp) {
- context_replace (pfolder, folder); /* update current folder */
- seq_setcur (mp, mp->hghsel); /* update current message */
- seq_save (mp); /* synchronize sequences */
- context_save (); /* save the context file */
+ context_replace(pfolder, folder); /* update current folder */
+ seq_setcur(mp, mp->hghsel); /* update current message */
+ seq_save(mp); /* synchronize sequences */
+ context_save(); /* save the context file */
}
- done (0);
+ done(0);
return 1;
}
static int
-write_content (CT *cts, char *outfile)
+write_content(CT *cts, char *outfile)
{
CT ct, *ctp;
for (ctp = cts; *ctp; ctp++) {
ct = *ctp;
- output_message (ct, outfile);
+ output_message(ct, outfile);
}
- flush_errors ();
+ flush_errors();
return OK;
}
static RETSIGTYPE
-pipeser (int i)
+pipeser(int i)
{
if (i == SIGQUIT) {
- unlink ("core");
- fflush (stdout);
- fprintf (stderr, "\n");
- fflush (stderr);
+ unlink("core");
+ fflush(stdout);
+ fprintf(stderr, "\n");
+ fflush(stderr);
}
- done (1);
+ done(1);
/* NOTREACHED */
}
/*
** static prototypes
*/
-static int donote (char *, int);
-static int checkmail (char *, char *, int, int, int);
+static int donote(char *, int);
+static int checkmail(char *, char *, int, int, int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int datesw = 1, notifysw = NT_ALL;
int status = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- mts_init (invo_name);
- uid = getuid ();
+ mts_init(invo_name);
+ uid = getuid();
user = getusername();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] [users ...]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches] [users ...]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case DATESW:
datesw++;
case NOTESW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- notifysw |= donote (cp, 1);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ notifysw |= donote(cp, 1);
continue;
case NNOTESW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- notifysw &= ~donote (cp, 0);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ notifysw &= ~donote(cp, 0);
continue;
}
}
if (vecp >= MAXVEC-1)
- adios (NULL, "you can only check %d users at a time", MAXVEC-1);
+ adios(NULL, "you can only check %d users at a time",
+ MAXVEC-1);
else
vec[vecp++] = cp;
}
/* Not sure this check makes sense... */
if (!geteuid() || NULL == (home = getenv("HOME"))) {
- pw = getpwnam (user);
+ pw = getpwnam(user);
if (pw == NULL)
- adios (NULL, "unable to get information about user");
+ adios(NULL, "unable to get information about user");
home = pw->pw_dir;
}
- status = checkmail (user, home, datesw, notifysw, 1);
+ status = checkmail(user, home, datesw, notifysw, 1);
} else {
for (vecp = 0; vec[vecp]; vecp++) {
- if ((pw = getpwnam (vec[vecp])))
- status += checkmail (pw->pw_name, pw->pw_dir, datesw, notifysw, 0);
+ if ((pw = getpwnam(vec[vecp])))
+ status += checkmail(pw->pw_name, pw->pw_dir,
+ datesw, notifysw, 0);
else
- advise (NULL, "no such user as %s", vec[vecp]);
+ advise(NULL, "no such user as %s", vec[vecp]);
}
}
- done (status);
+ done(status);
return 1;
}
static int
-donote (char *cp, int ntflag)
+donote(char *cp, int ntflag)
{
- switch (smatch (cp, ntswitches)) {
+ switch (smatch(cp, ntswitches)) {
case AMBIGSW:
- ambigsw (cp, ntswitches);
- done (1);
+ ambigsw(cp, ntswitches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%snotify %s unknown", ntflag ? "" : "no", cp);
+ adios(NULL, "-%snotify %s unknown",
+ ntflag ? "" : "no", cp);
case NALLSW:
return NT_ALL;
static int
-checkmail (char *user, char *home, int datesw, int notifysw, int personal)
+checkmail(char *user, char *home, int datesw, int notifysw, int personal)
{
int mf, status;
char buffer[BUFSIZ];
struct stat st;
- snprintf (buffer, sizeof(buffer), "%s/%s",
+ 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;
}
- mf = (stat (buffer, &st) == NOTOK || st.st_size == 0) ? NONEOK
+ mf = (stat(buffer, &st) == NOTOK || st.st_size == 0) ? NONEOK
: st.st_atime <= st.st_mtime ? MMDFNEW : MMDFOLD;
if ((mf & UUCPOK) || (mf & MMDFOK)) {
if (notifysw & NT_MAIL) {
- printf (personal ? "You have " : "%s has ", user);
+ printf(personal ? "You have " : "%s has ", user);
if (mf & UUCPOK)
- printf ("%s old-style bell",
+ printf("%s old-style bell",
mf & UUCPOLD ? "old" : "new");
if ((mf & UUCPOK) && (mf & MMDFOK))
- printf (" and ");
+ printf(" and ");
if (mf & MMDFOK)
- printf ("%s%s", mf & MMDFOLD ? "old" : "new",
+ printf("%s%s", mf & MMDFOLD ? "old" : "new",
mf & UUCPOK ? " Internet" : "");
- printf (" mail waiting");
+ printf(" mail waiting");
} else {
notifysw = 0;
}
}
else {
if (notifysw & NT_NMAI)
- printf (personal ? "You don't %s%s" : "%s doesn't %s",
+ printf(personal ? "You don't %s%s" : "%s doesn't %s",
personal ? "" : user,
"have any mail waiting");
else
if (notifysw)
if (datesw && st.st_atime)
- printf ("; last read on %s", dtime (&st.st_atime, 1));
+ printf("; last read on %s", dtime(&st.st_atime, 1));
if (notifysw)
- printf ("\n");
+ printf("\n");
return status;
}
field = getcpy(field);
/* copied from seq_read.c:seq_init */
- for (ap = brkstring (field, " ", "\n"); *ap; ap++) {
+ for (ap = brkstring(field, " ", "\n"); *ap; ap++) {
if ((cp = strchr(*ap, '-')))
*cp++ = '\0';
- if ((j = m_atoi (*ap)) > 0) {
- k = cp ? m_atoi (cp) : j;
+ if ((j = m_atoi(*ap)) > 0) {
+ k = cp ? m_atoi(cp) : j;
total += k - j + 1;
}
/* copied from seq_read.c:seq_public */
for (state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
+ switch (state = m_getfld(state, name, field, sizeof(field),
+ fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
if (state == FLDPLUS) {
- cp = getcpy (field);
+ cp = getcpy(field);
while (state == FLDPLUS) {
- state = m_getfld (state, name,
+ state = m_getfld(state, name,
field,
sizeof(field),
fp);
- cp = add (field, cp);
+ cp = add(field, cp);
}
/*
free(this_msgnums);
}
}
- free (cp);
+ free(cp);
} else {
/* and here */
if (seq_in_list(name, sequences)) {
case BODY:
case BODYEOF:
- adios (NULL, "no blank lines are permitted in %s", seqfile);
+ adios(NULL, "no blank lines are permitted in %s", seqfile);
/* fall */
case FILEEOF:
break;
default:
- adios (NULL, "%s is poorly formatted", seqfile);
+ adios(NULL, "%s is poorly formatted", seqfile);
}
break; /* break from for loop */
}
count = count_messages(node->n_field);
total += count;
- printf("%-*s %6d.%c %s\n",
- (int) folder_len, node->n_name,
- count,
- (strcmp(node->n_name, cur) == 0 ? '*' : ' '),
- node->n_field);
+ printf("%-*s %6d.%c %s\n", (int) folder_len,
+ node->n_name, count,
+ (strcmp(node->n_name, cur) == 0 ? '*' : ' '),
+ node->n_field);
}
}
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (help, sizeof(help),
+ snprintf(help, sizeof(help),
"%s [switches] [sequences]",
invo_name);
- print_help (help, switches, 1);
- done (1);
+ print_help(help, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case FOLDERSSW:
if (!(folders = *argp++) || *folders == '-')
context_save();
- done (0);
+ done(0);
return 1;
}
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int fd, msgnum;
char *cp, *maildir, *msgnam, *folder = NULL, buf[BUFSIZ];
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case FILESW:
if (file)
- adios (NULL, "only one file at a time!");
+ adios(NULL, "only one file at a time!");
if (!(file = *argp++) || *file == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case MBOXSW:
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
- folder = pluspath (cp);
+ adios(NULL, "only one folder at a time!");
+ folder = pluspath(cp);
} else
app_msgarg(&msgs, cp);
}
if (!file)
file = "./msgbox";
- file = path (file, TFILE);
+ file = path(file, TFILE);
/*
** Check if file to be created (or appended to)
*/
if (stat (file, &st) == NOTOK) {
if (errno != ENOENT)
- adios (file, "error on file");
- cp = concat ("Create file \"", file, "\"? ", NULL);
- if (!getanswer (cp))
- done (1);
- free (cp);
+ adios(file, "error on file");
+ cp = concat("Create file \"", file, "\"? ", NULL);
+ if (!getanswer(cp))
+ done(1);
+ free(cp);
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
/* default is to pack whole folder */
if (!msgs.size)
app_msgarg(&msgs, "all");
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to ");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to ");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msgs.msgs[msgnum]))
+ done(1);
+ 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)
- adios (file, "unable to open");
+ 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))
+ if ((fd = open(msgnam = m_name(msgnum), O_RDONLY))
== NOTOK) {
- admonish (msgnam, "unable to read message");
+ admonish(msgnam, "unable to read message");
break;
}
if (mbx_copy(file, mbx_style, md, fd, mapping, NULL, 1)
== NOTOK)
- adios (file, "error writing to file");
+ adios(file, "error writing to file");
- close (fd);
+ close(fd);
}
/* close and unlock maildrop file */
- mbx_close (file, md);
+ mbx_close(file, md);
- context_replace (pfolder, folder); /* update current folder */
+ context_replace(pfolder, folder); /* update current folder */
if (mp->hghsel != mp->curmsg)
- seq_setcur (mp, mp->lowsel);
- seq_save (mp);
- context_save (); /* save the context file */
- folder_free (mp); /* free folder/message structure */
- done (0);
+ seq_setcur(mp, mp->lowsel);
+ seq_save(mp);
+ context_save(); /* save the context file */
+ folder_free(mp); /* free folder/message structure */
+ done(0);
return 1;
}
static void
-mbxclose_done (int status)
+mbxclose_done(int status)
{
- mbx_close (file, md);
- exit (status);
+ mbx_close(file, md);
+ exit(status);
}
static int listsw = -1;
-static void putzero_done (int) NORETURN;
+static void putzero_done(int) NORETURN;
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int publicsw = -1, zerosw = 1, seqp = 0, vecp = 0;
int lo, hi, msgnum;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
vec[vecp++] = --cp;
goto pattern;
}
- switch (smatch (cp, switches)) {
+ switch (smatch(cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
+ ambigsw(cp, switches);
listsw = 0; /* HACK */
- done (1);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
- print_help (buf, switches, 1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
listsw = 0; /* HACK */
- done (1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
listsw = 0; /* HACK */
- done (1);
+ done(1);
case CCSW:
case DATESW:
vec[vecp++] = --cp;
pattern:
if (!(cp = *argp++)) /* allow -xyz arguments */
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
vec[vecp++] = cp;
continue;
case OTHRSW:
- adios (NULL, "internal error!");
+ adios(NULL, "internal error!");
case ANDSW:
case ORSW:
case SEQSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
/* check if too many sequences specified */
if (seqp >= NUMATTRS)
- adios (NULL, "too many sequences (more than %d) specified", NUMATTRS);
+ adios(NULL, "too many sequences (more than %d) specified", NUMATTRS);
- if (!seq_nameok (cp))
- done (1);
+ if (!seq_nameok(cp))
+ done(1);
seqs[seqp++] = cp;
continue;
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
app_msgarg(&msgs, cp);
}
vec[vecp] = NULL;
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
/*
** If we didn't specify which messages to search,
app_msgarg(&msgs, "all");
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msgs.msgs[msgnum]))
+ done(1);
+ seq_setprev(mp); /* set the previous-sequence */
/*
** If we aren't saving the results to a sequence,
listsw = !seqp;
if (publicsw == 1 && is_readonly(mp))
- adios (NULL, "folder %s is read-only, so -public not allowed",
+ adios(NULL, "folder %s is read-only, so -public not allowed",
folder);
- if (!pcompile (vec, NULL))
- done (1);
+ if (!pcompile(vec, NULL))
+ done(1);
lo = mp->lowsel;
hi = mp->hghsel;
** force line buffering on.
*/
if (listsw)
- setvbuf (stdout, NULL, _IOLBF, 0);
+ 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.
*/
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
- if (is_selected (mp, msgnum)) {
- if ((fp = fopen (cp = m_name (msgnum), "r")) == NULL)
- admonish (cp, "unable to read message");
- if (fp && pmatches (fp, msgnum, 0L, 0L)) {
+ if (is_selected(mp, msgnum)) {
+ if ((fp = fopen(cp = m_name(msgnum), "r")) == NULL)
+ admonish(cp, "unable to read message");
+ if (fp && pmatches(fp, msgnum, 0L, 0L)) {
if (msgnum < lo)
lo = msgnum;
if (msgnum > hi)
hi = msgnum;
if (listsw)
- printf ("%s\n", m_name (msgnum));
+ printf("%s\n", m_name(msgnum));
} else {
/* if it doesn't match, then unselect it */
- unset_selected (mp, msgnum);
+ unset_selected(mp, msgnum);
mp->numsel--;
}
if (fp)
- fclose (fp);
+ fclose(fp);
}
}
mp->hghsel = hi;
if (mp->numsel <= 0)
- adios (NULL, "no messages match specification");
+ adios(NULL, "no messages match specification");
seqs[seqp] = NULL;
** Add the matching messages to sequences
*/
for (seqp = 0; seqs[seqp]; seqp++)
- if (!seq_addsel (mp, seqs[seqp], publicsw, zerosw))
- done (1);
+ if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw))
+ done(1);
/*
** Print total matched if not printing each matched message number.
*/
if (!listsw) {
- printf ("%d hit%s\n", mp->numsel, mp->numsel == 1 ? "" : "s");
+ printf("%d hit%s\n", mp->numsel, mp->numsel == 1 ? "" : "s");
}
- context_replace (pfolder, folder); /* update current folder */
- seq_save (mp); /* synchronize message sequences */
- context_save (); /* save the context file */
- folder_free (mp); /* free folder/message structure */
- done (0);
+ context_replace(pfolder, folder); /* update current folder */
+ seq_save(mp); /* synchronize message sequences */
+ context_save(); /* save the context file */
+ folder_free(mp); /* free folder/message structure */
+ done(0);
return 1;
}
static void
-putzero_done (int status)
+putzero_done(int status)
{
- if (listsw && status && !isatty (fileno (stdout)))
- printf ("0\n");
- exit (status);
+ if (listsw && status && !isatty(fileno(stdout)))
+ printf("0\n");
+ exit(status);
}
int
-pcompile (char **vec, char *date)
+pcompile(char **vec, char *date)
{
register char *cp;
- if ((cp = getenv ("MHPDEBUG")) && *cp)
+ if ((cp = getenv("MHPDEBUG")) && *cp)
pdebug++;
argp = vec;
datesw = "date";
talked = 0;
- if ((head = parse ()) == NULL)
+ if ((head = parse()) == NULL)
return (talked ? 0 : 1);
if (*argp) {
- padvise (NULL, "%s unexpected", *argp);
+ padvise(NULL, "%s unexpected", *argp);
return 0;
}
static struct nexus *
-parse (void)
+parse(void)
{
register char *cp;
register struct nexus *n, *o;
- if ((n = nexp1 ()) == NULL || (cp = nxtarg ()) == NULL)
+ if ((n = nexp1()) == NULL || (cp = nxtarg()) == NULL)
return n;
if (*cp != '-') {
- padvise (NULL, "%s unexpected", cp);
+ padvise(NULL, "%s unexpected", cp);
return NULL;
}
if (*++cp == '-')
goto header;
- switch (smatch (cp, parswit)) {
+ switch (smatch(cp, parswit)) {
case AMBIGSW:
- ambigsw (cp, parswit);
+ ambigsw(cp, parswit);
talked++;
return NULL;
case UNKWNSW:
- fprintf (stderr, "-%s unknown\n", cp);
+ fprintf(stderr, "-%s unknown\n", cp);
talked++;
return NULL;
case PROR:
- o = newnexus (ORaction);
+ o = newnexus(ORaction);
o->n_L_child = n;
- if ((o->n_R_child = parse ()))
+ if ((o->n_R_child = parse()))
return o;
- padvise (NULL, "missing disjunctive");
+ padvise(NULL, "missing disjunctive");
return NULL;
header: ;
default:
- prvarg ();
+ prvarg();
return n;
}
}
static struct nexus *
-nexp1 (void)
+nexp1(void)
{
register char *cp;
register struct nexus *n, *o;
- if ((n = nexp2 ()) == NULL || (cp = nxtarg ()) == NULL)
+ if ((n = nexp2()) == NULL || (cp = nxtarg()) == NULL)
return n;
if (*cp != '-') {
- padvise (NULL, "%s unexpected", cp);
+ padvise(NULL, "%s unexpected", cp);
return NULL;
}
if (*++cp == '-')
goto header;
- switch (smatch (cp, parswit)) {
+ switch (smatch(cp, parswit)) {
case AMBIGSW:
- ambigsw (cp, parswit);
+ ambigsw(cp, parswit);
talked++;
return NULL;
case UNKWNSW:
- fprintf (stderr, "-%s unknown\n", cp);
+ fprintf(stderr, "-%s unknown\n", cp);
talked++;
return NULL;
case PRAND:
- o = newnexus (ANDaction);
+ o = newnexus(ANDaction);
o->n_L_child = n;
- if ((o->n_R_child = nexp1 ()))
+ if ((o->n_R_child = nexp1()))
return o;
- padvise (NULL, "missing conjunctive");
+ padvise(NULL, "missing conjunctive");
return NULL;
header: ;
default:
- prvarg ();
+ prvarg();
return n;
}
}
static struct nexus *
-nexp2 (void)
+nexp2(void)
{
register char *cp;
register struct nexus *n;
- if ((cp = nxtarg ()) == NULL)
+ if ((cp = nxtarg()) == NULL)
return NULL;
if (*cp != '-') {
- prvarg ();
- return nexp3 ();
+ prvarg();
+ return nexp3();
}
if (*++cp == '-')
goto header;
- switch (smatch (cp, parswit)) {
+ switch (smatch(cp, parswit)) {
case AMBIGSW:
- ambigsw (cp, parswit);
+ ambigsw(cp, parswit);
talked++;
return NULL;
case UNKWNSW:
- fprintf (stderr, "-%s unknown\n", cp);
+ fprintf(stderr, "-%s unknown\n", cp);
talked++;
return NULL;
case PRNOT:
- n = newnexus (NOTaction);
- if ((n->n_L_child = nexp3 ()))
+ n = newnexus(NOTaction);
+ if ((n->n_L_child = nexp3()))
return n;
- padvise (NULL, "missing negation");
+ padvise(NULL, "missing negation");
return NULL;
header: ;
default:
- prvarg ();
- return nexp3 ();
+ prvarg();
+ return nexp3();
}
}
static struct nexus *
-nexp3 (void)
+nexp3(void)
{
int i;
register char *cp, *dp;
char buffer[BUFSIZ], temp[64];
register struct nexus *n;
- if ((cp = nxtarg ()) == NULL)
+ if ((cp = nxtarg()) == NULL)
return NULL;
if (*cp != '-') {
- padvise (NULL, "%s unexpected", cp);
+ padvise(NULL, "%s unexpected", cp);
return NULL;
}
dp = ++cp;
goto header;
}
- switch (i = smatch (cp, parswit)) {
+ switch (i = smatch(cp, parswit)) {
case AMBIGSW:
- ambigsw (cp, parswit);
+ ambigsw(cp, parswit);
talked++;
return NULL;
case UNKWNSW:
- fprintf (stderr, "-%s unknown\n", cp);
+ fprintf(stderr, "-%s unknown\n", cp);
talked++;
return NULL;
case PRLBR:
- if ((n = parse ()) == NULL) {
- padvise (NULL, "missing group");
+ if ((n = parse()) == NULL) {
+ padvise(NULL, "missing group");
return NULL;
}
- if ((cp = nxtarg ()) == NULL) {
- padvise (NULL, "missing -rbrace");
+ if ((cp = nxtarg()) == NULL) {
+ padvise(NULL, "missing -rbrace");
return NULL;
}
- if (*cp++ == '-' && smatch (cp, parswit) == PRRBR)
+ if (*cp++ == '-' && smatch(cp, parswit) == PRRBR)
return n;
- padvise (NULL, "%s unexpected", --cp);
+ padvise(NULL, "%s unexpected", --cp);
return NULL;
default:
- prvarg ();
+ prvarg();
return NULL;
case PRCC:
case PRSUBJ:
strncpy(temp, parswit[i].sw, sizeof(temp));
temp[sizeof(temp) - 1] = '\0';
- dp = *brkstring (temp, " ", NULL);
+ dp = *brkstring(temp, " ", NULL);
header: ;
- if (!(cp = nxtarg ())) { /* allow -xyz arguments */
- padvise (NULL, "missing argument to %s",
+ if (!(cp = nxtarg())) { /* allow -xyz arguments */
+ padvise(NULL, "missing argument to %s",
argp[-2]);
return NULL;
}
- n = newnexus (GREPaction);
+ n = newnexus(GREPaction);
n->n_header = 1;
- snprintf (buffer, sizeof(buffer), "^%s[ \t]*:.*%s",
+ snprintf(buffer, sizeof(buffer), "^%s[ \t]*:.*%s",
dp, cp);
dp = buffer;
goto pattern;
case PRSRCH:
- n = newnexus (GREPaction);
+ n = newnexus(GREPaction);
n->n_header = 0;
- if (!(cp = nxtarg ())) { /* allow -xyz arguments */
- padvise (NULL, "missing argument to %s",
+ if (!(cp = nxtarg())) { /* allow -xyz arguments */
+ padvise(NULL, "missing argument to %s",
argp[-2]);
return NULL;
}
dp = cp;
pattern: ;
- if (!gcompile (n, dp)) {
- padvise (NULL, "pattern error in %s %s",
+ if (!gcompile(n, dp)) {
+ padvise(NULL, "pattern error in %s %s",
argp[-2], cp);
return NULL;
}
- n->n_patbuf = getcpy (dp);
+ n->n_patbuf = getcpy(dp);
return n;
case PROTHR:
- padvise (NULL, "internal error!");
+ padvise(NULL, "internal error!");
return NULL;
case PRDATF:
- if (!(datesw = nxtarg ()) || *datesw == '-') {
- padvise (NULL, "missing argument to %s",
+ if (!(datesw = nxtarg()) || *datesw == '-') {
+ padvise(NULL, "missing argument to %s",
argp[-2]);
return NULL;
}
- return nexp3 ();
+ return nexp3();
case PRAFTR:
case PRBEFR:
- if (!(cp = nxtarg ())) { /* allow -xyz arguments */
- padvise (NULL, "missing argument to %s",
+ if (!(cp = nxtarg())) { /* allow -xyz arguments */
+ padvise(NULL, "missing argument to %s",
argp[-2]);
return NULL;
}
- n = newnexus (TWSaction);
+ 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",
+ if (!tcompile(cp, &n->n_tws, n->n_after =
+ i == PRAFTR)) {
+ padvise(NULL, "unable to parse %s %s",
argp[-2], cp);
return NULL;
}
static struct nexus *
-newnexus (int (*action)())
+newnexus(int (*action)())
{
register struct nexus *p;
- if ((p = (struct nexus *) calloc ((size_t) 1, sizeof *p)) == NULL)
- adios (NULL, "unable to allocate component storage");
+ if ((p = (struct nexus *) calloc((size_t) 1, sizeof *p)) == NULL)
+ adios(NULL, "unable to allocate component storage");
p->n_action = action;
return p;
#define args(a) a, fp, msgnum, start, stop
-#define params args (n)
+#define params args(n)
#define plist \
register struct nexus *n; \
register FILE *fp; \
stop;
int
-pmatches (FILE *fp, int msgnum, long start, long stop)
+pmatches(FILE *fp, int msgnum, long start, long stop)
{
if (!head)
return 1;
if (!talked++ && pdebug)
- PRaction (head, 0);
+ PRaction(head, 0);
- return (*head->n_action) (args (head));
+ return (*head->n_action) (args(head));
}
static void
-PRaction (struct nexus *n, int level)
+PRaction(struct nexus *n, int level)
{
register int i;
for (i = 0; i < level; i++)
- fprintf (stderr, "| ");
+ fprintf(stderr, "| ");
if (n->n_action == ORaction) {
- fprintf (stderr, "OR\n");
- PRaction (n->n_L_child, level + 1);
- PRaction (n->n_R_child, level + 1);
+ fprintf(stderr, "OR\n");
+ PRaction(n->n_L_child, level + 1);
+ PRaction(n->n_R_child, level + 1);
return;
}
if (n->n_action == ANDaction) {
- fprintf (stderr, "AND\n");
- PRaction (n->n_L_child, level + 1);
- PRaction (n->n_R_child, level + 1);
+ fprintf(stderr, "AND\n");
+ PRaction(n->n_L_child, level + 1);
+ PRaction(n->n_R_child, level + 1);
return;
}
if (n->n_action == NOTaction) {
- fprintf (stderr, "NOT\n");
- PRaction (n->n_L_child, level + 1);
+ fprintf(stderr, "NOT\n");
+ PRaction(n->n_L_child, level + 1);
return;
}
if (n->n_action == GREPaction) {
- fprintf (stderr, "PATTERN(%s) %s\n",
+ fprintf(stderr, "PATTERN(%s) %s\n",
n->n_header ? "header" : "body", n->n_patbuf);
return;
}
if (n->n_action == TWSaction) {
- fprintf (stderr, "TEMPORAL(%s) %s: %s\n",
+ fprintf(stderr, "TEMPORAL(%s) %s: %s\n",
n->n_after ? "after" : "before", n->n_datef,
- dasctime (&n->n_tws, TW_NULL));
+ dasctime(&n->n_tws, TW_NULL));
return;
}
- fprintf (stderr, "UNKNOWN(0x%x)\n",
+ fprintf(stderr, "UNKNOWN(0x%x)\n",
(unsigned int)(unsigned long) (*n->n_action));
}
static int
-ORaction (params)
+ORaction(params)
plist
{
- if ((*n->n_L_child->n_action) (args (n->n_L_child)))
+ if ((*n->n_L_child->n_action) (args(n->n_L_child)))
return 1;
- return (*n->n_R_child->n_action) (args (n->n_R_child));
+ return (*n->n_R_child->n_action) (args(n->n_R_child));
}
static int
-ANDaction (params)
+ANDaction(params)
plist
{
- if (!(*n->n_L_child->n_action) (args (n->n_L_child)))
+ if (!(*n->n_L_child->n_action) (args(n->n_L_child)))
return 0;
- return (*n->n_R_child->n_action) (args (n->n_R_child));
+ return (*n->n_R_child->n_action) (args(n->n_R_child));
}
static int
-NOTaction (params)
+NOTaction(params)
plist
{
- return (!(*n->n_L_child->n_action) (args (n->n_L_child)));
+ return (!(*n->n_L_child->n_action) (args(n->n_L_child)));
}
static int
-gcompile (struct nexus *n, char *astr)
+gcompile(struct nexus *n, char *astr)
{
register int c;
int cclcnt;
static int
-GREPaction (params)
+GREPaction(params)
plist
{
int c, body, lf;
register char *p1, *p2, *ebp, *cbp;
char ibuf[BUFSIZ];
- fseek (fp, start, SEEK_SET);
+ fseek(fp, start, SEEK_SET);
body = 0;
ebp = cbp = ibuf;
for (;;) {
lf = 0;
for (;;) {
if (p2 >= ebp) {
- if (fgets (ibuf, sizeof ibuf, fp) == NULL
+ if (fgets(ibuf, sizeof ibuf, fp) == NULL
|| (stop && pos >= stop)) {
if (lf)
break;
return 0;
}
- pos += (long) strlen (ibuf);
+ pos += (long) strlen(ibuf);
p2 = ibuf;
- ebp = ibuf + strlen (ibuf);
+ ebp = ibuf + strlen(ibuf);
}
c = *p2++;
if (lf && c != '\n') {
p2 = n->n_expbuf;
if (n->n_circf) {
- if (advance (p1, p2))
+ if (advance(p1, p2))
return 1;
continue;
}
c = p2[1];
do {
if (*p1 == c || cc[(unsigned char)*p1] == c)
- if (advance (p1, p2))
+ if (advance(p1, p2))
return 1;
} while (*p1++);
continue;
}
do {
- if (advance (p1, p2))
+ if (advance(p1, p2))
return 1;
} while (*p1++);
}
static int
-advance (char *alp, char *aep)
+advance(char *alp, char *aep)
{
register unsigned char *lp, *ep, *curlp;
return 1;
case CCL:
- if (cclass (ep, *lp++, 1)) {
+ if (cclass(ep, *lp++, 1)) {
ep += *ep + 1;
continue;
}
return 0;
case NCCL:
- if (cclass (ep, *lp++, 0)) {
+ if (cclass(ep, *lp++, 0)) {
ep += *ep + 1;
continue;
}
case CCL | STAR:
case NCCL | STAR:
curlp = lp;
- while (cclass (ep, *lp++, ep[-1] == (CCL | STAR)))
+ while (cclass(ep, *lp++, ep[-1] == (CCL | STAR)))
continue;
ep += *ep + 1;
goto star;
star:
do {
lp--;
- if (advance (lp, ep))
+ if (advance(lp, ep))
return (1);
} while (lp > curlp);
return 0;
default:
- admonish (NULL, "advance() botch -- you lose big");
+ admonish(NULL, "advance() botch -- you lose big");
return 0;
}
}
static int
-cclass (unsigned char *aset, int ac, int af)
+cclass(unsigned char *aset, int ac, int af)
{
register unsigned int n;
- register unsigned char c, *set;
+ register unsigned char c, *set;
set = aset;
if ((c = ac) == 0)
static int
-tcompile (char *ap, struct tws *tb, int isafter)
+tcompile(char *ap, struct tws *tb, int isafter)
{
register struct tws *tw;
- if ((tw = tws_parse (ap, isafter)) == NULL)
+ if ((tw = tws_parse(ap, isafter)) == NULL)
return 0;
- twscopy (tb, tw);
+ twscopy(tb, tw);
return 1;
}
static struct tws *
-tws_parse (char *ap, int isafter)
+tws_parse(char *ap, int isafter)
{
char buffer[BUFSIZ];
register struct tws *tw, *ts;
- if ((tw = tws_special (ap)) != NULL) {
+ if ((tw = tws_special(ap)) != NULL) {
tw->tw_sec = tw->tw_min = isafter ? 59 : 0;
tw->tw_hour = isafter ? 23 : 0;
return tw;
}
- if ((tw = dparsetime (ap)) != NULL)
+ if ((tw = dparsetime(ap)) != NULL)
return tw;
- if ((ts = dlocaltimenow ()) == NULL)
+ if ((ts = dlocaltimenow()) == NULL)
return NULL;
- snprintf (buffer, sizeof(buffer), "%s %s", ap, dtwszone (ts));
- if ((tw = dparsetime (buffer)) != NULL)
+ snprintf(buffer, sizeof(buffer), "%s %s", ap, dtwszone(ts));
+ if ((tw = dparsetime(buffer)) != NULL)
return tw;
- snprintf (buffer, sizeof(buffer), "%s %02d:%02d:%02d %s", ap,
- ts->tw_hour, ts->tw_min, ts->tw_sec, dtwszone (ts));
- if ((tw = dparsetime (buffer)) != NULL)
+ snprintf(buffer, sizeof(buffer), "%s %02d:%02d:%02d %s", ap,
+ ts->tw_hour, ts->tw_min, ts->tw_sec, dtwszone(ts));
+ if ((tw = dparsetime(buffer)) != NULL)
return tw;
- snprintf (buffer, sizeof(buffer), "%02d %s %04d %s",
+ snprintf(buffer, sizeof(buffer), "%02d %s %04d %s",
ts->tw_mday, tw_moty[ts->tw_mon], ts->tw_year, ap);
- if ((tw = dparsetime (buffer)) != NULL)
+ if ((tw = dparsetime(buffer)) != NULL)
return tw;
- snprintf (buffer, sizeof(buffer), "%02d %s %04d %s %s",
+ snprintf(buffer, sizeof(buffer), "%02d %s %04d %s %s",
ts->tw_mday, tw_moty[ts->tw_mon], ts->tw_year,
- ap, dtwszone (ts));
- if ((tw = dparsetime (buffer)) != NULL)
+ ap, dtwszone(ts));
+ if ((tw = dparsetime(buffer)) != NULL)
return tw;
return NULL;
static struct tws *
-tws_special (char *ap)
+tws_special(char *ap)
{
int i;
time_t clock;
register struct tws *tw;
- time (&clock);
- if (!mh_strcasecmp (ap, "today"))
- return dlocaltime (&clock);
- if (!mh_strcasecmp (ap, "yesterday")) {
+ time(&clock);
+ if (!mh_strcasecmp(ap, "today"))
+ return dlocaltime(&clock);
+ if (!mh_strcasecmp(ap, "yesterday")) {
clock -= (long) (60 * 60 * 24);
- return dlocaltime (&clock);
+ return dlocaltime(&clock);
}
- if (!mh_strcasecmp (ap, "tomorrow")) {
+ if (!mh_strcasecmp(ap, "tomorrow")) {
clock += (long) (60 * 60 * 24);
- return dlocaltime (&clock);
+ return dlocaltime(&clock);
}
for (i = 0; tw_ldotw[i]; i++)
- if (!mh_strcasecmp (ap, tw_ldotw[i]))
+ if (!mh_strcasecmp(ap, tw_ldotw[i]))
break;
if (tw_ldotw[i]) {
- if ((tw = dlocaltime (&clock)) == NULL)
+ if ((tw = dlocaltime(&clock)) == NULL)
return NULL;
if ((i -= tw->tw_wday) > 0)
i -= 7;
if (*ap != '-')
return NULL;
else /* -ddd days ago */
- i = atoi (ap); /* we should error check this */
+ i = atoi(ap); /* we should error check this */
clock += (long) ((60 * 60 * 24) * i);
- return dlocaltime (&clock);
+ return dlocaltime(&clock);
}
static int
-TWSaction (params)
+TWSaction(params)
plist
{
int state;
char buf[BUFSIZ], name[NAMESZ];
register struct tws *tw;
- fseek (fp, start, SEEK_SET);
+ fseek(fp, start, SEEK_SET);
for (state = FLD, bp = NULL;;) {
- switch (state = m_getfld (state, name, buf, sizeof buf, fp)) {
+ switch (state = m_getfld(state, name, buf, sizeof buf, fp)) {
case FLD:
case FLDEOF:
case FLDPLUS:
if (bp != NULL)
- free (bp), bp = NULL;
- bp = add (buf, NULL);
+ free(bp), bp = NULL;
+ bp = add(buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf,
+ state = m_getfld(state, name, buf,
sizeof buf, fp);
- bp = add (buf, bp);
+ bp = add(buf, bp);
}
- if (!mh_strcasecmp (name, n->n_datef))
+ if (!mh_strcasecmp(name, n->n_datef))
break;
if (state != FLDEOF)
continue;
case LENERR:
case FMTERR:
if (state == LENERR || state == FMTERR)
- advise (NULL, "format error in message %d", msgnum);
+ advise(NULL, "format error in message %d", msgnum);
if (bp != NULL)
- free (bp);
+ free(bp);
return 0;
default:
- adios (NULL, "internal error -- you lose");
+ adios(NULL, "internal error -- you lose");
}
break;
}
- if ((tw = dparsetime (bp)) == NULL)
- advise (NULL, "unable to parse %s field in message %d, matching...",
+ if ((tw = dparsetime(bp)) == NULL)
+ advise(NULL, "unable to parse %s field in message %d, matching...",
n->n_datef, msgnum), state = 1;
else
- state = n->n_after ? (twsort (tw, &n->n_tws) > 0)
- : (twsort (tw, &n->n_tws) < 0);
+ state = n->n_after ? (twsort(tw, &n->n_tws) > 0)
+ : (twsort(tw, &n->n_tws) < 0);
if (bp != NULL)
- free (bp);
+ free(bp);
return state;
}
/*
** prototypes
*/
-int getln (char *, int);
-static int chrcnv (char *);
-static void chrdsp (char *, char);
-static RETSIGTYPE intrser (int);
+int getln(char *, int);
+static int chrcnv(char *);
+static void chrdsp(char *, char);
+static RETSIGTYPE intrser(int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int body = 1, prepend = 1, rapid = 0;
int doteof = 0, fdi, fdo, i, state;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++))
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buffer, sizeof(buffer),
+ snprintf(buffer, sizeof(buffer),
"%s [switches] file",
invo_name);
- print_help (buffer, switches, 1);
- done (1);
+ print_help(buffer, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case ERASESW:
if (!(erasep = *argp++) || *erasep == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case KILLSW:
if (!(killp = *argp++) || *killp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case PREPSW:
}
if (!drft)
- adios (NULL, "usage: %s [switches] file", invo_name);
- if ((in = fopen (drft, "r")) == NULL)
- adios (drft, "unable to open");
+ adios(NULL, "usage: %s [switches] file", invo_name);
+ if ((in = fopen(drft, "r")) == NULL)
+ adios(drft, "unable to open");
tfile = m_mktemp2(NULL, invo_name, NULL, &out);
if (tfile == NULL)
adios("prompter", "unable to create temporary file");
- chmod (tmpfil, 0600);
- strncpy (tmpfil, tfile, sizeof(tmpfil));
+ chmod(tmpfil, 0600);
+ strncpy(tmpfil, tfile, sizeof(tmpfil));
/*
** Are we changing the kill or erase character?
# ifdef HAVE_TERMIO_H
ioctl(0, TCGETA, &tio);
# else
- ioctl (0, TIOCGETP, (char *) &tio);
- ioctl (0, TIOCGETC, (char *) &tc);
+ ioctl(0, TIOCGETP, (char *) &tio);
+ ioctl(0, TIOCGETC, (char *) &tc);
# endif
#endif
save_erase = ERASE;
/* set new kill, erase character in terminal structure */
- KILL = killp ? chrcnv (killp) : save_kill;
- ERASE = erasep ? chrcnv (erasep) : save_erase;
+ KILL = killp ? chrcnv(killp) : save_kill;
+ ERASE = erasep ? chrcnv(erasep) : save_erase;
/* set the new terminal attributes */
#ifdef HAVE_TERMIOS_H
# ifdef HAVE_TERMIO_H
ioctl(0, TCSETAW, &tio);
# else
- ioctl (0, TIOCSETN, (char *) &tio);
+ ioctl(0, TIOCSETN, (char *) &tio);
# endif
#endif
/* print out new kill erase characters */
- chrdsp ("erase", ERASE);
- chrdsp (", kill", KILL);
- chrdsp (", intr", INTR);
- putchar ('\n');
- fflush (stdout);
+ chrdsp("erase", ERASE);
+ chrdsp(", kill", KILL);
+ chrdsp(", intr", INTR);
+ putchar('\n');
+ fflush(stdout);
/*
** We set the kill and erase character back to original
}
sigint = 0;
- SIGNAL2 (SIGINT, intrser);
+ SIGNAL2(SIGINT, intrser);
/*
** Loop through the lines of the draft skeleton.
*/
for (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:
/* If so, just add header line to draft */
if (*cp++ != '\n' || *cp != 0) {
- printf ("%s:%s", name, field);
- fprintf (out, "%s:%s", name, field);
+ printf("%s:%s", name, field);
+ fprintf(out, "%s:%s", name, field);
while (state == FLDPLUS) {
- state =
- m_getfld (state, name, field, sizeof(field), in);
- printf ("%s", field);
- fprintf (out, "%s", field);
+ state = m_getfld(state, name, field, sizeof(field), in);
+ printf("%s", field);
+ fprintf(out, "%s", field);
}
} else {
/* Else, get value of header field */
- printf ("%s: ", name);
- fflush (stdout);
- i = getln (field, sizeof(field));
+ printf("%s: ", name);
+ fflush(stdout);
+ i = getln(field, sizeof(field));
if (i == -1) {
abort:
if (killp || erasep) {
tcsetattr(0, TCSADRAIN, &tio);
#else
# ifdef HAVE_TERMIO
- ioctl (0, TCSETA, &tio);
+ ioctl(0, TCSETA, &tio);
# else
- ioctl (0, TIOCSETN, (char *) &tio);
+ ioctl(0, TIOCSETN, (char *) &tio);
# endif
#endif
}
- unlink (tmpfil);
- done (1);
+ unlink(tmpfil);
+ done(1);
}
if (i != 0 || (field[0] != '\n' && field[0] != 0)) {
- fprintf (out, "%s:", name);
+ fprintf(out, "%s:", name);
do {
if (field[0] != ' ' && field[0] != '\t')
- putc (' ', out);
- fprintf (out, "%s", field);
- } while (i == 1
- && (i = getln (field, sizeof(field))) >= 0);
+ putc(' ', out);
+ fprintf(out, "%s", field);
+ } while (i == 1 && (i = getln(field, sizeof(field))) >= 0);
if (i == -1)
goto abort;
}
}
if (state == FLDEOF) { /* moby hack */
- fprintf (out, "--------\n");
- printf ("--------\n");
+ fprintf(out, "--------\n");
+ printf("--------\n");
if (!body)
break;
goto no_body;
case FILEEOF:
if (!body)
break;
- fprintf (out, "--------\n");
+ fprintf(out, "--------\n");
if (field[0] == 0 || !prepend)
- printf ("--------\n");
+ printf("--------\n");
if (field[0]) {
if (prepend && body) {
- printf ("\n--------Enter initial text\n\n");
- fflush (stdout);
+ printf("\n--------Enter initial text\n\n");
+ fflush(stdout);
for (;;) {
- getln (buffer, sizeof(buffer));
+ getln(buffer, sizeof(buffer));
if (doteof && buffer[0] == '.' && buffer[1] == '\n')
break;
if (buffer[0] == 0)
break;
- fprintf (out, "%s", buffer);
+ fprintf(out, "%s", buffer);
}
}
do {
- fprintf (out, "%s", field);
+ fprintf(out, "%s", field);
if (!rapid && !sigint)
- printf ("%s", field);
+ printf("%s", field);
} while (state == BODY &&
- (state = m_getfld (state, name, field, sizeof(field), in)));
+ (state = m_getfld(state, name, field, sizeof(field), in)));
if (prepend || !body)
break;
else
printf ("\n--------Enter additional text\n\n");
}
no_body:
- fflush (stdout);
+ fflush(stdout);
for (;;) {
- getln (field, sizeof(field));
+ getln(field, sizeof(field));
if (doteof && field[0] == '.' && field[1] == '\n')
break;
if (field[0] == 0)
break;
- fprintf (out, "%s", field);
+ fprintf(out, "%s", field);
}
break;
default:
- adios (NULL, "skeleton is poorly formatted");
+ adios(NULL, "skeleton is poorly formatted");
}
break;
}
if (body)
- printf ("--------\n");
+ printf("--------\n");
- fflush (stdout);
- fclose (in);
- fclose (out);
- SIGNAL (SIGINT, SIG_IGN);
+ fflush(stdout);
+ fclose(in);
+ fclose(out);
+ SIGNAL(SIGINT, SIG_IGN);
if (killp || erasep) {
#ifdef HAVE_TERMIOS_H
tcsetattr(0, TCSADRAIN, &tio);
#else
# ifdef HAVE_TERMIO_H
- ioctl (0, TCSETAW, &tio);
+ ioctl(0, TCSETAW, &tio);
# else
- ioctl (0, TIOCSETN, (char *) &tio);
+ ioctl(0, TIOCSETN, (char *) &tio);
# endif
#endif
}
- if ((fdi = open (tmpfil, O_RDONLY)) == NOTOK)
- adios (tmpfil, "unable to re-open");
- if ((fdo = creat (drft, m_gmprot ())) == NOTOK)
- adios (drft, "unable to write");
- cpydata (fdi, fdo, tmpfil, drft);
- close (fdi);
- close (fdo);
- unlink (tmpfil);
-
- context_save (); /* save the context file */
- done (0);
+ if ((fdi = open(tmpfil, O_RDONLY)) == NOTOK)
+ adios(tmpfil, "unable to re-open");
+ if ((fdo = creat(drft, m_gmprot())) == NOTOK)
+ adios(drft, "unable to write");
+ cpydata(fdi, fdo, tmpfil, drft);
+ close(fdi);
+ close(fdo);
+ unlink(tmpfil);
+
+ context_save(); /* save the context file */
+ done(0);
return 1;
}
int
-getln (char *buffer, int n)
+getln(char *buffer, int n)
{
int c;
char *cp;
cp = buffer;
*cp = 0;
- switch (setjmp (sigenv)) {
+ switch (setjmp(sigenv)) {
case OK:
wtuser = 1;
break;
}
for (;;) {
- switch (c = getchar ()) {
+ switch (c = getchar()) {
case EOF:
- clearerr (stdin);
- longjmp (sigenv, DONE);
+ clearerr(stdin);
+ longjmp(sigenv, DONE);
case '\n':
if (cp[-1] == QUOTE) {
static RETSIGTYPE
-intrser (int i)
+intrser(int i)
{
#ifndef RELIABLE_SIGNALS
- SIGNAL (SIGINT, intrser);
+ SIGNAL(SIGINT, intrser);
#endif
if (wtuser)
- longjmp (sigenv, NOTOK);
+ longjmp(sigenv, NOTOK);
sigint++;
}
static int
-chrcnv (char *cp)
+chrcnv(char *cp)
{
- return (*cp != QUOTE ? *cp : m_atoi (++cp));
+ return (*cp != QUOTE ? *cp : m_atoi(++cp));
}
static void
-chrdsp (char *s, char c)
+chrdsp(char *s, char c)
{
- printf ("%s ", s);
+ printf("%s ", s);
if (c < ' ' || c == 0177)
- printf ("^%c", c ^ 0100);
+ printf("^%c", c ^ 0100);
else
- printf ("%c", c);
+ printf("%c", c);
}
/*
** prototypes
*/
-static void rcvdistout (FILE *, char *, char *);
-static void unlink_done (int) NORETURN;
+static void rcvdistout(FILE *, char *, char *);
+static void unlink_done(int) NORETURN;
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
pid_t child_id;
int i, vecp = 1;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
vec[vecp++] = --cp;
continue;
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] [switches for postproc] address ...", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches] [switches for postproc] address ...", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
}
}
- addrs = addrs ? add (cp, add (", ", addrs)) : getcpy (cp);
+ addrs = addrs ? add(cp, add(", ", addrs)) : getcpy(cp);
}
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 ());
+ umask(~m_gmprot());
tfile = m_mktemp2(NULL, invo_name, NULL, &fp);
if (tfile == NULL) adios("rcvdist", "unable to create temporary file");
- strncpy (tmpfil, tfile, sizeof(tmpfil));
+ strncpy(tmpfil, tfile, sizeof(tmpfil));
- cpydata (fileno (stdin), fileno (fp), "message", tmpfil);
- fseek (fp, 0L, SEEK_SET);
+ cpydata(fileno(stdin), fileno(fp), "message", tmpfil);
+ fseek(fp, 0L, SEEK_SET);
tfile = m_mktemp2(NULL, invo_name, NULL, NULL);
if (tfile == NULL) adios("forw", "unable to create temporary file");
- strncpy (drft, tfile, sizeof(tmpfil));
+ strncpy(drft, tfile, sizeof(tmpfil));
- rcvdistout (fp, form, addrs);
- fclose (fp);
+ rcvdistout(fp, form, addrs);
+ fclose(fp);
- if (distout (drft, tmpfil, backup) == NOTOK)
- done (1);
+ if (distout(drft, tmpfil, backup) == NOTOK)
+ done(1);
- vec[0] = r1bindex (postproc, '/');
+ vec[0] = r1bindex(postproc, '/');
vec[vecp++] = "-dist";
vec[vecp++] = drft;
vec[vecp] = NULL;
for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case NOTOK:
- admonish (NULL, "unable to fork");/* fall */
+ admonish(NULL, "unable to fork");/* fall */
case OK:
- execvp (postproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (postproc);
- _exit (1);
+ execvp(postproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(postproc);
+ _exit(1);
default:
- done (pidXwait(child_id, postproc));
+ done(pidXwait(child_id, postproc));
}
return 0; /* dead code to satisfy the compiler */
static void
-rcvdistout (FILE *inb, char *form, char *addrs)
+rcvdistout(FILE *inb, char *form, char *addrs)
{
register int char_read = 0, format_len, i, state;
register char *tmpbuf, **nxtbuf, **ap;
register struct comp *cptr, **savecomp;
FILE *out;
- if (!(out = fopen (drft, "w")))
- adios (drft, "unable to create");
+ if (!(out = fopen(drft, "w")))
+ adios(drft, "unable to create");
/* get new format string */
- cp = new_fs (form ? form : rcvdistcomps, NULL, NULL);
- format_len = strlen (cp);
- ncomps = fmt_compile (cp, &fmt) + 1;
+ 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 *))))
- adios (NULL, "unable to allocate component buffers");
+ (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),
+ (struct comp **) calloc((size_t) (ncomps + 1),
sizeof(struct comp *))))
- adios (NULL, "unable to allocate component buffer stack");
+ adios(NULL, "unable to allocate component buffer stack");
savecomp += ncomps + 1;
*--savecomp = 0;
for (i = ncomps; i--;)
- *nxtbuf++ = mh_xmalloc (SBUFSIZ);
+ *nxtbuf++ = mh_xmalloc(SBUFSIZ);
nxtbuf = compbuffers;
tmpbuf = *nxtbuf++;
for (ap = addrcomps; *ap; ap++) {
- FINDCOMP (cptr, *ap);
+ FINDCOMP(cptr, *ap);
if (cptr)
cptr->c_type |= CT_ADDR;
}
- FINDCOMP (cptr, "addresses");
+ FINDCOMP(cptr, "addresses");
if (cptr)
cptr->c_text = addrs;
for (state = FLD;;) {
- switch (state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb)) {
+ switch (state = m_getfld(state, name, tmpbuf, SBUFSIZ, inb)) {
case FLD:
case FLDPLUS:
- if ((cptr = wantcomp[CHASH (name)]))
+ if ((cptr = wantcomp[CHASH(name)]))
do {
- if (!mh_strcasecmp (name, cptr->c_name)) {
+ if (!mh_strcasecmp(name, cptr->c_name)) {
char_read += msg_count;
if (!cptr->c_text) {
cptr->c_text = tmpbuf;
*--savecomp = cptr;
tmpbuf = *nxtbuf++;
} else {
- i = strlen (cp = cptr->c_text) - 1;
+ i = strlen(cp = cptr->c_text) - 1;
if (cp[i] == '\n') {
if (cptr->c_type & CT_ADDR) {
cp[i] = 0;
- cp = add (",\n\t", cp);
+ cp = add(",\n\t", cp);
} else
- cp = add ("\t", cp);
+ cp = add("\t", cp);
}
- cptr->c_text = add (tmpbuf, cp);
+ cptr->c_text = add(tmpbuf, cp);
}
while (state == FLDPLUS) {
- state = m_getfld (state, name, tmpbuf,
- SBUFSIZ, inb);
- cptr->c_text = add (tmpbuf, cptr->c_text);
+ state = m_getfld(state, name, tmpbuf, SBUFSIZ, inb);
+ cptr->c_text = add(tmpbuf, cptr->c_text);
char_read += msg_count;
}
break;
} while ((cptr = cptr->c_next));
while (state == FLDPLUS)
- state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+ state = m_getfld(state, name, tmpbuf, SBUFSIZ, inb);
break;
case LENERR:
goto finished;
default:
- adios (NULL, "m_getfld() returned %d", state);
+ adios(NULL, "m_getfld() returned %d", state);
}
}
finished: ;
i = format_len + char_read + 256;
- scanl = mh_xmalloc ((size_t) i + 2);
+ scanl = mh_xmalloc((size_t) i + 2);
dat[0] = dat[1] = dat[2] = dat[4] = 0;
dat[3] = outputlinelen;
- fmt_scan (fmt, scanl, i, dat);
- fputs (scanl, out);
+ fmt_scan(fmt, scanl, i, dat);
+ fputs(scanl, out);
- if (ferror (out))
- adios (drft, "error writing");
- fclose (out);
+ if (ferror(out))
+ adios(drft, "error writing");
+ fclose(out);
- free (scanl);
+ free(scanl);
for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++);
nxtbuf++, i--)
- free (cptr->c_text);
+ free(cptr->c_text);
while (i-- > 0)
- free (*nxtbuf++);
- free ((char *) compbuffers);
- free ((char *) used_buf);
+ free(*nxtbuf++);
+ free((char *) compbuffers);
+ free((char *) used_buf);
}
static void
-unlink_done (int status)
+unlink_done(int status)
{
if (backup[0])
- unlink (backup);
+ unlink(backup);
if (drft[0])
- unlink (drft);
+ unlink(drft);
if (tmpfil[0])
- unlink (tmpfil);
+ unlink(tmpfil);
- exit (status ? RCV_MBX : RCV_MOK);
+ exit(status ? RCV_MBX : RCV_MOK);
}
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int md;
char *cp, *file = NULL, buf[BUFSIZ];
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/* parse arguments */
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf),
+ snprintf(buf, sizeof(buf),
"%s [switches] file",
invo_name);
- print_help (buf, switches, 1);
- done (1);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case MBOXSW:
mbx_style = MBOX_FORMAT;
}
}
if (file)
- adios (NULL, "only one file at a time!");
+ adios(NULL, "only one file at a time!");
else
file = cp;
}
if (!file)
- adios (NULL, "%s [switches] file", invo_name);
+ adios(NULL, "%s [switches] file", invo_name);
- rewind (stdin);
+ rewind(stdin);
/* open and lock the file */
- if ((md = mbx_open (file, mbx_style, getuid(), getgid(), m_gmprot()))
+ if ((md = mbx_open(file, mbx_style, getuid(), getgid(), m_gmprot()))
== NOTOK)
- done (RCV_MBX);
+ done(RCV_MBX);
/* append the message */
- if (mbx_copy (file, mbx_style, md, fileno(stdin), 1, NULL, 0)
+ if (mbx_copy(file, mbx_style, md, fileno(stdin), 1, NULL, 0)
== NOTOK) {
- mbx_close (file, md);
- done (RCV_MBX);
+ mbx_close(file, md);
+ done(RCV_MBX);
}
/* close and unlock the file */
- if (mbx_close (file, md) == NOTOK)
- done (RCV_MBX);
+ if (mbx_close(file, md) == NOTOK)
+ done(RCV_MBX);
- done (RCV_MOK);
+ done(RCV_MOK);
return 1;
}
static void unlink_done(int) NORETURN;
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int publicsw = -1, zerosw = 0;
int create = 1, unseensw = 1;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/* parse arguments */
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf),
- "%s [+folder] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf),
+ "%s [+folder] [switches]",
+ invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case SEQSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument name to %s", argp[-2]);
+ adios(NULL, "missing argument name to %s", argp[-2]);
/* check if too many sequences specified */
if (seqp >= NUMATTRS)
- adios (NULL, "too many sequences (more than %d) specified", NUMATTRS);
+ adios(NULL, "too many sequences (more than %d) specified", NUMATTRS);
seqs[seqp++] = cp;
continue;
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else {
- adios (NULL, "usage: %s [+folder] [switches]",
+ adios(NULL, "usage: %s [+folder] [switches]",
invo_name);
}
}
seqs[seqp] = NULL; /* NULL terminate list of sequences */
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
/* if no folder is given, use default folder */
if (!folder)
- folder = getfolder (0);
- maildir = m_maildir (folder);
+ folder = getfolder(0);
+ maildir = m_maildir(folder);
/* check if folder exists */
- if (stat (maildir, &st) == NOTOK) {
+ if (stat(maildir, &st) == NOTOK) {
if (errno != ENOENT)
- adios (maildir, "error on folder");
+ adios(maildir, "error on folder");
if (!create)
- adios (NULL, "folder %s doesn't exist", maildir);
- if (!makedir (maildir))
- adios (NULL, "unable to create folder %s", maildir);
+ adios(NULL, "folder %s doesn't exist", maildir);
+ if (!makedir(maildir))
+ adios(NULL, "unable to create folder %s", maildir);
}
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* ignore a few signals */
- SIGNAL (SIGHUP, SIG_IGN);
- SIGNAL (SIGINT, SIG_IGN);
- SIGNAL (SIGQUIT, SIG_IGN);
- SIGNAL (SIGTERM, SIG_IGN);
+ SIGNAL(SIGHUP, SIG_IGN);
+ SIGNAL(SIGINT, SIG_IGN);
+ SIGNAL(SIGQUIT, SIG_IGN);
+ SIGNAL(SIGTERM, SIG_IGN);
/* create a temporary file */
- tmpfilenam = m_mktemp (invo_name, &fd, NULL);
+ tmpfilenam = m_mktemp(invo_name, &fd, NULL);
if (tmpfilenam == NULL) {
- adios ("rcvstore", "unable to create temporary file");
+ adios("rcvstore", "unable to create temporary file");
}
- chmod (tmpfilenam, m_gmprot());
+ chmod(tmpfilenam, m_gmprot());
/* copy the message from stdin into temp file */
- cpydata (fileno (stdin), fd, "standard input", tmpfilenam);
+ cpydata(fileno(stdin), fd, "standard input", tmpfilenam);
- if (fstat (fd, &st) == NOTOK) {
- unlink (tmpfilenam);
- adios (tmpfilenam, "unable to fstat");
+ if (fstat(fd, &st) == NOTOK) {
+ unlink(tmpfilenam);
+ adios(tmpfilenam, "unable to fstat");
}
- if (close (fd) == NOTOK)
- adios (tmpfilenam, "error closing");
+ if (close(fd) == NOTOK)
+ adios(tmpfilenam, "error closing");
/* don't add file if it is empty */
if (st.st_size == 0) {
- unlink (tmpfilenam);
- advise (NULL, "empty file");
- done (0);
+ unlink(tmpfilenam);
+ advise(NULL, "empty file");
+ done(0);
}
/*
** read folder and create message structure
*/
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ 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,
+ if ((msgnum = folder_addmsg(&mp, tmpfilenam, 0, unseensw, 0, 0,
(char *)0)) == -1)
- done (1);
+ done(1);
/*
** 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);
+ if (!seq_addmsg(mp, seqs[seqp], msgnum, publicsw, zerosw))
+ done(1);
}
- seq_setunseen (mp, 0); /* synchronize any Unseen-Sequence's */
- seq_save (mp); /* synchronize and save message sequences */
- folder_free (mp); /* free folder/message structure */
+ seq_setunseen(mp, 0); /* synchronize any Unseen-Sequence's */
+ seq_save(mp); /* synchronize and save message sequences */
+ folder_free(mp); /* free folder/message structure */
- context_save (); /* save the global context file */
- unlink (tmpfilenam); /* remove temporary file */
+ context_save(); /* save the global context file */
+ unlink(tmpfilenam); /* remove temporary file */
tmpfilenam = NULL;
- done (0);
+ done(0);
return 1;
}
unlink_done(int status)
{
if (tmpfilenam && *tmpfilenam)
- unlink (tmpfilenam);
- exit (status);
+ unlink(tmpfilenam);
+ exit(status);
}
/*
** static prototypes
*/
-static RETSIGTYPE alrmser (int);
-static int message_fd (char **);
-static int header_fd (void);
-static void alert (char *, int);
+static RETSIGTYPE alrmser(int);
+static int message_fd(char **);
+static int header_fd(void);
+static void alert(char *, int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int md, vecp = 0;
char *cp, *user, buf[BUFSIZ], tty[BUFSIZ];
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
vec[vecp++] = --cp;
continue;
case HELPSW:
- snprintf (buf, sizeof(buf),
+ snprintf(buf, sizeof(buf),
"%s [command ...]",
invo_name);
- print_help (buf, switches, 1);
- done (1);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case BIFFSW:
biff = 1;
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
format = NULL;
continue;
case FMTSW:
if (!(format = *argp++) || *format == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
form = NULL;
continue;
}
vec[vecp] = 0;
- if ((md = vecp ? message_fd (vec) : header_fd ()) == NOTOK)
- exit (RCV_MBX);
+ if ((md = vecp ? message_fd(vec) : header_fd()) == NOTOK)
+ exit(RCV_MBX);
user = getusername();
utp->ut_type == USER_PROCESS &&
#endif
utp->ut_name[0] != 0 && utp->ut_line[0] != 0
- && strncmp (user, utp->ut_name,
+ && strncmp(user, utp->ut_name,
sizeof(utp->ut_name)) == 0) {
- strncpy (tty, utp->ut_line, sizeof(utp->ut_line));
- alert (tty, md);
+ strncpy(tty, utp->ut_line, sizeof(utp->ut_line));
+ alert(tty, md);
}
}
endutent();
#else
- if ((uf = fopen (UTMP_FILE, "r")) == NULL)
- 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) {
- strncpy (tty, ut.ut_line, sizeof(ut.ut_line));
- alert (tty, md);
+ if ((uf = fopen(UTMP_FILE, "r")) == NULL)
+ 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) {
+ strncpy(tty, ut.ut_line, sizeof(ut.ut_line));
+ alert(tty, md);
}
- fclose (uf);
+ fclose(uf);
#endif
- exit (RCV_MOK);
+ exit(RCV_MOK);
return 0; /* dead code to satisfy the compiler */
}
static RETSIGTYPE
-alrmser (int i)
+alrmser(int i)
{
#ifndef RELIABLE_SIGNALS
- SIGNAL (SIGALRM, alrmser);
+ SIGNAL(SIGALRM, alrmser);
#endif
- longjmp (myctx, 1);
+ longjmp(myctx, 1);
}
static int
-message_fd (char **vec)
+message_fd(char **vec)
{
pid_t child_id;
int bytes, fd, seconds;
struct stat st;
#ifdef HAVE_MKSTEMP
- fd = mkstemp (strncpy (tmpfil, "/tmp/rcvttyXXXXX", sizeof(tmpfil)));
+ fd = mkstemp(strncpy(tmpfil, "/tmp/rcvttyXXXXX", sizeof(tmpfil)));
#else
- unlink (mktemp (strncpy (tmpfil, "/tmp/rcvttyXXXXX", sizeof(tmpfil))));
- if ((fd = open (tmpfil, O_RDWR | O_CREAT | O_TRUNC, 0600)) == NOTOK)
- return header_fd ();
+ unlink(mktemp(strncpy(tmpfil, "/tmp/rcvttyXXXXX", sizeof(tmpfil))));
+ if ((fd = open(tmpfil, O_RDWR | O_CREAT | O_TRUNC, 0600)) == NOTOK)
+ return header_fd();
#endif
- unlink (tmpfil);
+ unlink(tmpfil);
if ((child_id = vfork()) == NOTOK) {
/* fork error */
- close (fd);
- return header_fd ();
+ close(fd);
+ return header_fd();
} else if (child_id) {
/* parent process */
- if (!setjmp (myctx)) {
- SIGNAL (SIGALRM, alrmser);
- bytes = fstat(fileno (stdin), &st) != NOTOK ?
+ if (!setjmp(myctx)) {
+ SIGNAL(SIGALRM, alrmser);
+ bytes = fstat(fileno(stdin), &st) != NOTOK ?
(int) st.st_size : 100;
/* amount of time to wait depends on message size */
} else {
seconds = (bytes / 60) + 300;
}
- alarm ((unsigned int) seconds);
+ alarm((unsigned int) seconds);
pidwait(child_id, OK);
- alarm (0);
+ alarm(0);
- if (fstat (fd, &st) != NOTOK && st.st_size > (off_t) 0)
+ if (fstat(fd, &st) != NOTOK && st.st_size > (off_t) 0)
return fd;
} else {
/*
*/
KILLPG(child_id, SIGKILL);
}
- close (fd);
- return header_fd ();
+ close(fd);
+ return header_fd();
}
/* child process */
- rewind (stdin);
- if (dup2 (fd, 1) == NOTOK || dup2 (fd, 2) == NOTOK)
- _exit (-1);
- closefds (3);
- setpgid ((pid_t) 0, getpid ()); /* put in own process group */
- execvp (vec[0], vec);
- _exit (-1);
+ rewind(stdin);
+ if (dup2(fd, 1) == NOTOK || dup2(fd, 2) == NOTOK)
+ _exit(-1);
+ closefds(3);
+ setpgid((pid_t) 0, getpid()); /* put in own process group */
+ execvp(vec[0], vec);
+ _exit(-1);
return 1; /* dead code to satisfy compiler */
}
static int
-header_fd (void)
+header_fd(void)
{
int fd;
char *nfs;
tfile = m_mktemp2(NULL, invo_name, &fd, NULL);
if (tfile == NULL) return NOTOK;
- unlink (tfile);
+ unlink(tfile);
- rewind (stdin);
+ rewind(stdin);
/* get new format string */
- nfs = new_fs (form, format, SCANFMT);
- scan (stdin, 0, 0, nfs, width, 0, 0, NULL, 0L, 0);
+ nfs = new_fs(form, format, SCANFMT);
+ scan(stdin, 0, 0, nfs, width, 0, 0, NULL, 0L, 0);
if (newline)
- write (fd, "\n\r", 2);
- write (fd, scanl, strlen (scanl));
+ write(fd, "\n\r", 2);
+ write(fd, scanl, strlen(scanl));
if (bell)
- write (fd, "\007", 1);
+ write(fd, "\007", 1);
return fd;
}
static void
-alert (char *tty, int md)
+alert(char *tty, int md)
{
int i, td, mask;
char buffer[BUFSIZ], ttyspec[BUFSIZ];
struct stat st;
- snprintf (ttyspec, sizeof(ttyspec), "/dev/%s", tty);
+ snprintf(ttyspec, sizeof(ttyspec), "/dev/%s", tty);
/*
** 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)
+ if (stat(ttyspec, &st) == NOTOK || (st.st_mode & mask) == 0)
return;
- if (!setjmp (myctx)) {
- SIGNAL (SIGALRM, alrmser);
- alarm (2);
- td = open (ttyspec, O_WRONLY);
- alarm (0);
+ if (!setjmp(myctx)) {
+ SIGNAL(SIGALRM, alrmser);
+ alarm(2);
+ td = open(ttyspec, O_WRONLY);
+ alarm(0);
if (td == NOTOK)
return;
} else {
- alarm (0);
+ alarm(0);
return;
}
- lseek (md, (off_t) 0, SEEK_SET);
+ lseek(md, (off_t) 0, SEEK_SET);
- while ((i = read (md, buffer, sizeof(buffer))) > 0)
- if (write (td, buffer, i) != i)
+ while ((i = read(md, buffer, sizeof(buffer))) > 0)
+ if (write(td, buffer, i) != i)
break;
- close (td);
+ close(td);
}
-
/*
** static prototypes
*/
-static void opnfolds (struct st_fold *, int);
-static void clsfolds (struct st_fold *, int);
-static void remove_files (int, char **);
-static int m_file (char *, struct st_fold *, int, int, int);
+static void opnfolds(struct st_fold *, int);
+static void clsfolds(struct st_fold *, int);
+static void remove_files(int, char **);
+static int m_file(char *, struct st_fold *, int, int, int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int linkf = 0, preserve = 0, filep = 0;
int foldp = 0, unlink_msgs = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown\n", cp);
+ adios(NULL, "-%s unknown\n", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [msgs] [switches] +folder ...", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [msgs] [switches] +folder ...", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case LINKSW:
linkf++;
case SRCSW:
if (folder)
- adios (NULL, "only one source folder at a time!");
+ 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 == '@' ?
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ folder = path(*cp == '+' || *cp == '@' ?
cp + 1 : cp,
*cp != '@' ?
TFOLDER : TSUBCWF);
continue;
case FILESW:
if (filep > NFOLDERS)
- adios (NULL, "only %d files allowed!",
+ adios(NULL, "only %d files allowed!",
NFOLDERS);
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
- files[filep++] = path (cp, TFILE);
+ files[filep++] = path(cp, TFILE);
continue;
case RPROCSW:
if (!(rmmproc = *argp++) || *rmmproc == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
case NRPRCSW:
}
if (*cp == '+' || *cp == '@') {
if (foldp > NFOLDERS)
- adios (NULL, "only %d folders allowed!",
+ adios(NULL, "only %d folders allowed!",
NFOLDERS);
folders[foldp++].f_name =
- pluspath (cp);
+ pluspath(cp);
} else
app_msgarg(&msgs, cp);
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (foldp == 0)
- adios (NULL, "no folder specified");
+ adios(NULL, "no folder specified");
#ifdef WHATNOW
- if (!msgs.size && !foldp && !filep && (cp = getenv ("mhdraft")) && *cp)
+ if (!msgs.size && !foldp && !filep && (cp = getenv("mhdraft")) && *cp)
files[filep++] = cp;
#endif /* WHATNOW */
*/
if (filep > 0) {
if (folder || msgs.size)
- adios (NULL, "use -file or some messages, not both");
- opnfolds (folders, foldp);
+ adios(NULL, "use -file or some messages, not both");
+ opnfolds(folders, foldp);
for (i = 0; i < filep; i++)
- if (m_file (files[i], folders, foldp, preserve, 0))
- done (1);
+ if (m_file(files[i], folders, foldp, preserve, 0))
+ done(1);
/* If -nolink, then "remove" files */
if (!linkf)
- remove_files (filep, filevec);
- done (0);
+ remove_files(filep, filevec);
+ done(0);
}
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder (1);
- strncpy (maildir, m_maildir (folder), sizeof(maildir));
+ folder = getfolder(1);
+ strncpy(maildir, m_maildir(folder), sizeof(maildir));
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read source folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse the message range/sequence/name and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msgs.msgs[msgnum]))
+ done(1);
+ seq_setprev(mp); /* set the previous-sequence */
/* create folder structures for each destination folder */
- opnfolds (folders, foldp);
+ opnfolds(folders, foldp);
/* Link all the selected messages into destination folders.
**
** 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));
- if (m_file (cp, folders, foldp, preserve, !linkf))
- done (1);
- free (cp);
+ if (is_selected(mp, msgnum)) {
+ cp = getcpy(m_name(msgnum));
+ if (m_file(cp, folders, foldp, preserve, !linkf))
+ done(1);
+ free(cp);
}
}
** directory. This should be moved to folder_delmsgs().
*/
if (rmmproc) {
- context_replace (pfolder, folder);
- context_save ();
- fflush (stdout);
+ context_replace(pfolder, folder);
+ context_save();
+ fflush(stdout);
}
/*
** because the message has already been handled above.
*/
if (!linkf) {
- folder_delmsgs (mp, unlink_msgs, 1);
+ folder_delmsgs(mp, unlink_msgs, 1);
}
- clsfolds (folders, foldp);
+ clsfolds(folders, foldp);
- if (mp->hghsel != mp->curmsg
- && (mp->numsel != mp->nummsg || linkf))
- seq_setcur (mp, mp->hghsel);
- seq_save (mp); /* synchronize message sequences */
+ if (mp->hghsel != mp->curmsg &&
+ (mp->numsel != mp->nummsg || linkf))
+ seq_setcur(mp, mp->hghsel);
+ seq_save(mp); /* synchronize message sequences */
- context_replace (pfolder, folder); /* update current folder */
- context_save (); /* save the context file */
- folder_free (mp); /* free folder structure */
- done (0);
+ context_replace(pfolder, folder); /* update current folder */
+ context_save(); /* save the context file */
+ folder_free(mp); /* free folder structure */
+ done(0);
return 1;
}
*/
static void
-opnfolds (struct st_fold *folders, int nfolders)
+opnfolds(struct st_fold *folders, int nfolders)
{
char nmaildir[BUFSIZ];
register struct st_fold *fp, *ep;
register struct msgs *mp;
for (fp = folders, ep = folders + nfolders; fp < ep; fp++) {
- chdir (m_maildir (""));
- strncpy (nmaildir, m_maildir (fp->f_name), sizeof(nmaildir));
+ chdir(m_maildir(""));
+ strncpy(nmaildir, m_maildir(fp->f_name), sizeof(nmaildir));
- create_folder (nmaildir, 0, done);
+ create_folder(nmaildir, 0, done);
- if (chdir (nmaildir) == NOTOK)
- adios (nmaildir, "unable to change directory to");
- if (!(mp = folder_read (fp->f_name)))
- adios (NULL, "unable to read folder %s", fp->f_name);
+ if (chdir(nmaildir) == NOTOK)
+ adios(nmaildir, "unable to change directory to");
+ if (!(mp = folder_read(fp->f_name)))
+ adios(NULL, "unable to read folder %s", fp->f_name);
mp->curmsg = 0;
fp->f_mp = mp;
- chdir (maildir);
+ chdir(maildir);
}
}
*/
static void
-clsfolds (struct st_fold *folders, int nfolders)
+clsfolds(struct st_fold *folders, int nfolders)
{
register struct st_fold *fp, *ep;
register struct msgs *mp;
for (fp = folders, ep = folders + nfolders; fp < ep; fp++) {
mp = fp->f_mp;
- seq_setprev (mp);
- seq_save (mp);
+ seq_setprev(mp);
+ seq_save(mp);
}
}
*/
static void
-remove_files (int filep, char **files)
+remove_files(int filep, char **files)
{
int i;
char **vec;
vec = files++; /* vec[0] = filevec[0] */
files[filep] = NULL; /* NULL terminate list */
- fflush (stdout);
- vec[0] = r1bindex (rmmproc, '/');
- execvp (rmmproc, vec);
- adios (rmmproc, "unable to exec");
+ fflush(stdout);
+ vec[0] = r1bindex(rmmproc, '/');
+ execvp(rmmproc, vec);
+ adios(rmmproc, "unable to exec");
}
/* Else just unlink the files */
files++; /* advance past filevec[0] */
for (i = 0; i < filep; i++) {
- if (unlink (files[i]) == NOTOK)
- admonish (files[i], "unable to unlink");
+ if (unlink(files[i]) == NOTOK)
+ admonish(files[i], "unable to unlink");
}
}
*/
static int
-m_file (char *msgfile, struct st_fold *folders, int nfolders, int preserve,
+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,
+ if ((msgnum = folder_addmsg(&fp->f_mp, msgfile, 1, 0,
preserve, nfolders == 1 && refile, maildir))
== -1)
return 1;
/*
** prototypes
*/
-void docc (char *, int);
+void docc(char *, int);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int anot = 0, inplace = 1;
int nedit = 0, nwhat = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s: [+folder] [msg] [switches]", invo_name);
- print_help (buf, switches, 1);
- done (0);
+ snprintf(buf, sizeof(buf), "%s: [+folder] [msg] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(0);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case GROUPSW:
groupreply++;
case CCSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- docc (cp, 1);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ docc(cp, 1);
continue;
case NCCSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- docc (cp, 0);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ docc(cp, 0);
continue;
case EDITRSW:
if (!(ed = *argp++) || *ed == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
nedit = 0;
continue;
case NEDITSW:
case WHATSW:
if (!(whatnowproc = *argp++) ||
*whatnowproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
nwhat = 0;
continue;
#ifdef MHE
case FCCSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
dp = NULL;
if (*cp == '@')
- cp = dp = path (cp + 1,
+ cp = dp = path(cp + 1,
TSUBCWF);
if (fcc)
- fcc = add (", ", fcc);
- fcc = add (cp, fcc);
+ fcc = add(", ", fcc);
+ fcc = add(cp, fcc);
if (dp)
- free (dp);
+ free(dp);
continue;
case FILESW:
if (file)
- adios (NULL, "only one file at a time!");
+ adios(NULL, "only one file at a time!");
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- file = path (cp, TFILE);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ file = path(cp, TFILE);
continue;
case FILTSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- filter = getcpy (etcpath (cp));
+ adios(NULL, "missing argument to %s", argp[-2]);
+ filter = getcpy(etcpath(cp));
mime = 0;
continue;
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case FRMTSW:
- filter = getcpy (etcpath (mhlreply));
+ filter = getcpy(etcpath(mhlreply));
mime = 0;
continue;
case NFRMTSW:
case WIDTHSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((outputlinelen = atoi (cp)) < 10)
- adios (NULL, "impossible width %d", outputlinelen);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((outputlinelen = atoi(cp)) < 10)
+ adios(NULL, "impossible width %d", outputlinelen);
continue;
}
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else {
if (msg)
- adios (NULL, "only one message at a time!");
+ adios(NULL, "only one message at a time!");
else
msg = cp;
}
if (ccme == -1)
ccme = groupreply;
- cwd = getcpy (pwd ());
+ cwd = getcpy(pwd());
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (file && (msg || folder))
- adios (NULL, "can't mix files and folders/msgs");
+ adios(NULL, "can't mix files and folders/msgs");
#ifdef MHE
- strncpy (drft, buildsw ? m_maildir ("reply")
+ strncpy(drft, buildsw ? m_maildir("reply")
: m_draft("new"), sizeof(drft));
#else
- strncpy (drft, m_draft("new"), sizeof(drft));
+ strncpy(drft, m_draft("new"), sizeof(drft));
#endif /* MHE */
if (file) {
if (!msg)
msg = "cur";
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse the message range/sequence/name and set SELECTED */
- if (!m_convert (mp, msg))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msg))
+ done(1);
+ seq_setprev(mp); /* set the previous-sequence */
if (mp->numsel > 1)
- adios (NULL, "only one message at a time!");
+ adios(NULL, "only one message at a time!");
- 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 */
+ 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 */
}
- msg = file ? file : getcpy (m_name (mp->lowsel));
+ msg = file ? file : getcpy(m_name(mp->lowsel));
- if ((in = fopen (msg, "r")) == NULL)
- adios (msg, "unable to open");
+ if ((in = fopen(msg, "r")) == NULL)
+ adios(msg, "unable to open");
/* find form (components) file */
if (!form) {
if (groupreply)
- form = etcpath (replgroupcomps);
+ form = etcpath(replgroupcomps);
else
- form = etcpath (replcomps);
+ form = etcpath(replcomps);
}
- replout (in, msg, drft, mp, outputlinelen, mime, form, filter, fcc);
- fclose (in);
+ replout(in, msg, drft, mp, outputlinelen, mime, form, filter, fcc);
+ fclose(in);
if (nwhat)
- done (0);
- what_now (ed, nedit, NOUSE, drft, msg, 0, mp,
- anot ? "Replied" : NULL, inplace, cwd);
- done (1);
+ done(0);
+ what_now(ed, nedit, NOUSE, drft, msg, 0, mp, anot ? "Replied" : NULL,
+ inplace, cwd);
+ done(1);
return 1;
}
void
-docc (char *cp, int ccflag)
+docc(char *cp, int ccflag)
{
- switch (smatch (cp, ccswitches)) {
+ switch (smatch(cp, ccswitches)) {
case AMBIGSW:
- ambigsw (cp, ccswitches);
- done (1);
+ 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;
/*
** static prototypes
*/
-static int insert (struct mailname *);
-static void replfilter (FILE *, FILE *, char *);
+static int insert(struct mailname *);
+static void replfilter(FILE *, FILE *, char *);
void
-replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
+replout(FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
int mime, char *form, char *filter, char *fcc)
{
register int state, i;
FILE *out;
mask = umask(~m_gmprot());
- if ((out = fopen (drft, "w")) == NULL)
- adios (drft, "unable to create");
+ if ((out = fopen(drft, "w")) == NULL)
+ adios(drft, "unable to create");
umask(mask);
/* get new format string */
- cp = new_fs (form, NULL, NULL);
- format_len = strlen (cp);
+ cp = new_fs(form, NULL, NULL);
+ format_len = strlen(cp);
/* compile format string */
- ncomps = fmt_compile (cp, &fmt) + 1;
+ ncomps = fmt_compile(cp, &fmt) + 1;
if (!(nxtbuf = compbuffers = (char **)
calloc((size_t) ncomps, sizeof(char *))))
- adios (NULL, "unable to allocate component buffers");
+ adios(NULL, "unable to allocate component buffers");
if (!(savecomp = used_buf = (struct comp **)
calloc((size_t) (ncomps+1), sizeof(struct comp *))))
- adios (NULL, "unable to allocate component buffer stack");
+ adios(NULL, "unable to allocate component buffer stack");
savecomp += ncomps + 1;
*--savecomp = NULL; /* point at zero'd end minus 1 */
tmpbuf = *nxtbuf++;
for (ap = addrcomps; *ap; ap++) {
- FINDCOMP (cptr, *ap);
+ FINDCOMP(cptr, *ap);
if (cptr)
cptr->c_type |= CT_ADDR;
}
** ignore any components killed by command line switches
*/
if (!ccto) {
- FINDCOMP (cptr, "to");
+ FINDCOMP(cptr, "to");
if (cptr)
cptr->c_name = "";
}
if (!cccc) {
- FINDCOMP (cptr, "cc");
+ FINDCOMP(cptr, "cc");
if (cptr)
cptr->c_name = "";
}
/* set up the "fcc" pseudo-component */
if (fcc) {
- FINDCOMP (cptr, "fcc");
+ FINDCOMP(cptr, "fcc");
if (cptr)
- cptr->c_text = getcpy (fcc);
+ cptr->c_text = getcpy(fcc);
}
if ((cp = getenv("USER"))) {
- FINDCOMP (cptr, "user");
+ FINDCOMP(cptr, "user");
if (cptr)
cptr->c_text = getcpy(cp);
}
if (!ccme)
- ismymbox (NULL);
+ ismymbox(NULL);
/*
** pick any interesting stuff out of msg "inb"
*/
for (state = FLD;;) {
- state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+ state = m_getfld(state, name, tmpbuf, SBUFSIZ, inb);
switch (state) {
case FLD:
case FLDPLUS:
*--savecomp = cptr;
tmpbuf = *nxtbuf++;
} else {
- i = strlen (cp = cptr->c_text) - 1;
+ i = strlen(cp = cptr->c_text) - 1;
if (cp[i] == '\n') {
if (cptr->c_type & CT_ADDR) {
cp[i] = '\0';
- cp = add (",\n\t", cp);
+ cp = add(",\n\t", cp);
} else {
- cp = add ("\t", cp);
+ cp = add("\t", cp);
}
}
- cptr->c_text = add (tmpbuf, cp);
+ cptr->c_text = add(tmpbuf, cp);
}
while (state == FLDPLUS) {
- state = m_getfld (state, name, tmpbuf,
+ state = m_getfld(state, name, tmpbuf,
SBUFSIZ, inb);
- cptr->c_text = add (tmpbuf, cptr->c_text);
+ cptr->c_text = add(tmpbuf, cptr->c_text);
char_read += msg_count;
}
break;
} while ((cptr = cptr->c_next));
while (state == FLDPLUS)
- state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+ state = m_getfld(state, name, tmpbuf, SBUFSIZ, inb);
break;
case LENERR:
goto finished;
default:
- adios (NULL, "m_getfld() returned %d", state);
+ adios(NULL, "m_getfld() returned %d", state);
}
}
/*
** if there's a "Subject" component, strip any "Re:"s off it
*/
- FINDCOMP (cptr, "subject")
+ FINDCOMP(cptr, "subject")
if (cptr && (cp = cptr->c_text)) {
register char *sp = cp;
}
if (sp != cptr->c_text) {
cp = cptr->c_text;
- cptr->c_text = getcpy (sp);
- free (cp);
+ cptr->c_text = getcpy(sp);
+ free(cp);
}
}
i = format_len + char_read + 256;
- scanl = mh_xmalloc ((size_t) i + 2);
+ scanl = mh_xmalloc((size_t) i + 2);
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
dat[3] = outputlinelen;
dat[4] = 0;
- fmt_scan (fmt, scanl, i, dat);
- fputs (scanl, out);
+ fmt_scan(fmt, scanl, i, dat);
+ fputs(scanl, out);
if (badaddrs) {
- fputs ("\nrepl: bad addresses:\n", out);
- fputs ( badaddrs, out);
+ fputs("\nrepl: bad addresses:\n", out);
+ fputs( badaddrs, out);
}
/*
*/
if (filter) {
fflush(out);
- if (ferror (out))
- adios (drft, "error writing");
+ if (ferror(out))
+ adios(drft, "error writing");
- replfilter (inb, out, filter);
+ 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);
- if (ferror (out))
- adios (drft, "error writing");
- fclose (out);
+ if (ferror(out))
+ adios(drft, "error writing");
+ fclose(out);
/* return dynamically allocated buffers */
- free (scanl);
+ free(scanl);
for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++);
nxtbuf++, i--)
- free (cptr->c_text); /* if not nxtbuf, nxtbuf already freed */
+ free(cptr->c_text); /* if not nxtbuf, nxtbuf already freed */
while ( i-- > 0)
- free (*nxtbuf++); /* free unused nxtbufs */
- free ((char *) compbuffers);
- free ((char *) used_buf);
+ free(*nxtbuf++); /* free unused nxtbufs */
+ free((char *) compbuffers);
+ free((char *) used_buf);
}
static char *buf; /* our current working buffer */
** add more mem if needed
*/
#define CHECKMEM(str) \
- if ((len = strlen (str)) >= bufend - dst) {\
+ if ((len = strlen(str)) >= bufend - dst) {\
int i = dst - buf;\
int n = last_dst - buf;\
bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
- buf = mh_xrealloc (buf, bufsiz);\
+ buf = mh_xrealloc(buf, bufsiz);\
dst = buf + i;\
last_dst = buf + n;\
bufend = buf + bufsiz;\
** length of the result string.
*/
char *
-formataddr (char *orig, char *str)
+formataddr(char *orig, char *str)
{
register int len;
char baddr[BUFSIZ], error[BUFSIZ];
/* if we don't have a buffer yet, get one */
if (bufsiz == 0) {
- buf = mh_xmalloc (BUFINCR);
+ buf = mh_xmalloc(BUFINCR);
last_dst = buf; /* XXX */
bufsiz = BUFINCR - 6; /* leave some slop */
bufend = buf + bufsiz;
*dst = '\0';
} else {
dst = last_dst; /* XXX */
- CHECKMEM (orig);
- CPY (orig);
+ CHECKMEM(orig);
+ CPY(orig);
}
/* concatenate all the new addresses onto 'buf' */
- for (isgroup = 0; (cp = getname (str)); ) {
- if ((mp = getm (cp, dfhost, dftype, AD_NAME, error)) == NULL) {
- snprintf (baddr, sizeof(baddr), "\t%s -- %s\n",
+ 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);
- badaddrs = add (baddr, badaddrs);
+ badaddrs = add(baddr, badaddrs);
continue;
}
if (isgroup && (mp->m_gname || !mp->m_ingrp)) {
*dst++ = ';';
isgroup = 0;
}
- if (insert (mp)) {
+ if (insert(mp)) {
/* if we get here we're going to add an address */
if (dst != buf) {
*dst++ = ',';
*dst++ = ' ';
}
if (mp->m_gname) {
- CHECKMEM (mp->m_gname);
- CPY (mp->m_gname);
+ CHECKMEM(mp->m_gname);
+ CPY(mp->m_gname);
isgroup++;
}
- sp = adrformat (mp);
- CHECKMEM (sp);
- CPY (sp);
+ sp = adrformat(mp);
+ CHECKMEM(sp);
+ CPY(sp);
}
}
static int
-insert (struct mailname *np)
+insert(struct mailname *np)
{
char buffer[BUFSIZ];
register struct mailname *mp;
return 0;
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))
+ if (!mh_strcasecmp(np->m_host, mp->m_next->m_host) &&
+ !mh_strcasecmp(np->m_mbox, mp->m_next->m_mbox))
return 0;
}
- if (!ccme && ismymbox (np))
+ if (!ccme && ismymbox(np))
return 0;
if (querysw) {
- snprintf (buffer, sizeof(buffer), "Reply to %s? ",
- adrformat (np));
- if (!gans (buffer, anoyes))
+ snprintf(buffer, sizeof(buffer), "Reply to %s? ",
+ adrformat(np));
+ if (!gans(buffer, anoyes))
return 0;
}
mp->m_next = np;
#ifdef ISI
- if (ismymbox (np))
+ if (ismymbox(np))
ccme = 0;
#endif
*/
static void
-replfilter (FILE *in, FILE *out, char *filter)
+replfilter(FILE *in, FILE *out, char *filter)
{
int pid;
char *mhl;
if (filter == NULL)
return;
- if (access (filter, R_OK) == NOTOK)
- adios (filter, "unable to read");
+ if (access(filter, R_OK) == NOTOK)
+ adios(filter, "unable to read");
- mhl = r1bindex (mhlproc, '/');
+ mhl = r1bindex(mhlproc, '/');
- rewind (in);
- lseek (fileno(in), (off_t) 0, SEEK_SET);
+ rewind(in);
+ lseek(fileno(in), (off_t) 0, SEEK_SET);
- switch (pid = vfork ()) {
+ switch (pid = vfork()) {
case NOTOK:
- adios ("fork", "unable to");
+ adios("fork", "unable to");
case OK:
- dup2 (fileno (in), fileno (stdin));
- dup2 (fileno (out), fileno (stdout));
- closefds (3);
+ dup2(fileno(in), fileno(stdin));
+ dup2(fileno(out), fileno(stdout));
+ closefds(3);
- execlp (mhlproc, mhl, "-form", filter, "-noclear",
+ execlp(mhlproc, mhl, "-form", filter, "-noclear",
NULL);
errstr = strerror(errno);
write(2, "unable to exec ", 15);
write(2, ": ", 2);
write(2, errstr, strlen(errstr));
write(2, "\n", 1);
- _exit (-1);
+ _exit(-1);
default:
- if (pidXwait (pid, mhl))
- done (1);
- fseek (out, 0L, SEEK_END);
+ if (pidXwait(pid, mhl))
+ done(1);
+ fseek(out, 0L, SEEK_END);
break;
}
}
** static prototypes
*/
static int rmf(char *);
-static void rma (char *);
+static void rma(char *);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int defolder = 0, interactive = -1;
char *cp, *folder = NULL, newfolder[BUFSIZ];
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [switches]", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case INTRSW:
interactive = 1;
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else {
- adios (NULL, "usage: %s [+folder] [switches]",
+ adios(NULL, "usage: %s [+folder] [switches]",
invo_name);
}
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (!folder) {
- folder = getfolder (1);
+ folder = getfolder(1);
defolder++;
}
- if (strcmp (m_mailpath (folder), pwd ()) == 0)
- adios (NULL, "sorry, you can't remove the current working directory");
+ if (strcmp(m_mailpath(folder), pwd()) == 0)
+ adios(NULL, "sorry, you can't remove the current working directory");
if (interactive == -1)
interactive = defolder;
- if (strchr (folder, '/') && (*folder != '/') && (*folder != '.')) {
- for (cp = copy (folder, newfolder);
+ if (strchr(folder, '/') && (*folder != '/') && (*folder != '.')) {
+ for (cp = copy(folder, newfolder);
cp > newfolder && *cp != '/'; cp--)
continue;
if (cp > newfolder)
*cp = '\0';
else
- strncpy (newfolder, getfolder(0), sizeof(newfolder));
+ strncpy(newfolder, getfolder(0), sizeof(newfolder));
} else {
- strncpy (newfolder, getfolder(0), sizeof(newfolder));
+ strncpy(newfolder, getfolder(0), sizeof(newfolder));
}
if (interactive) {
- cp = concat ("Remove folder \"", folder, "\"? ", NULL);
- if (!getanswer (cp))
- done (0);
- free (cp);
+ cp = concat("Remove folder \"", folder, "\"? ", NULL);
+ if (!getanswer(cp))
+ done(0);
+ free(cp);
}
- if (rmf (folder) == OK) {
+ if (rmf(folder) == OK) {
char *cfolder = context_find(pfolder);
- if (cfolder && strcmp (cfolder, newfolder)) {
- printf ("[+%s now current]\n", newfolder);
+ if (cfolder && strcmp(cfolder, newfolder)) {
+ printf("[+%s now current]\n", newfolder);
/* update current folder */
- context_replace (pfolder, newfolder);
+ context_replace(pfolder, newfolder);
}
}
- context_save (); /* save the context file */
- done (0);
+ context_save(); /* save the context file */
+ done(0);
return 1;
}
static int
-rmf (char *folder)
+rmf(char *folder)
{
int i, j, others;
register char *maildir;
register struct dirent *dp;
register DIR *dd;
- switch (i = chdir (maildir = m_maildir (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:
- snprintf (cur, sizeof(cur), "atr-%s-%s",
- current, m_mailpath (folder));
- if (!context_del (cur)) {
- printf ("[+%s de-referenced]\n", folder);
+ snprintf(cur, sizeof(cur), "atr-%s-%s",
+ current, m_mailpath(folder));
+ if (!context_del(cur)) {
+ 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;
}
- if ((dd = opendir (".")) == NULL)
- adios (NULL, "unable to read folder +%s", folder);
+ if ((dd = opendir(".")) == NULL)
+ adios(NULL, "unable to read folder +%s", folder);
others = 0;
/*
(void)ext_hook("del-hook", maildir, (char *)0);
j = strlen(backup_prefix);
- while ((dp = readdir (dd))) {
+ while ((dp = readdir(dd))) {
switch (dp->d_name[0]) {
case '.':
- if (strcmp (dp->d_name, ".") == 0
- || strcmp (dp->d_name, "..")
- == 0)
+ if (strcmp(dp->d_name, ".") == 0 ||
+ strcmp(dp->d_name, "..") == 0)
continue; /* else fall */
case ',':
break;
default:
- if (m_atoi (dp->d_name))
+ if (m_atoi(dp->d_name))
break;
- if (strcmp (dp->d_name, altmsglink) == 0
- || strncmp (dp->d_name,
+ if (strcmp(dp->d_name, altmsglink) == 0 ||
+ strncmp(dp->d_name,
backup_prefix, j) == 0)
break;
- admonish (NULL, "file \"%s/%s\" not deleted",
+ admonish(NULL, "file \"%s/%s\" not deleted",
folder, dp->d_name);
others++;
continue;
}
- if (unlink (dp->d_name) == NOTOK) {
- admonish (dp->d_name, "unable to unlink %s:", folder);
+ if (unlink(dp->d_name) == NOTOK) {
+ admonish(dp->d_name, "unable to unlink %s:", folder);
others++;
}
}
- closedir (dd);
+ closedir(dd);
/*
** Remove any relevant private sequences
** or attributes from context file.
*/
- rma (folder);
+ rma(folder);
- chdir ("..");
+ chdir("..");
if (others == 0) {
context_save(); /* Is this needed? meillo 2011-10 */
fflush(stdout); /* Is this needed? meillo 2011-10 */
if (rmdir(maildir) != -1) {
return OK;
}
- admonish (maildir, "unable to remove directory");
+ admonish(maildir, "unable to remove directory");
}
- advise (NULL, "folder +%s not removed", folder);
+ advise(NULL, "folder +%s not removed", folder);
return NOTOK;
}
*/
static void
-rma (char *folder)
+rma(char *folder)
{
register int alen, j, plen;
register char *cp;
register struct node *np, *pp;
- alen = strlen ("atr-");
- plen = strlen (cp = m_mailpath (folder)) + 1;
+ alen = strlen("atr-");
+ plen = strlen(cp = m_mailpath(folder)) + 1;
/*
** 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 (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\")",
+ admonish(NULL, "bug: context_del(key=\"%s\")",
np->n_name);
if (pp) {
pp->n_next = np->n_next;
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int msgnum, unlink_msgs = 0;
char *cp, *maildir, *folder = NULL;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/* parse arguments */
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown\n", cp);
+ adios(NULL, "-%s unknown\n", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case UNLINKSW:
unlink_msgs++;
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
app_msgarg(&msgs, cp);
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msgs.msgs[msgnum]))
+ done(1);
+ seq_setprev(mp); /* set the previous-sequence */
/*
** This is hackish. If we are using a external rmmproc,
** folder_delmsgs().
*/
if (rmmproc) {
- context_replace (pfolder, folder);
- context_save ();
- fflush (stdout);
+ context_replace(pfolder, folder);
+ context_save();
+ fflush(stdout);
}
/* "remove" the SELECTED messages */
- folder_delmsgs (mp, unlink_msgs, 0);
+ folder_delmsgs(mp, unlink_msgs, 0);
- seq_save (mp); /* synchronize message sequences */
- context_replace (pfolder, folder); /* update current folder */
- context_save (); /* save the context file */
- folder_free (mp); /* free folder structure */
- done (0);
+ seq_save(mp); /* synchronize message sequences */
+ context_replace(pfolder, folder); /* update current folder */
+ context_save(); /* save the context file */
+ folder_free(mp); /* free folder structure */
+ done(0);
return 1;
}
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int clearflag = 0, hdrflag = 0, ontty;
int width = 0, revflag = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case CLRSW:
clearflag++;
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
format = NULL;
continue;
case FMTSW:
if (!(format = *argp++) ||
*format == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
form = NULL;
continue;
case WIDTHSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- width = atoi (cp);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ width = atoi(cp);
continue;
case REVSW:
revflag++;
case FILESW:
if (!(cp = *argp++) || (cp[0] == '-' && cp[1]))
- adios (NULL, "missing argument to %s", argp[-2]);
- if (strcmp (file = cp, "-"))
- file = path (cp, TFILE);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if (strcmp(file = cp, "-"))
+ file = path(cp, TFILE);
continue;
}
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
app_msgarg(&msgs, cp);
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
/*
** Get new format string. Must be before chdir().
*/
- nfs = new_fs (form, format, FORMAT);
+ nfs = new_fs(form, format, FORMAT);
/*
** We are scanning a maildrop file
*/
if (file) {
if (msgs.size)
- adios (NULL, "\"msgs\" not allowed with -file");
+ adios(NULL, "\"msgs\" not allowed with -file");
if (folder)
- adios (NULL, "\"+folder\" not allowed with -file");
+ adios(NULL, "\"+folder\" not allowed with -file");
/* check if "file" is really stdin */
- if (strcmp (file, "-") == 0) {
+ if (strcmp(file, "-") == 0) {
in = stdin;
file = "stdin";
} else {
- if ((in = fopen (file, "r")) == NULL)
- adios (file, "unable to open");
+ if ((in = fopen(file, "r")) == NULL)
+ adios(file, "unable to open");
}
#ifndef JLR
if (hdrflag) {
- printf ("FOLDER %s\t%s\n", file, dtimenow (1));
+ printf("FOLDER %s\t%s\n", file, dtimenow(1));
}
#endif /* JLR */
- m_unknown (in);
+ m_unknown(in);
for (msgnum = 1; ; ++msgnum) {
- state = scan (in, msgnum, -1, nfs, width, 0, 0,
+ state = scan(in, msgnum, -1, nfs, width, 0, 0,
hdrflag ? file : NULL, 0L, 1);
if (state != SCNMSG && state != SCNENC)
break;
}
- fclose (in);
- done (0);
+ fclose(in);
+ done(0);
}
/*
if (!msgs.size)
app_msgarg(&msgs, "all");
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
+ if (!m_convert(mp, msgs.msgs[msgnum]))
done(1);
- seq_setprev (mp); /* set the Previous-Sequence */
+ seq_setprev(mp); /* set the Previous-Sequence */
- context_replace (pfolder, folder); /* update current folder */
- seq_save (mp); /* synchronize message sequences */
- context_save (); /* save the context file */
+ context_replace(pfolder, folder); /* update current folder */
+ seq_save(mp); /* synchronize message sequences */
+ context_save(); /* save the context file */
/*
** Get the sequence number for each sequence
** specified by Unseen-Sequence
*/
- if ((cp = context_find (usequence)) && *cp) {
+ if ((cp = context_find(usequence)) && *cp) {
char **ap, *dp;
dp = getcpy(cp);
- ap = brkstring (dp, " ", "\n");
+ ap = brkstring(dp, " ", "\n");
for (i = 0; ap && *ap; i++, ap++)
- seqnum[i] = seq_getnum (mp, *ap);
+ seqnum[i] = seq_getnum(mp, *ap);
num_unseen_seq = i;
if (dp)
free(dp);
}
- ontty = isatty (fileno (stdout));
+ ontty = isatty(fileno(stdout));
#ifdef LBL
else
(revflag ? msgnum >= mp->lowsel : msgnum <= mp->hghsel);
msgnum += (revflag ? -1 : 1)) {
if (is_selected(mp, msgnum)) {
- if ((in = fopen (cp = m_name (msgnum), "r")) == NULL) {
+ if ((in = fopen(cp = m_name(msgnum), "r")) == NULL) {
#if 0
if (errno != EACCES)
#endif
- admonish (cp, "unable to open message");
+ admonish(cp, "unable to open message");
#if 0
else
- printf ("%*d unreadable\n",
+ 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 */
}
}
- switch (state = scan (in, msgnum, 0, nfs, width,
+ switch (state = scan(in, msgnum, 0, nfs, width,
msgnum == mp->curmsg, unseen,
folder, 0L, 1)) {
case SCNMSG:
break;
default:
- adios (NULL, "scan() botch (%d)",
- state);
+ adios(NULL, "scan() botch(%d)", state);
case SCNEOF:
#if 0
- printf ("%*d empty\n", DMAXFOLDER,
+ printf("%*d empty\n", DMAXFOLDER,
msgnum);
#else
- advise (NULL, "message %d: empty",
+ advise(NULL, "message %d: empty",
msgnum);
#endif
break;
}
hdrflag = 0;
- fclose (in);
+ fclose(in);
if (ontty)
- fflush (stdout);
+ fflush(stdout);
}
}
#ifdef LBL
- seq_save (mp); /* because formatsbr might have made changes */
+ seq_save(mp); /* because formatsbr might have made changes */
#endif
- folder_free (mp); /* free folder/message structure */
+ folder_free(mp); /* free folder/message structure */
if (clearflag)
- clear_screen ();
+ clear_screen();
- done (0);
+ done(0);
return 1;
}
char *scanl = 0; /* text of most recent scanline */
-#define DIEWRERR() adios (scnmsg, "write error on")
+#define DIEWRERR() adios(scnmsg, "write error on")
#define FPUTS(buf) {\
if (mh_fputs(buf,scnout) == EOF)\
/*
** prototypes
*/
-int sc_width (void); /* from termsbr.c */
+int sc_width(void); /* from termsbr.c */
static int mh_fputs(char *, FILE *);
#ifdef MULTIBYTE_SUPPORT
#endif
int
-scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
+scan(FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
int unseen, char *folder, long size, int noisy)
{
int i, compnum, encrypted, state;
/* first-time only initialization */
if (!scanl) {
if (width == 0) {
- if ((width = sc_width ()) < WIDTH/2)
+ if ((width = sc_width()) < WIDTH/2)
width = WIDTH/2;
else if (width > MAXSCANL)
width = MAXSCANL;
umask(~m_gmprot());
/* Compile format string */
- ncomps = fmt_compile (nfs, &fmt) + 1;
+ ncomps = fmt_compile(nfs, &fmt) + 1;
#ifdef JLR
fmt_top = fmt;
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)];
+ cptr->c_next = wantcomp[i = CHASH(cptr->c_name)];
wantcomp[i] = cptr;
ncomps++;
}
- FINDCOMP (cptr, "dtimenow");
+ FINDCOMP(cptr, "dtimenow");
if (cptr)
- cptr->c_text = getcpy(dtimenow (0));
+ cptr->c_text = getcpy(dtimenow(0));
nxtbuf = compbuffers = (char **) calloc((size_t) ncomps,
sizeof(char *));
if (nxtbuf == NULL)
- adios (NULL, "unable to allocate component buffers");
+ adios(NULL, "unable to allocate component buffers");
used_buf = (struct comp **) calloc((size_t) (ncomps+1),
sizeof(struct comp *));
if (used_buf == NULL)
- adios (NULL, "unable to allocate component buffer stack");
+ adios(NULL, "unable to allocate component buffer stack");
used_buf += ncomps+1; *--used_buf = 0;
rlwidth = bodycomp && (width > SBUFSIZ) ? width : SBUFSIZ;
for (i = ncomps; i--; )
** 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 ((state = m_getfld(FLD, name, tmpbuf, rlwidth, inb)) == FILEEOF) {
if (ferror(inb)) {
advise("read", "unable to"); /* "read error" */
return SCNFAT;
if (outnum) {
if (outnum > 0) {
- scnmsg = m_name (outnum);
+ scnmsg = m_name(outnum);
if (*scnmsg == '?') /* msg num out of range */
return SCNNUM;
} else {
scnmsg = "/dev/null";
}
- if ((scnout = fopen (scnmsg, "w")) == NULL)
- adios (scnmsg, "unable to write");
+ if ((scnout = fopen(scnmsg, "w")) == NULL)
+ adios(scnmsg, "unable to write");
#ifdef RPATHS
/*
** Add the Return-Path and Delivery-Date
** header fields to message.
*/
- if (get_returnpath (returnpath, sizeof(returnpath),
+ if (get_returnpath(returnpath, sizeof(returnpath),
deliverydate, sizeof(deliverydate))) {
- FPUTS ("Return-Path: ");
- FPUTS (returnpath);
- FPUTS ("Delivery-Date: ");
- FPUTS (deliverydate);
+ FPUTS("Return-Path: ");
+ FPUTS(returnpath);
+ FPUTS("Delivery-Date: ");
+ FPUTS(deliverydate);
}
#endif /* RPATHS */
}
/* scan - main loop */
for (compnum = 1; ;
- state = m_getfld (state, name, tmpbuf, rlwidth, inb)) {
+ state = m_getfld(state, name, tmpbuf, rlwidth, inb)) {
switch (state) {
case FLD:
case FLDPLUS:
compnum++;
if (outnum) {
- FPUTS (name);
- if ( putc (':', scnout) == EOF)
+ FPUTS(name);
+ if (putc(':', scnout) == EOF)
DIEWRERR();
- FPUTS (tmpbuf);
+ FPUTS(tmpbuf);
}
/*
** if we're interested in this component,
if (!mh_strcasecmp(name, cptr->c_name)) {
if (! cptr->c_text) {
cptr->c_text = tmpbuf;
- for (cp = tmpbuf + strlen (tmpbuf) - 1;
+ for (cp = tmpbuf + strlen(tmpbuf) - 1;
cp >= tmpbuf; cp--)
- if (isspace (*cp))
+ if (isspace(*cp))
*cp = 0;
else
break;
}
while (state == FLDPLUS) {
- state = m_getfld (state, name, tmpbuf, rlwidth, inb);
+ state = m_getfld(state, name, tmpbuf,
+ rlwidth, inb);
if (outnum)
- FPUTS (tmpbuf);
+ FPUTS(tmpbuf);
}
break;
state = FILEEOF; /* stop now if scan cmd */
goto finished;
}
- if (putc ('\n', scnout) == EOF) DIEWRERR();
- FPUTS (tmpbuf);
+ if (putc('\n', scnout) == EOF) DIEWRERR();
+ FPUTS(tmpbuf);
/*
** performance hack: some people like to
** run "inc" on things like net.sources or
if (scnout->_cnt <= 0) {
#endif
if (fflush(scnout) == EOF)
- DIEWRERR ();
+ DIEWRERR();
}
#ifdef LINUX_STDIO
state = m_getfld(state, name, scnout->_IO_write_ptr,
(long)scnout->_IO_write_ptr-(long)scnout->_IO_write_end , inb);
scnout->_IO_write_ptr += msg_count;
#elif defined(__DragonFly__)
- state = m_getfld( state, name, ((struct __FILE_public *)scnout)->_p, -(((struct __FILE_public *)scnout)->_w), inb );
+ state = m_getfld(state, name, ((struct __FILE_public *)scnout)->_p, -(((struct __FILE_public *)scnout)->_w), inb );
((struct __FILE_public *)scnout)->_w -= msg_count;
((struct __FILE_public *)scnout)->_p += msg_count;
#else
case LENERR:
case FMTERR:
- fprintf (stderr, innum ? "??Format error (message %d) in " : "??Format error in ", outnum ? outnum : innum);
- fprintf (stderr, "component %d\n", compnum);
+ fprintf(stderr, innum ? "??Format error (message %d) in " : "??Format error in ", outnum ? outnum : innum);
+ fprintf(stderr, "component %d\n", compnum);
if (outnum) {
- FPUTS ("\n\nBAD MSG:\n");
- FPUTS (name);
- if (putc ('\n', scnout) == EOF) DIEWRERR();
+ FPUTS("\n\nBAD MSG:\n");
+ FPUTS(name);
+ if (putc('\n', scnout) == EOF)
+ DIEWRERR();
state = BODY;
goto body;
}
goto finished;
default:
- adios (NULL, "getfld() returned %d", state);
+ adios(NULL, "getfld() returned %d", state);
}
}
dat[2] = size;
else if (outnum > 0) {
dat[2] = ftell(scnout);
- if (dat[2] == EOF) DIEWRERR();
+ if (dat[2] == EOF)
+ DIEWRERR();
}
if ((datecomp && !datecomp->c_text) || (!size && !outnum)) {
struct stat st;
- fstat (fileno(inb), &st);
+ fstat(fileno(inb), &st);
if (!size && !outnum)
dat[2] = st.st_size;
if (datecomp) {
if (! datecomp->c_text) {
if (datecomp->c_tws == NULL)
- datecomp->c_tws = (struct tws *)
- calloc((size_t) 1, sizeof(*datecomp->c_tws));
+ datecomp->c_tws = (struct tws *) calloc((size_t) 1, sizeof(*datecomp->c_tws));
if (datecomp->c_tws == NULL)
- adios (NULL, "unable to allocate tws buffer");
- *datecomp->c_tws = *dlocaltime ((time_t *) &st.st_mtime);
+ adios(NULL, "unable to allocate tws buffer");
+ *datecomp->c_tws = *dlocaltime((time_t *) &st.st_mtime);
datecomp->c_flags |= CF_DATEFAB|CF_TRUE;
} else {
datecomp->c_flags &= ~CF_DATEFAB;
}
}
- fmt_scan (fmt, scanl, slwidth, dat);
+ fmt_scan(fmt, scanl, slwidth, dat);
#if 0
- fmt = fmt_scan (fmt, scanl, slwidth, dat);
+ fmt = fmt_scan(fmt, scanl, slwidth, dat);
if (!fmt)
fmt = fmt_top; /* reset for old format files */
#endif
bodycomp->c_text = saved_c_text;
if (noisy)
- fputs (scanl, stdout);
+ fputs(scanl, stdout);
- FINDCOMP (cptr, "encrypted");
+ FINDCOMP(cptr, "encrypted");
encrypted = cptr && cptr->c_text;
/* return dynamically allocated buffers to pool */
}
*--nxtbuf = tmpbuf;
- if (outnum && (ferror(scnout) || fclose (scnout) == EOF))
+ if (outnum && (ferror(scnout) || fclose(scnout) == EOF))
DIEWRERR();
return (state != FILEEOF ? SCNERR : encrypted ? SCNENC : SCNMSG);
char c;
while ((c = *s++))
- if (putc (c,stream) == EOF )
+ if (putc(c,stream) == EOF )
return(EOF);
return (0);
}
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int msgp = 0, distsw = 0, vecp = 1;
int mime = 0;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
vec[vecp++] = "-library";
- vec[vecp++] = getcpy (m_maildir (""));
+ vec[vecp++] = getcpy(m_maildir(""));
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown\n", cp);
+ adios(NULL, "-%s unknown\n", cp);
case HELPSW:
- snprintf (buf, sizeof(buf),
+ snprintf(buf, sizeof(buf),
"%s [file] [switches]",
invo_name);
- print_help (buf, switches, 1);
- done (1);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case PUSHSW:
pushsw++;
case PORTSW:
vec[vecp++] = --cp;
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
vec[vecp++] = cp;
continue;
case ATTACHSW:
- if (!(attach = *argp++) || *attach == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ if (!(attach = *argp++) ||
+ *attach == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case ATTACHFORMATSW:
if (! *argp || **argp == '-')
- adios (NULL, "missing argument to %s", argp[-1]);
+ adios(NULL, "missing argument to %s", argp[-1]);
else {
- attachformat = atoi (*argp);
+ attachformat = atoi(*argp);
if (attachformat < 0 ||
attachformat > ATTACHFORMATS - 1) {
- advise (NULL, "unsupported attachformat %d",
+ advise(NULL, "unsupported attachformat %d",
attachformat);
continue;
}
/*
** check for "Aliasfile:" profile entry
*/
- if ((cp = context_find ("Aliasfile"))) {
+ if ((cp = context_find("Aliasfile"))) {
char *dp = NULL;
for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap;
}
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (!msgp)
msgs[msgp++] = "cur";
- maildir = m_maildir (draftfolder);
+ maildir = m_maildir(draftfolder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (draftfolder)))
- adios (NULL, "unable to read draft folder %s", draftfolder);
+ if (!(mp = folder_read(draftfolder)))
+ adios(NULL, "unable to read draft folder %s", draftfolder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in draft folder %s", draftfolder);
+ adios(NULL, "no messages in draft folder %s", draftfolder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgp; msgnum++)
- if (!m_convert (mp, msgs[msgnum]))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
+ if (!m_convert(mp, msgs[msgnum]))
+ done(1);
+ seq_setprev(mp); /* set the previous-sequence */
for (msgp = 0, msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
- if (is_selected (mp, msgnum)) {
- msgs[msgp++] = getcpy (m_name (msgnum));
- unset_exists (mp, msgnum);
+ if (is_selected(mp, msgnum)) {
+ msgs[msgp++] = getcpy(m_name(msgnum));
+ unset_exists(mp, msgnum);
}
}
mp->msgflags |= SEQMOD;
- seq_save (mp);
+ seq_save(mp);
- if ((cp = getenv ("SIGNATURE")) == NULL || *cp == 0)
- if ((cp = context_find ("signature")) && *cp)
- m_putenv ("SIGNATURE", cp);
+ if ((cp = getenv("SIGNATURE")) == NULL || *cp == 0)
+ if ((cp = context_find("signature")) && *cp)
+ m_putenv("SIGNATURE", cp);
#ifdef UCI
else {
- snprintf (buf, sizeof(buf), "%s/.signature", mypath);
- if ((fp = fopen (buf, "r")) != NULL &&
+ snprintf(buf, sizeof(buf), "%s/.signature", mypath);
+ if ((fp = fopen(buf, "r")) != NULL &&
fgets(buf, sizeof buf, fp) != NULL) {
- fclose (fp);
- if (cp = strchr (buf, '\n'))
+ fclose(fp);
+ if (cp = strchr(buf, '\n'))
*cp = 0;
- m_putenv ("SIGNATURE", buf);
+ m_putenv("SIGNATURE", buf);
}
}
#endif /* UCI */
for (msgnum = 0; msgnum < msgp; msgnum++)
- if (stat (msgs[msgnum], &st) == NOTOK)
- adios (msgs[msgnum], "unable to stat draft file");
+ if (stat(msgs[msgnum], &st) == NOTOK)
+ adios(msgs[msgnum], "unable to stat draft file");
- if ((annotext = getenv ("mhannotate")) == NULL || *annotext == 0)
+ if ((annotext = getenv("mhannotate")) == NULL || *annotext == 0)
annotext = NULL;
- if (annotext && ((cp = getenv ("mhinplace")) != NULL && *cp != 0))
- inplace = atoi (cp);
- if ((altmsg = getenv ("mhaltmsg")) == NULL || *altmsg == 0)
+ if (annotext && ((cp = getenv("mhinplace")) != NULL && *cp != 0))
+ inplace = atoi(cp);
+ if ((altmsg = getenv("mhaltmsg")) == NULL || *altmsg == 0)
altmsg = NULL; /* used by dist interface - see below */
- if ((cp = getenv ("mhdist"))
- && *cp
- && (distsw = atoi (cp))
- && altmsg) {
+ if ((cp = getenv("mhdist")) && *cp && (distsw = atoi (cp)) && altmsg) {
vec[vecp++] = "-dist";
- distfile = getcpy (m_mktemp2 (altmsg, invo_name, NULL, NULL));
- if (link (altmsg, distfile) == NOTOK) {
+ distfile = getcpy(m_mktemp2(altmsg, invo_name, NULL, NULL));
+ if (link(altmsg, distfile) == NOTOK) {
if (errno != EXDEV
#ifdef EISREMOTE
&& errno != EISREMOTE
#endif /* EISREMOTE */
)
- adios (distfile, "unable to link %s to",
+ adios(distfile, "unable to link %s to",
altmsg);
- free (distfile);
- distfile = getcpy (m_mktemp2(NULL, invo_name,
+ free(distfile);
+ distfile = getcpy(m_mktemp2(NULL, invo_name,
NULL, NULL));
{
int in, out;
struct stat st;
- if ((in = open (altmsg, O_RDONLY)) == NOTOK)
- adios (altmsg, "unable to open");
+ if ((in = open(altmsg, O_RDONLY)) == NOTOK)
+ adios(altmsg, "unable to open");
fstat(in, &st);
- if ((out = creat (distfile,
+ if ((out = creat(distfile,
(int) st.st_mode & 0777))
== NOTOK)
- adios (distfile, "unable to write");
- cpydata (in, out, altmsg, distfile);
- close (in);
- close (out);
+ adios(distfile, "unable to write");
+ cpydata(in, out, altmsg, distfile);
+ close(in);
+ close(out);
}
}
} else {
distfile = NULL;
}
- if (altmsg == NULL || stat (altmsg, &st) == NOTOK) {
+ if (altmsg == NULL || stat(altmsg, &st) == NOTOK) {
st.st_mtime = 0;
st.st_dev = 0;
st.st_ino = 0;
}
if (pushsw)
- push ();
+ push();
status = 0;
- vec[0] = r1bindex (postproc, '/');
- closefds (3);
+ vec[0] = r1bindex(postproc, '/');
+ closefds(3);
for (msgnum = 0; msgnum < msgp; msgnum++) {
- switch (sendsbr (vec, vecp, msgs[msgnum], &st, 1, attach,
+ switch (sendsbr(vec, vecp, msgs[msgnum], &st, 1, attach,
attachformat)) {
case DONE:
- done (++status);
+ done(++status);
case NOTOK:
status++; /* fall */
case OK:
}
}
- context_save (); /* save the context file */
- done (status);
+ context_save(); /* save the context file */
+ done(status);
return 1;
}
/*
** external prototypes
*/
-int sendsbr (char **, int, char *, struct stat *, int, char *, int);
-char *getusername (void);
+int sendsbr(char **, int, char *, struct stat *, int, char *, int);
+char *getusername(void);
/*
** static prototypes
*/
-static void armed_done (int) NORETURN;
-static void alert (char *, int);
-static int tmp_fd (void);
-static void anno (int, struct stat *);
-static void annoaux (int);
-static int sendaux (char **, int, char *, struct stat *);
+static void armed_done(int) NORETURN;
+static void alert(char *, int);
+static int tmp_fd(void);
+static void anno(int, struct stat *);
+static void annoaux(int);
+static int sendaux(char **, int, char *, struct stat *);
static int attach(char *, char *, int);
static void clean_up_temporary_files(void);
*/
int
-sendsbr (char **vec, int vecp, char *drft, struct stat *st,
+sendsbr(char **vec, int vecp, char *drft, struct stat *st,
int rename_drft, char *attachment_header_field_name, int attachformat)
{
int status;
}
done=armed_done;
- switch (setjmp (env)) {
+ switch (setjmp(env)) {
case OK:
/*
** If given -push and -unique (which is undocumented), then
if (pushsw && unique) {
char *cp = m_mktemp2(drft, invo_name, NULL, NULL);
if (cp == NULL) {
- adios ("sendsbr", "unable to create temporary file");
+ adios("sendsbr", "unable to create temporary file");
}
- if (rename (drft, strncpy(file, cp, sizeof(file)))
+ if (rename(drft, strncpy(file, cp, sizeof(file)))
== NOTOK)
- adios (file, "unable to rename %s to", drft);
+ adios(file, "unable to rename %s to", drft);
drft = file;
}
- status = sendaux (vec, vecp, drft, st) ? NOTOK : OK;
+ status = sendaux(vec, vecp, drft, st) ? NOTOK : OK;
/* rename the original draft */
if (rename_drft && status == OK &&
- rename (original_draft, strncpy (buffer, m_backup (original_draft), sizeof(buffer))) == NOTOK)
- advise (buffer, "unable to rename %s to", drft);
+ rename(original_draft, strncpy(buffer,
+ m_backup(original_draft), sizeof(buffer)))
+ == NOTOK)
+ advise(buffer, "unable to rename %s to", drft);
break;
default:
done=exit;
if (distfile)
- unlink (distfile);
+ unlink(distfile);
/*
** Get rid of any temporary files that we created for attachments.
break;
case 1:
- if (stringdex (m_maildir(invo_name), file_name) == 0) {
+ 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);
+ fprintf(composition_file, "#%s <>", content_type);
} else {
/*
** Suppress Content-Id, insert simple
** Content-Disposition.
*/
- (void) fprintf (composition_file,
+ fprintf(composition_file,
"#%s; name=\"%s\" <>{attachment}",
content_type,
((p = strrchr(file_name, '/')) == (char *)0) ?
break;
case 2:
- if (stringdex (m_maildir(invo_name), file_name) == 0) {
+ 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);
+ fprintf(composition_file, "#%s <>", content_type);
} else {
/*
** Suppress Content-Id, insert Content-Disposition
** with modification date.
*/
- (void) fprintf (composition_file,
+ fprintf(composition_file,
"#%s; name=\"%s\" <>{attachment; modification-date=\"%s\"}",
content_type,
((p = strrchr(file_name, '/')) == (char *)0) ?
- file_name : p + 1, dtime (&st.st_mtime, 0));
+ file_name : p + 1, dtime(&st.st_mtime, 0));
}
break;
default:
- adios ((char *)0, "unsupported attachformat %d", attachformat);
+ adios((char *)0, "unsupported attachformat %d", attachformat);
}
/*
*/
static int
-sendaux (char **vec, int vecp, char *drft, struct stat *st)
+sendaux(char **vec, int vecp, char *drft, struct stat *st)
{
pid_t child_id;
int i, status, fd, fd2;
char backup[BUFSIZ], buf[BUFSIZ];
- fd = pushsw ? tmp_fd () : NOTOK;
+ fd = pushsw ? tmp_fd() : NOTOK;
fd2 = NOTOK;
vec[vecp++] = drft;
if (annotext) {
- if ((fd2 = tmp_fd ()) != NOTOK) {
+ if ((fd2 = tmp_fd()) != NOTOK) {
vec[vecp++] = "-idanno";
- snprintf (buf, sizeof(buf), "%d", fd2);
+ snprintf(buf, sizeof(buf), "%d", fd2);
vec[vecp++] = buf;
} else {
- admonish (NULL, "unable to create file for annotation list");
+ admonish(NULL, "unable to create file for annotation list");
}
}
- if (distfile && distout (drft, distfile, backup) == NOTOK)
- done (1);
+ if (distfile && distout(drft, distfile, backup) == NOTOK)
+ done(1);
vec[vecp] = NULL;
for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case -1:
/* oops -- fork error */
- adios ("fork", "unable to");
+ adios("fork", "unable to");
break; /* NOT REACHED */
case 0:
** file, so capture anything on stdout and stderr there.
*/
if (fd != NOTOK) {
- dup2 (fd, fileno (stdout));
- dup2 (fd, fileno (stderr));
- close (fd);
+ dup2(fd, fileno(stdout));
+ dup2(fd, fileno(stderr));
+ close(fd);
}
- execvp (postproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (postproc);
- _exit (-1);
+ execvp(postproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(postproc);
+ _exit(-1);
break; /* NOT REACHED */
default:
*/
if ((status = pidwait(child_id, NOTOK)) == OK) {
if (annotext && fd2 != NOTOK)
- anno (fd2, st);
+ anno(fd2, st);
} else {
/*
** If postproc failed, and we have good fd (which
** (and possibly the draft) back to the user.
*/
if (fd != NOTOK) {
- alert (drft, fd);
- close (fd);
+ alert(drft, fd);
+ close(fd);
} else {
- advise (NULL, "message not delivered to anyone");
+ advise(NULL, "message not delivered to anyone");
}
if (annotext && fd2 != NOTOK)
- close (fd2);
+ close(fd2);
if (distfile) {
- unlink (drft);
- if (rename (backup, drft) == NOTOK)
- advise (drft, "unable to rename %s to",
+ unlink(drft);
+ if (rename(backup, drft) == NOTOK)
+ advise(drft, "unable to rename %s to",
backup);
}
}
*/
static void
-alert (char *file, int out)
+alert(char *file, int out)
{
pid_t child_id;
int i, in;
char buf[BUFSIZ];
for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case NOTOK:
/* oops -- fork error */
- advise ("fork", "unable to");
+ advise("fork", "unable to");
case OK:
/* child process -- send it */
- SIGNAL (SIGHUP, SIG_IGN);
- SIGNAL (SIGINT, SIG_IGN);
- SIGNAL (SIGQUIT, SIG_IGN);
- SIGNAL (SIGTERM, SIG_IGN);
+ SIGNAL(SIGHUP, SIG_IGN);
+ SIGNAL(SIGINT, SIG_IGN);
+ SIGNAL(SIGQUIT, SIG_IGN);
+ SIGNAL(SIGTERM, SIG_IGN);
if (forwsw) {
- if ((in = open (file, O_RDONLY)) == NOTOK) {
- admonish (file, "unable to re-open");
+ if ((in = open(file, O_RDONLY)) == NOTOK) {
+ admonish(file, "unable to re-open");
} else {
- lseek (out, (off_t) 0, SEEK_END);
- strncpy (buf, "\nMessage not delivered to anyone.\n", sizeof(buf));
- write (out, buf, strlen (buf));
- strncpy (buf, "\n------- Unsent Draft\n\n", sizeof(buf));
- write (out, buf, strlen (buf));
- cpydgst (in, out, file, "temporary file");
- close (in);
- strncpy (buf, "\n------- End of Unsent Draft\n", sizeof(buf));
- write (out, buf, strlen (buf));
- if (rename (file, strncpy (buf, m_backup (file), sizeof(buf))) == NOTOK)
- admonish (buf, "unable to rename %s to", file);
+ lseek(out, (off_t) 0, SEEK_END);
+ strncpy(buf, "\nMessage not delivered to anyone.\n", sizeof(buf));
+ write(out, buf, strlen(buf));
+ strncpy(buf, "\n------- Unsent Draft\n\n", sizeof(buf));
+ write(out, buf, strlen(buf));
+ cpydgst(in, out, file, "temporary file");
+ close(in);
+ strncpy(buf, "\n------- End of Unsent Draft\n", sizeof(buf));
+ write(out, buf, strlen(buf));
+ if (rename(file, strncpy(buf, m_backup(file), sizeof(buf))) == NOTOK)
+ admonish(buf, "unable to rename %s to", file);
}
}
- lseek (out, (off_t) 0, SEEK_SET);
- dup2 (out, fileno (stdin));
- close (out);
+ lseek(out, (off_t) 0, SEEK_SET);
+ dup2(out, fileno(stdin));
+ close(out);
/* create subject for error notification */
- snprintf (buf, sizeof(buf), "send failed on %s",
- forwsw ?
- "enclosed draft" : file);
+ snprintf(buf, sizeof(buf), "send failed on %s",
+ forwsw ? "enclosed draft" : file);
- execlp (mailproc, r1bindex (mailproc, '/'),
- getusername (),
- "-subject", buf, NULL);
- fprintf (stderr, "unable to exec ");
- perror (mailproc);
- _exit (-1);
+ execlp(mailproc, r1bindex(mailproc, '/'),
+ getusername(), "-subject", buf, NULL);
+ fprintf(stderr, "unable to exec ");
+ perror(mailproc);
+ _exit(-1);
default: /* no waiting... */
break;
static int
-tmp_fd (void)
+tmp_fd(void)
{
int fd;
char *tfile = NULL;
fchmod(fd, 0600);
if (debugsw)
- advise (NULL, "temporary file %s selected", tfile);
+ advise(NULL, "temporary file %s selected", tfile);
else
- if (unlink (tfile) == NOTOK)
- advise (tfile, "unable to remove");
+ if (unlink(tfile) == NOTOK)
+ advise(tfile, "unable to remove");
return fd;
}
static void
-anno (int fd, struct stat *st)
+anno(int fd, struct stat *st)
{
pid_t child_id;
sigset_t set, oset;
static char *cwd = NULL;
struct stat st2;
- if (altmsg &&
- (stat (altmsg, &st2) == NOTOK
- || st->st_mtime != st2.st_mtime
- || st->st_dev != st2.st_dev
- || st->st_ino != st2.st_ino)) {
+ if (altmsg && (stat(altmsg, &st2) == NOTOK ||
+ st->st_mtime != st2.st_mtime ||
+ st->st_dev != st2.st_dev ||
+ st->st_ino != st2.st_ino)) {
if (debugsw)
- admonish (NULL, "$mhaltmsg mismatch");
+ admonish(NULL, "$mhaltmsg mismatch");
return;
}
- child_id = debugsw ? NOTOK : fork ();
+ child_id = debugsw ? NOTOK : fork();
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 ());
+ cwd = getcpy(pwd());
case OK:
/* block a few signals */
- sigemptyset (&set);
- sigaddset (&set, SIGHUP);
- sigaddset (&set, SIGINT);
- sigaddset (&set, SIGQUIT);
- sigaddset (&set, SIGTERM);
- SIGPROCMASK (SIG_BLOCK, &set, &oset);
-
- annoaux (fd);
+ sigemptyset(&set);
+ sigaddset(&set, SIGHUP);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGQUIT);
+ sigaddset(&set, SIGTERM);
+ SIGPROCMASK(SIG_BLOCK, &set, &oset);
+
+ annoaux(fd);
if (child_id == OK)
- _exit (0);
+ _exit(0);
/* reset the signal mask */
- SIGPROCMASK (SIG_SETMASK, &oset, &set);
+ SIGPROCMASK(SIG_SETMASK, &oset, &set);
- chdir (cwd);
+ chdir(cwd);
break;
default: /* no waiting... */
- close (fd);
+ close(fd);
break;
}
}
static void
-annoaux (int fd)
+annoaux(int fd)
{
int fd2, fd3, msgnum;
char *cp, *folder, *maildir;
FILE *fp;
struct msgs *mp;
- if ((folder = getenv ("mhfolder")) == NULL || *folder == 0) {
+ if ((folder = getenv("mhfolder")) == NULL || *folder == 0) {
if (debugsw)
- admonish (NULL, "$mhfolder not set");
+ admonish(NULL, "$mhfolder not set");
return;
}
- maildir = m_maildir (folder);
- if (chdir (maildir) == NOTOK) {
+ maildir = m_maildir(folder);
+ if (chdir(maildir) == NOTOK) {
if (debugsw)
- admonish (maildir, "unable to change directory to");
+ admonish(maildir, "unable to change directory to");
return;
}
- if (!(mp = folder_read (folder))) {
+ if (!(mp = folder_read(folder))) {
if (debugsw)
- admonish (NULL, "unable to read folder %s", folder);
+ admonish(NULL, "unable to read folder %s", folder);
return;
}
/* check for empty folder */
if (mp->nummsg == 0) {
if (debugsw)
- admonish (NULL, "no messages in %s", folder);
+ admonish(NULL, "no messages in %s", folder);
goto oops;
}
- if ((cp = getenv ("mhmessages")) == NULL || *cp == 0) {
+ if ((cp = getenv("mhmessages")) == NULL || *cp == 0) {
if (debugsw)
- admonish (NULL, "$mhmessages not set");
+ admonish(NULL, "$mhmessages not set");
goto oops;
}
if (!debugsw /* MOBY HACK... */
&& pushsw
- && (fd3 = open ("/dev/null", O_RDWR)) != NOTOK
- && (fd2 = dup (fileno (stderr))) != NOTOK) {
- dup2 (fd3, fileno (stderr));
- close (fd3);
+ && (fd3 = open("/dev/null", O_RDWR)) != NOTOK
+ && (fd2 = dup(fileno(stderr))) != NOTOK) {
+ dup2(fd3, fileno(stderr));
+ close(fd3);
}
else
fd2 = NOTOK;
- for (ap = brkstring (cp = getcpy (cp), " ", NULL); *ap; ap++)
- m_convert (mp, *ap);
- free (cp);
+ for (ap = brkstring(cp = getcpy(cp), " ", NULL); *ap; ap++)
+ m_convert(mp, *ap);
+ free(cp);
if (fd2 != NOTOK)
- dup2 (fd2, fileno (stderr));
+ dup2(fd2, fileno(stderr));
if (mp->numsel == 0) {
if (debugsw)
- admonish (NULL, "no messages to annotate");
+ admonish(NULL, "no messages to annotate");
goto oops;
}
- lseek (fd, (off_t) 0, SEEK_SET);
- if ((fp = fdopen (fd, "r")) == NULL) {
+ lseek(fd, (off_t) 0, SEEK_SET);
+ if ((fp = fdopen(fd, "r")) == NULL) {
if (debugsw)
- admonish (NULL, "unable to fdopen annotation list");
+ admonish(NULL, "unable to fdopen annotation list");
goto oops;
}
cp = NULL;
- while (fgets (buffer, sizeof(buffer), fp) != NULL)
- cp = add (buffer, cp);
- fclose (fp);
+ while (fgets(buffer, sizeof(buffer), fp) != NULL)
+ cp = add(buffer, cp);
+ fclose(fp);
if (debugsw)
- advise (NULL, "annotate%s with %s: \"%s\"",
+ advise(NULL, "annotate%s with %s: \"%s\"",
inplace ? " inplace" : "", annotext, cp);
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
if (debugsw)
- advise (NULL, "annotate message %d", msgnum);
- annotate (m_name (msgnum), annotext, cp, inplace, 1, -2, 0);
+ advise(NULL, "annotate message %d", msgnum);
+ annotate(m_name (msgnum), annotext, cp, inplace,
+ 1, -2, 0);
}
}
- free (cp);
+ free(cp);
oops:
- folder_free (mp); /* free folder/message structure */
+ folder_free(mp); /* free folder/message structure */
}
static void
-armed_done (int status)
+armed_done(int status)
{
- longjmp (env, status ? status : NOTOK);
+ longjmp(env, status ? status : NOTOK);
- exit (status);
+ exit(status);
}
static int is_nontext(char *);
/* prototype from mhlsbr.c */
-int mhl (int, char **);
+int mhl(int, char **);
#define SHOW 0
#define NEXT 1
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int headersw = 1, msgp = 0;
int nshow = 0, checkmime = 1, mime;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- if (!mh_strcasecmp (invo_name, "next")) {
+ if (!mh_strcasecmp(invo_name, "next")) {
mode = NEXT;
- } else if (!mh_strcasecmp (invo_name, "prev")) {
+ } else if (!mh_strcasecmp(invo_name, "prev")) {
mode = PREV;
}
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
case NPROGSW:
vec[vecp++] = --cp;
continue;
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] %s[switches] [switches for showproc]", invo_name, mode == SHOW ? "[msgs] ": "");
- print_help (buf, switches, 1);
- done (1);
+ 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:
print_version(invo_name);
- done (1);
+ done(1);
case FILESW:
if (mode != SHOW)
usage:
- adios (NULL, "usage: %s [+folder] [switches] [switches for showproc]", invo_name);
+ adios(NULL, "usage: %s [+folder] [switches] [switches for showproc]", invo_name);
if (file)
- adios (NULL, "only one file at a time!");
+ adios(NULL, "only one file at a time!");
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- file = path (cp, TFILE);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ file = path(cp, TFILE);
continue;
case HEADSW:
case FORMSW:
vec[vecp++] = --cp;
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- vec[vecp++] = getcpy (etcpath(cp));
+ adios(NULL, "missing argument to %s", argp[-2]);
+ vec[vecp++] = getcpy(etcpath(cp));
continue;
case PROGSW:
case WIDTHSW:
vec[vecp++] = --cp;
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
vec[vecp++] = cp;
continue;
case SHOWSW:
if (!(showproc = *argp++) || *showproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
nshow = 0;
continue;
case NSHOWSW:
case SHOWMIMESW:
if (!(showmimeproc = *argp++) || *showmimeproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
nshow = 0;
continue;
case CHECKMIMESW:
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else if (mode != SHOW) {
goto usage;
} else {
}
procp = vecp;
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (file) {
if (msgp)
- adios (NULL, "only one file at a time!");
+ adios(NULL, "only one file at a time!");
vec[vecp++] = file;
goto go_to_it;
}
#ifdef WHATNOW
if (!msgp && !folder && mode == SHOW &&
- (cp = getenv ("mhdraft")) && *cp) {
+ (cp = getenv("mhdraft")) && *cp) {
vec[vecp++] = cp;
goto go_to_it;
}
}
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgp; msgnum++)
- if (!m_convert (mp, msgs[msgnum]))
- done (1);
+ if (!m_convert(mp, msgs[msgnum]))
+ done(1);
/*
** Set the SELECT_UNSEEN bit for all the SELECTED messages,
*/
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
if (is_selected(mp, msgnum))
- set_unseen (mp, msgnum);
+ set_unseen(mp, msgnum);
- seq_setprev (mp); /* set the Previous-Sequence */
- seq_setunseen (mp, 1); /* unset the Unseen-Sequence */
+ seq_setprev(mp); /* set the Previous-Sequence */
+ seq_setunseen(mp, 1); /* unset the Unseen-Sequence */
if (mp->numsel > MAXARGS - 2)
- adios (NULL, "more than %d messages for show exec",
+ adios(NULL, "more than %d messages for show exec",
MAXARGS - 2);
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
if (is_selected(mp, msgnum))
- vec[vecp++] = getcpy (m_name (msgnum));
+ vec[vecp++] = getcpy(m_name(msgnum));
- seq_setcur (mp, mp->hghsel); /* update current message */
- seq_save (mp); /* synchronize sequences */
- context_replace (pfolder, folder); /* update current folder */
- context_save (); /* save the context file */
+ seq_setcur(mp, mp->hghsel); /* update current message */
+ seq_save(mp); /* synchronize sequences */
+ context_replace(pfolder, folder); /* update current folder */
+ context_save(); /* save the context file */
if (headersw && vecp == 2)
- printf ("(Message %s:%s)\n", folder, vec[1]);
+ printf("(Message %s:%s)\n", folder, vec[1]);
go_to_it: ;
- fflush (stdout);
+ fflush(stdout);
vec[vecp] = NULL;
proc = catproc;
} else {
/* check if any messages are non-text MIME messages */
- if (checkmime && !getenv ("NOMHNPROC")) {
+ if (checkmime && !getenv("NOMHNPROC")) {
if (!file) {
/*
** loop through selected messages
for (msgnum = mp->lowsel;
msgnum <= mp->hghsel;
msgnum++)
- if (is_selected (mp, msgnum) && is_nontext (m_name (msgnum))) {
+ if (is_selected(mp, msgnum) && is_nontext(m_name(msgnum))) {
mime = 1;
break;
}
} else {
/* check the file for MIME */
- if (is_nontext (vec[vecp - 1]))
+ if (is_nontext(vec[vecp - 1]))
mime = 1;
}
}
}
if (folder && !file)
- m_putenv ("mhfolder", folder);
+ m_putenv("mhfolder", folder);
/*
** For backward compatibility, if the "proc" is mhn,
** then add "-show" option. Add "-file" if showing
** file.
*/
- if (strcmp (r1bindex (proc, '/'), "mhn") == 0) {
+ if (strcmp(r1bindex(proc, '/'), "mhn") == 0) {
if (file) {
vec[vecp] = vec[vecp - 1];
vec[vecp - 1] = "-file";
}
/* If the "proc" is "mhshow", add "-file" if showing file. */
- if (strcmp (r1bindex (proc, '/'), "mhshow") == 0 && file ) {
+ if (strcmp(r1bindex(proc, '/'), "mhshow") == 0 && file ) {
vec[vecp] = vec[vecp - 1];
vec[vecp - 1] = "-file";
vec[++vecp] = NULL;
** If "proc" is mhl, then run it internally
** rather than exec'ing it.
*/
- if (strcmp (r1bindex (proc, '/'), "mhl") == 0) {
+ if (strcmp(r1bindex(proc, '/'), "mhl") == 0) {
vec[0] = "mhl";
- mhl (vecp, vec);
- done (0);
+ mhl(vecp, vec);
+ done(0);
}
/*
** 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")
+ if (!strcmp(r1bindex(proc, '/'), "mhl")
&& !file
- && chdir (maildir =
- concat (m_maildir (""), "/", NULL)) != NOTOK) {
- mp->foldpath = concat (mp->foldpath, "/", NULL);
- cp = ssequal (maildir, mp->foldpath)
- ? mp->foldpath + strlen (maildir)
+ && chdir(maildir =
+ concat(m_maildir(""), "/", NULL)) != NOTOK) {
+ mp->foldpath = concat(mp->foldpath, "/", NULL);
+ cp = ssequal(maildir, mp->foldpath)
+ ? mp->foldpath + strlen(maildir)
: mp->foldpath;
for (msgnum = procp; msgnum < vecp; msgnum++)
- vec[msgnum] = concat (cp, vec[msgnum], NULL);
+ vec[msgnum] = concat(cp, vec[msgnum], NULL);
}
- vec[0] = r1bindex (proc, '/');
- execvp (proc, vec);
- adios (proc, "unable to exec");
+ vec[0] = r1bindex(proc, '/');
+ execvp(proc, vec);
+ adios(proc, "unable to exec");
return 0; /* dead code to satisfy the compiler */
}
** Check if a message or file contains any non-text parts
*/
static int
-is_nontext (char *msgnam)
+is_nontext(char *msgnam)
{
int result, state;
unsigned char *bp, *dp;
char buf[BUFSIZ], name[NAMESZ];
FILE *fp;
- if ((fp = fopen (msgnam, "r")) == NULL)
+ if ((fp = fopen(msgnam, "r")) == NULL)
return 0;
for (state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ switch (state = m_getfld(state, name, buf, sizeof(buf), fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
/*
** Check Content-Type field
*/
- if (!mh_strcasecmp (name, TYPE_FIELD)) {
+ if (!mh_strcasecmp(name, TYPE_FIELD)) {
int passno;
char c;
- cp = add (buf, NULL);
+ cp = add(buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf,
+ state = m_getfld(state, name, buf,
sizeof(buf), fp);
- cp = add (buf, cp);
+ cp = add(buf, cp);
}
bp = cp;
passno = 1;
again:
- for (; isspace (*bp); bp++)
+ for (; isspace(*bp); bp++)
continue;
if (*bp == '(') {
int i;
passno = 3;
goto again;
}
- for (dp = bp; istoken (*dp); dp++)
+ for (dp = bp; istoken(*dp); dp++)
continue;
c = *dp;
*dp = '\0';
if (!*bp)
goto invalid;
if (passno > 1) {
- if ((result = (mh_strcasecmp (bp,
+ if ((result = (mh_strcasecmp(bp,
"plain") != 0)))
goto out;
*dp = c;
- for (dp++; isspace (*dp); dp++)
+ for (dp++; isspace(*dp); dp++)
continue;
if (*dp) {
- if ((result = !uprf (dp,
+ if ((result = !uprf(dp,
"charset")))
goto out;
dp += sizeof("charset") - 1;
- while (isspace (*dp))
+ while (isspace(*dp))
dp++;
if (*dp++ != '=')
goto invalid;
- while (isspace (*dp))
+ while (isspace(*dp))
dp++;
if (*dp == '"') {
if ((bp = strchr(++dp, '"')))
*bp = '\0';
} else {
for (bp = dp; *bp; bp++)
- if (!istoken (*bp)) {
+ if (!istoken(*bp)) {
*bp = '\0';
break;
}
dp = "US-ASCII";
}
/* Check the character set */
- result = !check_charset (dp, strlen (dp));
+ result = !check_charset(dp, strlen(dp));
} else {
- if (!(result = (mh_strcasecmp (bp, "text") != 0))) {
+ if (!(result = (mh_strcasecmp(bp, "text") != 0))) {
*dp = c;
bp = dp;
passno = 2;
}
}
out:
- free (cp);
+ free(cp);
if (result) {
- fclose (fp);
+ fclose(fp);
return result;
}
break;
/*
** Check Content-Transfer-Encoding field
*/
- if (!mh_strcasecmp (name, ENCODING_FIELD)) {
- cp = add (buf, NULL);
+ if (!mh_strcasecmp(name, ENCODING_FIELD)) {
+ cp = add(buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
- cp = add (buf, cp);
+ state = m_getfld(state, name, buf,
+ sizeof(buf), fp);
+ cp = add(buf, cp);
}
- for (bp = cp; isspace (*bp); bp++)
+ for (bp = cp; isspace(*bp); bp++)
continue;
- for (dp = bp; istoken (*dp); dp++)
+ for (dp = bp; istoken(*dp); dp++)
continue;
*dp = '\0';
- result = (mh_strcasecmp (bp, "7bit")
- && mh_strcasecmp (bp, "8bit")
- && mh_strcasecmp (bp, "binary"));
+ result = (mh_strcasecmp(bp, "7bit")
+ && mh_strcasecmp(bp, "8bit")
+ && mh_strcasecmp(bp, "binary"));
- free (cp);
+ free(cp);
if (result) {
- fclose (fp);
+ fclose(fp);
return result;
}
break;
** so message is just text.
*/
default:
- fclose (fp);
+ fclose(fp);
return 0;
}
}
/*
** static prototypes
*/
-static int localmail (int, char *);
-static int usr_delivery (int, char *, int);
-static int split (char *, char **);
-static int parse (int);
-static void expand (char *, char *, int);
-static void glob (int);
-static struct pair *lookup (struct pair *, char *);
-static int logged_in (void);
-static int timely (char *, char *);
-static int usr_file (int, char *, int);
-static int usr_pipe (int, char *, char *, char **, int);
-static int usr_folder (int, char *);
-static RETSIGTYPE alrmser (int);
-static void get_sender (char *, char **);
-static int copy_message (int, char *, int);
-static void verbose_printf (char *fmt, ...);
-static void adorn (char *, char *, ...);
-static void debug_printf (char *fmt, ...);
-static int suppress_duplicates (int, char *);
-static char *trim (char *);
+static int localmail(int, char *);
+static int usr_delivery(int, char *, int);
+static int split(char *, char **);
+static int parse(int);
+static void expand(char *, char *, int);
+static void glob(int);
+static struct pair *lookup(struct pair *, char *);
+static int logged_in(void);
+static int timely(char *, char *);
+static int usr_file(int, char *, int);
+static int usr_pipe(int, char *, char *, char **, int);
+static int usr_folder(int, char *);
+static RETSIGTYPE alrmser(int);
+static void get_sender(char *, char **);
+static int copy_message(int, char *, int);
+static void verbose_printf(char *fmt, ...);
+static void adorn(char *, char *, ...);
+static void debug_printf(char *fmt, ...);
+static int suppress_duplicates(int, char *);
+static char *trim(char *);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int fd, status;
FILE *fp = stdin;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (*argv, '/');
+ invo_name = r1bindex(*argv, '/');
/* foil search of user profile/context */
- if (context_foil (NULL) == -1)
- done (1);
+ if (context_foil(NULL) == -1)
+ done(1);
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 0);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 0);
argp = arguments;
/* Parse arguments */
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf),
- "%s [switches] [address info sender]", invo_name);
- print_help (buf, switches, 0);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches] [address info sender]", invo_name);
+ print_help(buf, switches, 0);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case ADDRSW:
if (!(addr = *argp++))
/* allow -xyz arguments */
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case INFOSW:
if (!(info = *argp++))
/* allow -xyz arguments */
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case USERSW:
if (!(user = *argp++))
/* allow -xyz arguments */
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case FILESW:
if (!(file = *argp++) || *file == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case SENDERSW:
if (!(sender = *argp++))
/* allow -xyz arguments */
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case MAILBOXSW:
if (!(mbox = *argp++) || *mbox == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case HOMESW:
if (!(home = *argp++) || *home == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case MAILSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
if (mdlvr)
- adios (NULL, "only one maildelivery file at a time!");
+ adios(NULL, "only one maildelivery file at a time!");
mdlvr = cp;
continue;
}
if (addr == NULL)
- addr = getusername ();
+ addr = getusername();
if (user == NULL)
user = (cp = strchr(addr, '.')) ? ++cp : addr;
- if ((pw = getpwnam (user)) == NULL)
- adios (NULL, "no such local user as %s", user);
+ if ((pw = getpwnam(user)) == NULL)
+ adios(NULL, "no such local user as %s", user);
- if (chdir (pw->pw_dir) == -1)
- chdir ("/");
- umask (0077);
+ if (chdir(pw->pw_dir) == -1)
+ chdir("/");
+ umask(0077);
if (geteuid() == 0) {
- setgid (pw->pw_gid);
- initgroups (pw->pw_name, pw->pw_gid);
- setuid (pw->pw_uid);
+ setgid(pw->pw_gid);
+ initgroups(pw->pw_name, pw->pw_gid);
+ setuid(pw->pw_uid);
}
if (info == NULL)
info = "";
- setbuf (stdin, NULL);
+ setbuf(stdin, NULL);
/* Record the delivery time */
- if ((now = dlocaltimenow ()) == NULL)
- adios (NULL, "unable to ascertain local time");
- snprintf (ddate, sizeof(ddate), "Delivery-Date: %s\n", dtimenow (0));
+ if ((now = dlocaltimenow()) == NULL)
+ adios(NULL, "unable to ascertain local time");
+ snprintf(ddate, sizeof(ddate), "Delivery-Date: %s\n", dtimenow(0));
/*
** Copy the message to a temporary file
int tempfd;
/* getting message from file */
- if ((tempfd = open (file, O_RDONLY)) == -1)
- adios (file, "unable to open");
+ if ((tempfd = open(file, O_RDONLY)) == -1)
+ adios(file, "unable to open");
if (debug)
- debug_printf ("retrieving message from file \"%s\"\n", file);
- if ((fd = copy_message (tempfd, tmpfil, 1)) == -1)
- adios (NULL, "unable to create temporary file");
- close (tempfd);
+ debug_printf("retrieving message from file \"%s\"\n",
+ file);
+ if ((fd = copy_message(tempfd, tmpfil, 1)) == -1)
+ adios(NULL, "unable to create temporary file");
+ close(tempfd);
} else {
/* getting message from stdin */
if (debug)
- debug_printf ("retrieving message from stdin\n");
- if ((fd = copy_message (fileno (stdin), tmpfil, 1)) == -1)
- adios (NULL, "unable to create temporary file");
+ debug_printf("retrieving message from stdin\n");
+ if ((fd = copy_message(fileno(stdin), tmpfil, 1)) == -1)
+ adios(NULL, "unable to create temporary file");
}
if (debug)
- debug_printf ("temporary file=\"%s\"\n", tmpfil);
+ debug_printf("temporary file=\"%s\"\n", tmpfil);
/*
** Delete the temp file now or a copy of every single message
** someone who cares about the temp-file-accessing functionality
** (they'll have to watch out for cases where we adios()).
*/
- unlink (tmpfil);
+ unlink(tmpfil);
- if (!(fp = fdopen (fd, "r+")))
- adios (NULL, "unable to access temporary file");
+ if (!(fp = fdopen(fd, "r+")))
+ adios(NULL, "unable to access temporary file");
/*
** If no sender given, extract it
** from envelope information.
*/
if (sender == NULL)
- get_sender (envelope, &sender);
+ get_sender(envelope, &sender);
if (mbox == NULL) {
- snprintf (mailbox, sizeof(mailbox), "%s/%s",
+ snprintf(mailbox, sizeof(mailbox), "%s/%s",
mmdfldir[0] ? mmdfldir : pw->pw_dir,
mmdflfil[0] ? mmdflfil : pw->pw_name);
mbox = mailbox;
home = pw->pw_dir;
if (debug) {
- debug_printf ("addr=\"%s\"\n", trim(addr));
- 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",
+ debug_printf("addr=\"%s\"\n", trim(addr));
+ 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 ("mbox=\"%s\"\n", trim(mbox));
- debug_printf ("home=\"%s\"\n", trim(home));
- debug_printf ("ddate=\"%s\"\n", trim(ddate));
- debug_printf ("now=%02d:%02d\n\n", now->tw_hour, now->tw_min);
+ debug_printf("mbox=\"%s\"\n", trim(mbox));
+ debug_printf("home=\"%s\"\n", trim(home));
+ debug_printf("ddate=\"%s\"\n", trim(ddate));
+ debug_printf("now=%02d:%02d\n\n", now->tw_hour, now->tw_min);
}
/* deliver the message */
- status = localmail (fd, mdlvr);
+ status = localmail(fd, mdlvr);
- done (status != -1 ? RCV_MOK : RCV_MBX);
+ done(status != -1 ? RCV_MOK : RCV_MBX);
return 1;
}
*/
static int
-localmail (int fd, char *mdlvr)
+localmail(int fd, char *mdlvr)
{
/* check if this message is a duplicate */
- if (suppressdup &&
- suppress_duplicates(fd,
- mdlvr ? mdlvr : ".maildelivery") == DONE)
+ if (suppressdup && suppress_duplicates(fd, mdlvr ?
+ mdlvr : ".maildelivery") == DONE)
return 0;
/* delivery according to personal Maildelivery file */
- if (usr_delivery (fd, mdlvr ? mdlvr : ".maildelivery", 0) != -1)
+ if (usr_delivery(fd, mdlvr ? mdlvr : ".maildelivery", 0) != -1)
return 0;
/* delivery according to global Maildelivery file */
- if (usr_delivery (fd, maildelivery, 1) != -1)
+ if (usr_delivery(fd, maildelivery, 1) != -1)
return 0;
if (verbose)
- verbose_printf ("(delivering to standard mail spool)\n");
+ verbose_printf("(delivering to standard mail spool)\n");
/* last resort - deliver to standard mail spool */
#ifdef SLOCAL_MBOX
- return usr_file (fd, mbox, MBOX_FORMAT);
+ return usr_file(fd, mbox, MBOX_FORMAT);
#else
- return usr_file (fd, mbox, MMDF_FORMAT);
+ return usr_file(fd, mbox, MMDF_FORMAT);
#endif
}
-#define matches(a,b) (stringdex (b, a) >= 0)
+#define matches(a,b) (stringdex(b, a) >= 0)
/*
** Parse the delivery file, and process incoming message.
*/
static int
-usr_delivery (int fd, char *delivery, int su)
+usr_delivery(int fd, char *delivery, int su)
{
int i, accept, status=1, won, vecp, next;
char *field, *pattern, *action, *result, *string;
FILE *fp;
/* open the delivery file */
- if ((fp = fopen (delivery, "r")) == NULL)
+ if ((fp = fopen(delivery, "r")) == NULL)
return -1;
/* check if delivery file has bad ownership or permissions */
- if (fstat (fileno (fp), &st) == -1
- || (st.st_uid != 0 && (su || st.st_uid != pw->pw_uid))
- || st.st_mode & (S_IWGRP|S_IWOTH)) {
+ if (fstat(fileno(fp), &st) == -1 ||
+ (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;
}
next = 1;
/* read and process delivery file */
- while (fgets (buffer, sizeof(buffer), fp)) {
+ while (fgets(buffer, sizeof(buffer), fp)) {
/* skip comments and empty lines */
if (*buffer == '#' || *buffer == '\n')
continue;
*cp = 0;
/* split buffer into fields */
- vecp = split (buffer, vec);
+ vecp = split(buffer, vec);
/* check for too few fields */
if (vecp < 5) {
if (debug)
- debug_printf ("WARNING: entry with only %d fields, skipping.\n", vecp);
+ debug_printf("WARNING: entry with only %d fields, skipping.\n", vecp);
continue;
}
if (debug) {
for (i = 0; vec[i]; i++)
- debug_printf ("vec[%d]: \"%s\"\n",
+ debug_printf("vec[%d]: \"%s\"\n",
i, trim(vec[i]));
}
}
if (vecp > 5) {
- if (!mh_strcasecmp (vec[5], "select")) {
- if (logged_in () != -1)
+ if (!mh_strcasecmp(vec[5], "select")) {
+ if (logged_in() != -1)
continue;
- if (vecp > 7 && timely (vec[6], vec[7]) == -1)
+ if (vecp > 7 && timely(vec[6], vec[7]) == -1)
continue;
}
}
** "default" matches only if the message hasn't
** been delivered yet.
*/
- if (!mh_strcasecmp (field, "default")) {
+ if (!mh_strcasecmp(field, "default")) {
if (won)
continue;
break;
default:
/* parse message and build lookup table */
- if (!parsed && parse (fd) == -1) {
- fclose (fp);
+ if (!parsed && parse(fd) == -1) {
+ fclose(fp);
return -1;
}
/*
** find header field in lookup table, and
** see if the pattern matches.
*/
- if ((p = lookup (hdrs, field)) &&
+ if ((p = lookup(hdrs, field)) &&
(p->p_value != NULL) &&
- matches (p->p_value, pattern)
+ matches(p->p_value, pattern)
) {
next = 1;
} else {
switch (*action) {
case 'q':
/* deliver to quoted pipe */
- if (mh_strcasecmp (action, "qpipe"))
+ if (mh_strcasecmp(action, "qpipe"))
continue; /* else fall */
case '^':
- expand (tmpbuf, string, fd);
- if (split (tmpbuf, vec) < 1)
+ expand(tmpbuf, string, fd);
+ if (split(tmpbuf, vec) < 1)
continue;
- status = usr_pipe (fd, tmpbuf, vec[0], vec, 0);
+ status = usr_pipe(fd, tmpbuf, vec[0], vec, 0);
break;
case 'p':
/* deliver to pipe */
- if (mh_strcasecmp (action, "pipe"))
+ if (mh_strcasecmp(action, "pipe"))
continue; /* else fall */
case '|':
vec[2] = "sh";
vec[3] = "-c";
- expand (tmpbuf, string, fd);
+ expand(tmpbuf, string, fd);
vec[4] = tmpbuf;
vec[5] = NULL;
- status = usr_pipe (fd, tmpbuf, "/bin/sh",
+ 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,
+ if (!mh_strcasecmp(action, "file")) {
+ status = usr_file(fd, string,
MBOX_FORMAT);
break;
}
/* deliver to nmh folder */
- else if (mh_strcasecmp (action, "folder"))
+ else if (mh_strcasecmp(action, "folder"))
continue; /* else fall */
case '+':
- status = usr_folder (fd, string);
+ status = usr_folder(fd, string);
break;
case 'm':
/* mmdf format */
- if (!mh_strcasecmp (action, "mmdf")) {
- status = usr_file (fd, string,
+ if (!mh_strcasecmp(action, "mmdf")) {
+ status = usr_file(fd, string,
MMDF_FORMAT);
break;
}
/* mbox format */
- else if (mh_strcasecmp (action, "mbox"))
+ else if (mh_strcasecmp(action, "mbox"))
continue; /* else fall */
case '>':
/* mbox format */
- status = usr_file (fd, string, MBOX_FORMAT);
+ status = usr_file(fd, string, MBOX_FORMAT);
break;
case 'd':
/* ignore message */
- if (mh_strcasecmp (action, "destroy"))
+ if (mh_strcasecmp(action, "destroy"))
continue;
status = 0;
break;
}
- if (status) next = 0; /* action failed, mark for 'N' result */
+ if (status)
+ next = 0; /* action failed, mark for 'N' result */
if (accept && status == 0)
won++;
}
- fclose (fp);
+ fclose(fp);
return (won ? 0 : -1);
}
*/
static int
-split (char *cp, char **vec)
+split(char *cp, char **vec)
{
int i;
unsigned char *s;
vec[i] = NULL;
/* zap any whitespace and comma's */
- while (isspace (*s) || *s == ',')
+ while (isspace(*s) || *s == ',')
*s++ = 0;
/* end of buffer, time to leave */
*/
if (*s == QUOTE) {
if (*++s == '"')
- strcpy (s - 1, s);
+ strcpy(s - 1, s);
s--;
}
}
vec[i++] = s++;
/* move forward to next field delimiter */
- while (*s && !isspace (*s) && *s != ',')
+ while (*s && !isspace(*s) && *s != ',')
s++;
}
vec[i] = NULL;
*/
static int
-parse (int fd)
+parse(int fd)
{
int i, state;
int fd1;
return 0;
/* get a new FILE pointer to message */
- if ((fd1 = dup (fd)) == -1)
+ if ((fd1 = dup(fd)) == -1)
return -1;
- if ((in = fdopen (fd1, "r")) == NULL) {
- close (fd1);
+ if ((in = fdopen(fd1, "r")) == NULL) {
+ close(fd1);
return -1;
}
- rewind (in);
+ rewind(in);
/* add special entries to lookup table */
- if ((p = lookup (hdrs, "source")))
- p->p_value = getcpy (sender);
- if ((p = lookup (hdrs, "addr")))
- p->p_value = getcpy (addr);
+ if ((p = lookup(hdrs, "source")))
+ p->p_value = getcpy(sender);
+ if ((p = lookup(hdrs, "addr")))
+ p->p_value = getcpy(addr);
/*
* Scan the headers of the message and build
* a lookup table.
*/
for (i = 0, state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field),
+ switch (state = m_getfld(state, name, field, sizeof(field),
in)) {
case FLD:
case FLDEOF:
case FLDPLUS:
- lp = add (field, NULL);
+ lp = add(field, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, field, sizeof(field), in);
- lp = add (field, lp);
+ state = m_getfld(state, name, field,
+ sizeof(field), in);
+ lp = add(field, lp);
}
for (p = hdrs; p->p_name; p++) {
- if (!mh_strcasecmp (p->p_name, name)) {
+ if (!mh_strcasecmp(p->p_name, name)) {
if (!(p->p_flags & P_HID)) {
if ((cp = p->p_value)) {
if (p->p_flags & P_ADR) {
- dp = cp + strlen (cp) - 1;
+ dp = cp + strlen(cp) - 1;
if (*dp == '\n')
*dp = 0;
- cp = add (",\n\t", cp);
+ cp = add(",\n\t", cp);
} else {
- cp = add ("\t", cp);
+ cp = add("\t", cp);
}
}
- p->p_value = add (lp, cp);
+ p->p_value = add(lp, cp);
}
- free (lp);
+ free(lp);
break;
}
}
if (p->p_name == NULL && i < NVEC) {
- p->p_name = getcpy (name);
+ p->p_name = getcpy(name);
p->p_value = lp;
p->p_flags = P_NIL;
p++, i++;
case LENERR:
case FMTERR:
- advise (NULL, "format error in message");
+ advise(NULL, "format error in message");
break;
default:
- advise (NULL, "internal error in m_getfld");
- fclose (in);
+ advise(NULL, "internal error in m_getfld");
+ fclose(in);
return -1;
}
break;
}
- fclose (in);
+ fclose(in);
- if ((p = lookup (vars, "reply-to"))) {
- if ((q = lookup (hdrs, "reply-to")) == NULL || q->p_value == NULL)
- q = lookup (hdrs, "from");
- p->p_value = getcpy (q ? q->p_value : "");
+ if ((p = lookup(vars, "reply-to"))) {
+ if ((q = lookup(hdrs, "reply-to")) == NULL ||
+ q->p_value == NULL)
+ q = lookup(hdrs, "from");
+ p->p_value = getcpy(q ? q->p_value : "");
p->p_flags &= ~P_CHK;
if (debug)
- debug_printf ("vars[%d]: name=\"%s\" value=\"%s\"\n",
+ debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
p - vars, p->p_name, trim(p->p_value));
}
if (debug) {
for (p = hdrs; p->p_name; p++)
- debug_printf ("hdrs[%d]: name=\"%s\" value=\"%s\"\n",
+ debug_printf("hdrs[%d]: name=\"%s\" value=\"%s\"\n",
p - hdrs, p->p_name, p->p_value ? trim(p->p_value) : "");
}
*/
static void
-expand (char *s1, char *s2, int fd)
+expand(char *s1, char *s2, int fd)
{
char c, *cp;
struct pair *p;
if (!globbed)
- glob (fd);
+ glob(fd);
while ((c = *s2++)) {
if (c != '$' || *s2 != LPAREN) {
continue;
}
*s2++ = 0;
- if ((p = lookup (vars, cp))) {
+ if ((p = lookup(vars, cp))) {
if (!parsed && (p->p_flags & P_CHK))
- parse (fd);
+ parse(fd);
- strcpy (s1, p->p_value);
- s1 += strlen (s1);
+ strcpy(s1, p->p_value);
+ s1 += strlen(s1);
}
}
}
*/
static void
-glob (int fd)
+glob(int fd)
{
char buffer[BUFSIZ];
struct stat st;
if (globbed++)
return;
- if ((p = lookup (vars, "sender")))
- p->p_value = getcpy (sender);
- if ((p = lookup (vars, "address")))
- p->p_value = getcpy (addr);
- if ((p = lookup (vars, "size"))) {
- snprintf (buffer, sizeof(buffer), "%d",
- fstat (fd, &st) != -1 ? (int) st.st_size : 0);
- p->p_value = getcpy (buffer);
+ if ((p = lookup(vars, "sender")))
+ p->p_value = getcpy(sender);
+ if ((p = lookup(vars, "address")))
+ p->p_value = getcpy(addr);
+ if ((p = lookup(vars, "size"))) {
+ snprintf(buffer, sizeof(buffer), "%d",
+ fstat(fd, &st) != -1 ? (int) st.st_size : 0);
+ p->p_value = getcpy(buffer);
}
- if ((p = lookup (vars, "info")))
- p->p_value = getcpy (info);
+ if ((p = lookup(vars, "info")))
+ p->p_value = getcpy(info);
if (debug) {
for (p = vars; p->p_name; p++)
- debug_printf ("vars[%d]: name=\"%s\" value=\"%s\"\n",
+ debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
p - vars, p->p_name, trim(p->p_value));
}
}
*/
static struct pair *
-lookup (struct pair *pairs, char *key)
+lookup(struct pair *pairs, char *key)
{
for (; pairs->p_name; pairs++)
- if (!mh_strcasecmp (pairs->p_name, key))
+ if (!mh_strcasecmp(pairs->p_name, key))
return pairs;
return NULL;
#ifdef HAVE_GETUTENT
static int
-logged_in (void)
+logged_in(void)
{
struct utmp * utp;
utp->ut_type == USER_PROCESS &&
#endif
utp->ut_name[0] != 0 &&
- strncmp (user, utp->ut_name,
+ strncmp(user, utp->ut_name,
sizeof(utp->ut_name)) == 0) {
if (debug)
continue;
}
#else
static int
-logged_in (void)
+logged_in(void)
{
struct utmp ut;
FILE *uf;
if (utmped)
return utmped;
- if ((uf = fopen (UTMP_FILE, "r")) == NULL)
+ if ((uf = fopen(UTMP_FILE, "r")) == NULL)
return NOTOK;
- while (fread ((char *) &ut, sizeof(ut), 1, uf) == 1) {
+ while (fread((char *) &ut, sizeof(ut), 1, uf) == 1) {
if (ut.ut_name[0] != 0 &&
- strncmp (user, ut.ut_name, sizeof(ut.ut_name))
+ strncmp(user, ut.ut_name, sizeof(ut.ut_name))
== 0) {
if (debug)
continue;
- fclose (uf);
+ fclose(uf);
return (utmped = DONE);
}
}
- fclose (uf);
+ fclose(uf);
return (utmped = NOTOK);
}
#endif
#define cmpar(h1,m1,h2,m2) if (h1 < h2 || (h1 == h2 && m1 < m2)) return 0
static int
-timely (char *t1, char *t2)
+timely(char *t1, char *t2)
{
int t1hours, t1mins, t2hours, t2mins;
- if (sscanf (t1, "%d:%d", &t1hours, &t1mins) != 2)
+ if (sscanf(t1, "%d:%d", &t1hours, &t1mins) != 2)
return -1;
- check (t1hours, 0, 23);
- check (t1mins, 0, 59);
+ check(t1hours, 0, 23);
+ check(t1mins, 0, 59);
- if (sscanf (t2, "%d:%d", &t2hours, &t2mins) != 2)
+ if (sscanf(t2, "%d:%d", &t2hours, &t2mins) != 2)
return -1;
- check (t2hours, 0, 23);
- check (t2mins, 0, 59);
+ check(t2hours, 0, 23);
+ check(t2mins, 0, 59);
- cmpar (now->tw_hour, now->tw_min, t1hours, t1mins);
- cmpar (t2hours, t2mins, now->tw_hour, now->tw_min);
+ cmpar(now->tw_hour, now->tw_min, t1hours, t1mins);
+ cmpar(t2hours, t2mins, now->tw_hour, now->tw_min);
return -1;
}
*/
static int
-usr_file (int fd, char *mailbox, int mbx_style)
+usr_file(int fd, char *mailbox, int mbx_style)
{
int md, mapping;
if (verbose)
- verbose_printf ("delivering to file \"%s\"", mailbox);
+ verbose_printf("delivering to file \"%s\"", mailbox);
if (mbx_style == MBOX_FORMAT) {
if (verbose)
- verbose_printf (" (mbox style)");
+ verbose_printf(" (mbox style)");
mapping = 0;
} else {
if (verbose)
- verbose_printf (" (mmdf style)");
+ verbose_printf(" (mmdf style)");
mapping = 1;
}
/* open and lock the file */
- if ((md = mbx_open (mailbox, mbx_style, pw->pw_uid, pw->pw_gid,
+ if ((md = mbx_open(mailbox, mbx_style, pw->pw_uid, pw->pw_gid,
m_gmprot())) == -1) {
if (verbose)
- adorn ("", "unable to open:");
+ adorn("", "unable to open:");
return -1;
}
- lseek (fd, (off_t) 0, SEEK_SET);
+ lseek(fd, (off_t) 0, SEEK_SET);
/* append message to file */
- if (mbx_copy (mailbox, mbx_style, md, fd, mapping, NULL, verbose)
+ if (mbx_copy(mailbox, mbx_style, md, fd, mapping, NULL, verbose)
== -1) {
if (verbose)
- adorn ("", "error writing to:");
+ adorn("", "error writing to:");
return -1;
}
/* close and unlock file */
- if (mbx_close (mailbox, md) == NOTOK) {
+ if (mbx_close(mailbox, md) == NOTOK) {
if (verbose)
- adorn ("", "error closing:");
+ adorn("", "error closing:");
return -1;
}
if (verbose)
- verbose_printf (", success.\n");
+ verbose_printf(", success.\n");
return 0;
}
*/
static int
-usr_folder (int fd, char *string)
+usr_folder(int fd, char *string)
{
int status;
char folder[BUFSIZ], *vec[3];
snprintf(folder, sizeof(folder), "+%s", string);
if (verbose)
- verbose_printf ("delivering to folder \"%s\"", folder + 1);
+ verbose_printf("delivering to folder \"%s\"", folder + 1);
vec[0] = "rcvstore";
vec[1] = folder;
vec[2] = NULL;
/* use rcvstore to put message in folder */
- status = usr_pipe (fd, "rcvstore", rcvstoreproc, vec, 1);
+ status = usr_pipe(fd, "rcvstore", rcvstoreproc, vec, 1);
#if 0
/*
*/
if (verbose) {
if (status == 0)
- verbose_printf (", success.\n");
+ verbose_printf(", success.\n");
else
- verbose_printf (", failed.\n");
+ verbose_printf(", failed.\n");
}
#endif
*/
static int
-usr_pipe (int fd, char *cmd, char *pgm, char **vec, int suppress)
+usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress)
{
pid_t child_id;
int i, bytes, seconds, status;
struct stat st;
if (verbose && !suppress)
- verbose_printf ("delivering to pipe \"%s\"", cmd);
+ verbose_printf("delivering to pipe \"%s\"", cmd);
- lseek (fd, (off_t) 0, SEEK_SET);
+ lseek(fd, (off_t) 0, SEEK_SET);
for (i = 0; (child_id = fork()) == -1 && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case -1:
/* fork error */
if (verbose)
- adorn ("fork", "unable to");
+ adorn("fork", "unable to");
return -1;
case 0:
/* child process */
if (fd != 0)
- dup2 (fd, 0);
- freopen ("/dev/null", "w", stdout);
- freopen ("/dev/null", "w", stderr);
+ dup2(fd, 0);
+ freopen("/dev/null", "w", stdout);
+ freopen("/dev/null", "w", stderr);
if (fd != 3)
- dup2 (fd, 3);
- closefds (4);
+ dup2(fd, 3);
+ closefds(4);
#ifdef TIOCNOTTY
- if ((fd = open ("/dev/tty", O_RDWR)) != -1) {
- ioctl (fd, TIOCNOTTY, NULL);
- close (fd);
+ if ((fd = open("/dev/tty", O_RDWR)) != -1) {
+ ioctl(fd, TIOCNOTTY, NULL);
+ close(fd);
}
#endif /* TIOCNOTTY */
/* put in own process group */
- setpgid ((pid_t) 0, getpid ());
+ setpgid((pid_t) 0, getpid());
*environ = NULL;
- m_putenv ("USER", pw->pw_name);
- m_putenv ("HOME", pw->pw_dir);
- m_putenv ("SHELL", pw->pw_shell);
+ m_putenv("USER", pw->pw_name);
+ m_putenv("HOME", pw->pw_dir);
+ m_putenv("SHELL", pw->pw_shell);
- execvp (pgm, vec);
- _exit (-1);
+ execvp(pgm, vec);
+ _exit(-1);
default:
/* parent process */
- if (!setjmp (myctx)) {
- SIGNAL (SIGALRM, alrmser);
- bytes = fstat (fd, &st) != -1 ?
+ if (!setjmp(myctx)) {
+ SIGNAL(SIGALRM, alrmser);
+ bytes = fstat(fd, &st) != -1 ?
(int) st.st_size : 100;
/*
} else {
seconds = (bytes / 60) + 300;
}
- alarm ((unsigned int) seconds);
- status = pidwait (child_id, 0);
- alarm (0);
+ alarm((unsigned int) seconds);
+ status = pidwait(child_id, 0);
+ alarm(0);
if (verbose) {
if (status == 0)
- verbose_printf (", success.\n");
+ verbose_printf(", success.\n");
else
if ((status & 0xff00) == 0xff00)
- verbose_printf (", system error\n");
+ verbose_printf(", system error\n");
else
- pidstatus (status, stdout, ", failed");
+ pidstatus(status, stdout, ", failed");
}
return (status == 0 ? 0 : -1);
} else {
*/
KILLPG(child_id, SIGKILL);
if (verbose)
- verbose_printf (", timed-out; terminated\n");
+ verbose_printf(", timed-out; terminated\n");
return -1;
}
}
static RETSIGTYPE
-alrmser (int i)
+alrmser(int i)
{
#ifndef RELIABLE_SIGNALS
- SIGNAL (SIGALRM, alrmser);
+ SIGNAL(SIGALRM, alrmser);
#endif
- longjmp (myctx, DONE);
+ longjmp(myctx, DONE);
}
*/
static void
-get_sender (char *envelope, char **sender)
+get_sender(char *envelope, char **sender)
{
int i;
unsigned char *cp;
unsigned char buffer[BUFSIZ];
if (envelope == NULL) {
- *sender = getcpy ("");
+ *sender = getcpy("");
return;
}
- i = strlen ("From ");
- strncpy (buffer, envelope + i, sizeof(buffer));
+ i = strlen("From ");
+ strncpy(buffer, envelope + i, sizeof(buffer));
if ((cp = strchr(buffer, '\n'))) {
*cp = 0;
cp -= 24;
}
*cp = 0;
- for (cp = buffer + strlen (buffer) - 1; cp >= buffer; cp--)
- if (isspace (*cp))
+ for (cp = buffer + strlen(buffer) - 1; cp >= buffer; cp--)
+ if (isspace(*cp))
*cp = 0;
else
break;
- *sender = getcpy (buffer);
+ *sender = getcpy(buffer);
}
*/
static int
-copy_message (int qd, char *tmpfil, int fold)
+copy_message(int qd, char *tmpfil, int fold)
{
int i, first = 1, fd1, fd2;
char buffer[BUFSIZ];
tfile = m_mktemp2(NULL, invo_name, &fd1, NULL);
if (tfile == NULL) return -1;
fchmod(fd1, 0600);
- strncpy (tmpfil, tfile, BUFSIZ);
+ strncpy(tmpfil, tfile, BUFSIZ);
if (!fold) {
- while ((i = read (qd, buffer, sizeof(buffer))) > 0)
- if (write (fd1, buffer, i) != i) {
+ while ((i = read(qd, buffer, sizeof(buffer))) > 0)
+ if (write(fd1, buffer, i) != i) {
you_lose:
- close (fd1);
- unlink (tmpfil);
+ close(fd1);
+ unlink(tmpfil);
return -1;
}
if (i == -1)
goto you_lose;
- lseek (fd1, (off_t) 0, SEEK_SET);
+ lseek(fd1, (off_t) 0, SEEK_SET);
return fd1;
}
/* dup the fd for incoming message */
- if ((fd2 = dup (qd)) == -1) {
- close (fd1);
+ if ((fd2 = dup(qd)) == -1) {
+ close(fd1);
return -1;
}
/* now create a FILE pointer for it */
- if ((qfp = fdopen (fd2, "r")) == NULL) {
- close (fd1);
- close (fd2);
+ if ((qfp = fdopen(fd2, "r")) == NULL) {
+ close(fd1);
+ close(fd2);
return -1;
}
/* dup the fd for temporary file */
- if ((fd2 = dup (fd1)) == -1) {
- close (fd1);
- fclose (qfp);
+ if ((fd2 = dup(fd1)) == -1) {
+ close(fd1);
+ fclose(qfp);
return -1;
}
/* now create a FILE pointer for it */
- if ((ffp = fdopen (fd2, "r+")) == NULL) {
- close (fd1);
- close (fd2);
- fclose (qfp);
+ if ((ffp = fdopen(fd2, "r+")) == NULL) {
+ close(fd1);
+ close(fd2);
+ fclose(qfp);
return -1;
}
** and massage the headers. Save
** a copy of the "From " line for later.
*/
- i = strlen ("From ");
- while (fgets (buffer, sizeof(buffer), qfp)) {
+ i = strlen("From ");
+ while (fgets(buffer, sizeof(buffer), qfp)) {
if (first) {
first = 0;
- if (!strncmp (buffer, "From ", i)) {
+ if (!strncmp(buffer, "From ", i)) {
#ifdef RPATHS
char *fp, *cp, *hp, *ep;
#endif
** get copy of envelope information
** ("From " line)
*/
- envelope = getcpy (buffer);
+ envelope = getcpy(buffer);
#if 0
/*
** First go ahead and put "From " line
** in message
*/
- fputs (buffer, ffp);
- if (ferror (ffp))
+ fputs(buffer, ffp);
+ if (ferror(ffp))
goto fputs_error;
#endif
*/
hp = cp = strchr(fp = envelope + i, ' ');
while ((hp = strchr(++hp, 'r')))
- if (uprf (hp, "remote from")) {
+ if (uprf(hp, "remote from")) {
hp = strrchr(hp, ' ');
break;
}
** 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);
+ snprintf(buffer, sizeof(buffer), "Return-Path: %.*s\n", (int)(cp - fp), fp);
}
/* Add Return-Path header to message */
- fputs (buffer, ffp);
- if (ferror (ffp))
+ fputs(buffer, ffp);
+ if (ferror(ffp))
goto fputs_error;
#endif
/* Put the delivery date in message */
- fputs (ddate, ffp);
- if (ferror (ffp))
+ fputs(ddate, ffp);
+ if (ferror(ffp))
goto fputs_error;
continue;
}
}
- fputs (buffer, ffp);
- if (ferror (ffp))
+ fputs(buffer, ffp);
+ if (ferror(ffp))
goto fputs_error;
}
- fclose (ffp);
- if (ferror (qfp)) {
- close (fd1);
- fclose (qfp);
+ fclose(ffp);
+ if (ferror(qfp)) {
+ close(fd1);
+ fclose(qfp);
return -1;
}
- fclose (qfp);
- lseek (fd1, (off_t) 0, SEEK_SET);
+ fclose(qfp);
+ lseek(fd1, (off_t) 0, SEEK_SET);
return fd1;
fputs_error:
- close (fd1);
- fclose (ffp);
- fclose (qfp);
+ close(fd1);
+ fclose(ffp);
+ fclose(qfp);
return -1;
}
*/
static char *
-trim (char *cp)
+trim(char *cp)
{
char buffer[BUFSIZ*4];
unsigned char *bp, *sp;
return NULL;
/* copy string into temp buffer */
- strncpy (buffer, cp, sizeof(buffer));
+ strncpy(buffer, cp, sizeof(buffer));
bp = buffer;
/* skip over leading whitespace */
*/
static void
-verbose_printf (char *fmt, ...)
+verbose_printf(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- vfprintf (stdout, fmt, ap);
+ vfprintf(stdout, fmt, ap);
va_end(ap);
- fflush (stdout); /* now flush output */
+ fflush(stdout); /* now flush output */
}
*/
static void
-adorn (char *what, char *fmt, ...)
+adorn(char *what, char *fmt, ...)
{
va_list ap;
int eindex;
char *s;
eindex = errno; /* save the errno */
- fprintf (stdout, ", ");
+ fprintf(stdout, ", ");
va_start(ap, fmt);
- vfprintf (stdout, fmt, ap);
+ vfprintf(stdout, fmt, ap);
va_end(ap);
if (what) {
if (*what)
- fprintf (stdout, " %s: ", what);
- if ((s = strerror (eindex)))
- fprintf (stdout, "%s", s);
+ fprintf(stdout, " %s: ", what);
+ if ((s = strerror(eindex)))
+ fprintf(stdout, "%s", s);
else
- fprintf (stdout, "Error %d", eindex);
+ fprintf(stdout, "Error %d", eindex);
}
- fputc ('\n', stdout);
- fflush (stdout);
+ fputc('\n', stdout);
+ fflush(stdout);
}
*/
static void
-debug_printf (char *fmt, ...)
+debug_printf(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- vfprintf (stderr, fmt, ap);
+ vfprintf(stderr, fmt, ap);
va_end(ap);
}
** Message-Id of this message to the ndbm/db file.
*/
static int
-suppress_duplicates (int fd, char *file)
+suppress_duplicates(int fd, char *file)
{
int fd1, lockfd, state, result;
char *cp, buf[BUFSIZ], name[NAMESZ];
DBM *db;
FILE *in;
- if ((fd1 = dup (fd)) == -1)
+ if ((fd1 = dup(fd)) == -1)
return -1;
- if (!(in = fdopen (fd1, "r"))) {
- close (fd1);
+ if (!(in = fdopen(fd1, "r"))) {
+ close(fd1);
return -1;
}
- rewind (in);
+ rewind(in);
for (state = FLD;;) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ state = m_getfld(state, name, buf, sizeof(buf), in);
switch (state) {
case FLD:
case FLDPLUS:
case FLDEOF:
/* Search for the message ID */
- if (mh_strcasecmp (name, "Message-ID")) {
+ if (mh_strcasecmp(name, "Message-ID")) {
while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ state = m_getfld(state, name, buf, sizeof(buf), in);
continue;
}
- cp = add (buf, NULL);
+ cp = add(buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
- cp = add (buf, cp);
+ state = m_getfld(state, name, buf, sizeof(buf), in);
+ cp = add(buf, cp);
}
- key.dptr = trimcpy (cp);
- key.dsize = strlen (key.dptr) + 1;
- free (cp);
+ key.dptr = trimcpy(cp);
+ key.dsize = strlen(key.dptr) + 1;
+ free(cp);
cp = key.dptr;
- if (!(db = dbm_open (file, O_RDWR | O_CREAT, 0600))) {
- advise (file, "unable to perform dbm_open on");
- free (cp);
- fclose (in);
+ if (!(db = dbm_open(file, O_RDWR | O_CREAT,
+ 0600))) {
+ advise(file, "unable to perform dbm_open on");
+ free(cp);
+ fclose(in);
return -1;
}
/*
** file doesn't exist.
*/
if ((lockfd = lkopen(file, O_RDWR, 0)) == -1) {
- advise (file, "unable to perform file locking on");
- free (cp);
- fclose (in);
+ advise(file, "unable to perform file locking on");
+ free(cp);
+ fclose(in);
return -1;
}
- value = dbm_fetch (db, key);
+ 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:");
value.dsize = strlen(value.dptr) + 1;
- if (dbm_store (db, key, value, DBM_INSERT))
- advise (file, "possibly corrupt file");
+ if (dbm_store(db, key, value, DBM_INSERT))
+ advise(file, "possibly corrupt file");
result = 0;
}
- dbm_close (db);
+ dbm_close(db);
lkclose(lockfd, file);
- free (cp);
- fclose (in);
+ free(cp);
+ fclose(in);
return result;
break;
break;
}
- fclose (in);
+ fclose(in);
return 0;
}
/*
** static prototypes
*/
-static int read_hdrs (struct msgs *, char *);
-static int get_fields (char *, int, struct smsg *);
-static int dsort (struct smsg **, struct smsg **);
-static int subsort (struct smsg **, struct smsg **);
-static int txtsort (struct smsg **, struct smsg **);
-static void rename_chain (struct msgs *, struct smsg **, int, int);
-static void rename_msgs (struct msgs *, struct smsg **);
+static int read_hdrs(struct msgs *, char *);
+static int get_fields(char *, int, struct smsg *);
+static int dsort(struct smsg **, struct smsg **);
+static int subsort(struct smsg **, struct smsg **);
+static int txtsort(struct smsg **, struct smsg **);
+static void rename_chain(struct msgs *, struct smsg **, int, int);
+static void rename_msgs(struct msgs *, struct smsg **);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int i, msgnum;
unsigned char *cp;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
*/
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case DATESW:
if (datesw)
- adios (NULL, "only one date field at a time");
+ adios(NULL, "only one date field at a time");
if (!(datesw = *argp++) || *datesw == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
case TEXTSW:
if (subjsort)
- adios (NULL, "only one text field at a time");
+ adios(NULL, "only one text field at a time");
if (!(subjsort = *argp++) || *subjsort == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
case LIMSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
while (*cp == '0')
cp++; /* skip any leading zeros */
if (!*cp) { /* hit end of string */
continue;
}
if (!isdigit(*cp) || !(datelimit = atoi(cp)))
- adios (NULL, "impossible limit %s", cp);
+ adios(NULL, "impossible limit %s", cp);
datelimit *= 60*60*24;
continue;
case NLIMSW:
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
- folder = pluspath (cp);
+ folder = pluspath(cp);
} else
app_msgarg(&msgs, cp);
}
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
+ if (!context_find("path"))
+ free(path("./", TFOLDER));
if (!msgs.size)
app_msgarg(&msgs, "all");
if (!datesw)
datesw = "date";
if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
+ folder = getfolder(1);
+ maildir = m_maildir(folder);
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/* check for empty folder */
if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
+ adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
- seq_setprev (mp); /* set the previous sequence */
+ if (!m_convert(mp, msgs.msgs[msgnum]))
+ done(1);
+ seq_setprev(mp); /* set the previous sequence */
- if ((nmsgs = read_hdrs (mp, datesw)) <= 0)
- adios (NULL, "no messages to sort");
+ if ((nmsgs = read_hdrs(mp, datesw)) <= 0)
+ adios(NULL, "no messages to sort");
/*
** sort a list of pointers to our "messages to be sorted".
*/
- dlist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*dlist));
+ dlist = (struct smsg **) mh_xmalloc((nmsgs+1) * sizeof(*dlist));
for (i = 0; i < nmsgs; i++)
dlist[i] = &smsgs[i];
dlist[nmsgs] = 0;
if (verbose) { /* announce what we're doing */
if (subjsort)
- printf ("sorting by %s-major %s-minor\n",
+ printf("sorting by %s-major %s-minor\n",
submajor ? subjsort : datesw,
submajor ? datesw : subjsort);
else
- printf ("sorting by datefield %s\n", datesw);
+ printf("sorting by datefield %s\n", datesw);
}
/* first sort by date, or by subject-major, date-minor */
- qsort ((char *) dlist, nmsgs, sizeof(*dlist),
+ qsort((char *) dlist, nmsgs, sizeof(*dlist),
(qsort_comp) (submajor && subjsort ? txtsort : dsort));
/*
register struct smsg ***il, **fp, **dp;
slist = (struct smsg **)
- mh_xmalloc ((nmsgs+1) * sizeof(*slist));
+ mh_xmalloc((nmsgs+1) * sizeof(*slist));
memcpy((char *)slist, (char *)dlist, (nmsgs+1)*sizeof(*slist));
qsort((char *)slist, nmsgs, sizeof(*slist),
(qsort_comp) subsort);
** the collection of messages with the same subj
** given a message number.
*/
- il = (struct smsg ***) calloc (mp->hghsel+1, sizeof(*il));
+ il = (struct smsg ***) calloc(mp->hghsel+1, sizeof(*il));
if (! il)
- adios (NULL, "couldn't allocate msg list");
+ adios(NULL, "couldn't allocate msg list");
for (i = 0; i < nmsgs; i++)
il[slist[i]->s_msg] = &slist[i];
/*
** all the same subjects grouped together.
*/
flist = (struct smsg **)
- mh_xmalloc ((nmsgs+1) * sizeof(*flist));
+ mh_xmalloc((nmsgs+1) * sizeof(*flist));
fp = flist;
for (dp = dlist; *dp;) {
register struct smsg **s = il[(*dp++)->s_msg];
}
}
*fp = 0;
- free (slist);
- free (dlist);
+ free(slist);
+ free(dlist);
dlist = flist;
}
** structures, each of which contains a message number.
*/
- rename_msgs (mp, dlist);
+ rename_msgs(mp, dlist);
- context_replace (pfolder, folder); /* update current folder */
- seq_save (mp); /* synchronize message sequences */
- context_save (); /* save the context file */
- folder_free (mp); /* free folder/message structure */
- done (0);
+ context_replace(pfolder, folder); /* update current folder */
+ seq_save(mp); /* synchronize message sequences */
+ context_save(); /* save the context file */
+ folder_free(mp); /* free folder/message structure */
+ done(0);
return 1;
}
static int
-read_hdrs (struct msgs *mp, char *datesw)
+read_hdrs(struct msgs *mp, char *datesw)
{
int msgnum;
struct tws tb;
register struct smsg *s;
- twscopy (&tb, dlocaltimenow ());
+ twscopy(&tb, dlocaltimenow());
- smsgs = (struct smsg *)
- calloc ((size_t) (mp->hghsel - mp->lowsel + 2),
+ smsgs = (struct smsg *) calloc((size_t) (mp->hghsel - mp->lowsel + 2),
sizeof(*smsgs));
if (smsgs == NULL)
- adios (NULL, "unable to allocate sort storage");
+ adios(NULL, "unable to allocate sort storage");
s = smsgs;
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
- if (get_fields (datesw, msgnum, s)) {
+ if (get_fields(datesw, msgnum, s)) {
s->s_msg = msgnum;
s++;
}
*/
static int
-get_fields (char *datesw, int msg, struct smsg *smsg)
+get_fields(char *datesw, int msg, struct smsg *smsg)
{
register int state;
int compnum;
register char *datecomp = NULL, *subjcomp = NULL;
register FILE *in;
- if ((in = fopen (msgnam = m_name (msg), "r")) == NULL) {
- admonish (msgnam, "unable to read message");
+ if ((in = fopen(msgnam = m_name(msg), "r")) == NULL) {
+ admonish(msgnam, "unable to read message");
return (0);
}
for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, nam, buf, sizeof(buf), in)) {
+ switch (state = m_getfld(state, nam, buf, sizeof(buf), in)) {
case FLD:
case FLDEOF:
case FLDPLUS:
compnum++;
- if (!mh_strcasecmp (nam, datesw)) {
- datecomp = add (buf, datecomp);
+ if (!mh_strcasecmp(nam, datesw)) {
+ datecomp = add(buf, datecomp);
while (state == FLDPLUS) {
- state = m_getfld (state, nam, buf,
+ state = m_getfld(state, nam, buf,
sizeof(buf), in);
- datecomp = add (buf, datecomp);
+ datecomp = add(buf, datecomp);
}
if (!subjsort || subjcomp)
break;
} else if (subjsort && !mh_strcasecmp(nam, subjsort)) {
- subjcomp = add (buf, subjcomp);
+ subjcomp = add(buf, subjcomp);
while (state == FLDPLUS) {
- state = m_getfld (state, nam, buf,
+ state = m_getfld(state, nam, buf,
sizeof(buf), in);
- subjcomp = add (buf, subjcomp);
+ subjcomp = add(buf, subjcomp);
}
if (datecomp)
break;
} else {
/* just flush this guy */
while (state == FLDPLUS)
- state = m_getfld (state, nam, buf,
+ state = m_getfld(state, nam, buf,
sizeof(buf), in);
}
continue;
case LENERR:
case FMTERR:
if (state == LENERR || state == FMTERR)
- admonish (NULL, "format error in message %d (header #%d)", msg, compnum);
+ admonish(NULL, "format error in message %d (header #%d)", msg, compnum);
if (datecomp)
- free (datecomp);
+ free(datecomp);
if (subjcomp)
- free (subjcomp);
- fclose (in);
+ free(subjcomp);
+ fclose(in);
return (0);
default:
- adios (NULL, "internal error -- you lose");
+ adios(NULL, "internal error -- you lose");
}
break;
}
** If no date component, then use the modification
** time of the file as its date
*/
- if (!datecomp || (tw = dparsetime (datecomp)) == NULL) {
+ if (!datecomp || (tw = dparsetime(datecomp)) == NULL) {
struct stat st;
- admonish (NULL, "can't parse %s field in message %d",
+ admonish(NULL, "can't parse %s field in message %d",
datesw, msg);
- fstat (fileno (in), &st);
+ fstat(fileno(in), &st);
smsg->s_clock = st.st_mtime;
} else {
- smsg->s_clock = dmktime (tw);
+ smsg->s_clock = dmktime(tw);
}
if (subjsort) {
cp = subjcomp;
cp2 = subjcomp;
- if (strcmp (subjsort, "subject") == 0) {
+ if (strcmp(subjsort, "subject") == 0) {
while ((c = *cp)) {
if (! isspace(c)) {
if(uprf(cp, "re:"))
smsg->s_subj = subjcomp;
}
- fclose (in);
+ fclose(in);
if (datecomp)
- free (datecomp);
+ free(datecomp);
return (1);
}
** sort on dates.
*/
static int
-dsort (struct smsg **a, struct smsg **b)
+dsort(struct smsg **a, struct smsg **b)
{
if ((*a)->s_clock < (*b)->s_clock)
return (-1);
** sort on subjects.
*/
static int
-subsort (struct smsg **a, struct smsg **b)
+subsort(struct smsg **a, struct smsg **b)
{
register int i;
- if ((i = strcmp ((*a)->s_subj, (*b)->s_subj)))
+ if ((i = strcmp((*a)->s_subj, (*b)->s_subj)))
return (i);
- return (dsort (a, b));
+ return (dsort(a, b));
}
static int
-txtsort (struct smsg **a, struct smsg **b)
+txtsort(struct smsg **a, struct smsg **b)
{
register int i;
- if ((i = strcmp ((*a)->s_subj, (*b)->s_subj)))
+ if ((i = strcmp((*a)->s_subj, (*b)->s_subj)))
return (i);
else if ((*a)->s_msg < (*b)->s_msg)
return (-1);
}
static void
-rename_chain (struct msgs *mp, struct smsg **mlist, int msg, int endmsg)
+rename_chain(struct msgs *mp, struct smsg **mlist, int msg, int endmsg)
{
int nxt, old, new;
char *newname, oldname[BUFSIZ];
mlist[msg] = (struct smsg *)0;
old = smsgs[nxt].s_msg;
new = smsgs[msg].s_msg;
- strncpy (oldname, m_name (old), sizeof(oldname));
- newname = m_name (new);
+ strncpy(oldname, m_name(old), sizeof(oldname));
+ newname = m_name(new);
if (verbose)
- printf ("message %d becomes message %d\n", old, new);
+ printf("message %d becomes message %d\n", old, 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)
- adios (newname, "unable to rename %s to", oldname);
+ if (rename(oldname, newname) == NOTOK)
+ adios(newname, "unable to rename %s to", oldname);
- copy_msg_flags (mp, new, old);
+ copy_msg_flags(mp, new, old);
if (mp->curmsg == old)
- seq_setcur (mp, new);
+ seq_setcur(mp, new);
if (nxt == endmsg)
break;
msg = nxt;
}
/* if (nxt != endmsg); */
-/* rename_chain (mp, mlist, nxt, endmsg); */
+/* rename_chain(mp, mlist, nxt, endmsg); */
}
static void
-rename_msgs (struct msgs *mp, struct smsg **mlist)
+rename_msgs(struct msgs *mp, struct smsg **mlist)
{
int i, j, old, new;
seqset_t tmpset;
char newbuf[MAXPATHLEN + 1];
struct smsg *sp;
- strncpy (tmpfil, m_name (mp->hghmsg + 1), sizeof(tmpfil));
+ strncpy(tmpfil, m_name(mp->hghmsg + 1), sizeof(tmpfil));
for (i = 0; i < nmsgs; i++) {
if (! (sp = mlist[i]))
*/
old = smsgs[j].s_msg;
new = smsgs[i].s_msg;
- strncpy (f1, m_name (old), sizeof(f1));
+ strncpy(f1, m_name(old), sizeof(f1));
if (verbose)
- printf ("renaming message chain from %d to %d\n",
+ printf("renaming message chain from %d to %d\n",
old, new);
/*
mp->foldpath, mp->hghmsg + 1);
ext_hook("ref-hook", f1, newbuf);
- if (rename (f1, tmpfil) == NOTOK)
- adios (tmpfil, "unable to rename %s to ", f1);
+ if (rename(f1, tmpfil) == NOTOK)
+ adios(tmpfil, "unable to rename %s to ", f1);
- get_msg_flags (mp, &tmpset, old);
+ get_msg_flags(mp, &tmpset, old);
- rename_chain (mp, mlist, j, i);
+ rename_chain(mp, mlist, j, i);
/*
** Run the external hook to refile the temorary message number
(void)snprintf(f1, sizeof (f1), "%s/%d", mp->foldpath, new);
ext_hook("ref-hook", newbuf, f1);
- if (rename (tmpfil, m_name(new)) == NOTOK)
- adios (m_name(new), "unable to rename %s to", tmpfil);
+ if (rename(tmpfil, m_name(new)) == NOTOK)
+ adios(m_name(new), "unable to rename %s to", tmpfil);
- set_msg_flags (mp, &tmpset, new);
+ set_msg_flags(mp, &tmpset, new);
mp->msgflags |= SEQMOD;
}
}
/*
** external prototypes
*/
-extern char *getfullname (void);
-extern char *getusername (void);
+extern char *getfullname(void);
+extern char *getusername(void);
extern boolean draft_from_masquerading; /* defined in mts.c */
/*
** static prototypes
*/
-static void putfmt (char *, char *, FILE *);
-static void start_headers (void);
-static void finish_headers (FILE *);
-static int get_header (char *, struct headers *);
-static void putadr (char *, struct mailname *);
-static int putone (char *, int, int);
-static void insert_fcc (struct headers *, unsigned char *);
-static void file (char *);
-static void fcc (char *, char *);
+static void putfmt(char *, char *, FILE *);
+static void start_headers(void);
+static void finish_headers(FILE *);
+static int get_header(char *, struct headers *);
+static void putadr(char *, struct mailname *);
+static int putone(char *, int, int);
+static void insert_fcc(struct headers *, unsigned char *);
+static void file(char *);
+static void fcc(char *, char *);
#if 0
-static void die (char *, char *, ...);
-static void make_bcc_file (void);
+static void die(char *, char *, ...);
+static void make_bcc_file(void);
#endif
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int state, i, pid, compnum;
char *cp, *msg = NULL, **argp, **arguments;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* foil search of user profile/context */
- if (context_foil (NULL) == -1)
- done (1);
+ if (context_foil(NULL) == -1)
+ done(1);
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 0);
+ mts_init(invo_name);
+ arguments = getarguments(invo_name, argc, argv, 0);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] file", invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf), "%s [switches] file", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case DEBUGSW:
debug++;
case FILTSW:
if (!(filter = *argp++) ||
*filter == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
case NFILTSW:
filter = NULL;
case ALIASW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
if (aliasflg < 0) {
/* load default aka's */
- alias (AliasFile);
+ 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;
case WIDTHSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- outputlinelen = atoi (cp);
+ adios(NULL, "missing argument to %s", argp[-2]);
+ outputlinelen = atoi(cp);
if (outputlinelen <= 10)
outputlinelen = 72;
continue;
case LIBSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
/* create a minimal context */
- if (context_foil (cp) == -1)
+ if (context_foil(cp) == -1)
done(1);
continue;
case ANNOSW:
/* -idanno switch ignored */
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios(NULL, "missing argument to %s", argp[-2]);
continue;
}
}
if (msg)
- adios (NULL, "only one message at a time!");
+ adios(NULL, "only one message at a time!");
else
msg = cp;
}
if (aliasflg < 0)
- alias (AliasFile); /* load default aka's */
+ alias(AliasFile); /* load default aka's */
if (!msg)
- adios (NULL, "usage: %s [switches] file", invo_name);
+ adios(NULL, "usage: %s [switches] file", invo_name);
- if ((in = fopen (msg, "r")) == NULL)
- adios (msg, "unable to open");
+ if ((in = fopen(msg, "r")) == NULL)
+ adios(msg, "unable to open");
- start_headers ();
+ start_headers();
if (debug) {
verbose++;
out = stdout;
}
else {
#ifdef HAVE_MKSTEMP
- if ((out = fdopen( mkstemp (tmpfil), "w" )) == NULL )
- adios (tmpfil, "unable to create");
+ if ((out = fdopen( mkstemp(tmpfil), "w" )) == NULL )
+ adios(tmpfil, "unable to create");
#else
- mktemp (tmpfil);
- if ((out = fopen (tmpfil, "w")) == NULL)
- adios (tmpfil, "unable to create");
- chmod (tmpfil, 0600);
+ mktemp(tmpfil);
+ if ((out = fopen(tmpfil, "w")) == NULL)
+ adios(tmpfil, "unable to create");
+ chmod(tmpfil, 0600);
#endif
}
hdrtab = (msgstate == normal) ? NHeaders : RHeaders;
for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+ switch (state = m_getfld(state, name, buf, sizeof(buf), in)) {
case FLD:
compnum++;
- putfmt (name, buf, out);
+ putfmt(name, buf, out);
continue;
case FLDPLUS:
compnum++;
- cp = add (buf, cp);
+ cp = add(buf, cp);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
- cp = add (buf, cp);
+ state = m_getfld(state, name, buf,
+ sizeof(buf), in);
+ cp = add(buf, cp);
}
- putfmt (name, cp, out);
- free (cp);
+ putfmt(name, cp, out);
+ free(cp);
continue;
case BODY:
- finish_headers (out);
- fprintf (out, "\n%s", buf);
+ finish_headers(out);
+ fprintf(out, "\n%s", buf);
while (state == BODY) {
- state = m_getfld (state, name, buf,
+ state = m_getfld(state, name, buf,
sizeof(buf), in);
- fputs (buf, out);
+ fputs(buf, out);
}
break;
case FILEEOF:
- finish_headers (out);
+ finish_headers(out);
break;
case LENERR:
case FMTERR:
- adios (NULL, "message format error in component #%d", compnum);
+ adios(NULL, "message format error in component #%d", compnum);
default:
- adios (NULL, "getfld() returned %d", state);
+ adios(NULL, "getfld() returned %d", state);
}
break;
}
- fclose (in);
+ fclose(in);
if (backflg) {
- strncpy (buf, m_backup (msg), sizeof(buf));
- if (rename (msg, buf) == NOTOK)
- advise (buf, "unable to rename %s to", msg);
+ strncpy(buf, m_backup(msg), sizeof(buf));
+ if (rename(msg, buf) == NOTOK)
+ advise(buf, "unable to rename %s to", msg);
}
if (debug) {
- done (0);
+ done(0);
}
else
- fclose (out);
+ fclose(out);
- file (tmpfil);
+ file(tmpfil);
/*
** 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 (freopen(tmpfil, "r", stdin) == NULL)
+ adios(tmpfil, "can't reopen for sendmail");
if (rmflg)
- unlink (tmpfil);
+ unlink(tmpfil);
argp = sargv;
*argp++ = "send-mail";
sleep(5);
switch (pid) {
case NOTOK:
- fprintf (verbose ? stdout : stderr,
+ fprintf(verbose ? stdout : stderr,
"%s: can't fork to %s\n",
invo_name, sendmail);
exit(-1);
exit(0);
}
}
- execv ( sendmail, sargv);
- adios ( sendmail, "can't exec");
+ execv(sendmail, sargv);
+ adios(sendmail, "can't exec");
return 0; /* dead code to satisfy the compiler */
}
/* DRAFT GENERATION */
static void
-putfmt (char *name, char *str, FILE *out)
+putfmt(char *name, char *str, FILE *out)
{
int i;
char *cp, *pp;
while (*str == ' ' || *str == '\t')
str++;
- if ((i = get_header (name, hdrtab)) == NOTOK) {
- fprintf (out, "%s: %s", name, str);
+ if ((i = get_header(name, hdrtab)) == NOTOK) {
+ fprintf(out, "%s: %s", name, str);
return;
}
if (hdr->flags & HIGN)
return;
if (hdr->flags & HBAD) {
- advise (NULL, "illegal header line -- %s:", name);
+ advise(NULL, "illegal header line -- %s:", name);
badmsg++;
return;
}
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')))
*cp = 0;
for (cp = pp = str; (cp = strchr(pp, ',')); pp = cp) {
*cp++ = 0;
- insert_fcc (hdr, pp);
+ insert_fcc(hdr, pp);
}
- insert_fcc (hdr, pp);
+ insert_fcc(hdr, pp);
return;
}
** alias processing as well.
** -- Dan Harkless <dan-nmh@dilvish.speed.net>
*/
- fprintf (out, "%s: %s", name, str );
+ fprintf(out, "%s: %s", name, str );
}
}
}
static void
-start_headers (void)
+start_headers(void)
{
char *cp;
char sigbuf[BUFSIZ];
strncpy(from, getusername(), sizeof(from));
- if ((cp = getfullname ()) && *cp) {
- strncpy (sigbuf, cp, sizeof(sigbuf));
- snprintf (signature, sizeof(signature), "%s <%s>",
+ if ((cp = getfullname()) && *cp) {
+ strncpy(sigbuf, cp, sizeof(sigbuf));
+ snprintf(signature, sizeof(signature), "%s <%s>",
sigbuf, from);
} else
- snprintf (signature, sizeof(signature), "%s", from);
+ snprintf(signature, sizeof(signature), "%s", from);
}
static void
-finish_headers (FILE *out)
+finish_headers(FILE *out)
{
switch (msgstate) {
case normal:
if (!(msgflags & MDAT))
- fprintf (out, "Date: %s\n", dtimenow (0));
+ fprintf(out, "Date: %s\n", dtimenow(0));
if (msgflags & MFRM) {
/*
** (and use it as the envelope
** From: later).
*/
- fprintf (out, "Sender: %s\n", from);
+ fprintf(out, "Sender: %s\n", from);
} else
- fprintf (out, "From: %s\n", signature);
+ fprintf(out, "From: %s\n", signature);
#ifdef notdef
if (!(msgflags & MVIS))
- fprintf (out, "Bcc: Blind Distribution List: ;\n");
+ fprintf(out, "Bcc: Blind Distribution List: ;\n");
#endif /* notdef */
break;
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.
** (and use it as the envelope
** From: later).
*/
- fprintf (out, "Resent-Sender: %s\n",
+ fprintf(out, "Resent-Sender: %s\n",
from);
} else
/* Construct a Resent-From: header. */
- fprintf (out, "Resent-From: %s\n", signature);
+ fprintf(out, "Resent-From: %s\n", signature);
#ifdef notdef
if (!(msgflags & MVIS))
- fprintf (out, "Resent-Bcc: Blind Re-Distribution List: ;\n");
+ fprintf(out, "Resent-Bcc: Blind Re-Distribution List: ;\n");
#endif /* notdef */
break;
}
if (badmsg)
- adios (NULL, "re-format message and try again");
+ adios(NULL, "re-format message and try again");
}
static int
-get_header (char *header, struct headers *table)
+get_header(char *header, struct headers *table)
{
struct headers *h;
for (h = table; h->value; h++)
- if (!mh_strcasecmp (header, h->value))
+ if (!mh_strcasecmp(header, h->value))
return (h - table);
return NOTOK;
** of the list. Alias substitution should be done on nl.
*/
static void
-putadr (char *name, struct mailname *nl)
+putadr(char *name, struct mailname *nl)
{
register struct mailname *mp, *mp2;
register int linepos;
register char *cp;
int namelen;
- fprintf (out, "%s: ", name);
+ fprintf(out, "%s: ", name);
namelen = strlen(name) + 2;
linepos = namelen;
for (mp = nl; mp; ) {
if (linepos > MAX_SM_FIELD) {
- fprintf (out, "\n%s: ", name);
+ fprintf(out, "\n%s: ", name);
linepos = namelen;
}
if (mp->m_nohost) {
/* an alias - expand it */
while ((cp = getname(cp))) {
if (linepos > MAX_SM_FIELD) {
- fprintf (out, "\n%s: ", name);
+ fprintf(out, "\n%s: ", name);
linepos = namelen;
}
mp2 = getm( cp, NULL, 0, AD_HOST, NULL);
}
static int
-putone (char *adr, int pos, int indent)
+putone(char *adr, int pos, int indent)
{
register int len;
static int linepos;
len = strlen( adr );
if (pos == indent)
linepos = pos;
- else if ( linepos+len > outputlinelen ) {
- fprintf ( out, ",\n%*s", indent, "");
+ else if (linepos+len > outputlinelen) {
+ fprintf( out, ",\n%*s", indent, "");
linepos = indent;
pos += indent + 2;
} else {
static void
-insert_fcc (struct headers *hdr, unsigned char *pp)
+insert_fcc(struct headers *hdr, unsigned char *pp)
{
unsigned char *cp;
- for (cp = pp; isspace (*cp); cp++)
+ for (cp = pp; isspace(*cp); cp++)
continue;
- for (pp += strlen (pp) - 1; pp > cp && isspace (*pp); pp--)
+ for (pp += strlen(pp) - 1; pp > cp && isspace(*pp); pp--)
continue;
if (pp >= cp)
*++pp = 0;
return;
if (fccind >= FCCS)
- adios (NULL, "too many %ss", hdr->value);
- fccfold[fccind++] = getcpy (cp);
+ adios(NULL, "too many %ss", hdr->value);
+ fccfold[fccind++] = getcpy(cp);
}
#if 0
/* BCC GENERATION */
static void
-make_bcc_file (void)
+make_bcc_file(void)
{
pid_t child_id;
int fd, i, status;
#ifdef HAVE_MKSTEMP
fd = mkstemp(bccfil);
if (fd == -1 || (out = fdopen(fd, "w")) == NULL)
- adios (bccfil, "unable to create");
+ adios(bccfil, "unable to create");
#else
- mktemp (bccfil);
- if ((out = fopen (bccfil, "w")) == NULL)
- adios (bccfil, "unable to create");
+ mktemp(bccfil);
+ if ((out = fopen(bccfil, "w")) == NULL)
+ adios(bccfil, "unable to create");
#endif
- chmod (bccfil, 0600);
+ chmod(bccfil, 0600);
- fprintf (out, "Date: %s\n", dtimenow (0));
+ fprintf(out, "Date: %s\n", dtimenow(0));
if (msgflags & MFRM) {
/* There was already a From: in the draft. Don't add one. */
if (!draft_from_masquerading)
** address in a Sender: header (and use it as the envelope
** From: later).
*/
- fprintf (out, "Sender: %s\n", from);
+ fprintf(out, "Sender: %s\n", from);
} else
- /* Construct a From: header. */
- fprintf (out, "From: %s\n", signature);
+ /* Construct a From: header. */
+ fprintf(out, "From: %s\n", signature);
if (subject)
- fprintf (out, "Subject: %s", subject);
- fprintf (out, "BCC:\n\n------- Blind-Carbon-Copy\n\n");
- fflush (out);
+ fprintf(out, "Subject: %s", subject);
+ fprintf(out, "BCC:\n\n------- Blind-Carbon-Copy\n\n");
+ fflush(out);
if (filter == NULL) {
- if ((fd = open (tmpfil, O_RDONLY)) == NOTOK)
- adios (NULL, "unable to re-open");
- cpydgst (fd, fileno (out), tmpfil, bccfil);
- close (fd);
+ if ((fd = open(tmpfil, O_RDONLY)) == NOTOK)
+ adios(NULL, "unable to re-open");
+ cpydgst(fd, fileno(out), tmpfil, bccfil);
+ close(fd);
} else {
- vec[0] = r1bindex (mhlproc, '/');
+ vec[0] = r1bindex(mhlproc, '/');
for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case NOTOK:
- adios ("vfork", "unable to");
+ adios("vfork", "unable to");
case OK:
- dup2 (fileno (out), 1);
+ dup2(fileno(out), 1);
i = 1;
vec[i++] = "-forward";
vec[i++] = tmpfil;
vec[i] = NULL;
- execvp (mhlproc, vec);
- adios (mhlproc, "unable to exec");
+ execvp(mhlproc, vec);
+ adios(mhlproc, "unable to exec");
default:
if (status = pidwait(child_id, OK))
- admonish (NULL, "%s lost (status=0%o)",
+ admonish(NULL, "%s lost (status=0%o)",
vec[0], status);
break;
}
}
- fseek (out, 0L, SEEK_END);
- fprintf (out, "\n------- End of Blind-Carbon-Copy\n");
- fclose (out);
+ fseek(out, 0L, SEEK_END);
+ fprintf(out, "\n------- End of Blind-Carbon-Copy\n");
+ fclose(out);
}
#endif /* if 0 */
/* FCC INTERACTION */
static void
-file (char *path)
+file(char *path)
{
int i;
return;
for (i = 0; i < fccind; i++)
- fcc (path, fccfold[i]);
+ fcc(path, fccfold[i]);
}
static void
-fcc (char *file, char *folder)
+fcc(char *file, char *folder)
{
pid_t child_id;
int i, status;
char fold[BUFSIZ];
if (verbose)
- printf ("%sFcc: %s\n", msgstate == resent ? "Resent-" : "", folder);
- fflush (stdout);
+ printf("%sFcc: %s\n", msgstate == resent ? "Resent-" : "",
+ folder);
+ fflush(stdout);
for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case NOTOK:
if (!verbose)
- fprintf (stderr, " %sFcc %s: ",
- msgstate == resent ? "Resent-" : "", folder);
- fprintf (verbose ? stdout : stderr, "no forks, so not ok\n");
+ fprintf(stderr, " %sFcc %s: ",
+ msgstate == resent ?
+ "Resent-" : "", folder);
+ fprintf(verbose ? stdout : stderr, "no forks, so not ok\n");
break;
case OK:
- snprintf (fold, sizeof(fold), "%s%s",
+ snprintf(fold, sizeof(fold), "%s%s",
*folder == '+' || *folder == '@' ? "" : "+", folder);
- execlp (fileproc, r1bindex (fileproc, '/'),
+ execlp(fileproc, r1bindex(fileproc, '/'),
"-link", "-file", file, fold, NULL);
- _exit (-1);
+ _exit(-1);
default:
if ((status = pidwait(child_id, OK))) {
if (!verbose)
- fprintf (stderr, " %sFcc %s: ",
- msgstate == resent ? "Resent-" : "", folder);
- fprintf (verbose ? stdout : stderr,
- " errored (0%o)\n", status);
+ fprintf(stderr, " %sFcc %s: ",
+ msgstate == resent ?
+ "Resent-" : "",
+ folder);
+ fprintf(verbose ? stdout : stderr,
+ " errored (0%o)\n", status);
}
}
- fflush (stdout);
+ fflush(stdout);
}
*/
static void
-die (char *what, char *fmt, ...)
+die(char *what, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- advertise (what, NULL, fmt, ap);
+ advertise(what, NULL, fmt, ap);
va_end(ap);
- done (1);
+ done(1);
}
#endif
if (inited++)
return;
- if (!(term = getenv ("TERM")))
+ if (!(term = getenv("TERM")))
return;
/*
** If possible, we let tgetent allocate its own termcap buffer
*/
#ifdef TGETENT_ACCEPTS_NULL
- if (tgetent (NULL, term) != TGETENT_SUCCESS)
+ if (tgetent(NULL, term) != TGETENT_SUCCESS)
return;
#else
- if (tgetent (termbuf, term) != TGETENT_SUCCESS)
+ if (tgetent(termbuf, term) != TGETENT_SUCCESS)
return;
#endif
# endif
#endif
- HC = tgetflag ("hc");
+ HC = tgetflag("hc");
- if (!initCO && (CO = tgetnum ("co")) <= 0)
+ if (!initCO && (CO = tgetnum("co")) <= 0)
CO = 80;
- if (!initLI && (LI = tgetnum ("li")) <= 0)
+ if (!initLI && (LI = tgetnum("li")) <= 0)
LI = 24;
cp = termcap;
- CL = tgetstr ("cl", &cp);
- if ((bp = tgetstr ("pc", &cp)))
+ CL = tgetstr("cl", &cp);
+ if ((bp = tgetstr("pc", &cp)))
PC = *bp;
- if (tgetnum ("sg") <= 0) {
- SE = tgetstr ("se", &cp);
- SO = tgetstr ("so", &cp);
+ if (tgetnum("sg") <= 0) {
+ SE = tgetstr("se", &cp);
+ SO = tgetstr("so", &cp);
}
}
int
-sc_width (void)
+sc_width(void)
{
#ifdef TIOCGWINSZ
struct winsize win;
int width;
- if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
+ if (ioctl(fileno(stderr), TIOCGWINSZ, &win) != NOTOK
&& (width = win.ws_col) > 0) {
CO = width;
initCO++;
int
-sc_length (void)
+sc_length(void)
{
#ifdef TIOCGWINSZ
struct winsize win;
- if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
+ if (ioctl(fileno(stderr), TIOCGWINSZ, &win) != NOTOK
&& (LI = win.ws_row) > 0)
initLI++;
else
static int
-outc (int c)
+outc(int c)
{
return putchar(c);
}
void
-clear_screen (void)
+clear_screen(void)
{
- read_termcap ();
+ read_termcap();
if (CL && speedcode)
- tputs (CL, LI, outc);
+ tputs(CL, LI, outc);
else {
- printf ("\f");
+ printf("\f");
if (speedcode)
- printf ("\200");
+ printf("\200");
}
- fflush (stdout);
+ fflush(stdout);
}
** print in standout mode
*/
int
-SOprintf (char *fmt, ...)
+SOprintf(char *fmt, ...)
{
va_list ap;
- read_termcap ();
+ read_termcap();
if (!(SO && SE))
return NOTOK;
- tputs (SO, 1, outc);
+ tputs(SO, 1, outc);
va_start(ap, fmt);
- vprintf (fmt, ap);
+ vprintf(fmt, ap);
va_end(ap);
- tputs (SE, 1, outc);
+ tputs(SE, 1, outc);
return OK;
}
int ebcdicsw = 0; /* hack for linking purposes */
/* mhmisc.c */
-void set_endian (void);
+void set_endian(void);
/* mhoutsbr.c */
-int writeBase64aux (FILE *, FILE *);
+int writeBase64aux(FILE *, FILE *);
/*
** static prototypes
*/
-static int via_mail (char *, char *, char *, char *, char *, char *);
+static int via_mail(char *, char *, char *, char *, char *, char *);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
char *f1 = NULL, *f2 = NULL, *f3 = NULL;
char *f4 = NULL, *f5 = NULL, *f7 = NULL;
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* foil search of user profile/context */
- if (context_foil (NULL) == -1)
- done (1);
+ if (context_foil(NULL) == -1)
+ done(1);
- arguments = getarguments (invo_name, argc, argv, 0);
+ arguments = getarguments(invo_name, argc, argv, 0);
argp = arguments;
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches]",
+ snprintf(buf, sizeof(buf), "%s [switches]",
invo_name);
- print_help (buf, switches, 1);
- done (1);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case TOSW:
if (!(f1 = *argp++))
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
case SUBJECTSW:
if (!(f2 = *argp++))
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
case PARAMSW:
if (!(f3 = *argp++))
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
case DESCRIPTSW:
if (!(f4 = *argp++))
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
case COMMENTSW:
if (!(f5 = *argp++))
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
case FROMSW:
if (!(f7 = *argp++))
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
}
}
- set_endian ();
+ set_endian();
if (!f1)
- adios (NULL, "missing -viamail \"mailpath\" switch");
+ adios(NULL, "missing -viamail \"mailpath\" switch");
- via_mail (f1, f2, f3, f4, f5, f7);
+ via_mail(f1, f2, f3, f4, f5, f7);
return 0; /* dead code to satisfy the compiler */
}
*/
static int
-via_mail (char *mailsw, char *subjsw, char *parmsw, char *descsw,
+via_mail(char *mailsw, char *subjsw, char *parmsw, char *descsw,
char *cmntsw, char *fromsw)
{
int status, vecp = 1;
FILE *fp;
char *tfile = NULL;
- umask (~m_gmprot ());
+ umask(~m_gmprot());
tfile = m_mktemp2(NULL, invo_name, NULL, &fp);
- if (tfile == NULL) adios("viamail", "unable to create temporary file");
+ if (tfile == NULL)
+ adios("viamail", "unable to create temporary file");
chmod(tfile, 0600);
- strncpy (tmpfil, tfile, sizeof(tmpfil));
+ strncpy(tmpfil, tfile, sizeof(tmpfil));
if (!strchr(mailsw, '@'))
- mailsw = concat (mailsw, "@", LocalName (), NULL);
- fprintf (fp, "To: %s\n", mailsw);
+ mailsw = concat(mailsw, "@", LocalName(), NULL);
+ fprintf(fp, "To: %s\n", mailsw);
if (subjsw)
- fprintf (fp, "Subject: %s\n", subjsw);
+ fprintf(fp, "Subject: %s\n", subjsw);
if (fromsw) {
if (!strchr(fromsw, '@'))
- fromsw = concat (fromsw, "@", LocalName (), NULL);
- fprintf (fp, "From: %s\n", fromsw);
+ fromsw = concat(fromsw, "@", LocalName(), NULL);
+ fprintf(fp, "From: %s\n", fromsw);
}
- fprintf (fp, "%s: %s\n", VRSN_FIELD, VRSN_VALUE);
- fprintf (fp, "%s: application/octet-stream", TYPE_FIELD);
+ fprintf(fp, "%s: %s\n", VRSN_FIELD, VRSN_VALUE);
+ fprintf(fp, "%s: application/octet-stream", TYPE_FIELD);
if (parmsw)
- fprintf (fp, "; %s", parmsw);
+ fprintf(fp, "; %s", parmsw);
if (cmntsw)
- fprintf (fp, "\n\t(%s)", cmntsw);
+ fprintf(fp, "\n\t(%s)", cmntsw);
if (descsw)
- fprintf (fp, "\n%s: %s", DESCR_FIELD, descsw);
+ fprintf(fp, "\n%s: %s", DESCR_FIELD, descsw);
- fprintf (fp, "\n%s: %s\n\n", ENCODING_FIELD, "base64");
+ fprintf(fp, "\n%s: %s\n\n", ENCODING_FIELD, "base64");
- if (fflush (fp))
- adios (tmpfil, "error writing to");
+ if (fflush(fp))
+ adios(tmpfil, "error writing to");
- writeBase64aux (stdin, fp);
- if (fflush (fp))
- adios (tmpfil, "error writing to");
+ writeBase64aux(stdin, fp);
+ if (fflush(fp))
+ adios(tmpfil, "error writing to");
- if (fstat (fileno (fp), &st) == NOTOK)
- adios ("failed", "fstat of %s", tmpfil);
+ if (fstat(fileno(fp), &st) == NOTOK)
+ adios("failed", "fstat of %s", tmpfil);
status = 0;
- vec[0] = r1bindex (postproc, '/');
+ vec[0] = r1bindex(postproc, '/');
if (verbsw)
vec[vecp++] = "-verbose";
- switch (sendsbr (vec, vecp, tmpfil, &st, 0, (char *)0, 0)) {
+ switch (sendsbr(vec, vecp, tmpfil, &st, 0, (char *)0, 0)) {
case DONE:
case NOTOK:
status++;
break;
}
- fclose (fp);
- if (unlink (tmpfil) == -1)
- advise (NULL, "unable to remove temp file %s", tmpfil);
- done (status);
+ fclose(fp);
+ if (unlink(tmpfil) == -1)
+ advise(NULL, "unable to remove temp file %s", tmpfil);
+ done(status);
return 1;
}
#include <h/mh.h>
/* from whatnowsbr.c */
-int WhatNow (int, char **);
+int WhatNow(int, char **);
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- return WhatNow (argc, argv);
+ return WhatNow(argc, argv);
}
*/
/* from whatnowsbr.c */
-int WhatNow (int, char **);
+int WhatNow(int, char **);
int
-what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist,
+what_now(char *ed, int nedit, int use, char *file, char *altmsg, int dist,
struct msgs *mp, char *text, int inplace, char *cwd)
{
int found, k, msgnum, vecp;
char buffer[BUFSIZ], *vec[MAXARGS];
vecp = 0;
- vec[vecp++] = r1bindex (whatnowproc, '/');
+ vec[vecp++] = r1bindex(whatnowproc, '/');
vec[vecp] = NULL;
- m_putenv ("mhdraft", file);
+ m_putenv("mhdraft", file);
if (mp)
- m_putenv ("mhfolder", mp->foldpath);
+ m_putenv("mhfolder", mp->foldpath);
else
- unputenv ("mhfolder");
+ unputenv("mhfolder");
if (altmsg) {
if (mp == NULL || *altmsg == '/' || cwd == NULL)
- m_putenv ("mhaltmsg", altmsg);
+ m_putenv("mhaltmsg", altmsg);
else {
- snprintf (buffer, sizeof(buffer), "%s/%s",
+ snprintf(buffer, sizeof(buffer), "%s/%s",
mp->foldpath, altmsg);
- m_putenv ("mhaltmsg", buffer);
+ m_putenv("mhaltmsg", buffer);
}
} else {
- unputenv ("mhaltmsg");
+ unputenv("mhaltmsg");
}
- if ((bp = getenv ("mhaltmsg")))/* XXX */
- m_putenv ("editalt", bp);
- snprintf (buffer, sizeof(buffer), "%d", dist);
- m_putenv ("mhdist", buffer);
+ if ((bp = getenv("mhaltmsg")))/* XXX */
+ m_putenv("editalt", bp);
+ snprintf(buffer, sizeof(buffer), "%d", dist);
+ m_putenv("mhdist", buffer);
if (nedit) {
- unputenv ("mheditor");
+ unputenv("mheditor");
} else {
- m_putenv ("mheditor", ed ? ed : (ed = context_find ("editor"))
- ? ed : defaulteditor);
+ m_putenv("mheditor", ed ? ed : (ed = context_find("editor")) ?
+ ed : defaulteditor);
}
- snprintf (buffer, sizeof(buffer), "%d", use);
- m_putenv ("mhuse", buffer);
+ snprintf(buffer, sizeof(buffer), "%d", use);
+ m_putenv("mhuse", buffer);
- unputenv ("mhmessages");
- unputenv ("mhannotate");
- unputenv ("mhinplace");
+ unputenv("mhmessages");
+ unputenv("mhannotate");
+ unputenv("mhinplace");
if (text && mp && !is_readonly(mp)) {
found = 0;
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));
- len = strlen (bp);
+ 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));
- len = strlen (bp);
+ snprintf(bp, buflen, "-%s", m_name(k));
+ len = strlen(bp);
bp += len;
buflen -= len;
}
}
}
if (found) {
- m_putenv ("mhmessages", buffer);
- m_putenv ("mhannotate", text);
- snprintf (buffer, sizeof(buffer), "%d", inplace);
- m_putenv ("mhinplace", buffer);
+ m_putenv("mhmessages", buffer);
+ m_putenv("mhannotate", text);
+ snprintf(buffer, sizeof(buffer), "%d", inplace);
+ m_putenv("mhinplace", buffer);
}
}
- context_save (); /* save the context file */
- fflush (stdout);
+ context_save(); /* save the context file */
+ fflush(stdout);
if (cwd)
- chdir (cwd);
+ chdir(cwd);
/*
** 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);
+ if (strcmp(vec[0], "whatnow") == 0) {
+ WhatNow(vecp, vec);
+ done(0);
}
- execvp (whatnowproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (whatnowproc);
+ execvp(whatnowproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(whatnowproc);
return 0;
}
/*
** static prototypes
*/
-static int editfile (char **, char **, char *, int, struct msgs *,
+static int editfile(char **, char **, char *, int, struct msgs *,
char *, char *, int);
-static int sendfile (char **, char *, int);
-static void sendit (char *, char **, char *, int);
-static int buildfile (char **, char *);
-static int check_draft (char *);
-static int removefile (char *);
+static int sendfile(char **, char *, int);
+static void sendit(char *, char **, char *, int);
+static int buildfile(char **, char *);
+static int check_draft(char *);
+static int removefile(char *);
static void writelscmd(char *, int, char **);
static void writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp);
static FILE* popen_in_dir(const char *dir, const char *cmd, const char *type);
#ifdef HAVE_LSTAT
-static int copyf (char *, char *);
+static int copyf(char *, char *);
#endif
int
-WhatNow (int argc, char **argv)
+WhatNow(int argc, char **argv)
{
int nedit = 0, use = 0;
char *cp;
char *l; /* set on -l to alist command */
int n; /* set on -n to alist command */
- invo_name = r1bindex (argv[0], '/');
+ invo_name = r1bindex(argv[0], '/');
/* read user profile/context */
context_read();
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/*
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, whatnowswitches)) {
+ switch (smatch(++cp, whatnowswitches)) {
case AMBIGSW:
- ambigsw (cp, whatnowswitches);
- done (1);
+ ambigsw(cp, whatnowswitches);
+ done(1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf),
+ snprintf(buf, sizeof(buf),
"%s [switches] [file]",
invo_name);
- print_help (buf, whatnowswitches, 1);
- done (1);
+ print_help(buf, whatnowswitches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case EDITRSW:
if (!(ed = *argp++) || *ed == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
nedit = 0;
continue;
case PRMPTSW:
if (!(myprompt = *argp++) || *myprompt == '-')
- adios (NULL, "missing argument to %s",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
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",
+ adios(NULL, "missing argument to %s",
argp[-2]);
continue;
}
}
if (drft)
- adios (NULL, "only one draft at a time!");
+ adios(NULL, "only one draft at a time!");
else
drft = cp;
}
if ((drft == NULL && (drft = getenv("mhdraft")) == NULL) || *drft == 0)
- drft = getcpy (m_draft("cur"));
+ drft = getcpy(m_draft("cur"));
- msgnam = (cp = getenv ("mhaltmsg")) && *cp ? getcpy (cp) : NULL;
+ msgnam = (cp = getenv("mhaltmsg")) && *cp ? getcpy(cp) : NULL;
- if ((cp = getenv ("mhuse")) && *cp)
- use = atoi (cp);
+ if ((cp = getenv("mhuse")) && *cp)
+ use = atoi(cp);
- if (ed == NULL && ((ed = getenv ("mheditor")) == NULL || *ed == 0)) {
+ if (ed == NULL && ((ed = getenv("mheditor")) == NULL || *ed == 0)) {
ed = NULL;
nedit++;
}
/* start editing the draft, unless -noedit was given */
if (!nedit && editfile(&ed, NULL, drft, use, NULL, msgnam, NULL, 1)
< 0)
- done (1);
+ done(1);
- snprintf (prompt, sizeof(prompt), myprompt, invo_name);
+ snprintf(prompt, sizeof(prompt), myprompt, invo_name);
for (;;) {
- if (!(argp = getans (prompt, aleqs))) {
- unlink (altmsglink);
- done (1);
+ if (!(argp = getans(prompt, aleqs))) {
+ unlink(altmsglink);
+ done(1);
}
- switch (smatch (*argp, aleqs)) {
+ switch (smatch(*argp, aleqs)) {
case DISPSW:
/*
** display the message being replied to,
** or distributed
*/
if (msgnam)
- showfile (++argp, msgnam);
+ showfile(++argp, msgnam);
else
- advise (NULL, "no alternate message to display");
+ advise(NULL, "no alternate message to display");
break;
case BUILDMIMESW:
/* Translate MIME composition file */
- buildfile (++argp, drft);
+ buildfile(++argp, drft);
break;
case EDITSW:
/* Call an editor on the draft file */
if (*++argp)
ed = *argp++;
- if (editfile (&ed, argp, drft, NOUSE, NULL,
+ if (editfile(&ed, argp, drft, NOUSE, NULL,
msgnam, NULL, 1) == NOTOK)
- done (1);
+ done(1);
break;
case LISTSW:
/* display the draft file */
- showfile (++argp, drft);
+ showfile(++argp, drft);
break;
case QUITSW:
/* Quit, and possibly delete the draft */
if (*++argp && (*argp[0] == 'd' ||
((*argp)[0] == '-' && (*argp)[1] == 'd'))) {
- removefile (drft);
+ removefile(drft);
} else {
- if (stat (drft, &st) != NOTOK)
+ if (stat(drft, &st) != NOTOK)
advise(NULL, "draft left on %s", drft);
}
- done (1);
+ done(1);
case DELETESW:
/* Delete draft and exit */
- removefile (drft);
- done (1);
+ removefile(drft);
+ done(1);
case PUSHSW:
/* Send draft in background */
- if (sendfile (++argp, drft, 1))
- done (1);
+ if (sendfile(++argp, drft, 1))
+ done(1);
break;
case SENDSW:
/* Send draft */
- sendfile (++argp, drft, 0);
+ sendfile(++argp, drft, 0);
break;
case REFILEOPT:
/* Refile the draft */
- if (refile (++argp, drft) == 0)
- done (0);
+ if (refile(++argp, drft) == 0)
+ done(0);
break;
case CDCMDSW:
default:
/* Unknown command */
- advise (NULL, "say what?");
+ advise(NULL, "say what?");
break;
}
}
static int
-editfile (char **ed, char **arg, char *file, int use, struct msgs *mp,
+editfile(char **ed, char **arg, char *file, int use, struct msgs *mp,
char *altmsg, char *cwd, int save_editor)
{
int pid, status, vecp;
if (reedit) {
if (!*ed) { /* no explicit editor */
*ed = edsave; /* so use the previous one */
- if ((cp = r1bindex (*ed, '/')) == NULL)
+ if ((cp = r1bindex(*ed, '/')) == NULL)
cp = *ed;
/* unless we've specified it via "editor-next" */
- cp = concat (cp, "-next", NULL);
- if ((cp = context_find (cp)) != NULL)
+ cp = concat(cp, "-next", NULL);
+ if ((cp = context_find(cp)) != NULL)
*ed = cp;
}
} else {
/* set initial editor */
- if (*ed == NULL && (*ed = context_find ("editor")) == NULL)
+ if (*ed == NULL && (*ed = context_find("editor")) == NULL)
*ed = defaulteditor;
}
if (altmsg) {
if (mp == NULL || *altmsg == '/' || cwd == NULL)
- strncpy (altpath, altmsg, sizeof(altpath));
+ strncpy(altpath, altmsg, sizeof(altpath));
else
- snprintf (altpath, sizeof(altpath), "%s/%s",
+ snprintf(altpath, sizeof(altpath), "%s/%s",
mp->foldpath, altmsg);
if (cwd == NULL)
- strncpy (linkpath, altmsglink, sizeof(linkpath));
+ strncpy(linkpath, altmsglink, sizeof(linkpath));
else
- snprintf (linkpath, sizeof(linkpath), "%s/%s",
+ snprintf(linkpath, sizeof(linkpath), "%s/%s",
cwd, altmsglink);
}
if (altmsg) {
- unlink (linkpath);
+ unlink(linkpath);
#ifdef HAVE_LSTAT
- if (link (altpath, linkpath) == NOTOK) {
+ if (link(altpath, linkpath) == NOTOK) {
#if 0
/* I don't think permission on symlinks matters /JLR */
/* PJS: else symlinks are world 'r' */
oumask = umask(0044);
#endif
- symlink (altpath, linkpath);
+ symlink(altpath, linkpath);
#if 0
umask(oumask); /* PJS: else symlinks are world 'r' */
#endif
slinked = 0;
}
#else /* not HAVE_LSTAT */
- link (altpath, linkpath);
+ link(altpath, linkpath);
#endif /* not HAVE_LSTAT */
}
- context_save (); /* save the context file */
- fflush (stdout);
+ context_save(); /* save the context file */
+ fflush(stdout);
- switch (pid = vfork ()) {
+ switch (pid = vfork()) {
case NOTOK:
- advise ("fork", "unable to");
+ advise("fork", "unable to");
status = NOTOK;
break;
case OK:
if (cwd)
- chdir (cwd);
+ chdir(cwd);
if (altmsg) {
if (mp)
- m_putenv ("mhfolder", mp->foldpath);
- m_putenv ("editalt", altpath);
+ m_putenv("mhfolder", mp->foldpath);
+ m_putenv("editalt", altpath);
}
vecp = 0;
- vec[vecp++] = r1bindex (*ed, '/');
+ vec[vecp++] = r1bindex(*ed, '/');
if (arg)
while (*arg)
vec[vecp++] = *arg++;
vec[vecp++] = file;
vec[vecp] = NULL;
- execvp (*ed, vec);
- fprintf (stderr, "unable to exec ");
- perror (*ed);
- _exit (-1);
+ execvp(*ed, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(*ed);
+ _exit(-1);
default:
- if ((status = pidwait (pid, NOTOK))) {
+ if ((status = pidwait(pid, NOTOK))) {
#ifdef ATTVIBUG
- if ((cp = r1bindex (*ed, '/'))
- && strcmp (cp, "vi") == 0
- && (status & 0x00ff) == 0)
+ if ((cp = r1bindex(*ed, '/')) &&
+ strcmp(cp, "vi") == 0 &&
+ (status & 0x00ff) == 0)
status = 0;
else {
#endif
if (((status & 0xff00) != 0xff00)
&& (!reedit || (status & 0x00ff))) {
- if (!use && (status & 0xff00) &&
- (rename (file, cp = m_backup (file)) != NOTOK)) {
- advise (NULL, "problems with edit--draft left in %s", cp);
+ if (!use && (status & 0xff00) && (rename(file, cp = m_backup (file)) != NOTOK)) {
+ advise(NULL, "problems with edit--draft left in %s", cp);
} else {
- advise (NULL, "problems with edit--%s preserved", file);
+ advise(NULL, "problems with edit--%s preserved", file);
}
}
status = -2; /* maybe "reedit ? -2 : -1"? */
reedit++;
#ifdef HAVE_LSTAT
- if (altmsg
- && mp
- && !is_readonly(mp)
- && (slinked
- ? lstat (linkpath, &st) != NOTOK
- && S_ISREG(st.st_mode)
- && copyf (linkpath, altpath) == NOTOK
- : stat (linkpath, &st) != NOTOK
- && st.st_nlink == 1
- && (unlink (altpath) == NOTOK
- || link (linkpath, altpath) == NOTOK)))
- advise (linkpath, "unable to update %s from", altmsg);
+ if (altmsg && mp && !is_readonly(mp) && (slinked ?
+ lstat (linkpath, &st) != NOTOK &&
+ S_ISREG(st.st_mode) &&
+ copyf(linkpath, altpath) == NOTOK :
+ stat(linkpath, &st) != NOTOK &&
+ st.st_nlink == 1 &&
+ (unlink(altpath) == NOTOK ||
+ link(linkpath, altpath) == NOTOK)))
+ advise(linkpath, "unable to update %s from", altmsg);
#else /* HAVE_LSTAT */
- 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",
+ 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);
#endif /* HAVE_LSTAT */
}
/* normally, we remember which editor we used */
if (save_editor)
- edsave = getcpy (*ed);
+ edsave = getcpy(*ed);
*ed = NULL;
if (altmsg)
- unlink (linkpath);
+ unlink(linkpath);
return status;
}
#ifdef HAVE_LSTAT
static int
-copyf (char *ifile, char *ofile)
+copyf(char *ifile, char *ofile)
{
int i, in, out;
char buffer[BUFSIZ];
- if ((in = open (ifile, O_RDONLY)) == NOTOK)
+ if ((in = open(ifile, O_RDONLY)) == NOTOK)
return NOTOK;
- if ((out = open (ofile, O_WRONLY | O_TRUNC)) == NOTOK) {
- admonish (ofile, "unable to open and truncate");
- close (in);
+ if ((out = open(ofile, O_WRONLY | O_TRUNC)) == NOTOK) {
+ admonish(ofile, "unable to open and truncate");
+ close(in);
return NOTOK;
}
- while ((i = read (in, buffer, sizeof(buffer))) > OK)
- if (write (out, buffer, i) != i) {
- advise (ofile, "may have damaged");
+ while ((i = read(in, buffer, sizeof(buffer))) > OK)
+ if (write(out, buffer, i) != i) {
+ advise(ofile, "may have damaged");
i = NOTOK;
break;
}
- close (in);
- close (out);
+ close(in);
+ close(out);
return i;
}
#endif /* HAVE_LSTAT */
*/
static int
-sendfile (char **arg, char *file, int pushsw)
+sendfile(char **arg, char *file, int pushsw)
{
pid_t child_id;
int i, vecp;
char *cp, *sp, *vec[MAXARGS];
/* Translate MIME composition file, if necessary */
- if ((cp = context_find ("automimeproc")) && (!strcmp (cp, "1"))
- && !getenv ("NOMHNPROC") && check_draft (file)
- && (buildfile (NULL, file) == NOTOK))
+ 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,
+ 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 (strcmp (sp = r1bindex (sendproc, '/'), "send") == 0) {
+ if (strcmp(sp = r1bindex(sendproc, '/'), "send") == 0) {
cp = invo_name;
- sendit (invo_name = sp, arg, file, pushsw);
+ sendit(invo_name = sp, arg, file, pushsw);
invo_name = cp;
return 1;
}
- context_save (); /* save the context file */
- fflush (stdout);
+ context_save(); /* save the context file */
+ fflush(stdout);
for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
- sleep (5);
+ sleep(5);
switch (child_id) {
case NOTOK:
- advise (NULL, "unable to fork, so sending directly...");
+ advise(NULL, "unable to fork, so sending directly...");
case OK:
vecp = 0;
vec[vecp++] = invo_name;
vec[vecp++] = file;
vec[vecp] = NULL;
- execvp (sendproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (sendproc);
- _exit (-1);
+ execvp(sendproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(sendproc);
+ _exit(-1);
default:
if (pidwait(child_id, OK) == 0)
- done (0);
+ done(0);
return 1;
}
}
*/
static int
-buildfile (char **argp, char *file)
+buildfile(char **argp, char *file)
{
int i;
char **args, *ed;
** if we are using mhn as buildmimeproc
*/
i = 0;
- if (strcmp (r1bindex (ed, '/'), "mhn") == 0)
+ if (strcmp(r1bindex(ed, '/'), "mhn") == 0)
args[i++] = "-build";
/* copy any other arguments */
args[i++] = *argp++;
args[i] = NULL;
- i = editfile (&ed, args, file, NOUSE, NULL, NULL, NULL, 0);
- free (args);
+ i = editfile(&ed, args, file, NOUSE, NULL, NULL, NULL, 0);
+ free(args);
return (i ? NOTOK : OK);
}
*/
static int
-check_draft (char *msgnam)
+check_draft(char *msgnam)
{
int state;
char buf[BUFSIZ], name[NAMESZ];
FILE *fp;
- if ((fp = fopen (msgnam, "r")) == NULL)
+ if ((fp = fopen(msgnam, "r")) == NULL)
return 0;
for (state = FLD;;)
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ switch (state = m_getfld(state, name, buf, sizeof(buf), fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
** Content-XXX fields, then assume it already
** been converted.
*/
- if (uprf (name, XXX_FIELD_PRF)) {
- fclose (fp);
+ if (uprf(name, XXX_FIELD_PRF)) {
+ fclose(fp);
return 0;
}
while (state == FLDPLUS)
- state = m_getfld (state, name, buf,
+ state = m_getfld(state, name, buf,
sizeof(buf), fp);
break;
for (bp = buf; *bp; bp++)
if (*bp != ' ' && *bp != '\t' && *bp != '\n') {
- fclose (fp);
+ fclose(fp);
return 1;
}
- state = m_getfld (state, name, buf,
+ state = m_getfld(state, name, buf,
sizeof(buf), fp);
} while (state == BODY);
/* and fall... */
default:
- fclose (fp);
+ fclose(fp);
return 0;
}
}
static void
-sendit (char *sp, char **arg, char *file, int pushed)
+sendit(char *sp, char **arg, char *file, int pushed)
{
int vecp, n = 1;
char *cp, buf[BUFSIZ], **argp;
if (arg) {
char **bp;
- copyip (arg, vec+1, MAXARGS-1);
+ copyip(arg, vec+1, MAXARGS-1);
bp = vec+1;
while (*bp++)
n++;
vecp = 1; /* we'll get the zero'th element later */
vec[vecp++] = "-library";
- vec[vecp++] = getcpy (m_maildir (""));
+ vec[vecp++] = getcpy(m_maildir(""));
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, sendswitches)) {
+ switch (smatch(++cp, sendswitches)) {
case AMBIGSW:
- ambigsw (cp, sendswitches);
+ ambigsw(cp, sendswitches);
return;
case UNKWNSW:
- advise (NULL, "-%s unknown\n", cp);
+ advise(NULL, "-%s unknown\n", cp);
return;
case SHELPSW:
- snprintf (buf, sizeof(buf),
+ snprintf(buf, sizeof(buf),
"%s [switches]", sp);
- print_help (buf, sendswitches, 1);
+ print_help(buf, sendswitches, 1);
return;
case SVERSIONSW:
- print_version (invo_name);
+ print_version(invo_name);
return;
case SPSHSW:
case PORTSW:
vec[vecp++] = --cp;
if (!(cp = *argp++) || *cp == '-') {
- advise (NULL, "missing argument to %s", argp[-2]);
+ advise(NULL, "missing argument to %s", argp[-2]);
return;
}
vec[vecp++] = cp;
case SNDATTACHSW:
if (!(attach = *argp++) ||
*attach == '-') {
- advise (NULL, "missing argument to %s", argp[-2]);
+ advise(NULL, "missing argument to %s", argp[-2]);
return;
}
continue;
case SNDATTACHFORMAT:
if (! *argp || **argp == '-')
- adios (NULL, "missing argument to %s", argp[-1]);
+ adios(NULL, "missing argument to %s", argp[-1]);
else {
- attachformat = atoi (*argp);
+ attachformat = atoi(*argp);
if (attachformat < 0 || attachformat > ATTACHFORMATS - 1) {
- advise (NULL, "unsupported attachformat %d", attachformat);
+ advise(NULL, "unsupported attachformat %d", attachformat);
continue;
}
}
continue;
}
}
- advise (NULL, "usage: %s [switches]", sp);
+ advise(NULL, "usage: %s [switches]", sp);
return;
}
/* allow Aliasfile: profile entry */
- if ((cp = context_find ("Aliasfile"))) {
+ if ((cp = context_find("Aliasfile"))) {
char **ap, *dp;
- dp = getcpy (cp);
- for (ap = brkstring (dp, " ", "\n"); ap && *ap; ap++) {
+ dp = getcpy(cp);
+ for (ap = brkstring(dp, " ", "\n"); ap && *ap; ap++) {
vec[vecp++] = "-alias";
vec[vecp++] = *ap;
}
}
- if ((cp = getenv ("SIGNATURE")) == NULL || *cp == 0)
- if ((cp = context_find ("signature")) && *cp)
- m_putenv ("SIGNATURE", cp);
+ if ((cp = getenv("SIGNATURE")) == NULL || *cp == 0)
+ if ((cp = context_find("signature")) && *cp)
+ m_putenv("SIGNATURE", cp);
#ifdef UCI
else {
- snprintf (buf, sizeof(buf), "%s/.signature", mypath);
- if ((fp = fopen (buf, "r")) != NULL
- && fgets (buf, sizeof(buf), fp) != NULL) {
- fclose (fp);
- if (cp = strchr (buf, '\n'))
- *cp = 0;
- m_putenv ("SIGNATURE", buf);
+ snprintf(buf, sizeof(buf), "%s/.signature", mypath);
+ if ((fp = fopen(buf, "r")) != NULL &&
+ fgets(buf, sizeof(buf), fp) != NULL) {
+ fclose(fp);
+ if (cp = strchr(buf, '\n'))
+ *cp = 0;
+ m_putenv("SIGNATURE", buf);
}
}
#endif /* UCI */
- if ((annotext = getenv ("mhannotate")) == NULL || *annotext == 0)
+ if ((annotext = getenv("mhannotate")) == NULL || *annotext == 0)
annotext = NULL;
- if ((altmsg = getenv ("mhaltmsg")) == NULL || *altmsg == 0)
+ if ((altmsg = getenv("mhaltmsg")) == NULL || *altmsg == 0)
altmsg = NULL;
- if (annotext && ((cp = getenv ("mhinplace")) != NULL && *cp != 0))
- inplace = atoi (cp);
+ if (annotext && ((cp = getenv("mhinplace")) != NULL && *cp != 0))
+ inplace = atoi(cp);
- if ((cp = getenv ("mhdist"))
- && *cp
+ if ((cp = getenv("mhdist")) && *cp
#ifndef lint
&& (distsw = atoi (cp))
#endif /* not lint */
&& altmsg) {
vec[vecp++] = "-dist";
- distfile = getcpy (m_mktemp2(altmsg, invo_name, NULL, NULL));
- if (link (altmsg, distfile) == NOTOK)
- adios (distfile, "unable to link %s to", altmsg);
+ distfile = getcpy(m_mktemp2(altmsg, invo_name, NULL, NULL));
+ if (link(altmsg, distfile) == NOTOK)
+ adios(distfile, "unable to link %s to", altmsg);
} else {
distfile = NULL;
}
- if (altmsg == NULL || stat (altmsg, &st) == NOTOK) {
+ if (altmsg == NULL || stat(altmsg, &st) == NOTOK) {
st.st_mtime = 0;
st.st_dev = 0;
st.st_ino = 0;
}
if ((pushsw = pushed))
- push ();
+ push();
- vec[0] = r1bindex (postproc, '/');
- closefds (3);
+ vec[0] = r1bindex(postproc, '/');
+ closefds(3);
- if (sendsbr (vec, vecp, file, &st, 1, attach, attachformat) == OK)
- done (0);
+ if (sendsbr(vec, vecp, file, &st, 1, attach, attachformat) == OK)
+ done(0);
}
*/
static int
-removefile (char *drft)
+removefile(char *drft)
{
- if (unlink (drft) == NOTOK)
- adios (drft, "unable to unlink");
+ if (unlink(drft) == NOTOK)
+ adios(drft, "unable to unlink");
return OK;
}