catopen, catclose -- open/close a message catalog


cc . . . -lc

#include  <nl_types.h>

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

int catclose (catd) nl_catd catd;


catopen(S) opens a message catalog generated by the gencat(CP) utility and returns a catalog descriptor for use by catgets(S). The name argument is the name of the message catalog to be opened.

catclose( ) closes the message catalog identified by the catd catalog descriptor.

If name contains a ``/'' then name specifies a pathname for the message catalog. Otherwise, name must be of the form


The pathname for the message catalog in this case is constructed from the environment variable $NLSPATH (see environ(M)) by substituting the %N component of $NLSPATH by filename and the optional %A component by archivename. If archivename is specified, catgets( ) accesses the message catalog in an archived directory.

If the environment variable $NLSPATH is not set, or if a message catalog can not be opened in any of the paths specified by $NLSPATH, then the default paths matching the following templates are used:



In these templates,

is the current value of the LC_MESSAGES category, or, if not set, C by default

is the language component from the LC_MESSAGES category

is the territory component from the LC_MESSAGES category

is the optional archive component (archivename) of the message catalog name

is the file component (filename) of the message catalog name
If the optional archive component, archivename, is not specified in name, %A is omitted when constructing pathnames for the message catalog from these templates.

The pathnames for the message catalog constructed from these templates or the environment variable $NLSPATH may be affected by the current setting of LC_MESSAGES if oflag has the value NL_CAT_LOCALE, or by the current setting of the LANG if oflag is 0.

oflag must have one of the following values. Setting oflag to any other values causes undefined behavior.

The current value of LANG is used to locate the catalog and the value of LC_MESSAGES is ignored.

The current value of LC_MESSAGES is used to locate the message catalog.

The environment variable $NLSPATH is used to locate the message catalog even if name contains a ``/''.

Return values

If successful, catopen( ) returns a message catalog descriptor for use on subsequent calls to catgets(S) and catclose( ). If unsuccessful, catopen( ) returns (nl_catd)-1.

catclose( ) returns 0 if successful; otherwise it returns -1.


The catopen( ) routine fails if one of the following is true:

Insufficient storage space is available.

The LANG variable is not defined or contains incorrect data.

No message file was found according to $NLSPATH.

Out of memory.

The catclose( ) routine fails if the following is true:

The message file could not be found or the message catalog file descriptor has already been closed.


Using catopen( ) may cause another file descriptor to be allocated by the calling process, in addition to stdin, stdout and stderr. Applications should take care not to close this file descriptor by mistake.

See also

catgets(S), environ(M), gencat(CP), mkmsgs(CP)

``Constructing and using message catalogs'' in Developer's Topics

Standards conformance

catopen(S) and catclose(S) are conformant with:

X/Open Portability Guide, Issue 3, 1989 .

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003