Opens a message catalog.
#include <nl_types.h> nl_catd catopen (const char *name, int oflag);
NLSPATH consists of one or more templates. The catopen function uses each template to construct a file specification. For example, NLSPATH could be defined as:
DEFINE NLSPATH SYS$SYSROOT:[SYS$I18N.MSG]%N.CAT,SYS$COMMON:[SYSMSG]%N.CAT
In this example, catopen first searches the directory SYS$SYSROOT:[SYS$I18N.MSG] for the named catalog. If the named catalog is not found there, the directory SYS$COMMON:[SYSMSG] is searced. The catalog name is constructed by substituting %N with the name passed to catopen, and adding the .cat suffix. %N is known as a substitution field. The following substitution fields are valid:
Field | Meaning |
---|---|
%N | Substitute the name passed to catopen |
%L | Substitute the
name of the locale from the LANG environment variable or as defined
for the LC_MESSAGES category of the current locale.
The period (.) and at-sign (@) characters in the specified name are replaced by an underscore (_) character. For example, a locale name of "zh_CN.dechanzi@radical" results in a substitution of ZH_CN_DECHANZI_RADICAL. |
%l [1] | Substitute the language part of the locale name. For example, if the current locale is en_GB.ISO8859-1, then the language part is en. |
%t [1] | Substitute the territory part of the locale name. For example, if the current locale is en_GB.ISO8859-1, then the territory part is GB. |
%c [1] | Substitute the codeset name from the locale name. For example, if the current locale is en_ GB.ISO8859-1, then the codeset name is ISO8859-1. |
[1] This substitution assumes that the locale name is of the form language_ territory.codeset@mode |
If the oflag argument is set to NL_CAT_LOCALE, then the current locale as defined for the LC_MESSAGES category is used to determine the substitution for the %L, %l, %t, and %c substitution fields. If the oflag argument is set to 0, then the value of the LANG environment variable is used as a locale name to determine the substitution for these fields. Note that using NL_ CAT_LOCALE conforms to the XPG4 specification while a value of 0 (zero) exists for the purpose of preserving XPG3 compatibility.
If the substitution value is not defined, an empty string is substituted.
Each template is separated by a comma (,). A leading comma or two adjacent commas (,,) is equivalent to specifying %N. For example,
DEFINE NLSPATH ",%N.CAT,SYS$COMMON:[SYSMSG.%L]%N.CAT"
In this example, catopen searches in the following locations in the order shown:
x | A message catalog file descriptor. Indicates the call was successful. This descriptor is used in calls to catgets and catopen. |
(nl_catd) -1 | Indicates an error occurred. The function sets
errno to one of the following values:
|