1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
'\" te
.\" Copyright 1989 AT&T Copyright (c) 1995, Sun Microsystems, Inc. All Rights Reserved Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
.\" This notice shall appear on any product containing this material.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH CATOPEN 3C "Dec 29, 1996"
.SH NAME
catopen, catclose \- open/close a message catalog
.SH SYNOPSIS
.LP
.nf
#include <nl_types.h>
\fBnl_catd\fR \fBcatopen\fR(\fBconst char *\fR\fIname\fR, \fBint\fR \fIoflag\fR);
.fi
.LP
.nf
\fBint\fR \fBcatclose\fR(\fBnl_catd\fR \fIcatd\fR);
.fi
.SH DESCRIPTION
.sp
.LP
The \fBcatopen()\fR function opens a message catalog and returns a message
catalog descriptor. \fIname\fR specifies the name of the message catalog to be
opened. If \fIname\fR contains a "/", then \fIname\fR specifies a complete
pathname for the message catalog; otherwise, the environment variable
\fBNLSPATH\fR is used and \fB/usr/lib/locale/\fR\fIlocale\fR\fB/LC_MESSAGES\fR
must exist. If \fBNLSPATH\fR does not exist in the environment, or if a message
catalog cannot be opened in any of the paths specified by \fBNLSPATH\fR, then
the default path \fB/usr/lib/locale/\fR\fIlocale\fR\fB/LC_MESSAGES\fR is used.
In the "C" locale, \fBcatopen()\fR will always succeed without checking the
default search path.
.sp
.LP
The names of message catalogs and their location in the filesystem can vary
from one system to another. Individual applications can choose to name or
locate message catalogs according to their own special needs. A mechanism is
therefore required to specify where the catalog resides.
.sp
.LP
The \fBNLSPATH\fR variable provides both the location of message catalogs, in
the form of a search path, and the naming conventions associated with message
catalog files. For example:
.sp
.in +2
.nf
NLSPATH=/nlslib/%L/%N.cat:/nlslib/%N/%L
.fi
.in -2
.sp
.LP
The metacharacter \fB%\fR introduces a substitution field, where \fB%L\fR
substitutes the current setting of either the \fBLANG\fR environment variable,
if the value of \fIoflag\fR is \fB0\fR, or the \fBLC_MESSAGES\fR category, if
the value of \fIoflag\fR is \fBNL_CAT_LOCALE\fR, and \fB%N\fR substitutes the
value of the \fIname\fR parameter passed to \fBcatopen()\fR. Thus, in the above
example, \fBcatopen()\fR will search in \fB/nlslib/$LANG/\fIname\fR.cat\fR, if
\fIoflag\fR is \fB0\fR, or in \fB/nlslib/{LC_MESSAGES}/\fIname\fR.cat\fR, if
\fIoflag\fR is \fBNL_CAT_LOCALE\fR.
.sp
.LP
The \fBNLSPATH\fR variable will normally be set up on a system wide basis (in
\fB/etc/profile\fR) and thus makes the location and naming conventions
associated with message catalogs transparent to both programs and users.
.sp
.LP
The full set of metacharacters is:
.sp
.ne 2
.na
\fB\fB%N\fR\fR
.ad
.RS 6n
The value of the name parameter passed to \fBcatopen()\fR.
.RE
.sp
.ne 2
.na
\fB\fB%L\fR\fR
.ad
.RS 6n
The value of \fBLANG\fR or \fBLC_MESSAGES\fR.
.RE
.sp
.ne 2
.na
\fB\fB%l\fR\fR
.ad
.RS 6n
The value of the \fIlanguage\fR element of \fBLANG\fR or \fBLC_MESSAGES\fR.
.RE
.sp
.ne 2
.na
\fB\fB%t\fR\fR
.ad
.RS 6n
The value of the \fIterritory\fR element of \fBLANG\fR or \fBLC_MESSAGES\fR.
.RE
.sp
.ne 2
.na
\fB\fB%c\fR\fR
.ad
.RS 6n
The value of the \fIcodeset\fR element of \fBLANG\fR or \fBLC_MESSAGES\fR.
.RE
.sp
.ne 2
.na
\fB\fB%%\fR\fR
.ad
.RS 6n
A single %.
.RE
.sp
.LP
The \fBLANG\fR environment variable provides the ability to specify the user's
requirements for native languages, local customs and character set, as an ASCII
string in the form
.sp
.in +2
.nf
LANG=language[_territory[.codeset]]
.fi
.in -2
.sp
.LP
A user who speaks German as it is spoken in Austria and has a terminal which
operates in ISO 8859/1 codeset, would want the setting of the LANG variable to
be
.sp
.in +2
.nf
LANG=De_A.88591
.fi
.in -2
.sp
.LP
With this setting it should be possible for that user to find any relevant
catalogs should they exist.
.sp
.LP
Should the \fBLANG\fR variable not be set, the value of \fBLC_MESSAGES\fR as
returned by \fBsetlocale()\fR is used. If this is \fINULL,\fR the default path
as defined in <\fBnl_types.h\fR> is used.
.sp
.LP
A message catalogue descriptor remains valid in a process until that process
closes it, or a successful call to one of the \fBexec\fR functions. A change in
the setting of the \fBLC_MESSAGES\fR category may invalidate existing open
catalogues.
.sp
.LP
If a file descriptor is used to implement message catalogue descriptors, the
\fBFD_CLOEXEC\fR flag will be set; see <\fBfcntl.h\fR>.
.sp
.LP
If the value of \fIoflag\fR argument is \fB0\fR, the \fBLANG\fR environment
variable is used to locate the catalogue without regard to the
\fBLC_MESSAGES\fR category. If the \fIoflag\fR argument is
\fBNL_CAT_LOCALE\fR, the \fBLC_MESSAGES\fR category is used to locate the
message catalogue.
.sp
.LP
The \fBcatclose()\fR function closes the message catalog identified by
\fIcatd\fR. If a file descriptor is used to implement the type \fBnl_catd\fR,
that file descriptor will be closed.
.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fBcatopen()\fR returns a message catalog
descriptor for use on subsequent calls to \fBcatgets()\fR and
\fBcatclose()\fR. Otherwise it returns \fB(nl_catd) \(mi1\fR.
.sp
.LP
Upon successful completion, \fBcatclose()\fR returns 0. Otherwise it returns
\(mi1 and sets \fBerrno\fR to indicate the error.
.SH ERRORS
.sp
.LP
The \fBcatopen()\fR function may fail if:
.sp
.ne 2
.na
\fB\fBEACCES\fR\fR
.ad
.RS 16n
Search permission is denied for the component of the path prefix of the message
catalogue or read permission is denied for the message catalogue.
.RE
.sp
.ne 2
.na
\fB\fBEMFILE\fR\fR
.ad
.RS 16n
There are \fBOPEN_MAX\fR file descriptors currently open in the calling
process.
.RE
.sp
.ne 2
.na
\fB\fBENAMETOOLONG\fR\fR
.ad
.RS 16n
The length of the pathname of the message catalogue exceeds \fIPATH_MAX\fR, or
a pathname component is longer than \fINAME_MAX\fR.
.RE
.sp
.ne 2
.na
\fB\fBENAMETOOLONG\fR\fR
.ad
.RS 16n
Pathname resolution of a symbolic link produced an intermediate result whose
length exceeds \fIPATH_MAX\fR.
.RE
.sp
.ne 2
.na
\fB\fBENFILE\fR\fR
.ad
.RS 16n
Too many files are currently open in the system.
.RE
.sp
.ne 2
.na
\fB\fBENOENT\fR\fR
.ad
.RS 16n
The message catalogue does not exist or the \fIname\fR argument points to an
empty string.
.RE
.sp
.ne 2
.na
\fB\fBENOMEM\fR\fR
.ad
.RS 16n
Insufficient storage space is available.
.RE
.sp
.ne 2
.na
\fB\fBENOTDIR\fR\fR
.ad
.RS 16n
A component of the path prefix of the message catalogue is not a directory.
.RE
.sp
.LP
The \fBcatclose()\fR function may fail if:
.sp
.ne 2
.na
\fB\fBEBADF\fR\fR
.ad
.RS 9n
The catalogue descriptor is not valid.
.RE
.sp
.ne 2
.na
\fB\fBEINTR\fR\fR
.ad
.RS 9n
The \fBcatclose()\fR function was interrupted by a signal.
.RE
.SH USAGE
.sp
.LP
The \fBcatopen()\fR and \fBcatclose()\fR functions can be used safely in
multithreaded applications, as long as \fBsetlocale\fR(3C) is not being called
to change the locale.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Standard
_
MT-Level MT-Safe
.TE
.SH SEE ALSO
.sp
.LP
\fBgencat\fR(1), \fBcatgets\fR(3C), \fBgettext\fR(3C), \fBnl_types.h\fR(3HEAD),
\fBsetlocale\fR(3C), \fBattributes\fR(5), \fBenviron\fR(5)
|