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 Affero 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.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @file gns/w32nsp-install.c
20 * @brief W32 integration installer for GNS
28 #include "gnunet_w32nsp_lib.h"
32 main (int argc, char **argv)
37 GUID id = GNUNET_NAMESPACE_PROVIDER_DNS;
41 /* Allocate a 4K buffer to retrieve all the namespace providers */
42 DWORD dwInitialBufferLen = 4096;
44 WSANAMESPACE_INFO *pi;
48 if (WSAStartup (MAKEWORD (2,2), &wsd) != 0)
50 fprintf (stderr, "WSAStartup () failed: %lu\n", GetLastError ());
54 dwBufferLen = dwInitialBufferLen;
55 pi = malloc (dwBufferLen);
58 fprintf (stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno);
62 p_count = WSAEnumNameSpaceProviders (&dwBufferLen, pi);
63 if (SOCKET_ERROR == p_count)
65 DWORD err = GetLastError ();
66 if (WSAEFAULT == err && dwBufferLen != dwInitialBufferLen)
70 pi = malloc (dwBufferLen);
73 fprintf (stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno);
78 p_count = WSAEnumNameSpaceProviders (&dwBufferLen, pi);
79 if (SOCKET_ERROR == p_count)
81 fprintf (stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError ());
89 fprintf (stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError ());
95 for (i= 0; i < p_count; i++)
97 if (IsEqualGUID (&pi[i].NSProviderId, &id))
99 fprintf (stderr, "GNUnet DNS provider is already installed\n");
107 cmdl = GetCommandLineW ();
113 wargv = CommandLineToArgvW (cmdl, &wargc);
123 ret = WSCInstallNameSpace (L"GNUnet DNS provider", wargv[1], NS_DNS, 0, &id);
126 fprintf (stderr, "Installed GNUnet DNS provider\n");
133 "WSCInstallNameSpace (L\"GNUnet DNS provider\", \"%S\", %d, 0, %p) failed: %lu\n",
134 wargv[1], NS_DNS, &id, GetLastError ());
138 fprintf (stderr, "Usage: %S <path-to-libw32nsp>\n", wargv[0]);