comparison ffstools/newcomp/compile-fc-batt.c @ 752:c79aaed75bd8

compile-fc-batt: allow possible third field in source lines Battery tables maintained in the fc-battery-conf repository will now have a third field added, defining thresholds for the battery bars icon, and there will be a new utility to compile them into the new /etc/batterytab2 file read by the FC Tourmaline version of our FCHG driver. For backward compatibility with the original Magnetite version of FCHG, compile-fc-batt remains the tool for compiling the original /etc/batterytab file format, and it needs to ignore the newly added third field in battery table sources.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Nov 2020 20:37:55 +0000
parents 182c3ae209f6
children
comparison
equal deleted inserted replaced
751:5dd748850f2b 752:c79aaed75bd8
1 /* 1 /*
2 * This utility compiles a table of battery thresholds for the new FreeCalypso 2 * This utility compiles a table of battery thresholds for the 2017-12 version
3 * battery management code from ASCII source into the binary form suitable 3 * of FreeCalypso battery management code from ASCII source into the binary
4 * for uploading into /etc/batterytab on a FreeCalypso device. 4 * form suitable for uploading into /etc/batterytab on a FreeCalypso device.
5 */ 5 */
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <string.h> 8 #include <string.h>
9 #include <strings.h> 9 #include <strings.h>
41 if (!isdigit(*cp)) 41 if (!isdigit(*cp))
42 goto inv; 42 goto inv;
43 percent = strtoul(cp, 0, 10); 43 percent = strtoul(cp, 0, 10);
44 while (isdigit(*cp)) 44 while (isdigit(*cp))
45 cp++; 45 cp++;
46 while (isspace(*cp)) 46 if (*cp && !isspace(*cp))
47 cp++;
48 if (*cp != '\0' && *cp != '#')
49 goto inv; 47 goto inv;
48 /* ignore possible third field added in 2020-11 for bars threshold */
50 if (mv > 0xFFFF) { 49 if (mv > 0xFFFF) {
51 fprintf(stderr, "%s line %d: the millivolt value is invalid\n", 50 fprintf(stderr, "%s line %d: the millivolt value is invalid\n",
52 infname, lineno); 51 infname, lineno);
53 exit(ERROR_USAGE); 52 exit(ERROR_USAGE);
54 } 53 }