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

  1. /* or_or2dmn: convert or list into domain form */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/or/RCS/or_or2dmn.c,v 6.0 1991/12/18 20:23:08 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/or/RCS/or_or2dmn.c,v 6.0 1991/12/18 20:23:08 jpo Rel $
  9.  *
  10.  * $Log: or_or2dmn.c,v $
  11.  * Revision 6.0  1991/12/18  20:23:08  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "or.h"
  19. #include "util.h"
  20.  
  21. void fixup_space(str, dest)
  22. char    *str;
  23. char *dest;
  24. {
  25.     int     seen_space = TRUE;
  26.     char    *sp, *dp;
  27.  
  28.     for (sp = str, dp = dest; *sp; sp++) {
  29.         if (*sp == ' ') {
  30.             if (seen_space == FALSE)
  31.                 seen_space = TRUE;
  32.             else
  33.                 continue;
  34.         } else
  35.             seen_space = FALSE;
  36.         *dp++ = *sp;
  37.     }
  38.     if (dp > dest && dp[-1] == ' ')
  39.         dp --;
  40.     if (dp == dest)
  41.         (void) strcpy (dest, " ");
  42.     else
  43.         *dp = NULL;
  44. }
  45.  
  46. void or_or2dmn (first, last, buf)
  47. OR_ptr          first;
  48. OR_ptr          last;
  49. char            *buf;
  50. {
  51.     OR_ptr      or;
  52.  
  53.     PP_DBG (("or_util.c/or_or2dmn ()"));
  54.  
  55.     /*
  56.     We print from BOTTOM of tree
  57.     */
  58.  
  59.     if (last == NULLOR)
  60.     or = or_lastpart (first);
  61.     else
  62.     or = last;
  63.  
  64.     buf[0] = '\0';
  65.  
  66.     for (; or != NULLOR; or = or -> or_prev ) {
  67.  
  68.     PP_DBG (("or_util.c/or_or2dmn Comp type='%d' ddname='%s' val='%s'",
  69.         or -> or_type, or-> or_ddname, or -> or_value));
  70.  
  71.     if (buf[0] != '\0')
  72.         (void) strcat (buf, ".");
  73.  
  74.     if (or -> or_type == OR_DD) {
  75.         (void) strcat (buf, "~");
  76.         dstrcat (buf, or -> or_ddname );
  77.         (void) strcat (buf, "$");
  78.         dstrcat (buf, or -> or_value);
  79.     }
  80.     else {
  81.         char    *name;
  82.         char tbuf[BUFSIZ];
  83.         if ((name = or_type2name (or -> or_type)) != NULLCP)
  84.             (void) strcat (buf, name);
  85.         else
  86.             (void) strcat (buf, "BOGUS");
  87.         (void) strcat (buf, "$" );
  88.         fixup_space (or -> or_value, tbuf);
  89.         dstrcat (buf, tbuf);
  90.     }
  91.     }
  92.  
  93.     PP_DBG (("or_util.c/or_or2dmn Returns: '%s'", buf));
  94. }
  95.