RSC/MP 7.2 Programming Manual

API Functions and Options
HP NonStop Remote Server Call (RSC/MP) Programming Manual522360-004
3-5
Using API Functions to Manage Options
Using API Functions to Manage Options
You might want to read some options from a disk file and set other options
programmatically. The following code fragment shows how to combine the two
methods of setting options.
The options file, RSC.INI, is used to store configuration-type options such as the name
of the host server and the group alias used for receiving UMS messages. The
RscSetOption function is used to set options at runtime; these options would include
sensitive information that does not belong in a configuration file, such as user name
and password.
Example RSC.INI file:
[MYAPPLICATION]
HOST_PIPENAME=myapp@host.mycompany.com
GROUP_ALIAS=bostonoffice
SUBSYSTEM_NAME=rscpipe
Corresponding sample application program code:
ULONG ulOptionsHandle;
ULONG ulConnectionHandle;
ULONG ulSessionHandle;
CHAR acUserName[RSC_USERID_SIZE];
CHAR acPassword[RSC_PASSWORD_SIZE];
CHAR acTermName[RSC_TERMNAME_SIZE];
/* Note: error checking is omitted here for clarity of the example. */
/* Please do check for errors! */
/* Create an options structure. Load the options structure with */
/* configuration options from RSC.INI */
RscCreateOptions(&ulOptionsHandle);
RscLoadOptions(ulOptionsHandle, "RSC.INI", "MYAPPLICATION");
/* Fill in the options that were not read from the file.*/
/* Insert code here to query the user for name and password. */
/* Store the reponses in acUserName and acPassword */
RscSetOption(ulOptionsHandle, "USER_ID", acUserName, 0);
RscSetOption(ulOptionsHandle, "PASSWORD", acPassword, 0);
/* Connect to the TDP */
RscConnect(ulOptionsHandle, RSC_CONNECT_WAITED, &ulConnectionHandle);
RscGetOption(ulOptionsHandle, "HOST_TERM_NAME", acTermName);
/* Insert code here to display the TERM object name for user. */
/* Begin a session and start doing I/O. */
RscBeginSession(ulOptionsHandle, ulConnectionHandle, ...., &ulSessionHandle);
RscWriteRead(ulOptionsHandle, ulConnectionHandle, ulSessionHandle, ....);
....
/* When finished, destroy the options structure before quitting. */
RscDestroyOptions(ulOptionsHandle);