コード例 #1
0
ファイル: example.c プロジェクト: Alushi/libmyolinux
int main(){
	unsigned char buffer[30];

	struct sockaddr_in server;
	memset(&server, 0, sizeof(struct sockaddr_in));
	server.sin_family = AF_INET;
	server.sin_addr.s_addr = htonl(INADDR_ANY);
	server.sin_port = htons(6970);

    int sock = socket(AF_INET, SOCK_STREAM, 0);
    bind(sock, (struct sockaddr *) &server, sizeof(server));

    listen(sock, 10);
    int conn = accept(sock, (struct sockaddr *) NULL, NULL);

    while (1) {
    	recv(conn, buffer, 30, 0);
    	parse_gesture(buffer);
    }

    close(conn);
    close(sock);

    /* Real sample packet */
    // unsigned char data[30] = {0x0,0x0,0xc2,0xbd,0x0,0x0,0x48,0x3c,0x0,0x80,0x71,0x3f,0x0,0x4c,0x0d,0xbf,0x0,0x40,0xbd,0x0,0x20,0x9a,0xbd,0x0,0x6c,0x54,0x3f,0xff,0x01,0x0};

    // parse_packet(data);

    return 0;
}
コード例 #2
0
ファイル: vcontrol.c プロジェクト: 0xDEC0DE/uqm-0.6.4-ee
void
VControl_ParseGesture (VCONTROL_GESTURE *g, const char *spec)
{
	parse_state ps;

	strncpy (ps.line, spec, LINE_SIZE);
	ps.line[LINE_SIZE] = '\0';
	ps.index = ps.error = 0;
	ps.linenum = -1;

	next_token (&ps);
	parse_gesture (&ps, g);
	if (ps.error)
		printf ("Error parsing %s\n", spec);
}