Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

catopen - open message catalog

&pagelevel(4)&pagelevel

Syntax

#include <nl_types.h>

nl_catd catopen(const char *name, int oflag);

Description

catopen() opens a message catalog and returns a message catalog descriptor.
The name argument specifies the name of the message catalog to be opened. If name
contains a "/", then name is interpreted as an absolute pathname for the message catalog.
Otherwise, the environment variable NLSPATH is evaluated and used with name substituted
for %N (see also section “Locale”).

If the environment variable NLSPATH does not exist or if a message catalog cannot be found
in any of the path components specified by NLSPATH, then the default path is used (see
nl_types.h).

If the value of oflag is NL_CAT_LOCALE, the default is determined by the category
LC_MESSAGES.

If oflag is 0, only the LANG environment variable is evaluated, regardless of the contents of
the LC_MESSAGES category (see also section “Environment variables”).

A message catalog descriptor remains valid in a process until it is closed by that process or
by a successful call to one of the exec functions. A change in the LC_MESSAGES category
can make existing open catalogs invalid.

If a file descriptor is used to define message catalog descriptors, the FD_CLOEXEC bit is set
(see also fcntl.h).

Return val.

Message catalog descriptor

if successful. This message catalog descriptor can then be used on subsequent
calls to catgets() and catclose().

(nl_catd) -1 if unsuccessful. errno is set to indicate the error.

Errors

catopen() will fail if:

EACCES

Search permission is denied for a component of the path prefix of the
message catalog
or read permission is denied for the message catalog.

EMFILE

The process uses more than {OPEN_MAX} file descriptors at one time.

ENAMETOOLONG


The length of the pathname of the message catalog exceeds {PATH_MAX},
or a pathname component is longer than {NAME_MAX}, or the resolution of
a symbolic link produces an interim result that is longer than {PATH_MAX}.

ENFILE

ENOENT

Too many files are currently open in the system.

The message catalog does not exist,
or the name argument points to an empty string

ENOMEM

ENOTDIR

Insufficient storage space is available.

A component of the path prefix of the message catalog is not a directory.

Notes

catopen() uses malloc() to allocate space for internal buffer areas. The catopen()
function may fail if there is insufficient storage space available to accommodate these
buffers.

Portable applications must assume that message catalog descriptors are not valid after a
call to one of the exec functions.

Every application must store the associated message catalog in one of the default
directories defined by DEF_NLSPATH in a format that allows it to be found on substitution of
name for %N (see also nl_types.h).

See also

catclose(), catgets(), fcntl.h, nl_types.h, section “Locale” and
section “Environment variables”.