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

  1. /* ch_nm2struct.c: convert channel name into structure */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/table/RCS/ch_nm2struct.c,v 6.0 1991/12/18 20:24:28 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/table/RCS/ch_nm2struct.c,v 6.0 1991/12/18 20:24:28 jpo Rel $
  9.  *
  10.  * $Log: ch_nm2struct.c,v $
  11.  * Revision 6.0  1991/12/18  20:24:28  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "util.h"
  19. #include "chan.h"
  20. #include "list_bpt.h"
  21.  
  22. extern char chrcnv[];
  23. #define LEXEQU(a,b)    (chrcnv[(a)[0]] == chrcnv[(b)[0]] && lexequ((a),(b)) ==0)
  24.  
  25. CHAN* ch_nm2struct (name)
  26. register char    *name;
  27. {
  28.     register CHAN   **chp, *chan;
  29.  
  30.     if (ch_all == (CHAN **)0)
  31.         return (NULLCHAN);
  32.  
  33.     for (chp = ch_all; (chan = *chp) != NULLCHAN; chp++)
  34.         if (LEXEQU (name, chan->ch_name) ||
  35.             (chan->ch_key && list_bpt_find (chan->ch_key, name) != NULLIST_BPT))
  36.             return (chan);
  37.     return (NULLCHAN);
  38. }
  39.  
  40. CHAN       *ch_mta2struct (name, mta)
  41. register char    *name;
  42. char    *mta;
  43. {
  44.     register CHAN    **cpp, *chan;
  45.     CHAN *good_match = NULLCHAN;
  46.     /* not actually used just there cos needed */
  47.     char    *subdom = NULLCP, chan_key[BUFSIZ], normalised[BUFSIZ];
  48.     
  49.     if (ch_all == (CHAN **)0)
  50.         return (NULLCHAN);
  51.  
  52.     for (cpp = ch_all; (chan = *cpp) != NULLCHAN; cpp++) {
  53.         if (! LEXEQU (name, chan->ch_name) &&
  54.             list_bpt_find (chan -> ch_key, name) == NULLIST_BPT)
  55.             continue;
  56.  
  57.         if (chan -> ch_mta_table == NULL)
  58.             good_match = chan;
  59.         else if (mta &&
  60.              tb_getdomain_table (chan -> ch_mta_table,
  61.                        mta, chan_key, normalised,
  62.                        chan -> ch_ad_order, &subdom) == OK) {
  63.             if (subdom) free(subdom);
  64.             return chan;
  65.         }
  66.         if (subdom) {
  67.             free(subdom);
  68.             subdom = NULLCP;
  69.         }
  70.     }
  71.     
  72.     return good_match;
  73. }
  74.