Imported Upstream version 2.13.2
[platform/upstream/freetype2.git] / src / tools / apinames.c
index aeecf88..dfa258f 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <string.h>
 #include <ctype.h>
 
+#include "vms_shorten_symbol.c"
+
 #define  PROGRAM_NAME     "apinames"
-#define  PROGRAM_VERSION  "0.3"
+#define  PROGRAM_VERSION  "0.5"
 
 #define  LINEBUFF_SIZE  1024
 
@@ -33,6 +36,7 @@ typedef enum  OutputFormat_
   OUTPUT_WINDOWS_DEF,   /* output a Windows .DEF file for Visual C++ or Mingw */
   OUTPUT_BORLAND_DEF,   /* output a Windows .DEF file for Borland C++         */
   OUTPUT_WATCOM_LBC,    /* output a Watcom Linker Command File                */
+  OUTPUT_VMS_OPT,       /* output an OpenVMS Linker Option File               */
   OUTPUT_NETWARE_IMP,   /* output a NetWare ImportFile                        */
   OUTPUT_GNU_VERMAP     /* output a version map for GNU or Solaris linker     */
 
@@ -40,9 +44,20 @@ typedef enum  OutputFormat_
 
 
 static void
-panic( const char*  message )
+panic( const char*  fmt,
+       ... )
 {
-  fprintf( stderr, "PANIC: %s\n", message );
+  va_list  ap;
+
+
+  fprintf( stderr, "PANIC: " );
+
+  va_start( ap, fmt );
+  vfprintf( stderr, fmt, ap );
+  va_end( ap );
+
+  fprintf( stderr, "\n" );
+
   exit(2);
 }
 
@@ -167,7 +182,6 @@ names_dump( FILE*         out,
   case OUTPUT_WATCOM_LBC:
     {
       const char*  dot;
-      char         temp[512];
 
 
       if ( !dll_name )
@@ -181,7 +195,8 @@ names_dump( FILE*         out,
       dot = strchr( dll_name, '.' );
       if ( dot )
       {
-        int  len = dot - dll_name;
+        char  temp[512];
+        int   len = dot - dll_name;
 
 
         if ( len > (int)( sizeof ( temp ) - 1 ) )
@@ -200,6 +215,28 @@ names_dump( FILE*         out,
 
     break;
 
+  case OUTPUT_VMS_OPT:
+    fprintf( out, "case_sensitive=YES\n" );
+
+    for ( nn = 0; nn < num_names; nn++ )
+    {
+      char  short_symbol[32];
+
+
+      if ( vms_shorten_symbol( the_names[nn].name, short_symbol, 1 ) == -1 )
+        panic( "could not shorten name '%s'", the_names[nn].name );
+      fprintf( out, "symbol_vector = ( %s = PROCEDURE)\n", short_symbol );
+
+      /* Also emit a 64-bit symbol, as created by the `vms_auto64` tool. */
+      /* It has the string '64__' appended to its name.                  */
+      strcat( the_names[nn].name , "64__" );
+      if ( vms_shorten_symbol( the_names[nn].name, short_symbol, 1 ) == -1 )
+        panic( "could not shorten name '%s'", the_names[nn].name );
+      fprintf( out, "symbol_vector = ( %s = PROCEDURE)\n", short_symbol );
+    }
+
+    break;
+
   case OUTPUT_NETWARE_IMP:
     if ( dll_name )
       fprintf( out, "  (%s)\n", dll_name );
@@ -352,6 +389,7 @@ usage( void )
     "           -w      output .DEF file for Visual C++ and Mingw\n"
     "           -wB     output .DEF file for Borland C++\n"
     "           -wW     output Watcom Linker Response File\n"
+    "           -wV     output OpenVMS Linker Options File\n"
     "           -wN     output NetWare Import File\n"
     "           -wL     output version map for GNU or Solaris linker\n"
     "\n";
@@ -445,6 +483,10 @@ main( int                 argc,
         format = OUTPUT_WATCOM_LBC;
         break;
 
+      case 'V':
+        format = OUTPUT_VMS_OPT;
+        break;
+
       case 'N':
         format = OUTPUT_NETWARE_IMP;
         break;