home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Chans / dr2rfc / write_queue.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  4.1 KB  |  149 lines

  1. /* write_queue.c - Creates & submits a Q_struct for a DR Msg */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Chans/dr2rfc/RCS/write_queue.c,v 6.0 1991/12/18 20:06:58 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Chans/dr2rfc/RCS/write_queue.c,v 6.0 1991/12/18 20:06:58 jpo Rel $
  9.  *
  10.  * $Log: write_queue.c,v $
  11.  * Revision 6.0  1991/12/18  20:06:58  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "head.h"
  19. #include "prm.h"
  20. #include "q.h"
  21. #include "tb_a.h"
  22. #include "tb_q.h"
  23. #include "tb_p1.h"
  24. #include <isode/cmd_srch.h>
  25.  
  26. extern CHAN             *mychan;
  27. extern char             *loc_dom_site;
  28. extern char             *getpostmaster(),
  29.             *hdr_822_bp,
  30.             *ia5_bp, error[];
  31. extern ADDR             *adr_new ();
  32. extern CMD_TABLE    qtbl_con_type[];
  33. extern LIST_BPT        *list_bpt_dup();
  34.  
  35. /* ---------------------  Begin Routines  --------------------------------- */
  36.  
  37. char     *recip_err;
  38.  
  39.  
  40. write_queue (to)
  41. ADDR    *to;
  42. {
  43.         struct prm_vars         prm;
  44.         Q_struct                QNewStruct,
  45.                                 *qp = &QNewStruct;
  46.         EncodedIT               *ep = &qp -> encodedinfo;
  47.         RP_Buf                  rps, *rp = &rps;
  48.  
  49.  
  50.         PP_TRACE (("dr2rfc/write_queue()"));
  51.  
  52.         if (to->ad_r822adr == NULLCP) {
  53.                 PP_LOG (LLOG_EXCEPTIONS, ("%s%s",
  54.                         "dr2rfc/write_queue - no rfc822 ",
  55.                         "recipient address has been specified"));
  56.         (void) sprintf(error,
  57.                    "no rfc822 recipient address has been specified");
  58.                 return RP_BAD;
  59.         }
  60.  
  61.  
  62.         /* -- initialize prm and Q fields -- */
  63.         prm_init (&prm);
  64.         q_init (qp);
  65.         qp -> msgtype           = MT_UMPDU;
  66.     qp -> inbound          = list_rchan_new (loc_dom_site,
  67.                           mychan->ch_name);
  68.     ep->eit_types = NULL;
  69.     list_bpt_add(&ep->eit_types, list_bpt_new(hdr_822_bp));
  70.     list_bpt_add(&ep->eit_types, list_bpt_new(ia5_bp));
  71.     
  72.  
  73.         MPDUid_new (&qp -> msgid);
  74.  
  75.         /* -- create the ADDR struct for orig and recipient -- */
  76.         qp->Oaddress            = adr_new (getpostmaster(AD_822_TYPE), 
  77.                        AD_822_TYPE, 0);
  78.         qp->Raddress            = adr_new ((isstr(to->ad_r822DR)) ?
  79.                        to->ad_r822DR : to->ad_r822adr, 
  80.                        AD_822_TYPE, 1);
  81.  
  82.  
  83.         if (rp_isbad (io_wprm (&prm, rp))) {
  84.                 PP_LOG (LLOG_EXCEPTIONS, ("dr2rfc/io_wprm err %s",
  85.                                           rp -> rp_line));
  86.         stop_io();
  87.         (void) sprintf (error,
  88.                 "io_wprm error [%s]",
  89.                 rp -> rp_line);
  90.                 return RP_BAD;
  91.         }
  92.  
  93.  
  94.         if (rp_isbad (io_wrq (qp, rp))) {
  95.                 PP_LOG (LLOG_EXCEPTIONS, ("dr2rfc/io_wrq err %s",
  96.                                           rp -> rp_line));
  97.         stop_io();
  98.         (void) sprintf (error,
  99.                 "io_wrq error [%s]",
  100.                 rp -> rp_line);
  101.                 return RP_BAD;
  102.         }
  103.  
  104.  
  105.         if (rp_isbad (io_wadr (qp -> Oaddress, AD_ORIGINATOR, rp))) {
  106.                 PP_OPER (NULLCP, ("dr2rfc/io_wadr originator/postmaster err %s",
  107.                                           rp -> rp_line));
  108.         stop_io();
  109.         (void) sprintf (error,
  110.                 "io_wadr originator/postmaster error [%s]",
  111.                 rp -> rp_line);
  112.                 return RP_BAD;
  113.         }
  114.  
  115.  
  116.         if (rp_isbad (io_wadr (qp -> Raddress, AD_RECIPIENT, rp))) {
  117.                 PP_LOG (LLOG_EXCEPTIONS, ("dr2rfc/io_wadr recipient err %s",
  118.                                           rp -> rp_line));
  119.         recip_err = strdup(rp->rp_line);
  120.         if (rp_isbad(io_wadr(qp -> Oaddress, AD_RECIPIENT, rp))) {
  121.             PP_OPER (NULLCP, ("dr2rfc/io_wadr originator/postmaster err %s",
  122.                                           rp -> rp_line));
  123.             (void) sprintf (error,
  124.                     "io_wadr originator/postmaster error [%s]",    
  125.                     rp -> rp_line);
  126.             stop_io();
  127.             return RP_BAD;
  128.         }
  129.         } else 
  130.         recip_err = NULLCP;
  131.  
  132.  
  133.         if (rp_isbad (io_adend (rp))) {
  134.                 PP_LOG (LLOG_EXCEPTIONS, ("dr2rfc/io_adend err %s",
  135.                                           rp -> rp_line));
  136.         stop_io();
  137.         (void) sprintf (error,
  138.                 "io_adend error [%s]",
  139.                 rp -> rp_line);
  140.                 return RP_BAD;
  141.         }
  142.  
  143.         /* -- frees the structure -- */
  144.         q_free (qp);
  145.         return RP_OK;
  146.  
  147. }
  148.  
  149.