# /* send_pmail.c * * This file contains the routines concerned with mailing a file to * a pmail user. The routines contained are: * send_pmail copy mail file to end of user's mailbox * pmail_host check if a particular host name is a pmail psuedo-host */ #include #include "rqfile.h" #include "extern.h" #include "tcode.h" send_pmail (mlfile, rqp, uname) /* Send the specified mail file to the specified user. Find the name * of the user's mailbox, and append the contents of the mail file to * it. Returns: * TOK on success * TACESS if unable to access a file * TNOUSR if the specified user doesn't exist * * Arguments: */ char *mlfile; /* name of file containing mail */ register struct req_rec *rqp; /* ptr. to request record */ char *uname; /* name of dest. user */ { register int sz; /* size of block read */ int mlfd; /* mail file descriptor */ int mbfd; /* mailbox file descriptor */ char mailbox[NAMSIZ]; /* user's mailbox file name */ char buffer[BIGBUF]; /* buffer for copy */ printf("Pmailing %s to %s\n", mlfile, uname); if (getpment (uname, mailbox) == NULL) return (TNOUSR); printf("Mailbox is |%s|\n", mailbox); if ((mlfd = open (mlfile, 0)) < 0) return (TACESS); printf("Input mail file open OK\n"); if ((mbfd = open (mailbox, 1)) < 0) {printf("Failure code was:%d\n",mbfd); return (TACESS); }printf("Mailbox open OK\n"); seek (mbfd, 0, 2); /* seek to end of mailbox */ write (mbfd, MSGSEP, MSGSEPL); /* write message separators */ while ((sz = read (mlfd, buffer, BIGBUF)) > 0) write (mbfd, buffer, sz); write (mbfd, MSGSEP, MSGSEPL); close (mbfd); close (mlfd); return (TOK); } pmail_host (hname) /* This routine determines whether the specified host a PMAIL psuedo-host * (by looking it up in a host table). It returns TRUE if so. * * Arguments: */ char *hname; /* name of destination host */ { return (strcmp(hname,"pmail") == 0); }