Back to home page

Enduro/X

 
 

    


0001 TPSVRINIT(3)
0002 ============
0003 :doctype: manpage
0004 
0005 
0006 NAME
0007 ----
0008 tpsvrinit - Template for server init function
0009 
0010 
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014 
0015 int tpsvrinit (int 'argc', char **'argv');
0016 
0017 For XATMI server link with '-latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm'
0018 
0019 DESCRIPTION
0020 -----------
0021 This function is called upon server startup. Before the services are advertise, 
0022 this function is activated. The 'argc' and 'argv' is command line parameters 
0023 passed to binary after the '--'. Initial parameters are used by Enduro/X, 
0024 these are sys-opts in the *ndrxconfig.xml*, after the '--' those are 
0025 application specific options.
0026 
0027 Normally at *tpsvrinit()* XATMI server does the *tpadvertise()*, and initialize 
0028 other resources, like calling *tpopen()*. Any advertise done here, actually 
0029 takes a part when function returns.
0030 
0031 The function can be exposed to Enduro/X system in different ways:
0032 
0033 1. If server binary is linked with '-latmisrv', then server must 
0034 contain public (non static) function of *tpsvrinit()*.
0035 
0036 2. If server binary is linked with '-latmisrvnomain', then above (1) 
0037 rule still applies. But in this case the caller's *main()* must invoke *ndrx_main()* function.
0038 
0039 3. If server binary is linked with '-latmisrvinteg', then functions 
0040 *tpsvrinit()* and tpsvrdone()* must be passed to *ndrx_main_integra()* function. 
0041 Or if starting server by *_tmstartserver()* - built by *buildserver(8)*, 
0042 function must pointer must be present in 'tmsvrargs_t'.
0043 
0044 Library 'atmisrvinteg' provides built in version of *tpsvrinit()* function. Function
0045 may be used only if starting server with *_tmstartserver(3)* (or was built by
0046 *buildserver(8)*). The default *tpsvrinit()* function, in case if application was
0047 not built for multi-threading (extern variable '_tmbuilt_with_thread_option' set to 0 
0048 or buildserver '-t' not set), 
0049 calls *tpsvrthrinit(3)* from the 'tmsvrargs_t'.
0050 In case there were no *tpsvrthrinit(3)* provided, the default *tpsvrthrinit()* is
0051 used also from 'atmisrvinteg' library. The default version of *tpsvrthrinit(3)* calls
0052 *tx_open(3)*.
0053 
0054 This only applies to XATMI servers.
0055 
0056 In case if using C++ compiler, function must be defined without name mangling,
0057 thus extern "C" prefix shall be used.
0058 
0059 RETURN VALUE
0060 ------------
0061 If application failed to initialize, the user shall return non 0 value. 
0062 If succeed, then 0 must be returned.
0063 
0064 ERRORS
0065 ------
0066 Not available.
0067 
0068 EXAMPLE
0069 -------
0070 See *atmitest/test001_basiccall/atmisv1.c* for sample code.
0071 
0072 BUGS
0073 ----
0074 Report bugs to support@mavimax.com
0075 
0076 SEE ALSO
0077 --------
0078 *ndrx_main(3)* *ndrx_main_integra(3)* *tpsvrdone(3)* *tpclose(3)* *tpopen(3)* *xadmin(8)*
0079 
0080 COPYING
0081 -------
0082 (C) Mavimax, Ltd
0083