FreeCalypso > hg > freecalypso-sw
comparison rvinterf/etm/interf.c @ 182:13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 24 Nov 2013 06:59:09 +0000 |
parents | |
children | 85222710dc92 |
comparison
equal
deleted
inserted
replaced
181:6800c2cc8c51 | 182:13a0348ffce4 |
---|---|
1 /* | |
2 * This module implements the link to rvinterf. | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <unistd.h> | |
9 #include "../localsock.h" | |
10 | |
11 extern int sock; | |
12 | |
13 u_char rvi_msg[LOCALSOCK_MAX_MSG]; | |
14 int rvi_msg_len; | |
15 | |
16 static int rx_state, rx_left; | |
17 static u_char *rx_ptr; | |
18 | |
19 void | |
20 localsock_prep_for_length_rx() | |
21 { | |
22 rx_state = 0; | |
23 rx_ptr = rvi_msg; | |
24 rx_left = 2; | |
25 } | |
26 | |
27 static void | |
28 prep_for_message_rx() | |
29 { | |
30 rx_state = 1; | |
31 rx_ptr = rvi_msg; | |
32 rx_left = rvi_msg_len; | |
33 } | |
34 | |
35 void | |
36 process_msg_from_rvinterf() | |
37 { | |
38 | |
39 | |
40 } | |
41 | |
42 void | |
43 handle_rvinterf_input() | |
44 { | |
45 int cc; | |
46 | |
47 cc = read(sock, rx_ptr, rx_left); | |
48 if (cc <= 0) { | |
49 tty_cleanup(); | |
50 perror("read from rvinterf socket"); | |
51 exit(1); | |
52 } | |
53 rx_ptr += cc; | |
54 rx_left -= cc; | |
55 if (rx_left) | |
56 return; | |
57 /* got the thing, process it */ | |
58 if (rx_state) { | |
59 process_msg_from_rvinterf(); | |
60 localsock_prep_for_length_rx(); | |
61 } else { | |
62 rvi_msg_len = rvi_msg[0] << 8 | rvi_msg[1]; | |
63 if (rvi_msg_len < 1 || rvi_msg_len > LOCALSOCK_MAX_MSG) { | |
64 tty_cleanup(); | |
65 fprintf(stderr, | |
66 "Invalid length from rvinterf: %02X%02X\n", | |
67 rvi_msg[0], rvi_msg[1]); | |
68 exit(1); | |
69 } | |
70 prep_for_message_rx(); | |
71 } | |
72 } |