comparison loadtools/lacrc32.c @ 640:5385aca4d813

fc-loadtool module refactoring: CRC-32 functions split out
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 01 Mar 2020 18:54:29 +0000
parents
children
comparison
equal deleted inserted replaced
639:963d15a808eb 640:5385aca4d813
1 /*
2 * This module implements the function for getting a CRC-32 computation
3 * from loadagent.
4 */
5
6 #include <sys/types.h>
7 #include <stdio.h>
8 #include <stdint.h>
9 #include <string.h>
10 #include <strings.h>
11 #include <stdlib.h>
12
13 extern char target_response_line[];
14
15 crc32_on_target(area_base, area_len, retptr)
16 u_long area_base, area_len, *retptr;
17 {
18 char arg1[10], arg2[10], *argv[4];
19 int stat;
20 char *strtoul_endp;
21
22 sprintf(arg1, "%lx", area_base);
23 sprintf(arg2, "%lx", area_len);
24 argv[0] = "crc32";
25 argv[1] = arg1;
26 argv[2] = arg2;
27 argv[3] = 0;
28 tpinterf_make_cmd(argv);
29 if (tpinterf_send_cmd() < 0)
30 return(-1);
31 stat = tpinterf_capture_output_oneline(10); /* 10 s timeout */
32 if (stat != 1) {
33 errout: fprintf(stderr, "error: malformed response to crc32 command\n");
34 return(-1);
35 }
36 if (strlen(target_response_line) != 8)
37 goto errout;
38 *retptr = strtoul(target_response_line, &strtoul_endp, 16);
39 if (strtoul_endp != target_response_line + 8)
40 goto errout;
41 return(0);
42 }