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

  1. /* or2addr.c: */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Chans/lists/RCS/or2addr.c,v 6.0 1991/12/18 20:10:43 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Chans/lists/RCS/or2addr.c,v 6.0 1991/12/18 20:10:43 jpo Rel $
  9.  *
  10.  * $Log: or2addr.c,v $
  11.  * Revision 6.0  1991/12/18  20:10:43  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "dlist.h"
  19. #include "retcode.h"
  20. #include "or.h"
  21. #include "adr.h"
  22. #include <isode/quipu/attrvalue.h>
  23.  
  24. extern char * dn2str ();
  25.  
  26. static ADDR *OR_Ptr2ADDR (or,parse,orig) 
  27. OR_ptr or;
  28. char parse;
  29. char orig;
  30. {
  31.         ADDR * ptr;
  32.         char buf[BUFSIZ];
  33.         RP_Buf rp;
  34.  
  35.     or_or2std(or,buf,0);
  36.  
  37.     ptr = adr_new (buf,AD_X400_TYPE,1);
  38.     
  39.     if (orig) {
  40.       ptr->ad_resp = FALSE;
  41.       ptr->ad_status = AD_STAT_DONE;
  42.     }
  43.  
  44.         if (parse && (rp_isbad(ad_parse(ptr, &rp, CH_USA_ONLY))))
  45.                 return NULLADDR;
  46.  
  47.     return ptr;
  48.  
  49. }
  50.  
  51. ADDR *dn2ADDR (dn,orig) 
  52. DN dn;
  53. char orig;
  54. {
  55. Attr_Sequence as;
  56. OR_ptr newor, as2or ();
  57. ADDR * ptr;
  58.  
  59.     if (dn2addr (dn, &as) != OK)
  60.         return NULLADDR;
  61.  
  62.     newor = as2or (as);
  63.     if (newor) {
  64.         if ((ptr = OR_Ptr2ADDR (newor,TRUE,orig)) == NULLADDR)
  65.             return NULLADDR;
  66.         if (dn)
  67.             ptr->ad_dn = dn2str (dn);
  68.  
  69. /*
  70.         if (as->attr_value->avseq_next != NULLAV) {
  71.             newor = (OR_ptr) as->attr_value->avseq_next->avseq_av.av_struct;
  72.             or_or2std(newor,buf,0);
  73.             ptr->ad_orig_req_alt = strdup (buf);
  74.         }
  75. */
  76.  
  77.         return ptr;
  78.     } 
  79.     return NULLADDR;
  80. }
  81.  
  82. ADDR *ORName2ADDR (or,dnlookup) 
  83. ORName *or;
  84. char dnlookup;    /* allow DN look up if addr missing */
  85. {
  86. ADDR * ptr;
  87.  
  88.     if (or->on_or) {
  89.         ptr = OR_Ptr2ADDR (or->on_or,FALSE,FALSE);
  90.         if (or->on_dn)
  91.             ptr->ad_dn = dn2str (or->on_dn);
  92.     } else if (or->on_dn) {
  93.         if (dnlookup) 
  94.             if ((ptr = dn2ADDR(or->on_dn,FALSE)) != NULLADDR)
  95.                 return ptr;
  96.  
  97.         ptr = (ADDR *) smalloc (sizeof(ADDR));
  98.         adr_init (ptr);
  99.         ptr->ad_type = AD_ANY_TYPE;
  100.         ptr->ad_dn = dn2str (or->on_dn);
  101.     }
  102.  
  103.     return ptr;
  104. }
  105.  
  106.  
  107. orAddr_check (or,buf)
  108. OR_ptr or;
  109. char * buf;
  110. {
  111. ADDR * ad;
  112. RP_Buf rp;
  113. char adr[BUFSIZ];
  114.  
  115.     or_or2std(or,adr,0);
  116.  
  117.     ad = adr_new (adr,AD_X400_TYPE,1);
  118.  
  119.     if (rp_isbad(ad_parse(ad, &rp, CH_USA_ONLY))) {
  120.         (void) strcpy (buf,ad->ad_parse_message);
  121.         return NOTOK;
  122.     }
  123.  
  124.     adr_free (ad);
  125.  
  126.     return OK;
  127. }
  128.  
  129.