misc/libfreetype/src/tools/apinames.c
author koda
Mon, 25 Apr 2011 01:46:54 +0200
changeset 5172 88f2e05288ba
permissions -rw-r--r--
aaand let's add freetype as well while we are at it other smaller changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
 * This little program is used to parse the FreeType headers and
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
 * find the declaration of all public APIs.  This is easy, because
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
 * they all look like the following:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
 *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
 *   FT_EXPORT( return_type )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
 *   function_name( function arguments );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
 *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
 * You must pass the list of header files as arguments.  Wildcards are
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
 * accepted if you are using GCC for compilation (and probably by
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
 * other compilers too).
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
 *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
 * Author: David Turner, 2005, 2006, 2008, 2009, 2010
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
 *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
 * This code is explicitly placed into the public domain.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
 *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include <stdio.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include <stdlib.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include <string.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include <ctype.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#define  PROGRAM_NAME     "apinames"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#define  PROGRAM_VERSION  "0.1"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#define  LINEBUFF_SIZE  1024
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
typedef enum  OutputFormat_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  OUTPUT_LIST = 0,      /* output the list of names, one per line             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  OUTPUT_WINDOWS_DEF,   /* output a Windows .DEF file for Visual C++ or Mingw */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  OUTPUT_BORLAND_DEF,   /* output a Windows .DEF file for Borland C++         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  OUTPUT_WATCOM_LBC     /* output a Watcom Linker Command File                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
} OutputFormat;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
panic( const char*  message )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  fprintf( stderr, "PANIC: %s\n", message );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  exit(2);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
typedef struct  NameRec_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  char*         name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
  unsigned int  hash;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
} NameRec, *Name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
static Name  the_names;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
static int   num_names;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
static int   max_names;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
names_add( const char*  name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
           const char*  end )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
  int   nn, len, h;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
  Name  nm;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
  if ( end <= name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
  /* compute hash value */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
  len = (int)(end - name);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
  h   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
  for ( nn = 0; nn < len; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    h = h*33 + name[nn];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
  /* check for an pre-existing name */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
  for ( nn = 0; nn < num_names; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    nm = the_names + nn;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    if ( (int)nm->hash                 == h &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
         memcmp( name, nm->name, len ) == 0 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
         nm->name[len]                 == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
  /* add new name */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
  if ( num_names >= max_names )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    max_names += (max_names >> 1) + 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
    the_names  = (NameRec*)realloc( the_names, sizeof(the_names[0])*max_names );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    if ( the_names == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
      panic( "not enough memory" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
  nm = &the_names[num_names++];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
  nm->hash = h;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
  nm->name = (char*)malloc( len+1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
  if ( nm->name == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    panic( "not enough memory" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
  memcpy( nm->name, name, len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
  nm->name[len] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
static int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
name_compare( const void*  name1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
              const void*  name2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
  Name  n1 = (Name)name1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  Name  n2 = (Name)name2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
  return strcmp( n1->name, n2->name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
names_sort( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
  qsort( the_names, (size_t)num_names, sizeof(the_names[0]), name_compare );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
names_dump( FILE*         out,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
            OutputFormat  format,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
            const char*   dll_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
  int  nn;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  switch ( format )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
    case OUTPUT_WINDOWS_DEF:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
      if ( dll_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
        fprintf( out, "LIBRARY %s\n", dll_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
      fprintf( out, "DESCRIPTION  FreeType 2 DLL\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
      fprintf( out, "EXPORTS\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
      for ( nn = 0; nn < num_names; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
        fprintf( out, "  %s\n", the_names[nn].name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
    case OUTPUT_BORLAND_DEF:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
      if ( dll_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
        fprintf( out, "LIBRARY %s\n", dll_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
      fprintf( out, "DESCRIPTION  FreeType 2 DLL\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
      fprintf( out, "EXPORTS\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
      for ( nn = 0; nn < num_names; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
        fprintf( out, "  _%s\n", the_names[nn].name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
    case OUTPUT_WATCOM_LBC:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
        /* we must omit the .dll suffix from the library name */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
        char         temp[512];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
        const char*  dot;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
        if ( dll_name == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
          fprintf( stderr,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
                   "you must provide a DLL name with the -d option!\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
          exit( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
        dot = strchr( dll_name, '.' );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
        if ( dot != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
          int  len = dot - dll_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
          if ( len > (int)( sizeof( temp ) - 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
            len = sizeof ( temp ) - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
          memcpy( temp, dll_name, len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
          temp[len] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
          dll_name = (const char*)temp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
        for ( nn = 0; nn < num_names; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
          fprintf( out, "++_%s.%s.%s\n", the_names[nn].name, dll_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
                        the_names[nn].name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
    default:  /* LIST */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
      for ( nn = 0; nn < num_names; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
        fprintf( out, "%s\n", the_names[nn].name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
/* states of the line parser */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
typedef enum  State_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
  STATE_START = 0,  /* waiting for FT_EXPORT keyword and return type */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
  STATE_TYPE        /* type was read, waiting for function name      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
} State;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
static int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
read_header_file( FILE*  file, int  verbose )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
  static char  buff[ LINEBUFF_SIZE+1 ];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
  State        state = STATE_START;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
  while ( !feof( file ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    char*  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
    if ( !fgets( buff, LINEBUFF_SIZE, file ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    p = buff;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    while ( *p && (*p == ' ' || *p == '\\') )  /* skip leading whitespace */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
      p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
    if ( *p == '\n' || *p == '\r' )  /* skip empty lines */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
      continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    switch ( state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
      case STATE_START:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
          if ( memcmp( p, "FT_EXPORT(", 10 ) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
          p += 10;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
          for (;;)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
            if ( *p == 0 || *p == '\n' || *p == '\r' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
              goto NextLine;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
            if ( *p == ')' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
              p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
            p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
          state = STATE_TYPE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
         /* sometimes, the name is just after the FT_EXPORT(...), so
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
          * skip whitespace, and fall-through if we find an alphanumeric
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
          * character
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
          while ( *p == ' ' || *p == '\t' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
            p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
          if ( !isalpha(*p) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
        /* fall-through */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
      case STATE_TYPE:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
          char*   name = p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
          while ( isalnum(*p) || *p == '_' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
            p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
          if ( p > name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
            if ( verbose )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
              fprintf( stderr, ">>> %.*s\n", (int)(p - name), name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
            names_add( name, p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
          state = STATE_START;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
        ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
  NextLine:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
    ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
  return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
usage( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
  static const char* const  format =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
   "%s %s: extract FreeType API names from header files\n\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
   "this program is used to extract the list of public FreeType API\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
   "functions. It receives the list of header files as argument and\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
   "generates a sorted list of unique identifiers\n\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
   "usage: %s header1 [options] [header2 ...]\n\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
   "options:   -      : parse the content of stdin, ignore arguments\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
   "           -v     : verbose mode, output sent to standard error\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
   "           -oFILE : write output to FILE instead of standard output\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
   "           -dNAME : indicate DLL file name, 'freetype.dll' by default\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
   "           -w     : output .DEF file for Visual C++ and Mingw\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
   "           -wB    : output .DEF file for Borland C++\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
   "           -wW    : output Watcom Linker Response File\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
   "\n";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
  fprintf( stderr,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
           format,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
           PROGRAM_NAME,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
           PROGRAM_VERSION,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
           PROGRAM_NAME
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
           );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
  exit(1);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
int  main( int argc, const char* const*  argv )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
  int           from_stdin = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
  int           verbose = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
  OutputFormat  format = OUTPUT_LIST;  /* the default */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
  FILE*         out    = stdout;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
  const char*   library_name = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
  if ( argc < 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
    usage();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
  /* '-' used as a single argument means read source file from stdin */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
  while ( argc > 1 && argv[1][0] == '-' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
    const char*  arg = argv[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
    switch ( arg[1] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
      case 'v':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
        verbose = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
      case 'o':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
        if ( arg[2] == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
          if ( argc < 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
            usage();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
          arg = argv[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
          argv++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
          argc--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
          arg += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
        out = fopen( arg, "wt" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
        if ( out == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
          fprintf( stderr, "could not open '%s' for writing\n", argv[2] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
          exit(3);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
      case 'd':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
        if ( arg[2] == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
          if ( argc < 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
            usage();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
          arg = argv[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
          argv++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
          argc--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
          arg += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
        library_name = arg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
      case 'w':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
        format = OUTPUT_WINDOWS_DEF;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
        switch ( arg[2] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
          case 'B':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
            format = OUTPUT_BORLAND_DEF;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
          case 'W':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
            format = OUTPUT_WATCOM_LBC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
          case 0:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
          default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
            usage();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
      case 0:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
        from_stdin = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
        usage();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
    argc--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
    argv++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
  if ( from_stdin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
    read_header_file( stdin, verbose );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
  else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
    for ( --argc, argv++; argc > 0; argc--, argv++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
      FILE*  file = fopen( argv[0], "rb" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
      if ( file == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
        fprintf( stderr, "unable to open '%s'\n", argv[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
        if ( verbose )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
          fprintf( stderr, "opening '%s'\n", argv[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
        read_header_file( file, verbose );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
        fclose( file );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
  if ( num_names == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
    panic( "could not find exported functions !!\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
  names_sort();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
  names_dump( out, format, library_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
  if ( out != stdout )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
    fclose( out );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
  return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
}