Annotation of researchv8dc/cmd/uucp/mailst.c, revision 1.1.1.1

1.1       root        1: /*     @(#)mailst.c    1.3     */
                      2: 
                      3: #include "uucp.h"
                      4: VERSION(@(#)mailst.c   1.3);
                      5: 
                      6: /*
                      7:  * fork and execute a mail command sending 
                      8:  * string (str) to user (user).
                      9:  * If file is non-null, the file is also sent.
                     10:  * (this is used for mail returned to sender.)
                     11:  *     user     -> user to send mail to
                     12:  *     str      -> string mailed to user
                     13:  *     infile   -> optional stdin mailed to user
                     14:  *     errfile  -> optional stderr mailed to user
                     15:  */
                     16: mailst(user, str, infile, errfile)
                     17: char *user, *str, *infile, *errfile;
                     18: {
                     19:        register FILE *fp, *fi;
                     20:        char cmd[BUFSIZ];
                     21:        char *c;
                     22: 
                     23:        /* get rid of some stuff that could hurt */
                     24:        if ( (c = strpbrk(user, ";&|<>^`\\('\"")) != NULL) {
                     25:                *c = NULLCHAR;
                     26:        }
                     27: 
                     28:        (void) sprintf(cmd, "%s mail %s", PATH, user);
                     29:        if ((fp = popen(cmd, "w")) == NULL)
                     30:                return;
                     31:        (void) fprintf(fp, "%s\n", str);
                     32: 
                     33:        /* copy back stderr */
                     34:        if (*errfile != '\0' && NOTEMPTY(errfile) && (fi = fopen(errfile, "r")) != NULL) {
                     35:                fputs("\n\t===== stderr was =====\n", fp);
                     36:                if (xfappend(fi, fp) != SUCCESS)
                     37:                        fputs("\n\t===== well, i tried =====\n", fp);
                     38:                (void) fclose(fi);
                     39:                fputc('\n', fp);
                     40:        }
                     41: 
                     42:        /* copy back stdin */
                     43:        if (*infile != '\0' && NOTEMPTY(infile) && (fi = fopen(infile, "r")) != NULL) {
                     44:                fputs("\n\t===== stdin was =====\n", fp);
                     45:                if (xfappend(fi, fp) != SUCCESS)
                     46:                        fputs("\n\t===== well, i tried =====\n", fp);
                     47:                (void) fclose(fi);
                     48:                fputc('\n', fp);
                     49:        }
                     50: 
                     51:        (void) pclose(fp);
                     52: }
                     53: #ifndef        V7
                     54: static char un[2*NAMESIZE];
                     55: setuucp(p)
                     56: char *p;
                     57: {
                     58:    char **envp;
                     59: 
                     60:     envp = Env;
                     61:     for ( ; *envp; envp++) {
                     62:        if(PREFIX("LOGNAME", *envp)) {
                     63:            (void) sprintf(un, "LOGNAME=%s",p);
                     64:            envp[0] = &un[0];
                     65:        }
                     66:     }
                     67: }
                     68: #else
                     69: /*ARGSUSED*/
                     70: setuucp(p) char        *p; {}
                     71: #endif

unix.superglobalmegacorp.com

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