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 static int globbed = 0; /* have we built "vars" table yet? */
90 static int parsed = 0; /* have we built header field table yet */
91 static int utmped = 0; /* have we scanned umtp(x) file yet */
93 static int verbose = 0;
96 static char *addr = NULL;
97 static char *user = NULL;
98 static char *info = NULL;
99 static char *file = NULL;
100 static char *sender = NULL;
101 static char *envelope = NULL; /* envelope information ("From " line) */
102 static char *mbox = NULL;
103 static char *home = NULL;
105 static struct passwd *pw; /* passwd file entry */
107 static char ddate[BUFSIZ]; /* record the delivery date */
110 static jmp_buf myctx;
112 /* flags for pair->p_flags */
114 #define P_ADR 0x01 /* field is address */
115 #define P_HID 0x02 /* special (fake) field */
127 ** Lookup table for matching fields and patterns
128 ** in messages. The rest of the table is added
129 ** when the message is parsed.
131 static struct pair hdrs[NVEC + 1] = {
132 { "source", NULL, P_HID },
133 { "addr", NULL, P_HID },
134 { "Return-Path", NULL, P_ADR },
135 { "Reply-To", NULL, P_ADR },
136 { "From", NULL, P_ADR },
137 { "Sender", NULL, P_ADR },
138 { "To", NULL, P_ADR },
139 { "cc", NULL, P_ADR },
140 { "Resent-Reply-To", NULL, P_ADR },
141 { "Resent-From", NULL, P_ADR },
142 { "Resent-Sender", NULL, P_ADR },
143 { "Resent-To", NULL, P_ADR },
144 { "Resent-Cc", NULL, P_ADR },
149 ** The list of builtin variables to expand in a string
150 ** before it is executed by the "pipe" or "qpipe" action.
152 static struct pair vars[] = {
153 { "sender", NULL, P_NIL },
154 { "address", NULL, P_NIL },
155 { "size", NULL, P_NIL },
156 { "reply-to", NULL, P_CHK },
157 { "info", NULL, P_NIL },
161 extern char **environ;
166 static int localmail(int, char *);
167 static int usr_delivery(int, char *, int);
168 static int split(char *, char **);
169 static int parse(int);
170 static void expand(char *, char *, int);
171 static void glob(int);
172 static struct pair *lookup(struct pair *, char *);
173 static int logged_in(void);
174 static int timely(char *, char *);
175 static int usr_file(int, char *);
176 static int usr_pipe(int, char *, char *, char **, int);
177 static int usr_folder(int, char *);
178 static void alrmser(int);
179 static void get_sender(char *, char **);
180 static int copy_message(int, char *, int);
181 static void verbose_printf(char *fmt, ...);
182 static void adorn(char *, char *, ...);
183 static void debug_printf(char *fmt, ...);
184 static char *trim(char *);
188 main(int argc, char **argv)
192 char *cp, *mdlvr = NULL, buf[BUFSIZ];
193 char mailbox[BUFSIZ], tmpfil[BUFSIZ];
194 char **argp, **arguments;
197 setlocale(LC_ALL, "");
199 invo_name = mhbasename(*argv);
201 /* foil search of user profile/context */
202 if (context_foil(NULL) == -1) {
205 arguments = getarguments(invo_name, argc, argv, 0);
208 /* Parse arguments */
209 while ((cp = *argp++)) {
211 switch (smatch(++cp, switches)) {
213 ambigsw(cp, switches);
216 adios(NULL, "-%s unknown", cp);
219 snprintf(buf, sizeof(buf), "%s [switches] [address info sender]", invo_name);
220 print_help(buf, switches, 0);
223 print_version(invo_name);
227 if (!(addr = *argp++)) {
228 /* allow -xyz arguments */
229 adios(NULL, "missing argument to %s",
234 if (!(info = *argp++)) {
235 /* allow -xyz arguments */
236 adios(NULL, "missing argument to %s",
241 if (!(user = *argp++)) {
242 /* allow -xyz arguments */
243 adios(NULL, "missing argument to %s",
248 if (!(file = *argp++) || *file == '-') {
249 adios(NULL, "missing argument to %s",
254 if (!(sender = *argp++)) {
255 /* allow -xyz arguments */
256 adios(NULL, "missing argument to %s",
261 if (!(mbox = *argp++) || *mbox == '-') {
262 adios(NULL, "missing argument to %s",
267 if (!(home = *argp++) || *home == '-') {
268 adios(NULL, "missing argument to %s",
274 if (!(cp = *argp++) || *cp == '-') {
275 adios(NULL, "missing argument to %s",
279 adios(NULL, "only one maildelivery file at a time!");
297 switch (argp - (argv + 1)) {
311 addr = getusername();
314 user = (cp = strchr(addr, '.')) ? ++cp : addr;
316 if (!(pw = getpwnam(user))) {
317 adios(NULL, "no such local user as %s", user);
320 if (chdir(pw->pw_dir) == -1) {
325 if (geteuid() == 0) {
327 initgroups(pw->pw_name, pw->pw_gid);
337 /* Record the delivery time */
338 if (!(now = dlocaltimenow())) {
339 adios(NULL, "unable to ascertain local time");
341 snprintf(ddate, sizeof(ddate), "Delivery-Date: %s\n", dtimenow(0));
344 ** Copy the message to a temporary file
349 /* getting message from file */
350 if ((tempfd = open(file, O_RDONLY)) == -1) {
351 adios(file, "unable to open");
354 debug_printf("retrieving message from file \"%s\"\n",
357 if ((fd = copy_message(tempfd, tmpfil, 1)) == -1) {
358 adios(NULL, "unable to create temporary file");
362 /* getting message from stdin */
364 debug_printf("retrieving message from stdin\n");
366 if ((fd = copy_message(fileno(stdin), tmpfil, 1)) == -1) {
367 adios(NULL, "unable to create temporary file");
372 debug_printf("temporary file=\"%s\"\n", tmpfil);
376 ** Delete the temp file now or a copy of every single message
377 ** passed through slocal will be left in the /tmp directory until
378 ** deleted manually! This unlink() used to be under an 'else'
379 ** of the 'if (debug)' above, but since some people like to
380 ** always run slocal with -debug and log the results, the /tmp
381 ** directory would get choked over time. Of course, now that
382 ** we always delete the temp file, the "temporary file=" message
383 ** above is somewhat pointless -- someone watching debug output
384 ** wouldn't have a chance to 'tail -f' or 'ln' the temp file
385 ** before it's unlinked. The best thing would be to delay this
386 ** unlink() until later if debug == 1, but I'll leave that for
387 ** someone who cares about the temp-file-accessing functionality
388 ** (they'll have to watch out for cases where we adios()).
392 if (!(fp = fdopen(fd, "r+"))) {
393 adios(NULL, "unable to access temporary file");
396 /* If no sender given, extract it from envelope information. */
398 get_sender(envelope, &sender);
401 snprintf(mailbox, sizeof(mailbox), "%s/%s",
402 mailspool, pw->pw_name);
410 debug_printf("addr=\"%s\"\n", trim(addr));
411 debug_printf("user=\"%s\"\n", trim(user));
412 debug_printf("info=\"%s\"\n", trim(info));
413 debug_printf("sender=\"%s\"\n", trim(sender));
414 debug_printf("envelope=\"%s\"\n",
415 envelope ? trim(envelope) : "");
416 debug_printf("mbox=\"%s\"\n", trim(mbox));
417 debug_printf("home=\"%s\"\n", trim(home));
418 debug_printf("ddate=\"%s\"\n", trim(ddate));
419 debug_printf("now=%02d:%02d\n\n", now->tw_hour, now->tw_min);
422 /* deliver the message */
423 status = localmail(fd, mdlvr);
425 done(status != -1 ? RCV_MOK : RCV_MBX);
431 ** Main routine for delivering message.
434 localmail(int fd, char *mdlvr)
438 /* delivery according to personal Maildelivery file */
439 if (usr_delivery(fd, mdlvr ? mdlvr : ".maildelivery", 0) != -1) {
442 /* delivery according to global Maildelivery file */
443 snprintf(buf, sizeof buf, "%s/%s", mhetcdir, "maildelivery");
444 if (usr_delivery(fd, buf, 1) != -1) {
448 verbose_printf("(delivering to standard mail spool)\n");
450 /* last resort - deliver to standard mail spool */
451 return usr_file(fd, mbox);
455 #define matches(a,b) (stringdex(b, a) >= 0)
458 ** Parse the delivery file, and process incoming message.
461 usr_delivery(int fd, char *delivery, int su)
463 int i, accept, status=1, won, vecp, next;
464 char *field, *pattern, *action, *result, *string;
465 char buffer[BUFSIZ], tmpbuf[BUFSIZ];
466 char *cp, *vec[NVEC];
471 /* open the delivery file */
472 if (!(fp = fopen(delivery, "r"))) {
475 /* check if delivery file has bad ownership or permissions */
476 if (fstat(fileno(fp), &st) == -1 ||
477 (st.st_uid != 0 && (su || st.st_uid != pw->pw_uid)) ||
478 st.st_mode & (S_IWGRP|S_IWOTH)) {
480 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);
488 /* read and process delivery file */
489 while (fgets(buffer, sizeof(buffer), fp)) {
490 /* skip comments and empty lines */
491 if (*buffer == '#' || *buffer == '\n') {
494 /* zap trailing newline */
495 if ((cp = strchr(buffer, '\n'))) {
498 /* split buffer into fields */
499 vecp = split(buffer, vec);
501 /* check for too few fields */
504 debug_printf("WARNING: entry with only %d fields, skipping.\n", vecp);
509 for (i = 0; vec[i]; i++) {
510 debug_printf("vec[%d]: \"%s\"\n",
521 /* find out how to perform the action */
526 ** If previous condition failed, don't
527 ** do this - else fall through
536 ** If already delivered, skip this action.
537 ** Else consider delivered if action is
548 ** Take action, and consider delivered if
549 ** action is successful.
558 ** Take action, but don't consider delivered,
559 ** even if action is successful
565 if (vecp > 5 && mh_strcasecmp(vec[5], "select")==0) {
566 if (logged_in() != -1) {
569 if (vecp > 7 && timely(vec[6], vec[7]) == -1) {
574 /* check if the field matches */
582 ** "default" matches only if the message hasn't
583 ** been delivered yet.
585 if (mh_strcasecmp(field, "default")==0) {
593 /* parse message and build lookup table */
594 if (!parsed && parse(fd) == -1) {
599 ** find header field in lookup table, and
600 ** see if the pattern matches.
602 if ((p = lookup(hdrs, field)) && p->p_value &&
603 matches(p->p_value, pattern)) {
612 /* find out the action to perform */
615 /* deliver to quoted pipe */
616 if (mh_strcasecmp(action, "qpipe")) {
621 expand(tmpbuf, string, fd);
622 if (split(tmpbuf, vec) < 1) {
625 status = usr_pipe(fd, tmpbuf, vec[0], vec, 0);
629 /* deliver to pipe */
630 if (mh_strcasecmp(action, "pipe")) {
637 expand(tmpbuf, string, fd);
640 status = usr_pipe(fd, tmpbuf, "/bin/sh", vec+2, 0);
644 if (mh_strcasecmp(action, "file")==0) {
646 status = usr_file(fd, string);
649 if (mh_strcasecmp(action, "folder")!=0) {
654 /* deliver to nmh folder */
655 status = usr_folder(fd, string);
660 if (mh_strcasecmp(action, "mbox")!=0) {
666 status = usr_file(fd, string);
671 if (mh_strcasecmp(action, "destroy")!=0) {
679 next = 0; /* action failed, mark for 'N' result */
686 return (won ? 0 : -1);
691 ** Split buffer into fields (delimited by whitespace or
692 ** comma's). Return the number of fields found.
695 split(char *cp, char **vec)
702 /* split into a maximum of NVEC fields */
703 for (i = 0; i <= NVEC;) {
706 /* zap any whitespace and comma's */
707 while (isspace(*s) || *s == ',') {
710 /* end of buffer, time to leave */
714 /* get double quote text as a single field */
716 for (vec[i++] = ++s; *s && *s != '"'; s++) {
718 ** Check for escaped double quote. We need
719 ** to shift the string to remove slash.
729 /* zap trailing double quote */
735 if (*s == '\\' && *++s != '"') {
740 /* move forward to next field delimiter */
741 while (*s && !isspace(*s) && *s != ',') {
752 ** Parse the headers of a message, and build the
753 ** lookup table for matching fields and patterns.
761 char name[NAMESZ], field[BUFSIZ];
769 /* get a new FILE pointer to message */
770 if ((fd1 = dup(fd)) == -1) {
773 if (!(in = fdopen(fd1, "r"))) {
779 /* add special entries to lookup table */
780 if ((p = lookup(hdrs, "source"))) {
781 p->p_value = getcpy(sender);
783 if ((p = lookup(hdrs, "addr"))) {
784 p->p_value = getcpy(addr);
788 ** Scan the headers of the message and build a lookup table.
790 for (i = 0, state = FLD;;) {
791 switch (state = m_getfld(state, name, field, sizeof(field),
797 while (state == FLDPLUS) {
798 state = m_getfld(state, name, field,
802 for (p = hdrs; p->p_name; p++) {
803 if (mh_strcasecmp(p->p_name, name)!=0) {
804 if (!(p->p_flags & P_HID)) {
805 if ((cp = p->p_value)) {
806 if (p->p_flags & P_ADR) {
807 dp = cp + strlen(cp) - 1;
811 cp = add(",\n\t", cp);
816 p->p_value = add(lp, cp);
822 if (!p->p_name && i < NVEC) {
823 p->p_name = getcpy(name);
829 if (state != FLDEOF) {
841 advise(NULL, "format error in message");
845 advise(NULL, "internal error in m_getfld");
853 if ((p = lookup(vars, "reply-to"))) {
854 if (!(q = lookup(hdrs, "reply-to")) || !q->p_value) {
855 q = lookup(hdrs, "from");
857 p->p_value = getcpy(q ? q->p_value : "");
858 p->p_flags &= ~P_CHK;
860 debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
861 p - vars, p->p_name, trim(p->p_value));
865 for (p = hdrs; p->p_name; p++) {
866 debug_printf("hdrs[%d]: name=\"%s\" value=\"%s\"\n",
868 p->p_value ? trim(p->p_value) : "");
876 ** Expand any builtin variables such as $(sender),
877 ** $(address), etc., in a string.
880 expand(char *s1, char *s2, int fd)
888 while ((c = *s2++)) {
889 if (c != '$' || *s2 != '(') {
892 for (cp = ++s2; *s2 && *s2 != ')'; s2++) {
900 if ((p = lookup(vars, cp))) {
901 if (!parsed && (p->p_flags & P_CHK)) {
904 strcpy(s1, p->p_value);
914 ** Fill in the information missing from the "vars"
915 ** table, which is necessary to expand any builtin
916 ** variables in the string for a "pipe" or "qpipe"
929 if ((p = lookup(vars, "sender"))) {
930 p->p_value = getcpy(sender);
932 if ((p = lookup(vars, "address"))) {
933 p->p_value = getcpy(addr);
935 if ((p = lookup(vars, "size"))) {
936 snprintf(buffer, sizeof(buffer), "%d",
937 fstat(fd, &st) != -1 ? (int) st.st_size : 0);
938 p->p_value = getcpy(buffer);
940 if ((p = lookup(vars, "info"))) {
941 p->p_value = getcpy(info);
944 for (p = vars; p->p_name; p++) {
945 debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
946 p - vars, p->p_name, trim(p->p_value));
953 ** Find a matching name in a lookup table. If found,
954 ** return the "pairs" entry, else return NULL.
957 lookup(struct pair *pairs, char *key)
959 for (; pairs->p_name; pairs++) {
960 if (!mh_strcasecmp(pairs->p_name, key)) {
969 ** Check utmp(x) file to see if user is currently
983 while ((utp = getutent())) {
985 #ifdef HAVE_STRUCT_UTMP_UT_TYPE
986 utp->ut_type == USER_PROCESS &&
988 utp->ut_name[0] != 0 &&
989 strncmp(user, utp->ut_name,
990 sizeof(utp->ut_name)) == 0) {
995 return (utmped = DONE);
1000 return (utmped = NOTOK);
1012 if (!(uf = fopen(UTMP_FILE, "r"))) {
1015 while (fread((char *) &ut, sizeof(ut), 1, uf) == 1) {
1016 if (ut.ut_name[0] && strncmp(user, ut.ut_name,
1017 sizeof(ut.ut_name))==0) {
1022 return (utmped = DONE);
1026 return (utmped = NOTOK);
1030 #define check(t,a,b) if ((t) < (a) || (t) > (b)) return -1
1031 #define cmpar(h1,m1,h2,m2) if ((h1)<(h2) || ((h1)==(h2) && (m1)<(m2))) \
1035 timely(char *t1, char *t2)
1037 int t1hours, t1mins, t2hours, t2mins;
1039 if (sscanf(t1, "%d:%d", &t1hours, &t1mins) != 2) {
1042 check(t1hours, 0, 23);
1043 check(t1mins, 0, 59);
1045 if (sscanf(t2, "%d:%d", &t2hours, &t2mins) != 2) {
1048 check(t2hours, 0, 23);
1049 check(t2mins, 0, 59);
1051 cmpar(now->tw_hour, now->tw_min, t1hours, t1mins);
1052 cmpar(t2hours, t2mins, now->tw_hour, now->tw_min);
1059 ** Deliver message by appending to a file, using rcvpack(1).
1062 usr_file(int fd, char *mailbox)
1067 verbose_printf("delivering to file \"%s\" (mbox style)",
1074 return usr_pipe(fd, "rcvpack", "rcvpack", vec, 1);
1079 ** Deliver message to a nmh folder, using rcvstore(1).
1082 usr_folder(int fd, char *string)
1084 char folder[BUFSIZ], *vec[3];
1086 /* get folder name ready */
1087 if (*string == '+') {
1088 strncpy(folder, string, sizeof(folder));
1090 snprintf(folder, sizeof(folder), "+%s", string);
1093 verbose_printf("delivering to folder \"%s\"", folder + 1);
1095 vec[0] = "rcvstore";
1099 return usr_pipe(fd, "rcvstore", "rcvstore", vec, 1);
1103 ** Deliver message to a process.
1106 usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress)
1109 int bytes, seconds, status, n;
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);
1136 for (n=4; n<OPEN_MAX; n++) {
1141 if ((fd = open("/dev/tty", O_RDWR)) != -1) {
1142 ioctl(fd, TIOCNOTTY, NULL);
1145 #endif /* TIOCNOTTY */
1147 /* put in own process group */
1148 setpgid((pid_t) 0, getpid());
1150 path = getenv("PATH");
1152 m_putenv("USER", pw->pw_name);
1153 m_putenv("HOME", pw->pw_dir);
1154 m_putenv("SHELL", pw->pw_shell);
1155 m_putenv("PATH", path);
1161 /* parent process */
1162 if (setjmp(myctx)) {
1164 ** Ruthlessly kill the child and anything
1165 ** else in its process group.
1167 kill(-child_id, SIGKILL);
1169 verbose_printf(", timed-out; terminated\n");
1172 SIGNAL(SIGALRM, alrmser);
1173 bytes = fstat(fd, &st) != -1 ? (int) st.st_size : 100;
1175 /* amount of time to wait depends on message size */
1177 /* give at least 5 minutes */
1179 } else if (bytes >= 90000) {
1180 /* a half hour is long enough */
1183 seconds = (bytes / 60) + 300;
1185 alarm((unsigned int) seconds);
1186 status = pidwait(child_id, 0);
1191 verbose_printf(", success.\n");
1192 } else if ((status & 0xff00) == 0xff00) {
1193 verbose_printf(", system error\n");
1195 pidstatus(status, stdout, ", failed");
1198 return (status == 0 ? 0 : -1);
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("/tmp/", 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) {
1322 ** get copy of envelope information
1325 envelope = getcpy(buffer);
1327 /* Put the delivery date in message */
1349 lseek(fd1, (off_t) 0, SEEK_SET);
1360 ** Trim strings for pretty printing of debugging output
1365 char buffer[BUFSIZ*4];
1366 unsigned char *bp, *sp;
1372 /* copy string into temp buffer */
1373 strncpy(buffer, cp, sizeof(buffer));
1376 /* skip over leading whitespace */
1377 while (isspace(*bp)) {
1380 /* start at the end and zap trailing whitespace */
1381 for (sp = bp + strlen(bp) - 1; sp >= bp; sp--) {
1389 /* replace remaining whitespace with spaces */
1390 for (sp = bp; *sp; sp++) {
1399 ** Function for printing `verbose' messages.
1402 verbose_printf(char *fmt, ...)
1407 vfprintf(stdout, fmt, ap);
1414 ** Function for printing `verbose' delivery
1418 adorn(char *what, char *fmt, ...)
1424 eindex = errno; /* save the errno */
1425 fprintf(stdout, ", ");
1428 vfprintf(stdout, fmt, ap);
1433 fprintf(stdout, " %s: ", what);
1435 if ((s = strerror(eindex))) {
1436 fprintf(stdout, "%s", s);
1438 fprintf(stdout, "Error %d", eindex);
1442 fputc('\n', stdout);
1448 ** Function for printing `debug' messages.
1451 debug_printf(char *fmt, ...)
1456 vfprintf(stderr, fmt, ap);