malloc_get_state.3: tfix
[man-pages.git] / man3 / catopen.3
blob4fc327add23ca83d09917877e93970df2da05a39
1 '\" t
2 .\" Copyright 1993 Mitchum DSouza <m.dsouza@mrc-applied-psychology.cambridge.ac.uk>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" Modified Thu Dec 13 22:51:19 2001 by Martin Schulze <joey@infodrom.org>
7 .\" Modified 2001-12-14 aeb
8 .\"
9 .TH catopen 3 (date) "Linux man-pages (unreleased)"
10 .SH NAME
11 catopen, catclose \- open/close a message catalog
12 .SH LIBRARY
13 Standard C library
14 .RI ( libc ", " \-lc )
15 .SH SYNOPSIS
16 .nf
17 .B #include <nl_types.h>
19 .BI "nl_catd catopen(const char *" name ", int " flag );
20 .BI "int catclose(nl_catd " catalog );
21 .fi
22 .SH DESCRIPTION
23 The function
24 .BR catopen ()
25 opens a message catalog and returns a catalog descriptor.
26 The descriptor remains valid until
27 .BR catclose ()
29 .BR execve (2).
30 If a file descriptor is used to implement catalog descriptors,
31 then the
32 .B FD_CLOEXEC
33 flag will be set.
35 The argument
36 .I name
37 specifies the name of the message catalog to be opened.
39 .I name
40 specifies an absolute path (i.e., contains a \[aq]/\[aq]),
41 then
42 .I name
43 specifies a pathname for the message catalog.
44 Otherwise, the environment variable
45 .B NLSPATH
46 is used with
47 .I name
48 substituted for
49 .B %N
50 (see
51 .BR locale (7)).
52 It is unspecified whether
53 .B NLSPATH
54 will be used when the process has root privileges.
56 .B NLSPATH
57 does not exist in the environment,
58 or if a message catalog cannot be opened
59 in any of the paths specified by it,
60 then an implementation defined path is used.
61 This latter default path may depend on the
62 .B LC_MESSAGES
63 locale setting when the
64 .I flag
65 argument is
66 .B NL_CAT_LOCALE
67 and on the
68 .B LANG
69 environment variable when the
70 .I flag
71 argument is 0.
72 Changing the
73 .B LC_MESSAGES
74 part of the locale may invalidate
75 open catalog descriptors.
77 The
78 .I flag
79 argument to
80 .BR catopen ()
81 is used to indicate the source for the language to use.
82 If it is set to
83 .BR NL_CAT_LOCALE ,
84 then it will use the current locale setting for
85 .BR LC_MESSAGES .
86 Otherwise, it will use the
87 .B LANG
88 environment variable.
90 The function
91 .BR catclose ()
92 closes the message catalog identified by
93 .IR catalog .
94 It invalidates any subsequent references to the message catalog
95 defined by
96 .IR catalog .
97 .SH RETURN VALUE
98 The function
99 .BR catopen ()
100 returns a message catalog descriptor of type
101 .I nl_catd
102 on success.
103 On failure, it returns
104 .I (nl_catd)\~\-1
105 and sets
106 .I errno
107 to indicate the error.
108 The possible error values include all
109 possible values for the
110 .BR open (2)
111 call.
113 The function
114 .BR catclose ()
115 returns 0 on success, or \-1 on failure.
116 .SH ENVIRONMENT
118 .B LC_MESSAGES
119 May be the source of the
120 .B LC_MESSAGES
121 locale setting, and thus
122 determine the language to use if
123 .I flag
124 is set to
125 .BR NL_CAT_LOCALE .
127 .B LANG
128 The language to use if
129 .I flag
130 is 0.
131 .SH ATTRIBUTES
132 For an explanation of the terms used in this section, see
133 .BR attributes (7).
135 allbox;
136 lbx lb lb
137 l l l.
138 Interface       Attribute       Value
142 .BR catopen ()
143 T}      Thread safety   MT-Safe env
147 .BR catclose ()
148 T}      Thread safety   MT-Safe
150 .SH VERSIONS
151 The above is the POSIX.1 description.
152 The glibc value for
153 .B NL_CAT_LOCALE
154 is 1.
155 .\" (Compare
156 .\" .B MCLoadAll
157 .\" below.)
158 The default path varies, but usually looks at a number of places below
159 .IR /usr/share/locale .
160 .\" .SS Linux notes
161 .\" These functions are available for Linux since libc 4.4.4c.
162 .\" In the case of linux libc4 and libc5, the catalog descriptor
163 .\" .I nl_catd
164 .\" is a
165 .\" .BR mmap (2)'ed
166 .\" area of memory and not a file descriptor.
167 .\" The
168 .\" .I flag
169 .\" argument to
170 .\" .BR catopen ()
171 .\" should be either
172 .\" .B MCLoadBySet
173 .\" (=0) or
174 .\" .B MCLoadAll
175 .\" (=1).
176 .\" The former value indicates that a set from the catalog is to be
177 .\" loaded when needed, whereas the latter causes the initial call to
178 .\" .BR catopen ()
179 .\" to load the entire catalog into memory.
180 .\" The default search path varies, but usually looks at a number of places below
181 .\" .I /etc/locale
182 .\" and
183 .\" .IR /usr/lib/locale .
184 .SH STANDARDS
185 POSIX.1-2008.
186 .SH HISTORY
187 POSIX.1-2001.
188 .\" In XPG 1987, Vol. 3 it says:
189 .\" .I "The flag argument of catopen is reserved for future use"
190 .\" .IR "and should be set to 0" .
192 .\" It is unclear what the source was for the constants
193 .\" .B MCLoadBySet
194 .\" and
195 .\" .B MCLoadAll
196 .\" (see below).
197 .SH SEE ALSO
198 .BR catgets (3),
199 .BR setlocale (3)