summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal/lib/roken/mini_inetd.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/heimdal/lib/roken/mini_inetd.c')
-rw-r--r--crypto/heimdal/lib/roken/mini_inetd.c46
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);
+}
OpenPOWER on IntegriCloud