/* Prototypes */
#ifdef __GNUC__
#include <proto/locale.h>
#include <proto/dos.h>
#else
#include <proto/locale.h>
#include <clib/dos_protos.h>

extern struct Library *LocaleBase;

#endif /* __GNUC__ */



static LONG SearcherStrings_Version = 0;
static const STRPTR SearcherStrings_BuiltInLanguage = (STRPTR) "english";

struct FC_Type
{   LONG   ID;
    char *Str;
};

/* Definitions */
const struct FC_Type _MSG_AppDescription = { 0, "Search Records in ADAC Databases" };
const struct FC_Type _MSG_AppCopyright = { 1, "Point Design Software" };
const struct FC_Type _MSG_MN_Project = { 2, "Project" };
const struct FC_Type _MSG_MN_Quit = { 3, "Quit" };
const struct FC_Type _MSG_MN_QuitChar = { 4, "Q " };
const struct FC_Type _MSG_WI_Searcher = { 5, "ADAC Searcher" };
const struct FC_Type _MSG_GR_Search_Regs0 = { 6, "Fields" };
const struct FC_Type _MSG_GR_Search_Regs1 = { 7, "Query" };
const struct FC_Type _MSG_CY_Field0 = { 8, "Fieldname" };
const struct FC_Type _MSG_CY_Operator0 = { 9, "AND" };
const struct FC_Type _MSG_CY_Operator1 = { 10, "OR" };
const struct FC_Type _MSG_CY_Operator2 = { 11, "XOR" };
const struct FC_Type _MSG_BT_Add = { 12, "A\00Add Criteria" };
const struct FC_Type _MSG_BT_Remove = { 13, "C\00Remove Criteria" };
const struct FC_Type _MSG_BT_Search = { 14, "G\00Go" };
const struct FC_Type _MSG_BT_Quit = { 15, "Q\00Quit" };
const struct FC_Type _MSG_STR_DB_Server = { 16, "S\00Server:" };
const struct FC_Type _MSG_LA_DataBase = { 17, "_Database:" };
const struct FC_Type _MSG_LA_Table = { 18, "_Table:" };
const struct FC_Type _MSG_GR_ResultsTitle = { 19, "Results" };

extern void CloseAppCatalog(void);

static struct Catalog *SearcherStrings_Catalog = NULL;

void OpenAppCatalog(struct Locale *loc, STRPTR language)
{
	LONG tag, tagarg;

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

	if (SearcherStrings_Catalog == NULL)
	{
		if (language == NULL)
			tag = TAG_IGNORE;
		else
		{
			tag = OC_Language;
			tagarg = (LONG) language;
		}
		SearcherStrings_Catalog = OpenCatalog(loc, (STRPTR) "SearcherStrings.catalog",
			OC_BuiltInLanguage,(LONG)SearcherStrings_BuiltInLanguage,
			tag, tagarg,
			OC_Version, SearcherStrings_Version,
			TAG_DONE);
	}
}

void CloseAppCatalog(void)
{
	CloseCatalog(SearcherStrings_Catalog);
	SearcherStrings_Catalog = NULL;
}

char * Get_SearcherString(APTR fcstr)
{
	char *defaultstr;
	LONG strnum;

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

	return(SearcherStrings_Catalog ? (char *)GetCatalogStr(SearcherStrings_Catalog, strnum, defaultstr) :
			defaultstr);
}
