Open System Services Library Calls Reference Manual (G06.28+, H06.05+)

OSS Library Calls (s) setlocale_from_msg(3)
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
H-series OSS processes: /G/system/zdllnnn/zicnvdll
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 Identier
(LID) associated with msg_tag. A process can change its locale for a thread/request by calling
this function. This function sets the processs locale to the clients preferences. (Note that to set
aservers 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 processs internationalization environment variables.
The setlocale() function also lets a user set a processs locale with a specic locale name.
With the setlocale_from_msg() function, client processesLID 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 clients 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 nally,
restores the locale to the saved environment. The main program typically uses setlocale() to set
its locale environment to the locale specied by the users environment variables and uses
setlocale_from_msg() to set the locale to the one that matches the clients locale. If a function
needs to execute in a specic 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 */
FILE_GETRECEIVEINFO_(receive_info);
527187-007 Hewlett-Packard Company 627