FreeCalypso > hg > freecalypso-sw
comparison rvinterf/asyncshell/sendarb.c @ 1013:6eee1e547778
fc-shell: arbitrary send command implemented in interactive mode
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 20 Mar 2016 22:27:07 +0000 |
parents | 93f4fc26b204 |
children |
comparison
equal
deleted
inserted
replaced
1012:93f4fc26b204 | 1013:6eee1e547778 |
---|---|
8 #include <string.h> | 8 #include <string.h> |
9 #include <strings.h> | 9 #include <strings.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
11 #include "limits.h" | 11 #include "limits.h" |
12 | 12 |
13 cmd_send_oneshot(argc, argv) | 13 cmd_send_common(argc, argv) |
14 char **argv; | 14 char **argv; |
15 { | 15 { |
16 u_char sendpkt[MAX_PKT_TO_TARGET]; | 16 u_char sendpkt[MAX_PKT_TO_TARGET]; |
17 unsigned pktlen = argc - 1, i; | 17 unsigned pktlen = argc, i; |
18 char *endp; | 18 char *endp; |
19 | 19 |
20 for (i = 0; i < pktlen; i++) { | 20 for (i = 0; i < pktlen; i++) { |
21 sendpkt[i] = strtoul(argv[i+1], &endp, 16); | 21 sendpkt[i] = strtoul(argv[i], &endp, 16); |
22 if (*endp) { | 22 if (*endp) { |
23 printf( | 23 printf( |
24 "error: all arguments to send command must be hex bytes\n"); | 24 "error: all arguments to send command must be hex bytes\n"); |
25 return(1); | 25 return(1); |
26 } | 26 } |
27 } | 27 } |
28 /* send it! */ | 28 /* send it! */ |
29 send_pkt_to_target(sendpkt, pktlen); | 29 send_pkt_to_target(sendpkt, pktlen); |
30 return(0); | 30 return(0); |
31 } | 31 } |
32 | |
33 void | |
34 cmd_send_interactive(argstr) | |
35 char *argstr; | |
36 { | |
37 char *argv[MAX_PKT_TO_TARGET+1]; | |
38 int argc, rc; | |
39 | |
40 rc = parse_interactive_command_into_argv(argstr, argv, 1, | |
41 MAX_PKT_TO_TARGET, &argc); | |
42 if (rc < 0) | |
43 return; | |
44 cmd_send_common(argc, argv); | |
45 } | |
46 | |
47 cmd_send_oneshot(argc, argv) | |
48 char **argv; | |
49 { | |
50 return cmd_send_common(argc - 1, argv + 1); | |
51 } |