home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / src / smphone / ph_wtmail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-28  |  5.6 KB  |  256 lines

  1. #include "util.h"
  2. #include "mmdf.h"
  3. #include "adr_queue.h"
  4. #include "ph.h"
  5. /*
  6.  *     MULTI-CHANNEL MEMO DISTRIBUTION FACILITY  (MMDF)
  7.  *     
  8.  *
  9.  *     Copyright (C) 1979,1980,1981  University of Delaware
  10.  *     
  11.  *     Department of Electrical Engineering
  12.  *     University of Delaware
  13.  *     Newark, Delaware  19711
  14.  *
  15.  *     Phone:  (302) 738-1163
  16.  *     
  17.  *     
  18.  *     This program module was developed as part of the University
  19.  *     of Delaware's Multi-Channel Memo Distribution Facility (MMDF).
  20.  *     
  21.  *     Acquisition, use, and distribution of this module and its listings
  22.  *     are subject restricted to the terms of a license agreement.
  23.  *     Documents describing systems using this module must cite its source.
  24.  *
  25.  *     The above statements must be retained with all copies of this
  26.  *     program and may not be removed without the consent of the
  27.  *     University of Delaware.
  28.  *     
  29.  *
  30.  *     version  -1    David H. Crocker    March   1979
  31.  *     version   0    David H. Crocker    April   1980
  32.  *     version  v7    David H. Crocker    May     1981
  33.  *     version   1    David H. Crocker    October 1981
  34.  *
  35.  */
  36.  
  37. extern struct ll_struct   *logptr;
  38.  
  39. /* **************  (ph_)  PHONE MAIL-WRITING SUB-MODULE  ************** */
  40.  
  41. LOCVAR short  ph_nadrs;             /* number of addresses this message   */
  42. LOCVAR  long ph_nchrs;            /* number of chars in msg text        */
  43. LOCVAR struct rp_construct
  44.     rp_gdtxt =
  45. {
  46.     RP_MOK, 't', 'e', 'x', 't', ' ', 's', 'e', 'n', 't', ' ', 'o', 'k', '\0'
  47. };
  48.  
  49. struct ps_rstruct ps_rp;
  50.  
  51. /* ARGSUSED */
  52.  
  53. ph_winit (vianet, info, retadr)  /* pass msg initialization info       */
  54. char    vianet[];          /* what channel coming in from        */
  55. char    info[],              /* general info                       */
  56.         retadr[];          /* return address for error msgs      */
  57. {
  58.     short     retval;
  59.     char  initbuf[LINESIZE];
  60.  
  61.  
  62. /* DBG:  make sure info has right form */
  63.  
  64. #ifdef DEBUG
  65.     ll_log (logptr, LLOGBTR, "ph_winit");
  66. #endif
  67.  
  68.     ph_nadrs = 0;
  69.     ph_nchrs = 0L;
  70.     
  71.     switch (info[0])
  72.     { 
  73.     case (ADR_TTY):
  74.         sprintf (initbuf, "SEND FROM:<%s>", retadr);
  75.         break;
  76.     case (ADR_BOTH):
  77.         sprintf (initbuf, "SAML FROM:<%s>", retadr);
  78.         break;
  79.     case (ADR_TorM):
  80.         sprintf (initbuf, "SOML FROM:<%s>", retadr);
  81.         break;
  82.     case (ADR_MAIL):
  83.     default:
  84.         sprintf (initbuf, "MAIL FROM:<%s>", retadr);
  85.         break;
  86.     }    
  87.     retval = ps_cmd (initbuf);  /* ignore return */
  88.     return (retval);
  89. }
  90. /* */
  91.  
  92. ph_wadr (host, adr, thereply)  /* send one address spec to local     */
  93. char    host[],              /* "next" location part of address    */
  94.         adr[];              /* rest of address                    */
  95. struct rp_bufstruct *thereply;     
  96. {
  97.     extern char *strdup (),
  98.         *multcat ();
  99.     short     retval;
  100.     register char  *adrstr;
  101.     char linebuf[LINESIZE];
  102.  
  103. #ifdef DEBUG
  104.     ll_log (logptr, LLOGBTR, "ph_wadr(%s, %s)", host, adr);
  105. #endif
  106.  
  107.     ph_nadrs++;
  108.  
  109.     sprintf (linebuf, "RCPT TO:<%s>", adr);
  110.     if (rp_isbad (ps_cmd (linebuf)))
  111.     return (RP_DHST);
  112.  
  113.     switch (ps_rp.sm_rval)
  114.     {
  115.     case 250:
  116.     case 251:
  117.         ps_rp.sm_rval = RP_AOK;
  118.         break;
  119.  
  120.     case 421:
  121.     case 450:
  122.     case 451:
  123.     case 452:
  124.         ps_rp.sm_rval = RP_NO;
  125.         break;
  126.  
  127.     case 550:
  128.     case 551:
  129.     case 552:
  130.     case 553:
  131.         ps_rp.sm_rval = RP_USER;
  132.         break;
  133.  
  134.     case 500:
  135.     case 501:
  136.         ps_rp.sm_rval = RP_PARM;
  137.         break;
  138.  
  139.     default:
  140.         ps_rp.sm_rval = RP_RPLY;
  141.     }
  142.  
  143.     if (ps_rp.sm_rgot) 
  144.     strncpy (thereply->rp_line, ps_rp.sm_rstr, ps_rp.sm_rlen+1);
  145.     else
  146.     strcpy (thereply->rp_line, "Unknown Problem");
  147.     
  148.     thereply->rp_val = ps_rp.sm_rval;
  149.     return (RP_OK);
  150. }
  151.  
  152. ph_waend ()                      /* end of address list                */
  153. {
  154. #ifdef DEBUG
  155.     ll_log (logptr, LLOGBTR, "ph_waend");
  156. #endif
  157.  
  158.     return (RP_DONE);
  159. }
  160. /* */
  161. ph_wtinit()
  162. {
  163.  
  164. #ifdef DEBUG
  165.     ll_log (logptr, LLOGBTR, "ph_wtinit()");
  166. #endif
  167.  
  168.     if (rp_isbad (ps_cmd ("DATA"))) {
  169.     return(RP_RPLY);
  170.     }
  171.  
  172.     switch( ps_rp.sm_rval ) {
  173.     case 354:
  174.     break;          /* Go ahead and send mail */
  175.  
  176.     case 500:
  177.     case 501:
  178.     case 503:
  179.     case 554:
  180.     return(RP_NDEL);
  181.  
  182.     case 421:
  183.     case 451:
  184.     default:
  185.     return(RP_AGN);
  186.     }
  187.     return (RP_OK);
  188. }
  189.  
  190. ph_wtxt (buffer, len)            /* send next part of msg text         */
  191. char    buffer[];          /* the text                           */
  192. short     len;                      /* length of text                     */
  193. {
  194. #ifdef DEBUG
  195.     ll_log (logptr, LLOGBTR, "ph_wtxt()");
  196. #endif
  197.  
  198.     ph_nchrs += (long) len;
  199.  
  200.     return (ph_wstm (buffer, len));
  201. }
  202.  
  203. ph_wtend (thereply)        /* end of message text                */
  204. struct rp_bufstruct *thereply;
  205. {
  206.  
  207. #ifdef DEBUG
  208.     ll_log (logptr, LLOGBTR, "ph_wtend");
  209. #endif
  210.  
  211.     if (rp_isbad (ph_wstm ((char *) 0, 0))) {
  212.                 /* flush text buffer / send eos       */
  213.     strcpy (thereply->rp_line, "Error flushing text to remote host");
  214.     return(thereply->rp_val = RP_RPLY);
  215.     }
  216.  
  217.     if (rp_isbad (ps_cmd("."))) {
  218.     strcpy (thereply->rp_line, "Bad response to final dot");
  219.     return(thereply->rp_val = RP_BHST);
  220.     }
  221.  
  222.     switch( ps_rp.sm_rval ) {
  223.     case 250:
  224.     case 251:
  225.     blt (&rp_gdtxt, (char *)thereply, sizeof rp_gdtxt);
  226.     break;
  227.  
  228.     case 552:
  229.     case 554:
  230.     thereply->rp_val = RP_NDEL;
  231.     if (ps_rp.sm_rgot)
  232.         strncpy (thereply->rp_line, ps_rp.sm_rstr, ps_rp.sm_rlen+1);
  233.     else
  234.         strcpy (thereply->rp_line, "Unknown Problem");
  235.     break;
  236.  
  237.     case 421:
  238.     case 451:
  239.     case 452:
  240.     default:
  241.     thereply->rp_val = RP_AGN;
  242.     if (ps_rp.sm_rgot)
  243.         strncpy (thereply->rp_line, ps_rp.sm_rstr, ps_rp.sm_rlen+1);
  244.     else     
  245.         strcpy (thereply->rp_line, "Unknown Problem");
  246.     }
  247.  
  248. #ifdef DEBUG
  249.     ll_log (logptr, LLOGBTR, "ph_wtend reply (%s) %s",
  250.                      rp_valstr(thereply->rp_val), thereply->rp_line);
  251. #endif DEBUG
  252.  
  253.     return(RP_OK);
  254.  
  255. }
  256.