FreeBSD Bugzilla – Attachment 8700 Details for
Bug 18100
[patch] from(1): update to src/usr.bin/from/from.c for multiple mboxes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 3.00 KB, created by
srm
on 2000-04-20 01:20:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
srm
Created:
2000-04-20 01:20:01 UTC
Size:
3.00 KB
patch
obsolete
>--- /usr/src/usr.bin/from/from.c Wed Apr 19 18:46:42 2000 >+++ ./from.c Wed Apr 19 18:45:39 2000 >@@ -42,7 +42,7 @@ > static char sccsid[] = "@(#)from.c 8.1 (Berkeley) 6/6/93"; > #endif > static const char rcsid[] = >- "$FreeBSD: src/usr.bin/from/from.c,v 1.8 1999/08/28 01:01:22 peter Exp $"; >+ "$FreeBSD: src/usr.bin/from/from.c,v 1.5.2.2 1999/10/30 21:49:05 green Exp $"; > #endif /* not lint */ > > #include <sys/types.h> >@@ -57,6 +57,7 @@ > > int match __P((char *, char *)); > static void usage __P((void)); >+char * getbox __P((char *)); > > int > main(argc, argv) >@@ -66,8 +67,8 @@ > extern char *optarg; > extern int optind; > struct passwd *pwd; >- int ch, count, newline; >- char *file, *sender, *p; >+ int ch, count, newline, header, deflt; >+ char *file, *mailenv, *sender, *p; > #if MAXPATHLEN > BUFSIZ > char buf[MAXPATHLEN]; > #else >@@ -76,6 +77,7 @@ > > file = sender = NULL; > count = -1; >+ deflt = -1; > while ((ch = getopt(argc, argv, "cf:s:")) != -1) > switch (ch) { > case 'c': >@@ -99,7 +101,7 @@ > if (!file) { > if (*argv) { > (void)sprintf(buf, "%s/%s", _PATH_MAILDIR, *argv); >- file = buf; >+ file = strdup(buf); deflt=1; > } else { > if (!(file = getenv("MAIL"))) { > if (!(pwd = getpwuid(getuid()))) >@@ -107,36 +109,67 @@ > file = pwd->pw_name; > (void)sprintf(buf, > "%s/%s", _PATH_MAILDIR, file); >- file = buf; >+ file = strdup(buf); deflt=1; > } > } > } > >- /* read from stdin */ >- if (strcmp(file, "-") == 0) { >- } >- else if (!freopen(file, "r", stdin)) { >- errx(1, "can't read %s", file); >- } >- for (newline = 1; fgets(buf, sizeof(buf), stdin);) { >- if (*buf == '\n') { >- newline = 1; >- continue; >+ while(((deflt) && (mailenv = getbox(file)) != NULL)) { >+ >+ /* read from stdin */ >+ if (strcmp(file, "-") == 0) { > } >- if (newline && !strncmp(buf, "From ", 5) && >- (!sender || match(buf + 5, sender))) { >- if (count != -1) >- count++; >- else >- printf("%s", buf); >+ else { >+ if (!freopen(file, "r", stdin)) >+ errx(1, "can't read %s", file); >+ } >+ >+ header=0; >+ for (newline = 1; fgets(buf, sizeof(buf), stdin);) { >+ if (*buf == '\n') { >+ newline = 1; >+ continue; >+ } >+ if (newline && !strncmp(buf, "From ", 5) && >+ (!sender || match(buf + 5, sender))) { >+ if (count != -1) >+ count++; >+ else >+ if(!header) { >+ printf("%s:\n\n",file); >+ header++; >+ } >+ printf("%s", buf); >+ fflush(stdout); >+ } >+ newline = 0; > } >- newline = 0; >+ if (count != -1) >+ printf("There %s %d message%s in your incoming mailbox.\n", >+ count == 1 ? "is" : "are", count, count == 1 ? "" : "s"); >+ if(deflt == 1) >+ deflt--; >+ file = mailenv; > } >- if (count != -1) >- printf("There %s %d message%s in your incoming mailbox.\n", >- count == 1 ? "is" : "are", count, count == 1 ? "" : "s"); >- exit(0); > } >+ >+char * >+getbox(str) >+ char *str; >+{ >+ char *p; >+ >+ if(*str == '\0') >+ return((char *)NULL); >+ >+ for (p = str;((*str != ':')&&(*str != '\0'));str++) {} >+ *str++ = '\0'; >+ return(str); >+} >+ >+ >+ >+ > > static void > usage()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 18100
: 8700