Subject: Re: c-ares not compiling with mingw32ce

Re: c-ares not compiling with mingw32ce

From: Yang Tse <yangsita_at_gmail.com>
Date: Wed, 23 Mar 2011 21:11:08 +0100

2011/3/22 Vincent Torri wrote:

> Link problems
>
>  .libs/ares_gethostbyaddr.o:ares_gethostbyaddr:(.text+0x238): undefined
> reference to `GetVersion'
> .libs/ares_gethostbyaddr.o:ares_gethostbyaddr:(.text+0x370): undefined
> reference to `GetWindowsDirectoryW'
> .libs/ares_gethostbyaddr.o:ares_gethostbyaddr:(.text+0x3ac): undefined
> reference to `ExpandEnvironmentStringsW'
> .libs/ares_getnameinfo.o:ares_getnameinfo.c:(.text+0x8c): undefined
> reference to `getservbyport'
> .libs/ares_init.o:ares_init.c:(.text+0xdd4): undefined reference to `getenv'
>
> 1) Windows CE has no environment variables, so no getenv (lines 522 and 530
> or ares_init.c) nor ExpandEnvironmentStrings. I don't know what to do, here.

If there's no environment, then we can simply fake a replacement
getenv() function which returns NULL for winCE. This commit
https://github.com/bagder/c-ares/commit/822fd0f8771d3792da0a08276ab0400b2a68f07e
does that. It could be expanded to use a 'fake' private environment,
but at this point I think there's little benefit from doing so.

> 2) It seems that GetVersion() does not exist on Windows CE, but
> GetVersionEx() does (I use it in one of my library). The macro
>
> #define IS_NT()        ((int)GetVersion() > 0)
>
> does not check NT at all. MSDN says that, but Microsoft actually removed all
> references to Windows 95 or 98. So GetVersion() can return a correct value
> while being on Windows98, for example. Just the macro IS_NT() is not
> sufficient imho. Anyway, see

Ok, got rid of IS_NT macro and GetVersionEx() is used now to find out
windows version with private function getplatform(). Notice that
existing logic has only been adapted to handle existing windows
support. So in any place (three locations) that you find a
getplatform() function call some changes will be needed to handle the
winCE case.
https://github.com/bagder/c-ares/commit/bd066ab8efa0d43ef002954f4587a195a15ac460

> 3) get_res_nt() should be rewritten for Windows CE. I have written code to
> access to registry on Windows CE. It uses RegCreateKeyEx, RegCloseKey,
> RegQueryValueEx, RegSetValueEx.
>
> 4) Instead of GetWindowsDirectory, on Windows CE, use
> SHGetSpecialFolderPath(0, buf, CSIDL_WINDOWS, 0);

Points 3 and 4 heavilly depend on how you want to handle tha changes
introduced for point 2. So, what do you propose?

> 5) getservbyport is not supported by Windows CE (see

Does CE have a %WINDIR%\system32\drivers\etc\services or similar file?
If CE has a services file somewhere or if there's a registry hive
holding the services database, creating a getservbyport function for
CE is just a matter of parsing and extracting required info from
appropriate location.

-- 
-=[Yang]=-
Received on 2011-03-23