1 /* 2 * Copyright (c) 1985,1989 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 * @(#)res.h 5.10 (Berkeley) 6/1/90 34 */ 35 36 /* 37 ******************************************************************************* 38 * 39 * res.h -- 40 * 41 * Definitions used by modules of the name server lookup program. 42 * 43 * Copyright (c) 1985 44 * Andrew Cherenson 45 * U.C. Berkeley 46 * CS298-26 Fall 1985 47 * 48 ******************************************************************************* 49 */ 50 51 #define TRUE 1 52 #define FALSE 0 53 typedef int Boolean; 54 55 /* 56 * Define return statuses in addtion to the ones defined in namserv.h 57 * let SUCCESS be a synonym for NOERROR 58 * 59 * TIME_OUT - a socket connection timed out. 60 * NO_INFO - the server didn't find any info about the host. 61 * ERROR - one of the following types of errors: 62 * dn_expand, res_mkquery failed 63 * bad command line, socket operation failed, etc. 64 * NONAUTH - the server didn't have the desired info but 65 * returned the name(s) of some servers who should. 66 * NO_RESPONSE - the server didn't respond. 67 * 68 */ 69 70 #define SUCCESS 0 71 #define TIME_OUT -1 72 #define NO_INFO -2 73 #define ERROR -3 74 #define NONAUTH -4 75 #define NO_RESPONSE -5 76 77 /* 78 * Define additional options for the resolver state structure. 79 * 80 * RES_DEBUG2 more verbose debug level 81 */ 82 83 #define RES_DEBUG2 0x80000000 84 85 /* 86 * Maximum length of server, host and file names. 87 */ 88 89 #define NAME_LEN 256 90 91 92 /* 93 * Modified struct hostent from <netdb.h> 94 * 95 * "Structures returned by network data base library. All addresses 96 * are supplied in host order, and returned in network order (suitable 97 * for use in system calls)." 98 */ 99 100 typedef struct { 101 char *name; /* official name of host */ 102 char **domains; /* domains it serves */ 103 char **addrList; /* list of addresses from name server */ 104 } ServerInfo; 105 106 typedef struct { 107 char *name; /* official name of host */ 108 char **aliases; /* alias list */ 109 char **addrList; /* list of addresses from name server */ 110 int addrType; /* host address type */ 111 int addrLen; /* length of address */ 112 ServerInfo **servers; 113 } HostInfo; 114 115 116 /* 117 * FilePtr is used for directing listings to a file. 118 * It is global so the Control-C handler can close it. 119 */ 120 121 extern FILE *filePtr; 122 123 /* 124 * TCP/UDP port of server. 125 */ 126 extern unsigned short nsport; 127 128 /* 129 * External routines: 130 */ 131 132 extern Boolean IsAddr(); 133 extern int Print_query(); 134 extern char *Print_cdname(); 135 extern char *Print_cdname2(); /* fixed width */ 136 extern char *Print_rr(); 137 extern char *DecodeType(); /* descriptive version of p_type */ 138 extern char *DecodeError(); 139 extern char *Calloc(); 140 extern char *Malloc(); 141 extern void NsError(); 142 extern void PrintServer(); 143 extern void PrintHostInfo(); 144 extern void ShowOptions(); 145 extern void FreeHostInfoPtr(); 146 extern FILE *OpenFile(); 147 extern char *res_skip(); 148