Annotation of 43BSD/contrib/pathalias/def.h, revision 1.1

1.1     ! root        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;

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.