| 1 |
/**************************************************************************/ |
| 2 |
/* */ |
| 3 |
/* This file is part of Frama-C. */ |
| 4 |
/* */ |
| 5 |
/* Copyright (C) 2007-2022 */ |
| 6 |
/* CEA (Commissariat à l'énergie atomique et aux énergies */ |
| 7 |
/* alternatives) */ |
| 8 |
/* */ |
| 9 |
/* you can redistribute it and/or modify it under the terms of the GNU */ |
| 10 |
/* Lesser General Public License as published by the Free Software */ |
| 11 |
/* Foundation, version 2.1. */ |
| 12 |
/* */ |
| 13 |
/* It is distributed in the hope that it will be useful, */ |
| 14 |
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
| 15 |
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
| 16 |
/* GNU Lesser General Public License for more details. */ |
| 17 |
/* */ |
| 18 |
/* See the GNU Lesser General Public License version 2.1 */ |
| 19 |
/* for more details (enclosed in the file licenses/LGPLv2.1). */ |
| 20 |
/* */ |
| 21 |
/**************************************************************************/ |
| 22 |
|
| 23 |
#ifndef __FC_LOCALE |
| 24 |
#define __FC_LOCALE |
| 25 |
#include "features.h" |
| 26 |
__PUSH_FC_STDLIB |
| 27 |
#include "__fc_define_locale_t.h" |
| 28 |
__BEGIN_DECLS |
| 29 |
|
| 30 |
/* Structure giving information about numeric and monetary notation. */ |
| 31 |
struct lconv |
| 32 |
{ |
| 33 |
/* Numeric (non-monetary) information. */ |
| 34 |
|
| 35 |
char *decimal_point; /* Decimal point character. */ |
| 36 |
char *thousands_sep; /* Thousands separator. */ |
| 37 |
/* Each element is the number of digits in each group; |
| 38 |
elements with higher indices are farther left. |
| 39 |
An element with value CHAR_MAX means that no further grouping is done. |
| 40 |
An element with value 0 means that the previous element is used |
| 41 |
for all groups farther left. */ |
| 42 |
char *grouping; |
| 43 |
|
| 44 |
/* Monetary information. */ |
| 45 |
|
| 46 |
/* First three chars are a currency symbol from ISO 4217. |
| 47 |
Fourth char is the separator. Fifth char is '\0'. */ |
| 48 |
char *int_curr_symbol; |
| 49 |
char *currency_symbol; /* Local currency symbol. */ |
| 50 |
char *mon_decimal_point; /* Decimal point character. */ |
| 51 |
char *mon_thousands_sep; /* Thousands separator. */ |
| 52 |
char *mon_grouping; /* Like `grouping' element (above). */ |
| 53 |
char *positive_sign; /* Sign for positive values. */ |
| 54 |
char *negative_sign; /* Sign for negative values. */ |
| 55 |
char int_frac_digits; /* Int'l fractional digits. */ |
| 56 |
char frac_digits; /* Local fractional digits. */ |
| 57 |
/* 1 if currency_symbol precedes a positive value, 0 if succeeds. */ |
| 58 |
char p_cs_precedes; |
| 59 |
/* 1 iff a space separates currency_symbol from a positive value. */ |
| 60 |
char p_sep_by_space; |
| 61 |
/* 1 if currency_symbol precedes a negative value, 0 if succeeds. */ |
| 62 |
char n_cs_precedes; |
| 63 |
/* 1 iff a space separates currency_symbol from a negative value. */ |
| 64 |
char n_sep_by_space; |
| 65 |
/* Positive and negative sign positions: |
| 66 |
0 Parentheses surround the quantity and currency_symbol. |
| 67 |
1 The sign string precedes the quantity and currency_symbol. |
| 68 |
2 The sign string follows the quantity and currency_symbol. |
| 69 |
3 The sign string immediately precedes the currency_symbol. |
| 70 |
4 The sign string immediately follows the currency_symbol. */ |
| 71 |
char p_sign_posn; |
| 72 |
char n_sign_posn; |
| 73 |
/* 1 if int_curr_symbol precedes a positive value, 0 if succeeds. */ |
| 74 |
char int_p_cs_precedes; |
| 75 |
/* 1 iff a space separates int_curr_symbol from a positive value. */ |
| 76 |
char int_p_sep_by_space; |
| 77 |
/* 1 if int_curr_symbol precedes a negative value, 0 if succeeds. */ |
| 78 |
char int_n_cs_precedes; |
| 79 |
/* 1 iff a space separates int_curr_symbol from a negative value. */ |
| 80 |
char int_n_sep_by_space; |
| 81 |
/* Positive and negative sign positions: |
| 82 |
0 Parentheses surround the quantity and int_curr_symbol. |
| 83 |
1 The sign string precedes the quantity and int_curr_symbol. |
| 84 |
2 The sign string follows the quantity and int_curr_symbol. |
| 85 |
3 The sign string immediately precedes the int_curr_symbol. |
| 86 |
4 The sign string immediately follows the int_curr_symbol. */ |
| 87 |
char int_p_sign_posn; |
| 88 |
char int_n_sign_posn; |
| 89 |
}; |
| 90 |
|
| 91 |
#include "__fc_define_null.h" |
| 92 |
#include "__fc_string_axiomatic.h" |
| 93 |
|
| 94 |
#define LC_CTYPE 0 |
| 95 |
#define LC_NUMERIC 1 |
| 96 |
#define LC_TIME 2 |
| 97 |
#define LC_COLLATE 3 |
| 98 |
#define LC_MONETARY 4 |
| 99 |
#define LC_MESSAGES 5 |
| 100 |
#define LC_ALL 6 |
| 101 |
#define LC_PAPER 7 |
| 102 |
#define LC_NAME 8 |
| 103 |
#define LC_ADDRESS 9 |
| 104 |
#define LC_TELEPHONE 10 |
| 105 |
#define LC_MEASUREMENT 11 |
| 106 |
#define LC_IDENTIFICATION 12 |
| 107 |
|
| 108 |
# define LC_CTYPE_MASK (1 << LC_CTYPE) |
| 109 |
# define LC_NUMERIC_MASK (1 << LC_NUMERIC) |
| 110 |
# define LC_TIME_MASK (1 << LC_TIME) |
| 111 |
# define LC_COLLATE_MASK (1 << LC_COLLATE) |
| 112 |
# define LC_MONETARY_MASK (1 << LC_MONETARY) |
| 113 |
# define LC_MESSAGES_MASK (1 << LC_MESSAGES) |
| 114 |
# define LC_PAPER_MASK (1 << LC_PAPER) |
| 115 |
# define LC_NAME_MASK (1 << LC_NAME) |
| 116 |
# define LC_ADDRESS_MASK (1 << LC_ADDRESS) |
| 117 |
# define LC_TELEPHONE_MASK (1 << LC_TELEPHONE) |
| 118 |
# define LC_MEASUREMENT_MASK (1 << LC_MEASUREMENT) |
| 119 |
# define LC_IDENTIFICATION_MASK (1 << LC_IDENTIFICATION) |
| 120 |
# define LC_ALL_MASK (LC_CTYPE_MASK \ |
| 121 |
| LC_NUMERIC_MASK \ |
| 122 |
| LC_TIME_MASK \ |
| 123 |
| LC_COLLATE_MASK \ |
| 124 |
| LC_MONETARY_MASK \ |
| 125 |
| LC_MESSAGES_MASK \ |
| 126 |
| LC_PAPER_MASK \ |
| 127 |
| LC_NAME_MASK \ |
| 128 |
| LC_ADDRESS_MASK \ |
| 129 |
| LC_TELEPHONE_MASK \ |
| 130 |
| LC_MEASUREMENT_MASK \ |
| 131 |
| LC_IDENTIFICATION_MASK \ |
| 132 |
) |
| 133 |
|
| 134 |
extern struct lconv* __fc_locale; |
| 135 |
extern char*__fc_locale_names[512]; |
| 136 |
|
| 137 |
/*@ |
| 138 |
requires locale_null_or_valid_string: locale == \null || valid_read_string(locale); |
| 139 |
assigns __fc_locale \from category, locale[..]; |
| 140 |
assigns \result \from __fc_locale,category, locale[..]; |
| 141 |
ensures result_null_or_locale_name: \result==\null || (\valid(\result) |
| 142 |
&& \exists ℤ i ; \result == __fc_locale_names[i]) ; |
| 143 |
*/ |
| 144 |
extern char *setlocale(int category, const char *locale); |
| 145 |
|
| 146 |
/*@ |
| 147 |
assigns \result \from __fc_locale; |
| 148 |
ensures result_current_locale: \result == __fc_locale; |
| 149 |
*/ |
| 150 |
extern struct lconv *localeconv(void); |
| 151 |
|
| 152 |
extern locale_t duplocale(locale_t); |
| 153 |
extern void freelocale(locale_t); |
| 154 |
extern locale_t newlocale(int, const char *, locale_t); |
| 155 |
extern locale_t uselocale(locale_t); |
| 156 |
|
| 157 |
__END_DECLS |
| 158 |
|
| 159 |
__POP_FC_STDLIB |
| 160 |
#endif |