diff options
author | nectar <nectar@FreeBSD.org> | 2002-08-30 21:23:27 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2002-08-30 21:23:27 +0000 |
commit | a77dba08ca7d8ad2f2dcd653974ac66df78cfa49 (patch) | |
tree | 6015f89700252fb05eb8fa267c46dba41913e9d8 /crypto/heimdal/lib/roken/mini_inetd.c | |
parent | 69a91bec14ec3ad49d1c8a82c40a796755f9e4a3 (diff) | |
download | FreeBSD-src-a77dba08ca7d8ad2f2dcd653974ac66df78cfa49.zip FreeBSD-src-a77dba08ca7d8ad2f2dcd653974ac66df78cfa49.tar.gz |
Import of Heimdal Kerberos from KTH repository circa 2002/08/29.
Diffstat (limited to 'crypto/heimdal/lib/roken/mini_inetd.c')
-rw-r--r-- | crypto/heimdal/lib/roken/mini_inetd.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/crypto/heimdal/lib/roken/mini_inetd.c b/crypto/heimdal/lib/roken/mini_inetd.c index 39dd046..8c8f72d 100644 --- a/crypto/heimdal/lib/roken/mini_inetd.c +++ b/crypto/heimdal/lib/roken/mini_inetd.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: mini_inetd.c,v 1.29 2001/08/01 14:48:54 assar Exp $"); +RCSID("$Id: mini_inetd.c,v 1.30 2002/02/18 19:08:55 joda Exp $"); #endif #include <err.h> @@ -59,31 +59,19 @@ accept_it (int s) } /* - * Listen on `port' emulating inetd. + * Listen on a specified port, emulating inetd. */ void -mini_inetd (int port) +mini_inetd_addrinfo (struct addrinfo *ai) { - int error, ret; - struct addrinfo *ai, *a, hints; - char portstr[NI_MAXSERV]; + int ret; + struct addrinfo *a; int n, nalloc, i; int *fds; fd_set orig_read_set, read_set; int max_fd = -1; - memset (&hints, 0, sizeof(hints)); - hints.ai_flags = AI_PASSIVE; - hints.ai_socktype = SOCK_STREAM; - hints.ai_family = PF_UNSPEC; - - snprintf (portstr, sizeof(portstr), "%d", ntohs(port)); - - error = getaddrinfo (NULL, portstr, &hints, &ai); - if (error) - errx (1, "getaddrinfo: %s", gai_strerror (error)); - for (nalloc = 0, a = ai; a != NULL; a = a->ai_next) ++nalloc; @@ -116,7 +104,6 @@ mini_inetd (int port) max_fd = max(max_fd, fds[i]); ++i; } - freeaddrinfo (ai); if (i == 0) errx (1, "no sockets"); n = i; @@ -136,3 +123,26 @@ mini_inetd (int port) } abort (); } + +void +mini_inetd (int port) +{ + int error; + struct addrinfo *ai, hints; + char portstr[NI_MAXSERV]; + + memset (&hints, 0, sizeof(hints)); + hints.ai_flags = AI_PASSIVE; + hints.ai_socktype = SOCK_STREAM; + hints.ai_family = PF_UNSPEC; + + snprintf (portstr, sizeof(portstr), "%d", ntohs(port)); + + error = getaddrinfo (NULL, portstr, &hints, &ai); + if (error) + errx (1, "getaddrinfo: %s", gai_strerror (error)); + + mini_inetd_addrinfo(ai); + + freeaddrinfo(ai); +} |