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

  1. #include "util.h"
  2. #include "mmdf.h"
  3. #include "ch.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. /*                  SEND FROM PHONE TO LOCAL (SUBMIT)                   */
  37.  
  38. extern struct ll_struct   *logptr;
  39.  
  40. mm2ph_send (curchan)                /* overall mngmt for batch of msgs    */
  41.     Chan *curchan;                /* channel being picked up            */
  42. {
  43.     short     result;
  44.     char    info[LINESIZE],
  45.             sender[LINESIZE];
  46.  
  47. #ifdef DEBUG
  48.     ll_log (logptr, LLOGBTR, "mm2ph_send (%s)", curchan -> ch_name);
  49. #endif
  50.  
  51.     if (rp_isbad (result = mm_pkinit (curchan -> ch_name)))
  52.     return (result);
  53.     if (rp_isbad (result = ph_sbinit ()))
  54.     return (result);
  55.  
  56.     while (rp_gval (result = mm_rinit (info, sender)) == RP_OK)
  57.     {
  58. #ifdef DEBUG
  59.     ll_log (logptr, LLOGPTR, "new message");
  60. #endif
  61.     if (rp_isbad (result = ph_winit (curchan -> ch_name, info, sender)))
  62.         return (result);      /* ready to process a message         */
  63.  
  64.     if (rp_isbad (result = m2p_admng ()))
  65.         return (result);      /* send the address list              */
  66.  
  67.     if (rp_isbad (result = m2p_txmng ()))
  68.         return (result);      /* send the message text              */
  69.     }
  70. #ifdef DEBUG
  71.     ll_log (logptr, LLOGPTR, "done w/msgs");
  72. #endif
  73.  
  74.     mm_pkend ();                  /* done getting messages              */
  75.     ph_sbend ();                  /* done sending messages              */
  76.  
  77.     switch (rp_gval (result))
  78.     {
  79.     case RP_DONE: 
  80.     case RP_EOF: 
  81.         return (RP_OK);
  82.     }
  83.     return (result);
  84. }
  85. /* */
  86.  
  87. LOCFUN
  88.     m2p_admng ()              /* send address list                  */
  89. {
  90.     struct rp_bufstruct thereply;
  91.     int       len;
  92.     short     result;
  93.     char    host[LINESIZE];
  94.     char    adr[LINESIZE];
  95.  
  96. #ifdef DEBUG
  97.     ll_log (logptr, LLOGPTR, "doing adrs");
  98. #endif
  99.  
  100.     FOREVER              /* iterate thru list                    */
  101.     {                  /* we already have and adr              */
  102. #ifdef DEBUG
  103.     ll_log (logptr, LLOGBTR, "new addr");
  104. #endif
  105.     result = mm_radr (host, adr);
  106.     if (rp_isbad (result))
  107.         return (result);      /* get address from Deliver           */
  108.     if (rp_gval (result) == RP_DONE)
  109.         break;          /* end of address list                */
  110.  
  111.     if (rp_isbad (result = ph_wadr (host, adr, &thereply)))
  112.         return (result);      /* give to remote site                */
  113.  
  114.     switch (rp_gval (thereply.rp_val))
  115.                   /* was address acceptable?            */
  116.     {
  117.         case RP_AOK:       /* address ok, text not yet sent      */
  118.         mm_wrply (&thereply, rp_structlen(thereply));
  119.         break;
  120.  
  121.         case RP_NO:       /* remaining acceptible responses     */
  122.         thereply.rp_val = RP_NDEL;
  123.         case RP_USER: 
  124.         case RP_NDEL: 
  125.         case RP_AGN: 
  126.         case RP_NOOP: 
  127.         mm_wrply (&thereply, rp_structlen(thereply));
  128.         break;
  129.  
  130.         default:           /* responses which force abort        */
  131.         ll_log (logptr, LLOGFAT,
  132.             "adr eof reply err (%s)'%s'",
  133.             rp_valstr (thereply.rp_val), thereply.rp_line);
  134.         if (rp_isbad (thereply.rp_val))
  135.             return (thereply.rp_val);
  136.         return (RP_RPLY);
  137.     }
  138.     }
  139.     return (ph_waend ());        /* tell remote of address list end    */
  140. }
  141. /* */
  142.  
  143. LOCFUN
  144.     m2p_txmng ()              /* send message text                  */
  145. {
  146.     struct rp_bufstruct thereply;
  147.     char    buffer[BUFSIZ];
  148.     int     len;
  149.     short     result;
  150.  
  151.     if (rp_isbad( ph_wtinit() ))
  152.         return (RP_RPLY);
  153.  
  154. #ifdef DEBUG
  155.     ll_log (logptr, LLOGPTR, "doing text");
  156. #endif
  157.     while ((rp_gval (result = mm_rtxt (buffer, &len))) == RP_OK)
  158.     if (rp_isbad (result = ph_wtxt (buffer, len)))
  159.         return (result);
  160. #ifdef DEBUG
  161.     ll_log (logptr, LLOGBTR, "done sending");
  162. #endif
  163.  
  164.     if (rp_isbad (result))
  165.     return (result);      /* problem with transmission          */
  166.     if (rp_gval (result) != RP_DONE)
  167.     return (RP_RPLY);      /* protocol error in reply code       */
  168.     if (rp_isbad (result = ph_wtend (&thereply)))
  169.     return (result);      /* flag end of message                */
  170.  
  171.     switch (rp_gval (thereply.rp_val))
  172.                   /* was text acceptable?               */
  173.     {
  174.     case RP_OK: 
  175.         thereply.rp_val = RP_MOK;
  176.     case RP_MOK:           /* text was accepted                  */
  177.         mm_wrply (&thereply, rp_structlen(thereply));
  178.         break;
  179.  
  180.     case RP_NO:           /* remaining acceptible responses     */
  181.         thereply.rp_val = RP_NDEL;
  182.     case RP_NDEL: 
  183.     case RP_AGN: 
  184.     case RP_NOOP: 
  185.         mm_wrply (&thereply, rp_structlen(thereply));
  186.         thereply.rp_val = RP_OK;
  187.         break;                /* don't abort the process            */
  188.  
  189.     default:           /* responses which force abort        */
  190.         ll_log (logptr, LLOGFAT,
  191.             "text eof reply err (%s)'%s'",
  192.             rp_valstr (thereply.rp_val), thereply.rp_line);
  193.         if (rp_isbad (thereply.rp_val))
  194.         return (thereply.rp_val);
  195.         return (RP_RPLY);
  196.     }
  197.     return (RP_OK);
  198. }
  199.