BSD 4_1c_2 release
[unix-history] / usr / src / usr.bin / uucp / sdmail.c
CommitLineData
e804469b
C
1static char sccsid[] = "@(#)sdmail.c 4.1 (Berkeley) 9/11/82";
2
fea9ca7b
C
3#include "uucp.h"
4#include <pwd.h>
5
6
7/*******
8 * sdmail(file, uid)
9 * char *file, *uid;
10 *
11 * sdmail - this routine will determine the owner
12 * of the file (file), create a message string and
13 * call "mailst" to send the cleanup message.
14 * This is only implemented for local system
15 * mail at this time.
16 */
17
18sdmail(file, uid)
19char *file, *uid;
20{
21 static struct passwd *pwd;
22 struct passwd *getpwuid();
23 char mstr[40];
24
25 sprintf(mstr, "uuclean deleted file %s\n", file);
26 if (pwd->pw_uid == uid) {
27 mailst(pwd->pw_name, mstr);
28 return(0);
29 }
30
31 setpwent();
32 if ((pwd = getpwuid(uid)) != NULL) {
33 mailst(pwd->pw_name, mstr);
34 }
35 return(0);
36}
37
38
39/***
40 * mailst(user, str)
41 * char *user, *str;
42 *
43 * mailst - this routine will fork and execute
44 * a mail command sending string (str) to user (user).
45 */
46
47mailst(user, str)
48char *user, *str;
49{
50 FILE *fp;
51 extern FILE *popen(), *pclose();
52 char cmd[100];
53
54 sprintf(cmd, "mail %s", user);
55 if ((fp = popen(cmd, "w")) == NULL)
56 return;
57 fprintf(fp, "%s", str);
58 pclose(fp);
59 return;
60}