Sun Jul 28 23:46:14 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[platform/upstream/linaro-glibc.git] / locale / localeinfo.h
1 /* localeinfo.h -- declarations for internal libc locale interfaces
2 Copyright (C) 1995, 1996 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB.  If
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA.  */
19
20 #ifndef _LOCALEINFO_H
21 #define _LOCALEINFO_H 1
22
23 #include <stddef.h>
24 #include <langinfo.h>
25 #include <sys/types.h>
26
27 #include "../intl/loadinfo.h"   /* For loaded_l10nfile definition.  */
28
29 /* Magic number at the beginning of a locale data file for CATEGORY.  */
30 #define LIMAGIC(category)       (0x960617de ^ (category))
31
32 /* Two special weight constants for the collation data.  */
33 #define FORWARD_CHAR ((wchar_t) 0xfffffffd)
34 #define ELLIPSIS_CHAR ((wchar_t) 0xfffffffe)
35 #define IGNORE_CHAR ((wchar_t) 0xffffffff)
36
37 /* Structure describing locale data in core for a category.  */
38 struct locale_data
39 {
40   const char *name;
41   const char *filedata;         /* Region mapping the file data.  */
42   off_t filesize;               /* Size of the file (and the region).  */
43
44   unsigned int nstrings;        /* Number of strings below.  */
45   union locale_data_value
46   {
47     const wchar_t *wstr;
48     const char *string;
49     unsigned int word;
50   }
51   values[0];    /* Items, usually pointers into `filedata'.  */
52 };
53
54 /* We know three kinds of collation sorting rules.  */
55 enum coll_sort_rule
56 {
57   illegal_0__,
58   sort_forward,
59   sort_backward,
60   illegal_3__,
61   sort_position,
62   sort_forward_position,
63   sort_backward_position,
64   sort_mask
65 };
66
67 /* We can map the types of the entries into four categories.  */
68 enum value_type
69 {
70   none,
71   string,
72   stringarray,
73   byte,
74   bytearray,
75   word
76 };
77
78
79 /* For each category declare the variable for the current locale data.  */
80 #define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
81 extern const struct locale_data *_nl_current_##category;
82 #include "categories.def"
83 #undef  DEFINE_CATEGORY
84
85 extern const char *const _nl_category_names[LC_ALL + 1];
86 extern const size_t _nl_category_name_sizes[LC_ALL + 1];
87 extern const struct locale_data * *const _nl_current[LC_ALL];
88
89 /* Name of the standard locale.  */
90 extern const char _nl_C_name[];
91
92 /* Extract the current CATEGORY locale's string for ITEM.  */
93 #define _NL_CURRENT(category, item) \
94   (_nl_current_##category->values[_NL_ITEM_INDEX (item)].string)
95
96 /* Extract the current CATEGORY locale's word for ITEM.  */
97 #define _NL_CURRENT_WORD(category, item) \
98   (_nl_current_##category->values[_NL_ITEM_INDEX (item)].word)
99
100 /* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY.  */
101 #define _NL_CURRENT_DEFINE(category) \
102   extern const struct locale_data _nl_C_##category; \
103   const struct locale_data *_nl_current_##category = &_nl_C_##category
104
105 /* Load the locale data for CATEGORY from the file specified by *NAME.
106    If *NAME is "", use environment variables as specified by POSIX,
107    and fill in *NAME with the actual name used.  The directories
108    listed in LOCALE_PATH are searched for the locale files.  */
109 extern const struct locale_data *_nl_find_locale (const char *locale_path,
110                                                   size_t locale_path_len,
111                                                   int category, char **name);
112
113 /* Try to load the file described by FILE.  */
114 extern void _nl_load_locale (struct loaded_l10nfile *file, int category);
115
116 /* Free the locale data read in by a `_nl_load_locale' call.  */
117 extern void _nl_free_locale (const struct locale_data *);
118
119
120 /* Global variables for LC_COLLATE category data.  */
121 extern const u_int32_t *__collate_table;
122 extern const u_int32_t *__collate_extra;
123 extern const u_int32_t *__collate_element_hash;
124 extern const char *__collate_element_strings;
125 extern const wchar_t *__collate_element_values;
126 extern const u_int32_t *__collate_symbol_hash;
127 extern const char *__collate_symbol_strings;
128 extern const u_int32_t *__collate_symbol_classes;
129
130 #endif  /* localeinfo.h */