/*
 * Um dieses Programm mit Ihrem C-Compiler
 * übersetzen zu können, benötigen Sie die
 * entpsprechenden Include-Dateien und eine neue
 * »amiga.lib«. Diese erhalten Sie bei dem für
 * Ihren Compiler zuständigen Händler.
 */

#include <exec/types.h>
#include <exec/libraries.h>
#include <libraries/locale.h>
#include <utility/tagitem.h>

#include <clib/exec_protos.h>
#include <clib/dos_protos.h>

#include <pragmas/exec_pragmas.h>
#include <pragmas/dos_pragmas.h>

extern struct Library   *DOSBase;
extern struct Library   *SysBase;

struct Library *LocaleBase=NULL;
struct Catalog *mycatalog;

char *CatalogName="sys/workbench.catalog";

/*
 * protos
 */
struct Locale *OpenLocale(STRPTR);
struct Catalog *OpenCatalogA(struct Locale *, STRPTR, APTR);
STRPTR GetLocaleStr( struct Locale *, ULONG );
STRPTR GetCatalogStr(struct Catalog *, LONG, STRPTR );
BOOL   CloseLocale( struct Locale * );
BOOL   CloseCatalog( struct Catalog *);

VOID main(ULONG argc, char **argv)
{
  ULONG stringid;

  if( argc ) {
    /*
     * Nur vom CLI zu starten
     */
    LocaleBase=OpenLibrary("locale.library",38);

    if( LocaleBase ) {
      mycatalog=OpenCatalogA(NULL,CatalogName,NULL);

      if( mycatalog ) {
        for( stringid=1; stringid <= 179; stringid++ )
           printf("String[%d]=\"%s\"\n",stringid,GetCatalogStr(mycatalog,stringid,NULL) );
        CloseCatalog( mycatalog );
      } else printf("Fehler beim Öffnen des Catalogs\n");

      CloseLibrary(LocaleBase);
    } else printf("Locale.library konnte nicht geöffnet\n");
  }
}
