User Tools

Site Tools


Sidebar

Table Of Contents

endurox:v7.5.x:api:xatmi:tpsvrinit.3

tpsvrinit

Name

tpsvrinit — Template for server init function

Synopsis

#include <atmi.h>

int tpsvrinit (int argc, char **argv);

For XATMI server link with -latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm

DESCRIPTION

This function is called upon server startup. Before the services are advertise, this function is activated. The argc and argv is command line parameters passed to binary after the --. Initial parameters are used by Enduro/X, these are sys-opts in the ndrxconfig.xml, after the -- those are application specific options.

Normally at tpsvrinit() XATMI server does the tpadvertise(), and initialize other resources, like calling tpopen(). Any advertise done here, actually takes a part when function returns.

The function can be exposed to Enduro/X system in different ways:

  1. If server binary is linked with -latmisrv, then server must contain public (non static) function of tpsvrinit().
  2. If server binary is linked with -latmisrvnomain, then above (1) rule still applies. But in this case the caller’s main() must invoke ndrx_main() function.
  3. If server binary is linked with -latmisrvinteg, then functions tpsvrinit() and tpsvrdone()* must be passed to ndrx_main_integra() function. Or if starting server by _tmstartserver() - built by buildserver(8), function must pointer must be present in tmsvrargs_t.

Library atmisrvinteg provides built in version of tpsvrinit() function. Function may be used only if starting server with _tmstartserver(3) (or was built by buildserver(8)). The default tpsvrinit() function, in case if application was not built for multi-threading (extern variable _tmbuilt_with_thread_option set to 0 or buildserver -t not set), calls tpsvrthrinit(3) from the tmsvrargs_t. In case there were no tpsvrthrinit(3) provided, the default tpsvrthrinit() is used also from atmisrvinteg library. The default version of tpsvrthrinit(3) calls tx_open(3).

This only applies to XATMI servers.

In case if using C++ compiler, function must be defined without name mangling, thus extern "C" prefix shall be used.

RETURN VALUE

If application failed to initialize, the user shall return non 0 value. If succeed, then 0 must be returned.

ERRORS

Not available.

EXAMPLE

See atmitest/test001_basiccall/atmisv1.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd