void
tc_connect_lip_client(short port)
{
	union {
		struct sockaddr_storage	ss;
		struct sockaddr_in	in;
	} sa;
	struct achat_channel    *c  = NULL;
	achat_rc		 rc = ACHAT_RC_ERROR;

	c = acc_create();
	fail_if(c == NULL, "couldn't create client channel");
	fail_if(c->euid != (uid_t)-1, "euid expected -1 but is %i", c->euid);
	fail_if(c->egid != (gid_t)-1, "egid expected -1 but is %i", c->egid);

	rc = acc_settail(c, ACC_TAIL_CLIENT);
	fail_if(rc != ACHAT_RC_OK, "client settail failed with rc=%d", rc);
	rc = acc_setsslmode(c, ACC_SSLMODE_CLEAR);
	fail_if(rc != ACHAT_RC_OK, "client setsslmode failed with rc=%d", rc);
	mark_point();

	bzero(&sa.ss, sizeof(sa.ss));
	sa.in.sin_family = AF_INET;
	sa.in.sin_port = htons(port);
	inet_aton("127.0.0.1", &(sa.in.sin_addr));
	rc = acc_setaddr(c, &sa.ss, sizeof(struct sockaddr_in));
	if (rc != ACHAT_RC_OK)
		fail("client setaddr failed with rc=%d", rc);
	mark_point();

	rc = acc_prepare(c);
	fail_if(rc != ACHAT_RC_OK, "client prepare failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));

	sleep(4); /* give the server time to open his socket */
	rc = acc_open(c);
	fail_if(rc != ACHAT_RC_OK, "client open failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));
	fail_unless(c->euid == (uid_t)-1, "euid: -1 expected but is %i",
	    c->euid);
	fail_unless(c->egid == (gid_t)-1, "egid: -1 expected but is %i",
	    c->egid);

	rc = acc_destroy(c);
	fail_if(rc != ACHAT_RC_OK, "client destroy failed with rc=%d", rc);

	exit(0);
}
void
tc_connect_lud_client(const char *sockname)
{
	union {
		struct sockaddr_storage	ss;
		struct sockaddr_un	un;
	} sa;
	struct achat_channel    *c  = NULL;
	achat_rc		 rc = ACHAT_RC_ERROR;

	c = acc_create();
	fail_if(c == NULL, "couldn't create client channel");
	fail_if(c->euid != (uid_t)-1, "euid expected -1 but is %i", c->euid);
	fail_if(c->egid != (gid_t)-1, "egid expected -1 but is %i", c->egid);
	mark_point();

	rc = acc_settail(c, ACC_TAIL_CLIENT);
	fail_if(rc != ACHAT_RC_OK, "client settail failed with rc=%d", rc);
	rc = acc_setsslmode(c, ACC_SSLMODE_CLEAR);
	fail_if(rc != ACHAT_RC_OK, "client setsslmode failed with rc=%d", rc);
	mark_point();

	bzero(&sa.ss, sizeof(sa.ss));
	sa.un.sun_family = AF_UNIX;
	strlcpy(sa.un.sun_path, sockname, sizeof(sa.un.sun_path));
	rc = acc_setaddr(c, &sa.ss, sizeof(struct sockaddr_un));
	if (rc != ACHAT_RC_OK)
		fail("client setaddr failed with rc=%d", rc);
	mark_point();

	rc = acc_prepare(c);
	fail_if(rc != ACHAT_RC_OK, "client prepare failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));

	sleep(4); /* give the server time to open his socket */
	rc = acc_open(c);
	fail_if(rc != ACHAT_RC_OK, "client open failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));

	fail_if(c->euid == (uid_t)-1, "euid != -1 expected, is %i", c->euid);
	fail_if(c->egid == (gid_t)-1, "egid != -1 expected, is %i", c->egid);

	rc = acc_destroy(c);
	fail_if(rc != ACHAT_RC_OK, "client destroy failed with rc=%d", rc);

	exit(0);
}
void
tc_connect_lud_server(const char *sockname)
{
	union {
		struct sockaddr_storage	ss;
		struct sockaddr_un	un;
	} sa;
	struct achat_channel    *s  = NULL;
	achat_rc		 rc = ACHAT_RC_ERROR;

	s = acc_create();
	fail_if(s == NULL, "couldn't create server channel");
	fail_if(s->euid != (uid_t)-1, "euid expected -1 but is %i", s->euid);
	fail_if(s->egid != (gid_t)-1, "egid expected -1 but is %i", s->egid);

	rc = acc_settail(s, ACC_TAIL_SERVER);
	fail_if(rc != ACHAT_RC_OK, "server settail failed with rc=%d", rc);
	rc = acc_setsslmode(s, ACC_SSLMODE_CLEAR);
	fail_if(rc != ACHAT_RC_OK, "server setsslmode failed with rc=%d", rc);
	mark_point();

	bzero(&sa.ss, sizeof(sa.ss));
	sa.un.sun_family = AF_UNIX;
	strlcpy(sa.un.sun_path, sockname, sizeof(sa.un.sun_path));
	rc = acc_setaddr(s, &sa.ss, sizeof(struct sockaddr_un));
	if (rc != ACHAT_RC_OK)
		fail("server setaddr failed with rc=%d", rc);
	mark_point();

	rc = acc_prepare(s);
	fail_if(rc != ACHAT_RC_OK, "server prepare failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));

	rc = acc_open(s);
	fail_if(rc != ACHAT_RC_OK, "server open failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));

	fail_if(s->euid != geteuid(), "server retrieved bogus uid %d, "
	    "expected %d", s->euid, geteuid());
	fail_if(s->egid != getegid(), "server retrieved bogus gid %d, "
	    "expected %d", s->egid, getegid());

	rc = acc_destroy(s);
	fail_if(rc != ACHAT_RC_OK, "server destroy failed with rc=%d", rc);
}
예제 #4
0
/* ................................................................
 * Handle user interaction with a form in open window `w'.
 *
 * Initial conditions are as follows:
 * w->x is the address of the form.
 * window is open, with appropriate WINFO rects & coordinates set
 * form is drawn within window, at correct virtual coordinates
 * ROOT object of form has correct x,y coordinates
 *
 * This routine works just like form_do, but dispatches window
 * events, redrawing and fixing up the object tree as appropriate,
 * and maintaining the various rects and coordinates in the WINFO struct.
 *
 * Returns exit object selected, |= 0x8000 if double clicked a TOUCHEXIT,
 * OR -1 if a message was received which couldn't be handled.
 * In the latter case, the `puntmsg' array is filled with the message buffer
 * which xform_do() couldn't handle, and the application is responsible for
 * picking up where xform_do() left off.  A cop-out, I know.
 *
 * NOTE: form_dial( FMD_START,... ) and form_dial( FMD_FINISH,... )
 *		should NOT be used with xform_do().
 *
 * User defined objects could cause problems with this routine, as
 * the boundary of the object may lie outside the window coordinates.
 * Caveat programmer.
 */
WORD
cdecl
xform_do( OBJECT *tree, WORD start_field, WORD puntmsg[] )
{
	WORD	next_obj, edit_obj, idx;
	BOOLEAN	cont, doedit;
	WORD	event;
	MRETS	m;
	WORD	key, clicks;
	DIRS	direction; /* form_keybd */
	GRECT	rect;
		
	cpx_tree = tree;
	SetAccCloseState( FALSE );
	SetWmCloseState( FALSE );
	/*
	 * Get the next editable object
	 */
	if( start_field == 0 )
		next_obj = find_obj( tree, 0, FORWARD );
	else
		next_obj = start_field;

	edit_obj = 0;
	cont = TRUE;
	
	cursor = FALSE;
	
	while( cont ) {

		/*
		 * Put the cursor in the edit field
		 * Note: This is skipped if there is only one field.
		 */
		if( (next_obj != 0) && (edit_obj != next_obj) ) {
			edit_obj = next_obj;
			next_obj = 0;
			doedit = can_edit( tree, edit_obj );
			if( doedit && !cursor )
			{
				objc_edit( tree, edit_obj, 0, (int *)&idx, ED_INIT );
				cursor = TRUE;
			}	
		}
		wind_update( FALSE );
		/*
		 * Wait...
		 */
		event = Evnt_multi( MU_KEYBD|MU_BUTTON|MU_MESAG, 2, 1, 1,
							NULL, NULL, msg, 0L, &m, &key, &clicks );
		wind_update( TRUE );

		if( EvMessage() ) {
			switch( MsgType(msg) ) {
				case AC_OPEN:   acc_open( (int *)msg );
						break;
						
				case WM_TOPPED:
				case WM_NEWTOP:
					        Wm_Topped( ( int *)msg );
						doedit = can_edit( tree, edit_obj );
					        if( doedit && !cursor )
					        {
					           objc_edit( tree, edit_obj, 0, (int *)&idx, ED_INIT );
						   cursor = TRUE;
					        }
						break;
						
				case WM_SIZED:
					doedit = can_edit( tree, edit_obj );
					
				/* fall through */
				case WM_MOVED:	/* if moving, that means we are on top, therefore, cursor is already on */
						doedit = can_edit( tree, edit_obj );
						if( !doedit )
							cursor = FALSE;
				case WM_REDRAW:
				case WM_FULLED:
				case WM_ARROWED:
				case WM_HSLID:
				case WM_VSLID:
				/* redraw 'n' shit */
						
					if( edit_obj && ( msg[0] == WM_REDRAW ))
					{
					    NoEdit( edit_obj );
					    rect = ObRect( edit_obj );
					    objc_offset( tree, edit_obj, &rect.g_x, &rect.g_y );

					    /* The offsets will take care of the blinking cursor
					     * area that needs to be redraw to erase it.
					     */
					    rect.g_y -= 3;
					    rect.g_w += 3;
					    rect.g_h += 6;

					    /* Clip the rectangle to the work area of the form.*/
					    rc_intersect( &w.work, &rect ); 

					    /* The redraw is necessary to turn off the blinking cursor.
					     * We are going to need to send a redraw message to the calling
					     * cpx in case they have any custom redraws that need to be done.
					     */
					    Redraw_XForm_Do( &rect );
					    
					    if( msg[0] == WM_REDRAW )
					    {	
					       for( idx = 0; idx < 8; idx++ )
						   puntmsg[idx] = msg[idx];
					    }

					}
					/* Here we redraw/move the area that is dirtied */    
					do_windows( (int *)msg, (int *)&event );
					if( edit_obj )
					    MakeEditable( edit_obj );
					doedit = can_edit( tree, edit_obj );
					if( !doedit )
						cursor = FALSE;
					if( msg[0] == WM_REDRAW )
					{	
					   for( idx = 0; idx < 8; idx++ )
						   puntmsg[idx] = msg[idx];
					   return -1;
					}
				break;

				default:if( msg[0] == AC_CLOSE )
						SetAccCloseState( TRUE );
					if( msg[0] == AP_TERM )
					{
					    SetAccCloseState( TRUE );
					    msg[0] = AC_CLOSE;
					}
					if( msg[0] == WM_CLOSED )
					        SetWmCloseState( TRUE );
					for( idx = 0; idx < 8; idx++ )
						puntmsg[idx] = msg[idx];
					return -1;
			}
		}


/*
 * What about hot keys?? AIEEE!!
 */
		if( EvKey() ) {

			/*
			 * form_keybd() encapsulated here
			 */
			direction = NODIR;
			switch( key ) {

				case K_RETURN:
				case K_ENTER:
					next_obj = 0;
					direction = DEFAULTDIR;
					break;

				case K_BACKTAB:
				case K_UP:
					direction = BACKWARD;
					break;

				case K_TAB:
				case K_DOWN:
					direction = FORWARD;
					break;
			}

			if( direction != NODIR ) {
				key = 0;
				next_obj = find_obj( tree, edit_obj, direction );
				if( (direction == DEFAULTDIR) && (next_obj != 0) ) {
					Objc_change( tree, next_obj, &w.work,
 				        ObState(next_obj)|SELECTED, TRUE );
					cont = FALSE;
				}
			}
			/*
			 * End of form_keybd()
			 */

			/* The above code clears 'key', therefore, we'll
			 * check key FIRST, then test the ASCII and 
			 * scancode
			 */
			if( key && ( !( key & 0xff ) )  )
			{
			  if( ( key != K_UP     )  &&
			      ( key != K_DOWN   )  &&
			      ( key != K_RIGHT  )  &&
			      ( key != K_LEFT   )  &&
			      ( key != K_RETURN )  &&
			      ( key != K_ENTER  )  &&
			      ( key != K_TAB )	   &&
			      ( key != K_BACKTAB)
			    )
			    {
			      puntmsg[0] = CT_KEY;
			      puntmsg[3] = key;
			      return -1;
			    }  
			}

			if( key && doedit )
				objc_edit( tree, edit_obj, key, (int *)&idx, ED_CHAR );
		}

		if( EvButton() ) {
			next_obj = objc_find( tree, ROOT, MAX_DEPTH, m.x, m.y );
			if( next_obj == NIL ) {
				Bconout( 2, 7 );
				next_obj = 0;
			} else {
				cont = fm_button( tree, next_obj, clicks, &next_obj );
			}
		}

		if(  doedit && (!cont || (next_obj != 0)) && ( next_obj != edit_obj) )
		{
		   objc_edit( tree, edit_obj, 0, (int *)&idx, ED_END );
		   cursor = FALSE;
		}   		
	}

	return next_obj;
}
END_TEST


START_TEST(tc_connect_localip)
{
	union {
		struct sockaddr_storage	ss;
		struct sockaddr_in	in;
	} sa;
	struct achat_channel    *s  = NULL;
	achat_rc		 rc = ACHAT_RC_ERROR;
	pid_t			 childpid;
	socklen_t		 sslen;

	s = acc_create();
	fail_if(s == NULL, "couldn't create server channel");
	fail_if(s->euid != (uid_t)-1, "euid expected -1 but is %i", s->euid);
	fail_if(s->egid != (gid_t)-1, "egid expected -1 but is %i", s->egid);

	rc = acc_settail(s, ACC_TAIL_SERVER);
	fail_if(rc != ACHAT_RC_OK, "server settail failed with rc=%d", rc);
	rc = acc_setsslmode(s, ACC_SSLMODE_CLEAR);
	fail_if(rc != ACHAT_RC_OK, "server setsslmode failed with rc=%d", rc);
	mark_point();

	bzero(&sa.ss, sizeof(sa.ss));
	sa.in.sin_family = AF_INET;
	sa.in.sin_port = 0;
	inet_aton("127.0.0.1", &(sa.in.sin_addr));
	rc = acc_setaddr(s, &sa.ss, sizeof(struct sockaddr_in));
	if (rc != ACHAT_RC_OK)
		fail("server setaddr failed with rc=%d", rc);
	mark_point();

	rc = acc_prepare(s);
	fail_if(rc != ACHAT_RC_OK, "server prepare failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));
	mark_point();

	bzero(&sa.ss, sizeof(sa.ss));
	sslen = sizeof(sa.ss);
	if (getsockname(s->fd, (struct sockaddr *)&sa.ss, &sslen) == -1)
		fail("error while asking about server socket name [%s]",
		    anoubis_strerror(errno));
	fail_if(sa.in.sin_port == 0,
	    "couldn't determine port of server socket");
	mark_point();

	switch (childpid = check_fork()) {
	case -1:
		fail("couldn't fork");
		break;
	case 0:
		/* child / client */
		tc_connect_lip_client(ntohs(sa.in.sin_port));
		check_waitpid_and_exit(0);
		break;
	default:
		/* parent / server */
		rc = acc_open(s);
		fail_if(rc != ACHAT_RC_OK, "server open failed with rc=%d [%s]",
		    rc, anoubis_strerror(errno));
		fail_unless(s->euid == (uid_t)-1, "euid: -1 expected but is %i",
			s->euid);
		fail_unless(s->egid == (gid_t)-1, "egid: -1 expected but is %i",
			s->egid);

		rc = acc_destroy(s);
		fail_if(rc != ACHAT_RC_OK, "server destroy failed with rc=%d",
		    rc);

		check_waitpid_and_exit(childpid);
		break;
	}
}
예제 #6
0
void
main( int argc, char *argv[], char *envp[] )
{
	int 	i;
/* 	-----	evnt_multi return parameters */
	int		event, msg[8], key, nclicks;
	MRETS	mrets;
	int  	rez;
/*
 * Initialize global arguments
 */
	if( (nargs = argc) != 1)
		args = argv;
	env = envp;

/*
 * See if we were run from the AUTO folder...
 */
	if( (gl_apid = appl_init()) == -1 ) {
		Cconws("\r\nError initializing GEM, hit a key...");
		Cconin();
		exit( gl_apid );
	}
	rez = Getrez() + 2;
	if(( rez != 2 ) && ( rez != 6 ) )
	{
	   /* Ensure that we run ONLY in ST LOW or TT MED - 640x480 16 colors */
	   form_alert( 1, "[3][ | This program runs in| ST LOW or TT MED Only][ OK ]" );
	   appl_exit();
	   exit( -1 );
	}
/*
 * Set up work_in to initialize VDI functions to useful values,
 * Get the physical workstation handle from the AES, then
 * open a virtual workstation and get our AES work area's extent.
 */
	work_in[0] = Getrez()+2; /* let's not gag GDOS */
	for( i = 1; i < 10; work_in[i++] = 1 )
	;
	work_in[10] = 2; /* raster coordinates */
	vhandle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox );
	v_opnvwk( work_in, &vhandle, work_out );
	xres = work_out[0];
	yres = work_out[1];

/*
 * Call initialization hooks
 */
	Wind_get( 0, WF_WORKXYWH, ( WARGS *)&desk );
	if( !rsrc_init() ) {
		form_alert( 1, "[3][ RSC ERROR ][ OK ]" );
		v_clsvwk( vhandle );
		appl_exit();
		exit( -1 );
	}

	wind_init();
	evnt_init();

/*
 * Main event loop
 */
	do {

		event = Evnt_multi( ev_mask, ev_clicks, ev_bmask, ev_bstate,
							&ev_m1, &ev_m2, ( WORD *)msg, ev_time,
							&mrets, ( WORD *)&key, ( WORD *)&nclicks );
		wind_update( BEG_UPDATE );
	/*
	 * call pre-event-processing hook
	 */
		if( evnt_hook( event, msg, &mrets, &key, &nclicks ) )
			continue;

	/* Dispatch events.
	 * It is possible to get more than one event at a time, so if the
	 * order of event handling is important to you, change the order
	 * in which they're handled here.
	 */
		if( event & MU_TIMER )
			do_timer( &event );

		if( event & MU_KEYBD )
			do_key( mrets.kstate, key, &event );

		if( event & MU_BUTTON )
			do_button( &mrets, nclicks, &event );

		if( event & MU_M1 )
			do_m1( &mrets, &event );

		if( event & MU_M2 )
			do_m2( &mrets, &event );

		if( event & MU_MESAG )
			switch( msg[0] ) {

				case MN_SELECTED:
					do_menu( msg, &event );
				break;

				case WM_REDRAW:
				case WM_TOPPED:
				case WM_CLOSED:
				case WM_FULLED:
				case WM_ARROWED:
				case WM_HSLID:
				case WM_VSLID:
				case WM_SIZED:
				case WM_MOVED:
				case WM_NEWTOP:
					do_windows( msg, &event );
				break;

				case AC_OPEN:
					acc_open( msg );
				break;

				case AC_CLOSE:
					acc_close( msg );
				break;

				default:
					msg_hook( msg, &event );
			} /* switch */
		/* MU_MESAG */

		wind_update( END_UPDATE );

	/*
	 * Event handling routines zero out the event variable
	 * to exit the application.
	 */
	} while( event );

	gem_exit( 0 );
}
예제 #7
0
파일: ComThread.cpp 프로젝트: genua/anoubis
ComThread::ConnectResult
ComThread::connect(void)
{
	struct sockaddr_storage	 ss;
	struct sockaddr_un	*ss_sun = (struct sockaddr_un *)&ss;
	achat_rc		 rc = ACHAT_RC_ERROR;
	int			 result;

	struct sigaction        act;

	sigemptyset(&act.sa_mask);
	act.sa_flags = 0;
	act.sa_handler = SIG_IGN;
	sigaction(SIGPIPE, &act, NULL);

	/*
	 * *** channel ***
	 */

	channel_ = acc_create();
	if (channel_ == 0)
		return (Failure);

	rc = acc_settail(channel_, ACC_TAIL_CLIENT);
	if (rc != ACHAT_RC_OK) {
		disconnect();
		return (Failure);
	}

	rc = acc_setsslmode(channel_, ACC_SSLMODE_CLEAR);
	if (rc != ACHAT_RC_OK) {
		disconnect();
		return (Failure);
	}

	bzero(&ss, sizeof(ss));
	ss_sun->sun_family = AF_UNIX;
	strlcpy(ss_sun->sun_path, socketPath_.fn_str(),
	    sizeof(ss_sun->sun_path));
	rc = acc_setaddr(channel_, &ss, sizeof(struct sockaddr_un));
	if (rc != ACHAT_RC_OK) {
		disconnect();
		return (Failure);
	}

	rc = acc_prepare(channel_);
	if (rc != ACHAT_RC_OK) {
		disconnect();
		return (Failure);
	}

	rc = acc_open(channel_);
	if (rc != ACHAT_RC_OK) {
		disconnect();
		return (Failure);
	}

	/*
	 * *** client ***
	 */

	client_ = anoubis_client_create(channel_, ANOUBIS_AUTH_TRANSPORTANDKEY,
	    &x_auth_callback);
	if (client_ == 0) {
		disconnect();
		return (Failure);
	}

	result = anoubis_client_connect(client_, ANOUBIS_PROTO_BOTH);

	/* Pass protocol version back to the JobCtrl */
	JobCtrl::instance()->protocolVersion_ =
	    anoubis_client_serverversion(client_);

	/* Convert result to a enum */
	switch (-result) {
	/* In case everything is allright */
	case X_AUTH_SUCCESS:
		return Success;
		/* NOTREACHED */
	/* In case of missmatching Version */
	case EPROTONOSUPPORT:
		disconnect();
		return VersionMismatch;
		/* NOTREACHED */
	/* In case of error while authentication*/
	case X_AUTH_NOKEY:
		disconnect();
		return AuthNoKey;
		/* NOTREACHED */
	case ANOUBIS_AUTHERR_KEY_MISMATCH:
		disconnect();
		return AuthWrongKeyId;
		/* NOTREACHED */
	case ANOUBIS_AUTHERR_KEY:
		disconnect();
		return AuthInvalidKey;
		/* NOTREACHED */
	case ANOUBIS_AUTHERR_CERT:
		disconnect();
		return AuthInvalidCert;
		/* NOTREACHED */
	/* Internal System Error */
	case ANOUBIS_AUTHERR_PKG:
	case ANOUBIS_AUTHERR_INVAL:
	case ANOUBIS_AUTHERR_RAND:
	case ANOUBIS_AUTHERR_NOMEM:
	case ANOUBIS_AUTHERR_SIGN:
	default:
		disconnect();
		return AuthSysFail;
		/* NOTREACHED */
	}

	/* Should not happen since we handel everythin before */
	return (Failure);
}
예제 #8
0
/*
 * main()
 * ================================================================
 */
void
main( void )
{
	int	event, msg[8], key, nclicks;
	MRETS	mrets;


/*
 * See if we were run from the AUTO folder...
 */
        gl_apid = appl_init();

	/* Get the AES version #.  TOS 3.0 is TT TOS */
	AES_Version = _GemParBlk.global[0];
/*
 * Set up work_in to initialize VDI functions to useful values,
 * Get the physical workstation handle from the AES, then
 * open a virtual workstation and get our AES work area's extent.
 */
	phys_handle = graf_handle(&gl_wchar,&gl_hchar,&gl_wbox,&gl_hbox );

	Wind_get( 0, WF_WORKXYWH, ( WARGS *)&desk );
	
	/* Call initialization hooks */
	rsrc_init();


	if( !open_vwork() )
        {
	   /* Unable to open workstation - exit application */
           form_alert( 1, alert18 );
	   gem_exit( 0 );
        }
	close_vwork();
	gl_ncolors = work_out[13];
	xres       = work_out[0];
	yres	   = work_out[1];
	vhandle = 0;

	
	wind_init();
	evnt_init();
	
	/* Main event loop */
	do
	{

		event = Evnt_multi( ev_mask, ev_clicks, ev_bmask, ev_bstate,
				    &ev_m1, &ev_m2, ( WORD *)msg, ev_time,
				    &mrets,(WORD *)&key,(WORD *)&nclicks );
		wind_update( BEG_UPDATE );
		

	/* Dispatch events.
	 * It is possible to get more than one event at a time, so if the
	 * order of event handling is important to you, change the order
	 * in which they're handled here.
	 */
		if( event & MU_MESAG )
			switch( msg[0] ) {

				case MN_SELECTED:
				break;

				case WM_REDRAW:
				case WM_TOPPED:
				case WM_CLOSED:
				case WM_FULLED:
				case WM_ARROWED:
				case WM_HSLID:
				case WM_VSLID:
				case WM_SIZED:
				case WM_MOVED:
				case WM_NEWTOP:
					do_windows( msg, &event );
				break;

				case AC_OPEN:
					acc_open( msg );
				break;
				
				case AP_TERM:
				case AC_CLOSE:
					acc_close( msg );
				break;

				default:
					break;
			} /* switch */
		/* MU_MESAG */

		wind_update( END_UPDATE );

	/*
	 * Event handling routines zero out the event variable
	 * to exit the application.
	 */
	} while( event );

	gem_exit( 0 );
}
예제 #9
0
END_TEST

START_TEST(tc_Sessions_three)
{
	union {
		struct sockaddr_storage	ss;
		struct sockaddr_un	un;
	} sa;
	struct achat_channel	*c  = NULL;
	achat_rc		 rc = ACHAT_RC_ERROR;
	struct anoubis_client   *client;
	struct anoubis_transaction * t;
	int count = 0;
	int ret;

	c = acc_create();
	fail_if(c == NULL, "couldn't create channel");
	rc = acc_settail(c, ACC_TAIL_CLIENT);
	fail_if(rc != ACHAT_RC_OK, "settail failed with rc=%d", rc);
	rc = acc_setsslmode(c, ACC_SSLMODE_CLEAR);
	fail_if(rc != ACHAT_RC_OK, "setsslmode failed with rc=%d", rc);
	mark_point();

	bzero(&sa.ss, sizeof(sa.ss));
	sa.un.sun_family = AF_UNIX;
	strlcpy(sa.un.sun_path, sockname, sizeof(sa.un.sun_path));
	rc = acc_setaddr(c, &sa.ss, sizeof(struct sockaddr_un));
	fail_if(rc != ACHAT_RC_OK, "setaddr failed with rc=%d", rc);
	mark_point();

	rc = acc_prepare(c);
	fail_if(rc != ACHAT_RC_OK, "prepare failed with rc=%d [%s]", rc,
	    anoubis_strerror(errno));
	rc = acc_open(c);
	fail_if(rc != ACHAT_RC_OK, "open failed with rc=%d [%s]", rc,
	    anoubis_strerror(errno));
	mark_point();

	client = anoubis_client_create(c, ANOUBIS_AUTH_TRANSPORT, NULL);
	fail_if(!client, "Failed to create client");
	mark_point();

	ret = anoubis_client_connect(client, ANOUBIS_PROTO_BOTH);
	fail_if(ret < 0, "client connect failed with code %d", ret);
	mark_point();

	t = anoubis_client_register_start(client, 0x123, 0, 0,
	    ANOUBIS_SOURCE_STAT);
	fail_if(!t, "Failed to register for stat events");
	while(count < 3) {
		struct anoubis_msg * m = anoubis_msg_new(4000);
		size_t length = 4000;
		fail_if(!m, "Cannot allocate message");
		rc = acc_receivemsg(c, m->u.buf, &length);
		fail_if(rc != ACHAT_RC_OK, "receive message returned %d", rc);
		anoubis_msg_resize(m, length);
		rc = anoubis_client_process(client, m);
		fail_if(rc != 1, "client process failed");
		m = anoubis_client_getnotify(client);
		if (m) {
			anoubis_dump(m, "NOTIFY");
			anoubis_msg_free(m);
			count++;
		}
	}
	anoubis_client_close(client);
	mark_point();

	rc = acc_destroy(c);
	fail_if(rc != ACHAT_RC_OK, "destroy failed with rc=%d", rc);
}
예제 #10
0
END_TEST

START_TEST(tc_Sessions_two)
{
	union {
		struct sockaddr_storage	ss;
		struct sockaddr_un	un;
	} sa;
	struct achat_channel	*c1  = NULL;
	struct achat_channel	*c2  = NULL;
	achat_rc		 rc = ACHAT_RC_ERROR;
	struct anoubis_client   *client1, *client2;
	int			 ret;

	c1 = acc_create();
	fail_if(c1 == NULL, "couldn't create first channel");
	rc = acc_settail(c1, ACC_TAIL_CLIENT);
	fail_if(rc != ACHAT_RC_OK, "1st channel settail failed with rc=%d", rc);
	rc = acc_setsslmode(c1, ACC_SSLMODE_CLEAR);
	fail_if(rc != ACHAT_RC_OK, "1st channel setsslmode failed with rc=%d",
	    rc);
	mark_point();

	c2 = acc_create();
	fail_if(c2 == NULL, "couldn't create second channel");
	rc = acc_settail(c2, ACC_TAIL_CLIENT);
	fail_if(rc != ACHAT_RC_OK, "2nd channel settail failed with rc=%d", rc);
	rc = acc_setsslmode(c2, ACC_SSLMODE_CLEAR);
	fail_if(rc != ACHAT_RC_OK, "2nd channel setsslmode failed with rc=%d",
	    rc);
	mark_point();

	bzero(&sa.ss, sizeof(sa.ss));
	sa.un.sun_family = AF_UNIX;
	strlcpy(sa.un.sun_path, sockname, sizeof(sa.un.sun_path));
	rc = acc_setaddr(c1, &sa.ss, sizeof(struct sockaddr_un));
	fail_if(rc != ACHAT_RC_OK, "1st channel setaddr failed with rc=%d", rc);
	rc = acc_setaddr(c2, &sa.ss, sizeof(struct sockaddr_un));
	fail_if(rc != ACHAT_RC_OK, "2nd channel setaddr failed with rc=%d", rc);
	mark_point();

	rc = acc_prepare(c1);
	fail_if(rc != ACHAT_RC_OK, "1st channel prepare failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));
	rc = acc_open(c1);
	fail_if(rc != ACHAT_RC_OK, "1st channel open failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));
	mark_point();

	client1 = anoubis_client_create(c1, ANOUBIS_AUTH_TRANSPORT, NULL);
	fail_if(!client1, "1st client create failed");
	mark_point();

	rc = acc_prepare(c2);
	fail_if(rc != ACHAT_RC_OK, "2nd channel prepare failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));
	rc = acc_open(c2);
	fail_if(rc != ACHAT_RC_OK, "2nd channel open failed with rc=%d [%s]",
	    rc, anoubis_strerror(errno));
	mark_point();
	client2 = anoubis_client_create(c2, ANOUBIS_AUTH_TRANSPORT, NULL);
	fail_if(!client1, "2nd client create failed");
	mark_point();

	ret = anoubis_client_connect(client1, ANOUBIS_PROTO_BOTH);
	fail_if(ret < 0, "1st client connect failed with %d", ret);
	mark_point();

	ret = anoubis_client_connect(client2, ANOUBIS_PROTO_BOTH);
	fail_if(ret < 0, "2nd client connect failed with %d", ret);
	mark_point();

	rc = acc_destroy(c1);
	fail_if(rc != ACHAT_RC_OK, "1st channel destroy failed with rc=%d", rc);

	rc = acc_destroy(c2);
	fail_if(rc != ACHAT_RC_OK, "2nd channel destroy failed with rc=%d", rc);
}