From ibrahim@mind.daemon.sh  Fri Nov 21 12:01:47 2003
Return-Path: <ibrahim@mind.daemon.sh>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id AC29116A4D1
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 21 Nov 2003 12:01:47 -0800 (PST)
Received: from smtp6.mindspring.com (smtp6.mindspring.com [207.69.200.110])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D087D43F75
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 21 Nov 2003 12:01:46 -0800 (PST)
	(envelope-from ibrahim@mind.daemon.sh)
Received: from sdn-ap-024dcwashp0157.dialsprint.net ([63.191.176.157])
	by smtp6.mindspring.com with esmtp (Exim 3.33 #1)
	id 1ANHTN-0001v5-00
	for FreeBSD-gnats-submit@freebsd.org; Fri, 21 Nov 2003 15:01:45 -0500
Message-Id: <200311211502.24290.ibrahim@mind.daemon.sh>
Date: Fri, 21 Nov 2003 15:02:24 -0500
From: Ibrahim Abdullah <ibrahim@mind.daemon.sh>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCHES] Add option to from command to also show subjects

>Number:         59564
>Category:       bin
>Synopsis:       [patch] from(1) add option (-S) to also display subject headers
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 21 12:10:14 PST 2003
>Closed-Date:    
>Last-Modified:  Sat May 24 19:07:08 UTC 2008
>Originator:     Ibrahim Abdullah
>Release:        FreeBSD 5.1-RELEASE-p10 i386
>Organization:
none
>Environment:
System: FreeBSD mind.daemon.sh 5.1-RELEASE-p10 FreeBSD 5.1-RELEASE-p10 #0: Sat Nov 15 22:17:30
EST 2003 root@mind.daemon.sh:/usr/obj/usr/src/sys/NEW i386


>Description:
	I added an option to /usr/src/usr.bin/from/from.c to enable it to display subject headers.
>How-To-Repeat:
	Not a problem report. Add patches below to /usr/src/usr.bin/from/from.c and /usr/src/usr.bin/from/from.1
>Fix:

Patch for from.c:

--- /usr/src/usr.bin/from/from.c	Wed Sep  4 19:29:00 2002
+++ from.c	Fri Nov 21 01:53:53 2003
@@ -63,7 +63,7 @@
 {
 	FILE *mbox;
 	struct passwd *pwd;
-	int ch, count, newline;
+	int ch, count, subject, newline;
 	const char *file;
 	char *sender, *p;
 #if MAXPATHLEN > BUFSIZ
@@ -74,8 +74,12 @@
 
 	file = sender = NULL;
 	count = -1;
-	while ((ch = getopt(argc, argv, "cf:s:")) != -1)
+	subject = 0;
+	while ((ch = getopt(argc, argv, "Scf:s:")) != -1)
 		switch (ch) {
+		case 'S':
+			subject = 1;
+			break;
 		case 'c':
 			count = 0;
 			break;
@@ -125,10 +129,17 @@
 		}
 		if (newline && !strncmp(buf, "From ", 5) &&
 		    (!sender || match(buf + 5, sender))) {
-			if (count != -1)
+			if (count != -1) {
 				count++;
-			else
+			} else {
 				printf("%s", buf);
+				while (subject && fgets(buf, sizeof(buf), mbox)) {
+					if (*buf == '\n')
+						break;
+					if (!strncmp(buf, "Subject: ", 9))
+						printf("    %s", buf);
+				}
+			}
 		}
 		newline = 0;
 	}
@@ -142,7 +153,7 @@
 static void
 usage(void)
 {
-	fprintf(stderr, "usage: from [-c] [-f file] [-s sender] [user]\n");
+	fprintf(stderr, "usage: from [-S] [-c] [-f file] [-s sender] [user]\n");
 	exit(1);
 }
 

Patch fo from.1

--- /usr/src/usr.bin/from/from.1	Mon Jul 15 02:15:38 2002
+++ from.1	Fri Nov 21 00:12:59 2003
@@ -40,6 +40,7 @@
 .Nd print names of those who have sent mail
 .Sh SYNOPSIS
 .Nm
+.Op Fl S
 .Op Fl c
 .Op Fl s Ar sender
 .Op Fl f Ar file
@@ -52,6 +53,8 @@
 .Pp
 The following options are available:
 .Bl -tag -width indent
+.It Fl S
+Also display subject headers.
 .It Fl c
 Just print a count of messages and exit.
 .It Fl f Ar file

>Release-Note:
>Audit-Trail:
>Unformatted:
