* CallBack.c	Example server using InternetCT request model.  This server
 *				will call you back some number of seconds after you 
 *				connect to it and provide a password.  Who pays for the call?
 *
 *				1. Display a welcome banner and request a password.
 *				2. Run a command loop. [DELAY [nnn] | OK | LIST | QUIT]
 *				3. Also has timeout close.
 *
 * 				Several (memory limited) sessions can be started with the 
 *				server at one time.  The entire server is one process and is 
 *				completely event driven.
 *
 *
 *
 * Change History
 *
 * DRH	920914	Initial.
 *
 *
 *

ifdef DEBUG
include stdio.h
endif
include std.h
include inetrq.h
include timer.h
include dlstr.h
include cmdparse.h
include CallBack.h

*.< Local Functions >*

unsigned int			initialize();
unsigned int			main();
void					post_listen();
CBCB					* create_cb();
void					delete_cb();
void					idle_timeout();
void					send_msg();
void					process_buf();
void					process_cmd();
char					* cmd_ok();
char					* cmd_delay();
char					* cmd_quit();
char					* cmd_list();
char					* cmd_help();
void					call_back();

*.< Imported Functions >*

extern unsigned int		TcpGetSetup();			* ICT procedural interface *
extern unsigned int		OpenTCPConnection();
extern unsigned int		CloseTCPConnection();

												* Lib> *
extern unsigned int		os_start_timer();		* timer.c *
extern void				os_service_timer();
extern unsigned int		os_stop_timer();
extern void				tick();
extern void				start_timer();
extern void				stop_timer();

extern IRCB				* address_of_ircb();	* inetrq.c *
extern unsigned int		inet_rq_open();
extern unsigned int		inet_rq_close();
extern unsigned int		inet_rq_get_tcb();
extern unsigned int		inet_rq_send();
extern unsigned int		inet_rq_receive();

extern void				get_param_yes_no();		* param.c *
extern void				get_param_unsigned();
extern void				get_param_string();

extern char				* cmdparse();			* cmdparse.c *

extern unsigned int		CheckErc();				* CTOS procedural interface *
extern unsigned int		AllocExch();
extern unsigned int		SetMsgRet();
extern unsigned int		ConvertToSys();
extern unsigned int		SetPartitionName();
extern unsigned int		Wait();

*.< c Library >*

extern char				* alloc();
extern char				* calloc();

*.< Local Data >*

ifdef DEBUG
FILE					* debugfp;
endif

	* Parameters *
unsigned int			k				= 5;		* 1, K bytes memory.	*
unsigned char			convert_to_sys	= TRUE;		* 2, System service?	*
char					pswd[SPSWD + 1]	= Sirius;	* 3, Password			*
unsigned int			default_delay	= 150;		* 4, Delay before call	*

unsigned int			server_exch;

TIMER					server_timer;

unsigned int			server_erc;

char					version[21];
char					banner_fmt[]	= CallBack Server (s)\r\n;
char					banner[sizeof(version) + sizeof(banner_fmt) + 1];

unsigned long int		ip_addr;
unsigned int			mss;
unsigned int			window;
unsigned int			ttl;
char					hostname[HOSTNAMELEN + 1];
unsigned int			shostnameret;

char					partition_name[]		= CallBack;

char	msg_get_pswd[]		= \r\ns\r\n\nHello s. Please enter password: ;
char	msg_bad_pswd[]		= \r\nIncorrect password Closing connection.;
char	msg_cmd[]			= \r\nCommand: ;
char	msg_delay[]			= \r\nDelay setting is u seconds\r\n;
char	msg_will_call[]		= \r\nWill call back in u seconds\r\n;
char	msg_wont_call[]		= \r\nWill NOT call back;
char	msg_bye[]			= \r\nClosing connection. Goodbye\r\n;
char	msg_pending[]		= \tPending callbacks:\r\n;
char	msg_call_header[]	= \tNode                Will call back at\r\n;
char	msg_call_line[]		= \t20s20s\r\n;

char	msg_memory[]	= No Memory\r\n;

CMDS					cmds[] = {
	ok,		cmd_ok,		0,	NULLCHAR,
	delay,	cmd_delay,	0,	NULLCHAR,
	quit,		cmd_quit,	0,	NULLCHAR,
	exit,		cmd_quit,	0,	NULLCHAR,
	list,		cmd_list,	0,	NULLCHAR,
	help,		cmd_help,	0,	NULLCHAR,
	?,		cmd_help,	0,	NULLCHAR,
	NULLCHAR,	NULLCHAR,	0, 	\r\nUnknown command; Help or ? for list\r\n
	};

DLSTR					* cb_head;

*.< Imported Data >*

extern unsigned char	sbverrun[];			* Provided by linker *
extern unsigned int		fdevelopement;

*======================.=========< CallBack >===============================*
unsigned int main()
{
	REQUEST					* rq;
	IRCB					* ircb;
	unsigned int			rq_erc;
	CBCB					* cbcb;
	unsigned int			len;

ifdef DEBUG
	unsigned int			l_e_n;
fdevelopement = TRUE;
if( ( debugfp = fopen( [Sys]<INetCT>CallBack.Debug, w)) == NULL) {
		l_e_n = sprintf( banner, Could not open debug file\n);
		SetMsgRet( banner, l_e_n);
		Exit( 0);
}
else
	fdevelopement = FALSE;
endif


	initialize();

	post_listen( NULLCHAR);

	for(;;) {
		checkerc( Wait( server_exch, rq));

		if( rq>rqcode == OPENRTCLOCK) {
			os_service_timer();
			continue;
		}

		if( ( ircb = address_of_ircb( rq)) == NULLIRCB) {
ifdef DEBUG
fprintf( debugfp, Main:\taddress_of_ircb() was BOGUS\n);
endif
			continue;
		}

		rq_erc = rq>ercret;
		cbcb = ircb>user_cb;		* NULLCHAR until we get past LISTEN *

ifdef DEBUG
fprintf( debugfp, Main: rq_erc=u, cbcb=lx\n, rq_erc, cbcb);
fflush( debugfp);
endif

		switch( rq>rqcode  REQUEST_BASE) {
		case ORC_OPEN_TCP_CONNECTION_NO_WAIT:
ifdef DEBUG
fprintf( debugfp, Main:\tOPEN\n);
endif
			if( rq_erc == ERC_OK) {
				inet_rq_get_tcb( ircb);
			} else {
				delete_cb( ircb, cbcb);
				post_listen( NULLCHAR);
			}
			break;

		case ORC_CLOSE_TCP_CONNECTION:
		case ORC_ABORT_TCP_CONNECTION:
ifdef DEBUG
fprintf( debugfp, Main:\tCLOSE\n);
endif
			delete_cb( ircb, cbcb);
			break;

		case ORC_SEND_TCP_MESSAGE:
ifdef DEBUG
fprintf( debugfp, Main:\tSEND\n);
endif
			if( rq_erc == ERC_OK) {
				send_msg( ircb, cbcb);
				start_timer( cbcb>timeout);
			} else {
				delete_cb( ircb, cbcb);
			}
			break;

		case ORC_RECEIVE_TCP_MESSAGE:
ifdef DEBUG
fprintf( debugfp, Main:\tRECEIVE\n);
endif
			if( rq_erc == ERC_OK) {
				process_buf( ircb, cbcb);
			} else {
				delete_cb( ircb, cbcb);
			}
			break;

		case ORC_GET_TCB:
ifdef DEBUG
fprintf( debugfp, Main:\tGET_TCB\n);
endif
			if( rq_erc == ERC_OK) {
				if( ircb>tcb.notice_type == NOTICE_STATE) {
					switch( ircb>tcb.state) {
					case LISTEN:
ifdef DEBUG
fprintf( debugfp, Main:\t\t\tState Change  LISTEN\n);
endif
						inet_rq_get_tcb( ircb);
						break;

					case SYN_SENT:
ifdef DEBUG
fprintf( debugfp, Main:\t\t\tState Change  SYN_SENT\n);
endif
						create_cb( ircb);
						inet_rq_get_tcb( ircb);
						break;
					case SYN_RECEIVED:
ifdef DEBUG
fprintf( debugfp, Main:\t\t\tState Change  SYN_RECEIVED\n);
endif
						create_cb( ircb);
						inet_rq_get_tcb( ircb);
						break;

					case ESTABLISHED:
ifdef DEBUG
fprintf( debugfp, Main:\t\t\tState Change  ESTABLISHED:\n);
endif
						if( (cbcb = create_cb( ircb)) = NULLCBCB) {
							if( ircb>index == INDEX_CALLBACK) {			
ifdef DEBUG
fprintf( debugfp, Main:\t\t\tState Change  ESTABLISHED:\tCALLBACK\n);
endif
								delete_cb( ircb, cbcb);
							} else if( AddrToHostName( 
												ircb>tcb.conn.remote.address, 
												hostname, HOSTNAMELEN, 
												shostnameret) == ERC_OK) {
								hostname[shostnameret] = '\0';
								sprintf( cbcb>msg, msg_get_pswd, banner, 
										 hostname);
								dlstr_insert( cbcb>msg_head, NULLDLSTR, 
											  cbcb>msg);
								send_msg( ircb, cbcb);
								inet_rq_receive( ircb, cbcb>buf, SBUF_MAX);
								cbcb>state = STATE_BANNER;
								start_timer( cbcb>timeout);
							}
						}
						break;
					}
				} else {
ifdef DEBUG
fprintf( debugfp, Main:\t\tOther Notice Type = u\n, ircb>tcb.notice_type);
endif
					inet_rq_get_tcb( ircb);
				}

			} else {
				delete_cb( ircb, cbcb);
			} 
			break;
		}
	}
}
*======================.========< Initialize >==============================*
unsigned int initialize()
{
	unsigned int		len;
	char				* cp;
	unsigned int		handle;
	

		* Allocate exchange for inetrq and timer use *
	CheckErc( AllocExch( server_exch));

		* Copy the version number for use in banner *
	memcpy( version, sbverrun[1], min( sbverrun[0], (sizeof(version)1)));

		* Get local host identity information *
	CheckErc( TCPGetSetup( ip_addr, mss, window, ttl,
					 	   hostname, HOSTNAMELEN, shostnameret));
	hostname[shostnameret] = '\0';

		* Check for CallBack server already installed by trying to connect. *
	if( OpenTCPConnection(	0, hostname, shostnameret, 
							CALLBACK_PORT, TCP_ACTIVE, 
							0,0,0, NULLCHAR, 0, handle) == ERC_OK) {
		CloseTCPConnection( handle);
		len = sprintf( banner, CallBack server already active\n);
		SetMsgRet( banner, len);
		Exit( 0);
	}

	len = sprintf( banner, banner_fmt, version);	* Setup banner			*

	get_param_unsigned( 1, 0, k);					* How much to allocate *
	get_param_yes_no( 2, 0, convert_to_sys);		* Convert to Sys?		*
	get_param_string( 3, 0, pswd, SPSWD);			* Get the password		*
	get_param_unsigned( 4, 0, default_delay);		* Get default delay	*
	
	free( calloc( k, 1024));						* Grabfree memory		*

	if( convert_to_sys) {
		SetMsgRet( banner, len);
		CheckErc( ConvertToSys());
		exit();
	}

	SetPartitionName( 0, partition_name, strlen( partition_name));

	os_start_timer( TIMER_GRANULARITY, server_exch, tick);

	server_timer.start = SERVER_TIMER_VALUE;
	server_timer.func = post_listen;
	server_timer.arg = NULLCHAR;
}*======================.=======< Post Listen >==============================*
void post_listen( dummy)
unsigned char			* dummy;
{
	IRCB				* ircb;

ifdef DEBUG
fprintf( debugfp, Post Listen:\n);
endif
	stop_timer( server_timer);

	if( ( ircb = calloc( 1, sizeof( IRCB))) == NULLCHAR) {
ifdef DEBUG
fprintf( debugfp, Post Listen:\tcalloc IRCB failed\n);
endif
		server_erc = ERC_NO_MEMORY;
		start_timer( server_timer);
	} else {
		ircb>self_ref = ircb;
		if( ( server_erc = inet_rq_open( ircb, server_exch, 
										 0, INETCT_OPEN_NO_WAIT, 
										 CALLBACK_PORT, 0, TCP_PASSIVE, 
										 NULLCHAR, 0)) = ERC_OK) {
			start_timer( server_timer);
			free( ircb);
		}
	}
}
*======================.========< Create CB >===============================*
CBCB * create_cb( ircb)

IRCB					* ircb;
{
	CBCB				* cbcb;

ifdef DEBUG
fprintf( debugfp, Create CB:\n);
endif
	if( ircb>user_cb == NULLCHAR) {
ifdef DEBUG
fprintf( debugfp, Create CB:\tcbcb DID NOT EXIST\n);
endif
		if( ( cbcb = (CBCB *) calloc( 1, sizeof(CBCB))) == NULLCBCB) {
ifdef DEBUG
fprintf( debugfp, Create CB:\tcbcb calloc failed\n, ircb>user_cb);
endif
			inet_rq_close( ircb, INETCT_ABORT);
		} else {
			cbcb>ircb		= ircb;
			ircb>user_cb	= (char *)cbcb;

			cbcb>timeout.start	= IDLE_TIMER_VALUE;
			cbcb>timeout.func	= idle_timeout;
			cbcb>timeout.arg	= ircb;
			start_timer( cbcb>timeout);
			cbcb>delay = default_delay;
		}
		if( ircb>index = INDEX_CALLBACK) {
			post_listen( NULLCHAR);
		}
	} else {
ifdef DEBUG
fprintf( debugfp, Create CB:\tcbcb EXISTED, ircb>cb=lx\n, ircb>user_cb);
endif
		cbcb = (CBCB *) ircb>user_cb;
	}
	return( cbcb);
}
*======================.========< Delete CB >===============================*
void delete_cb( ircb, cbcb)

IRCB					* ircb;
CBCB					* cbcb;
{

ifdef DEBUG
fprintf( debugfp, Delete CB:\n);
endif
	if( cbcb = NULLCBCB  cbcb>fclosed) {
ifdef DEBUG
fprintf( debugfp, Delete CB:\tactive CBCB  connection, Close Connection\n);
endif
		inet_rq_close( ircb, INETCT_CLOSE);
		cbcb>fclosed = TRUE;
	}
	if( cbcb = NULLCBCB) {
ifdef DEBUG
fprintf( debugfp, Delete CB:\tactive CBCB, Stop Idle Timer\n);
endif
		stop_timer( cbcb>timeout);
	}

	if( ircb>rqs_out == 0) {
ifdef DEBUG
fprintf( debugfp, Delete CB:\tircb>rqs_out = 0\n);
endif
		if( cbcb = NULLCBCB) {
ifdef DEBUG
fprintf( debugfp, Delete CB:\t\tcbcb = NULLCBCB, free it\n);
endif
			dlstr_free_list( cbcb>msg_head);
			free( (char *) cbcb);
		}
ifdef DEBUG
fprintf( debugfp, Delete CB:\t\tfree ircb\n);
endif
		free( (char *) ircb);
	}
}
*======================.=======< Send Message >=============================*
void send_msg( ircb, cbcb)

IRCB					* ircb;
CBCB					* cbcb;
{
	DLSTR				* dlstr;

ifdef DEBUG
fprintf( debugfp, Send Message:\n);
endif
	if( ( dlstr = cbcb>msg_head) = NULLDLSTR) {
		inet_rq_send( ircb, 0, 0, dlstr>string, strlen( dlstr>string));
		dlstr_delete( cbcb>msg_head, dlstr);
	}
}
*======================.=======< Idle Timeout >=============================*
void idle_timeout( ircb)

IRCB					* ircb;
{

ifdef DEBUG
fprintf( debugfp, Idle Timeout:\n);
endif
	delete_cb( ircb, ircb>user_cb);
}
*======================.=====< Process Buffer >============================*
void process_buf( ircb, cbcb)

IRCB					* ircb;
CBCB					* cbcb;
{
	unsigned int		i;
	unsigned int		sbuf;


ifdef DEBUG
fprintf( debugfp, Process Buffer:\n);
endif
	for( i = 0; i < ircb>smsgret; i++) {
		switch( cbcb>buf[i]) {
		case CTL_D:			* Goodbye. *
ifdef DEBUG
fprintf( debugfp, Process Buffer:\tCtlD\n);
endif
			inet_rq_send( ircb, 0, 0, msg_bye, strlen( msg_bye));
			delete_cb( ircb, cbcb);
			return;
			break;

		case '\r':
ifdef DEBUG
fprintf( debugfp, Process Buffer:\tCarriage Return\n);
endif
			break;

		case '\n':			* End of Line *
ifdef DEBUG
fprintf( debugfp, Process Buffer:\tNewLine\n);
endif
			cbcb>cmd[cbcb>scmd] = '\0';
			process_cmd( ircb, cbcb, cbcb>cmd, cbcb>scmd);
			cbcb>scmd = 0;
			break;

		default:
			if( cbcb>scmd < SCMD_MAX) {
				cbcb>cmd[cbcb>scmd++] = cbcb>buf[i];
			} else {
				cbcb>cmd[SCMD_MAX] = '\0';
				process_cmd( ircb, cbcb, cbcb>cmd, SCMD_MAX);
				cbcb>scmd = 0;
			}
			break;
		}
	}
ifdef DEBUG
fprintf( debugfp, Process Buffer:\tinet_rq_receive(), start_timer()\n);
endif
	inet_rq_receive( ircb, cbcb>buf, SBUF_MAX);
	start_timer( cbcb>timeout);
}
*======================.=====< Process Command >============================*
void process_cmd( ircb, cbcb, cmd, scmd)

IRCB					* ircb;
CBCB					* cbcb;
char					* cmd;
unsigned int			scmd;
{

	char				* msg;

ifdef DEBUG
fprintf( debugfp, Process Command:\n);
endif
	if( *cmd == TELNET_OPT_ESC) {	* Ignore 'em *
		return;
	}

	switch( cbcb>state) {
	case STATE_BANNER:
ifdef DEBUG
fprintf( debugfp, Process Command:\tSTATE_BANNER\n);
endif
		if( strlen( pswd) > 0) {
			if( strncmpi( cmd, pswd, strlen( pswd))) {
				inet_rq_send( ircb, 0, 0, msg_bad_pswd, strlen( msg_bad_pswd));
				delete_cb( ircb, cbcb);
				return;
			}
		}
		sprintf( cbcb>msg, msg_delay, default_delay);
		dlstr_insert( cbcb>msg_head, NULLDLSTR, cbcb>msg);
		dlstr_insert( cbcb>msg_head, NULLDLSTR, msg_cmd);
		send_msg( ircb, cbcb);
		cbcb>state = STATE_COMMAND;
		break;
	case STATE_COMMAND:
ifdef DEBUG
fprintf( debugfp, Process Command:\tSTATE_COMMAND\n);
endif
		if( ( msg = cmdparse( ircb, cbcb, cmds, cmd)) = NULLCHAR) {
			dlstr_insert( cbcb>msg_head, NULLDLSTR, msg);
		}
		dlstr_insert( cbcb>msg_head, NULLDLSTR, msg_cmd);
		send_msg( ircb, cbcb);
		break;
	}
}
*======================.============< OK >==================================*
char * cmd_ok( ircb, cbcb, argc, argv)

IRCB					* ircb;
CBCB					* cbcb;
unsigned int			argc;
char					* argv[];
{
	CALLBACK			* cb;
	unsigned long int	seconds;

ifdef DEBUG
fprintf( debugfp, Command OK:\n);
endif
	if( ( cb = calloc( 1, sizeof( CALLBACK))) == NULLCHAR) {
		return( msg_memory);
ifdef DEBUG
fprintf( debugfp, Command OK:\tcalloc failed\n);
endif
	} else {
		cb>address = ircb>tcb.conn.remote.address;
		getdatetime( cb>time);
		seconds = (unsigned long int)( cb>time.hds.seconds) + cbcb>delay;
		cb>time.hds.half_days += (unsigned int)(seconds  HALF_DAY_SECONDS);
		cb>time.hds.seconds = (unsigned int)(seconds  HALF_DAY_SECONDS);
		cb>timer.start	= cbcb>delay;
		cb>timer.func	= call_back;
		cb>timer.arg	= cb;
		start_timer( cb>timer);
		listaddtotail( cb_head, cb);
	}
	sprintf( cbcb>msg, msg_will_call, cbcb>delay);
	return cbcb>msg;
}
*======================.==========< Delay >=================================*
char * cmd_delay( ircb, cbcb, argc, argv)

IRCB					* ircb;
CBCB					* cbcb;
unsigned int			argc;
char					* argv[];
{
ifdef DEBUG
fprintf( debugfp, Command Delay:\n);
endif
	if( argc > 1) {
		cbcb>delay = atoi( argv[1]);
	}
	sprintf( cbcb>msg, msg_delay, cbcb>delay);
	dlstr_insert( cbcb>msg_head, NULLDLSTR, cbcb>msg);
	return NULLCHAR;
}
*======================.===========< Quit >=================================*
char * cmd_quit( ircb, cbcb, argc, argv)

IRCB					* ircb;
CBCB					* cbcb;
unsigned int			argc;
char					* argv[];
{
ifdef DEBUG
fprintf( debugfp, Command Quit:\n);
endif
	dlstr_free_list( cbcb>msg_head);
	inet_rq_send( ircb, 0, 0, msg_bye, strlen( msg_bye));
	delete_cb( ircb, cbcb);
	return NULLCHAR;

}
*======================.===========< List >=================================*
char * cmd_list( ircb, cbcb, argc, argv)

IRCB					* ircb;
CBCB					* cbcb;
unsigned int			argc;
char					* argv[];
{
	CALLBACK			* cb;
	unsigned long int	sysdt;
	unsigned int		cbret;
	static char			fmt[] = 0y0o0d0t:0m:0s;
	static char			tod[16];

ifdef DEBUG
fprintf( debugfp, Command List:\n);
endif
	dlstr_insert( cbcb>msg_head, NULLDLSTR, msg_call_header);
	for( cb = cb_head; cb = NULLCHAR; cb = cb>next) {
		AddrToHostName( cb>address, hostname, HOSTNAMELEN, shostnameret);
		hostname[shostnameret] = '\0';
		NlsFormatDateTime( NULLCHAR, cb>time.sdt, fmt, strlen( fmt),
						   tod, sizeof( tod) 1, cbret);
		tod[cbret] = '\0';
		sprintf( cbcb>msg, msg_call_line, hostname, tod);
		dlstr_insert( cbcb>msg_head, NULLDLSTR, cbcb>msg);
	}
	GetDateTime( sysdt);
	NlsFormatDateTime( NULLCHAR, sysdt, fmt, strlen( fmt),
					   tod, sizeof(tod)  1, cbret);
	tod[cbret] = '\0';
	sprintf( cbcb>msg, msg_call_line, ** Current time **, tod);
	return cbcb>msg;
}
*======================.===========< Help >=================================*
char * cmd_help( ircb, cbcb, argc, argv)

IRCB					* ircb;
CBCB					* cbcb;
unsigned int			argc;
char					* argv[];
{
	char				name[17];
	unsigned int		i;
	CMDS				* cmdp;


ifdef DEBUG
fprintf( debugfp, Command Help:\n);
endif
	dlstr_insert( cbcb>msg_head, NULLDLSTR, Commands are:\r\n);
	cbcb>msg[0] = '\0';
	for( i = 0, cmdp = cmds; cmdp>name = NULLCHAR; cmdp++, i++) {
		sprintf( name, 16s, cmdp>name);
		strcat( cbcb>msg, name);
		if( (i  4) == 3) {
			strcat( cbcb>msg, \r\n);
			dlstr_insert( cbcb>msg_head, NULLDLSTR, cbcb>msg);
			cbcb>msg[0] = '\0';
		}
	}
	if( (i  4) = 0) {
		strcat( cbcb>msg, \r\n);
		dlstr_insert( cbcb>msg_head, NULLDLSTR, cbcb>msg);
	}
	return NULLCHAR;
}
*======================.========< Call Back >===============================*
void call_back( cb)

CALLBACK				* cb;
{
	IRCB				* ircb;
	AT_ADDRESS			at_address;

ifdef DEBUG
fprintf( debugfp, CallBack:\n);
endif
	if( ( ircb = calloc( 1, sizeof( IRCB))) == NULLCHAR) {
ifdef DEBUG
fprintf( debugfp, CallBack:\tcalloc failed\n);
endif
		server_erc = ERC_NO_MEMORY;
	} else {
		ircb>self_ref = ircb;
		at_address.at = '@';
		at_address.address = cb>address;
		if( ( server_erc = inet_rq_open( ircb, server_exch, INDEX_CALLBACK,
										 INETCT_OPEN_NO_WAIT, 0, DISCARD_PORT, 
										 TCP_ACTIVE, at_address, 
										 sizeof( AT_ADDRESS))) = ERC_OK) {
			free( ircb);
		}
	}
	listremove( cb_head,  cb);
	free( cb);
}
swd) > 0) {
			if( strncmpi( cmd, pswd, strlen( pswd))) {
				inet_rq_send( ircb, 0, 0, msg_bad_pswd, strlen( msg_bad_pswd));
				delete_cb( ircb, cbcb);
				return;
			}
		}
		sprintf( cbcb