Upload tizen 2.0 beta source
[framework/graphics/freetype.git] / src / sfnt / sfdriver.c
index b74679b..847d83d 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    High-level SFNT driver interface (body).                             */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
+/*  Copyright 1996-2007, 2009-2011 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
                    FT_ULong  *offset,
                    FT_ULong  *length )
   {
-    if ( !tag || !offset || !length )
+    if ( !offset || !length )
       return SFNT_Err_Invalid_Argument;
 
-    if ( idx >= face->num_tables )
-      return SFNT_Err_Table_Missing;
+    if ( !tag )
+      *length = face->num_tables;
+    else
+    {
+      if ( idx >= face->num_tables )
+        return SFNT_Err_Table_Missing;
 
-    *tag    = face->dir_tables[idx].Tag;
-    *offset = face->dir_tables[idx].Offset;
-    *length = face->dir_tables[idx].Length;
+      *tag    = face->dir_tables[idx].Tag;
+      *offset = face->dir_tables[idx].Offset;
+      *length = face->dir_tables[idx].Length;
+    }
 
     return SFNT_Err_Ok;
   }
   sfnt_get_interface( FT_Module    module,
                       const char*  module_interface )
   {
-    FT_UNUSED( module );
+    /* FT_SFNT_SERVICES_GET derefers `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+    FT_Library  library;
+
 
+    if ( !module )
+      return NULL;
+    library = module->library;
+    if ( !library )
+      return NULL;
+#else
+    FT_UNUSED( module );
+#endif
     return ft_service_list_lookup( FT_SFNT_SERVICES_GET, module_interface );
   }
 
 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
 
 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-#define PUT_EMBEDDED_BITMAPS(a) a 
+#define PUT_EMBEDDED_BITMAPS(a) a
 #else
-#define PUT_EMBEDDED_BITMAPS(a) 0 
+#define PUT_EMBEDDED_BITMAPS(a) 0
 #endif
 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-#define PUT_PS_NAMES(a) a 
+#define PUT_PS_NAMES(a) a
 #else
-#define PUT_PS_NAMES(a) 0 
+#define PUT_PS_NAMES(a) 0
 #endif
 
   FT_DEFINE_SFNT_INTERFACE(sfnt_interface,
 
 
   FT_DEFINE_MODULE(sfnt_module_class,
-  
+
     0,  /* not a font driver or renderer */
-    sizeof( FT_ModuleRec ),
+    sizeof ( FT_ModuleRec ),
 
     "sfnt",     /* driver name                            */
     0x10000L,   /* driver version 1.0                     */