1CATOPEN(3P)                POSIX Programmer's Manual               CATOPEN(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       catopen — open a message catalog
13

SYNOPSIS

15       #include <nl_types.h>
16
17       nl_catd catopen(const char *name, int oflag);
18

DESCRIPTION

20       The catopen() function shall open a message catalog and return  a  mes‐
21       sage  catalog  descriptor.  The name argument specifies the name of the
22       message catalog to be opened. If name contains a '/', then name  speci‐
23       fies  a  pathname  for  the message catalog. Otherwise, the environment
24       variable NLSPATH is used with name substituted for  the  %N  conversion
25       specification (see the Base Definitions volume of POSIX.1‐2017, Chapter
26       8, Environment Variables); if NLSPATH exists in  the  environment  when
27       the process starts, then if the process has appropriate privileges, the
28       behavior of catopen() is undefined. If NLSPATH does not  exist  in  the
29       environment, or if a message catalog cannot be found in any of the com‐
30       ponents specified by NLSPATH, then  an  implementation-defined  default
31       path  shall  be  used.  This  default may be affected by the setting of
32       LC_MESSAGES if the value of oflag is NL_CAT_LOCALE, or the  LANG  envi‐
33       ronment variable if oflag is 0.
34
35       A message catalog descriptor shall remain valid in a process until that
36       process closes it, or a successful call to one of the exec functions. A
37       change in the setting of the LC_MESSAGES category may invalidate exist‐
38       ing open catalogs.
39
40       If a file descriptor is used to implement message catalog  descriptors,
41       the FD_CLOEXEC flag shall be set; see <fcntl.h>.
42
43       If  the value of the oflag argument is 0, the LANG environment variable
44       is used to locate the catalog without regard to the  LC_MESSAGES  cate‐
45       gory.  If the oflag argument is NL_CAT_LOCALE, the LC_MESSAGES category
46       is used to locate the message catalog (see the Base Definitions  volume
47       of POSIX.1‐2017, Section 8.2, Internationalization Variables).
48

RETURN VALUE

50       Upon  successful  completion,  catopen() shall return a message catalog
51       descriptor for use on subsequent calls  to  catgets()  and  catclose().
52       Otherwise,  catopen()  shall return (nl_catd) -1 and set errno to indi‐
53       cate the error.
54

ERRORS

56       The catopen() function may fail if:
57
58       EACCES Search permission is denied for the component of the path prefix
59              of the message catalog or read permission is denied for the mes‐
60              sage catalog.
61
62       EMFILE All file descriptors available  to  the  process  are  currently
63              open.
64
65       ENAMETOOLONG
66              The  length  of  a  component  of  a  pathname  is  longer  than
67              {NAME_MAX}.
68
69       ENAMETOOLONG
70              The length of a pathname exceeds {PATH_MAX}, or pathname resolu‐
71              tion  of  a symbolic link produced an intermediate result with a
72              length that exceeds {PATH_MAX}.
73
74       ENFILE Too many files are currently open in the system.
75
76       ENOENT The message catalog does not exist or the name  argument  points
77              to an empty string.
78
79       ENOMEM Insufficient storage space is available.
80
81       ENOTDIR
82              A  component  of the path prefix of the message catalog names an
83              existing file that is neither a directory nor a symbolic link to
84              a  directory, or the pathname of the message catalog contains at
85              least one non-<slash> character and ends with one or more trail‐
86              ing  <slash> characters and the last pathname component names an
87              existing file that is neither a directory nor a symbolic link to
88              a directory.
89
90       The following sections are informative.
91

EXAMPLES

93       None.
94

APPLICATION USAGE

96       Some  implementations  of  catopen() use malloc() to allocate space for
97       internal buffer areas. The catopen() function  may  fail  if  there  is
98       insufficient storage space available to accommodate these buffers.
99
100       Conforming  applications  must  assume that message catalog descriptors
101       are not valid after a call to one of the exec functions.
102
103       Application developers should be aware that guidelines for the location
104       of  message catalogs have not yet been developed. Therefore they should
105       take care to avoid conflicting with catalogs used by other applications
106       and the standard utilities.
107
108       To be sure that messages produced by an application running with appro‐
109       priate privileges cannot be used by an attacker setting  an  unexpected
110       value for NLSPATH in the environment to confuse a system administrator,
111       such applications should use pathnames containing a '/' to get  defined
112       behavior when using catopen() to open a message catalog.
113

RATIONALE

115       None.
116

FUTURE DIRECTIONS

118       None.
119

SEE ALSO

121       catclose(), catgets()
122
123       The  Base  Definitions  volume  of POSIX.1‐2017, Chapter 8, Environment
124       Variables, <fcntl.h>, <nl_types.h>,
125
127       Portions of this text are reprinted and reproduced in  electronic  form
128       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
129       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
130       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
131       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
132       event of any discrepancy between this version and the original IEEE and
133       The Open Group Standard, the original IEEE and The Open Group  Standard
134       is  the  referee document. The original Standard can be obtained online
135       at http://www.opengroup.org/unix/online.html .
136
137       Any typographical or formatting errors that appear  in  this  page  are
138       most likely to have been introduced during the conversion of the source
139       files to man page format. To report such errors,  see  https://www.ker
140       nel.org/doc/man-pages/reporting_bugs.html .
141
142
143
144IEEE/The Open Group                  2017                          CATOPEN(3P)
Impressum