-dead code elimination
[oweals/gnunet.git] / src / gns / w32nsp-install.c
1 /*\r
2      This file is part of GNUnet.\r
3      (C) 2012 Christian Grothoff (and other contributing authors)\r
4 \r
5      GNUnet is free software; you can redistribute it and/or modify\r
6      it under the terms of the GNU General Public License as published\r
7      by the Free Software Foundation; either version 3, or (at your\r
8      option) any later version.\r
9 \r
10      GNUnet is distributed in the hope that it will be useful, but\r
11      WITHOUT ANY WARRANTY; without even the implied warranty of\r
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
13      General Public License for more details.\r
14 \r
15      You should have received a copy of the GNU General Public License\r
16      along with GNUnet; see the file COPYING.  If not, write to the\r
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
18      Boston, MA 02111-1307, USA.\r
19 */\r
20 /**\r
21  * @file gns/w32nsp-install.c\r
22  * @brief W32 integration installer for GNS\r
23  * @author LRN\r
24  */\r
25 \r
26 #define INITGUID\r
27 #include <windows.h>\r
28 #include <nspapi.h>\r
29 #include <ws2spi.h>\r
30 #include "gnunet_w32nsp_lib.h"\r
31 #include <stdio.h>\r
32 \r
33 int\r
34 main (int argc, char **argv)\r
35 {\r
36   int ret;\r
37   int r = 1;\r
38   WSADATA wsd;\r
39   GUID id = GNUNET_NAMESPACE_PROVIDER_DNS;\r
40   wchar_t *cmdl;\r
41   int wargc;\r
42   wchar_t **wargv;\r
43 \r
44   if (WSAStartup(MAKEWORD(2,2), &wsd) != 0)\r
45   {\r
46     fprintf (stderr, "WSAStartup() failed: %lu\n", GetLastError());\r
47     return 5;\r
48   }\r
49 \r
50   cmdl = GetCommandLineW ();\r
51   if (cmdl == NULL)\r
52   {\r
53     WSACleanup();\r
54     return 2;\r
55   }\r
56   wargv = CommandLineToArgvW (cmdl, &wargc);\r
57   if (wargv == NULL)\r
58   {\r
59     WSACleanup();\r
60     return 3;\r
61   }\r
62   r = 4;\r
63 \r
64   if (wargc == 2)\r
65   {\r
66     ret = WSCInstallNameSpace (L"GNUnet DNS provider", wargv[1], NS_DNS, 1, &id);\r
67     if (ret == NO_ERROR)\r
68     {\r
69       r = 0;\r
70     }\r
71     else\r
72     {\r
73       r = 1;\r
74       fprintf (stderr,\r
75           "WSCInstallNameSpace(L\"GNUnet DNS provider\", \"%S\", %d, 0, %p) failed: %lu\n",\r
76           wargv[1], NS_DNS, &id, GetLastError ());\r
77     }\r
78   }\r
79   WSACleanup();\r
80   return r;\r
81 }\r