/* Localization <locale.h>12This file is part of the Public Domain C Library (PDCLib).3Permission is granted to use, modify, and / or redistribute at will.4*/56#ifndef _PDCLIB_LOCALE_H7#define _PDCLIB_LOCALE_H _PDCLIB_LOCALE_H8#include "_PDCLIB_int.h"910#ifdef __cplusplus11extern "C" {12#endif1314#ifndef _PDCLIB_NULL_DEFINED15#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED16#define NULL _PDCLIB_NULL17#endif1819/* The structure returned by localeconv().2021The values for *_sep_by_space:220 - no space231 - if symbol and sign are adjacent, a space seperates them from the value;24otherwise a space seperates the symbol from the value252 - if symbol and sign are adjacent, a space seperates them; otherwise a26space seperates the sign from the value2728The values for *_sign_posn:290 - Parentheses surround value and symbol301 - sign precedes value and symbol312 - sign succeeds value and symbol323 - sign immediately precedes symbol334 - sign immediately succeeds symbol34*/35struct lconv36{37char * decimal_point; /* decimal point character */38char * thousands_sep; /* character for seperating groups of digits */39char * grouping; /* string indicating the size of digit groups */40char * mon_decimal_point; /* decimal point for monetary quantities */41char * mon_thousands_sep; /* thousands_sep for monetary quantities */42char * mon_grouping; /* grouping for monetary quantities */43char * positive_sign; /* string indicating nonnegative mty. qty. */44char * negative_sign; /* string indicating negative mty. qty. */45char * currency_symbol; /* local currency symbol (e.g. '$') */46char * int_curr_symbol; /* international currency symbol (e.g. "USD" */47char frac_digits; /* fractional digits in local monetary qty. */48char p_cs_precedes; /* if currency_symbol precedes positive qty. */49char n_cs_precedes; /* if currency_symbol precedes negative qty. */50char p_sep_by_space; /* if it is seperated by space from pos. qty. */51char n_sep_by_space; /* if it is seperated by space from neg. qty. */52char p_sign_posn; /* positioning of positive_sign for mon. qty. */53char n_sign_posn; /* positioning of negative_sign for mon. qty. */54char int_frac_digits; /* Same as above, for international format */55char int_p_cs_precedes; /* Same as above, for international format */56char int_n_cs_precedes; /* Same as above, for international format */57char int_p_sep_by_space; /* Same as above, for international format */58char int_n_sep_by_space; /* Same as above, for international format */59char int_p_sign_posn; /* Same as above, for international format */60char int_n_sign_posn; /* Same as above, for international format */61};6263/* First arguments to setlocale().64TODO: Beware, values might change before v0.6 is released.65*/66/* Entire locale */67#define LC_ALL -168/* Collation (strcoll(), strxfrm()) */69#define LC_COLLATE 070/* Character types (<ctype.h>) */71#define LC_CTYPE 172/* Monetary formatting (as returned by localeconv) */73#define LC_MONETARY 274/* Decimal-point character (for printf() / scanf() functions), string75conversions, nonmonetary formatting as returned by localeconv */76#define LC_NUMERIC 377/* Time formats (strftime(), wcsftime()) */78#define LC_TIME 47980/* not supported! */81#define LC_MESSAGES 58283/* The category parameter can be any of the LC_* macros to specify if the call84to setlocale() shall affect the entire locale or only a portion thereof.85The category locale specifies which locale should be switched to, with "C"86being the minimal default locale, and "" being the locale-specific native87environment. A NULL pointer makes setlocale() return the *current* setting.88Otherwise, returns a pointer to a string associated with the specified89category for the new locale.90*/91char * setlocale( int category, const char * locale ) _PDCLIB_nothrow;9293/* Returns a struct lconv initialized to the values appropriate for the current94locale setting.95*/96struct lconv * localeconv( void ) _PDCLIB_nothrow;9798#if _PDCLIB_POSIX_MIN(2008)99#define LC_COLLATE_MASK (1 << LC_COLLATE)100#define LC_CTYPE_MASK (1 << LC_CTYPE)101#define LC_MONETARY_MASK (1 << LC_MONETARY)102#define LC_NUMERIC_MASK (1 << LC_NUMERIC)103#define LC_TIME_MASK (1 << LC_TIME)104#define LC_MESSAGES_MASK (1 << LC_MESSAGES)105#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MONETARY_MASK | \106LC_NUMERIC_MASK | LC_TIME_MASK | LC_MESSAGES_MASK)107108109/* POSIX locale type */110typedef _PDCLIB_locale_t locale_t;111112/* Global locale */113extern struct _PDCLIB_locale _PDCLIB_global_locale;114#define LC_GLOBAL_LOCALE (&_PDCLIB_global_locale)115116#ifdef _PDCLIB_LOCALE_METHOD117118locale_t newlocale(int category_mask, const char *locale, locale_t base);119120/* Set the thread locale to newlocale121*122* If newlocale is (locale_t)0, then doesn't change the locale and just returns123* the existing locale.124*125* If newlocale is LC_GLOBAL_LOCALE, resets the thread's locale to use the126* global locale.127*128* Returns the previous thread locale. If the thread had no previous locale,129* returns the global locale.130*/131locale_t uselocale( locale_t newlocale );132133/* Returns a copy of loc */134locale_t duplocale( locale_t loc );135136/* Frees the passed locale object */137void freelocale( locale_t loc );138#endif139140#endif141142#ifdef __cplusplus143}144#endif145146#endif147148149