diff options
author | phk <phk@FreeBSD.org> | 1995-02-25 05:10:18 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-02-25 05:10:18 +0000 |
commit | 80ef2eaf89dbd07515d303e6e3409d8c1cf97610 (patch) | |
tree | 34fd72bb2cbdc3ecd008b14ff3c1eb7aba954d64 /usr.sbin/ctm/ctm_rmail/error.c | |
parent | 030f982dd69dac94b908d1e725850626a5185985 (diff) | |
download | FreeBSD-src-80ef2eaf89dbd07515d303e6e3409d8c1cf97610.zip FreeBSD-src-80ef2eaf89dbd07515d303e6e3409d8c1cf97610.tar.gz |
(Not tested yet. I may insist that ctm be invoked with absolute path. /phk)
This patch fixes the concurrency problem, and adds a possibly useful -f switch
(which you can read about in the man page :-) ). It also removes the absolute
path from the invocation of ctm. I'll write a note about how to use a script
with sendmail and procmail or some such, and people can fix their PATH there.
BTW, this patch changes ctm_rmail.1, ctm_rmail.c and error.c in the ctm_rmail
directory.
Stephen.
Reviewed by: phk
Submitted by: Stephen McKay <syssgm@devetir.qld.gov.au>
Diffstat (limited to 'usr.sbin/ctm/ctm_rmail/error.c')
-rw-r--r-- | usr.sbin/ctm/ctm_rmail/error.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/usr.sbin/ctm/ctm_rmail/error.c b/usr.sbin/ctm/ctm_rmail/error.c index be3581d..724b117 100644 --- a/usr.sbin/ctm/ctm_rmail/error.c +++ b/usr.sbin/ctm/ctm_rmail/error.c @@ -1,7 +1,22 @@ +/* + * Routines for logging error messages or other informative messages. + * + * Log messages can easily contain the program name, a time stamp, system + * error messages, and arbitrary printf-style strings, and can be directed + * to stderr or a log file. + * + * Author: Stephen McKay + * + * NOTICE: This is free software. I hope you get some use from this program. + * In return you should think about all the nice people who give away software. + * Maybe you should write some free software too. + */ + #include <stdio.h> #include <string.h> #include <stdarg.h> #include <time.h> +#include <errno.h> #include "error.h" static FILE *error_fp = NULL; @@ -38,6 +53,9 @@ err_prog_name(char *name) /* * Log an error. + * + * A leading '*' in the message format means we want the system errno + * decoded and appended. */ void err(char *fmt, ...) @@ -46,6 +64,8 @@ err(char *fmt, ...) time_t now; struct tm *tm; FILE *fp; + int x = errno; + int want_errno; if ((fp = error_fp) == NULL) { @@ -61,10 +81,17 @@ err(char *fmt, ...) tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min); } + want_errno = 0; + if (*fmt == '*') + want_errno++, fmt++; + va_start(ap, fmt); vfprintf(fp, fmt, ap); va_end(ap); + if (want_errno) + fprintf(fp, ": %s", strerror(x)); + fprintf(fp, "\n"); fflush(fp); } |