* autoload.cc (IdnToAscii): Define.

(IdnToUnicode): Define.
	(FreeAddrInfoW): Define.
	(GetAddrInfoW): Define.
	(GetNameInfoW): Define.
	* net.cc: Drop W. Richard STEVENS libgai implementation.
	(cygwin_freeaddrinfo): Move code from ipv4_freeaddrinfo here.  Move
	definition up in file to avoid forward declaration in ga_duplist.
	(ga_dup): Take addrinfoW as input.  Add parameters to get IDN flags
	and to set error value.  Handle IDN flags and especially AI_CANONIDN.
	Convert input wchar_t ai_canonname string to multibyte for output.
	(ga_duplist): Add parameters to get IDN flags and to set error value
	and propagate to ga_dup.  Call cygwin_freeaddrinfo.
	(gai_errmap): Add comments.  Align error strings to GLibc.  Add
	EAI_IDN_ENCODE entry.
	(get_ipv6_funcs): Remove.
	(load_ipv6_guard): Remove.
	(ipv6_inited): Remove.
	(load_ipv6): Remove.
	(load_ipv6_funcs): Remove.
	(cygwin_getaddrinfo): Drop calling load_ipv6.  Handle AI_IDN* flags.
	Convert input strings to wchar_t and call GetAddrInfoW/FreeAddrInfoW.
	In case hints is NULL, set default ai_flags explicitely to
	AI_V4MAPPED | AI_ADDRCONFIG, as documented for Glibc.  Only add AI_ALL
	if AI_ADDRCONFIG is not given.  Unconditionally add Windows-specific
	AI_DISABLE_IDN_ENCODING to ai_flags to make IDN behaviour compatible
	to Glibc even on Windows 8 and later.
	(cygwin_getnameinfo): Drop calling load_ipv6.  Handle NI_IDN* flags.
	Call GetNameInfoW and convert returned strings from wchar_t to
	multibyte.
	* include/netdb.h: Add comments to describe flags and error values.
	(AI_*): Define all flags using hex values for clearness.
	(AI_IDN): Define.
	(AI_CANONIDN): Define.
	(AI_IDN_ALLOW_UNASSIGNED): Define.
	(AI_IDN_USE_STD3_ASCII_RULES): Define.
	(NI_*): Define all flags using hex values for clearness.
	(NI_IDN): Define.
	(NI_IDN_ALLOW_UNASSIGNED): Define.
	(NI_IDN_USE_STD3_ASCII_RULES): Define.
	(EAI_IDN_ENCODE): Define.
This commit is contained in:
Corinna Vinschen 2013-11-19 13:29:37 +00:00
parent ff125797e3
commit 5b56e9b02b
6 changed files with 329 additions and 992 deletions

View File

@ -1,3 +1,47 @@
2013-11-19 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (IdnToAscii): Define.
(IdnToUnicode): Define.
(FreeAddrInfoW): Define.
(GetAddrInfoW): Define.
(GetNameInfoW): Define.
* net.cc: Drop W. Richard STEVENS libgai implementation.
(cygwin_freeaddrinfo): Move code from ipv4_freeaddrinfo here. Move
definition up in file to avoid forward declaration in ga_duplist.
(ga_dup): Take addrinfoW as input. Add parameters to get IDN flags
and to set error value. Handle IDN flags and especially AI_CANONIDN.
Convert input wchar_t ai_canonname string to multibyte for output.
(ga_duplist): Add parameters to get IDN flags and to set error value
and propagate to ga_dup. Call cygwin_freeaddrinfo.
(gai_errmap): Add comments. Align error strings to GLibc. Add
EAI_IDN_ENCODE entry.
(get_ipv6_funcs): Remove.
(load_ipv6_guard): Remove.
(ipv6_inited): Remove.
(load_ipv6): Remove.
(load_ipv6_funcs): Remove.
(cygwin_getaddrinfo): Drop calling load_ipv6. Handle AI_IDN* flags.
Convert input strings to wchar_t and call GetAddrInfoW/FreeAddrInfoW.
In case hints is NULL, set default ai_flags explicitely to
AI_V4MAPPED | AI_ADDRCONFIG, as documented for Glibc. Only add AI_ALL
if AI_ADDRCONFIG is not given. Unconditionally add Windows-specific
AI_DISABLE_IDN_ENCODING to ai_flags to make IDN behaviour compatible
to Glibc even on Windows 8 and later.
(cygwin_getnameinfo): Drop calling load_ipv6. Handle NI_IDN* flags.
Call GetNameInfoW and convert returned strings from wchar_t to
multibyte.
* include/netdb.h: Add comments to describe flags and error values.
(AI_*): Define all flags using hex values for clearness.
(AI_IDN): Define.
(AI_CANONIDN): Define.
(AI_IDN_ALLOW_UNASSIGNED): Define.
(AI_IDN_USE_STD3_ASCII_RULES): Define.
(NI_*): Define all flags using hex values for clearness.
(NI_IDN): Define.
(NI_IDN_ALLOW_UNASSIGNED): Define.
(NI_IDN_USE_STD3_ASCII_RULES): Define.
(EAI_IDN_ENCODE): Define.
2013-11-06 Christopher Faylor <me.cygwin2013@cgf.cx>
* configure.ac: Detect windows headers/libs after we've figured out the

View File

@ -576,6 +576,8 @@ LoadDLLfuncEx (CancelSynchronousIo, 4, kernel32, 1)
LoadDLLfunc (CreateSymbolicLinkW, 12, kernel32)
LoadDLLfuncEx (GetNamedPipeClientProcessId, 8, kernel32, 1)
LoadDLLfunc (GetSystemTimePreciseAsFileTime, 4, kernel32)
LoadDLLfuncEx2 (IdnToAscii, 20, kernel32, 1, 0)
LoadDLLfuncEx2 (IdnToUnicode, 20, kernel32, 1, 0)
LoadDLLfunc (LocaleNameToLCID, 8, kernel32)
LoadDLLfunc (WNetCloseEnum, 4, mpr)
@ -663,6 +665,9 @@ LoadDLLfunc (accept, 12, ws2_32)
LoadDLLfunc (bind, 12, ws2_32)
LoadDLLfunc (closesocket, 4, ws2_32)
LoadDLLfunc (connect, 12, ws2_32)
LoadDLLfunc (FreeAddrInfoW, 4, ws2_32)
LoadDLLfunc (GetAddrInfoW, 16, ws2_32)
LoadDLLfunc (GetNameInfoW, 28, ws2_32)
LoadDLLfunc (gethostbyaddr, 12, ws2_32)
LoadDLLfunc (gethostbyname, 4, ws2_32)
LoadDLLfunc (gethostname, 8, ws2_32)

View File

@ -28,7 +28,7 @@ const char *getprogname (void);
void setprogname (const char *);
#ifndef __STRICT_ANSI__
char *realpath (const char *, char *);
char *realpath (const char *__restrict, char *__restrict );
char *canonicalize_file_name (const char *);
int unsetenv (const char *);
char *initstate (unsigned seed, char *state, size_t size);

View File

@ -152,38 +152,61 @@ extern __declspec(dllimport) int h_errno;
#define NO_DATA 4 /* Valid name, no data record of requested type */
#define NO_ADDRESS NO_DATA /* no address, look for MX record */
#define AI_PASSIVE 1
#define AI_CANONNAME 2
#define AI_NUMERICHOST 4
#define AI_NUMERICSERV 8
#define AI_ALL 256
#define AI_ADDRCONFIG 1024 /* Only available on Vista. Unchangable default
on older systems. */
#define AI_V4MAPPED 2048
/* Flag values for getaddrinfo function. */
#define AI_PASSIVE 0x1 /* Intend socket address for bind. */
#define AI_CANONNAME 0x2 /* Return canonical node name. */
#define AI_NUMERICHOST 0x4 /* Input is address, don't resolve. */
#define AI_NUMERICSERV 0x8 /* Input is port number, don't resolve. */
#define AI_ALL 0x100 /* Return v4-mapped and v6 addresses. */
#define AI_ADDRCONFIG 0x400 /* Only available on Vista. Unchangable default
on older systems. */
#define AI_V4MAPPED 0x800
/* Glibc extensions. We use numerical values taken by winsock-specific
extensions. */
#define AI_IDN 0x4000 /* Encode IDN input from current local to
punycode per RFC 3490. */
#define AI_CANONIDN 0x8000 /* Convert ai_canonname from punycode to IDN
in current locale. */
#define AI_IDN_ALLOW_UNASSIGNED 0x10000 /* Allow unassigned code points in
input string. */
#define AI_IDN_USE_STD3_ASCII_RULES 0x20000 /* Filter ASCII chars according to
STD3 rules. */
#define NI_NOFQDN 1
#define NI_NUMERICHOST 2
#define NI_NAMEREQD 4
#define NI_NUMERICSERV 8
#define NI_DGRAM 16
/* Flag values for getnameinfo function. */
#define NI_NOFQDN 0x1 /* Don't lookup hostname. */
#define NI_NUMERICHOST 0x2 /* Return host address, rather than name. */
#define NI_NAMEREQD 0x4 /* Not being able to resolve is an error. */
#define NI_NUMERICSERV 0x8 /* Return port number, rather than name. */
#define NI_DGRAM 0x10 /* Lookup datagram (UDP) service. */
/* Glibc extensions. We use numerical values taken by winsock-specific
extensions. */
#define NI_IDN 0x4000 /* Decode name from punycode to IDN in
current locale. */
#define NI_IDN_ALLOW_UNASSIGNED 0x10000 /* Allow unassigned code points in
output string. */
#define NI_IDN_USE_STD3_ASCII_RULES 0x20000 /* Filter ASCII chars according to
STD3 rules. */
#define NI_MAXHOST 1025
#define NI_MAXSERV 32
#define NI_MAXHOST 1025 /* Best effort maximum hostname length. */
#define NI_MAXSERV 32 /* Best effort maximum service name length. */
#define EAI_ADDRFAMILY 1
#define EAI_AGAIN 2
#define EAI_BADFLAGS 3
#define EAI_FAIL 4
#define EAI_FAMILY 5
#define EAI_MEMORY 6
#define EAI_NODATA 7
#define EAI_NONAME 8
#define EAI_SERVICE 9
#define EAI_SOCKTYPE 10
#define EAI_SYSTEM 11
#define EAI_BADHINTS 12
#define EAI_PROTOCOL 13
#define EAI_OVERFLOW 14
/* Error codes returned by getaddrinfo and getnameinfo. */
#define EAI_ADDRFAMILY 1 /* Address family for hostname not supported */
#define EAI_AGAIN 2 /* Temporary failure in name resolution */
#define EAI_BADFLAGS 3 /* Bad value for ai_flags */
#define EAI_FAIL 4 /* Non-recoverable failure in name resolution */
#define EAI_FAMILY 5 /* ai_family not supported */
#define EAI_MEMORY 6 /* Memory allocation failure */
#define EAI_NODATA 7 /* No address associated with hostname */
#define EAI_NONAME 8 /* Name or service not known */
#define EAI_SERVICE 9 /* Servname not supported for ai_socktype */
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
#define EAI_SYSTEM 11 /* System error */
#define EAI_BADHINTS 12 /* Invalid value for hints */
#define EAI_PROTOCOL 13 /* Resolved protocol is unknown */
#define EAI_OVERFLOW 14 /* An argument buffer overflowed */
/* Glibc extensions. */
#define EAI_IDN_ENCODE 15 /* Parameter string not correctly encoded */
#ifndef __INSIDE_CYGWIN_NET__
void endhostent (void);

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,13 @@
What's new:
-----------
- getaddrinfo now supports glibc-specific International Domain Name (IDN)
extension flags: AI_IDN, AI_CANONIDN, AI_IDN_ALLOW_UNASSIGNED,
AI_IDN_USE_STD3_ASCII_RULES.
- getnameinfo now supports glibc-specific International Domain Name (IDN)
extension flags: NI_IDN, NI_IDN_ALLOW_UNASSIGNED, NI_IDN_USE_STD3_ASCII_RULES.
What changed:
-------------