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

  1. /* syn_orname.c: */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Chans/lists/RCS/syn_orname.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_orname.c,v 6.0 1991/12/18 20:10:43 jpo Rel $
  9.  *
  10.  * $Log: syn_orname.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.  
  27. extern OR_ptr orAddr_parse();
  28. extern OR_ptr or_cpy();
  29. extern ORName *pe2orn();
  30. extern PE orn2pe();
  31.  
  32. ORName * orName_parse (str)
  33. char * str;
  34. {
  35. ORName * or;
  36. char * ptr;
  37.  
  38.     or = (ORName *) smalloc (sizeof (ORName));
  39.  
  40.     if ( (ptr=index (str,'$')) == NULLCP) {
  41.         if ((or->on_dn = str2dn (str)) == NULLDN)
  42.             return (NULLORName);
  43.         or->on_or = NULLOR;
  44.         return or;
  45.     }
  46.  
  47.     *ptr--= 0;
  48.     if (isspace (*ptr)) {
  49.         *ptr = 0;
  50.     }
  51.     ptr++;
  52.     ptr++;
  53.  
  54.     if (*str == 0)
  55.         or->on_dn = NULLDN;
  56.     else
  57.         if ((or->on_dn = str2dn (str)) == NULLDN)
  58.             return (NULLORName);
  59.  
  60.     ptr = SkipSpace(ptr);    
  61.     if (*ptr == 0)
  62.         or->on_or = NULLOR;
  63.     else if ((or->on_or = orAddr_parse (ptr)) == NULLOR)
  64.         return (NULLORName);
  65.     
  66.     return (or);
  67. }
  68.  
  69. orName_print (ps,or,format)
  70. PS ps;
  71. ORName * or;
  72. int format;
  73. {
  74.     if (or == NULLORName)
  75.         return;
  76.     if (or->on_dn != NULLDN) {
  77.  
  78.         dn_print (ps,or->on_dn,format);
  79.  
  80.         if ((format == UFNOUT) || format == READOUT) 
  81.             return;
  82.     }
  83.  
  84.     if ((format != READOUT) && (format != UFNOUT))
  85.         ps_print (ps," $ ");
  86.     else if (or->on_dn == NULLDN)
  87.         ps_print (ps,"X.400 Address: ");
  88.  
  89.     if (or->on_or)
  90.         orAddr_print (ps,or->on_or,format);
  91.  
  92. }
  93.  
  94. ORName * orName_cpy (a)
  95. ORName * a;
  96. {
  97. ORName * top;
  98.  
  99.     top = (ORName *) smalloc (sizeof (ORName));
  100.     top->on_or = or_cpy (a->on_or);
  101.     top->on_dn = dn_cpy (a->on_dn);
  102.  
  103.     return (top);
  104. }
  105.  
  106. orName_cmp (a,b)
  107. ORName *a, *b;
  108. {
  109. int res;
  110.     if ( a == NULLORName)
  111.         return (b == NULLORName ? 0 : -1);
  112.     if ( b == NULLORName)
  113.         return     1;
  114.  
  115.     if ((res = dn_cmp (a->on_dn,b->on_dn)) == 0) 
  116.          return orAddr_cmp (a->on_or,b->on_or);
  117.     else
  118.         return res;
  119. }
  120.  
  121. orName_cmp_user (a,b)
  122. ORName *a, *b;
  123. {
  124.     /* IF DN's equal -> match OK */
  125.  
  126.     if ((a->on_dn == NULLDN) || (b->on_dn == NULLDN))
  127.          return orAddr_cmp (a->on_or,b->on_or);
  128.  
  129.     return dn_cmp (a->on_dn,b->on_dn);
  130. }
  131.  
  132. extern IFP orName_free();
  133.  
  134. orName_syntax ()
  135. {
  136.     (void) add_attribute_syntax ("ORName",
  137.         (IFP) orn2pe,    (IFP) pe2orn,
  138.         (IFP) orName_parse,    orName_print,
  139.         (IFP) orName_cpy,    orName_cmp,
  140.         ORName_free,        NULLCP,
  141.         NULLIFP,        TRUE);
  142. }
  143.