Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
setlocale_from_msg(3) OSS Library Calls Reference Manual
NAME
setlocale_from_msg - Changes the locale of the process to match the message received on
$RECEIVE
LIBRARY
G-series native OSS processes: /G/system/sysnn/zicnvsrl
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zicnvdll |
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/yicnvdll |
SYNOPSIS
#include <locale.h>
char* setlocale_from_msg(
short msg_tag);
PARAMETERS
msg_tag Message tag of the message from which locale is to be set.
DESCRIPTION
The setlocale_from_msg( ) function sets the locale of the process from the Locale Identifier
(LID) associated with msg_tag. A process can change its locale for a thread/request by calling
this function. This function sets the process’s locale to the client’s preferences. (Note that to set
a server’s locale to its own preference, it calls setlocale( )).
The main difference between setlocale_from_msg( ) and setlocale( ) is that
setlocale_from_msg( ) gets the category values from the LID associated with msg_tag, while
setlocale( ) gets the locale names from the process’s internationalization environment variables.
The setlocale( ) function also lets a user set a process’s locale with a specific locale name.
With the setlocale_from_msg( ) function, client processes’ LID values are sent to the server pro-
cess along with the message only when the server requests it with a Guardian FILE_OPEN_ call.
The server can process a request based on the category values in the LID of a client’s message on
a per-thread/request basis.
EXAMPLES
The following example sets and saves the existing locale environment, then explicitly sets the
locale based on the received message, performs some operations in that locale and finally,
restores the locale to the saved environment. The main program typically uses setlocale( ) to set
its locale environment to the locale specified by the user’s environment variables and uses
setlocale_from_msg( ) to set the locale to the one that matches the client’s locale. If a function
needs to execute in a specific locale, it must save and restore the international environment.
#include <locale.h>
#include <string.h>
#include <cextdecs.h>
void Do_setlocale_from_message(void)
{
char *client_lc, *server_lc;
short rf_num, options, read_cnt, fn_len;
char r_buf[80], receive_info[17];
/* Setting the locale from the environment variable LC_ALL. */
server_lc = setlocale(LC_ALL,"");
options = %000004; /* set bit-13 on so that locale information can be received. */
FILE_OPEN_("$RECEIVE", 8, &rf_num,,,1, options);
READUPDATE(rf_num, r_buf, &read_cnt);
/* Retrieve the message tag */
6−38 Hewlett-Packard Company 527187-017