version 1.7, 2014/10/20 16:19:05 |
version 1.8, 2014/10/24 10:23:32 |
|
|
static int ethers(int, char *[]); |
static int ethers(int, char *[]); |
static int group(int, char *[]); |
static int group(int, char *[]); |
static int hosts(int, char *[]); |
static int hosts(int, char *[]); |
static int networks(int, char *[]); |
|
static int passwd(int, char *[]); |
static int passwd(int, char *[]); |
static int protocols(int, char *[]); |
static int protocols(int, char *[]); |
static int rpc(int, char *[]); |
static int rpc(int, char *[]); |
|
|
{ "ethers", ethers, }, |
{ "ethers", ethers, }, |
{ "group", group, }, |
{ "group", group, }, |
{ "hosts", hosts, }, |
{ "hosts", hosts, }, |
{ "networks", networks, }, |
|
{ "passwd", passwd, }, |
{ "passwd", passwd, }, |
{ "protocols", protocols, }, |
{ "protocols", protocols, }, |
{ "rpc", rpc, }, |
{ "rpc", rpc, }, |
|
|
break; |
break; |
} |
} |
} |
} |
return rv; |
|
} |
|
|
|
static void |
|
networksprint(const struct netent *ne) |
|
{ |
|
char buf[INET6_ADDRSTRLEN]; |
|
struct in_addr ianet; |
|
|
|
ianet = inet_makeaddr(ne->n_net, 0); |
|
if (inet_ntop(ne->n_addrtype, &ianet, buf, sizeof(buf)) == NULL) |
|
strlcpy(buf, "# unknown", sizeof(buf)); |
|
printfmtstrings(ne->n_aliases, " ", " ", "%-16s %s", ne->n_name, buf); |
|
} |
|
|
|
static int |
|
networks(int argc, char *argv[]) |
|
{ |
|
int i, rv = RV_OK; |
|
struct netent *ne; |
|
in_addr_t net; |
|
|
|
setnetent(1); |
|
if (argc == 2) { |
|
while ((ne = getnetent()) != NULL) |
|
networksprint(ne); |
|
} else { |
|
for (i = 2; i < argc; i++) { |
|
net = inet_network(argv[i]); |
|
if (net != INADDR_NONE) |
|
ne = getnetbyaddr(net, AF_INET); |
|
else |
|
ne = getnetbyname(argv[i]); |
|
if (ne != NULL) |
|
networksprint(ne); |
|
else { |
|
rv = RV_NOTFOUND; |
|
break; |
|
} |
|
} |
|
} |
|
endnetent(); |
|
return rv; |
return rv; |
} |
} |
|
|