]> git.ipfire.org Git - thirdparty/glibc.git/blame - locale/localeinfo.h
Thu Mar 28 03:25:10 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu>
[thirdparty/glibc.git] / locale / localeinfo.h
CommitLineData
933e73fa 1/* localeinfo.h -- declarations for internal libc locale interfaces
19bc17a9 2Copyright (C) 1995, 1996 Free Software Foundation, Inc.
28f540f4
RM
3This file is part of the GNU C Library.
4
5The GNU C Library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Library General Public License as
7published by the Free Software Foundation; either version 2 of the
8License, or (at your option) any later version.
9
10The GNU C Library is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13Library General Public License for more details.
14
15You should have received a copy of the GNU Library General Public
16License along with the GNU C Library; see the file COPYING.LIB. If
933e73fa 17not, write to the Free Software Foundation, Inc., 675 Mass Ave,
28f540f4
RM
18Cambridge, MA 02139, USA. */
19
933e73fa
RM
20#ifndef _LOCALEINFO_H
21#define _LOCALEINFO_H 1
28f540f4 22
933e73fa
RM
23#include <stddef.h>
24#include <langinfo.h>
25#include <sys/types.h>
28f540f4 26
933e73fa 27/* Magic number at the beginning of a locale data file for CATEGORY. */
19bc17a9
RM
28#define LIMAGIC(category) (0x960316de ^ (category))
29
30/* Two special weight constants for the collation data. */
31#define FORWARD_CHAR 0xfffffffd
32#define ELLIPSIS_CHAR 0xfffffffe
33#define IGNORE_CHAR 0xffffffff
28f540f4 34
933e73fa
RM
35/* Structure describing locale data in core for a category. */
36struct locale_data
19bc17a9
RM
37{
38 const char *filedata; /* Region mapping the file data. */
39 off_t filesize; /* Size of the file (and the region). */
933e73fa 40
19bc17a9
RM
41 unsigned int nstrings; /* Number of strings below. */
42 union locale_data_value
43 {
44 const char *string;
45 unsigned int word;
46 }
47 values[0]; /* Items, usually pointers into `filedata'. */
48};
49
50/* We know three kinds of collation sorting rules. */
51enum coll_sort_rule
52{
53 illegal_0__,
54 sort_forward,
55 sort_backward,
56 illegal_3__,
57 sort_position,
58 sort_forward_position,
59 sort_backward_position,
60 sort_mask
61};
62
63/* We can map the types of the entries into four categories. */
64enum value_type
65{
66 none,
67 string,
68 stringarray,
69 byte,
70 bytearray,
71 word
72};
933e73fa
RM
73
74
75/* For each category declare the variable for the current locale data. */
76#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
77extern const struct locale_data *_nl_current_##category;
78#include "categories.def"
79#undef DEFINE_CATEGORY
80
81extern const char *const _nl_category_names[LC_ALL];
40deae08 82extern const struct locale_data * *const _nl_current[LC_ALL];
933e73fa
RM
83
84/* Extract the current CATEGORY locale's string for ITEM. */
85#define _NL_CURRENT(category, item) \
19bc17a9
RM
86 (_nl_current_##category->values[_NL_ITEM_INDEX (item)].string)
87
88/* Extract the current CATEGORY locale's word for ITEM. */
89#define _NL_CURRENT_WORD(category, item) \
90 (_nl_current_##category->values[_NL_ITEM_INDEX (item)].word)
933e73fa
RM
91
92/* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY. */
93#define _NL_CURRENT_DEFINE(category) \
94 extern const struct locale_data _nl_C_##category; \
40deae08 95 const struct locale_data *_nl_current_##category = &_nl_C_##category
933e73fa
RM
96
97/* Load the locale data for CATEGORY from the file specified by *NAME.
98 If *NAME is "", use environment variables as specified by POSIX,
99 and fill in *NAME with the actual name used. */
100extern struct locale_data *_nl_load_locale (int category, char **name);
101
102/* Free the locale data read in by a `_nl_load_locale' call. */
103extern void _nl_free_locale (struct locale_data *);
28f540f4
RM
104
105
19bc17a9
RM
106/* XXX For now. */
107typedef unsigned int u32_t;
108
109/* Global variables for LC_COLLATE category data. */
110extern const u32_t *__collate_table;
111extern const u32_t *__collate_extra;
112
933e73fa 113#endif /* localeinfo.h */