| 1 | /* General definitions for localedef(1). | 
|---|
| 2 | Copyright (C) 1998-2020 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 <https://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.  */ | 
|---|
| 37 | enum | 
|---|
| 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.  */ | 
|---|
| 67 | struct locale_ctype_t; | 
|---|
| 68 | struct locale_collate_t; | 
|---|
| 69 | struct locale_monetary_t; | 
|---|
| 70 | struct locale_numeric_t; | 
|---|
| 71 | struct locale_time_t; | 
|---|
| 72 | struct locale_messages_t; | 
|---|
| 73 | struct locale_paper_t; | 
|---|
| 74 | struct locale_name_t; | 
|---|
| 75 | struct locale_address_t; | 
|---|
| 76 | struct locale_telephone_t; | 
|---|
| 77 | struct locale_measurement_t; | 
|---|
| 78 | struct locale_identification_t; | 
|---|
| 79 |  | 
|---|
| 80 |  | 
|---|
| 81 | /* Definitions for the locale.  */ | 
|---|
| 82 | struct 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.  */ | 
|---|
| 117 | extern const char *repertoire_global; | 
|---|
| 118 | extern int max_locarchive_open_retry; | 
|---|
| 119 | extern bool no_archive; | 
|---|
| 120 | extern const char *alias_file; | 
|---|
| 121 | extern bool hard_links; | 
|---|
| 122 |  | 
|---|
| 123 |  | 
|---|
| 124 | /* Prototypes for a few program-wide used functions.  */ | 
|---|
| 125 | #include <programs/xmalloc.h> | 
|---|
| 126 | #include <programs/xasprintf.h> | 
|---|
| 127 |  | 
|---|
| 128 |  | 
|---|
| 129 | /* Mark given locale as to be read.  */ | 
|---|
| 130 | extern struct localedef_t *add_to_readlist (int locale, const char *name, | 
|---|
| 131 | const char *repertoire_name, | 
|---|
| 132 | int generate, | 
|---|
| 133 | struct localedef_t *copy_locale); | 
|---|
| 134 |  | 
|---|
| 135 | /* Find the information for the locale NAME.  */ | 
|---|
| 136 | extern struct localedef_t *find_locale (int locale, const char *name, | 
|---|
| 137 | const char *repertoire_name, | 
|---|
| 138 | const struct charmap_t *charmap); | 
|---|
| 139 |  | 
|---|
| 140 | /* Load (if necessary) the information for the locale NAME.  */ | 
|---|
| 141 | extern struct localedef_t *load_locale (int locale, const char *name, | 
|---|
| 142 | const char *repertoire_name, | 
|---|
| 143 | const struct charmap_t *charmap, | 
|---|
| 144 | struct localedef_t *copy_locale); | 
|---|
| 145 |  | 
|---|
| 146 |  | 
|---|
| 147 | /* Open the locale archive.  */ | 
|---|
| 148 | extern void open_archive (struct locarhandle *ah, bool readonly); | 
|---|
| 149 |  | 
|---|
| 150 | /* Close the locale archive.  */ | 
|---|
| 151 | extern void close_archive (struct locarhandle *ah); | 
|---|
| 152 |  | 
|---|
| 153 | /* Add given locale data to the archive.  */ | 
|---|
| 154 | extern int add_locale_to_archive (struct locarhandle *ah, const char *name, | 
|---|
| 155 | locale_data_t data, bool replace); | 
|---|
| 156 |  | 
|---|
| 157 | /* Add content of named directories to locale archive.  */ | 
|---|
| 158 | extern int add_locales_to_archive (size_t nlist, char *list[], bool replace); | 
|---|
| 159 |  | 
|---|
| 160 | /* Removed named locales from archive.  */ | 
|---|
| 161 | extern int delete_locales_from_archive (size_t nlist, char *list[]); | 
|---|
| 162 |  | 
|---|
| 163 | /* List content of locale archive. If FNAME is non-null use that as | 
|---|
| 164 | the locale archive to list, otherwise the default.  */ | 
|---|
| 165 | extern void show_archive_content (const char *fname, | 
|---|
| 166 | int verbose) __attribute__ ((noreturn)); | 
|---|
| 167 |  | 
|---|
| 168 | #endif /* localedef.h */ | 
|---|
| 169 |  | 
|---|