comparison rvinterf/rvtat/main.c @ 448:261c1b6d936e

fcup-rvtat: added support for long strings with new fw versions
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 15 Jan 2019 06:01:04 +0000
parents e40bb5a6c6b9
children
comparison
equal deleted inserted replaced
447:e13f60d4f8dd 448:261c1b6d936e
13 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; 13 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
14 14
15 extern u_char rvi_msg[]; 15 extern u_char rvi_msg[];
16 extern int rvi_msg_len; 16 extern int rvi_msg_len;
17 17
18 char command[256], message[256]; 18 char command[508], message[508];
19 int cmd_with_msg; 19 int cmd_with_msg;
20 20
21 read_command_input(buf) 21 read_command_input(buf)
22 char *buf; 22 char *buf;
23 { 23 {
24 char *nl; 24 char *nl;
25 25
26 if (!fgets(buf, 256, stdin)) 26 if (!fgets(buf, 508, stdin))
27 return(0); 27 return(0);
28 nl = index(buf, '\n'); 28 nl = index(buf, '\n');
29 if (!nl) { 29 if (!nl) {
30 printf("Ecommand or message is too long\n"); 30 printf("Ecommand or message is too long\n");
31 exit(1); 31 exit(1);
32 } 32 }
33 *nl = '\0'; 33 *nl = '\0';
34 return(1); 34 return(1);
35 } 35 }
36 36
37 send_to_target(str) 37 send_to_target_prefix(str)
38 char *str;
39 {
40 u_char sendpkt[MAX_PKT_TO_TARGET];
41
42 /* fill out the packet */
43 sendpkt[0] = RVT_AT_HEADER;
44 sendpkt[1] = 0x01;
45 bcopy(str, sendpkt + 2, 252);
46 /* send it! */
47 send_pkt_to_target(sendpkt, 254);
48 return(0);
49 }
50
51 send_to_target_plain(str)
38 char *str; 52 char *str;
39 { 53 {
40 unsigned len; 54 unsigned len;
41 u_char sendpkt[MAX_PKT_TO_TARGET+1]; 55 u_char sendpkt[MAX_PKT_TO_TARGET+1];
42 56
44 /* fill out the packet */ 58 /* fill out the packet */
45 sendpkt[0] = RVT_AT_HEADER; 59 sendpkt[0] = RVT_AT_HEADER;
46 strcpy(sendpkt + 1, str); 60 strcpy(sendpkt + 1, str);
47 /* send it! */ 61 /* send it! */
48 send_pkt_to_target(sendpkt, len + 1); 62 send_pkt_to_target(sendpkt, len + 1);
63 return(0);
64 }
65
66 send_to_target(str)
67 char *str;
68 {
69 unsigned len;
70
71 len = strlen(str);
72 if (len <= 254)
73 send_to_target_plain(str);
74 else {
75 send_to_target_prefix(str);
76 send_to_target_plain(str + 252);
77 }
49 return(0); 78 return(0);
50 } 79 }
51 80
52 execute_command() 81 execute_command()
53 { 82 {