2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file gns/w32nsp-install.c
22 * @brief W32 integration installer for GNS
30 #include "gnunet_w32nsp_lib.h"
34 main (int argc, char **argv)
39 GUID id = GNUNET_NAMESPACE_PROVIDER_DNS;
43 /* Allocate a 4K buffer to retrieve all the namespace providers */
44 DWORD dwInitialBufferLen = 4096;
46 WSANAMESPACE_INFO *pi;
50 if (WSAStartup (MAKEWORD (2,2), &wsd) != 0)
52 fprintf (stderr, "WSAStartup () failed: %lu\n", GetLastError ());
56 dwBufferLen = dwInitialBufferLen;
57 pi = malloc (dwBufferLen);
60 fprintf (stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno);
64 p_count = WSAEnumNameSpaceProviders (&dwBufferLen, pi);
65 if (SOCKET_ERROR == p_count)
67 DWORD err = GetLastError ();
68 if (WSAEFAULT == err && dwBufferLen != dwInitialBufferLen)
72 pi = malloc (dwBufferLen);
75 fprintf (stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno);
80 p_count = WSAEnumNameSpaceProviders (&dwBufferLen, pi);
81 if (SOCKET_ERROR == p_count)
83 fprintf (stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError ());
91 fprintf (stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError ());
97 for (i= 0; i < p_count; i++)
99 if (IsEqualGUID (&pi[i].NSProviderId, &id))
101 fprintf (stderr, "GNUnet DNS provider is already installed\n");
109 cmdl = GetCommandLineW ();
115 wargv = CommandLineToArgvW (cmdl, &wargc);
125 ret = WSCInstallNameSpace (L"GNUnet DNS provider", wargv[1], NS_DNS, 0, &id);
128 fprintf (stderr, "Installed GNUnet DNS provider\n");
135 "WSCInstallNameSpace (L\"GNUnet DNS provider\", \"%S\", %d, 0, %p) failed: %lu\n",
136 wargv[1], NS_DNS, &id, GetLastError ());
140 fprintf (stderr, "Usage: %S <path-to-libw32nsp>\n", wargv[0]);