1/* General definitions for localedef(1).
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef _LOCALEDEF_H
20#define _LOCALEDEF_H 1
21
22/* Get the basic locale definitions. */
23#include <errno.h>
24#include <locale.h>
25#include <stdbool.h>
26#include <stddef.h>
27#include <stdarg.h>
28#include <stdio.h>
29#include <stdlib.h>
30
31#include "record-status.h"
32#include "repertoire.h"
33#include "../locarchive.h"
34
35
36/* We need a bitmask for the locales. */
37enum
38{
39 CTYPE_LOCALE = 1 << LC_CTYPE,
40 NUMERIC_LOCALE = 1 << LC_NUMERIC,
41 TIME_LOCALE = 1 << LC_TIME,
42 COLLATE_LOCALE = 1 << LC_COLLATE,
43 MONETARY_LOCALE = 1 << LC_MONETARY,
44 MESSAGES_LOCALE = 1 << LC_MESSAGES,
45 PAPER_LOCALE = 1 << LC_PAPER,
46 NAME_LOCALE = 1 << LC_NAME,
47 ADDRESS_LOCALE = 1 << LC_ADDRESS,
48 TELEPHONE_LOCALE = 1 << LC_TELEPHONE,
49 MEASUREMENT_LOCALE = 1 << LC_MEASUREMENT,
50 IDENTIFICATION_LOCALE = 1 << LC_IDENTIFICATION,
51 ALL_LOCALES = (1 << LC_CTYPE
52 | 1 << LC_NUMERIC
53 | 1 << LC_TIME
54 | 1 << LC_COLLATE
55 | 1 << LC_MONETARY
56 | 1 << LC_MESSAGES
57 | 1 << LC_PAPER
58 | 1 << LC_NAME
59 | 1 << LC_ADDRESS
60 | 1 << LC_TELEPHONE
61 | 1 << LC_MEASUREMENT
62 | 1 << LC_IDENTIFICATION)
63};
64
65
66/* Opaque types for the different locales. */
67struct locale_ctype_t;
68struct locale_collate_t;
69struct locale_monetary_t;
70struct locale_numeric_t;
71struct locale_time_t;
72struct locale_messages_t;
73struct locale_paper_t;
74struct locale_name_t;
75struct locale_address_t;
76struct locale_telephone_t;
77struct locale_measurement_t;
78struct locale_identification_t;
79
80
81/* Definitions for the locale. */
82struct localedef_t
83{
84 struct localedef_t *next;
85
86 const char *name;
87
88 int needed;
89 int avail;
90
91 union
92 {
93 void *generic;
94 struct locale_ctype_t *ctype;
95 struct locale_collate_t *collate;
96 struct locale_monetary_t *monetary;
97 struct locale_numeric_t *numeric;
98 struct locale_time_t *time;
99 struct locale_messages_t *messages;
100 struct locale_paper_t *paper;
101 struct locale_name_t *name;
102 struct locale_address_t *address;
103 struct locale_telephone_t *telephone;
104 struct locale_measurement_t *measurement;
105 struct locale_identification_t *identification;
106 } categories[__LC_LAST];
107
108 size_t len[__LC_LAST];
109
110 const char *copy_name[__LC_LAST];
111
112 const char *repertoire_name;
113};
114
115
116/* Global variables of the localedef program. */
117extern const char *repertoire_global;
118extern int max_locarchive_open_retry;
119extern bool no_archive;
120extern const char *alias_file;
121extern bool hard_links;
122
123
124/* Prototypes for a few program-wide used functions. */
125#include <programs/xmalloc.h>
126
127
128/* Mark given locale as to be read. */
129extern struct localedef_t *add_to_readlist (int locale, const char *name,
130 const char *repertoire_name,
131 int generate,
132 struct localedef_t *copy_locale);
133
134/* Find the information for the locale NAME. */
135extern struct localedef_t *find_locale (int locale, const char *name,
136 const char *repertoire_name,
137 const struct charmap_t *charmap);
138
139/* Load (if necessary) the information for the locale NAME. */
140extern struct localedef_t *load_locale (int locale, const char *name,
141 const char *repertoire_name,
142 const struct charmap_t *charmap,
143 struct localedef_t *copy_locale);
144
145
146/* Open the locale archive. */
147extern void open_archive (struct locarhandle *ah, bool readonly);
148
149/* Close the locale archive. */
150extern void close_archive (struct locarhandle *ah);
151
152/* Add given locale data to the archive. */
153extern int add_locale_to_archive (struct locarhandle *ah, const char *name,
154 locale_data_t data, bool replace);
155
156/* Add content of named directories to locale archive. */
157extern int add_locales_to_archive (size_t nlist, char *list[], bool replace);
158
159/* Removed named locales from archive. */
160extern int delete_locales_from_archive (size_t nlist, char *list[]);
161
162/* List content of locale archive. If FNAME is non-null use that as
163 the locale archive to list, otherwise the default. */
164extern void show_archive_content (const char *fname,
165 int verbose) __attribute__ ((noreturn));
166
167#endif /* localedef.h */
168