/****************************************************************
   This file was created automatically by `FlexCat 2.4'
   from "locale/Amster.cd".

   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.
****************************************************************/


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

#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/locale.h>
#include <proto/utility.h>
#include <proto/iffparse.h>

#include <stdlib.h>
#include <string.h>



#include "Amster_cat.h"


/*
    Variables
*/
struct FC_String Amster_Strings[211] = {
    { (STRPTR) "Napster client", 0 },
    { (STRPTR) "About this fine product...", 1 },
    { (STRPTR) "Version", 2 },
    { (STRPTR) "Team", 3 },
    { (STRPTR) "License", 4 },
    { (STRPTR) "Homepage <http://home.worldonline.dk/~jlaur/amiga/amster>", 5 },
    { (STRPTR) "Mailing list <http://www.egroups.com/group/amster>", 6 },
    { (STRPTR) "\033c\033bCoding\033p\n"\
	"\033cGürer Özen <palpa@linuxfan.com>\n"\
	"\033cJacob Laursen <laursen@myself.com>\n\n"\
	"\033c\033bDocumentation\033p\n"\
	"\033cJacob Laursen <laursen@myself.com>\n\n"\
	"\033c\033bTranslation\033p\n"\
	"\033uCoordinator\n"\
	"Jacob Laursen <laursen@myself.com>\n\n"\
	"\033uATO Translators\n"\
	"   \033iCatalan:\n"\
	"Llorenç Grau <llor69@olivet.com>\n\n"\
	"   \033iCzech\n"\
	"Vit Sindlar <sindlarv@voskop.cz>\n\n"\
	"   \033iDanish\n"\
	"Jacob Laursen <laursen@myself.com>\n\n"\
	"   \033iDutch\n"\
	"Frank Mosch <frank.mosch@pandora.be>\n"\
	"Guno Heitman <Guno@cable.A2000.nl>\n\n"\
	"   \033iFinnish\n"\
	"Janne Karppanen <janne.karppanen@quicknet.inet.fi>\n"\
	"Samppa Rönkä <eksotic@dlc.fi>\n\n"\
	"   \033iGerman\n"\
	"Heiko Hayn <Smeagel@gmx.net>\n"\
	"Sönke Tesch <s.tesch@sh-home.de>\n\n"\
	"   \033iHungarian\n"\
	"Álmos Rajnai <racs@fs2.bdtf.hu>\n"\
	"Péter Horváth <pcpince@syneco.hu>\n\n"\
	"   \033iItalian\n"\
	"Francesco Celli <mc3510@mclink.it>\n"\
	"Francesco Mancuso <mcfrank@mediatel.it>\n\n"\
	"   \033iNorwegian\n"\
	"Řyvind Falch <oyvind.falch@triumph.no>\n\n"\
	"   \033iPortuguese\n"\
	"Rúben Alvim <alvim_r@yahoo.com>\n"\
	"Joel Alvim <mindwalker@mail.telepac.pt>\n\n"\
	"   \033iRussian\n"\
	"Oleg Sergeev <bigblack@mail.lanck.net>\n"\
	"Andrew Boyarintsev <ntrs@redline.ru>\n\n"\
	"   \033iSlovenian\n"\
	"Uros Bogataj <urosb@technologist.com>\n"\
	"Damir Arh <damir.arh@telesat.si>\n\n"\
	"   \033iSpanish\n"\
	"Javier de las Rivas <javierdlr@retemail.es>\n\n"\
	"   \033iSwedish\n"\
	"Fredrik Söderberg <mcdrill@hem.passagen.se>\n"\
	"Linus Andersson <linus_79@lover-boy.com>\n\n"\
	"\033uOther Translators\n"\
	"   \033iFrench\n"\
	"Jerome Chesnot <jchesnot@noname.fr>\n", 7 },
    { (STRPTR) "Amster (Napster Client)\n"\
	"Copyright (c) 1999-2000 Gürer Özen\n"\
	"Copyright (c) 2000 Jacob Laursen\n"\
	"\n"\
	"This program is free software; you can redistribute it and/or modify "\
	"it under the terms of the GNU General Public License as published by "\
	"the Free Software Foundation; either version 2 of the License, or "\
	"(at your option) any later version.\n\n"\
	"This program is distributed in the hope that it will be useful, "\
	"but WITHOUT ANY WARRANTY; without even the implied warranty of "\
	"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "\
	"GNU General Public License for more details.\n\n"\
	"You should have received a copy of the GNU General Public License "\
	"along with this program; if not, write to the Free Software "\
	"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n\n"\
	"No reverse engineering on Napster client was done to make "\
	"this client, it's fully based on protocol documentation by "\
	"the Linux community.\n", 8 },
    { (STRPTR) "_OK", 9 },
    { (STRPTR) "Warning!", 10 },
    { (STRPTR) "Amster is still downloading some MP3's.\n"\
	"Do you want to stop transfers?", 11 },
    { (STRPTR) "_Yes|*_No", 12 },
    { (STRPTR) "Select ARexx script to run...", 13 },
    { (STRPTR) "Amster", 14 },
    { (STRPTR) "?\000About", 15 },
    { (STRPTR) "About MUI", 16 },
    { (STRPTR) "Help", 17 },
    { (STRPTR) "H\000Hide", 18 },
    { (STRPTR) "Q\000Quit", 19 },
    { (STRPTR) "Project", 20 },
    { (STRPTR) "O\000Open...", 21 },
    { (STRPTR) "S\000Save", 22 },
    { (STRPTR) "A\000Save as...", 23 },
    { (STRPTR) "Settings", 24 },
    { (STRPTR) "Icon Panel", 25 },
    { (STRPTR) "MUI...", 26 },
    { (STRPTR) "Configuration...", 27 },
    { (STRPTR) "Save settings", 28 },
    { (STRPTR) "Windows", 29 },
    { (STRPTR) "Debug", 30 },
    { (STRPTR) "Library", 31 },
    { (STRPTR) "Downloads", 32 },
    { (STRPTR) "Messages", 33 },
    { (STRPTR) "New chat window", 34 },
    { (STRPTR) "ARexx", 35 },
    { (STRPTR) "Execute script...", 36 },
    { (STRPTR) "_Connect", 37 },
    { (STRPTR) "_Disconnect", 38 },
    { (STRPTR) "_Reconnect", 39 },
    { (STRPTR) "Not connected to a server.", 40 },
    { (STRPTR) "Connecting...", 41 },
    { (STRPTR) "Connecting to %s...", 42 },
    { (STRPTR) "Connection to %s failed.", 43 },
    { (STRPTR) "Finding optimal server...", 44 },
    { (STRPTR) "Failed to find optimal server.", 45 },
    { (STRPTR) "%d songs in %d libraries (%d GB)", 46 },
    { (STRPTR) "Song", 47 },
    { (STRPTR) "Max.", 48 },
    { (STRPTR) "_Search", 49 },
    { (STRPTR) "\033c\033b-- Advanced Search Options --", 50 },
    { (STRPTR) "Use", 51 },
    { (STRPTR) "Reset", 52 },
    { (STRPTR) "Line speed must be", 53 },
    { (STRPTR) "Bitrate must be", 54 },
    { (STRPTR) "Frequency must be", 55 },
    { (STRPTR) "Unknown", 56 },
    { (STRPTR) "14.4 Modem", 57 },
    { (STRPTR) "28.8 Modem", 58 },
    { (STRPTR) "33.6 Modem", 59 },
    { (STRPTR) "56K Modem", 60 },
    { (STRPTR) "ISDN 64K", 61 },
    { (STRPTR) "ISDN 128K", 62 },
    { (STRPTR) "Cable", 63 },
    { (STRPTR) "DSL", 64 },
    { (STRPTR) "T1", 65 },
    { (STRPTR) "T3+", 66 },
    { (STRPTR) "User", 67 },
    { (STRPTR) "List all MP3 files shared by a single user", 68 },
    { (STRPTR) "Browse", 69 },
    { (STRPTR) "Result:", 70 },
    { (STRPTR) "Not important", 71 },
    { (STRPTR) "At least", 72 },
    { (STRPTR) "Equal to", 73 },
    { (STRPTR) "At best", 74 },
    { (STRPTR) "Cl_ear", 75 },
    { (STRPTR) "Clear a_ll", 76 },
    { (STRPTR) "Do_wnload", 77 },
    { (STRPTR) "Searching...", 78 },
    { (STRPTR) "No files found.", 79 },
    { (STRPTR) "1 file found.", 80 },
    { (STRPTR) "%d files found.", 81 },
    { (STRPTR) "Requesting list from user...", 82 },
    { (STRPTR) "\033cSong", 83 },
    { (STRPTR) "\033cSize", 84 },
    { (STRPTR) "\033cTime", 85 },
    { (STRPTR) "\033cUser", 86 },
    { (STRPTR) "\033cLink", 87 },
    { (STRPTR) "File", 88 },
    { (STRPTR) "Bitrate", 89 },
    { (STRPTR) "Frequency", 90 },
    { (STRPTR) "MD5", 91 },
    { (STRPTR) "\033cState", 92 },
    { (STRPTR) "\033cCps", 93 },
    { (STRPTR) "\033cTime", 94 },
    { (STRPTR) "Amster Configuration", 95 },
    { (STRPTR) "Error", 96 },
    { (STRPTR) "You must be connected to change your e-mail address.", 97 },
    { (STRPTR) "User", 98 },
    { (STRPTR) "Options", 99 },
    { (STRPTR) "Network", 100 },
    { (STRPTR) "Events", 101 },
    { (STRPTR) "Advanced", 102 },
    { (STRPTR) "Username", 103 },
    { (STRPTR) "Password", 104 },
    { (STRPTR) "E-Mail", 105 },
    { (STRPTR) "U_pdate", 106 },
    { (STRPTR) "Connection", 107 },
    { (STRPTR) "Download path", 108 },
    { (STRPTR) "Select your download directory...", 109 },
    { (STRPTR) "Clear list before new searches.", 110 },
    { (STRPTR) "Auto-connect on program startup.", 111 },
    { (STRPTR) "Show full paths in result list.", 112 },
    { (STRPTR) "Startup", 113 },
    { (STRPTR) "Exit", 114 },
    { (STRPTR) "Connect", 115 },
    { (STRPTR) "Disconnect", 116 },
    { (STRPTR) "Download Finish", 117 },
    { (STRPTR) "Download Error", 118 },
    { (STRPTR) "MP3 Player", 119 },
    { (STRPTR) "Script", 120 },
    { (STRPTR) "Select ARexx script...", 121 },
    { (STRPTR) "Sound", 122 },
    { (STRPTR) "Select sound file...", 123 },
    { (STRPTR) "Test", 124 },
    { (STRPTR) "Main server", 125 },
    { (STRPTR) "Amster gets MP3 server address from this server. You don't need to change it.", 126 },
    { (STRPTR) "MP3 server", 127 },
    { (STRPTR) "MP3 server address. If you want to get it from main server, leave this string empty.", 128 },
    { (STRPTR) "Version", 129 },
    { (STRPTR) "Listening port", 130 },
    { (STRPTR) "\033rBehind firewall", 131 },
    { (STRPTR) "_Save", 132 },
    { (STRPTR) "_Use", 133 },
    { (STRPTR) "_Cancel", 134 },
    { (STRPTR) "Cannot save configuration!", 135 },
    { (STRPTR) "Amster Debug", 136 },
    { (STRPTR) "_Clear", 137 },
    { (STRPTR) "Connected.", 138 },
    { (STRPTR) "Login failed!", 139 },
    { (STRPTR) "Logged in.", 140 },
    { (STRPTR) "Server returned e-mail address '%s'.", 141 },
    { (STRPTR) "Server is busy. Try again later.", 142 },
    { (STRPTR) "Got '%s' from Napster.", 143 },
    { (STRPTR) "Port number needed (hostname:port)!", 144 },
    { (STRPTR) "Nickname already registered.", 145 },
    { (STRPTR) "Amster Downloads", 146 },
    { (STRPTR) "Preparing", 147 },
    { (STRPTR) "Connecting", 148 },
    { (STRPTR) "Requesting", 149 },
    { (STRPTR) "Downloading", 150 },
    { (STRPTR) "\033bFinished", 151 },
    { (STRPTR) "\033bAborted", 152 },
    { (STRPTR) "\033bError", 153 },
    { (STRPTR) "Play", 154 },
    { (STRPTR) "_Abort", 155 },
    { (STRPTR) "_Resume", 156 },
    { (STRPTR) "Cleanup", 157 },
    { (STRPTR) "Select filename to download...", 158 },
    { (STRPTR) "Resume Information", 159 },
    { (STRPTR) "\033cThe file '%s'\n"\
	"already exists in your download directory.\n"\
	"\n"\
	"\033bLocal file size: \033n%ld\n"\
	"\033bRemote file size: \033n%ld\n"\
	"\n"\
	"\033bLocal MD5 checksum:\n"\
	"\033n%s\n"\
	"\n"\
	"\033bRemote MD5 checksum:\n"\
	"\033n%s\n"\
	"\n"\
	"%s", 160 },
    { (STRPTR) "«N/A»", 161 },
    { (STRPTR) "Remote file is smaller than local file.", 162 },
    { (STRPTR) "The files appear to be identical.\n"\
	"Resuming should be safe.", 163 },
    { (STRPTR) "The MD5 checksums of the files do not match.\n"\
	"Resuming would destroy your file.", 164 },
    { (STRPTR) "The file comment of the local file to resume\n"\
	"does not contain any MD5 checksum.\n"\
	"The files may not be identical.", 165 },
    { (STRPTR) "R_esume anyway|_Rename|_Overwrite|*_Cancel", 166 },
    { (STRPTR) "_Overwrite|_Rename|*_Cancel", 167 },
    { (STRPTR) "*_Resume|R_ename|_Overwrite|_Cancel", 168 },
    { (STRPTR) "Amster Messenger", 169 },
    { (STRPTR) "You're not connected!", 170 },
    { (STRPTR) "_Add", 171 },
    { (STRPTR) "_Remove", 172 },
    { (STRPTR) "Remove a_ll", 173 },
    { (STRPTR) "File sharing", 174 },
    { (STRPTR) "Select files to add", 175 },
    { (STRPTR) "Save sharelist", 176 },
    { (STRPTR) "Load sharelist", 177 },
    { (STRPTR) "Error adding '%s' (size: %ld, bitrate: %ld, frequency: %ld)\n", 178 },
    { (STRPTR) "%ld songs (%ld %s)", 179 },
    { (STRPTR) "kB", 180 },
    { (STRPTR) "MB", 181 },
    { (STRPTR) "GB", 182 },
    { (STRPTR) "Cannot open %s V%d!\n", 183 },
    { (STRPTR) "Cannot create mui app!\n", 184 },
    { (STRPTR) "TCP/IP stack needed!", 185 },
    { (STRPTR) "Network error.", 186 },
    { (STRPTR) "recv() error!", 187 },
    { (STRPTR) "Hostname lookup failed!", 188 },
    { (STRPTR) "Socket() error!", 189 },
    { (STRPTR) "Cannot connect!", 190 },
    { (STRPTR) "Stalled", 191 },
    { (STRPTR) "Hz", 192 },
    { (STRPTR) "kbps", 193 },
    { (STRPTR) "Add _dir", 194 },
    { (STRPTR) "Paths", 195 },
    { (STRPTR) "Select directory to add", 196 },
    { (STRPTR) "\033ckbps", 197 },
    { (STRPTR) "\033cHz", 198 },
    { (STRPTR) "%ld songs (%s %s)", 199 },
    { (STRPTR) "Requested file was not found in sharing database.\n", 200 },
    { (STRPTR) "User '%s' requested file '%s'.\n", 201 },
    { (STRPTR) "File '%s' already exists in library.\n", 202 },
    { (STRPTR) "_Play", 203 },
    { (STRPTR) "Add downloaded files to library.", 204 },
    { (STRPTR) "Auto-save library on program exit.", 205 },
    { (STRPTR) "Failed to open main window!\n", 206 },
    { (STRPTR) "Always ask filename.", 207 },
    { (STRPTR) "Account successfully registered.", 208 },
    { (STRPTR) "At least one file failed to be added to library.\n"\
	"Please consult the debug window for details.", 209 },
    { (STRPTR) "Unofficial Napster FAQ <http://napster.cjb.net>", 210 }
};

STATIC struct Catalog *AmsterCatalog = NULL;
#ifdef LOCALIZE_V20
STATIC STRPTR AmsterStrings = NULL;
STATIC ULONG AmsterStringsSize;
#endif


#if defined(_DCC)
STATIC __autoexit VOID _STDCloseAmsterCatalog(VOID)
#elif defined(__SASC)
VOID _STDCloseAmsterCatalog(VOID)
#elif defined(__GNUC__)
STATIC VOID _STDCloseAmsterCatalog(VOID)
#else
VOID CloseAmsterCatalog(VOID)
#endif

{
    if (AmsterCatalog) {
	CloseCatalog(AmsterCatalog);
    }
#ifdef LOCALIZE_V20
    if (AmsterStrings) {
	FreeMem(AmsterStrings, AmsterStringsSize);
    }
#endif
}


#if defined(_DCC)
STATIC __autoinit VOID _STIOpenAmsterCatalog(VOID)
#elif defined(__SASC)
VOID _STIOpenAmsterCatalog(VOID)
#elif defined(__GNUC__)
VOID _STIOpenAmsterCatalog(VOID)
#else
VOID OpenAmsterCatalog(VOID)
#endif

{
    if (LocaleBase) {
	if ((AmsterCatalog = OpenCatalog(NULL, (STRPTR) "Amster.catalog",
				     OC_BuiltInLanguage, "english",
				     OC_Version, 0,
				     TAG_DONE))) {
	    struct FC_String *fc;
	    int i;

	    for (i = 0, fc = Amster_Strings;  i < 211;  i++, fc++) {
		 fc->msg = GetCatalogStr(AmsterCatalog, fc->id, (STRPTR) fc->msg);
	    }
	}
    }
}

#if defined(__GNUC__)
__asm ("  .text;  .stabs \"___CTOR_LIST__\",22,0,0,__STIOpenAmsterCatalog");
__asm ("  .text;  .stabs \"___DTOR_LIST__\",22,0,0,__STDCloseAmsterCatalog");
#endif



#ifdef LOCALIZE_V20
VOID InitAmsterCatalog(STRPTR language)

{
    struct IFFHandle *iffHandle;

    /*
    **  Use iffparse.library only, if we need to.
    */
    if (LocaleBase  ||  !IFFParseBase  ||  !language  ||
	Stricmp(language, "english") == 0) {
	return;
    }

    if ((iffHandle = AllocIFF())) {
	char path[128]; /* Enough to hold 4 path items (dos.library 3.1)    */
	strcpy(path, "PROGDIR:Catalogs");
	AddPart((STRPTR) path, language, sizeof(path));
	AddPart((STRPTR) path, "Amster.catalog", sizeof(path));
	if (!(iffHandle->iff_Stream = Open((STRPTR) path, MODE_OLDFILE))) {
	    strcpy(path, "LOCALE:Catalogs");
	    AddPart((STRPTR) path, language, sizeof(path));
	    AddPart((STRPTR) path, language, sizeof(path));
	    iffHandle->iff_Stream = Open((STRPTR) path, MODE_OLDFILE);
	}

	if (iffHandle->iff_Stream) {
	    InitIFFasDOS(iffHandle);
	    if (!OpenIFF(iffHandle, IFFF_READ)) {
		if (!PropChunk(iffHandle, MAKE_ID('C','T','L','G'),
			       MAKE_ID('S','T','R','S'))) {
		    struct StoredProperty *sp;
		    int error;

		    for (;;) {
			if ((error = ParseIFF(iffHandle, IFFPARSE_STEP))
				   ==  IFFERR_EOC) {
			    continue;
			}
			if (error) {
			    break;
			}

			if ((sp = FindProp(iffHandle, MAKE_ID('C','T','L','G'),
					   MAKE_ID('S','T','R','S')))) {
			    /*
			    **  Check catalog and calculate the needed
			    **  number of bytes.
			    **  A catalog string consists of
			    **      ID (LONG)
			    **      Size (LONG)
			    **      Bytes (long word padded)
			    */
			    LONG bytesRemaining;
			    LONG *ptr;

			    AmsterStringsSize = 0;
			    bytesRemaining = sp->sp_Size;
			    ptr = (LONG *) sp->sp_Data;

			    while (bytesRemaining > 0) {
				LONG skipSize, stringSize;

				ptr++;                  /*  Skip ID     */
				stringSize = *ptr++;
				skipSize = ((stringSize+3) >> 2);

				AmsterStringsSize += stringSize+1;  /*  NUL */
				bytesRemaining -= 8 + (skipSize << 2);
				ptr += skipSize;
			    }

			    if (!bytesRemaining  &&
				(AmsterStrings = AllocMem(AmsterStringsSize, MEMF_ANY))) {
				STRPTR sptr;

				bytesRemaining = sp->sp_Size;
				ptr = (LONG *) sp->sp_Data;
				sptr = AmsterStrings;

				while (bytesRemaining) {
				    LONG skipSize, stringSize, id;
				    struct FC_String *fc;
				    int i;

				    id = *ptr++;
				    stringSize = *ptr++;
				    skipSize = ((stringSize+3) >> 2);

				    CopyMem(ptr, sptr, stringSize);
				    bytesRemaining -= 8 + (skipSize << 2);
				    ptr += skipSize;

				    for (i = 0, fc = Amster_Strings;  i < 211;  i++, fc++) {
					if (fc->id == id) {
					    fc->msg = sptr;
					}
				    }

				    sptr += stringSize;
				    *sptr++ = '\0';
				}
			    }
			    break;
			}
		    }
		}
		CloseIFF(iffHandle);
	    }
	    Close(iffHandle->iff_Stream);
	}
	FreeIFF(iffHandle);
    }
}
#endif
