home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / on-line / amster / src / amster_cat.c next >
C/C++ Source or Header  |  2000-01-21  |  11KB  |  354 lines

  1. /****************************************************************
  2.    This file was created automatically by `FlexCat 2.3'
  3.    from "amster.cd".
  4.  
  5.    Do NOT edit by hand!
  6. ****************************************************************/
  7.  
  8. /****************************************************************
  9.     This file uses the auto initialization possibilities of
  10.     Dice, gcc and SAS/C, respectively.
  11.  
  12.     Dice does this by using the keywords __autoinit and
  13.     __autoexit, SAS uses names beginning with _STI or
  14.     _STD, respectively. gcc uses the asm() instruction,
  15.     to emulate C++ constructors and destructors.
  16.  
  17.     Using this file you don't have *all* possibilities of
  18.     the locale.library. (No Locale or Language arguments are
  19.     supported when opening the catalog. However, these are
  20.     *very* rarely used, so this should be sufficient for most
  21.     applications.
  22. ****************************************************************/
  23.  
  24.  
  25. /*
  26.     Include files and compiler specific stuff
  27. */
  28. #include <exec/memory.h>
  29. #include <libraries/locale.h>
  30. #include <libraries/iffparse.h>
  31.  
  32. #include <proto/exec.h>
  33. #include <proto/dos.h>
  34. #include <proto/locale.h>
  35. #include <proto/utility.h>
  36. #include <proto/iffparse.h>
  37.  
  38. #include <stdlib.h>
  39. #include <string.h>
  40.  
  41.  
  42.  
  43. #include "amster_Cat.h"
  44.  
  45.  
  46. /*
  47.     Variables
  48. */
  49. struct FC_String amster_Strings[116] = {
  50.     { (STRPTR) "Cannot open %s V%d!\n", 0 },
  51.     { (STRPTR) "Cannot create mui app!\n", 1 },
  52.     { (STRPTR) "TCP/IP stack needed!", 2 },
  53.     { (STRPTR) "Napster client", 3 },
  54.     { (STRPTR) "Amster", 4 },
  55.     { (STRPTR) "?\000About...", 5 },
  56.     { (STRPTR) "About MUI...", 6 },
  57.     { (STRPTR) "H\000Hide", 7 },
  58.     { (STRPTR) "Q\000Quit", 8 },
  59.     { (STRPTR) "Settings", 9 },
  60.     { (STRPTR) "Configuration...", 10 },
  61.     { (STRPTR) "MUI...", 11 },
  62.     { (STRPTR) "About Amster", 12 },
  63.     { (STRPTR) "\033c\033bAmster %s (%s)\033n\n\n"\
  64.     "\033cCopyright © 1999-2000 by Gürer Özen.\n"\
  65.     "\033cReleased under GNU Public License.\n"\
  66.     "\n"\
  67.     "Programming by Gürer Özen & Jacob Laursen.\n"\
  68.     "Documentation by Jacob Laursen.\n", 13 },
  69.     { (STRPTR) "_OK", 14 },
  70.     { (STRPTR) "_Connect", 15 },
  71.     { (STRPTR) "_Disconnect", 16 },
  72.     { (STRPTR) "_Reconnect", 17 },
  73.     { (STRPTR) "_Settings...", 18 },
  74.     { (STRPTR) "Song", 19 },
  75.     { (STRPTR) "Max.", 20 },
  76.     { (STRPTR) "Search", 21 },
  77.     { (STRPTR) "\033c\033b-- Advanced Search Options --", 22 },
  78.     { (STRPTR) "Use", 23 },
  79.     { (STRPTR) "Reset", 24 },
  80.     { (STRPTR) "Line speed must be", 25 },
  81.     { (STRPTR) "Bitrate must be", 26 },
  82.     { (STRPTR) "Frequency must be", 27 },
  83.     { (STRPTR) "Unknown", 28 },
  84.     { (STRPTR) "14.4 Modem", 29 },
  85.     { (STRPTR) "28.8 Modem", 30 },
  86.     { (STRPTR) "33.6 Modem", 31 },
  87.     { (STRPTR) "56K Modem", 32 },
  88.     { (STRPTR) "ISDN 64K", 33 },
  89.     { (STRPTR) "ISDN 128K", 34 },
  90.     { (STRPTR) "Cable", 35 },
  91.     { (STRPTR) "DSL", 36 },
  92.     { (STRPTR) "T1", 37 },
  93.     { (STRPTR) "T3+", 38 },
  94.     { (STRPTR) "User", 39 },
  95.     { (STRPTR) "List all MP3 files shared by a single user", 40 },
  96.     { (STRPTR) "Browse", 41 },
  97.     { (STRPTR) "Result:", 42 },
  98.     { (STRPTR) "Not important", 43 },
  99.     { (STRPTR) "At least", 44 },
  100.     { (STRPTR) "Equal to", 45 },
  101.     { (STRPTR) "At best", 46 },
  102.     { (STRPTR) "\033cSong", 47 },
  103.     { (STRPTR) "\033cSize", 48 },
  104.     { (STRPTR) "\033cUser", 49 },
  105.     { (STRPTR) "\033cLink", 50 },
  106.     { (STRPTR) "Cl_ear", 51 },
  107.     { (STRPTR) "Clear _all", 52 },
  108.     { (STRPTR) "Do_wnload", 53 },
  109.     { (STRPTR) "Searching...", 54 },
  110.     { (STRPTR) "No files found.", 55 },
  111.     { (STRPTR) "%d files found.", 56 },
  112.     { (STRPTR) "Requesting list from user...", 57 },
  113.     { (STRPTR) "Not connected to a server.", 58 },
  114.     { (STRPTR) "Connecting...", 59 },
  115.     { (STRPTR) "Connecting to %s...", 60 },
  116.     { (STRPTR) "Connection to %s failed.", 61 },
  117.     { (STRPTR) "Finding optimal server...", 62 },
  118.     { (STRPTR) "Failed to find optimal server.", 63 },
  119.     { (STRPTR) "%d songs in %d libraries (%d GB)", 64 },
  120.     { (STRPTR) "Amster settings...", 65 },
  121.     { (STRPTR) "Error", 66 },
  122.     { (STRPTR) "You must be connected to change your e-mail address.", 67 },
  123.     { (STRPTR) "User", 68 },
  124.     { (STRPTR) "Options", 69 },
  125.     { (STRPTR) "Advanced", 70 },
  126.     { (STRPTR) "Username", 71 },
  127.     { (STRPTR) "Password", 72 },
  128.     { (STRPTR) "E-Mail", 73 },
  129.     { (STRPTR) "U_pdate", 74 },
  130.     { (STRPTR) "Connection", 75 },
  131.     { (STRPTR) "Download path", 76 },
  132.     { (STRPTR) "Select your download directory...", 77 },
  133.     { (STRPTR) "Clear list before new searches", 78 },
  134.     { (STRPTR) "Auto-connect on program startup", 79 },
  135.     { (STRPTR) "Show full paths in result list", 80 },
  136.     { (STRPTR) "Main server", 81 },
  137.     { (STRPTR) "Amster gets MP3 server address from this server. You don't need to change it.", 82 },
  138.     { (STRPTR) "MP3 server", 83 },
  139.     { (STRPTR) "MP3 server address. If you want to get it from main server, leave this string empty.", 84 },
  140.     { (STRPTR) "Version", 85 },
  141.     { (STRPTR) "_Save", 86 },
  142.     { (STRPTR) "_Use", 87 },
  143.     { (STRPTR) "_Cancel", 88 },
  144.     { (STRPTR) "Cannot save configuration!", 89 },
  145.     { (STRPTR) "Amster information/debug...", 90 },
  146.     { (STRPTR) "_Clear", 91 },
  147.     { (STRPTR) "Connected.", 92 },
  148.     { (STRPTR) "Login failed!", 93 },
  149.     { (STRPTR) "Logged in.", 94 },
  150.     { (STRPTR) "Server returned e-mail address '%s'.", 95 },
  151.     { (STRPTR) "Server is busy. Try again later.", 96 },
  152.     { (STRPTR) "Got '%s' from Napster.", 97 },
  153.     { (STRPTR) "Port number needed (hostname:port)!", 98 },
  154.     { (STRPTR) "Amster download...", 99 },
  155.     { (STRPTR) "User aborted connection!", 100 },
  156.     { (STRPTR) "Looking for host...", 101 },
  157.     { (STRPTR) "_Abort", 102 },
  158.     { (STRPTR) "\033uTitle\033n:\n"\
  159.     "%s\n"\
  160.     "\033uUser\033n: %s, \033uLink\033n: %s\n"\
  161.     "\033uSize\033n: %ld bytes.\n"\
  162.     "\033uBitrate\033n: %d kbps, \033uFrequency\033n: %d kHz\n", 103 },
  163.     { (STRPTR) "Connecting...", 104 },
  164.     { (STRPTR) "Connection lost.", 105 },
  165.     { (STRPTR) "Requesting file...", 106 },
  166.     { (STRPTR) "Downloading mp3...", 107 },
  167.     { (STRPTR) "Cannot open file!", 108 },
  168.     { (STRPTR) "Download finished", 109 },
  169.     { (STRPTR) "Amster messenger...", 110 },
  170.     { (STRPTR) "Network error.", 111 },
  171.     { (STRPTR) "recv() error!", 112 },
  172.     { (STRPTR) "Hostname lookup failed!", 113 },
  173.     { (STRPTR) "Socket() error!", 114 },
  174.     { (STRPTR) "Cannot connect!", 115 }
  175. };
  176.  
  177. STATIC struct Catalog *amsterCatalog = NULL;
  178. #ifdef LOCALIZE_V20
  179. STATIC STRPTR amsterStrings = NULL;
  180. STATIC ULONG amsterStringsSize;
  181. #endif
  182.  
  183.  
  184. #if defined(_DCC)
  185. STATIC __autoexit VOID _STDCloseamsterCatalog(VOID)
  186. #elif defined(__SASC)
  187. VOID _STDCloseamsterCatalog(VOID)
  188. #elif defined(__GNUC__)
  189. STATIC VOID _STDCloseamsterCatalog(VOID)
  190. #else
  191. VOID CloseamsterCatalog(VOID)
  192. #endif
  193.  
  194. {
  195.     if (amsterCatalog) {
  196.     CloseCatalog(amsterCatalog);
  197.     }
  198. #ifdef LOCALIZE_V20
  199.     if (amsterStrings) {
  200.     FreeMem(amsterStrings, amsterStringsSize);
  201.     }
  202. #endif
  203. }
  204.  
  205.  
  206. #if defined(_DCC)
  207. STATIC __autoinit VOID _STIOpenamsterCatalog(VOID)
  208. #elif defined(__SASC)
  209. VOID _STIOpenamsterCatalog(VOID)
  210. #elif defined(__GNUC__)
  211. VOID _STIOpenamsterCatalog(VOID)
  212. #else
  213. VOID OpenamsterCatalog(VOID)
  214. #endif
  215.  
  216. {
  217.     if (LocaleBase) {
  218.     if ((amsterCatalog = OpenCatalog(NULL, (STRPTR) "amster.catalog",
  219.                      OC_BuiltInLanguage, "english",
  220.                      OC_Version, 0,
  221.                      TAG_DONE))) {
  222.         struct FC_String *fc;
  223.         int i;
  224.  
  225.         for (i = 0, fc = amster_Strings;  i < 116;  i++, fc++) {
  226.          fc->msg = GetCatalogStr(amsterCatalog, fc->id, (STRPTR) fc->msg);
  227.         }
  228.     }
  229.     }
  230. }
  231.  
  232. #if defined(__GNUC__)
  233. __asm ("  .text;  .stabs \"___CTOR_LIST__\",22,0,0,__STIOpenamsterCatalog");
  234. __asm ("  .text;  .stabs \"___DTOR_LIST__\",22,0,0,__STDCloseamsterCatalog");
  235. #endif
  236.  
  237.  
  238.  
  239. #ifdef LOCALIZE_V20
  240. VOID InitamsterCatalog(STRPTR language)
  241.  
  242. {
  243.     struct IFFHandle *iffHandle;
  244.  
  245.     /*
  246.     **  Use iffparse.library only, if we need to.
  247.     */
  248.     if (LocaleBase  ||  !IFFParseBase  ||  !language  ||
  249.     Stricmp(language, "english") == 0) {
  250.     return;
  251.     }
  252.  
  253.     if ((iffHandle = AllocIFF())) {
  254.     char path[128]; /* Enough to hold 4 path items (dos.library 3.1)    */
  255.     strcpy(path, "PROGDIR:Catalogs");
  256.     AddPart((STRPTR) path, language, sizeof(path));
  257.     AddPart((STRPTR) path, "amster.catalog", sizeof(path));
  258.     if (!(iffHandle->iff_Stream = Open((STRPTR) path, MODE_OLDFILE))) {
  259.         strcpy(path, "LOCALE:Catalogs");
  260.         AddPart((STRPTR) path, language, sizeof(path));
  261.         AddPart((STRPTR) path, language, sizeof(path));
  262.         iffHandle->iff_Stream = Open((STRPTR) path, MODE_OLDFILE);
  263.     }
  264.  
  265.     if (iffHandle->iff_Stream) {
  266.         InitIFFasDOS(iffHandle);
  267.         if (!OpenIFF(iffHandle, IFFF_READ)) {
  268.         if (!PropChunk(iffHandle, MAKE_ID('C','T','L','G'),
  269.                    MAKE_ID('S','T','R','S'))) {
  270.             struct StoredProperty *sp;
  271.             int error;
  272.  
  273.             for (;;) {
  274.             if ((error = ParseIFF(iffHandle, IFFPARSE_STEP))
  275.                    ==  IFFERR_EOC) {
  276.                 continue;
  277.             }
  278.             if (error) {
  279.                 break;
  280.             }
  281.  
  282.             if ((sp = FindProp(iffHandle, MAKE_ID('C','T','L','G'),
  283.                        MAKE_ID('S','T','R','S')))) {
  284.                 /*
  285.                 **  Check catalog and calculate the needed
  286.                 **  number of bytes.
  287.                 **  A catalog string consists of
  288.                 **      ID (LONG)
  289.                 **      Size (LONG)
  290.                 **      Bytes (long word padded)
  291.                 */
  292.                 LONG bytesRemaining;
  293.                 LONG *ptr;
  294.  
  295.                 amsterStringsSize = 0;
  296.                 bytesRemaining = sp->sp_Size;
  297.                 ptr = (LONG *) sp->sp_Data;
  298.  
  299.                 while (bytesRemaining > 0) {
  300.                 LONG skipSize, stringSize;
  301.  
  302.                 ptr++;                  /*  Skip ID     */
  303.                 stringSize = *ptr++;
  304.                 skipSize = ((stringSize+3) >> 2);
  305.  
  306.                 amsterStringsSize += stringSize+1;  /*  NUL */
  307.                 bytesRemaining -= 8 + (skipSize << 2);
  308.                 ptr += skipSize;
  309.                 }
  310.  
  311.                 if (!bytesRemaining  &&
  312.                 (amsterStrings = AllocMem(amsterStringsSize, MEMF_ANY))) {
  313.                 STRPTR sptr;
  314.  
  315.                 bytesRemaining = sp->sp_Size;
  316.                 ptr = (LONG *) sp->sp_Data;
  317.                 sptr = amsterStrings;
  318.  
  319.                 while (bytesRemaining) {
  320.                     LONG skipSize, stringSize, id;
  321.                     struct FC_String *fc;
  322.                     int i;
  323.  
  324.                     id = *ptr++;
  325.                     stringSize = *ptr++;
  326.                     skipSize = ((stringSize+3) >> 2);
  327.  
  328.                     CopyMem(ptr, sptr, stringSize);
  329.                     bytesRemaining -= 8 + (skipSize << 2);
  330.                     ptr += skipSize;
  331.  
  332.                     for (i = 0, fc = amster_Strings;  i < 116;  i++, fc++) {
  333.                     if (fc->id == id) {
  334.                         fc->msg = sptr;
  335.                     }
  336.                     }
  337.  
  338.                     sptr += stringSize;
  339.                     *sptr++ = '\0';
  340.                 }
  341.                 }
  342.                 break;
  343.             }
  344.             }
  345.         }
  346.         CloseIFF(iffHandle);
  347.         }
  348.         Close(iffHandle->iff_Stream);
  349.     }
  350.     FreeIFF(iffHandle);
  351.     }
  352. }
  353. #endif
  354.