/* Dieses Programm liest die Systemkataloge aus
 * Aufruf: programmname <sprache> katalog [katalog]
 * Verwendeter C-Compiler: SAS-C 6.5x
 */
#include <exec/types.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/locale.h>
#include <proto/utility.h>

#include <stdio.h>
#include <string.h>

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

#define VERZEICHNIS "sys/"
char CatalogName[100];
VOID main(ULONG argc, char **argv)
{
  ULONG argus = 2;
  if( argc ) {
    LocaleBase=OpenLibrary("locale.library",38);
    if( LocaleBase ) {
      while( argus < argc)
      {
        strcpy(CatalogName,VERZEICHNIS);
        strcat(CatalogName,argv[argus++]);
        /* Katalog der gewünschten Sprache öffnen */
        mycatalog=OpenCatalog(NULL,CatalogName,
            OC_Language, (ULONG)argv[1], TAG_DONE);
        if( mycatalog ) {
          long nr = 0;
          UBYTE *text;
          printf("Kataloginhalt von %s\n",CatalogName);
          while( (text=GetCatalogStr(mycatalog,nr,NULL)) 
                 != NULL )
            printf("String[%d]=\"%s\"\n",nr++,text);
          CloseCatalog( mycatalog );
        } else printf("Fehler beim Öffnen"
                      " des Catalogs %s\n",CatalogName);
      }
      CloseLibrary(LocaleBase);
    } else printf("Locale-Library nicht vorhanden\n");
  }
}
