/*
** Util-Funktionen
**
** Copyright (C) 1996 by Stefan Scherer.
**
** Permission to use, copy, modify, and distribute this software and its
** documentation for non-commerical use and without fee is hereby granted,
** provided that the above copyright notice appear in all copies and that
** both that copyright notice and this permission notice appear in
** supporting documentation.  This software is provided "as is" without
** express or implied warranty.
*/

#ifndef LOCALESUPPORT_H
#define LOCALESUPPORT_H

#include <libraries/locale.h>

#define CATCOMP_NUMBERS
extern struct CatCompArrayType CatCompArray[];
#include "Locales.h"
#ifndef CATCOMP_ARRAY
struct CatCompArrayType
  {
    LONG cca_ID;
    STRPTR cca_Str;
  };
#endif

/* === Abkürzung, um an einen Locale-String zu gelangen ========== */

#define STRING(n)    CatCompArray[ n ].cca_Str
#define CHAR(n)      *CatCompArray[ n ].cca_Str

/*
**  Die Support-Funktionen
*/

extern int ConstructLocale (void);
extern void DestructLocale (void);

extern ULONG GetThisYear (void);
extern void CorrectDate (STRPTR date);
extern void PrintCurrency (STRPTR buffer, double number);
extern void PrintMonetary (STRPTR buffer, double number);
extern double ScanMonetary (STRPTR string);
double ScanMonetaryNew (STRPTR string, STRPTR group, STRPTR decimal,
                        STRPTR fracgroup);
double ScanMonetaryMulti (STRPTR string);

extern STRPTR L_GetErrorMsg (void);

void DisplayBetrag (STRPTR buffer, double betrag, double mwstsatz, UWORD mode);
void DisplayBetragOhneDM (STRPTR buffer, double betrag, double mwstsatz,
                          UWORD mode);
double Brutto2Netto (double zahl, double mwst);


/* Fehlercodes beim Konstruktor-Aufruf */

enum
  {
    ERR_LOC_OK,
    ERR_LOC_NOLIB,
    ERR_LOC_NOLOCALE,
    ERR_LOC_NOGERMAN	/* Sprache ist nicht auf Deutsch eingestellt ! */
  };

extern struct Library *LocaleBase;	/* die geöffnete Library */
extern struct Catalog *Catalog;	/* Zeiger auf den geöffneten Katalog */
extern struct Locale *Locale;	/* Zeiger auf die Locale-Struktur */

#endif /* LOCALESUPPORT_H */
