FreeCalypso > hg > freecalypso-reveng
view miscprog/pirbattextr.c @ 338:b730c7844233
fluid-mnf/fileio.c: passes compilation
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 13 Mar 2020 02:26:02 +0000 |
parents | 30804198d5d0 |
children |
line wrap: on
line source
/* * This program extracts the a_pwr_thresholds[] table from one of Pirelli's * fw images and converts the numbers to decimal. */ #include <sys/types.h> #include <sys/file.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> struct entry { u_char mvolt[2]; u_char percent; u_char pad; }; struct entry array[21]; read_array_from_image(filename, offset_arg) char *filename, *offset_arg; { int fd; fd = open(filename, O_RDONLY); if (fd < 0) { perror(filename); exit(1); } lseek(fd, strtoul(offset_arg, 0, 0), 0); read(fd, array, sizeof array); close(fd); } dump_array() { int i; unsigned mvolt; for (i = 0; i < 21; i++) { mvolt = array[i].mvolt[0] | (array[i].mvolt[1] << 8); printf("%4u\t%u\n", mvolt, array[i].percent); } } main(argc, argv) char **argv; { if (argc != 3) { fprintf(stderr, "usage: %s fw-image offset\n", argv[0]); exit(1); } read_array_from_image(argv[1], argv[2]); dump_array(); exit(0); }