home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / dev / misc / flexcat / src / flexcat_cat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-17  |  6.5 KB  |  162 lines

  1. /****************************************************************
  2.    This file was created automatically by `v'
  3.    from "0".
  4.  
  5.    Do NOT edit by hand!
  6. ****************************************************************/
  7.  
  8. /****************************************************************
  9.     This file uses the auto initialization possibilities of
  10.     Dice, gcc and SAS/C, respectively.
  11.  
  12.     Dice does this by using the keywords __autoinit and
  13.     __autoexit, SAS uses names beginning with _STI or
  14.     _STD, respectively. gcc uses the asm() instruction,
  15.     to emulate C++ constructors and destructors.
  16.  
  17.     Using this file you don't have *all* possibilities of
  18.     the locale.library. (No Locale or Language arguments are
  19.     supported when opening the catalog. However, these are
  20.     *very* rarely used, so this should be sufficient for most
  21.     applications.
  22.  
  23.     If you really need all possibilities or you have another
  24.     compiler, you should use the source description C_c_V21.sd
  25.     instead.
  26. ****************************************************************/
  27.  
  28.  
  29. /*
  30.     Include files and compiler specific stuff
  31. */
  32. #include <libraries/locale.h>
  33.  
  34. #if defined(__SASC)  ||  defined(_DCC)
  35. #include <proto/exec.h>
  36. #include <proto/locale.h>
  37. typedef struct Library LocaleBase_t;
  38. #elif defined(__GNUC__)
  39. #include <inline/exec.h>
  40. #include <inline/locale.h>
  41. typedef struct LocaleBase LocaleBase_t;
  42. #else
  43. #error "Don't know how to handle your compiler."
  44. #endif
  45.  
  46. #if defined(__SASC) || defined(__GNUC__)
  47. #define __autoinit
  48. #define __autoexit
  49. #endif
  50.  
  51.  
  52. /*
  53.     Variables
  54. */
  55. struct FC_Type
  56. {   LONG   ID;
  57.     STRPTR Str;
  58. };
  59. const struct FC_Type _msgMemoryError = { 0, (STRPTR) "Out of memory!" };
  60. const struct FC_Type _msgWarning = { 1, (STRPTR) "%s, Line %d; warning: " };
  61. const struct FC_Type _msgExpectedHex = { 2, (STRPTR) "Expected hex character (one of [0-9a-4A-F])." };
  62. const struct FC_Type _msgExpectedOctal = { 3, (STRPTR) "Expected octal character (one of [0-7])." };
  63. const struct FC_Type _msgNoCatalogDescription = { 4, (STRPTR) "Cannot open catalog description %s." };
  64. const struct FC_Type _msgNoLengthBytes = { 5, (STRPTR) "LengthBytes > %d (sizeof long) not possible." };
  65. const struct FC_Type _msgUnknownCDCommand = { 6, (STRPTR) "Unknown catalog description command" };
  66. const struct FC_Type _msgUnexpectedBlanks = { 7, (STRPTR) "Unexpected blanks." };
  67. const struct FC_Type _msgNoIdentifier = { 8, (STRPTR) "Missing identifier." };
  68. const struct FC_Type _msgNoLeadingBracket = { 9, (STRPTR) "Missing '('." };
  69. const struct FC_Type _msgDoubleID = { 10, (STRPTR) "ID number used twice." };
  70. const struct FC_Type _msgDoubleIdentifier = { 11, (STRPTR) "Identifier redeclared." };
  71. const struct FC_Type _msgNoMinLen = { 12, (STRPTR) "Expected MinLen (character '/')." };
  72. const struct FC_Type _msgNoMaxLen = { 13, (STRPTR) "Expected MaxLen (character '/')." };
  73. const struct FC_Type _msgNoTrailingBracket = { 14, (STRPTR) "Expected ')'." };
  74. const struct FC_Type _msgExtraCharacters = { 15, (STRPTR) "Extra characters at the end of the line." };
  75. const struct FC_Type _msgNoString = { 16, (STRPTR) "Unexpected end of file (missing catalog string)." };
  76. const struct FC_Type _msgShortString = { 17, (STRPTR) "String too short." };
  77. const struct FC_Type _msgLongString = { 18, (STRPTR) "String too long." };
  78. const struct FC_Type _msgNoCatalogTranslation = { 19, (STRPTR) "Cannot open catalog translation file %s." };
  79. const struct FC_Type _msgNoCTCommand = { 20, (STRPTR) "Missing catalog translation command. (Expected second '#'.)" };
  80. const struct FC_Type _msgUnknownCTCommand = { 21, (STRPTR) "Unknown catalog translation command." };
  81. const struct FC_Type _msgNoCTVersion = { 22, (STRPTR) "Missing catalog translation version." };
  82. const struct FC_Type _msgNoCTLanguage = { 23, (STRPTR) "Missing catalog translation language." };
  83. const struct FC_Type _msgNoCatalog = { 24, (STRPTR) "Cannot open catalog file %s." };
  84. const struct FC_Type _msgNoNewCTFile = { 25, (STRPTR) "Cannot create catalog translation file %s." };
  85. const struct FC_Type _msgUnknownIdentifier = { 26, (STRPTR) "%s missing in catalog description." };
  86. const struct FC_Type _msgNoSourceDescription = { 27, (STRPTR) "Cannot open source description file %s." };
  87. const struct FC_Type _msgNoSource = { 28, (STRPTR) "Cannot open source file %s." };
  88. const struct FC_Type _msgUnknownStringType = { 29, (STRPTR) "Unknown string type." };
  89. const struct FC_Type _msgNoTerminateBracket = { 30, (STRPTR) "Unexpected end of line. (Missing ')')" };
  90. const struct FC_Type _msgUsage = { 31, (STRPTR) "Usage:\tFlexCat CDFILE/A,CTFILE,CATALOG/K,NEWCTFILE/K,SOURCES/M,WARNCTGAPS/S\n\n"\
  91.     "    CDFILE:\tCatalog description file to scan.\n"\
  92.     "    CTFILE:\tCatalog translation file to scan.\n"\
  93.     "    CATALOG:\tCatalog file to create.\n"\
  94.     "    NEWCTFILE:\tCatalog translation file to create.\n"\
  95.     "    SOURCES:\tSources to create; must be something like sfile=sdfile,\n"\
  96.     "\t\twhere sfile is a sourcefile and sdfile is a source\n"\
  97.     "\t\tdescription file.\n"\
  98.     "    WARNCTGAPS: Warn symbols missing in CT file." };
  99. const struct FC_Type _msgNoCTArgument = { 32, (STRPTR) "Creating a catalog needs a catalog translation file as argument." };
  100. const struct FC_Type _msgNoBinChars = { 33, (STRPTR) "Binary characters in stringtype None." };
  101. const struct FC_Type _msgCTGap = { 34, (STRPTR) "ID %s missing in CT file." };
  102. const struct FC_Type _msgDoubleCTLanguage = { 35, (STRPTR) "Catalog language declared twice." };
  103. const struct FC_Type _msgDoubleCTVersion = { 36, (STRPTR) "Catalog version declared twice." };
  104.  
  105. static struct Catalog *FlexCat_Catalog = NULL;
  106.  
  107. LocaleBase_t *LocaleBase;
  108.  
  109.  
  110.  
  111.  
  112.  
  113. STATIC __autoinit VOID _STIOpenCatalog(VOID)
  114.  
  115.   {
  116.     STATIC const struct TagItem tags[] =
  117.       {
  118.     { OC_BuiltInLanguage, (ULONG) "english" },
  119.     { OC_Version, 2 },
  120.     { TAG_DONE, 0 }
  121.       };
  122.     if ((LocaleBase = (LocaleBase_t *)
  123.               OpenLibrary((STRPTR) "locale.library", 38)))
  124.     {
  125.       FlexCat_Catalog = OpenCatalogA(NULL, (STRPTR) "FlexCat.catalog",
  126.                 (struct TagItem *) tags);
  127.     }
  128.   }
  129.  
  130.  
  131.  
  132. STATIC __autoexit VOID _STDCloseCatalog(VOID)
  133.  
  134.   {
  135.     if (LocaleBase)
  136.       {
  137.     CloseCatalog(FlexCat_Catalog);
  138.     FlexCat_Catalog = NULL;
  139.     CloseLibrary((struct Library *) LocaleBase);
  140.       }
  141.   }
  142.  
  143.  
  144.  
  145. STRPTR GetString(struct FC_Type *fcstr)
  146.  
  147.   {
  148.     STRPTR defaultstr;
  149.     LONG strnum;
  150.  
  151.     strnum = fcstr->ID;
  152.     defaultstr = fcstr->Str;
  153.  
  154.     return(FlexCat_Catalog ? GetCatalogStr(FlexCat_Catalog, strnum, defaultstr) :
  155.             defaultstr);
  156.   }
  157.  
  158. #if defined(__GNUC__)
  159. asm ("  .text;  .stabs \"___CTOR_LIST__\",22,0,0,__STIOpenCatalog");
  160. asm ("  .text;  .stabs \"___DTOR_LIST__\",22,0,0,__STDCloseCatalog");
  161. #endif
  162.