/****************************************************************
   This file was created automatically by `v'
   from "0".

   Do NOT edit by hand!
****************************************************************/

/****************************************************************
    This file uses the auto initialization possibilities of
    Dice, gcc and SAS/C, respectively.

    Dice does this by using the keywords __autoinit and
    __autoexit, SAS uses names beginning with _STI or
    _STD, respectively. gcc uses the asm() instruction,
    to emulate C++ constructors and destructors.

    Using this file you don't have *all* possibilities of
    the locale.library. (No Locale or Language arguments are
    supported when opening the catalog. However, these are
    *very* rarely used, so this should be sufficient for most
    applications.

    If you really need all possibilities or you have another
    compiler, you should use the source description C_c_V21.sd
    instead.
****************************************************************/


/*
    Include files and compiler specific stuff
*/
#include <libraries/locale.h>

#if defined(__SASC)  ||  defined(_DCC)
#include <proto/exec.h>
#include <proto/locale.h>
typedef struct Library LocaleBase_t;
#elif defined(__GNUC__)
#include <inline/exec.h>
#include <inline/locale.h>
typedef struct LocaleBase LocaleBase_t;
#else
#error "Don't know how to handle your compiler."
#endif

#if defined(__SASC) || defined(__GNUC__)
#define __autoinit
#define __autoexit
#endif


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

static struct Catalog *FlexCat_Catalog = NULL;

LocaleBase_t *LocaleBase;





STATIC __autoinit VOID _STIOpenCatalog(VOID)

  {
    STATIC const struct TagItem tags[] =
      {
	{ OC_BuiltInLanguage, (ULONG) "english" },
	{ OC_Version, 2 },
	{ TAG_DONE, 0 }
      };
    if ((LocaleBase = (LocaleBase_t *)
		      OpenLibrary((STRPTR) "locale.library", 38)))
    {
      FlexCat_Catalog = OpenCatalogA(NULL, (STRPTR) "FlexCat.catalog",
				(struct TagItem *) tags);
    }
  }



STATIC __autoexit VOID _STDCloseCatalog(VOID)

  {
    if (LocaleBase)
      {
	CloseCatalog(FlexCat_Catalog);
	FlexCat_Catalog = NULL;
	CloseLibrary((struct Library *) LocaleBase);
      }
  }



STRPTR GetString(struct FC_Type *fcstr)

  {
    STRPTR defaultstr;
    LONG strnum;

    strnum = fcstr->ID;
    defaultstr = fcstr->Str;

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

#if defined(__GNUC__)
asm ("  .text;  .stabs \"___CTOR_LIST__\",22,0,0,__STIOpenCatalog");
asm ("  .text;  .stabs \"___DTOR_LIST__\",22,0,0,__STDCloseCatalog");
#endif
