source: trunk/libs/newlib/src/newlib/libc/sys/linux/iconv/localeinfo.h

Last change on this file was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 6.6 KB
Line 
1/* Declarations for internal libc locale interfaces
2   Copyright (C) 1995, 96, 97, 98, 99,2000,2001 Free Software Foundation, Inc.
3   This file is part of the GNU C Library.
4
5   The GNU C Library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9
10   The GNU C Library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser General Public
16   License along with the GNU C Library; if not, write to the Free
17   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18   02111-1307 USA.  */
19
20#ifndef _LOCALEINFO_H
21#define _LOCALEINFO_H 1
22
23#include <stddef.h>
24#include <langinfo.h>
25#include <limits.h>
26#include <time.h>
27#include <stdint.h>
28#include <sys/types.h>
29
30/* This has to be changed whenever a new locale is defined.  */
31#define __LC_LAST       13
32
33#include "loadinfo.h"   /* For loaded_l10nfile definition.  */
34
35/* Magic number at the beginning of a locale data file for CATEGORY.  */
36#define LIMAGIC(category)       ((unsigned int) (0x20000828 ^ (category)))
37
38/* Two special weight constants for the collation data.  */
39#define IGNORE_CHAR     2
40
41/* We use a special value for the usage counter in `locale_data' to
42   signal that this data must never be removed anymore.  */
43#define MAX_USAGE_COUNT (UINT_MAX - 1)
44#define UNDELETABLE     UINT_MAX
45
46/* Structure describing locale data in core for a category.  */
47struct locale_data
48{
49  const char *name;
50  const char *filedata;         /* Region mapping the file data.  */
51  off_t filesize;               /* Size of the file (and the region).  */
52  int mmaped;                   /* If nonzero the data is mmaped.  */
53
54  unsigned int usage_count;     /* Counter for users.  */
55
56  int use_translit;             /* Nonzero if the mb*towv*() and wc*tomb()
57                                   functions should use transliteration.  */
58  const char *options;          /* Extra options from the locale name,
59                                   not used in the path to the locale data.  */
60
61  unsigned int nstrings;        /* Number of strings below.  */
62  union locale_data_value
63  {
64    const uint32_t *wstr;
65    const char *string;
66    unsigned int word;
67  }
68  values __flexarr;     /* Items, usually pointers into `filedata'.  */
69};
70
71/* We know three kinds of collation sorting rules.  */
72enum coll_sort_rule
73{
74  illegal_0__,
75  sort_forward,
76  sort_backward,
77  illegal_3__,
78  sort_position,
79  sort_forward_position,
80  sort_backward_position,
81  sort_mask
82};
83
84/* We can map the types of the entries into a few categories.  */
85enum value_type
86{
87  none,
88  string,
89  stringarray,
90  byte,
91  bytearray,
92  word,
93  stringlist,
94  wordarray,
95  wstring,
96  wstringarray,
97  wstringlist
98};
99
100
101/* Definitions for `era' information from LC_TIME.  */
102#define ERA_NAME_FORMAT_MEMBERS 4
103#define ERA_M_NAME   0
104#define ERA_M_FORMAT 1
105#define ERA_W_NAME   2
106#define ERA_W_FORMAT 3
107
108
109/* Structure to access `era' information from LC_TIME.  */
110struct era_entry
111{
112  uint32_t direction;           /* Contains '+' or '-'.  */
113  int32_t offset;
114  int32_t start_date[3];
115  int32_t stop_date[3];
116  const char *era_name;
117  const char *era_format;
118  const wchar_t *era_wname;
119  const wchar_t *era_wformat;
120  int absolute_direction;
121  /* absolute direction:
122     +1 indicates that year number is higher in the future. (like A.D.)
123     -1 indicates that year number is higher in the past. (like B.C.)  */
124};
125
126
127/* LC_CTYPE specific:
128   Hardwired indices for standard wide character translation mappings.  */
129enum
130{
131  __TOW_toupper = 0,
132  __TOW_tolower = 1
133};
134
135
136/* LC_CTYPE specific:
137   Access a wide character class with a single character index.
138   _ISCTYPE (c, desc) = iswctype (btowc (c), desc).
139   c must be an `unsigned char'.  desc must be a nonzero wctype_t.  */
140#define _ISCTYPE(c, desc) \
141  (((((const uint32_t *) (desc)) - 8)[(c) >> 5] >> ((c) & 0x1f)) & 1)
142
143
144/* For each category declare the variable for the current locale data.  */
145#define DEFINE_CATEGORY(category, category_name, items, a) \
146extern struct locale_data *_nl_current_##category;
147#include "categories.def"
148#undef  DEFINE_CATEGORY
149
150extern const char *const _nl_category_names[__LC_LAST];
151extern const size_t _nl_category_name_sizes[__LC_LAST];
152extern struct locale_data * *const _nl_current[__LC_LAST];
153
154/* Extract the current CATEGORY locale's string for ITEM.  */
155#define _NL_CURRENT(category, item) \
156  (_nl_current_##category->values[_NL_ITEM_INDEX (item)].string)
157
158/* Extract the current CATEGORY locale's string for ITEM.  */
159#define _NL_CURRENT_WSTR(category, item) \
160  ((wchar_t *) (_nl_current_##category->values[_NL_ITEM_INDEX (item)].wstr))
161
162/* Extract the current CATEGORY locale's word for ITEM.  */
163#define _NL_CURRENT_WORD(category, item) \
164  (_nl_current_##category->values[_NL_ITEM_INDEX (item)].word)
165
166/* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY.  */
167#define _NL_CURRENT_DEFINE(category) \
168  extern struct locale_data _nl_C_##category; \
169  struct locale_data *_nl_current_##category = &_nl_C_##category
170
171/* Load the locale data for CATEGORY from the file specified by *NAME.
172   If *NAME is "", use environment variables as specified by POSIX,
173   and fill in *NAME with the actual name used.  The directories
174   listed in LOCALE_PATH are searched for the locale files.  */
175extern struct locale_data *_nl_find_locale (const char *locale_path,
176                                            size_t locale_path_len,
177                                            int category, const char **name);
178
179/* Try to load the file described by FILE.  */
180extern void _nl_load_locale (struct loaded_l10nfile *file, int category);
181
182/* Free all resource.  */
183extern void _nl_unload_locale (struct locale_data *locale);
184
185/* Free the locale and give back all memory if the usage count is one.  */
186extern void _nl_remove_locale (int locale, struct locale_data *data);
187
188
189/* Return `era' entry which corresponds to TP.  Used in strftime.  */
190extern struct era_entry *_nl_get_era_entry (const struct tm *tp);
191
192/* Return `era' cnt'th entry .  Used in strptime.  */
193extern struct era_entry *_nl_select_era_entry (int cnt);
194
195/* Return `alt_digit' which corresponds to NUMBER.  Used in strftime.  */
196extern const char *_nl_get_alt_digit (unsigned int number);
197
198/* Similar, but now for wide characters.  */
199extern const wchar_t *_nl_get_walt_digit (unsigned int number);
200
201/* Parse string as alternative digit and return numeric value.  */
202extern int _nl_parse_alt_digit (const char **strp);
203
204/* Postload processing.  */
205extern void _nl_postload_ctype (void);
206extern void _nl_postload_time (void);
207
208
209#endif  /* localeinfo.h */
Note: See TracBrowser for help on using the repository browser.