catclose() — Close Message Catalog
Format
#include <nl_types.h>
int catclose (nl_catd catd);
Language Level
XPG4
Threadsafe
Yes
Locale Sensitive
This function is not available when LOCALETYPE(*CLD) is specified on the compilation command.
Integrated File System Interface
This function is not available when SYSIFCOPT(*NOIFSIO) is specified on the compilation command.
Description
The catclose()
function
closes the previously opened message catalog that is identified by catd.
Return Value
If the close is performed successfully, 0 is returned. Otherwise, -1 is returned indicating failure, which might happen if catd is not a valid message catalog descriptor.
The value of errno can be set to:
- EBADF
- The catalog descriptor is not valid.
- EINTR
- The function was interrupted by a signal.
Example
#include <stdio.h>
#include <nl_types.h>
#include <locale.h>
/* Name of the message catalog is "/qsys.lib/mylib.lib/msgs.usrspc" */
int main(void) {
nl_catd msg_file;
char * my_msg;
char * my_locale;
setlocale(LC_ALL, NULL);
msg_file = catopen("/qsys.lib/mylib.lib/msgs.usrspc", 0);
if (msg_file != CATD_ERR) {
my_msg = catgets(msg_file, 1, 2, "oops");
printf("%s\n", my_msg);
catclose(msg_file);
}
}