home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / new / dev / misc / flexcat / src / flexcat_cat.c < prev    next >
C/C++ Source or Header  |  1993-12-21  |  4KB  |  120 lines

  1. /****************************************************************
  2.    This file was created automatically by `FlexCat V1.0'
  3.    Do NOT edit by hand!
  4. ****************************************************************/
  5.  
  6. #ifndef FlexCat_CAT_H
  7. #include "FlexCat_cat.h"
  8. #endif    /*  !FlexCat_CAT_H            */
  9.  
  10. #ifndef CLIB_LOCALE_PROTOS_H
  11. #include <clib/locale_protos.h>
  12. #endif    /*  !CLIB_LOCALE_PROTOS_H   */
  13.  
  14. #ifdef AZTEC_C
  15. #ifndef __PRAGMAS_LOCALE_LIB_H
  16. #include <pragmas/locale_lib.h>
  17. #endif /*   !PRAGMAS_LOCALE_LIB_H   */
  18. #endif /*   AZTEC_C            */
  19.  
  20. static LONG FlexCat_Version = 0;
  21. static const STRPTR FlexCat_BuiltInLanguage = (STRPTR) "english";
  22.  
  23. struct FC_Type
  24. {   LONG   ID;
  25.     STRPTR Str;
  26. };
  27.  
  28.  
  29. static const struct FC_Type FlexCat_Array [] =
  30. {
  31.     msgMemoryError, (STRPTR) "Out of memory!",
  32.     msgWarning, (STRPTR) "%s, Line %d; warning: "\
  33.     "",
  34.     msgExpectedHex, (STRPTR) "Expected hex character (one of [0-9a-4A-F]).",
  35.     msgExpectedOctal, (STRPTR) "Expected octal character (one of [0-7]).",
  36.     msgNoCatalogDescription, (STRPTR) "Cannot open catalog description %s.",
  37.     msgNoLengthBytes, (STRPTR) "LengthBytes > %d (sizeof long) not possible.",
  38.     msgUnknownCDCommand, (STRPTR) "Unknown catalog description command",
  39.     msgUnexpectedBlanks, (STRPTR) "Unexpected blanks.",
  40.     msgNoIdentifier, (STRPTR) "Missing identifier.",
  41.     msgNoLeadingBracket, (STRPTR) "Missing '('.",
  42.     msgDoubleID, (STRPTR) "ID number used twice.",
  43.     msgDoubleIdentifier, (STRPTR) "Identifier redeclared.",
  44.     msgNoMinLen, (STRPTR) "Expected MinLen (character '/').",
  45.     msgNoMaxLen, (STRPTR) "Expected MaxLen (character '/').",
  46.     msgNoTrailingBracket, (STRPTR) "Expected ')'.",
  47.     msgExtraCharacters, (STRPTR) "Extra characters at the end of the line.",
  48.     msgNoString, (STRPTR) "Unexpected end of file (missing catalog string).",
  49.     msgShortString, (STRPTR) "String too short.",
  50.     msgLongString, (STRPTR) "String too long.",
  51.     msgNoCatalogTranslation, (STRPTR) "Cannot open catalog translation file %s.",
  52.     msgNoCTCommand, (STRPTR) "Missing catalog translation command. (Expected second '#'.)",
  53.     msgUnknownCTCommand, (STRPTR) "Unknown catalog translation command.",
  54.     msgNoCTVersion, (STRPTR) "Missing catalog translation version.",
  55.     msgNoCTLanguage, (STRPTR) "Missing catalog translation language.",
  56.     msgNoCatalog, (STRPTR) "Cannot open catalog file %s.",
  57.     msgNoNewCTFile, (STRPTR) "Cannot create catalog translation file %s.",
  58.     msgUnknownIdentifier, (STRPTR) "%s missing in catalog description.",
  59.     msgNoSourceDescription, (STRPTR) "Cannot open source description file %s.",
  60.     msgNoSource, (STRPTR) "Cannot open source file %s.",
  61.     msgUnknownStringType, (STRPTR) "Unknown string type.",
  62.     msgNoTerminateBracket, (STRPTR) "Unexpected end of line. (Missing ')')",
  63.     msgUsage, (STRPTR) "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.     msgNoCTArgument, (STRPTR) "Creating a catalog needs a catalog translation file as argument.",
  72.     msgNoBinChars, (STRPTR) "Binary characters in stringtype None.",
  73. };
  74.  
  75.  
  76. static struct Catalog *FlexCat_Catalog = NULL;
  77.  
  78. void OpenFlexCatCatalog(struct Locale *loc, STRPTR language)
  79. { LONG tag, tagarg;
  80.   extern struct Library *LocaleBase;
  81.  
  82.   if (language == NULL)
  83.   { tag = TAG_IGNORE;
  84.   }
  85.   else
  86.   { tag = OC_Language;
  87.     tagarg = (LONG) language;
  88.   }
  89.   if (LocaleBase != NULL  &&  FlexCat_Catalog == NULL)
  90.   { FlexCat_Catalog = OpenCatalog(loc, (STRPTR) "FlexCat.catalog",
  91.                  OC_BuiltInLanguage, FlexCat_BuiltInLanguage,
  92.                  tag, tagarg,
  93.                  OC_Version, FlexCat_Version,
  94.                  TAG_DONE);
  95.   }
  96. }
  97.  
  98. void CloseFlexCatCatalog(void)
  99. { if (LocaleBase != NULL)
  100.   { CloseCatalog(FlexCat_Catalog);
  101.   }
  102.   FlexCat_Catalog = NULL;
  103. }
  104.  
  105. STRPTR GetFlexCatString(LONG strnum)
  106. { STRPTR defaultstr = NULL;
  107.   LONG i;
  108.  
  109.   for (i = 0;  i < sizeof(FlexCat_Array)/sizeof(struct FC_Type);  i++)
  110.     { if (FlexCat_Array[i].ID == strnum)
  111.       { defaultstr = FlexCat_Array[i].Str;
  112.     break;
  113.       }
  114.     }
  115.   if (FlexCat_Catalog == NULL)
  116.   { return(defaultstr);
  117.   }
  118.   return(GetCatalogStr(FlexCat_Catalog, strnum, defaultstr));
  119. }
  120.