]> git.sesse.net Git - vlc/commitdiff
- Support for glibc IDN
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 16 Oct 2005 14:32:37 +0000 (14:32 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 16 Oct 2005 14:32:37 +0000 (14:32 +0000)
- Run-time check for IDN

include/network.h
src/misc/getaddrinfo.c

index d484ba6bcb4fd995b4c92c3f29d7b9e9aeae7130..6c6226be7b2c76c1d0668729547b1548c093a97a 100644 (file)
@@ -484,12 +484,6 @@ struct addrinfo
 #  define AI_NUMERICHOST 4
 # endif /* if !HAVE_STRUCT_ADDRINFO */
 
-/*** libidn support ***/
-# ifndef AI_IDN
-#  define AI_IDN      0
-#  define AI_CANONIDN 0
-# endif
-
 VLC_EXPORT( const char *, vlc_gai_strerror, ( int ) );
 VLC_EXPORT( int, vlc_getnameinfo, ( const struct sockaddr *, int, char *, int, int *, int ) );
 VLC_EXPORT( int, vlc_getaddrinfo, ( vlc_object_t *, const char *, int, const struct addrinfo *, struct addrinfo ** ) );
index 4fcd5d23dbf0af578c026ef63db89570cfa7eb80..114d3241edbac49a4d5f8637404e36ef6f666164 100644 (file)
@@ -638,7 +638,7 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
                                             struct addrinfo ** );
         HINSTANCE wship6_module;
         GETADDRINFO ws2_getaddrinfo;
-         
+
         wship6_module = LoadLibrary( "wship6.dll" );
         if( wship6_module != NULL )
         {
@@ -659,6 +659,30 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
     }
 #endif
 #if defined( HAVE_GETADDRINFO ) || defined( UNDER_CE )
+# ifdef AI_IDN
+    /* Run-time I18n Domain Names support */
+    {
+        static int i_idn = AI_IDN; /* beware of thread-safety */
+
+        if( i_idn )
+        {
+            int i_ret;
+
+            hints.ai_flags |= i_idn;
+            i_ret = getaddrinfo( psz_node, psz_service, &hints, res );
+
+            if( i_ret != EAI_BADFLAGS )
+                return i_ret;
+
+            /* libidn not available: disable and retry without it */
+
+            /* NOTE: Using i_idn here would not be thread-safe */
+            hints.ai_flags &= ~AI_IDN;
+            i_idn = 0;
+            msg_Dbg( p_this, "I18n Domain Names not supported - disabled" );
+        }
+    }
+# endif
     return getaddrinfo( psz_node, psz_service, &hints, res );
 #else
 {