better error logging
[unix-history] / usr / src / usr.bin / uucp / sdmail.c
CommitLineData
10074d5c 1#ifndef lint
48bce963 2static char sccsid[] = "@(#)sdmail.c 5.2 (Berkeley) %G%";
10074d5c
SL
3#endif
4
5#include "uucp.h"
6#include <pwd.h>
7
8/*******
9 * sdmail(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;
20register int uid;
21{
22 static struct passwd *pwd = NULL;
23 struct passwd *getpwuid();
24 char mstr[40];
25
26 sprintf(mstr, "uuclean deleted file %s\n", file);
27 if (pwd != NULL && pwd->pw_uid == uid) {
28 mailst(pwd->pw_name, mstr);
29 return(0);
30 }
31
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 register FILE *fp;
10074d5c
SL
51 char cmd[100];
52
53 sprintf(cmd, "mail %s", user);
48bce963 54 if ((fp = rpopen(cmd, "w")) == NULL)
10074d5c
SL
55 return;
56/* \n added to mail message. uw-beave!jim (Jim Rees) */
57 fprintf(fp, "%s\n", str);
58 pclose(fp);
59 return;
60}