home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / auucp+-1.02 / fuucp_plus_src.lzh / pathalias / def.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-17  |  4.4 KB  |  157 lines

  1. /* pathalias -- by steve bellovin, as told to peter honeyman */
  2.  
  3. #ifndef lint
  4. #ifdef MAIN
  5. static char    *h_sccsid = "@(#)def.h    9.5 88/05/09";
  6. #endif /*MAIN*/
  7. #endif /*lint*/
  8.  
  9. #include <stdio.h>
  10. #include <ctype.h>
  11. #ifdef AMIGA
  12. #include <string.h>
  13. #endif AMIGA
  14. #include "config.h"
  15.  
  16. typedef    long Cost;
  17. typedef struct node node;
  18. typedef struct link link;
  19.  
  20. #ifdef lint
  21. #define vprintf fprintf
  22. #else /*!lint -- this gives null effect warning*/
  23. /* because it's there ... */
  24. #define vprintf        !Vflag ? 0 : fprintf
  25. #endif /*lint*/
  26.  
  27. #define NTRACE    16    /* can trace up to NTRACE hosts/links */
  28.  
  29. /* flags for n_flag */
  30. #define ISPRIVATE  0x0001 /* invisible outside its definition file */
  31. #define NALIAS       0x0002 /* heaped as an alias */
  32. #define ATSIGN       0x0004 /* seen an at sign?  used for magic @/% rules */
  33. #define MAPPED       0x0008 /* extracted from heap */
  34. #define    NDEAD       0x0010 /* out links are dead */
  35. #define HASLEFT       0x0020 /* has a left side net character */
  36. #define HASRIGHT   0x0040 /* route has a right side net character */
  37. #define    NNET       0x0080 /* network pseudo-host */
  38. #define INDFS       0x0100 /* used when removing net cycles (for -g) */
  39. #define DUMP       0x0200 /* we have dumped this net's edges (for -g) */
  40. #define PRINTED       0x0400 /* this host has been printed */
  41. #define NTERMINAL  0x0800 /* heaped as terminal edge (or alias thereto) */
  42. #define NREF       0x1000 /* node has an "interesting" reference */
  43.  
  44. #define ISADOMAIN(n)     ((n)->n_name[0] == '.')
  45. #define ISANET(n)     (((n)->n_flag & NNET) || ISADOMAIN(n))
  46. #define ALTEREGO(n1, n2) ((n1)->n_name == (n2)->n_name)
  47. #define DEADHOST(n)     (((n)->n_flag & (NDEAD | NTERMINAL)) && !ISANET(n))
  48. #define DEADLINK(l)     ((l)->l_flag & LDEAD)
  49. #define DEADNET(n)     (((n)->n_flag & (NNET | NDEAD)) == (NNET | NDEAD))
  50. #define GATEWAYED(n)     (DEADNET(n) || ISADOMAIN(n))
  51.  
  52. #ifndef DEBUG
  53. /*
  54.  * save some space in nodes -- there are > 10,000 allocated!
  55.  */
  56.  
  57. #define n_root un1.nu_root
  58. #define n_net un1.nu_net
  59. #define n_copy un1.nu_copy
  60.  
  61. #define n_private un2.nu_priv
  62. #define n_parent  un2.nu_par
  63.  
  64. /* WARNING: if > 2^16 nodes, type of n_tloc must change */
  65. struct node {
  66.     char    *n_name;    /* host name */
  67.     link    *n_link;    /* adjacency list */
  68.     Cost    n_cost;        /* cost to this host */
  69.     union {
  70.         node *nu_net;    /* others in this network (parsing) */
  71.         node *nu_root;    /* root of net cycle (graph dumping) */
  72.         node *nu_copy;    /* circular copy list (mapping) */
  73.     } un1;
  74.     union {
  75.         node *nu_priv;    /* other privates in this file (parsing) */
  76.         node *nu_par;    /* parent in shortest path tree (mapping) */
  77.     } un2;
  78.     unsigned short n_tloc;    /* back ptr to heap/hash table */
  79.     unsigned short n_flag;        /* see manifests above */
  80. };
  81.  
  82. #endif /*DEBUG*/
  83.  
  84. #define MILLION (1000L * 1000L)
  85. #define    DEFNET    '!'            /* default network operator */
  86. #define    DEFDIR    LLEFT            /* host on left is default */
  87. #define    DEFCOST    ((Cost) 4000)        /* default cost of a link */
  88. #define    INF    ((Cost) 100 * MILLION)    /* infinitely expensive link */
  89. #define DEFPENALTY ((Cost) 200)        /* default avoidance cost */
  90.  
  91. /* data structure for adjacency list representation */
  92.  
  93. /* flags for l_dir */
  94.  
  95. #define NETDIR(l)    ((l)->l_flag & LDIR)
  96. #define NETCHAR(l)    ((l)->l_netop)
  97.  
  98. #define LDIR      0x0008    /* 0 for left, 1 for right */
  99. #define LRIGHT      0x0000    /* user@host style */
  100. #define LLEFT      0x0008    /* host!user style */
  101.  
  102. #define LDEAD      0x0010    /* this link is dead */
  103. #define LALIAS      0x0020    /* this link is an alias */
  104. #define LTREE      0x0040    /* member of shortest path tree */
  105. #define LGATEWAY  0x0080    /* this link is a gateway */
  106. #define LTERMINAL 0x0100    /* this link is terminal */
  107.  
  108. #ifndef DEBUG
  109. /*
  110.  * borrow a field for link/node tracing.  there's a shitload of
  111.  * edges -- every word counts.  only so much squishing is possible:
  112.  * alignment dictates that the size be a multiple of four.
  113.  */
  114.  
  115. #define l_next un.lu_next
  116. #define l_from un.lu_from
  117.  
  118. struct link {
  119.     node    *l_to;        /* adjacent node */
  120.     Cost    l_cost;        /* edge cost */
  121.     union {
  122.         link *lu_next;    /* rest of adjacency list (not tracing) */
  123.         node *lu_from;    /* source node (tracing) */
  124.     } un;
  125.     short    l_flag;        /* right/left syntax, flags */
  126.     char    l_netop;    /* network operator */
  127. };
  128.  
  129. #endif /*DEBUG*/
  130.  
  131. #ifdef DEBUG
  132. /*
  133.  * flattening out the unions makes it easier
  134.  * to debug (when pi is unavailable).
  135.  */
  136. struct node {
  137.     char    *n_name;
  138.     link    *n_link;
  139.     Cost    n_cost;
  140.     node    *n_net;
  141.     node    *n_root;
  142.     node    *n_copy;
  143.     node    *n_private;
  144.     node    *n_parent;
  145.     unsigned short n_tloc;
  146.     unsigned short n_flag;
  147. };
  148. struct link {
  149.     node    *l_to;
  150.     Cost    l_cost;
  151.     link    *l_next;
  152.     node    *l_from;
  153.     short    l_flag;
  154.     char    l_netop;
  155. };
  156. #endif /*DEBUG*/
  157.