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

Defined variables

h_sccsid defined in line 5; never used

Defined struct's

link defined in line 172; used 3 times
node defined in line 156; used 3 times

Defined typedef's

Defined macros

ATSIGN defined in line 50; used 8 times
COSTING defined in line 44; used 2 times
DEADHOST defined in line 63; used 1 times
DEFCOST defined in line 104; used 2 times
DEFPENALTY defined in line 106; used 1 times
DUMP defined in line 57; never used
HASLEFT defined in line 53; used 7 times
HASRIGHT defined in line 54; used 7 times
INDFS defined in line 56; used 3 times
ISANET defined in line 62; used 9 times
LDEAD defined in line 119; used 6 times
LDIR defined in line 115; used 4 times
LGATEWAY defined in line 122; used 8 times
MAXNAME defined in line 38; used 5 times
NALIAS defined in line 49; used 6 times
NDEAD defined in line 52; used 5 times
NEWLINE defined in line 45; used 2 times
NNET defined in line 55; used 13 times
NTERMINAL defined in line 59; used 12 times
NTRACE defined in line 36; used 3 times
OTHER defined in line 43; used 2 times
PRINTED defined in line 58; used 7 times
l_from defined in line 133; used 15 times
n_copy defined in line 73; used 16 times
n_net defined in line 72; used 5 times
n_parent defined in line 76; used 32 times
n_private defined in line 75; used 5 times
n_root defined in line 71; used 11 times
p_node defined in line 25; used 139 times

Usage of this include

Last modified: 1988-04-16
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 4156
Valid CSS Valid XHTML 1.0 Strict