FreeCalypso > hg > freecalypso-sw
comparison rvinterf/libg23/fmtdispatch.c @ 976:ca65f5adf1af
rvinterf: print old ASCII GPF traces emitted by 20020917 firmware on D-Sample
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 29 Nov 2015 05:22:41 +0000 |
parents | 42c91c51ca7f |
children |
comparison
equal
deleted
inserted
replaced
975:0d7cc054ef72 | 976:ca65f5adf1af |
---|---|
52 /* checks pass */ | 52 /* checks pass */ |
53 return(1); | 53 return(1); |
54 } | 54 } |
55 | 55 |
56 static void | 56 static void |
57 print_malformed(rxpkt, rxpkt_len, outbuf) | 57 print_unknown_bin(rxpkt, rxpkt_len, outbuf) |
58 u_char *rxpkt; | 58 u_char *rxpkt; |
59 char *outbuf; | 59 char *outbuf; |
60 { | 60 { |
61 int i; | 61 int i; |
62 char *dp; | 62 char *dp; |
67 for (i = 1; i < rxpkt_len; i++) { | 67 for (i = 1; i < rxpkt_len; i++) { |
68 sprintf(dp, " %02X", rxpkt[i]); | 68 sprintf(dp, " %02X", rxpkt[i]); |
69 dp += 3; | 69 dp += 3; |
70 } | 70 } |
71 *dp = '\0'; | 71 *dp = '\0'; |
72 } | |
73 | |
74 static void | |
75 print_old_ascii(rxpkt, rxpkt_len, outbuf) | |
76 u_char *rxpkt; | |
77 char *outbuf; | |
78 { | |
79 char *dp; | |
80 int txtlen = rxpkt_len - 1; | |
81 | |
82 dp = outbuf; | |
83 strcpy(dp, "GPF ASC: "); | |
84 dp += 9; | |
85 bcopy(rxpkt + 1, dp, txtlen); | |
86 dp += txtlen; | |
87 *dp = '\0'; | |
88 } | |
89 | |
90 static int | |
91 is_old_ascii(rxpkt, rxpkt_len) | |
92 u_char *rxpkt; | |
93 { | |
94 int i, c; | |
95 | |
96 for (i = 1; i < rxpkt_len; i++) { | |
97 c = rxpkt[i]; | |
98 if (c < ' ' || c > '~') | |
99 return(0); | |
100 } | |
101 return(1); | |
102 } | |
103 | |
104 static void | |
105 print_malformed(rxpkt, rxpkt_len, outbuf) | |
106 u_char *rxpkt; | |
107 char *outbuf; | |
108 { | |
109 if (is_old_ascii(rxpkt, rxpkt_len)) | |
110 print_old_ascii(rxpkt, rxpkt_len, outbuf); | |
111 else | |
112 print_unknown_bin(rxpkt, rxpkt_len, outbuf); | |
72 } | 113 } |
73 | 114 |
74 void | 115 void |
75 format_g23_packet(rxpkt, rxpkt_len, outbuf) | 116 format_g23_packet(rxpkt, rxpkt_len, outbuf) |
76 u_char *rxpkt; | 117 u_char *rxpkt; |