home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / lib / addr / adrparse.c next >
Encoding:
C/C++ Source or Header  |  1989-05-11  |  1.5 KB  |  64 lines

  1. /*
  2. **
  3. **    R E V I S I O N  H I S T O R Y
  4. **
  5. **    03/08/85    LDK    Added compress() in this module to remove
  6. **            VAK    leading and trailing space.
  7. **
  8. */
  9.  
  10. #include "util.h"
  11. #include "mmdf.h"
  12. #include "ap.h"
  13.  
  14. extern    char    *ap_s2p();
  15. extern    char    *ap_p2s();
  16. extern    char    *compress();
  17. extern    int    ap_outtype;
  18. extern    LLog    *logptr;
  19.  
  20. parsadr(thestr, name, mbox, host)
  21. register char *thestr;        /* string with an address    */
  22. char    *name,            /* where to put name part    */
  23.     *mbox,            /* where to put mailbox part    */
  24.     *host;            /* where to put hostname part    */
  25. {
  26.     register    char    *cp;
  27.             AP_ptr    treep, namep, local, domain, routep;
  28.             char    *route;
  29.             char    tbuf[LINESIZE];
  30.  
  31.     ap_outtype = AP_822;
  32.  
  33.     if (name != (char *)0)
  34.         *name = '\0';
  35.     if (mbox != (char *)0)
  36.         *mbox = '\0';
  37.     if (host != (char *)0)
  38.         *host = '\0';
  39.  
  40.     cp = ap_s2p (thestr, &treep, (AP_ptr *)0, &namep,
  41.                 &local, &domain, &routep);
  42.     if (cp == (char *)DONE || cp == (char *)NOTOK)
  43.         return;
  44.     else if (local->ap_obvalue == NULL)
  45.         return;        /* Bad format */
  46.     if (name && namep != 0 && namep->ap_obvalue != 0)
  47.         (void) strcpy(name, namep->ap_obvalue);
  48.     if (mbox && local != 0 && local->ap_obvalue != 0)
  49.         (void) strcpy(mbox, local->ap_obvalue);
  50.     if (host && domain != 0 && domain->ap_obvalue != 0)
  51.         (void) strcpy(host, domain->ap_obvalue);
  52.     if (mbox && routep != (AP_ptr)0 &&
  53.         (route = ap_p2s((AP_ptr)0, (AP_ptr)0,
  54.         (AP_ptr)0, (AP_ptr)0, routep)) != (char *)NOTOK)
  55.     {
  56.         (void) strcpy(tbuf, route);
  57.         free(route);
  58.         (void) strcat(tbuf, mbox);
  59.         (void) strcpy(mbox, tbuf);
  60.     }
  61.     ap_free(treep);
  62.     return;
  63. }
  64.