2 ** slocal.c -- asynchronously filter and deliver new mail
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
10 ** Under sendmail, users should add the line
12 ** "| /usr/local/mmh/bin/slocal"
14 ** to their $HOME/.forward file.
18 /* Changed to use getutent() and friends. Assumes that when getutent() exists,
19 ** a number of other things also exist. Please check.
20 ** Ruud de Rooij <ruud@ruud.org> Sun, 28 May 2000 17:28:55 +0200
24 #include <h/rcvmail.h>
25 #include <h/signals.h>
31 #include <sys/ioctl.h>
34 #ifdef INITGROUPS_HEADER
35 #include INITGROUPS_HEADER
38 ** On AIX 4.1, initgroups() is defined and even documented (giving the
39 ** parameter types as char* and int), but doesn't have a prototype in any
40 ** of the system header files. AIX 4.3, SunOS 4.1.3, and ULTRIX 4.2A have
43 extern int initgroups(char*, int);
51 # define UTMP_FILE _PATH_UTMP
53 # define UTMP_FILE "/etc/utmp"
58 static struct swit switches[] = {
60 { "addr address", 0 },
66 { "sender address", 0 },
68 { "mailbox file", 0 },
70 { "home directory", -4 },
74 { "maildelivery file", 0 },
89 /* global maildelivery file */
90 char *maildelivery = NMHETCDIR"/maildelivery";
93 static int globbed = 0; /* have we built "vars" table yet? */
94 static int parsed = 0; /* have we built header field table yet */
95 static int utmped = 0; /* have we scanned umtp(x) file yet */
97 static int verbose = 0;
100 static char *addr = NULL;
101 static char *user = NULL;
102 static char *info = NULL;
103 static char *file = NULL;
104 static char *sender = NULL;
105 static char *envelope = NULL; /* envelope information ("From " line) */
106 static char *mbox = NULL;
107 static char *home = NULL;
109 static struct passwd *pw; /* passwd file entry */
111 static char ddate[BUFSIZ]; /* record the delivery date */
114 static jmp_buf myctx;
116 /* flags for pair->p_flags */
118 #define P_ADR 0x01 /* field is address */
119 #define P_HID 0x02 /* special (fake) field */
131 ** Lookup table for matching fields and patterns
132 ** in messages. The rest of the table is added
133 ** when the message is parsed.
135 static struct pair hdrs[NVEC + 1] = {
136 { "source", NULL, P_HID },
137 { "addr", NULL, P_HID },
138 { "Return-Path", NULL, P_ADR },
139 { "Reply-To", NULL, P_ADR },
140 { "From", NULL, P_ADR },
141 { "Sender", NULL, P_ADR },
142 { "To", NULL, P_ADR },
143 { "cc", NULL, P_ADR },
144 { "Resent-Reply-To", NULL, P_ADR },
145 { "Resent-From", NULL, P_ADR },
146 { "Resent-Sender", NULL, P_ADR },
147 { "Resent-To", NULL, P_ADR },
148 { "Resent-Cc", NULL, P_ADR },
153 ** The list of builtin variables to expand in a string
154 ** before it is executed by the "pipe" or "qpipe" action.
156 static struct pair vars[] = {
157 { "sender", NULL, P_NIL },
158 { "address", NULL, P_NIL },
159 { "size", NULL, P_NIL },
160 { "reply-to", NULL, P_CHK },
161 { "info", NULL, P_NIL },
165 extern char **environ;
170 static int localmail(int, char *);
171 static int usr_delivery(int, char *, int);
172 static int split(char *, char **);
173 static int parse(int);
174 static void expand(char *, char *, int);
175 static void glob(int);
176 static struct pair *lookup(struct pair *, char *);
177 static int logged_in(void);
178 static int timely(char *, char *);
179 static int usr_file(int, char *);
180 static int usr_pipe(int, char *, char *, char **, int);
181 static int usr_folder(int, char *);
182 static RETSIGTYPE alrmser(int);
183 static void get_sender(char *, char **);
184 static int copy_message(int, char *, int);
185 static void verbose_printf(char *fmt, ...);
186 static void adorn(char *, char *, ...);
187 static void debug_printf(char *fmt, ...);
188 static char *trim(char *);
192 main(int argc, char **argv)
196 char *cp, *mdlvr = NULL, buf[BUFSIZ];
197 char mailbox[BUFSIZ], tmpfil[BUFSIZ];
198 char **argp, **arguments;
201 setlocale(LC_ALL, "");
203 invo_name = mhbasename(*argv);
205 /* foil search of user profile/context */
206 if (context_foil(NULL) == -1) {
209 arguments = getarguments(invo_name, argc, argv, 0);
212 /* Parse arguments */
213 while ((cp = *argp++)) {
215 switch (smatch(++cp, switches)) {
217 ambigsw(cp, switches);
220 adios(NULL, "-%s unknown", cp);
223 snprintf(buf, sizeof(buf), "%s [switches] [address info sender]", invo_name);
224 print_help(buf, switches, 0);
227 print_version(invo_name);
231 if (!(addr = *argp++)) {
232 /* allow -xyz arguments */
233 adios(NULL, "missing argument to %s",
238 if (!(info = *argp++)) {
239 /* allow -xyz arguments */
240 adios(NULL, "missing argument to %s",
245 if (!(user = *argp++)) {
246 /* allow -xyz arguments */
247 adios(NULL, "missing argument to %s",
252 if (!(file = *argp++) || *file == '-') {
253 adios(NULL, "missing argument to %s",
258 if (!(sender = *argp++)) {
259 /* allow -xyz arguments */
260 adios(NULL, "missing argument to %s",
265 if (!(mbox = *argp++) || *mbox == '-') {
266 adios(NULL, "missing argument to %s",
271 if (!(home = *argp++) || *home == '-') {
272 adios(NULL, "missing argument to %s",
278 if (!(cp = *argp++) || *cp == '-') {
279 adios(NULL, "missing argument to %s",
283 adios(NULL, "only one maildelivery file at a time!");
301 switch (argp - (argv + 1)) {
315 addr = getusername();
318 user = (cp = strchr(addr, '.')) ? ++cp : addr;
320 if (!(pw = getpwnam(user))) {
321 adios(NULL, "no such local user as %s", user);
324 if (chdir(pw->pw_dir) == -1) {
329 if (geteuid() == 0) {
331 initgroups(pw->pw_name, pw->pw_gid);
341 /* Record the delivery time */
342 if (!(now = dlocaltimenow())) {
343 adios(NULL, "unable to ascertain local time");
345 snprintf(ddate, sizeof(ddate), "Delivery-Date: %s\n", dtimenow(0));
348 ** Copy the message to a temporary file
353 /* getting message from file */
354 if ((tempfd = open(file, O_RDONLY)) == -1) {
355 adios(file, "unable to open");
358 debug_printf("retrieving message from file \"%s\"\n",
361 if ((fd = copy_message(tempfd, tmpfil, 1)) == -1) {
362 adios(NULL, "unable to create temporary file");
366 /* getting message from stdin */
368 debug_printf("retrieving message from stdin\n");
370 if ((fd = copy_message(fileno(stdin), tmpfil, 1)) == -1) {
371 adios(NULL, "unable to create temporary file");
376 debug_printf("temporary file=\"%s\"\n", tmpfil);
380 ** Delete the temp file now or a copy of every single message
381 ** passed through slocal will be left in the /tmp directory until
382 ** deleted manually! This unlink() used to be under an 'else'
383 ** of the 'if (debug)' above, but since some people like to
384 ** always run slocal with -debug and log the results, the /tmp
385 ** directory would get choked over time. Of course, now that
386 ** we always delete the temp file, the "temporary file=" message
387 ** above is somewhat pointless -- someone watching debug output
388 ** wouldn't have a chance to 'tail -f' or 'ln' the temp file
389 ** before it's unlinked. The best thing would be to delay this
390 ** unlink() until later if debug == 1, but I'll leave that for
391 ** someone who cares about the temp-file-accessing functionality
392 ** (they'll have to watch out for cases where we adios()).
396 if (!(fp = fdopen(fd, "r+"))) {
397 adios(NULL, "unable to access temporary file");
400 /* If no sender given, extract it from envelope information. */
402 get_sender(envelope, &sender);
405 snprintf(mailbox, sizeof(mailbox), "%s/%s",
406 mailspool, pw->pw_name);
414 debug_printf("addr=\"%s\"\n", trim(addr));
415 debug_printf("user=\"%s\"\n", trim(user));
416 debug_printf("info=\"%s\"\n", trim(info));
417 debug_printf("sender=\"%s\"\n", trim(sender));
418 debug_printf("envelope=\"%s\"\n",
419 envelope ? trim(envelope) : "");
420 debug_printf("mbox=\"%s\"\n", trim(mbox));
421 debug_printf("home=\"%s\"\n", trim(home));
422 debug_printf("ddate=\"%s\"\n", trim(ddate));
423 debug_printf("now=%02d:%02d\n\n", now->tw_hour, now->tw_min);
426 /* deliver the message */
427 status = localmail(fd, mdlvr);
429 done(status != -1 ? RCV_MOK : RCV_MBX);
435 ** Main routine for delivering message.
438 localmail(int fd, char *mdlvr)
440 /* delivery according to personal Maildelivery file */
441 if (usr_delivery(fd, mdlvr ? mdlvr : ".maildelivery", 0) != -1) {
444 /* delivery according to global Maildelivery file */
445 if (usr_delivery(fd, maildelivery, 1) != -1) {
449 verbose_printf("(delivering to standard mail spool)\n");
451 /* last resort - deliver to standard mail spool */
452 return usr_file(fd, mbox);
456 #define matches(a,b) (stringdex(b, a) >= 0)
459 ** Parse the delivery file, and process incoming message.
462 usr_delivery(int fd, char *delivery, int su)
464 int i, accept, status=1, won, vecp, next;
465 char *field, *pattern, *action, *result, *string;
466 char buffer[BUFSIZ], tmpbuf[BUFSIZ];
467 char *cp, *vec[NVEC];
472 /* open the delivery file */
473 if (!(fp = fopen(delivery, "r"))) {
476 /* check if delivery file has bad ownership or permissions */
477 if (fstat(fileno(fp), &st) == -1 ||
478 (st.st_uid != 0 && (su || st.st_uid != pw->pw_uid)) ||
479 st.st_mode & (S_IWGRP|S_IWOTH)) {
481 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);
489 /* read and process delivery file */
490 while (fgets(buffer, sizeof(buffer), fp)) {
491 /* skip comments and empty lines */
492 if (*buffer == '#' || *buffer == '\n') {
495 /* zap trailing newline */
496 if ((cp = strchr(buffer, '\n'))) {
499 /* split buffer into fields */
500 vecp = split(buffer, vec);
502 /* check for too few fields */
505 debug_printf("WARNING: entry with only %d fields, skipping.\n", vecp);
510 for (i = 0; vec[i]; i++) {
511 debug_printf("vec[%d]: \"%s\"\n",
522 /* find out how to perform the action */
527 ** If previous condition failed, don't
528 ** do this - else fall through
537 ** If already delivered, skip this action.
538 ** Else consider delivered if action is
549 ** Take action, and consider delivered if
550 ** action is successful.
559 ** Take action, but don't consider delivered,
560 ** even if action is successful
566 if (vecp > 5 && mh_strcasecmp(vec[5], "select")==0) {
567 if (logged_in() != -1) {
570 if (vecp > 7 && timely(vec[6], vec[7]) == -1) {
575 /* check if the field matches */
583 ** "default" matches only if the message hasn't
584 ** been delivered yet.
586 if (mh_strcasecmp(field, "default")==0) {
594 /* parse message and build lookup table */
595 if (!parsed && parse(fd) == -1) {
600 ** find header field in lookup table, and
601 ** see if the pattern matches.
603 if ((p = lookup(hdrs, field)) && p->p_value &&
604 matches(p->p_value, pattern)) {
613 /* find out the action to perform */
616 /* deliver to quoted pipe */
617 if (mh_strcasecmp(action, "qpipe")) {
622 expand(tmpbuf, string, fd);
623 if (split(tmpbuf, vec) < 1) {
626 status = usr_pipe(fd, tmpbuf, vec[0], vec, 0);
630 /* deliver to pipe */
631 if (mh_strcasecmp(action, "pipe")) {
638 expand(tmpbuf, string, fd);
641 status = usr_pipe(fd, tmpbuf, "/bin/sh", vec+2, 0);
645 if (mh_strcasecmp(action, "file")==0) {
647 status = usr_file(fd, string);
650 if (mh_strcasecmp(action, "folder")!=0) {
655 /* deliver to nmh folder */
656 status = usr_folder(fd, string);
661 if (mh_strcasecmp(action, "mbox")!=0) {
667 status = usr_file(fd, string);
672 if (mh_strcasecmp(action, "destroy")!=0) {
680 next = 0; /* action failed, mark for 'N' result */
687 return (won ? 0 : -1);
692 ** Split buffer into fields (delimited by whitespace or
693 ** comma's). Return the number of fields found.
696 split(char *cp, char **vec)
703 /* split into a maximum of NVEC fields */
704 for (i = 0; i <= NVEC;) {
707 /* zap any whitespace and comma's */
708 while (isspace(*s) || *s == ',') {
711 /* end of buffer, time to leave */
715 /* get double quote text as a single field */
717 for (vec[i++] = ++s; *s && *s != '"'; s++) {
719 ** Check for escaped double quote. We need
720 ** to shift the string to remove slash.
730 /* zap trailing double quote */
736 if (*s == '\\' && *++s != '"') {
741 /* move forward to next field delimiter */
742 while (*s && !isspace(*s) && *s != ',') {
753 ** Parse the headers of a message, and build the
754 ** lookup table for matching fields and patterns.
762 char name[NAMESZ], field[BUFSIZ];
770 /* get a new FILE pointer to message */
771 if ((fd1 = dup(fd)) == -1) {
774 if (!(in = fdopen(fd1, "r"))) {
780 /* add special entries to lookup table */
781 if ((p = lookup(hdrs, "source"))) {
782 p->p_value = getcpy(sender);
784 if ((p = lookup(hdrs, "addr"))) {
785 p->p_value = getcpy(addr);
789 ** Scan the headers of the message and build a lookup table.
791 for (i = 0, state = FLD;;) {
792 switch (state = m_getfld(state, name, field, sizeof(field),
798 while (state == FLDPLUS) {
799 state = m_getfld(state, name, field,
803 for (p = hdrs; p->p_name; p++) {
804 if (mh_strcasecmp(p->p_name, name)!=0) {
805 if (!(p->p_flags & P_HID)) {
806 if ((cp = p->p_value)) {
807 if (p->p_flags & P_ADR) {
808 dp = cp + strlen(cp) - 1;
812 cp = add(",\n\t", cp);
817 p->p_value = add(lp, cp);
823 if (!p->p_name && i < NVEC) {
824 p->p_name = getcpy(name);
830 if (state != FLDEOF) {
842 advise(NULL, "format error in message");
846 advise(NULL, "internal error in m_getfld");
854 if ((p = lookup(vars, "reply-to"))) {
855 if (!(q = lookup(hdrs, "reply-to")) || !q->p_value) {
856 q = lookup(hdrs, "from");
858 p->p_value = getcpy(q ? q->p_value : "");
859 p->p_flags &= ~P_CHK;
861 debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
862 p - vars, p->p_name, trim(p->p_value));
866 for (p = hdrs; p->p_name; p++) {
867 debug_printf("hdrs[%d]: name=\"%s\" value=\"%s\"\n",
869 p->p_value ? trim(p->p_value) : "");
877 ** Expand any builtin variables such as $(sender),
878 ** $(address), etc., in a string.
881 expand(char *s1, char *s2, int fd)
889 while ((c = *s2++)) {
890 if (c != '$' || *s2 != '(') {
893 for (cp = ++s2; *s2 && *s2 != ')'; s2++) {
901 if ((p = lookup(vars, cp))) {
902 if (!parsed && (p->p_flags & P_CHK)) {
905 strcpy(s1, p->p_value);
915 ** Fill in the information missing from the "vars"
916 ** table, which is necessary to expand any builtin
917 ** variables in the string for a "pipe" or "qpipe"
930 if ((p = lookup(vars, "sender"))) {
931 p->p_value = getcpy(sender);
933 if ((p = lookup(vars, "address"))) {
934 p->p_value = getcpy(addr);
936 if ((p = lookup(vars, "size"))) {
937 snprintf(buffer, sizeof(buffer), "%d",
938 fstat(fd, &st) != -1 ? (int) st.st_size : 0);
939 p->p_value = getcpy(buffer);
941 if ((p = lookup(vars, "info"))) {
942 p->p_value = getcpy(info);
945 for (p = vars; p->p_name; p++) {
946 debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
947 p - vars, p->p_name, trim(p->p_value));
954 ** Find a matching name in a lookup table. If found,
955 ** return the "pairs" entry, else return NULL.
958 lookup(struct pair *pairs, char *key)
960 for (; pairs->p_name; pairs++) {
961 if (!mh_strcasecmp(pairs->p_name, key)) {
970 ** Check utmp(x) file to see if user is currently
984 while ((utp = getutent())) {
986 #ifdef HAVE_STRUCT_UTMP_UT_TYPE
987 utp->ut_type == USER_PROCESS &&
989 utp->ut_name[0] != 0 &&
990 strncmp(user, utp->ut_name,
991 sizeof(utp->ut_name)) == 0) {
996 return (utmped = DONE);
1001 return (utmped = NOTOK);
1013 if (!(uf = fopen(UTMP_FILE, "r"))) {
1016 while (fread((char *) &ut, sizeof(ut), 1, uf) == 1) {
1017 if (ut.ut_name[0] && strncmp(user, ut.ut_name,
1018 sizeof(ut.ut_name))==0) {
1023 return (utmped = DONE);
1027 return (utmped = NOTOK);
1031 #define check(t,a,b) if ((t) < (a) || (t) > (b)) return -1
1032 #define cmpar(h1,m1,h2,m2) if ((h1)<(h2) || ((h1)==(h2) && (m1)<(m2))) \
1036 timely(char *t1, char *t2)
1038 int t1hours, t1mins, t2hours, t2mins;
1040 if (sscanf(t1, "%d:%d", &t1hours, &t1mins) != 2) {
1043 check(t1hours, 0, 23);
1044 check(t1mins, 0, 59);
1046 if (sscanf(t2, "%d:%d", &t2hours, &t2mins) != 2) {
1049 check(t2hours, 0, 23);
1050 check(t2mins, 0, 59);
1052 cmpar(now->tw_hour, now->tw_min, t1hours, t1mins);
1053 cmpar(t2hours, t2mins, now->tw_hour, now->tw_min);
1060 ** Deliver message by appending to a file, using rcvpack(1).
1063 usr_file(int fd, char *mailbox)
1068 verbose_printf("delivering to file \"%s\" (mbox style)",
1075 return usr_pipe(fd, "rcvpack", "rcvpack", vec, 1);
1080 ** Deliver message to a nmh folder, using rcvstore(1).
1083 usr_folder(int fd, char *string)
1085 char folder[BUFSIZ], *vec[3];
1087 /* get folder name ready */
1088 if (*string == '+') {
1089 strncpy(folder, string, sizeof(folder));
1091 snprintf(folder, sizeof(folder), "+%s", string);
1094 verbose_printf("delivering to folder \"%s\"", folder + 1);
1096 vec[0] = "rcvstore";
1100 return usr_pipe(fd, "rcvstore", rcvstoreproc, vec, 1);
1104 ** Deliver message to a process.
1107 usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress)
1110 int bytes, seconds, status;
1113 if (verbose && !suppress) {
1114 verbose_printf("delivering to pipe \"%s\"", cmd);
1116 lseek(fd, (off_t) 0, SEEK_SET);
1118 switch ((child_id = fork())) {
1122 adorn("fork", "unable to");
1131 freopen("/dev/null", "w", stdout);
1132 freopen("/dev/null", "w", stderr);
1139 if ((fd = open("/dev/tty", O_RDWR)) != -1) {
1140 ioctl(fd, TIOCNOTTY, NULL);
1143 #endif /* TIOCNOTTY */
1145 /* put in own process group */
1146 setpgid((pid_t) 0, getpid());
1149 m_putenv("USER", pw->pw_name);
1150 m_putenv("HOME", pw->pw_dir);
1151 m_putenv("SHELL", pw->pw_shell);
1157 /* parent process */
1158 if (setjmp(myctx)) {
1160 ** Ruthlessly kill the child and anything
1161 ** else in its process group.
1163 KILLPG(child_id, SIGKILL);
1165 verbose_printf(", timed-out; terminated\n");
1168 SIGNAL(SIGALRM, alrmser);
1169 bytes = fstat(fd, &st) != -1 ? (int) st.st_size : 100;
1171 /* amount of time to wait depends on message size */
1173 /* give at least 5 minutes */
1175 } else if (bytes >= 90000) {
1176 /* a half hour is long enough */
1179 seconds = (bytes / 60) + 300;
1181 alarm((unsigned int) seconds);
1182 status = pidwait(child_id, 0);
1187 verbose_printf(", success.\n");
1188 } else if ((status & 0xff00) == 0xff00) {
1189 verbose_printf(", system error\n");
1191 pidstatus(status, stdout, ", failed");
1194 return (status == 0 ? 0 : -1);
1202 #ifndef RELIABLE_SIGNALS
1203 SIGNAL(SIGALRM, alrmser);
1206 longjmp(myctx, DONE);
1211 ** Get the `sender' from the envelope
1212 ** information ("From " line).
1215 get_sender(char *envelope, char **sender)
1219 unsigned char buffer[BUFSIZ];
1222 *sender = getcpy("");
1226 i = strlen("From ");
1227 strncpy(buffer, envelope + i, sizeof(buffer));
1228 if ((cp = strchr(buffer, '\n'))) {
1239 for (cp = buffer + strlen(buffer) - 1; cp >= buffer; cp--)
1245 *sender = getcpy(buffer);
1250 ** Copy message into a temporary file.
1251 ** While copying, it will do some header processing
1252 ** including the extraction of the envelope information.
1255 copy_message(int qd, char *tmpfil, int fold)
1257 int i, first = 1, fd1, fd2;
1258 char buffer[BUFSIZ];
1262 tfile = m_mktemp2(NULL, invo_name, &fd1, NULL);
1263 if (tfile == NULL) return -1;
1265 strncpy(tmpfil, tfile, BUFSIZ);
1268 while ((i = read(qd, buffer, sizeof(buffer))) > 0) {
1269 if (write(fd1, buffer, i) != i) {
1279 lseek(fd1, (off_t) 0, SEEK_SET);
1283 /* dup the fd for incoming message */
1284 if ((fd2 = dup(qd)) == -1) {
1289 /* now create a FILE pointer for it */
1290 if (!(qfp = fdopen(fd2, "r"))) {
1296 /* dup the fd for temporary file */
1297 if ((fd2 = dup(fd1)) == -1) {
1303 /* now create a FILE pointer for it */
1304 if (!(ffp = fdopen(fd2, "r+"))) {
1312 ** copy message into temporary file
1313 ** and massage the headers. Save
1314 ** a copy of the "From " line for later.
1316 i = strlen("From ");
1317 while (fgets(buffer, sizeof(buffer), qfp)) {
1320 if (strncmp(buffer, "From ", i)==0) {
1323 ** get copy of envelope information
1326 envelope = getcpy(buffer);
1329 ** Now create a "Return-Path:" line
1330 ** from the "From " line.
1332 cp = strchr(fp = envelope + i, ' ');
1333 snprintf(buffer, sizeof(buffer),
1334 "Return-Path: %.*s\n",
1335 (int)(cp - fp), fp);
1337 /* Add Return-Path header to message */
1342 /* Put the delivery date in message */
1364 lseek(fd1, (off_t) 0, SEEK_SET);
1375 ** Trim strings for pretty printing of debugging output
1380 char buffer[BUFSIZ*4];
1381 unsigned char *bp, *sp;
1387 /* copy string into temp buffer */
1388 strncpy(buffer, cp, sizeof(buffer));
1391 /* skip over leading whitespace */
1392 while (isspace(*bp)) {
1395 /* start at the end and zap trailing whitespace */
1396 for (sp = bp + strlen(bp) - 1; sp >= bp; sp--) {
1404 /* replace remaining whitespace with spaces */
1405 for (sp = bp; *sp; sp++) {
1414 ** Function for printing `verbose' messages.
1417 verbose_printf(char *fmt, ...)
1422 vfprintf(stdout, fmt, ap);
1429 ** Function for printing `verbose' delivery
1433 adorn(char *what, char *fmt, ...)
1439 eindex = errno; /* save the errno */
1440 fprintf(stdout, ", ");
1443 vfprintf(stdout, fmt, ap);
1448 fprintf(stdout, " %s: ", what);
1450 if ((s = strerror(eindex))) {
1451 fprintf(stdout, "%s", s);
1453 fprintf(stdout, "Error %d", eindex);
1457 fputc('\n', stdout);
1463 ** Function for printing `debug' messages.
1466 debug_printf(char *fmt, ...)
1471 vfprintf(stderr, fmt, ap);