示例#1
0
int Vid_GetKey()
{
	int l;

	getevents();
	
	return input_buffer_pop();
}
示例#2
0
文件: statestr.c 项目: sambuc/netbsd
/*
 * statustoa - return a descriptive string for a peer status
 */
char *
statustoa(
	int type,
	int st
	)
{
	char *	cb;
	char *	cc;
	u_char	pst;

	LIB_GETBUF(cb);

	switch (type) {

	case TYPE_SYS:
		snprintf(cb, LIB_BUFLENGTH, "%s, %s, %s, %s",
			 getcode(CTL_SYS_LI(st), leap_codes),
			 getcode(CTL_SYS_SOURCE(st), sync_codes),
			 getevents(CTL_SYS_NEVNT(st)),
			 getcode(CTL_SYS_EVENT(st), sys_codes));
		break;
	
	case TYPE_PEER:
		pst = (u_char)CTL_PEER_STATVAL(st);
		snprintf(cb, LIB_BUFLENGTH, "%s, %s, %s",
			 peer_st_flags(pst),
			 getcode(pst & 0x7, select_codes),
			 getevents(CTL_PEER_NEVNT(st)));
		if (CTL_PEER_EVENT(st) != EVNT_UNSPEC) {
			cc = cb + strlen(cb);
			snprintf(cc, LIB_BUFLENGTH - (cc - cb), ", %s",
				 getcode(CTL_PEER_EVENT(st),
					 peer_codes));
		}
		break;
	
	case TYPE_CLOCK:
		snprintf(cb, LIB_BUFLENGTH, "%s, %s",
			 getevents(CTL_SYS_NEVNT(st)),
			 getcode((st) & 0xf, clock_codes));
		break;
	}

	return cb;
}
示例#3
0
static void action(void)
{
    UBYTE *buf = AllocVec(SCREENWIDTH * SCREENHEIGHT * sizeof(ULONG), MEMF_PUBLIC);
    ULONG i;
    
    if (buf)
    {
    	ReadPixelArray(buf,
	    	       0,
		       0,
		       SCREENWIDTH * sizeof(ULONG),
		       win->RPort,
		       win->BorderLeft,
		       win->BorderTop,
		       SCREENWIDTH,
		       SCREENHEIGHT,
		       RECTFMT_ARGB);

    	for(i = 0; i < SCREENWIDTH * SCREENHEIGHT * 4; i += 4)
	{
	    buf[i + 1] /= 2;
	    buf[i + 2] /= 2;
	    buf[i + 3] /= 2;	    
	}
	
    	WritePixelArray(buf,
	    		0,
			0,
			SCREENWIDTH * sizeof(ULONG),
			win->RPort,
			win->BorderLeft,
			win->BorderTop,
			SCREENWIDTH,
			SCREENHEIGHT,
			RECTFMT_ARGB);
		       
    }
    
    while (!Keys[KC_ESC])
    {
    	WaitPort(win->UserPort);
        getevents();
	
    } /* while(!Keys[KC_ESC]) */

    if (buf)
	FreeVec(buf);
}
示例#4
0
文件: statestr.c 项目: Distrotech/ntp
/*
 * statustoa - return a descriptive string for a peer status
 */
char *
statustoa(
	int type,
	int st
	)
{
	char *cb;
	u_char pst;

	LIB_GETBUF(cb);

	switch (type) {
	    case TYPE_SYS:
		strcpy(cb, getcode(CTL_SYS_LI(st), leap_codes));
		strcat(cb, ", ");
		strcat(cb, getcode(CTL_SYS_SOURCE(st), sync_codes));
		strcat(cb, ", ");
		strcat(cb, getevents(CTL_SYS_NEVNT(st)));
		strcat(cb, ", ");
		strcat(cb, getcode(CTL_SYS_EVENT(st), sys_codes));
		break;
	
	    case TYPE_PEER:

		/*
		 * Handcraft the bits
		 */
		pst = (u_char) CTL_PEER_STATVAL(st);
		if (pst & CTL_PST_CONFIG)
			strcpy(cb, "conf");
		if (pst & CTL_PST_AUTHENABLE) {
			if (pst & CTL_PST_CONFIG)
				strcat(cb, ", authenb");
			else
				strcat(cb, "authenb");
		}
		if (pst & CTL_PST_AUTHENTIC) {
			if (pst & (CTL_PST_CONFIG | CTL_PST_AUTHENABLE))
				strcat(cb, ", auth");
			else
				strcat(cb, "auth");
		}
		if (pst & CTL_PST_REACH) {
			if (pst & (CTL_PST_CONFIG | CTL_PST_AUTHENABLE |
			    CTL_PST_AUTHENTIC))
				strcat(cb, ", reach");
			else
				strcat(cb, "reach");
		}
		if (pst & CTL_PST_BCAST) {
			if (pst & (CTL_PST_CONFIG | CTL_PST_AUTHENABLE |
			    CTL_PST_AUTHENTIC | CTL_PST_REACH))
				strcat(cb, ", bcst");
			else
				strcat(cb, "bcst");
		}

		/*
		 * Now the codes
		 */
		strcat(cb, ", ");
		strcat(cb, getcode(pst & 0x7, select_codes));
		strcat(cb, ", ");
		strcat(cb, getevents(CTL_PEER_NEVNT(st)));
		if (CTL_PEER_EVENT(st) != EVNT_UNSPEC) {
			strcat(cb, ", ");
			strcat(cb, getcode(CTL_PEER_EVENT(st),
			    peer_codes));
		}
		break;
	
	    case TYPE_CLOCK:
		strcat(cb, ", ");
		strcat(cb, getevents(CTL_SYS_NEVNT(st)));
		strcat(cb, ", ");
		strcat(cb, getcode((st) & 0xf, clock_codes));
		break;
	}
	return cb;
}
示例#5
0
BOOL Vid_GetCtrlBreak()
{
	getevents();
	return ctrlbreak;
}
示例#6
0
文件: poll.c 项目: panliang/nanomsg
int main ()
{
    int rc;
    int sb;
    char buf [3];
    struct nn_thread thread;
    struct nn_pollfd pfd [2];

    /* Test nn_poll() function. */
    sb = test_socket (AF_SP, NN_PAIR);
    test_bind (sb, SOCKET_ADDRESS);
    sc = test_socket (AF_SP, NN_PAIR);
    test_connect (sc, SOCKET_ADDRESS);
    test_send (sc, "ABC");
    nn_sleep (100);
    pfd [0].fd = sb;
    pfd [0].events = NN_POLLIN | NN_POLLOUT;
    pfd [1].fd = sc;
    pfd [1].events = NN_POLLIN | NN_POLLOUT;
    rc = nn_poll (pfd, 2, -1);
    errno_assert (rc >= 0);
    nn_assert (rc == 2);
    nn_assert (pfd [0].revents == (NN_POLLIN | NN_POLLOUT));
    nn_assert (pfd [1].revents == NN_POLLOUT);
    test_close (sc);
    test_close (sb);

    /*  Create a simple topology. */
    sb = test_socket (AF_SP, NN_PAIR);
    test_bind (sb, SOCKET_ADDRESS);
    sc = test_socket (AF_SP, NN_PAIR);
    test_connect (sc, SOCKET_ADDRESS);

    /*  Check the initial state of the socket. */
    rc = getevents (sb, NN_IN | NN_OUT, 1000);
    nn_assert (rc == NN_OUT);

    /*  Poll for IN when there's no message available. The call should
        time out. */
    rc = getevents (sb, NN_IN, 10);
    nn_assert (rc == 0);

    /*  Send a message and start polling. This time IN event should be
        signaled. */
    test_send (sc, "ABC");
    rc = getevents (sb, NN_IN, 1000);
    nn_assert (rc == NN_IN);

    /*  Receive the message and make sure that IN is no longer signaled. */
    test_recv (sb, "ABC");
    rc = getevents (sb, NN_IN, 10);
    nn_assert (rc == 0);

    /*  Check signalling from a different thread. */
    nn_thread_init (&thread, routine1, NULL);
    rc = getevents (sb, NN_IN, 1000);
    nn_assert (rc == NN_IN);
    test_recv (sb, "ABC");
    nn_thread_term (&thread);

    /*  Check terminating the library from a different thread. */
    nn_thread_init (&thread, routine2, NULL);
    rc = getevents (sb, NN_IN, 1000);
    nn_assert (rc == NN_IN);
    rc = nn_recv (sb, buf, sizeof (buf), 0);
    nn_assert (rc < 0 && nn_errno () == ETERM);
    nn_thread_term (&thread);

    /*  Clean up. */
    test_close (sc);
    test_close (sb);

    return 0;
}