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 | 757642f6756e5dc6b48082d1661758012e28db69 (patch) | |
tree | 152a66fad39e0c2a78f0e78d5faa3dfc51b910c5 /ares_library_init.c | |
parent | b677ff3d15f3a26b185e89f15dee45bbd125902d (diff) | |
download | c-ares-757642f6756e5dc6b48082d1661758012e28db69.tar.gz c-ares-757642f6756e5dc6b48082d1661758012e28db69.tar.bz2 c-ares-757642f6756e5dc6b48082d1661758012e28db69.zip |
Remove run-time requirement for advapi32.dll since
c-ares can work even with no advapi32.dll at all.
Diffstat (limited to 'ares_library_init.c')
-rw-r--r-- | ares_library_init.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/ares_library_init.c b/ares_library_init.c index ee3fe68..b3e8dc9 100644 --- a/ares_library_init.c +++ b/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; } |