]> sourceware.org Git - glibc.git/blame - intl/libintl.h
Update from main archive 961219
[glibc.git] / intl / libintl.h
CommitLineData
036cc82f 1/* libintl.h -- Message catalogs for internationalization.
54d79e99
UD
2 Copyright (C) 1995, 1996 Free Software Foundation, Inc.
3 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
4 This file is derived from the file libgettext.h in the GNU gettext package.
2b83a2a4 5
54d79e99
UD
6 This file is part of the GNU C Library. Its master source is NOT part of
7 the C library, however. The master source lives in /gd/gnu/lib.
0393dfd6 8
54d79e99
UD
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
2b83a2a4 13
54d79e99
UD
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
2b83a2a4 18
54d79e99
UD
19 You should have received a copy of the GNU Library General Public
20 License along with the GNU C Library; see the file COPYING.LIB. If not,
21 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
2b83a2a4
RM
23
24#ifndef _LIBINTL_H
036cc82f 25
c709e372
RM
26#define _LIBINTL_H 1
27#include <features.h>
2b83a2a4 28
c709e372
RM
29/* We define an additional symbol to signal that we use the GNU
30 implementation of gettext. */
31#define __USE_GNU_GETTEXT 1
32
33__BEGIN_DECLS
2b83a2a4
RM
34
35/* Look up MSGID in the current default message catalog for the current
36 LC_MESSAGES locale. If not found, returns MSGID itself (the default
37 text). */
be10a868
RM
38extern char *gettext __P ((__const char *__msgid));
39extern char *__gettext __P ((__const char *__msgid));
2b83a2a4
RM
40
41/* Look up MSGID in the DOMAINNAME message catalog for the current
42 LC_MESSAGES locale. */
be10a868
RM
43extern char *dgettext __P ((__const char *__domainname,
44 __const char *__msgid));
45extern char *__dgettext __P ((__const char *__domainname,
46 __const char *__msgid));
2b83a2a4
RM
47
48/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
49 locale. */
be10a868
RM
50extern char *dcgettext __P ((__const char *__domainname,
51 __const char *__msgid, int __category));
52extern char *__dcgettext __P ((__const char *__domainname,
53 __const char *__msgid, int __category));
2b83a2a4
RM
54
55
56/* Set the current default message catalog to DOMAINNAME.
57 If DOMAINNAME is null, return the current default.
58 If DOMAINNAME is "", reset to the default of "messages". */
be10a868
RM
59extern char *textdomain __P ((__const char *__domainname));
60extern char *__textdomain __P ((__const char *__domainname));
2b83a2a4
RM
61
62/* Specify that the DOMAINNAME message catalog will be found
63 in DIRNAME rather than in the system locale data base. */
be10a868
RM
64extern char *bindtextdomain __P ((__const char *__domainname,
65 __const char *__dirname));
66extern char *__bindtextdomain __P ((__const char *__domainname,
67 __const char *__dirname));
c709e372 68
2b83a2a4 69
c709e372 70/* Optimized version of the function above. */
036cc82f
RM
71#if defined __OPTIMIZE__
72
73/* We need NULL for `gettext'. */
74#define __need_NULL
75#include <stddef.h>
76
77/* We need LC_MESSAGES for `dgettext'. */
78# include <locale.h>
79
80/* These must be macros. Inlined functions are useless because the
c709e372
RM
81 `__builtin_constant_p' predicate in dcgettext would always return
82 false. */
2b83a2a4 83
be10a868 84# define gettext(msgid) dgettext (NULL, msgid)
2b83a2a4 85
be10a868 86# define dgettext(domainname, msgid) \
c709e372 87 dcgettext (domainname, msgid, LC_MESSAGES)
2b83a2a4 88
c709e372 89# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
036cc82f
RM
90/* Variable defined in loadmsgcat.c which gets incremented every time a
91 new catalog is loaded. */
92extern int _nl_msg_cat_cntr;
93
c709e372 94# define dcgettext(domainname, msgid, category) \
2b83a2a4
RM
95 (__extension__ \
96 ({ \
036cc82f 97 char *__result; \
c709e372
RM
98 if (__builtin_constant_p (msgid)) \
99 { \
c709e372
RM
100 static char *__translation__; \
101 static int __catalog_counter__; \
102 if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr) \
103 { \
104 __translation__ = \
105 __dcgettext ((domainname), (msgid), (category)); \
106 __catalog_counter__ = _nl_msg_cat_cntr; \
107 } \
036cc82f 108 __result = __translation__; \
c709e372
RM
109 } \
110 else \
036cc82f
RM
111 __result = __dcgettext ((domainname), (msgid), (category)); \
112 __result; \
2b83a2a4 113 }))
c709e372
RM
114# endif
115#endif /* Optimizing. */
116
117
118__END_DECLS
2b83a2a4 119
c709e372 120#endif /* libintl.h */
This page took 0.062002 seconds and 5 git commands to generate.