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