comparison rvinterf/libasync/rvtrace.c @ 0:e7502631a0f9

initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Jun 2016 00:13:35 +0000
parents
children 6a0aa8d36d06
comparison
equal deleted inserted replaced
-1:000000000000 0:e7502631a0f9
1 /*
2 * Here we detect and handle "Lost Message" packets.
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <strings.h>
9 #include <stdlib.h>
10 #include "pktmux.h"
11 #include "limits.h"
12 #include "localsock.h"
13
14 extern u_char rvi_msg[];
15 extern int rvi_msg_len;
16
17 void
18 safe_print_trace(src, srclen, dest)
19 u_char *src;
20 char *dest;
21 {
22 int i, c;
23 char *dp;
24
25 dp = dest;
26 for (i = 0; i < srclen; i++) {
27 c = src[i];
28 if (c & 0x80) {
29 *dp++ = 'M';
30 *dp++ = '-';
31 c &= 0x7F;
32 }
33 if (c < 0x20) {
34 *dp++ = '^';
35 *dp++ = c + '@';
36 } else if (c == 0x7F) {
37 *dp++ = '^';
38 *dp++ = '?';
39 } else
40 *dp++ = c;
41 }
42 *dp = '\0';
43 }
44
45 void
46 handle_useid_0()
47 {
48 char buf[MAX_PKT_FROM_TARGET*4];
49
50 if (strncmp(rvi_msg + 7, "RVT: Lost Message", 17))
51 return;
52 safe_print_trace(rvi_msg + 7, rvi_msg_len - 7, buf);
53 async_msg_output(buf);
54 }