aboutsummaryrefslogtreecommitdiff
path: root/src/gns/w32nsp-install.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/w32nsp-install.c')
-rw-r--r--src/gns/w32nsp-install.c152
1 files changed, 76 insertions, 76 deletions
diff --git a/src/gns/w32nsp-install.c b/src/gns/w32nsp-install.c
index 6c9c44409..2674359fb 100644
--- a/src/gns/w32nsp-install.c
+++ b/src/gns/w32nsp-install.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20/** 20/**
21 * @file gns/w32nsp-install.c 21 * @file gns/w32nsp-install.c
22 * @brief W32 integration installer for GNS 22 * @brief W32 integration installer for GNS
@@ -31,7 +31,7 @@
31#include <stdio.h> 31#include <stdio.h>
32 32
33int 33int
34main (int argc, char **argv) 34main(int argc, char **argv)
35{ 35{
36 int ret; 36 int ret;
37 int r = 1; 37 int r = 1;
@@ -47,97 +47,97 @@ main (int argc, char **argv)
47 int p_count; 47 int p_count;
48 int i; 48 int i;
49 49
50 if (WSAStartup (MAKEWORD (2,2), &wsd) != 0) 50 if (WSAStartup(MAKEWORD(2, 2), &wsd) != 0)
51 { 51 {
52 fprintf (stderr, "WSAStartup () failed: %lu\n", GetLastError ()); 52 fprintf(stderr, "WSAStartup () failed: %lu\n", GetLastError());
53 return 5; 53 return 5;
54 } 54 }
55 55
56 dwBufferLen = dwInitialBufferLen; 56 dwBufferLen = dwInitialBufferLen;
57 pi = malloc (dwBufferLen); 57 pi = malloc(dwBufferLen);
58 if (NULL == pi) 58 if (NULL == pi)
59 { 59 {
60 fprintf (stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno); 60 fprintf(stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno);
61 WSACleanup (); 61 WSACleanup();
62 return 6; 62 return 6;
63 } 63 }
64 p_count = WSAEnumNameSpaceProviders (&dwBufferLen, pi); 64 p_count = WSAEnumNameSpaceProviders(&dwBufferLen, pi);
65 if (SOCKET_ERROR == p_count) 65 if (SOCKET_ERROR == p_count)
66 {
67 DWORD err = GetLastError ();
68 if (WSAEFAULT == err && dwBufferLen != dwInitialBufferLen)
69 { 66 {
70 free (pi); 67 DWORD err = GetLastError();
68 if (WSAEFAULT == err && dwBufferLen != dwInitialBufferLen)
69 {
70 free(pi);
71 71
72 pi = malloc (dwBufferLen); 72 pi = malloc(dwBufferLen);
73 if (pi == NULL) 73 if (pi == NULL)
74 { 74 {
75 fprintf (stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno); 75 fprintf(stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno);
76 WSACleanup (); 76 WSACleanup();
77 return 6; 77 return 6;
78 } 78 }
79 79
80 p_count = WSAEnumNameSpaceProviders (&dwBufferLen, pi); 80 p_count = WSAEnumNameSpaceProviders(&dwBufferLen, pi);
81 if (SOCKET_ERROR == p_count) 81 if (SOCKET_ERROR == p_count)
82 { 82 {
83 fprintf (stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError ()); 83 fprintf(stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError());
84 free (pi); 84 free(pi);
85 WSACleanup (); 85 WSACleanup();
86 return 7; 86 return 7;
87 } 87 }
88 } 88 }
89 else 89 else
90 { 90 {
91 fprintf (stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError ()); 91 fprintf(stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError());
92 free (pi); 92 free(pi);
93 WSACleanup (); 93 WSACleanup();
94 return 8; 94 return 8;
95 }
95 } 96 }
96 } 97 for (i = 0; i < p_count; i++)
97 for (i= 0; i < p_count; i++)
98 {
99 if (IsEqualGUID (&pi[i].NSProviderId, &id))
100 { 98 {
101 fprintf (stderr, "GNUnet DNS provider is already installed\n"); 99 if (IsEqualGUID(&pi[i].NSProviderId, &id))
102 free (pi); 100 {
103 WSACleanup (); 101 fprintf(stderr, "GNUnet DNS provider is already installed\n");
104 return 0; 102 free(pi);
103 WSACleanup();
104 return 0;
105 }
105 } 106 }
106 } 107 free(pi);
107 free (pi);
108 108
109 cmdl = GetCommandLineW (); 109 cmdl = GetCommandLineW();
110 if (cmdl == NULL) 110 if (cmdl == NULL)
111 { 111 {
112 WSACleanup (); 112 WSACleanup();
113 return 2; 113 return 2;
114 } 114 }
115 wargv = CommandLineToArgvW (cmdl, &wargc); 115 wargv = CommandLineToArgvW(cmdl, &wargc);
116 if (wargv == NULL) 116 if (wargv == NULL)
117 { 117 {
118 WSACleanup (); 118 WSACleanup();
119 return 3; 119 return 3;
120 } 120 }
121 r = 4; 121 r = 4;
122 122
123 if (wargc == 2) 123 if (wargc == 2)
124 {
125 ret = WSCInstallNameSpace (L"GNUnet DNS provider", wargv[1], NS_DNS, 0, &id);
126 if (ret == NO_ERROR)
127 {
128 fprintf (stderr, "Installed GNUnet DNS provider\n");
129 r = 0;
130 }
131 else
132 { 124 {
133 r = 1; 125 ret = WSCInstallNameSpace(L"GNUnet DNS provider", wargv[1], NS_DNS, 0, &id);
134 fprintf (stderr, 126 if (ret == NO_ERROR)
135 "WSCInstallNameSpace (L\"GNUnet DNS provider\", \"%S\", %d, 0, %p) failed: %lu\n", 127 {
136 wargv[1], NS_DNS, &id, GetLastError ()); 128 fprintf(stderr, "Installed GNUnet DNS provider\n");
129 r = 0;
130 }
131 else
132 {
133 r = 1;
134 fprintf(stderr,
135 "WSCInstallNameSpace (L\"GNUnet DNS provider\", \"%S\", %d, 0, %p) failed: %lu\n",
136 wargv[1], NS_DNS, &id, GetLastError());
137 }
137 } 138 }
138 }
139 else 139 else
140 fprintf (stderr, "Usage: %S <path-to-libw32nsp>\n", wargv[0]); 140 fprintf(stderr, "Usage: %S <path-to-libw32nsp>\n", wargv[0]);
141 WSACleanup (); 141 WSACleanup();
142 return r; 142 return r;
143} 143}