+/*
+ This file is part of GNUnet.
+ (C) 2012 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file gns/w32nsp-resolve.c
+ * @brief W32 integration for GNS
+ * @author LRN
+ */
#define INITGUID
+#include <ws2tcpip.h>
#include <windows.h>
#include <nspapi.h>
#include <ws2spi.h>
#include <nspapi.h>
-#include <ws2tcpip.h>
#include "gnunet_w32nsp_lib.h"
#include <stdio.h>
// to convert structures returned as BLOBs.
//
-VOID FixList(PCHAR ** List, PCHAR Base)
+VOID
+FixList(PCHAR ** List, PCHAR Base)
{
if(*List)
{
// Routine to convert a hostent returned in a BLOB to one with
// usable pointers. The structure is converted in-place.
//
-VOID UnpackHostEnt(struct hostent * hostent)
+VOID
+UnpackHostEnt(struct hostent * hostent)
{
PCHAR pch;
FixList(&hostent->h_addr_list, pch);
}
-void
+
+static void
print_hostent (struct hostent *he)
{
int i;
char **pAlias;
+
printf("\tOfficial name: %s\n", he->h_name);
- for (pAlias = he->h_aliases; *pAlias != 0; pAlias++) {
+ for (i=0, pAlias = he->h_aliases; *pAlias != 0; pAlias++) {
printf("\tAlternate name #%d: %s\n", ++i, *pAlias);
}
printf("\tAddress type: ");
}
}
+
int
main (int argc, char **argv)
{
int ret;
int r = 1;
WSADATA wsd;
- GUID *prov = NULL;
- GUID *sc = NULL;
+ GUID prov;
+ GUID sc;
wchar_t *cmdl;
int wargc;
wchar_t **wargv;
if (wargc == 5)
{
if (wcscmp (wargv[1], L"A") == 0)
- sc = &SVCID_DNS_TYPE_A;
+ sc = SVCID_DNS_TYPE_A;
else if (wcscmp (wargv[1], L"AAAA") == 0)
- sc = &SVCID_DNS_TYPE_AAAA;
+ sc = SVCID_DNS_TYPE_AAAA;
else if (wcscmp (wargv[1], L"name") == 0)
- sc = &SVCID_HOSTNAME;
+ sc = SVCID_HOSTNAME;
else if (wcscmp (wargv[1], L"addr") == 0)
- sc = &SVCID_INET_HOSTADDRBYNAME;
+ sc = SVCID_INET_HOSTADDRBYNAME;
else
wargc -= 1;
if (wcscmp (wargv[4], L"mswdns") == 0)
- prov = &W32_DNS;
+ prov = W32_DNS;
else if (wcscmp (wargv[4], L"gnunetdns") == 0)
- prov = &GNUNET_NAMESPACE_PROVIDER_DNS;
+ prov = GNUNET_NAMESPACE_PROVIDER_DNS;
else
wargc -= 1;
}
if (startup != NULL)
{
NSP_ROUTINE api;
- ret = startup (prov, &api);
+ ret = startup (&prov, &api);
if (NO_ERROR != ret)
fprintf (stderr, "startup failed\n");
else
memset (&search, 0, sizeof (search));
search.dwSize = sizeof (search);
search.lpszServiceInstanceName = (wcscmp (wargv[2], L" ") == 0) ? NULL : wargv[2];
- search.lpServiceClassId = sc;
- search.lpNSProviderId = prov;
+ search.lpServiceClassId = ≻
+ search.lpNSProviderId = &prov;
search.dwNameSpace = NS_ALL;
- ret = api.NSPLookupServiceBegin (prov, &search, NULL, LUP_RETURN_ALL, &lookup);
+ ret = api.NSPLookupServiceBegin (&prov, &search, NULL, LUP_RETURN_ALL, &lookup);
if (ret != NO_ERROR)
{
fprintf (stderr, "lookup start failed\n");
if (ret != NO_ERROR)
printf ("NSPLookupServiceEnd() failed: %lu\n", GetLastError ());
}
- api.NSPCleanup (prov);
+ api.NSPCleanup (&prov);
}
}
FreeLibrary (nsp);
}
WSACleanup();
return r;
-}
\ No newline at end of file
+}