home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.sbin / named / db.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-24  |  4.4 KB  |  131 lines

  1. /*
  2.  * Copyright (c) 1985, 1990 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)db.h    4.16 (Berkeley) 6/1/90
  34.  */
  35.  
  36. /*
  37.  * Global structures and variables for data base routines.
  38.  */
  39.  
  40. #define INVBLKSZ    7    /* # of namebuf pointers per block */
  41. #define INVHASHSZ    919    /* size of inverse hash table */
  42.  
  43.     /* max length of data in RR data field */
  44. #define MAXDATA        2048
  45.  
  46. /*
  47.  * Hash table structures.
  48.  */
  49. struct databuf {
  50.     struct    databuf *d_next;    /* linked list */
  51.     u_long    d_ttl;            /* time to live */
  52.     short    d_flags;
  53.     short    d_zone;            /* zone number */
  54.     short    d_class;        /* class number */
  55.     short    d_type;            /* type number */
  56.     short    d_mark;            /* place to mark data */
  57.     short    d_size;            /* size of data area */
  58.     u_long    d_nstime;        /* NS response time, milliseconds */
  59.     char    d_data[1];         /* the data is malloc'ed to size */
  60. };
  61. #define DATASIZE(n) (sizeof(struct databuf) - 1 + n)
  62.  
  63. /*
  64.  * d_flags definitions
  65.  */
  66. #define DB_F_HINT       0x01    /* databuf belongs to fcachetab */
  67.  
  68. struct namebuf {
  69.     char    *n_dname;        /* domain name */
  70.     u_int    n_hashval;        /* hash value of n_dname */
  71.     struct    namebuf *n_next;    /* linked list */
  72.     struct    databuf *n_data;    /* data records */
  73.     struct    namebuf *n_parent;    /* parent domain */
  74.     struct    hashbuf *n_hash;    /* hash table for children */
  75. };
  76.  
  77. struct invbuf {
  78.     struct    invbuf *i_next;        /* linked list */
  79.     struct    namebuf    *i_dname[INVBLKSZ];    /* domain name */
  80. };
  81.  
  82. struct hashbuf {
  83.     int    h_size;            /* size of hash table */
  84.     int    h_cnt;            /* number of entries */
  85.     struct    namebuf    *h_tab[1];    /* malloc'ed as needed */
  86. };
  87. #define HASHSIZE(s) (s*sizeof(struct namebuf *) + 2*sizeof(int))
  88.  
  89. #define HASHSHIFT    3
  90. #define HASHMASK    0x1f
  91.  
  92. /*
  93.  * Flags to updatedb
  94.  */
  95. #define DB_NODATA    0x01    /* data should not exist */
  96. #define DB_MEXIST    0x02    /* data must exist */
  97. #define DB_DELETE    0x04    /* delete data if it exists */
  98. #define DB_NOTAUTH    0x08    /* must not update authoritative data */
  99. #define DB_NOHINTS      0x10    /* don't reflect update in fcachetab */
  100.  
  101. #define DB_Z_CACHE      (0)    /* cache-zone-only db_dump()  */
  102. #define DB_Z_ALL        (-1)    /* normal db_dump() */
  103.  
  104. /*
  105.  * Error return codes
  106.  */
  107. #define OK        0
  108. #define NONAME        -1
  109. #define NOCLASS        -2
  110. #define NOTYPE        -3
  111. #define NODATA        -4
  112. #define DATAEXISTS    -5
  113. #define NODBFILE    -6
  114. #define TOOMANYZONES    -7
  115. #define GOODDB        -8
  116. #define NEWDB        -9
  117. #define AUTH        -10
  118.  
  119. extern struct hashbuf *hashtab;        /* root hash table */
  120. extern struct invbuf *invtab[];        /* inverse hash table */
  121. extern struct hashbuf *fcachetab;    /* hash table for cache read from file*/
  122.  
  123. extern struct namebuf *nlookup();
  124. extern struct namebuf *savename();
  125. extern struct databuf *savedata();
  126. extern struct databuf *rm_datum();
  127. extern struct hashbuf *savehash();
  128. extern struct invbuf *saveinv();
  129. extern char *savestr();
  130. extern char *malloc(), *realloc(), *calloc();
  131.