/****************************************************************
   This file was created automatically by `FlexCat V1.1'
   Do NOT edit by hand!
****************************************************************/

#include <clib/locale_protos.h>

#ifdef AZTEC_C
#include <pragmas/locale_lib.h>
#endif /*   AZTEC_C		    */

#if defined(__SASC)  ||  defined(_DCC)  ||  defined(__MAXON__)
#include <pragmas/locale_pragmas.h>
#endif	/*  __SASC  ||	_DCC  ||  __MAXON__	*/

#ifdef __GNUC__
#include <inline/locale.h>
#endif	/*  __GNUC__	*/




static LONG FlexCat_Version = 0;
static const STRPTR FlexCat_BuiltInLanguage = (STRPTR) "english";

struct FC_Type
{   LONG   ID;
    STRPTR Str;
};


const struct FC_Type _msgMemoryError = { 0, "Out of memory!" };
const struct FC_Type _msgWarning = { 1, "%s, Line %d; warning: " };
const struct FC_Type _msgExpectedHex = { 2, "Expected hex character (one of [0-9a-4A-F])." };
const struct FC_Type _msgExpectedOctal = { 3, "Expected octal character (one of [0-7])." };
const struct FC_Type _msgNoCatalogDescription = { 4, "Cannot open catalog description %s." };
const struct FC_Type _msgNoLengthBytes = { 5, "LengthBytes > %d (sizeof long) not possible." };
const struct FC_Type _msgUnknownCDCommand = { 6, "Unknown catalog description command" };
const struct FC_Type _msgUnexpectedBlanks = { 7, "Unexpected blanks." };
const struct FC_Type _msgNoIdentifier = { 8, "Missing identifier." };
const struct FC_Type _msgNoLeadingBracket = { 9, "Missing '('." };
const struct FC_Type _msgDoubleID = { 10, "ID number used twice." };
const struct FC_Type _msgDoubleIdentifier = { 11, "Identifier redeclared." };
const struct FC_Type _msgNoMinLen = { 12, "Expected MinLen (character '/')." };
const struct FC_Type _msgNoMaxLen = { 13, "Expected MaxLen (character '/')." };
const struct FC_Type _msgNoTrailingBracket = { 14, "Expected ')'." };
const struct FC_Type _msgExtraCharacters = { 15, "Extra characters at the end of the line." };
const struct FC_Type _msgNoString = { 16, "Unexpected end of file (missing catalog string)." };
const struct FC_Type _msgShortString = { 17, "String too short." };
const struct FC_Type _msgLongString = { 18, "String too long." };
const struct FC_Type _msgNoCatalogTranslation = { 19, "Cannot open catalog translation file %s." };
const struct FC_Type _msgNoCTCommand = { 20, "Missing catalog translation command. (Expected second '#'.)" };
const struct FC_Type _msgUnknownCTCommand = { 21, "Unknown catalog translation command." };
const struct FC_Type _msgNoCTVersion = { 22, "Missing catalog translation version." };
const struct FC_Type _msgNoCTLanguage = { 23, "Missing catalog translation language." };
const struct FC_Type _msgNoCatalog = { 24, "Cannot open catalog file %s." };
const struct FC_Type _msgNoNewCTFile = { 25, "Cannot create catalog translation file %s." };
const struct FC_Type _msgUnknownIdentifier = { 26, "%s missing in catalog description." };
const struct FC_Type _msgNoSourceDescription = { 27, "Cannot open source description file %s." };
const struct FC_Type _msgNoSource = { 28, "Cannot open source file %s." };
const struct FC_Type _msgUnknownStringType = { 29, "Unknown string type." };
const struct FC_Type _msgNoTerminateBracket = { 30, "Unexpected end of line. (Missing ')')" };
const struct FC_Type _msgUsage = { 31, "Usage:\tFlexCat CDFILE/A,CTFILE,CATALOG/K,NEWCTFILE/K,SOURCES/M\n\n"\
	"    CDFILE:\tcatalog description file to scan.\n"\
	"    CTFILE:\tcatalog translation file to scan.\n"\
	"    CATALOG:\tcatalog file to create.\n"\
	"    NEWCTFILE:\tcatalog translation file to create.\n"\
	"    SOURCES:\tsources to create; must be something like sfile=sdfile,\n"\
	"\t\twhere sfile is a sourcefile and sdfile is a source\n"\
	"\t\tdescription file.\n" };
const struct FC_Type _msgNoCTArgument = { 32, "Creating a catalog needs a catalog translation file as argument." };
const struct FC_Type _msgNoBinChars = { 33, "Binary characters in stringtype None." };


static struct Catalog *FlexCat_Catalog = NULL;

void OpenFlexCatCatalog(struct Locale *loc, STRPTR language)
{ LONG tag, tagarg;
  extern struct Library *LocaleBase;
  extern void CloseFlexCatCatalog(void);

  CloseFlexCatCatalog(); /* Not needed if the programmer pairs OpenFlexCatCatalog
		       and CloseFlexCatCatalog right, but does no harm.  */

  if (LocaleBase != NULL  &&  FlexCat_Catalog == NULL)
  { if (language == NULL)
    { tag = TAG_IGNORE;
    }
    else
    { tag = OC_Language;
      tagarg = (LONG) language;
    }
    FlexCat_Catalog = OpenCatalog(loc, (STRPTR) "FlexCat.catalog",
				OC_BuiltInLanguage, FlexCat_BuiltInLanguage,
				tag, tagarg,
				OC_Version, FlexCat_Version,
				TAG_DONE);
  }
}

void CloseFlexCatCatalog(void)
{ if (LocaleBase != NULL)
  { CloseCatalog(FlexCat_Catalog);
  }
  FlexCat_Catalog = NULL;
}

STRPTR GetFlexCatString(APTR fcstr)
{ STRPTR defaultstr;
  LONG strnum;

  strnum = ((struct FC_Type *) fcstr)->ID;
  defaultstr = ((struct FC_Type *) fcstr)->Str;

  return(FlexCat_Catalog ? GetCatalogStr(FlexCat_Catalog, strnum, defaultstr) :
		      defaultstr);
}
