Back to index

glibc  2.9
localedef.h
Go to the documentation of this file.
00001 /* General definitions for localedef(1).
00002    Copyright (C) 1998,1999,2000,2001,2002,2005 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published
00008    by the Free Software Foundation; version 2 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software Foundation,
00018    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00019 
00020 #ifndef _LOCALEDEF_H
00021 #define _LOCALEDEF_H 1
00022 
00023 /* Get the basic locale definitions.  */
00024 #include <errno.h>
00025 #include <locale.h>
00026 #include <stdbool.h>
00027 #include <stddef.h>
00028 
00029 #include "repertoire.h"
00030 #include "../locarchive.h"
00031 
00032 
00033 /* We need a bitmask for the locales.  */
00034 enum
00035 {
00036   CTYPE_LOCALE = 1 << LC_CTYPE,
00037   NUMERIC_LOCALE = 1 << LC_NUMERIC,
00038   TIME_LOCALE = 1 << LC_TIME,
00039   COLLATE_LOCALE = 1 << LC_COLLATE,
00040   MONETARY_LOCALE = 1 << LC_MONETARY,
00041   MESSAGES_LOCALE = 1 << LC_MESSAGES,
00042   PAPER_LOCALE = 1 << LC_PAPER,
00043   NAME_LOCALE = 1 << LC_NAME,
00044   ADDRESS_LOCALE = 1 << LC_ADDRESS,
00045   TELEPHONE_LOCALE = 1 << LC_TELEPHONE,
00046   MEASUREMENT_LOCALE = 1 << LC_MEASUREMENT,
00047   IDENTIFICATION_LOCALE = 1 << LC_IDENTIFICATION,
00048   ALL_LOCALES = (1 << LC_CTYPE
00049                | 1 << LC_NUMERIC
00050                | 1 << LC_TIME
00051                | 1 << LC_COLLATE
00052                | 1 << LC_MONETARY
00053                | 1 << LC_MESSAGES
00054                | 1 << LC_PAPER
00055                | 1 << LC_NAME
00056                | 1 << LC_ADDRESS
00057                | 1 << LC_TELEPHONE
00058                | 1 << LC_MEASUREMENT
00059                | 1 << LC_IDENTIFICATION)
00060 };
00061 
00062 
00063 /* Opaque types for the different locales.  */
00064 struct locale_ctype_t;
00065 struct locale_collate_t;
00066 struct locale_monetary_t;
00067 struct locale_numeric_t;
00068 struct locale_time_t;
00069 struct locale_messages_t;
00070 struct locale_paper_t;
00071 struct locale_name_t;
00072 struct locale_address_t;
00073 struct locale_telephone_t;
00074 struct locale_measurement_t;
00075 struct locale_identification_t;
00076 
00077 
00078 /* Definitions for the locale.  */
00079 struct localedef_t
00080 {
00081   struct localedef_t *next;
00082 
00083   const char *name;
00084 
00085   int needed;
00086   int avail;
00087 
00088   union
00089   {
00090     void *generic;
00091     struct locale_ctype_t *ctype;
00092     struct locale_collate_t *collate;
00093     struct locale_monetary_t *monetary;
00094     struct locale_numeric_t *numeric;
00095     struct locale_time_t *time;
00096     struct locale_messages_t *messages;
00097     struct locale_paper_t *paper;
00098     struct locale_name_t *name;
00099     struct locale_address_t *address;
00100     struct locale_telephone_t *telephone;
00101     struct locale_measurement_t *measurement;
00102     struct locale_identification_t *identification;
00103   } categories[__LC_LAST];
00104 
00105   size_t len[__LC_LAST];
00106 
00107   const char *copy_name[__LC_LAST];
00108 
00109   const char *repertoire_name;
00110 };
00111 
00112 
00113 /* Global variables of the localedef program.  */
00114 extern int verbose;
00115 extern int be_quiet;
00116 extern int oldstyle_tables;
00117 extern const char *repertoire_global;
00118 extern int max_locarchive_open_retry;
00119 extern bool no_archive;
00120 extern const char *alias_file;
00121 
00122 
00123 /* Prototypes for a few program-wide used functions.  */
00124 extern void *xmalloc (size_t __n);
00125 extern void *xcalloc (size_t __n, size_t __size);
00126 extern void *xrealloc (void *__p, size_t __n);
00127 extern char *xstrdup (const char *__str);
00128 
00129 
00130 /* Wrapper to switch LC_CTYPE back to the locale specified in the
00131    environment for output.  */
00132 #define WITH_CUR_LOCALE(stmt)                                  \
00133   do {                                                  \
00134       int saved_errno = errno;                                 \
00135       const char *cur_locale_ = setlocale (LC_CTYPE, NULL);    \
00136       setlocale (LC_CTYPE, "");                                \
00137       errno = saved_errno;                              \
00138       stmt;                                             \
00139       setlocale (LC_CTYPE, cur_locale_);                \
00140   } while (0)
00141 
00142 
00143 /* Mark given locale as to be read.  */
00144 extern struct localedef_t *add_to_readlist (int locale, const char *name,
00145                                        const char *repertoire_name,
00146                                        int generate,
00147                                        struct localedef_t *copy_locale);
00148 
00149 /* Find the information for the locale NAME.  */
00150 extern struct localedef_t *find_locale (int locale, const char *name,
00151                                    const char *repertoire_name,
00152                                    const struct charmap_t *charmap);
00153 
00154 /* Load (if necessary) the information for the locale NAME.  */
00155 extern struct localedef_t *load_locale (int locale, const char *name,
00156                                    const char *repertoire_name,
00157                                    const struct charmap_t *charmap,
00158                                    struct localedef_t *copy_locale);
00159 
00160 
00161 /* Open the locale archive.  */
00162 extern void open_archive (struct locarhandle *ah, bool readonly);
00163 
00164 /* Close the locale archive.  */
00165 extern void close_archive (struct locarhandle *ah);
00166 
00167 /* Add given locale data to the archive.  */
00168 extern int add_locale_to_archive (struct locarhandle *ah, const char *name,
00169                               locale_data_t data, bool replace);
00170 
00171 /* Add content of named directories to locale archive.  */
00172 extern int add_locales_to_archive (size_t nlist, char *list[], bool replace);
00173 
00174 /* Removed named locales from archive.  */
00175 extern int delete_locales_from_archive (size_t nlist, char *list[]);
00176 
00177 /* List content of locale archive.  */
00178 extern void show_archive_content (int verbose);
00179 
00180 #endif /* localedef.h */