+ dwBufferLen = dwInitialBufferLen;
+ pi = malloc (dwBufferLen);
+ if (NULL == pi)
+ {
+ fprintf (stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno);
+ WSACleanup ();
+ return 6;
+ }
+ p_count = WSAEnumNameSpaceProviders (&dwBufferLen, pi);
+ if (SOCKET_ERROR == p_count)
+ {
+ DWORD err = GetLastError ();
+ if (WSAEFAULT == err && dwBufferLen != dwInitialBufferLen)
+ {
+ free (pi);
+
+ pi = malloc (dwBufferLen);
+ if (pi == NULL)
+ {
+ fprintf (stderr, "malloc (%lu) failed: %d\n", dwBufferLen, errno);
+ WSACleanup ();
+ return 6;
+ }
+
+ p_count = WSAEnumNameSpaceProviders (&dwBufferLen, pi);
+ if (SOCKET_ERROR == p_count)
+ {
+ fprintf (stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError ());
+ free (pi);
+ WSACleanup ();
+ return 7;
+ }
+ }
+ else
+ {
+ fprintf (stderr, "WSAEnumNameSpaceProviders (&%lu, %p) failed: %lu\n", dwBufferLen, pi, GetLastError ());
+ free (pi);
+ WSACleanup ();
+ return 8;
+ }
+ }
+ for (i= 0; i < p_count; i++)
+ {
+ if (IsEqualGUID (&pi[i].NSProviderId, &id))
+ {
+ fprintf (stderr, "GNUnet DNS provider is already installed\n");
+ free (pi);
+ WSACleanup ();
+ return 0;
+ }
+ }
+ free (pi);
+