**************************************************************************
* Mnemonic: SIinitialise
* Abstract: Initialisation and other context management functions.
-*
+*
* Date: 26 March 1995
* Author: E. Scott Daniels
*
-* Mod: 17 FEB 2002 - To convert to a globally managed gpointer
-* 09 Mar 2007 - To allow for ipv6 (added SIinitialise() to
+* Mod: 17 FEB 2002 - To convert to a globally managed gpointer
+* 09 Mar 2007 - To allow for ipv6 (added SIinitialise() to
* replace SIinit())
**************************************************************************
*/
-#include "sisetup.h" // get the setup stuff
+#include "sisetup.h" // get the setup stuff
/*
Initialise the SI environment. Specifically:
*/
extern struct ginfo_blk* SIinitialise( int opts )
{
- struct ginfo_blk *gptr = NULL; // pointer at gen info blk
- int status = SI_OK; // status of internal processing
- struct tp_blk *tpptr; // pointer at tp stuff
- struct sigaction sact; // signal action block
- int i; // loop index
- int signals = SI_DEF_SIGS; // signals to be set in SIsetsig
+ struct ginfo_blk *gptr = NULL; // pointer at gen info blk
+ int status = SI_OK; // status of internal processing
+ struct tp_blk *tpptr; // pointer at tp stuff
+ struct sigaction sact; // signal action block
+ int i; // loop index
+ int signals = SI_DEF_SIGS; // signals to be set in SIsetsig
errno = ENOMEM;
gptr->cbtab = (struct callback_blk *) malloc(
(sizeof( struct callback_blk ) * MAX_CBS ) );
if( gptr->cbtab != NULL ) {
- for( i = 0; i < MAX_CBS; i++ ) { // initialize callback table
- gptr->cbtab[i].cbdata = NULL; // no data and no functions
+ for( i = 0; i < MAX_CBS; i++ ) { // initialize callback table
+ gptr->cbtab[i].cbdata = NULL; // no data and no functions
gptr->cbtab[i].cbrtn = NULL;
}
- } else { // if call back table allocation failed - error off
- SIshutdown( gptr ); // clean up any open fds
+ } else { // if call back table allocation failed - error off
+ SIshutdown( gptr ); // clean up any open fds
+ free( gptr->tp_map );
free( gptr );
- gptr = NULL; // dont allow them to continue
+ gptr = NULL; // dont allow them to continue
}
- } // end if gen infor block allocated successfully
+ } // end if gen infor block allocated successfully
+
-
memset( &sact, 0, sizeof( sact ) );
sact.sa_handler = SIG_IGN;
sigaction( SIGPIPE, &sact, NULL ); // ignore pipe signals as for some bloody reason linux sets this off if write to closed socket
- return gptr; // all's well that ends well
-}
+ return gptr; // all's well that ends well
+}
/*
This will set all of the tcp oriented flags in mask (SI_TF_* constants).