2 This file is part of GNUnet.
3 Copyright (C) 2012 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
16 * @file gns/w32nsp-install.c
17 * @brief W32 integration installer for GNS
25 #include "gnunet_w32nsp_lib.h"
29 main (int argc, char **argv)
34 GUID id = GNUNET_NAMESPACE_PROVIDER_DNS;
38 /* Allocate a 4K buffer to retrieve all the namespace providers */
39 DWORD dwInitialBufferLen = 4096;
41 WSANAMESPACE_INFO *pi;
45 if (WSAStartup (MAKEWORD (2,2), &wsd) != 0)
47 fprintf (stderr, "WSAStartup () failed: %lu\n", GetLastError ());
51 dwBufferLen = dwInitialBufferLen;
52 pi = malloc (dwBufferLen);
55 fprintf (stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno);
59 p_count = WSAEnumNameSpaceProviders (&dwBufferLen, pi);
60 if (SOCKET_ERROR == p_count)
62 DWORD err = GetLastError ();
63 if (WSAEFAULT == err && dwBufferLen != dwInitialBufferLen)
67 pi = malloc (dwBufferLen);
70 fprintf (stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno);
75 p_count = WSAEnumNameSpaceProviders (&dwBufferLen, pi);
76 if (SOCKET_ERROR == p_count)
78 fprintf (stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError ());
86 fprintf (stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError ());
92 for (i= 0; i < p_count; i++)
94 if (IsEqualGUID (&pi[i].NSProviderId, &id))
96 fprintf (stderr, "GNUnet DNS provider is already installed\n");
104 cmdl = GetCommandLineW ();
110 wargv = CommandLineToArgvW (cmdl, &wargc);
120 ret = WSCInstallNameSpace (L"GNUnet DNS provider", wargv[1], NS_DNS, 0, &id);
123 fprintf (stderr, "Installed GNUnet DNS provider\n");
130 "WSCInstallNameSpace (L\"GNUnet DNS provider\", \"%S\", %d, 0, %p) failed: %lu\n",
131 wargv[1], NS_DNS, &id, GetLastError ());
135 fprintf (stderr, "Usage: %S <path-to-libw32nsp>\n", wargv[0]);