home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / format / adr2rfc.c next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  4.6 KB  |  194 lines

  1. /* adr2rfc.c - Converts an X400 address into an RFC one */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/format/RCS/adr2rfc.c,v 6.0 1991/12/18 20:22:06 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/format/RCS/adr2rfc.c,v 6.0 1991/12/18 20:22:06 jpo Rel $
  9.  *
  10.  * $Log: adr2rfc.c,v $
  11.  * Revision 6.0  1991/12/18  20:22:06  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "util.h"
  19. #include "or.h"
  20. #include "adr.h"
  21. #include <isode/cmd_srch.h>
  22.  
  23.  
  24. /* -------------------- Begin Routines  ----------------------------------- */
  25.  
  26. extern char    *oid2lstr();
  27.  
  28. extern CMD_TABLE atbl_rdm[], atbl_pd_modes[], atbl_reg_mail[];
  29.  
  30. int adr2rfc (ap, buffer, order_pref)
  31. ADDR    *ap;
  32. char    *buffer;
  33. int    order_pref;
  34. {
  35.     OR_ptr  or;
  36.     char    lbuf[LINESIZE];
  37.     char    *str = NULLCP;
  38.  
  39.     /* -- RFC or X400 address ? -- */
  40.  
  41.     if (ap->ad_r822adr)
  42.         (void) strcpy (buffer, ap->ad_r822adr);
  43.     else if (ap->ad_type == AD_822_TYPE)
  44.         return NOTOK;
  45.  
  46.     else if (ap->ad_r400adr) {
  47.         if ((or = or_std2or (ap->ad_r400adr)) == NULLOR)
  48.             return NOTOK;
  49.         if (or_or2rfc (or, lbuf) == NOTOK)
  50.             return NOTOK;
  51.         or_free (or);
  52.         (void) strcpy (buffer, lbuf);
  53.     }
  54.     else
  55.         return NOTOK;
  56.  
  57.  
  58.     ap_s2s(buffer, &str, order_pref);
  59.     if (str != NULLCP) {
  60.         (void) strcpy (buffer, str);
  61.         free (str);
  62.     }
  63.     if (ap -> ad_no != 0) /* don't do for Originator */
  64.         return adr2comments(ap, buffer);
  65.     return OK;
  66. }
  67.  
  68. int adr2comments(ap, buffer)
  69. ADDR    *ap;
  70. char    *buffer;
  71. {
  72.     char    lbuf[LINESIZE];
  73.     char    *type;
  74.  
  75.     /* do 1148 stuff */
  76.     if (ap -> ad_redirection_history != NULL) {
  77.         char        *reason;
  78.         Redirection    *ix = ap -> ad_redirection_history;
  79.         (void) strcat(buffer, " (");
  80.         while (ix != NULL) {
  81.             switch (ix->rd_reason) {
  82.                 case RDR_RECIP_ASSIGNED:
  83.                 reason = "Recipient Assigned Alternate Recipient";
  84.                 break;
  85.                 case RDR_ORIG_ASSIGNED:
  86.                 reason = "Originator Requested Alternate Recipient";
  87.                 break;
  88.                 case RDR_MD_ASSIGNED:
  89.                 reason = "Recipient MD Assigned Alternate Recipient";
  90.                 break;
  91.                 default:
  92.                 reason = NULLCP;
  93.                 break;
  94.             }
  95.  
  96.             if (ix->rd_addr != NULLCP
  97.                 || ix->rd_dn != NULLCP) {
  98.                 if (ix == ap->ad_redirection_history)
  99.                     (void) strcat(buffer, "Originally To: ");
  100.                 else
  101.                     (void) strcat (buffer, " ");
  102.                 (void) strcat (buffer,
  103.                            (ix -> rd_addr != NULLCP) ?
  104.                            ix -> rd_addr : ix -> rd_dn);
  105.             }
  106.             if (ix == ap->ad_redirection_history)
  107.                 (void) strcat (buffer, " Redirected on ");
  108.             else
  109.                 (void) strcat (buffer, " Redirected Again on ");
  110.                 
  111.             if (UTC2rfc (ix->rd_time, lbuf) != OK)
  112.                 return NOTOK;
  113.             (void) strcat (buffer, lbuf);
  114.             (void) strcat (buffer, " To: ");
  115.             if (reason != NULLCP)
  116.                 (void) strcat (buffer, reason);
  117.             ix = ix -> rd_next;
  118.         }
  119.         (void) strcat (buffer, ")");
  120.     }
  121.  
  122.     if (ap -> ad_req_del[0] != AD_RDM_NOTUSED
  123.         && ap -> ad_req_del[0] != AD_RDM_ANY) {
  124.         int ix = 0, first = OK;
  125.  
  126.         (void) sprintf (buffer,
  127.                 "%s (Requested Delivery Methods ",
  128.                 buffer);
  129.         while (ix < AD_RDM_MAX 
  130.                && ap -> ad_req_del[ix] != AD_RDM_NOTUSED
  131.                && ap -> ad_req_del[ix] != AD_RDM_ANY) {
  132.             if ((type = rcmd_srch(ap -> ad_req_del[ix],
  133.                           atbl_rdm)) != NULLCP)
  134.                 (void) sprintf(buffer,
  135.                            "%s%s%s",
  136.                            buffer,
  137.                            (first == OK) ? "" : ", ",
  138.                            type);
  139.             ix++;
  140.             first = NOTOK;
  141.         }
  142.         (void) sprintf (buffer, "%s)", buffer);
  143.     }
  144.         
  145.     if (ap -> ad_phys_forward)
  146.         (void) sprintf (buffer,
  147.                 "%s (Physical Forwarding Prohibited)",
  148.                 buffer);
  149.         
  150.     if (ap -> ad_phys_fw_ad_req)
  151.         (void) sprintf (buffer,
  152.                 "%s (Physical Forwarding Address Requested)",
  153.                 buffer);
  154.         
  155.     if (ap -> ad_phys_modes
  156.         && ap -> ad_phys_modes != AD_PM_ORD
  157.         && (type = rcmd_srch (ap -> ad_phys_modes, atbl_pd_modes)) != NULLCP)
  158.         (void) sprintf (buffer,
  159.                 "%s (Physical Delivery Mode %s)",
  160.                 buffer, type);
  161.         
  162.     if (ap -> ad_reg_mail_type
  163.         && ap -> ad_reg_mail_type != AD_RMT_UNSPECIFIED
  164.         && (type = rcmd_srch (ap -> ad_reg_mail_type, atbl_reg_mail)) != NULLCP)
  165.         (void) sprintf (buffer,
  166.                 "%s (Registered Mail Type %s)",
  167.                 buffer, type);
  168.         
  169.     if (ap -> ad_recip_number_for_advice != NULLCP)
  170.         (void) sprintf (buffer,
  171.                 "%s (Recipient Number For Advice %s)",
  172.                 buffer, 
  173.                 ap -> ad_recip_number_for_advice);
  174.         
  175.     if (ap -> ad_phys_rendition_attribs != NULL)
  176.         (void) sprintf (buffer,
  177.                 "%s (Physical Rendition Attributes %s)",
  178.                 buffer, 
  179.                 oid2lstr(ap -> ad_phys_rendition_attribs));
  180.  
  181.     if (ap -> ad_pd_report_request)
  182.         (void) sprintf (buffer,
  183.                 "%s (Physical Delivery Report Requested)",
  184.                 buffer);
  185.  
  186.     if (ap -> ad_proof_delivery)
  187.         (void) sprintf (buffer,
  188.                 "%s (Proof of Delivery Requested)",
  189.                 buffer);
  190.         
  191.     PP_DBG (("Lib/adr2rfc returns (%s)", buffer));
  192.     return OK;
  193. }
  194.