diff options
author | Yang Tse <yangsita@gmail.com> | 2009-05-18 15:49:32 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2009-05-18 15:49:32 +0000 |
commit | f96204dbe08d5800453d54aec4dc282f1301f834 (patch) | |
tree | 6efe5f624f0f0ce828745528db8cf3934e6f2faa /ares | |
parent | 0427b783e2ae554a118057d23c65f29041b7cb6e (diff) |
Remove run-time requirement for advapi32.dll since
c-ares can work even with no advapi32.dll at all.
Diffstat (limited to 'ares')
-rw-r--r-- | ares/ares.h | 3 | ||||
-rw-r--r-- | ares/ares_library_init.c | 21 | ||||
-rw-r--r-- | ares/ares_strerror.c | 1 |
3 files changed, 10 insertions, 15 deletions
diff --git a/ares/ares.h b/ares/ares.h index 6db8b9647..9f4413f62 100644 --- a/ares/ares.h +++ b/ares/ares.h @@ -96,8 +96,7 @@ extern "C" { /* ares_library_init error codes */ #define ARES_ELOADIPHLPAPI 21 -#define ARES_ELOADADVAPI32 22 -#define ARES_EADDRGetNetworkParams 23 +#define ARES_EADDRGetNetworkParams 22 /* Flag values */ #define ARES_FLAG_USEVC (1 << 0) diff --git a/ares/ares_library_init.c b/ares/ares_library_init.c index ee3fe68b6..b3e8dc9e1 100644 --- a/ares/ares_library_init.c +++ b/ares/ares_library_init.c @@ -41,23 +41,20 @@ static int ares_win32_init(void) return ARES_EADDRGetNetworkParams; } + /* + * When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036, + * also known as RtlGenRandom, which is the case for Windows versions prior + * to WinXP then c-ares uses portable rand() function. Then don't error here. + */ + hnd_advapi32 = 0; hnd_advapi32 = LoadLibrary("advapi32.dll"); - if (!hnd_advapi32) + if (hnd_advapi32) { - FreeLibrary(hnd_iphlpapi); - return ARES_ELOADADVAPI32; + fpSystemFunction036 = (fpSystemFunction036_t) + GetProcAddress(hnd_advapi32, "SystemFunction036"); } - fpSystemFunction036 = (fpSystemFunction036_t) - GetProcAddress(hnd_advapi32, "SystemFunction036"); - - /* - * Intentionally avoid checking if the address of SystemFunction036, a.k.a. - * RtlGenRandom, has been located or not. This function is only available on - * WinXP and later. When unavailable c-ares uses portable rand() function. - */ - #endif return ARES_SUCCESS; } diff --git a/ares/ares_strerror.c b/ares/ares_strerror.c index 6ded90da0..6d291ee63 100644 --- a/ares/ares_strerror.c +++ b/ares/ares_strerror.c @@ -45,7 +45,6 @@ const char *ares_strerror(int code) "Given hostname is not numeric", "Illegal hints flags specified", "Error loading iphlpapi.dll", - "Error loading advapi32.dll", "Could not find GetNetworkParams function" }; |