home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / dev / flexcat / src / flexcat_cat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-08  |  5.0 KB  |  118 lines

  1. /****************************************************************
  2.    This file was created automatically by `FlexCat V1.1'
  3.    Do NOT edit by hand!
  4. ****************************************************************/
  5.  
  6. #include <clib/locale_protos.h>
  7.  
  8. #ifdef AZTEC_C
  9. #include <pragmas/locale_lib.h>
  10. #endif /*   AZTEC_C            */
  11.  
  12. #if defined(__SASC)  ||  defined(_DCC)  ||  defined(__MAXON__)
  13. #include <pragmas/locale_pragmas.h>
  14. #endif    /*  __SASC  ||    _DCC  ||  __MAXON__    */
  15.  
  16. #ifdef __GNUC__
  17. #include <inline/locale.h>
  18. #endif    /*  __GNUC__    */
  19.  
  20.  
  21.  
  22.  
  23. static LONG FlexCat_Version = 0;
  24. static const STRPTR FlexCat_BuiltInLanguage = (STRPTR) "english";
  25.  
  26. struct FC_Type
  27. {   LONG   ID;
  28.     STRPTR Str;
  29. };
  30.  
  31.  
  32. const struct FC_Type _msgMemoryError = { 0, "Out of memory!" };
  33. const struct FC_Type _msgWarning = { 1, "%s, Line %d; warning: " };
  34. const struct FC_Type _msgExpectedHex = { 2, "Expected hex character (one of [0-9a-4A-F])." };
  35. const struct FC_Type _msgExpectedOctal = { 3, "Expected octal character (one of [0-7])." };
  36. const struct FC_Type _msgNoCatalogDescription = { 4, "Cannot open catalog description %s." };
  37. const struct FC_Type _msgNoLengthBytes = { 5, "LengthBytes > %d (sizeof long) not possible." };
  38. const struct FC_Type _msgUnknownCDCommand = { 6, "Unknown catalog description command" };
  39. const struct FC_Type _msgUnexpectedBlanks = { 7, "Unexpected blanks." };
  40. const struct FC_Type _msgNoIdentifier = { 8, "Missing identifier." };
  41. const struct FC_Type _msgNoLeadingBracket = { 9, "Missing '('." };
  42. const struct FC_Type _msgDoubleID = { 10, "ID number used twice." };
  43. const struct FC_Type _msgDoubleIdentifier = { 11, "Identifier redeclared." };
  44. const struct FC_Type _msgNoMinLen = { 12, "Expected MinLen (character '/')." };
  45. const struct FC_Type _msgNoMaxLen = { 13, "Expected MaxLen (character '/')." };
  46. const struct FC_Type _msgNoTrailingBracket = { 14, "Expected ')'." };
  47. const struct FC_Type _msgExtraCharacters = { 15, "Extra characters at the end of the line." };
  48. const struct FC_Type _msgNoString = { 16, "Unexpected end of file (missing catalog string)." };
  49. const struct FC_Type _msgShortString = { 17, "String too short." };
  50. const struct FC_Type _msgLongString = { 18, "String too long." };
  51. const struct FC_Type _msgNoCatalogTranslation = { 19, "Cannot open catalog translation file %s." };
  52. const struct FC_Type _msgNoCTCommand = { 20, "Missing catalog translation command. (Expected second '#'.)" };
  53. const struct FC_Type _msgUnknownCTCommand = { 21, "Unknown catalog translation command." };
  54. const struct FC_Type _msgNoCTVersion = { 22, "Missing catalog translation version." };
  55. const struct FC_Type _msgNoCTLanguage = { 23, "Missing catalog translation language." };
  56. const struct FC_Type _msgNoCatalog = { 24, "Cannot open catalog file %s." };
  57. const struct FC_Type _msgNoNewCTFile = { 25, "Cannot create catalog translation file %s." };
  58. const struct FC_Type _msgUnknownIdentifier = { 26, "%s missing in catalog description." };
  59. const struct FC_Type _msgNoSourceDescription = { 27, "Cannot open source description file %s." };
  60. const struct FC_Type _msgNoSource = { 28, "Cannot open source file %s." };
  61. const struct FC_Type _msgUnknownStringType = { 29, "Unknown string type." };
  62. const struct FC_Type _msgNoTerminateBracket = { 30, "Unexpected end of line. (Missing ')')" };
  63. const struct FC_Type _msgUsage = { 31, "Usage:\tFlexCat CDFILE/A,CTFILE,CATALOG/K,NEWCTFILE/K,SOURCES/M\n\n"\
  64.     "    CDFILE:\tcatalog description file to scan.\n"\
  65.     "    CTFILE:\tcatalog translation file to scan.\n"\
  66.     "    CATALOG:\tcatalog file to create.\n"\
  67.     "    NEWCTFILE:\tcatalog translation file to create.\n"\
  68.     "    SOURCES:\tsources to create; must be something like sfile=sdfile,\n"\
  69.     "\t\twhere sfile is a sourcefile and sdfile is a source\n"\
  70.     "\t\tdescription file.\n" };
  71. const struct FC_Type _msgNoCTArgument = { 32, "Creating a catalog needs a catalog translation file as argument." };
  72. const struct FC_Type _msgNoBinChars = { 33, "Binary characters in stringtype None." };
  73.  
  74.  
  75. static struct Catalog *FlexCat_Catalog = NULL;
  76.  
  77. void OpenFlexCatCatalog(struct Locale *loc, STRPTR language)
  78. { LONG tag, tagarg;
  79.   extern struct Library *LocaleBase;
  80.   extern void CloseFlexCatCatalog(void);
  81.  
  82.   CloseFlexCatCatalog(); /* Not needed if the programmer pairs OpenFlexCatCatalog
  83.                and CloseFlexCatCatalog right, but does no harm.  */
  84.  
  85.   if (LocaleBase != NULL  &&  FlexCat_Catalog == NULL)
  86.   { if (language == NULL)
  87.     { tag = TAG_IGNORE;
  88.     }
  89.     else
  90.     { tag = OC_Language;
  91.       tagarg = (LONG) language;
  92.     }
  93.     FlexCat_Catalog = OpenCatalog(loc, (STRPTR) "FlexCat.catalog",
  94.                 OC_BuiltInLanguage, FlexCat_BuiltInLanguage,
  95.                 tag, tagarg,
  96.                 OC_Version, FlexCat_Version,
  97.                 TAG_DONE);
  98.   }
  99. }
  100.  
  101. void CloseFlexCatCatalog(void)
  102. { if (LocaleBase != NULL)
  103.   { CloseCatalog(FlexCat_Catalog);
  104.   }
  105.   FlexCat_Catalog = NULL;
  106. }
  107.  
  108. STRPTR GetFlexCatString(APTR fcstr)
  109. { STRPTR defaultstr;
  110.   LONG strnum;
  111.  
  112.   strnum = ((struct FC_Type *) fcstr)->ID;
  113.   defaultstr = ((struct FC_Type *) fcstr)->Str;
  114.  
  115.   return(FlexCat_Catalog ? GetCatalogStr(FlexCat_Catalog, strnum, defaultstr) :
  116.               defaultstr);
  117. }
  118.