[prev in list] [next in list] [prev in thread] [next in thread]
List: openbsd-tech
Subject: For your consideration
From: Marco S Hyman <marc () snafu ! org>
Date: 1999-05-30 20:05:34
[Download RAW message or body]
It has annoyed me that the vacation program doesn't allow me to
reference the subject of the original message in the automagically
generated response, something that I think sunos vacation did many,
many years ago.
This patch works for me. It lets me create a .vacation.msg file
along the lines of:
From: Marco S Hyman <marc@snafu.org>
Subject: I'm on vacation...
Precedence: bulk
Yep, it's vacation time again. I'll be back later and will
get to your message
$SUBJECT
at that time.
// marc
Index: vacation.1
===================================================================
RCS file: /cvs/src/usr.bin/vacation/vacation.1,v
retrieving revision 1.6
diff -u -p -r1.6 vacation.1
--- vacation.1 1999/05/16 19:58:06 1.6
+++ vacation.1 1999/05/30 20:06:53
@@ -141,6 +141,14 @@ please contact Keith Bostic <bostic@CS.B
--eric
.Ed
.Pp
+Any occurance of the string
+.Li $SUBJECT
+in
+.Pa .vacation.msg
+will be replaced by the subject of the message that triggered the
+.Nm vacation
+program.
+.Pp
.Nm vacation
reads the incoming message from standard input, checking the message
headers for either the
Index: vacation.c
===================================================================
RCS file: /cvs/src/usr.bin/vacation/vacation.c,v
retrieving revision 1.11
diff -u -p -r1.11 vacation.c
--- vacation.c 1999/02/12 01:21:07 1.11
+++ vacation.c 1999/05/30 20:06:53
@@ -90,6 +90,7 @@ ALIAS *names;
DB *db;
char from[MAXLINE];
+char subj[MAXLINE];
int junkmail __P((void));
int nsearch __P((char *, char *));
@@ -260,6 +261,21 @@ readheaders()
!strncasecmp(p, "list", 4))
exit(0);
break;
+ case 'S': /* Subject: */
+ cont = 0;
+ if (strncasecmp(buf, "Subject:",
+ sizeof("Subject:")-1) ||
+ buf[8] != ' ' && buf[8] != '\t')
+ break;
+ for (p = buf + 8; *p && isspace(*p); ++p);
+ if (strlcpy(subj, p, sizeof subj ) > sizeof subj) {
+ syslog(LOG_NOTICE,
+ "Subject %s exceeds limits", p);
+ exit(1);
+ }
+ if (p = strchr(subj, '\n'))
+ *p = '\0';
+ break;
case 'C': /* "Cc:" */
if (strncmp(buf, "Cc:", 3))
break;
@@ -452,8 +468,17 @@ sendmessage(myname)
close(pvect[0]);
sfp = fdopen(pvect[1], "w");
fprintf(sfp, "To: %s\n", from);
- while (fgets(buf, sizeof buf, mfp))
- fputs(buf, sfp);
+ while (fgets(buf, sizeof buf, mfp)) {
+ char *s = strstr(buf, "$SUBJECT");
+ if ( s ) {
+ *s = 0;
+ fputs(buf, sfp);
+ fputs(subj, sfp);
+ fputs(s+8, sfp);
+ } else {
+ fputs(buf, sfp);
+ }
+ }
fclose(mfp);
fclose(sfp);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic