Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / lib / gethost.c
blobb8eeac663db4a5287886bbc28db024936bbe7017
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2002-2004 by Darren Reed.
5 *
6 * See the IPFILTER.LICENCE file for details on licencing.
7 *
8 * Id: gethost.c,v 1.3.2.2 2006/06/16 17:20:59 darrenr Exp
9 */
11 #include "ipf.h"
13 int gethost(name, hostp)
14 char *name;
15 u_32_t *hostp;
17 struct hostent *h;
18 struct netent *n;
19 u_32_t addr;
21 if (!strcmp(name, "test.host.dots")) {
22 *hostp = htonl(0xfedcba98);
23 return 0;
26 if (!strcmp(name, "<thishost>"))
27 name = thishost;
29 h = gethostbyname(name);
30 if (h != NULL) {
31 if ((h->h_addr != NULL) && (h->h_length == sizeof(addr))) {
32 bcopy(h->h_addr, (char *)&addr, sizeof(addr));
33 *hostp = addr;
34 return 0;
38 n = getnetbyname(name);
39 if (n != NULL) {
40 *hostp = (u_32_t)htonl(n->n_net & 0xffffffff);
41 return 0;
43 return -1;