summaryrefslogtreecommitdiffstats
path: root/upstream/archlinux/man3p/catopen.3p
blob: 44f9b320c8801c00a863ede3765f9b4ac4a194af (plain)
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
'\" et
.TH CATOPEN "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\"
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.\"
.SH NAME
catopen
\(em open a message catalog
.SH SYNOPSIS
.LP
.nf
#include <nl_types.h>
.P
nl_catd catopen(const char *\fIname\fP, int \fIoflag\fP);
.fi
.SH DESCRIPTION
The
\fIcatopen\fR()
function shall open a message catalog and return a message catalog
descriptor. The
.IR name
argument specifies the name of the message catalog to be opened. If
.IR name
contains a
.BR '/' ,
then
.IR name
specifies a pathname for the message catalog. Otherwise, the
environment variable
.IR NLSPATH
is used with
.IR name
substituted for the
.BR %N
conversion specification (see the Base Definitions volume of POSIX.1\(hy2017,
.IR "Chapter 8" ", " "Environment Variables");
if
.IR NLSPATH
exists in the environment when the process starts, then if the process
has appropriate privileges, the behavior of
\fIcatopen\fR()
is undefined. If
.IR NLSPATH
does not exist in the environment, or if a message catalog cannot be
found in any of the components specified by
.IR NLSPATH ,
then an implementation-defined default path shall be used. This default
may be affected by the setting of
.IR LC_MESSAGES
if the value of
.IR oflag
is NL_CAT_LOCALE, or the
.IR LANG
environment variable if
.IR oflag
is 0.
.P
A message catalog descriptor shall remain valid in a process until that
process closes it, or a successful call to one of the
.IR exec
functions. A change in the setting of the
.IR LC_MESSAGES
category may invalidate existing open catalogs.
.P
If a file descriptor is used to implement message catalog descriptors,
the FD_CLOEXEC flag shall be set; see
.IR <fcntl.h> .
.P
If the value of the
.IR oflag
argument is 0, the
.IR LANG
environment variable is used to locate the catalog without regard to
the
.IR LC_MESSAGES
category. If the
.IR oflag
argument is NL_CAT_LOCALE, the
.IR LC_MESSAGES
category is used to locate the message catalog (see the Base Definitions volume of POSIX.1\(hy2017,
.IR "Section 8.2" ", " "Internationalization Variables").
.SH "RETURN VALUE"
Upon successful completion,
\fIcatopen\fR()
shall return a message catalog descriptor for use on subsequent calls to
\fIcatgets\fR()
and
\fIcatclose\fR().
Otherwise,
\fIcatopen\fR()
shall return (\c
.BR nl_catd )
\-1 and set
.IR errno
to indicate the error.
.SH ERRORS
The
\fIcatopen\fR()
function may fail if:
.TP
.BR EACCES
Search permission is denied for the component of the path prefix of the
message catalog or read permission is denied for the message catalog.
.TP
.BR EMFILE
All file descriptors available to the process are currently open.
.TP
.BR ENAMETOOLONG
.br
The length of a component of a pathname is longer than
{NAME_MAX}.
.TP
.BR ENAMETOOLONG
.br
The length of a pathname exceeds
{PATH_MAX},
or pathname resolution of a symbolic link produced an intermediate
result with a length that exceeds
{PATH_MAX}.
.TP
.BR ENFILE
Too many files are currently open in the system.
.TP
.BR ENOENT
The message catalog does not exist or the
.IR name
argument points to an empty string.
.TP
.BR ENOMEM
Insufficient storage space is available.
.TP
.BR ENOTDIR
A component of the path prefix of the message catalog names an existing
file that is neither a directory nor a symbolic link to a directory,
or the pathname of the message catalog contains at least one non-\c
<slash>
character and ends with one or more trailing
<slash>
characters and the last pathname component names an existing file
that is neither a directory nor a symbolic link to a directory.
.LP
.IR "The following sections are informative."
.SH EXAMPLES
None.
.SH "APPLICATION USAGE"
Some implementations of
\fIcatopen\fR()
use
\fImalloc\fR()
to allocate space for internal buffer areas. The
\fIcatopen\fR()
function may fail if there is insufficient storage space available to
accommodate these buffers.
.P
Conforming applications must assume that message catalog descriptors are
not valid after a call to one of the
.IR exec
functions.
.P
Application developers should be aware that guidelines for the location
of message catalogs have not yet been developed. Therefore they should
take care to avoid conflicting with catalogs used by other applications
and the standard utilities.
.P
To be sure that messages produced by an application running with
appropriate privileges cannot be used by an attacker setting an
unexpected value for
.IR NLSPATH
in the environment to confuse a system administrator, such
applications should use pathnames containing a
.BR '/' 
to get defined behavior when using
\fIcatopen\fR()
to open a message catalog.
.SH RATIONALE
None.
.SH "FUTURE DIRECTIONS"
None.
.SH "SEE ALSO"
.IR "\fIcatclose\fR\^(\|)",
.IR "\fIcatgets\fR\^(\|)"
.P
The Base Definitions volume of POSIX.1\(hy2017,
.IR "Chapter 8" ", " "Environment Variables",
.IR "\fB<fcntl.h>\fP",
.IR "\fB<nl_types.h>\fP",
.\"
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1-2017, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 7, 2018 Edition,
Copyright (C) 2018 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group.
In the event of any discrepancy between this version 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 .
.PP
Any typographical or formatting errors that appear
in this page are most likely
to have been introduced during the conversion of the source files to
man page format. To report such errors, see
https://www.kernel.org/doc/man-pages/reporting_bugs.html .