From 773ec24a37effee3f7aee951b9270cdaa167d444 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 14 Nov 1996 03:49:50 +0000 Subject: [PATCH] added %h expansion --- logging.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/logging.c b/logging.c index d72deb569..529b9dbe6 100644 --- a/logging.c +++ b/logging.c @@ -444,6 +444,7 @@ static void send_mail() char *mailer = MAILER; char *subject = MAILSUBJECT; int fd[2]; + char *p; #ifdef POSIX_SIGNALS struct sigaction action; @@ -498,8 +499,18 @@ static void send_mail() /* feed the data to sendmail */ /* XXX - do we need to fdopen this fd #1 to a new stream??? */ - (void) fprintf(stdout, "To: %s\nSubject: %s\n\n%s : %s\n\n", - ALERTMAIL, subject, host, logline); + (void) fprintf(stdout, "To: %s\nSubject: ", ALERTMAIL); + p = subject; + while (*p) { + /* expand %h -> hostname in subject */ + if (*p == '%' && *(p+1) == 'h') { + (void) fputs(host, stdout); + p++; + } else + (void) fputc(*p, stdout); + p++; + } + (void) fprintf(stdout, "\n\n%s : %s\n\n", host, logline); fclose(stdout); exit(0); -- 2.50.1