Annotation of researchv8dc/cmd/upas/send/log.c, revision 1.1.1.1

1.1       root        1: #include <sys/types.h>
                      2: #include <sys/stat.h>
                      3: #include "mail.h"
                      4: 
                      5: /* configuration */
                      6: #define LOGFILE "/usr/spool/mail/mail.log"
                      7: #define LOGTEMP "/usr/spool/mail/mail.tmp"
                      8: 
                      9: /* imports */
                     10: void lock();
                     11: void unlock();
                     12: 
                     13: /* log a mail transmission */
                     14: logsend (to, from, at, tag)
                     15:        char *to;       /* receiver */
                     16:        char *from;     /* the sender */
                     17:        char *at;       /* time sent */
                     18:        char *tag;      /* type of mail */
                     19: {
                     20: #      include <grp.h>
                     21:        char buf[FROMLINESIZE];
                     22:        int out, in;
                     23:        long len;
                     24:        long lseek();
                     25: 
                     26:        lock(LOGFILE);
                     27: 
                     28:        /* append to log */
                     29:        out = open(LOGFILE, 2);
                     30:        len = lseek(out, 0L, 2);
                     31:        if (len > 32000) {
                     32:                in = out;
                     33:                out = creat(LOGTEMP, 0660);
                     34:                if (out >= 0 && in >= 0 && lseek(in, -4000L, 2) >= 0) {
                     35:                        while ((len = read(in, buf, FROMLINESIZE)) > 0)
                     36:                                (void)write(out, buf, (unsigned int)len);
                     37:                        close(in);
                     38:                        close(out);
                     39:                        unlink(LOGFILE);
                     40:                        link(LOGTEMP, LOGFILE);
                     41:                        unlink(LOGTEMP);
                     42:                } else {
                     43:                        close(in);
                     44:                        close(out);
                     45:                }
                     46:                out = open(LOGFILE, 2);
                     47:        }
                     48:        sprintf (buf, "%s %s From %s %s\n", tag, to, from, at);
                     49:        (void)write(out, buf, strlen(buf));
                     50:        close(out);
                     51:        chmod(LOGFILE, 0666);
                     52: 
                     53:        unlock ();
                     54: 
                     55: }

unix.superglobalmegacorp.com

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