Commit | Line | Data |
---|---|---|
c635088c | 1 | #ifndef lint |
48bce963 | 2 | static char sccsid[] = "@(#)mailst.c 5.2 (Berkeley) %G%"; |
c635088c SL |
3 | #endif |
4 | ||
5 | #include "uucp.h" | |
6 | ||
7 | /******* | |
8 | * mailst(user, str, file) | |
9 | * | |
10 | * mailst - this routine will fork and execute | |
11 | * a mail command sending string (str) to user (user). | |
12 | * If file is non-null, the file is also sent. | |
13 | * (this is used for mail returned to sender.) | |
14 | */ | |
15 | ||
16 | mailst(user, str, file) | |
17 | char *user, *str, *file; | |
18 | { | |
19 | register FILE *fp, *fi; | |
c635088c SL |
20 | char cmd[100], buf[BUFSIZ]; |
21 | register int nc; | |
22 | ||
23 | sprintf(cmd, "mail %s", user); | |
48bce963 | 24 | if ((fp = rpopen(cmd, "w")) == NULL) |
c635088c SL |
25 | return; |
26 | fprintf(fp, "%s", str); | |
27 | ||
28 | if (*file != '\0' && (fi = fopen(subfile(file), "r")) != NULL) { | |
29 | while ((nc = fread(buf, sizeof (char), BUFSIZ, fi)) > 0) | |
30 | fwrite(buf, sizeof (char), nc, fp); | |
31 | fclose(fi); | |
32 | } | |
33 | ||
34 | pclose(fp); | |
35 | return; | |
36 | } |