/*
 *
 *  Copyright (C) 2024-2025  Yurii Yakubin (yurii.yakubin@gmail.com)
 *
 */

#ifndef _LOCALE_H
#define _LOCALE_H

#include <bits/locale_struct.h>
#include <bits/locale_category.h>

#ifdef __cplusplus
extern "C" {
#endif

#define LC_CTYPE          __LC_CTYPE
#define LC_NUMERIC        __LC_NUMERIC
#define LC_TIME           __LC_TIME
#define LC_COLLATE        __LC_COLLATE
#define LC_MONETARY       __LC_MONETARY
#define LC_MESSAGES       __LC_MESSAGES
#define LC_ALL            __LC_ALL
#define LC_PAPER          __LC_PAPER
#define LC_NAME           __LC_NAME
#define LC_ADDRESS        __LC_ADDRESS
#define LC_TELEPHONE      __LC_TELEPHONE
#define LC_MEASUREMENT    __LC_MEASUREMENT
#define LC_IDENTIFICATION __LC_IDENTIFICATION

#define LC_CTYPE_MASK          (1 << __LC_CTYPE)
#define LC_NUMERIC_MASK        (1 << __LC_NUMERIC)
#define LC_TIME_MASK           (1 << __LC_TIME)
#define LC_COLLATE_MASK        (1 << __LC_COLLATE)
#define LC_MONETARY_MASK       (1 << __LC_MONETARY)
#define LC_MESSAGES_MASK       (1 << __LC_MESSAGES)
#define LC_PAPER_MASK          (1 << __LC_PAPER)
#define LC_NAME_MASK           (1 << __LC_NAME)
#define LC_ADDRESS_MASK        (1 << __LC_ADDRESS)
#define LC_TELEPHONE_MASK      (1 << __LC_TELEPHONE)
#define LC_MEASUREMENT_MASK    (1 << __LC_MEASUREMENT)
#define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION)

#define LC_ALL_MASK (LC_CTYPE_MASK         \
                   | LC_NUMERIC_MASK       \
                   | LC_TIME_MASK          \
                   | LC_COLLATE_MASK       \
                   | LC_MONETARY_MASK      \
                   | LC_MESSAGES_MASK      \
                   | LC_PAPER_MASK         \
                   | LC_NAME_MASK          \
                   | LC_ADDRESS_MASK       \
                   | LC_TELEPHONE_MASK     \
                   | LC_MEASUREMENT_MASK   \
                   | LC_IDENTIFICATION_MASK)

struct lconv {
  char* decimal_point;
  char* thousands_sep;
  char* grouping;
  char* int_curr_symbol;
  char* currency_symbol;
  char* mon_decimal_point;
  char* mon_thousands_sep;
  char* mon_grouping;
  char* positive_sign;
  char* negative_sign;
  char int_frac_digits;
  char frac_digits;
  char p_cs_precedes;
  char p_sep_by_space;
  char n_cs_precedes;
  char n_sep_by_space;
  char p_sign_posn;
  char n_sign_posn;
};

char* setlocale(int category, const char* locale);
locale_t newlocale(int category_mask, const char* locale, locale_t base);
void freelocale(locale_t locale);

struct lconv* localeconv(void);

#ifdef __cplusplus
}
#endif

#endif /* _LOCALE_H */
