/****************************************************************
   This file was created automatically by `FlexCat 2.4'
   from "stricq.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 "stricq_cat.h"


/*
    Variables
*/
struct FC_String stricq_Strings[307] = {
    { (STRPTR) "\033c\033bProgramming & Documentation\033p\n"\
	"\033cDouglas F. McLaughlin \033cv<stricq@owlnet.net>\n\n"\
	"\033c\033bLocale Support and GUI Changes\n"\
	"\033cNogfx \033cv<NicoEFE@ifrance.com>\n\n"\
	"\033c\033bCurrent Language\n"\
	"\033cBuilt-in English", 0 },
    { (STRPTR) "STRICQ - An Amiga, MUI Based ICQ Clone.\n"\
	"Copyright (C) 1998-2000 Douglas F. McLaughlin\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 usefull, "\
	"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"\
	"\nDouglas F. McLaughlin\n"\
	"; Menu 1: titre !", 1 },
    { (STRPTR) "\000Project", 2 },
    { (STRPTR) "S\000Search UIN", 3 },
    { (STRPTR) "R\000Reset Sockets", 4 },
    { (STRPTR) "A\000About...", 5 },
    { (STRPTR) "\000About MUI...", 6 },
    { (STRPTR) "Q\000Quit", 7 },
    { (STRPTR) "\000Settings", 8 },
    { (STRPTR) "I\000ICQ Prefs...", 9 },
    { (STRPTR) "\000Save Prefs", 10 },
    { (STRPTR) "M\000MUI...", 11 },
    { (STRPTR) "\000Messages", 12 },
    { (STRPTR) "\000Save...", 13 },
    { (STRPTR) "\000Windows", 14 },
    { (STRPTR) "1\000Activity Log", 15 },
    { (STRPTR) "2\000Active Sockets", 16 },
    { (STRPTR) "3\000Errors", 17 },
    { (STRPTR) "4\000Message History", 18 },
    { (STRPTR) "5\000STRICQ Log", 19 },
    { (STRPTR) "6\000Incoming Messages", 20 },
    { (STRPTR) "7\000Pager Messages", 21 },
    { (STRPTR) "8\000System Message", 22 },
    { (STRPTR) "9\000User Information", 23 },
    { (STRPTR) "Online", 24 },
    { (STRPTR) "Invisible", 25 },
    { (STRPTR) "Not Available", 26 },
    { (STRPTR) "Free For Chat", 27 },
    { (STRPTR) "Occupied", 28 },
    { (STRPTR) "Away", 29 },
    { (STRPTR) "Do Not Disturb", 30 },
    { (STRPTR) "OFFLINE", 31 },
    { (STRPTR) "Basic Info", 32 },
    { (STRPTR) "Extended Info", 33 },
    { (STRPTR) "Options", 34 },
    { (STRPTR) "List", 35 },
    { (STRPTR) "Auto Reply", 36 },
    { (STRPTR) "Set Away", 37 },
    { (STRPTR) "Status Color", 38 },
    { (STRPTR) "Chat Mode Color", 39 },
    { (STRPTR) "Main", 40 },
    { (STRPTR) "Home", 41 },
    { (STRPTR) "Work", 42 },
    { (STRPTR) "More", 43 },
    { (STRPTR) "Info/About", 44 },
    { (STRPTR) "Affiliations", 45 },
    { (STRPTR) "Interests", 46 },
    { (STRPTR) "Picture", 47 },
    { (STRPTR) "Security", 48 },
    { (STRPTR) "Ignore", 49 },
    { (STRPTR) "Servers", 50 },
    { (STRPTR) "Notify", 51 },
    { (STRPTR) "Color", 52 },
    { (STRPTR) "Away", 53 },
    { (STRPTR) "Options", 54 },
    { (STRPTR) "Unspecified", 55 },
    { (STRPTR) "Female", 56 },
    { (STRPTR) "Male", 57 },
    { (STRPTR) "N/A", 58 },
    { (STRPTR) "January", 59 },
    { (STRPTR) "February", 60 },
    { (STRPTR) "March", 61 },
    { (STRPTR) "April", 62 },
    { (STRPTR) "May", 63 },
    { (STRPTR) "June", 64 },
    { (STRPTR) "July", 65 },
    { (STRPTR) "August", 66 },
    { (STRPTR) "September", 67 },
    { (STRPTR) "October", 68 },
    { (STRPTR) "November", 69 },
    { (STRPTR) "December", 70 },
    { (STRPTR) "Auto send to users on my list", 71 },
    { (STRPTR) "Auto send to all users", 72 },
    { (STRPTR) "Show request", 73 },
    { (STRPTR) "All users may add me to their contact list", 74 },
    { (STRPTR) "My authoriation is required", 75 },
    { (STRPTR) "Double-Click here to open\nthe User Window.", 76 },
    { (STRPTR) "Add", 77 },
    { (STRPTR) "Remove", 78 },
    { (STRPTR) "About STRICQ", 79 },
    { (STRPTR) "Load Progress", 80 },
    { (STRPTR) "Initializing", 81 },
    { (STRPTR) "STRICQ Log", 82 },
    { (STRPTR) "From Client To Server:", 83 },
    { (STRPTR) "From Server To Client:", 84 },
    { (STRPTR) "Incoming Messages", 85 },
    { (STRPTR) "Reply", 86 },
    { (STRPTR) "Get Info", 87 },
    { (STRPTR) "Remove Message", 88 },
    { (STRPTR) "Clear Messages", 89 },
    { (STRPTR) "Authorize", 90 },
    { (STRPTR) "Send URL", 91 },
    { (STRPTR) "Message", 92 },
    { (STRPTR) "Send to", 93 },
    { (STRPTR) "Send Message", 94 },
    { (STRPTR) "Send This Message", 95 },
    { (STRPTR) "User Information", 96 },
    { (STRPTR) "Nick", 97 },
    { (STRPTR) "First", 98 },
    { (STRPTR) "Last", 99 },
    { (STRPTR) "E-Mail", 100 },
    { (STRPTR) "Auth. Required", 101 },
    { (STRPTR) "City", 102 },
    { (STRPTR) "Country Code", 103 },
    { (STRPTR) "Time Zone", 104 },
    { (STRPTR) "State", 105 },
    { (STRPTR) "Age", 106 },
    { (STRPTR) "Sex", 107 },
    { (STRPTR) "Phone", 108 },
    { (STRPTR) "Home Page", 109 },
    { (STRPTR) "About", 110 },
    { (STRPTR) "Add To Contact List", 111 },
    { (STRPTR) "Search For User", 112 },
    { (STRPTR) "Search UIN", 113 },
    { (STRPTR) "Search E-Mail", 114 },
    { (STRPTR) "Search Name", 115 },
    { (STRPTR) "Search Results", 116 },
    { (STRPTR) "Search Hits:", 117 },
    { (STRPTR) "Add / Update Contact List", 118 },
    { (STRPTR) "Get Userinfo", 119 },
    { (STRPTR) "Send a URL", 120 },
    { (STRPTR) "Description", 121 },
    { (STRPTR) "URL", 122 },
    { (STRPTR) "System Message", 123 },
    { (STRPTR) "OK", 124 },
    { (STRPTR) "Message History", 125 },
    { (STRPTR) "Activity Log", 126 },
    { (STRPTR) "Active Sockets", 127 },
    { (STRPTR) "Chat Request", 128 },
    { (STRPTR) "Chat", 129 },
    { (STRPTR) "Join", 130 },
    { (STRPTR) "Cancel", 131 },
    { (STRPTR) "FileDirect Request", 132 },
    { (STRPTR) "File List", 133 },
    { (STRPTR) "Add File(s)", 134 },
    { (STRPTR) "Remove File", 135 },
    { (STRPTR) "Enter File Description", 136 },
    { (STRPTR) "Send", 137 },
    { (STRPTR) "Add UIN Request", 138 },
    { (STRPTR) "Get Userinfo", 139 },
    { (STRPTR) "Close", 140 },
    { (STRPTR) "Pager Messages", 141 },
    { (STRPTR) "Name", 142 },
    { (STRPTR) "Errors, Information & Debug", 143 },
    { (STRPTR) "Debug Levels", 144 },
    { (STRPTR) "Show UDP Packets", 145 },
    { (STRPTR) "Show UDP Debug", 146 },
    { (STRPTR) "Show TCP Packets", 147 },
    { (STRPTR) "Show TCP Debug", 148 },
    { (STRPTR) "Clear Errors", 149 },
    { (STRPTR) "Save To File", 150 },
    { (STRPTR) "Ignored UIN", 151 },
    { (STRPTR) "-1 = Never Expire", 152 },
    { (STRPTR) "ICQ Number", 153 },
    { (STRPTR) "ICQ#", 154 },
    { (STRPTR) "Current / Last IP", 155 },
    { (STRPTR) "Nickname", 156 },
    { (STRPTR) "EMail Addresses", 157 },
    { (STRPTR) "Primary EMail", 158 },
    { (STRPTR) "Don't Publish my Primary EMail address", 159 },
    { (STRPTR) "Secondary Email", 160 },
    { (STRPTR) "Old Mail", 161 },
    { (STRPTR) "Home Address", 162 },
    { (STRPTR) "Street", 163 },
    { (STRPTR) "Address", 164 },
    { (STRPTR) "Zip Code", 165 },
    { (STRPTR) "Display Map", 166 },
    { (STRPTR) "Country", 167 },
    { (STRPTR) "Phone Directory Listings", 168 },
    { (STRPTR) "FAX", 169 },
    { (STRPTR) "Cellular", 170 },
    { (STRPTR) "Local Time", 171 },
    { (STRPTR) "Time Zone", 172 },
    { (STRPTR) "Company", 173 },
    { (STRPTR) "Position", 174 },
    { (STRPTR) "Occupation", 175 },
    { (STRPTR) "Work Address", 176 },
    { (STRPTR) "Additionnal Details", 177 },
    { (STRPTR) "Gender", 178 },
    { (STRPTR) "Home Page Category", 179 },
    { (STRPTR) "Birth Date & Horoscope", 180 },
    { (STRPTR) "Month", 181 },
    { (STRPTR) "Day", 182 },
    { (STRPTR) "Year", 183 },
    { (STRPTR) "Zodiac", 184 },
    { (STRPTR) "Notify everyone on my birthday", 185 },
    { (STRPTR) "View Horoscope", 186 },
    { (STRPTR) "Spoken Languages", 187 },
    { (STRPTR) "Write a bit about your personality, favorites, \nfamily, friends... so that other ICQ members\nwith similar interests can locate you", 188 },
    { (STRPTR) "Select up to three categories and enter\nkeywords to describe specific interests", 189 },
    { (STRPTR) "Organization, Affiliation, Group", 190 },
    { (STRPTR) "Enter Name(s) or Keywords", 191 },
    { (STRPTR) "Past Background", 192 },
    { (STRPTR) "Click the Edit button to select a category of\n interest and available interest topics", 193 },
    { (STRPTR) "Personnal Interests", 194 },
    { (STRPTR) "Select Categories", 195 },
    { (STRPTR) "Edit", 196 },
    { (STRPTR) "Select Picture File", 197 },
    { (STRPTR) "Last Update Date", 198 },
    { (STRPTR) "None available", 199 },
    { (STRPTR) "Picture File", 200 },
    { (STRPTR) "Clear", 201 },
    { (STRPTR) "File Size", 202 },
    { (STRPTR) "Picture Privacy Settings (//)", 203 },
    { (STRPTR) "Do not have a picture (Auto Decline)", 204 },
    { (STRPTR) "Thumbnail Preview", 205 },
    { (STRPTR) "Preview not yet available", 206 },
    { (STRPTR) "Change Contact List Authorization", 207 },
    { (STRPTR) "IP Publishing", 208 },
    { (STRPTR) "Do not publish my IP address", 209 },
    { (STRPTR) "WebAware", 210 },
    { (STRPTR) "Allow others to view my online\npresence on the World Wide Web", 211 },
    { (STRPTR) "Change Password", 212 },
    { (STRPTR) "Password", 213 },
    { (STRPTR) "Verify Password", 214 },
    { (STRPTR) "Save Password", 215 },
    { (STRPTR) "Delete", 216 },
    { (STRPTR) "Port", 217 },
    { (STRPTR) "Server", 218 },
    { (STRPTR) "On Startup", 219 },
    { (STRPTR) "On Shutdown", 220 },
    { (STRPTR) "Message Notify", 221 },
    { (STRPTR) "Message PreParse", 222 },
    { (STRPTR) "Message PostParse", 223 },
    { (STRPTR) "Online Notify", 224 },
    { (STRPTR) "Offline Notify", 225 },
    { (STRPTR) "Chat Notify", 226 },
    { (STRPTR) "Chat Beep", 227 },
    { (STRPTR) "FileDirect", 228 },
    { (STRPTR) "Download Dir", 229 },
    { (STRPTR) "Online", 230 },
    { (STRPTR) "Online Color", 231 },
    { (STRPTR) "Offline", 232 },
    { (STRPTR) "Offline Color", 233 },
    { (STRPTR) "Invisible", 234 },
    { (STRPTR) "Invisible Color", 235 },
    { (STRPTR) "Not Available", 236 },
    { (STRPTR) "Not Available Color", 237 },
    { (STRPTR) "Free For Chat", 238 },
    { (STRPTR) "Free For Chat Color", 239 },
    { (STRPTR) "Occupied", 240 },
    { (STRPTR) "Occupied Color", 241 },
    { (STRPTR) "Away", 242 },
    { (STRPTR) "Away Color", 243 },
    { (STRPTR) "Do Not Disturb", 244 },
    { (STRPTR) "Do Not Disturb Color", 245 },
    { (STRPTR) "New User", 246 },
    { (STRPTR) "New User Color", 247 },
    { (STRPTR) "Do Not Disturb", 248 },
    { (STRPTR) "Set Your status to change after specified\nnumber of seconds. Use 0 to disable.\nTimes are acumulative. Resolution of 5 seconds.", 249 },
    { (STRPTR) "Change status to:", 250 },
    { (STRPTR) "After this many seconds:", 251 },
    { (STRPTR) "Global Options", 252 },
    { (STRPTR) "Open Log Window", 253 },
    { (STRPTR) "Auto Reconnect", 254 },
    { (STRPTR) "Open Message Win", 255 },
    { (STRPTR) "Show Message Time", 256 },
    { (STRPTR) "Activity Name Sort", 257 },
    { (STRPTR) "Multi-line Message Input", 258 },
    { (STRPTR) "Use Internet Time", 259 },
    { (STRPTR) "Selections", 260 },
    { (STRPTR) "Notify Lamp", 261 },
    { (STRPTR) "UDP Protocol", 262 },
    { (STRPTR) "Messages Options", 263 },
    { (STRPTR) "Window Pop-Up", 264 },
    { (STRPTR) "Screen To Front", 265 },
    { (STRPTR) "No Message Log", 266 },
    { (STRPTR) "Storage", 267 },
    { (STRPTR) "Active", 268 },
    { (STRPTR) "Retrieve From Server", 269 },
    { (STRPTR) "Save To Server", 270 },
    { (STRPTR) "Could not create Keep-Alive Timer object.", 271 },
    { (STRPTR) "Could not create Command-Resend Timer object.", 272 },
    { (STRPTR) "Could not create Command-Parser Timer object.", 273 },
    { (STRPTR) "An Amiga ICQ Client", 274 },
    { (STRPTR) "Start Search", 275 },
    { (STRPTR) "Send This URL", 276 },
    { (STRPTR) "ICQ preferences", 277 },
    { (STRPTR) "Div/Dept", 278 },
    { (STRPTR) "Dialogue", 279 },
    { (STRPTR) "Send", 280 },
    { (STRPTR) "User Info", 281 },
    { (STRPTR) "History", 282 },
    { (STRPTR) "Basic Info", 283 },
    { (STRPTR) "Extended Info", 284 },
    { (STRPTR) "Prefs", 285 },
    { (STRPTR) "Main", 286 },
    { (STRPTR) "Home", 287 },
    { (STRPTR) "More", 288 },
    { (STRPTR) "Info/About", 289 },
    { (STRPTR) "Prefs", 290 },
    { (STRPTR) "Black", 291 },
    { (STRPTR) "Maroon", 292 },
    { (STRPTR) "Green", 293 },
    { (STRPTR) "Olive", 294 },
    { (STRPTR) "Navy", 295 },
    { (STRPTR) "Purple", 296 },
    { (STRPTR) "Teal", 297 },
    { (STRPTR) "Gray", 298 },
    { (STRPTR) "Silver", 299 },
    { (STRPTR) "Red", 300 },
    { (STRPTR) "Lime", 301 },
    { (STRPTR) "Yellow", 302 },
    { (STRPTR) "Blue", 303 },
    { (STRPTR) "Fuchsia", 304 },
    { (STRPTR) "Aqua", 305 },
    { (STRPTR) "White", 306 }
};

STATIC struct Catalog *stricqCatalog = NULL;
#ifdef LOCALIZE_V20
STATIC STRPTR stricqStrings = NULL;
STATIC ULONG stricqStringsSize;
#endif


#if defined(_DCC)
STATIC __autoexit VOID _STDClosestricqCatalog(VOID)
#elif defined(__SASC)
VOID _STDClosestricqCatalog(VOID)
#elif defined(__GNUC__)
STATIC VOID _STDClosestricqCatalog(VOID)
#else
VOID ClosestricqCatalog(VOID)
#endif

{
    if (stricqCatalog) {
	CloseCatalog(stricqCatalog);
    }
#ifdef LOCALIZE_V20
    if (stricqStrings) {
	FreeMem(stricqStrings, stricqStringsSize);
    }
#endif
}


#if defined(_DCC)
STATIC __autoinit VOID _STIOpenstricqCatalog(VOID)
#elif defined(__SASC)
VOID _STIOpenstricqCatalog(VOID)
#elif defined(__GNUC__)
VOID _STIOpenstricqCatalog(VOID)
#else
VOID OpenstricqCatalog(VOID)
#endif

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

	    for (i = 0, fc = stricq_Strings;  i < 307;  i++, fc++) {
		 fc->msg = GetCatalogStr(stricqCatalog, fc->id, (STRPTR) fc->msg);
	    }
	}
    }
}

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



#ifdef LOCALIZE_V20
VOID InitstricqCatalog(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, "stricq.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;

			    stricqStringsSize = 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);

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

			    if (!bytesRemaining  &&
				(stricqStrings = AllocMem(stricqStringsSize, MEMF_ANY))) {
				STRPTR sptr;

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

				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 = stricq_Strings;  i < 307;  i++, fc++) {
					if (fc->id == id) {
					    fc->msg = sptr;
					}
				    }

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