/* Test the getaddrinfo module.
- Copyright (C) 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2006-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Written by Simon Josefsson. */
-#include "config.h"
+#include <config.h>
#include "getaddrinfo.h"
-#include "inet_ntop.h"
+#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
# define AF_UNSPEC 0
#endif
+#ifndef EAI_SERVICE
+# define EAI_SERVICE 0
+#endif
+
int simple (char *host, char *service)
{
char buf[BUFSIZ];
printf ("Finding %s service %s...\n", host, service);
+ /* This initializes "hints" but does not use it. Is there a reason
+ for this? If so, please fix this comment. */
memset (&hints, 0, sizeof (hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
+
res = getaddrinfo (host, service, 0, &ai0);
printf ("res %d: %s\n", res, gai_strerror (res));
if (res != 0)
- return 1;
+ {
+ /* IRIX reports EAI_NONAME for "https". Don't fail the test
+ merely because of this. */
+ if (res == EAI_NONAME)
+ return 0;
+ /* Solaris reports EAI_SERVICE for "http" and "https". Don't
+ fail the test merely because of this. */
+ if (res == EAI_SERVICE)
+ return 0;
+ /* AIX reports EAI_NODATA for "https". Don't fail the test
+ merely because of this. */
+ if (res == EAI_NODATA)
+ return 0;
+
+ return 1;
+ }
for (ai = ai0; ai; ai = ai->ai_next)
{