Initialize an Open Server application.
SRV_SERVER *srv_init(scp, servernamep, namelen)
SRV_CONFIG *scp; CS_CHAR *servernamep; CS_INT namelen;
The configuration structure that holds the values of all the Open Server configuration options. This argument is optional. It is included for backward compatibility.
A pointer to the Open Server application name. The name you supply is looked up in the interfaces file to get the necessary network information. If you use (CS_CHAR *) NULL as the Open Server name, the value of DSLISTEN will be the server’s name. If DSLISTEN has not been explicitly set, the name defaults to the string “SYBASE”.
The length, in bytes, of the string in *servernamep. If the string is (CS_CHAR *) NULL, namelen is ignored. If the string is null terminated, namelen can be CS_NULLTERM.
Returns |
To indicate |
---|---|
SRV_SERVER pointer |
The routine ran successfully. |
(SRV_SERVER *) NULL |
The routine failed. |
#include <ospublic.h>
/*
** Local prototype.
*/
SRV_SERVER *ex_srv_init PROTOTYPE((
SRV_CONFIG *scp
));
/*
** EX_SRV_INIT
**
** Example routine to initialize an Open Server application.
**
** Arguments:
** scp - A pointer to the configuration structure.
**
** Returns:
** On success, a pointer to a newly allocated SRV_SERVER
structure.
** On failure, NULL.
**
*/
SRV_SERVER *ex_srv_init(scp)
SRV_CONFIG *scp;
{
SRV_SERVER *server;
CS_CHAR *servername = “EX_SERVER”;
server = srv_init(scp, servername, CS_NULLTERM);
return (server);
}
A server must be initialized before it is started with srv_run.
srv_init initializes an Open Server application. The initialization process consists primarily of allocating the necessary data structures for the server, initializing the server state, and starting up the network listener.
Most configuration options must be set before srv_init is called if values other than the defaults are desired. See the srv_props reference page, for a list of configurable options.
srv_version must be called prior to srv_init to set up library version information and default internationalization values.
Open Server releases the SRV_SERVER structure when a SRV_STOP event occurs. An Open Server application should not release it.
For information on designating an interfaces file, see the srv_props reference page. For more information on the interfaces file itself, see the Open Client/Server Supplement for your platform.