version 1.31, 2007/05/17 10:59:26 |
version 1.32, 2007/09/09 12:36:38 |
|
|
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <dirent.h> |
#include <dirent.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <pwd.h> |
#include <pwd.h> |
|
|
printf("Message %d:\nFrom %s %sSubject: ", |
printf("Message %d:\nFrom %s %sSubject: ", |
nextmsg, pw->pw_name, ctime(&t)); |
nextmsg, pw->pw_name, ctime(&t)); |
fflush(stdout); |
fflush(stdout); |
fgets(inbuf, sizeof inbuf, stdin); |
if (fgets(inbuf, sizeof inbuf, stdin) == NULL) |
|
errx(1, "could not read input"); |
putchar('\n'); |
putchar('\n'); |
fflush(stdout); |
fflush(stdout); |
fprintf(newmsg, "From %s %sSubject: %s\n", |
fprintf(newmsg, "From %s %sSubject: %s\n", |
|
|
} else |
} else |
blankline = seensubj = NO; |
blankline = seensubj = NO; |
for (;;) { |
for (;;) { |
fgets(inbuf, sizeof inbuf, stdin); |
if (fgets(inbuf, sizeof inbuf, stdin) == NULL) |
if (feof(stdin) || ferror(stdin)) |
|
break; |
break; |
blankline = (blankline || (inbuf[0] == '\n')); |
blankline = (blankline || (inbuf[0] == '\n')); |
seensubj = (seensubj || |
seensubj = (seensubj || |
|
|
printf("%s ", prompt); |
printf("%s ", prompt); |
fflush(stdout); |
fflush(stdout); |
intrpflg = NO; |
intrpflg = NO; |
(void) fgets(inbuf, sizeof inbuf, stdin); |
if (fgets(inbuf, sizeof inbuf, stdin) == NULL) |
if ((n = strlen(inbuf)) > 0 && inbuf[n - 1] == '\n') |
errx(1, "could not read input"); |
inbuf[n - 1] = '\0'; |
inbuf[strcspn(inbuf, "\n")] = '\0'; |
if (intrpflg) |
if (intrpflg) |
inbuf[0] = 'x'; |
inbuf[0] = 'x'; |
|
|