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

  1. /* syn_oraddr.c: */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Chans/lists/RCS/syn_oraddr.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/syn_oraddr.c,v 6.0 1991/12/18 20:10:43 jpo Rel $
  9.  *
  10.  * $Log: syn_oraddr.c,v $
  11.  * Revision 6.0  1991/12/18  20:10:43  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. /* LINTLIBRARY */
  19.  
  20. #include "util.h"
  21. #include <varargs.h>
  22. #include "retcode.h"
  23. #include "adr.h"
  24. #include "ap.h"
  25. #include "dlist.h"
  26. #include <isode/quipu/attrvalue.h>
  27.  
  28. int gl_addr_parse_full = 1; /* do full check */
  29.  
  30. OR_ptr orAddr_parse (ptr)
  31. char * ptr;
  32. {
  33. OR_ptr or;
  34. char * str;
  35. ADDR * ad;
  36. RP_Buf rp;
  37.  
  38.     if (gl_addr_parse_full == 0) {
  39.         if ((or = or_std2or(ptr)) == NULLOR) {
  40.             parse_error ("std2or failed %s",ptr);
  41.             return (NULLOR);
  42.         }
  43.         return or;
  44.     }
  45.  
  46.     ad = adr_new (ptr, (or_str_isps(ptr)) ? AD_X400_TYPE : AD_822_TYPE, 1);
  47.     ad->ad_resp = NO;
  48.  
  49. #ifdef UKORDER
  50.     (void) ad_parse(ad, &rp, CH_UK_PREF);
  51. #else
  52.     (void) ad_parse(ad, &rp, CH_USA_PREF);
  53. #endif
  54.     if (ad->ad_r400adr == NULLCP) {
  55.         parse_error ("bad address %s",ad->ad_parse_message);
  56.         return NULLOR;
  57.     }
  58.  
  59.     if ((or = or_std2or(ad->ad_r400adr)) == NULLOR) {
  60.         parse_error ("std2or failed %s",ad->ad_r400adr);
  61.         adr_free (ad);
  62.         return (NULLOR);
  63.     }
  64.  
  65.     adr_free (ad);
  66.     
  67.     return (or);
  68. }
  69.  
  70. OR_ptr orAddr_parse_user (ptr)
  71. char * ptr;
  72. {
  73. OR_ptr or;
  74. ADDR * ad;
  75. RP_Buf rp;
  76.  
  77.     /* as above but normalize address */
  78.  
  79.     ad = adr_new (ptr, (*ptr == '/') ? AD_X400_TYPE : AD_822_TYPE, 0);
  80.     ad->ad_resp = YES;
  81.  
  82. #ifdef UKORDER
  83.     (void) ad_parse(ad, &rp, CH_UK_PREF);
  84. #else
  85.     (void) ad_parse(ad, &rp, CH_USA_PREF);
  86. #endif
  87.     if (ad->ad_r400adr == NULLCP) {
  88.         parse_error ("bad address %s",ad->ad_parse_message);
  89.         return NULLOR;
  90.     }
  91.  
  92.     if ((or = or_std2or(ad->ad_r400adr)) == NULLOR) {
  93.         parse_error ("std2or failed %s",ad->ad_r400adr);
  94.         adr_free (ad);
  95.         return (NULLOR);
  96.     }
  97.  
  98.     adr_free (ad);
  99.     
  100.     return (or);
  101. }
  102.  
  103. /* ARGSUSED */
  104. orAddr_print (ps,or,format)
  105. PS ps;
  106. OR_ptr or;
  107. int format;
  108. {
  109. char buf[LINESIZE];
  110.  
  111. /*
  112.     if ((format == READOUT) || (format == UFNOUT))
  113.         or_or2rfc (or,buf);
  114.     else
  115. */
  116.         or_or2std (or,buf,0);
  117.  
  118.     ps_printf (ps,"%s",buf);
  119. }
  120.  
  121. OR_ptr or_cpy (a)
  122. OR_ptr a;
  123. {
  124. OR_ptr top = NULLOR;
  125.  
  126.     for (; a != NULLOR; a=a->or_next) 
  127.         top = or_add (top,or_dup(a),FALSE);
  128.  
  129.     return (top);
  130. }
  131.  
  132. static int my_or_cmp (or1, or2)
  133. OR_ptr          or1;
  134. OR_ptr          or2;
  135. {
  136. int res;
  137.  
  138.     if (or1 -> or_type != or2 -> or_type) 
  139.     return (or1 -> or_type > or2 -> or_type) ? 1 : -1;
  140.  
  141.     if ((res = lexequ (or1 -> or_value, or2 -> or_value)) != 0)
  142.         return res;
  143.  
  144.     if (or1 -> or_type == OR_DD
  145.     && (res = lexequ (or1 -> or_ddname, or2 -> or_ddname)) != 0)
  146.         return res;
  147.  
  148.     return 0;
  149. }
  150.  
  151. orAddr_cmp (a,b)
  152. OR_ptr a,b;
  153. {
  154. int res;
  155.  
  156.     for (; (a != NULLOR) && (b != NULLOR) ; a = a->or_next, b = b->or_next) 
  157.         if ((res = my_or_cmp (a,b)) != 0) 
  158.             return res;
  159.  
  160.     if (( a == NULLOR) && (b == NULLOR)) 
  161.         return 0;
  162.     else
  163.         return (a == NULLOR) ? 1 : -1;
  164. }
  165.  
  166. extern OR_ptr pe2ora();
  167. extern PE ora2pe();
  168.  
  169. orAddr_syntax ()
  170. {
  171.     (void) add_attribute_syntax ("ORAddress",
  172.         (IFP) ora2pe,    (IFP) pe2ora,
  173.         (IFP) orAddr_parse,    orAddr_print,
  174.         (IFP) or_cpy,        orAddr_cmp,
  175.         (IFP) or_free,        NULLCP,
  176.         NULLIFP,        TRUE);
  177. }
  178.