1999-08-31 07:04:41 +00:00
|
|
|
/* General definitions for localedef(1).
|
2017-01-01 00:14:16 +00:00
|
|
|
Copyright (C) 1998-2017 Free Software Foundation, Inc.
|
1999-08-31 07:04:41 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
|
|
|
|
2005-12-07 05:49:17 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
2007-07-16 00:56:07 +00:00
|
|
|
it under the terms of the GNU General Public License as published
|
|
|
|
by the Free Software Foundation; version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
1999-08-31 07:04:41 +00:00
|
|
|
|
2005-12-07 05:49:17 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
1999-08-31 07:04:41 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2005-12-07 05:49:17 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
1999-08-31 07:04:41 +00:00
|
|
|
|
2005-12-07 05:49:17 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
2012-02-09 23:18:22 +00:00
|
|
|
along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
1999-08-31 07:04:41 +00:00
|
|
|
|
|
|
|
#ifndef _LOCALEDEF_H
|
|
|
|
#define _LOCALEDEF_H 1
|
|
|
|
|
|
|
|
/* Get the basic locale definitions. */
|
2002-04-18 08:08:23 +00:00
|
|
|
#include <errno.h>
|
1999-08-31 07:04:41 +00:00
|
|
|
#include <locale.h>
|
2002-04-18 08:08:23 +00:00
|
|
|
#include <stdbool.h>
|
1999-08-31 07:04:41 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include "repertoire.h"
|
2002-04-18 08:08:23 +00:00
|
|
|
#include "../locarchive.h"
|
1999-08-31 07:04:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* We need a bitmask for the locales. */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CTYPE_LOCALE = 1 << LC_CTYPE,
|
|
|
|
NUMERIC_LOCALE = 1 << LC_NUMERIC,
|
|
|
|
TIME_LOCALE = 1 << LC_TIME,
|
|
|
|
COLLATE_LOCALE = 1 << LC_COLLATE,
|
|
|
|
MONETARY_LOCALE = 1 << LC_MONETARY,
|
|
|
|
MESSAGES_LOCALE = 1 << LC_MESSAGES,
|
|
|
|
PAPER_LOCALE = 1 << LC_PAPER,
|
|
|
|
NAME_LOCALE = 1 << LC_NAME,
|
|
|
|
ADDRESS_LOCALE = 1 << LC_ADDRESS,
|
|
|
|
TELEPHONE_LOCALE = 1 << LC_TELEPHONE,
|
|
|
|
MEASUREMENT_LOCALE = 1 << LC_MEASUREMENT,
|
|
|
|
IDENTIFICATION_LOCALE = 1 << LC_IDENTIFICATION,
|
|
|
|
ALL_LOCALES = (1 << LC_CTYPE
|
|
|
|
| 1 << LC_NUMERIC
|
|
|
|
| 1 << LC_TIME
|
|
|
|
| 1 << LC_COLLATE
|
|
|
|
| 1 << LC_MONETARY
|
|
|
|
| 1 << LC_MESSAGES
|
|
|
|
| 1 << LC_PAPER
|
|
|
|
| 1 << LC_NAME
|
|
|
|
| 1 << LC_ADDRESS
|
|
|
|
| 1 << LC_TELEPHONE
|
|
|
|
| 1 << LC_MEASUREMENT
|
|
|
|
| 1 << LC_IDENTIFICATION)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Opaque types for the different locales. */
|
|
|
|
struct locale_ctype_t;
|
|
|
|
struct locale_collate_t;
|
|
|
|
struct locale_monetary_t;
|
|
|
|
struct locale_numeric_t;
|
|
|
|
struct locale_time_t;
|
|
|
|
struct locale_messages_t;
|
|
|
|
struct locale_paper_t;
|
|
|
|
struct locale_name_t;
|
|
|
|
struct locale_address_t;
|
|
|
|
struct locale_telephone_t;
|
|
|
|
struct locale_measurement_t;
|
|
|
|
struct locale_identification_t;
|
|
|
|
|
|
|
|
|
|
|
|
/* Definitions for the locale. */
|
|
|
|
struct localedef_t
|
|
|
|
{
|
|
|
|
struct localedef_t *next;
|
|
|
|
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
int needed;
|
|
|
|
int avail;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
void *generic;
|
|
|
|
struct locale_ctype_t *ctype;
|
|
|
|
struct locale_collate_t *collate;
|
|
|
|
struct locale_monetary_t *monetary;
|
|
|
|
struct locale_numeric_t *numeric;
|
|
|
|
struct locale_time_t *time;
|
|
|
|
struct locale_messages_t *messages;
|
|
|
|
struct locale_paper_t *paper;
|
|
|
|
struct locale_name_t *name;
|
|
|
|
struct locale_address_t *address;
|
|
|
|
struct locale_telephone_t *telephone;
|
|
|
|
struct locale_measurement_t *measurement;
|
|
|
|
struct locale_identification_t *identification;
|
1999-09-12 08:28:56 +00:00
|
|
|
} categories[__LC_LAST];
|
1999-08-31 07:04:41 +00:00
|
|
|
|
1999-09-12 08:28:56 +00:00
|
|
|
size_t len[__LC_LAST];
|
|
|
|
|
|
|
|
const char *copy_name[__LC_LAST];
|
1999-08-31 07:04:41 +00:00
|
|
|
|
|
|
|
const char *repertoire_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Global variables of the localedef program. */
|
|
|
|
extern int verbose;
|
|
|
|
extern int be_quiet;
|
|
|
|
extern const char *repertoire_global;
|
2002-04-18 08:08:23 +00:00
|
|
|
extern int max_locarchive_open_retry;
|
|
|
|
extern bool no_archive;
|
* locale/loadarchive.c (_nl_load_locale_from_archive): Parse locale
name to find codeset name (if any) and normalize it. If the
normalized name differs, look up only that in the archive.
* locale/programs/locarchive.c (add_locale_to_archive): If the name
contains a codeset, normalize the codeset store only the normalized
name in the archive. If not, add an alias containing the locale's
normalized codeset name. Apply codeset name normalization when
matching entries in the alias file.
* locale/programs/locarchive.c (delete_locales_from_archive): Don't
decrement HEAD->namehash_used here.
(add_locale): Only need to insert name string when name_offset != 0.
* locale/programs/localedef.c (options): Add -A/--alias-file.
(alias_file): New variable.
(parse_opt): Grok -A, set that.
* locale/programs/localedef.h: Declare it.
* locale/programs/locarchive.c (insert_name): New function, broken out
of ...
(add_locale_to_archive): ... here. Call that.
(add_alias): New function.
(add_locale): New static function, add_locale_to_archive renamed.
(add_locale_to_archive): Call that and use add_alias to add an alias
for the name with codeset if the given name lacks it.
(enlarge_archive): Call add_locale instead of add_locale_to_archive.
* locale/Makefile (routines): Add loadarchive.
* locale/loadarchive.c: New file, started from code by Ulrich Drepper.
(_nl_load_locale_from_archive): New function.
* locale/localeinfo.h: Declare it.
* locale/findlocale.c (_nl_find_locale): If using default locale path,
try _nl_load_locale_from_archive first.
* locale/loadlocale.c (_nl_intern_locale_data): New function,
broken out of _nl_load_locale.
(_nl_load_locale): Call that.
* locale/localeinfo.h: Declare it.
(struct locale_data): Replace member `mmaped' with `alloc', an enum.
(struct locale_data): Remove unused member `options'.
* locale/findlocale.c (_nl_remove_locale): Update uses.
* locale/loadlocale.c (_nl_load_locale, _nl_unload_locale): Likewise.
* locale/C-collate.c: Update initializer.
* locale/C-identification.c: Likewise.
* locale/C-measurement.c: Likewise.
* locale/C-telephone.c: Likewise.
* locale/C-address.c: Likewise.
* locale/C-name.c: Likewise.
* locale/C-paper.c: Likewise.
* locale/C-time.c: Likewise.
* locale/C-numeric.c: Likewise.
* locale/C-monetary.c: Likewise.
* locale/C-messages.c : Likewise.
* locale/C-ctype.c: Likewise.
* locale/hashval.h [! LONGBITS]: Include <limits.h> here and
use CHAR_BIT instead of BITSPERBYTE.
* locale/localeinfo.h (_nl_find_locale, _nl_load_locale,
_nl_unload_locale): Add `internal_function attribute_hidden' to decls.
* locale/findlocale.c (_nl_find_locale): Add internal_function to defn.
(_nl_remove_locale): Likewise.
* locale/loadlocale.c (_nl_load_locale, _nl_unload_locale): Likewise.
* locale/findlocale.c (_nl_default_locale_path): New variable.
(_nl_find_locale): If LOCALE_PATH is null, default to that.
* locale/localeinfo.h: Declare it.
* locale/setlocale.c (setlocale): Use _nl_default_locale_path
in place of LOCALEDIR. If no LOCPATH, pass null to _nl_find_locale.
* locale/newlocale.c (__newlocale): Likewise.
* misc/err.c (vwarnx, vwarn): Fix typos in libc_hidden_def uses.
* inet/rexec.c (rexec_af): Add libc_hidden_def.
* sysdeps/generic/morecore.c: Likewise.
* signal/allocrtsig.c (__libc_current_sigrtmin): Likewise.
(__libc_current_sigrtmax): Likewise.
2002-08-08 Roland McGrath <roland@redhat.com>
* locale/loadlocale.c (_nl_load_locale): Don't use MAP_INHERIT.
* catgets/open_catalog.c (__open_catalog): Likewise.
* locale/programs/locarchive.c (INITIAL_NUM_NAMES): Renamed
from typo INITIAL_NUM_NANES.
(create_archive): Update use.
2002-08-10 06:22:37 +00:00
|
|
|
extern const char *alias_file;
|
1999-08-31 07:04:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Prototypes for a few program-wide used functions. */
|
2012-12-30 22:41:42 +00:00
|
|
|
#include <programs/xmalloc.h>
|
1999-08-31 07:04:41 +00:00
|
|
|
|
|
|
|
|
2002-02-05 23:29:24 +00:00
|
|
|
/* Wrapper to switch LC_CTYPE back to the locale specified in the
|
|
|
|
environment for output. */
|
|
|
|
#define WITH_CUR_LOCALE(stmt) \
|
|
|
|
do { \
|
|
|
|
int saved_errno = errno; \
|
|
|
|
const char *cur_locale_ = setlocale (LC_CTYPE, NULL); \
|
|
|
|
setlocale (LC_CTYPE, ""); \
|
|
|
|
errno = saved_errno; \
|
|
|
|
stmt; \
|
|
|
|
setlocale (LC_CTYPE, cur_locale_); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
1999-08-31 07:04:41 +00:00
|
|
|
/* Mark given locale as to be read. */
|
|
|
|
extern struct localedef_t *add_to_readlist (int locale, const char *name,
|
1999-09-12 08:28:56 +00:00
|
|
|
const char *repertoire_name,
|
2000-06-25 18:14:28 +00:00
|
|
|
int generate,
|
|
|
|
struct localedef_t *copy_locale);
|
1999-08-31 07:04:41 +00:00
|
|
|
|
|
|
|
/* Find the information for the locale NAME. */
|
|
|
|
extern struct localedef_t *find_locale (int locale, const char *name,
|
|
|
|
const char *repertoire_name,
|
2001-12-10 01:37:56 +00:00
|
|
|
const struct charmap_t *charmap);
|
1999-08-31 07:04:41 +00:00
|
|
|
|
1999-12-27 05:05:12 +00:00
|
|
|
/* Load (if necessary) the information for the locale NAME. */
|
|
|
|
extern struct localedef_t *load_locale (int locale, const char *name,
|
|
|
|
const char *repertoire_name,
|
2001-12-10 01:37:56 +00:00
|
|
|
const struct charmap_t *charmap,
|
2000-06-25 18:14:28 +00:00
|
|
|
struct localedef_t *copy_locale);
|
1999-12-27 05:05:12 +00:00
|
|
|
|
2002-04-18 08:08:23 +00:00
|
|
|
|
|
|
|
/* Open the locale archive. */
|
Update.
2002-05-11 Jakub Jelinek <jakub@redhat.com>
* include/netinet/in.h (bindresvport_internal): Add prototype.
* include/rpc/auth.h (authunix_create_internal,
authunix_create_default_internal, authnone_create_internal,
authdes_pk_create_internal): Add prototypes.
* include/rpc/clnt.h (clnt_create_internal, clnttcp_create_internal,
clntudp_create_internal, clntudp_bufcreate_internal,
clntunix_create_internal): Add prototypes.
* include/rpc/svc.h (svc_sendreply_internal, svcerr_decode_internal,
svc_getreq_internal, svc_getreq_common_internal,
svc_getreqset_internal, svc_getreq_poll_internal,
svc_register_internal, svc_unregister_internal,
svcudp_create_internal, svcudp_bufcreate_internal): Add prototypes.
* include/rpc/svc_auth.h (_authenticate_internal): Add prototype.
* include/sys/socket.h (__sendto, __recvfrom, __sendmsg, __recvmsg,
__setsockopt, __getsockname, __bind, __listen): Add prototypes.
* inet/rexec.c (rexec_af): Use __listen and __getsockname.
* inet/rcmd.c (rcmd_af): Use __listen.
(rresvport_af): Use __bind.
* sunrpc/clnt_udp.c: Use INTUSE calls to bindresvport,
authunix_create, authunix_create_default, authnone_create,
authdes_pk_create, clnt_create, clnttcp_create, clntudp_create,
clntudp_bufcreate, clntunix_create svc_sendreply, svcerr_decode,
svc_getreq, svc_getreq_common, svc_getreqset, svc_getreq_poll,
svc_register, svc_unregister, svcudp_create, svcudp_bufcreate,
_authenticate, add INTDEF after such function definitions.
Use __listen, __bind, __sendto, __recvfrom, __sendmsg, __recvmsg,
__setsockopt, __getsockname instead of non-__ variants.
* sunrpc/pmap_rmt.c: Likewise.
* sunrpc/rtime.c: Likewise.
* sunrpc/svc_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/svc_unix.c: Likewise.
* sunrpc/bindrsvprt.c: Likewise.
* sunrpc/svc_tcp.c: Likewise.
* sunrpc/auth_none.c: Likewise.
* sunrpc/clnt_raw.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/auth_unix.c: Likewise.
* sunrpc/key_call.c: Likewise.
* sunrpc/clnt_gen.c: Likewise.
* sunrpc/pm_getmaps.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/pmap_clnt.c: Likewise.
* sunrpc/svc_run.c: Likewise.
* sunrpc/svc.c: Likewise.
* sunrpc/svc_simple.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
* sunrpc/auth_des.c: Likewise.
* sunrpc/svc_auth.c: Likewise.
* sysdeps/generic/unwind-dw2-fde.c (__register_frame_info_bases,
__register_frame_info_table_bases, __deregister_frame_info_bases):
Add INTDEF.
(__register_frame_info_bases_internal,
__register_frame_info_table_bases_internal,
__deregister_frame_info_bases_internal): Add prototypes.
(__register_frame_info, __register_frame): Use INTUSE in call to
__register_frame_info_bases.
(__register_frame_info_table): Similarly.
(__deregister_frame_info, __deregister_frame): Similarly.
* sysdeps/generic/sendto.c (__sendto): Renamed from sendto, add
sendto as weak alias.
* sysdeps/mach/hurd/sendto.c: Likewise.
* sysdeps/generic/recvfrom.c (__recvfrom): Renamed from recvfrom, add
recvfrom as weak alias.
* sysdeps/mach/hurd/recvfrom.c: Likewise.
* sysdeps/unix/sysv/aix/recvfrom.c: Likewise.
* sysdeps/generic/recvmsg.c (__recvmsg): Renamed from recvmsg, add
recvmsg as weak alias.
* sysdeps/unix/sysv/aix/recvmsg.c: Likewise.
* sysdeps/generic/sendmsg.c (__sendmsg): Renamed from sendmsg, add
sendmsg as weak alias.
* sysdeps/unix/sysv/aix/sendmsg.c: Likewise.
* sysdeps/generic/setsockopt.c (__setsockopt): Renamed from
setsockopt, add setsockopt as weak alias.
* sysdeps/mach/hurd/setsockopt.c: Likewise.
* sysdeps/generic/bind.c (__bind): Renamed from bind, add bind as
weak alias.
* sysdeps/mach/hurd/bind.c: Likewise.
* sysdeps/generic/listen.c (__listen): Renamed from listen, add listen
as weak alias.
* sysdeps/mach/hurd/listen.c: Likewise.
* sysdeps/generic/getsockname.c (__getsockname): Renamed from
getsockname, add getsockname as weak alias.
* sysdeps/mach/hurd/getsockname.c: Likewise.
* sysdeps/unix/sysv/aix/getsockname.c: Likewise.
* sysdeps/mach/hurd/recvmsg.c (__recvmsg): Add weak alias.
* sysdeps/mach/hurd/sendmsg.c (__sendmsg): Add weak alias.
* sysdeps/unix/inet/syscalls.list (__bind, __listen, __recvmsg,
__recvfrom, __sendmsg, __sendto, __setsockopt): Add aliases.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (__recvmsg, __sendmsg):
Add aliases.
* sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/recvfrom.S (__recvfrom): Add weak alias.
* sysdeps/unix/sysv/linux/recvmsg.S (__recvmsg): Likewise.
* sysdeps/unix/sysv/linux/sendmsg.S (__sendmsg): Likewise.
* sysdeps/unix/sysv/linux/sendto.S (__sendto): Likewise.
* sysdeps/unix/sysv/linux/setsockopt.S (__setsockopt): Likewise.
* sysdeps/unix/sysv/linux/bind.S (__bind): Likewise.
* sysdeps/unix/sysv/linux/listen.S (__listen): Likewise.
* sysdeps/unix/sysv/linux/getsockname.S (__getsockname): Likewise.
2002-05-10 Jakub Jelinek <jakub@redhat.com>
* locale/programs/localedef.h (show_archive_content): Add verbose
argument.
* locale/programs/localedef.c (main): Adjust caller.
* locale/programs/locarchive.c (struct nameent, struct dataent): New.
(nameentcmp, dataentcmp): New functions.
(xstrcmp): Remove.
(show_archive_content): Print verbose listing with --list-archive -v.
* locale/programs/locarchive.c (open_archive): Take extra argument
readonly. If true open file with O_RDONLY and don't create the
archive if it doesn't exist.
Adapt all callers.
(close_archive): Don't do anything if fd element is -1.
* locale/programs/localedef.h (open_archive): Adjust prototype.
* locale/programs/locfile.c (write_all_categories): Adjust open_archive
call.
* malloc/malloc.c (__posix_memalign): Correct check for size of
alignment value [PR libc/3444].
2002-05-15 00:22:23 +00:00
|
|
|
extern void open_archive (struct locarhandle *ah, bool readonly);
|
2002-04-18 08:08:23 +00:00
|
|
|
|
|
|
|
/* Close the locale archive. */
|
|
|
|
extern void close_archive (struct locarhandle *ah);
|
|
|
|
|
|
|
|
/* Add given locale data to the archive. */
|
|
|
|
extern int add_locale_to_archive (struct locarhandle *ah, const char *name,
|
|
|
|
locale_data_t data, bool replace);
|
|
|
|
|
|
|
|
/* Add content of named directories to locale archive. */
|
|
|
|
extern int add_locales_to_archive (size_t nlist, char *list[], bool replace);
|
|
|
|
|
|
|
|
/* Removed named locales from archive. */
|
|
|
|
extern int delete_locales_from_archive (size_t nlist, char *list[]);
|
|
|
|
|
2013-10-19 03:41:30 +00:00
|
|
|
/* List content of locale archive. If FNAME is non-null use that as
|
|
|
|
the locale archive to list, otherwise the default. */
|
|
|
|
extern void show_archive_content (const char *fname,
|
|
|
|
int verbose) __attribute__ ((noreturn));
|
2002-04-18 08:08:23 +00:00
|
|
|
|
1999-08-31 07:04:41 +00:00
|
|
|
#endif /* localedef.h */
|