Annotation of 42BSD/usr.bin/uucp/sdmail.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)sdmail.c   5.2 (Berkeley) 7/19/83";
                      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: 
                     18: sdmail(file, uid)
                     19: char *file;
                     20: register 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: 
                     47: mailst(user, str)
                     48: char *user, *str;
                     49: {
                     50:        register FILE *fp;
                     51:        char cmd[100];
                     52: 
                     53:        sprintf(cmd, "mail %s", user);
                     54:        if ((fp = rpopen(cmd, "w")) == NULL)
                     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: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.