// catalog parser for AmyShutDown

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

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

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

static LONG ShutDownStrings_Version = 0;
static const STRPTR ShutDownStrings_BuiltInLanguage = (STRPTR) "english";

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

/* Definitions */
const struct FC_Type _MSG_winChoose = { 2, "ShutDown System?" };
const struct FC_Type _MSG_labSelect = { 3, "\033b\033cP_lease Select" };
const struct FC_Type _MSG_radOptions = { 4, "l\00" };
const struct FC_Type _MSG_radOptions0 = { 5, "ShutDown the system" };
const struct FC_Type _MSG_radOptions1 = { 6, "Reboot the system" };
const struct FC_Type _MSG_butOk = { 7, "O_k" };
const struct FC_Type _MSG_butCancel = { 8, "Ca_ncel" };

#ifdef __SASC
extern struct Library *LocaleBase;
#endif /* __SASC */
extern void CloseAppCatalog(void);

static struct Catalog *ShutDownStrings_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 (LocaleBase != NULL  &&  ShutDownStrings_Catalog == NULL)
	{
	if (language == NULL)
		tag = TAG_IGNORE;
	else
	{
		tag = OC_Language;
		tagarg = (LONG) language;
	}
	ShutDownStrings_Catalog = OpenCatalog(loc, (STRPTR) "AmyShutDown.catalog",
			OC_BuiltInLanguage,(LONG)ShutDownStrings_BuiltInLanguage,
			tag, tagarg,
			OC_Version, ShutDownStrings_Version,
			TAG_DONE);
	}
}

void CloseAppCatalog(void)
{
	if (LocaleBase != NULL)
		CloseCatalog(ShutDownStrings_Catalog);
	ShutDownStrings_Catalog = NULL;
}

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

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

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