1: /* pathalias -- by steve bellovin, as told to peter honeyman */
   2: #ifndef lint
   3: #ifdef MAIN
   4: static char *h_sccsid = "@(#)def.h	8.1 (down!honey) 86/01/19";
   5: #endif /*MAIN*/
   6: #endif /*lint*/
   7: 
   8: #include <stdio.h>
   9: #include <ctype.h>
  10: #include "config.h"
  11: 
  12: typedef long Cost;
  13: typedef struct node node;
  14: typedef struct link link;
  15: 
  16: #ifdef lint
  17: #define vprintf fprintf
  18: #else /*!lint -- this gives null effect warning*/
  19: /* because it's there ... */
  20: #define vprintf     !Vflag ? 0 : fprintf
  21: #endif /*lint*/
  22: 
  23: #define NTRACE  16  /* can trace up to NTRACE hosts/links */
  24: 
  25: /* scanner states (yylex, parse) */
  26: #define OTHER 0
  27: #define COSTING 1
  28: #define NEWLINE 2
  29: 
  30: #define isnetc(c)   ((c)=='!' || (c)==':' || (c)=='@' || (c)=='%')
  31: 
  32: #define dirbits(c)  (c)
  33: 
  34: /* flags for n_flag */
  35: #define ISPRIVATE  0x0001 /* this node invisible outside its definition file */
  36: #define COLLISION  0x0002 /* collides with a private host name */
  37: #define ATSIGN     0x0004 /* seen an at sign?  used for magic @/% rules */
  38: #define MAPPED     0x0008 /* done mapping this node */
  39: #define NDEAD      0x0010 /* node is dead */
  40: #define HASLEFT    0x0020 /* route has a left side net character */
  41: #define HASRIGHT   0x0040 /* route has a right side net character */
  42: #define NNET       0x0080 /* node is a network name */
  43: #define INDFS      0x0100 /* used when removing net cycles */
  44: #define DUMP       0x0200 /* we have dumped this net's edges */
  45: #define GATEWAYIN  0x0400 /* heaped via gatewayed net */
  46: 
  47: #define ISADOMAIN(n) ((n)->n_name[0] == '.')
  48: #define ISANET(n) (((n)->n_flag & NNET) || ISADOMAIN(n))
  49: #define DEADHOST(n) (((n)->n_flag & (NNET | NDEAD)) == NDEAD)
  50: #define GATEWAYED(n) (((n)->n_flag & (NNET | NDEAD)) == (NNET | NDEAD) || ISADOMAIN(n))
  51: 
  52: 
  53: /*
  54:  * save some space in nodes -- there are > 10,000 allocated!
  55:  *
  56:  *	node	*n_net		others in this network (parsing)
  57:  * 	node	*n_root		root of net cycle (mapping)
  58:  *
  59:  *	node	*n_private	other privates in this file (parsing)
  60:  *	char	*n_parent	parent in shortest path tree (mapping)
  61:  *
  62:  */
  63: 
  64: #define n_root n_net_root
  65: #define n_net n_net_root
  66: 
  67: #define n_private n_private_parent
  68: #define n_parent  n_private_parent
  69: 
  70: /* WARNING: if > 2^16 nodes, type of n_tloc must change */
  71: struct node {
  72:     char    *n_name;    /* host name */
  73:     link    *n_link;    /* head of adjacency list */
  74:     node    *n_net_root;
  75:     node    *n_private_parent;
  76:     Cost    n_cost;     /* cost to this host */
  77:     unsigned short  n_tloc; /* back ptr to heap/hash table */
  78:     short   n_flag;     /* see manifests above */
  79: };
  80: 
  81: #define DEFNET  '!'         /* default network operator */
  82: #define DEFDIR  LLEFT           /* host on left is default */
  83: #define DEFCOST ((Cost) 4000)       /* default cost of a link */
  84: #define INF ((Cost) 30000000)   /* infinitely expensive link */
  85: 
  86: /* data structure for adjacency list representation */
  87: 
  88: /* flags for l_dir */
  89: 
  90: /*
  91:  * there's an ugly dependency between the following manifests and the
  92:  * variable Netchars = "!:^@%", defined in extern.c.  this saves 2
  93:  * bytes per link (of which there are well over 20k).  this does not
  94:  * mean i'm satsified with bad design.
  95:  */
  96: #define NETDIR(l)   ((l)->l_flag & LDIR)
  97: #define NETCHAR(l)  (Netchars[(l)->l_flag & LNETCHARS])
  98: 
  99: #define LNETCHARS   0x3
 100: #define LBANG       0x0
 101: #define LCOLON      0x1
 102: #define LAT     0x2
 103: #define LPERCENT    0x3
 104: 
 105: #define LDIR    0x8 /* 0 for left, 1 for right */
 106: #define LRIGHT  0x0 /* user@host style */
 107: #define LLEFT   0x8 /* host!user style */
 108: 
 109: #define LDEAD    0x10   /* this link is dead */
 110: #define LTREE    0x20   /* member of shortest path tree */
 111: #define LALIAS   0x40   /* alias */
 112: #define LGATEWAY 0x80   /* this link is a gateway */
 113: 
 114: /*
 115:  * borrow a field for link/node tracing
 116:  *
 117:  *	link	*l_next;	rest of adjacency list (not tracing)
 118:  *	link	*l_from;	source node (tracing) -- requires a cast
 119:  *
 120:  */
 121: 
 122: #define l_next  l_next_from
 123: #define l_from  l_next_from
 124: 
 125: struct link {
 126:     link    *l_next_from;
 127:     node    *l_to;      /* adjacent node */
 128:     Cost    l_cost;     /* edge cost */
 129:     char    l_flag;     /* right/left syntax */
 130: };
 131: 
 132: /*
 133:  * static functions don't show up in prof(1), so ...
 134:  * someday i'll be done profiling.
 135:  * yeah, sure, like when hell freezes over.
 136:  */
 137: #define STATIC /*static*/
 138: 
 139: /* external functions */
 140: extern node *addnode(), *newnode(), **newtable(), *addprivate();
 141: extern link *addlink(), *addgateway(), *newlink();
 142: extern char *strsave(), *local();
 143: extern void pack();
 144: 
 145: /* external variables */
 146: extern char *optarg;
 147: extern int  optind;
 148: extern node *Home;
 149: extern char *Cfile;
 150: extern char **Ifiles;
 151: extern char *ProgName;
 152: extern int  Lineno;
 153: extern node **Table;
 154: extern long Tabsize;
 155: extern char *Netchars;
 156: extern int  Vflag;
 157: extern int  Cflag;
 158: extern int  Iflag;
 159: extern int  Tflag;
 160: extern int  Ncount;
 161: extern int  Lcount;
 162: extern char *Graphout;
 163: extern char *Linkout;
 164: extern node *Private;
 165: extern long Hashpart;
 166: extern int  Scanstate;

Defined variables

h_sccsid defined in line 4; never used

Defined struct's

link defined in line 125; used 1 times
  • in line 14
node defined in line 71; used 1 times
  • in line 13

Defined typedef's

Defined macros

ATSIGN defined in line 37; used 4 times
COLLISION defined in line 36; used 3 times
COSTING defined in line 27; used 2 times
DEADHOST defined in line 49; used 1 times
DUMP defined in line 44; never used
GATEWAYIN defined in line 45; used 4 times
HASLEFT defined in line 40; used 6 times
HASRIGHT defined in line 41; used 6 times
INDFS defined in line 43; used 3 times
ISADOMAIN defined in line 47; used 13 times
ISANET defined in line 48; used 4 times
LAT defined in line 102; never used
LBANG defined in line 100; never used
LCOLON defined in line 101; never used
LDEAD defined in line 109; used 5 times
LDIR defined in line 105; used 2 times
LGATEWAY defined in line 112; used 6 times
LNETCHARS defined in line 99; used 2 times
LPERCENT defined in line 103; never used
LTREE defined in line 110; used 3 times
MAPPED defined in line 38; used 3 times
NDEAD defined in line 39; used 5 times
NETCHAR defined in line 97; used 1 times
NETDIR defined in line 96; used 5 times
NEWLINE defined in line 28; used 2 times
NTRACE defined in line 23; used 3 times
OTHER defined in line 26; used 2 times
dirbits defined in line 32; used 1 times
isnetc defined in line 30; never used
l_from defined in line 123; used 7 times
n_net defined in line 65; used 4 times
n_private defined in line 67; used 4 times
n_root defined in line 64; used 10 times

Usage of this include

Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1135
Valid CSS Valid XHTML 1.0 Strict