home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / lib / addr / ap_s2tree.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  1004 b   |  58 lines

  1. #include "util.h"
  2. #include "ap.h"
  3. #include "ll_log.h"
  4.  
  5. /* parse a string into an address tree */
  6.  
  7. extern LLog *logptr;
  8.  
  9. LOCVAR char *ap_strptr;
  10.  
  11. LOCVAR
  12.     getach ()       /* get next character from string */
  13. {
  14.     if (*ap_strptr == '\0')  /* end of the string, of course */
  15.     return (0);
  16.     return (*ap_strptr++);
  17. }
  18.  
  19. AP_ptr
  20.     ap_s2tree (thestr)
  21.     char thestr[];
  22. {
  23.     short gotone;
  24.     AP_ptr thetree;
  25.  
  26. #ifdef DEBUG
  27.     ll_log (logptr, LLOGBTR, "ap_s2tree (%s)", thestr);
  28. #endif
  29.  
  30.     ap_strptr = thestr;
  31.  
  32.     if ((thetree = ap_pinit (getach)) == (AP_ptr) NOTOK)
  33.     goto badend;
  34.     ap_clear();
  35.  
  36.     gotone = FALSE;
  37.     for ( ; ; )
  38.     switch (ap_1adr ()) {
  39.         case NOTOK:
  40.         ap_sqdelete (thetree, (AP_ptr) 0);
  41.         ap_free (thetree);
  42.     badend:
  43.         ap_strptr = (char *) 0;
  44.         return ((AP_ptr) NOTOK);
  45.  
  46.         case OK:
  47.             gotone = TRUE;
  48.         continue;       /* more to process */
  49.  
  50.         case DONE:
  51.         ap_strptr = (char *) 0;
  52.         if (gotone == FALSE)
  53.             return ((AP_ptr) NOTOK);
  54.         return (thetree);
  55.     }
  56.     /* NOTREACHED */
  57. }
  58.