From ec5861a57ff3aa329935820f9e7df4822a5af5ed Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sat, 4 Dec 1999 18:17:26 +0000 Subject: [PATCH] use client_doit git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7503 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/test/gssapi_client.c | 38 +-------------------------------- appl/test/nt_gss_client.c | 38 +-------------------------------- appl/test/tcp_client.c | 45 +-------------------------------------- appl/test/uu_client.c | 38 +-------------------------------- 4 files changed, 4 insertions(+), 155 deletions(-) diff --git a/appl/test/gssapi_client.c b/appl/test/gssapi_client.c index 4f250cf88..75a49e00e 100644 --- a/appl/test/gssapi_client.c +++ b/appl/test/gssapi_client.c @@ -148,46 +148,10 @@ proto (int sock, const char *hostname, const char *service) return 0; } -static int -doit (const char *hostname, int port, const char *service) -{ - struct in_addr **h; - struct hostent *hostent; - - hostent = roken_gethostbyname (hostname); - if (hostent == NULL) - errx (1, "gethostbyname '%s' failed: %s", - hostname, - hstrerror(h_errno)); - - for (h = (struct in_addr **)hostent->h_addr_list; - *h != NULL; - ++h) { - struct sockaddr_in addr; - int s; - - memset (&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_port = port; - addr.sin_addr = **h; - - s = socket (AF_INET, SOCK_STREAM, 0); - if (s < 0) - err (1, "socket"); - if (connect (s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - warn ("connect(%s)", hostname); - close (s); - continue; - } - return proto (s, hostname, service); - } - return 1; -} - int main(int argc, char **argv) { krb5_context context; /* XXX */ int port = client_setup(&context, &argc, argv); - return doit (argv[argc], port, service); + return client_doit (argv[argc], port, service, proto); } diff --git a/appl/test/nt_gss_client.c b/appl/test/nt_gss_client.c index 9b4f24899..879646aee 100644 --- a/appl/test/nt_gss_client.c +++ b/appl/test/nt_gss_client.c @@ -154,46 +154,10 @@ proto (int sock, const char *hostname, const char *service) return 0; } -static int -doit (const char *hostname, int port, const char *service) -{ - struct in_addr **h; - struct hostent *hostent; - - hostent = roken_gethostbyname (hostname); - if (hostent == NULL) - errx (1, "gethostbyname '%s' failed: %s", - hostname, - hstrerror(h_errno)); - - for (h = (struct in_addr **)hostent->h_addr_list; - *h != NULL; - ++h) { - struct sockaddr_in addr; - int s; - - memset (&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_port = port; - addr.sin_addr = **h; - - s = socket (AF_INET, SOCK_STREAM, 0); - if (s < 0) - err (1, "socket"); - if (connect (s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - warn ("connect(%s)", hostname); - close (s); - continue; - } - return proto (s, hostname, service); - } - return 1; -} - int main(int argc, char **argv) { krb5_context context; /* XXX */ int port = client_setup(&context, &argc, argv); - return doit (argv[argc], port, service); + return client_doit (argv[argc], port, service, proto); } diff --git a/appl/test/tcp_client.c b/appl/test/tcp_client.c index 27f30dd41..f4d10d41e 100644 --- a/appl/test/tcp_client.c +++ b/appl/test/tcp_client.c @@ -125,52 +125,9 @@ proto (int sock, const char *hostname, const char *service) return 0; } -static int -doit (const char *hostname, int port, const char *service) -{ - struct hostent *hostent = NULL; - char **h; - int error; - int af; - -#ifdef HAVE_IPV6 - if (hostent == NULL) - hostent = getipnodebyname (hostname, AF_INET6, 0, &error); -#endif - if (hostent == NULL) - hostent = getipnodebyname (hostname, AF_INET, 0, &error); - - if (hostent == NULL) - errx(1, "gethostbyname '%s' failed: %s", hostname, hstrerror(error)); - - af = hostent->h_addrtype; - - for (h = hostent->h_addr_list; *h != NULL; ++h) { - struct sockaddr_storage sa_ss; - struct sockaddr *sa = (struct sockaddr *)&sa_ss; - int s; - - sa->sa_family = af; - socket_set_address_and_port (sa, *h, port); - - s = socket (af, SOCK_STREAM, 0); - if (s < 0) - err (1, "socket"); - if (connect (s, sa, socket_sockaddr_size(sa)) < 0) { - warn ("connect(%s)", hostname); - close (s); - continue; - } - freehostent (hostent); - return proto (s, hostname, service); - } - freehostent (hostent); - return 1; -} - int main(int argc, char **argv) { int port = client_setup(&context, &argc, argv); - return doit (argv[argc], port, service); + return client_doit (argv[argc], port, service, proto); } diff --git a/appl/test/uu_client.c b/appl/test/uu_client.c index ea28d4263..9dc1c5407 100644 --- a/appl/test/uu_client.c +++ b/appl/test/uu_client.c @@ -167,45 +167,9 @@ proto (int sock, const char *hostname, const char *service) return 0; } -static int -doit (const char *hostname, int port, const char *service) -{ - struct in_addr **h; - struct hostent *hostent; - - hostent = gethostbyname (hostname); - if (hostent == NULL) - errx (1, "gethostbyname '%s' failed: %s", - hostname, - hstrerror(h_errno)); - - for (h = (struct in_addr **)hostent->h_addr_list; - *h != NULL; - ++h) { - struct sockaddr_in addr; - int s; - - memset (&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_port = port; - addr.sin_addr = **h; - - s = socket (AF_INET, SOCK_STREAM, 0); - if (s < 0) - err (1, "socket"); - if (connect (s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - warn ("connect(%s)", hostname); - close (s); - continue; - } - return proto (s, hostname, service); - } - return 1; -} - int main(int argc, char **argv) { int port = client_setup(&context, &argc, argv); - return doit (argv[argc], port, service); + return client_doit (argv[argc], port, service, proto); }