Update, from libc-alpha post.
[libidn.git] / libc / libc.patch
blobcaebcebd24e38e531960140783bc4014f642291d
1 Index: resolv/netdb.h
2 ===================================================================
3 RCS file: /cvs/glibc/libc/resolv/netdb.h,v
4 retrieving revision 1.42
5 diff -u -p -r1.42 netdb.h
6 --- resolv/netdb.h 24 Apr 2003 23:40:02 -0000 1.42
7 +++ resolv/netdb.h 7 Mar 2004 23:53:59 -0000
8 @@ -1,4 +1,4 @@
9 - /* Copyright (C) 1996-2002, 2003 Free Software Foundation, Inc.
10 + /* Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc.
11 This file is part of the GNU C Library.
13 The GNU C Library is free software; you can redistribute it and/or
14 @@ -573,6 +573,11 @@ struct gaicb
15 # define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
16 # define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
17 returned address type.. */
18 +# ifdef __USE_GNU
19 +# define AI_IDN 0x0040 /* IDN encode input (assuming it is encoded
20 + in the current locale's character set)
21 + before looking it up. */
22 +# endif
24 /* Error values for `getaddrinfo' function. */
25 # define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
26 @@ -592,6 +597,7 @@ struct gaicb
27 # define EAI_NOTCANCELED -102 /* Request not canceled. */
28 # define EAI_ALLDONE -103 /* All requests done. */
29 # define EAI_INTR -104 /* Interrupted by a signal. */
30 +# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
31 # endif
33 # define NI_MAXHOST 1025
34 Index: sysdeps/posix/getaddrinfo.c
35 ===================================================================
36 RCS file: /cvs/glibc/libc/sysdeps/posix/getaddrinfo.c,v
37 retrieving revision 1.56
38 diff -u -p -r1.56 getaddrinfo.c
39 --- sysdeps/posix/getaddrinfo.c 23 Feb 2004 19:52:58 -0000 1.56
40 +++ sysdeps/posix/getaddrinfo.c 7 Mar 2004 23:53:59 -0000
41 @@ -55,6 +55,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
42 #include <nsswitch.h>
43 #include <not-cancel.h>
45 +extern int idna_to_ascii_lz (const char *input, char **output, int flags);
46 +#define IDNA_SUCCESS 0
48 #define GAIH_OKIFUNSPEC 0x0100
49 #define GAIH_EAI ~(GAIH_OKIFUNSPEC)
51 @@ -539,6 +542,16 @@ gaih_inet (const char *name, const struc
52 at->scopeid = 0;
53 at->next = NULL;
55 + if (req->ai_flags & AI_IDN)
56 + {
57 + char *p = NULL;
58 + rc = idna_to_ascii_lz (name, &p, 0);
59 + if (rc != IDNA_SUCCESS)
60 + return -EAI_IDN_ENCODE;
61 + name = strdupa (p);
62 + free (p);
63 + }
65 if (inet_pton (AF_INET, name, at->addr) > 0)
67 if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
68 @@ -1252,7 +1265,7 @@ getaddrinfo (const char *name, const cha
70 if (hints->ai_flags
71 & ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST|AI_ADDRCONFIG|AI_V4MAPPED
72 - |AI_ALL))
73 + |AI_ALL|AI_IDN))
74 return EAI_BADFLAGS;
76 if ((hints->ai_flags & AI_CANONNAME) && name == NULL)