1 /* $NetBSD: irs.h,v 1.1.1.2 2012/09/09 16:07:48 christos Exp $ */ 2 3 /* 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 5 * Copyright (c) 1996,1999 by Internet Software Consortium. 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /* 21 * Id: irs.h,v 1.5 2005/04/27 04:56:15 sra Exp 22 */ 23 24 #ifndef _IRS_H_INCLUDED 25 #define _IRS_H_INCLUDED 26 27 /*! \file */ 28 29 #include <sys/types.h> 30 31 #include <arpa/nameser.h> 32 33 #include <grp.h> 34 #include <netdb.h> 35 #include <resolv.h> 36 #include <pwd.h> 37 38 /*% 39 * This is the group map class. 40 */ 41 struct irs_gr { 42 void * private; 43 void (*close) __P((struct irs_gr *)); 44 struct group * (*next) __P((struct irs_gr *)); 45 struct group * (*byname) __P((struct irs_gr *, const char *)); 46 struct group * (*bygid) __P((struct irs_gr *, gid_t)); 47 int (*list) __P((struct irs_gr *, const char *, 48 gid_t, gid_t *, int *)); 49 void (*rewind) __P((struct irs_gr *)); 50 void (*minimize) __P((struct irs_gr *)); 51 struct __res_state * (*res_get) __P((struct irs_gr *)); 52 void (*res_set) __P((struct irs_gr *, res_state, 53 void (*)(void *))); 54 }; 55 56 /*% 57 * This is the password map class. 58 */ 59 struct irs_pw { 60 void * private; 61 void (*close) __P((struct irs_pw *)); 62 struct passwd * (*next) __P((struct irs_pw *)); 63 struct passwd * (*byname) __P((struct irs_pw *, const char *)); 64 struct passwd * (*byuid) __P((struct irs_pw *, uid_t)); 65 void (*rewind) __P((struct irs_pw *)); 66 void (*minimize) __P((struct irs_pw *)); 67 struct __res_state * (*res_get) __P((struct irs_pw *)); 68 void (*res_set) __P((struct irs_pw *, res_state, 69 void (*)(void *))); 70 }; 71 72 /*% 73 * This is the service map class. 74 */ 75 struct irs_sv { 76 void * private; 77 void (*close) __P((struct irs_sv *)); 78 struct servent *(*byname) __P((struct irs_sv *, 79 const char *, const char *)); 80 struct servent *(*byport) __P((struct irs_sv *, int, const char *)); 81 struct servent *(*next) __P((struct irs_sv *)); 82 void (*rewind) __P((struct irs_sv *)); 83 void (*minimize) __P((struct irs_sv *)); 84 struct __res_state * (*res_get) __P((struct irs_sv *)); 85 void (*res_set) __P((struct irs_sv *, res_state, 86 void (*)(void *))); 87 }; 88 89 /*% 90 * This is the protocols map class. 91 */ 92 struct irs_pr { 93 void * private; 94 void (*close) __P((struct irs_pr *)); 95 struct protoent *(*byname) __P((struct irs_pr *, const char *)); 96 struct protoent *(*bynumber) __P((struct irs_pr *, int)); 97 struct protoent *(*next) __P((struct irs_pr *)); 98 void (*rewind) __P((struct irs_pr *)); 99 void (*minimize) __P((struct irs_pr *)); 100 struct __res_state * (*res_get) __P((struct irs_pr *)); 101 void (*res_set) __P((struct irs_pr *, res_state, 102 void (*)(void *))); 103 }; 104 105 /*% 106 * This is the hosts map class. 107 */ 108 struct irs_ho { 109 void * private; 110 void (*close) __P((struct irs_ho *)); 111 struct hostent *(*byname) __P((struct irs_ho *, const char *)); 112 struct hostent *(*byname2) __P((struct irs_ho *, const char *, int)); 113 struct hostent *(*byaddr) __P((struct irs_ho *, 114 const void *, int, int)); 115 struct hostent *(*next) __P((struct irs_ho *)); 116 void (*rewind) __P((struct irs_ho *)); 117 void (*minimize) __P((struct irs_ho *)); 118 struct __res_state * (*res_get) __P((struct irs_ho *)); 119 void (*res_set) __P((struct irs_ho *, res_state, 120 void (*)(void *))); 121 struct addrinfo *(*addrinfo) __P((struct irs_ho *, const char *, 122 const struct addrinfo *)); 123 }; 124 125 /*% 126 * This is the networks map class. 127 */ 128 struct irs_nw { 129 void * private; 130 void (*close) __P((struct irs_nw *)); 131 struct nwent * (*byname) __P((struct irs_nw *, const char *, int)); 132 struct nwent * (*byaddr) __P((struct irs_nw *, void *, int, int)); 133 struct nwent * (*next) __P((struct irs_nw *)); 134 void (*rewind) __P((struct irs_nw *)); 135 void (*minimize) __P((struct irs_nw *)); 136 struct __res_state * (*res_get) __P((struct irs_nw *)); 137 void (*res_set) __P((struct irs_nw *, res_state, 138 void (*)(void *))); 139 }; 140 141 /*% 142 * This is the netgroups map class. 143 */ 144 struct irs_ng { 145 void * private; 146 void (*close) __P((struct irs_ng *)); 147 int (*next) __P((struct irs_ng *, const char **, 148 const char **, const char **)); 149 int (*test) __P((struct irs_ng *, const char *, 150 const char *, const char *, 151 const char *)); 152 void (*rewind) __P((struct irs_ng *, const char *)); 153 void (*minimize) __P((struct irs_ng *)); 154 }; 155 156 /*% 157 * This is the generic map class, which copies the front of all others. 158 */ 159 struct irs_map { 160 void * private; 161 void (*close) __P((void *)); 162 }; 163 164 /*% 165 * This is the accessor class. It contains pointers to all of the 166 * initializers for the map classes for a particular accessor. 167 */ 168 struct irs_acc { 169 void * private; 170 void (*close) __P((struct irs_acc *)); 171 struct irs_gr * (*gr_map) __P((struct irs_acc *)); 172 struct irs_pw * (*pw_map) __P((struct irs_acc *)); 173 struct irs_sv * (*sv_map) __P((struct irs_acc *)); 174 struct irs_pr * (*pr_map) __P((struct irs_acc *)); 175 struct irs_ho * (*ho_map) __P((struct irs_acc *)); 176 struct irs_nw * (*nw_map) __P((struct irs_acc *)); 177 struct irs_ng * (*ng_map) __P((struct irs_acc *)); 178 struct __res_state * (*res_get) __P((struct irs_acc *)); 179 void (*res_set) __P((struct irs_acc *, res_state, 180 void (*)(void *))); 181 }; 182 183 /*% 184 * This is because the official definition of "struct netent" has no 185 * concept of CIDR even though it allows variant address families (on 186 * output but not input). The compatibility stubs convert the structs 187 * below into "struct netent"'s. 188 */ 189 struct nwent { 190 char *n_name; /*%< official name of net */ 191 char **n_aliases; /*%< alias list */ 192 int n_addrtype; /*%< net address type */ 193 void *n_addr; /*%< network address */ 194 int n_length; /*%< address length, in bits */ 195 }; 196 197 /*% 198 * Hide external function names from POSIX. 199 */ 200 #define irs_gen_acc __irs_gen_acc 201 #define irs_lcl_acc __irs_lcl_acc 202 #define irs_dns_acc __irs_dns_acc 203 #define irs_nis_acc __irs_nis_acc 204 #define irs_irp_acc __irs_irp_acc 205 #define irs_destroy __irs_destroy 206 #define irs_dns_gr __irs_dns_gr 207 #define irs_dns_ho __irs_dns_ho 208 #define irs_dns_nw __irs_dns_nw 209 #define irs_dns_pr __irs_dns_pr 210 #define irs_dns_pw __irs_dns_pw 211 #define irs_dns_sv __irs_dns_sv 212 #define irs_gen_gr __irs_gen_gr 213 #define irs_gen_ho __irs_gen_ho 214 #define irs_gen_ng __irs_gen_ng 215 #define irs_gen_nw __irs_gen_nw 216 #define irs_gen_pr __irs_gen_pr 217 #define irs_gen_pw __irs_gen_pw 218 #define irs_gen_sv __irs_gen_sv 219 #define irs_irp_get_full_response __irs_irp_get_full_response 220 #define irs_irp_gr __irs_irp_gr 221 #define irs_irp_ho __irs_irp_ho 222 #define irs_irp_is_connected __irs_irp_is_connected 223 #define irs_irp_ng __irs_irp_ng 224 #define irs_irp_nw __irs_irp_nw 225 #define irs_irp_pr __irs_irp_pr 226 #define irs_irp_pw __irs_irp_pw 227 #define irs_irp_read_line __irs_irp_read_line 228 #define irs_irp_sv __irs_irp_sv 229 #define irs_lcl_gr __irs_lcl_gr 230 #define irs_lcl_ho __irs_lcl_ho 231 #define irs_lcl_ng __irs_lcl_ng 232 #define irs_lcl_nw __irs_lcl_nw 233 #define irs_lcl_pr __irs_lcl_pr 234 #define irs_lcl_pw __irs_lcl_pw 235 #define irs_lcl_sv __irs_lcl_sv 236 #define irs_nis_gr __irs_nis_gr 237 #define irs_nis_ho __irs_nis_ho 238 #define irs_nis_ng __irs_nis_ng 239 #define irs_nis_nw __irs_nis_nw 240 #define irs_nis_pr __irs_nis_pr 241 #define irs_nis_pw __irs_nis_pw 242 #define irs_nis_sv __irs_nis_sv 243 #define net_data_create __net_data_create 244 #define net_data_destroy __net_data_destroy 245 #define net_data_minimize __net_data_minimize 246 247 /*% 248 * Externs. 249 */ 250 extern struct irs_acc * irs_gen_acc __P((const char *, const char *)); 251 extern struct irs_acc * irs_lcl_acc __P((const char *)); 252 extern struct irs_acc * irs_dns_acc __P((const char *)); 253 extern struct irs_acc * irs_nis_acc __P((const char *)); 254 extern struct irs_acc * irs_irp_acc __P((const char *)); 255 256 extern void irs_destroy __P((void)); 257 258 /*% 259 * These forward declarations are for the semi-private functions in 260 * the get*.c files. Each of these funcs implements the real get* 261 * functionality and the standard versions are just wrappers that 262 * call these. Apart from the wrappers, only irpd is expected to 263 * call these directly, hence these decls are put here and not in 264 * the /usr/include replacements. 265 */ 266 267 struct net_data; /*%< forward */ 268 /* 269 * net_data_create gets a singleton net_data object. net_data_init 270 * creates as many net_data objects as times it is called. Clients using 271 * the default interface will use net_data_create by default. Servers will 272 * probably want net_data_init (one call per client) 273 */ 274 struct net_data *net_data_create __P((const char *)); 275 struct net_data *net_data_init __P((const char *)); 276 void net_data_destroy __P((void *)); 277 278 extern struct group *getgrent_p __P((struct net_data *)); 279 extern struct group *getgrnam_p __P((const char *, struct net_data *)); 280 extern struct group *getgrgid_p __P((gid_t, struct net_data *)); 281 extern int setgroupent_p __P((int, struct net_data *)); 282 extern void endgrent_p __P((struct net_data *)); 283 extern int getgrouplist_p __P((const char *, gid_t, gid_t *, int *, 284 struct net_data *)); 285 286 #ifdef SETGRENT_VOID 287 extern void setgrent_p __P((struct net_data *)); 288 #else 289 extern int setgrent_p __P((struct net_data *)); 290 #endif 291 292 extern struct hostent *gethostbyname_p __P((const char *, 293 struct net_data *)); 294 extern struct hostent *gethostbyname2_p __P((const char *, int, 295 struct net_data *)); 296 extern struct hostent *gethostbyaddr_p __P((const char *, int, int, 297 struct net_data *)); 298 extern struct hostent *gethostent_p __P((struct net_data *)); 299 extern void sethostent_p __P((int, struct net_data *)); 300 extern void endhostent_p __P((struct net_data *)); 301 extern struct hostent *getipnodebyname_p __P((const char *, int, int, int *, 302 struct net_data *)); 303 extern struct hostent *getipnodebyaddr_p __P((const void *, size_t, 304 int, int *, struct net_data *)); 305 306 extern struct netent *getnetent_p __P((struct net_data *)); 307 extern struct netent *getnetbyname_p __P((const char *, struct net_data *)); 308 extern struct netent *getnetbyaddr_p __P((unsigned long, int, 309 struct net_data *)); 310 extern void setnetent_p __P((int, struct net_data *)); 311 extern void endnetent_p __P((struct net_data *)); 312 313 extern void setnetgrent_p __P((const char *, struct net_data *)); 314 extern void endnetgrent_p __P((struct net_data *)); 315 extern int innetgr_p __P((const char *, const char *, const char *, 316 const char *, struct net_data *)); 317 extern int getnetgrent_p __P((const char **, const char **, 318 const char **, struct net_data *)); 319 320 extern struct protoent *getprotoent_p __P((struct net_data *)); 321 extern struct protoent *getprotobyname_p __P((const char *, 322 struct net_data *)); 323 extern struct protoent *getprotobynumber_p __P((int, struct net_data *)); 324 extern void setprotoent_p __P((int, struct net_data *)); 325 extern void endprotoent_p __P((struct net_data *)); 326 327 328 extern struct passwd *getpwent_p __P((struct net_data *)); 329 extern struct passwd *getpwnam_p __P((const char *, struct net_data *)); 330 extern struct passwd *getpwuid_p __P((uid_t, struct net_data *)); 331 extern int setpassent_p __P((int, struct net_data *)); 332 extern void endpwent_p __P((struct net_data *)); 333 334 #ifdef SETPWENT_VOID 335 extern void setpwent_p __P((struct net_data *)); 336 #else 337 extern int setpwent_p __P((struct net_data *)); 338 #endif 339 340 extern struct servent *getservent_p __P((struct net_data *)); 341 extern struct servent *getservbyname_p __P((const char *, const char *, 342 struct net_data *)); 343 extern struct servent *getservbyport_p __P((int, const char *, 344 struct net_data *)); 345 extern void setservent_p __P((int, struct net_data *)); 346 extern void endservent_p __P((struct net_data *)); 347 348 #endif /*_IRS_H_INCLUDED*/ 349 350 /*! \file */ 351