mirror of
https://github.com/tio/tio.git
synced 2026-05-01 23:07:58 +02:00
Replace inih with glib key file parser
After including the use of glib we might as well replace inih with the glib key file parser. All configuraiton file parsing has been reworked and also the options parsing has been cleaned up, resulting in better and stricter configuration file and option value checks. Compared to old, configuration files now requires any default configurations to be put in a group/section named [default]. Configuration file keywords such as "enable", "disable", "on", "off", "yes", "no", "0", "1" have been retired. Now only "true" and "false" apply to boolean configuration options. This is done to simplify things and avoid any confusion. The pattern option feature has been reworked so now the user can now access the full match string and any matching subexpression using the %mN syntax. For example: [usb devices] pattern = usb([0-9]*) device = /dev/ttyUSB%m1 Then when using tio: $ tio usb12 %m0 = 'usb12' // Full match string %m1 = 12 // First match subexpression Which results in device = /dev/ttyUSB12
This commit is contained in:
parent
68d3b845b2
commit
65c5a068d8
23 changed files with 969 additions and 723 deletions
|
|
@ -93,60 +93,3 @@ char *timestamp_current_time(void)
|
|||
|
||||
return (len < TIME_STRING_SIZE_MAX) ? time_string : NULL;
|
||||
}
|
||||
|
||||
const char* timestamp_state_to_string(timestamp_t timestamp)
|
||||
{
|
||||
switch (timestamp)
|
||||
{
|
||||
case TIMESTAMP_NONE:
|
||||
return "disabled";
|
||||
break;
|
||||
|
||||
case TIMESTAMP_24HOUR:
|
||||
return "24hour";
|
||||
break;
|
||||
|
||||
case TIMESTAMP_24HOUR_START:
|
||||
return "24hour-start";
|
||||
break;
|
||||
|
||||
case TIMESTAMP_24HOUR_DELTA:
|
||||
return "24hour-delta";
|
||||
break;
|
||||
|
||||
case TIMESTAMP_ISO8601:
|
||||
return "iso8601";
|
||||
break;
|
||||
|
||||
default:
|
||||
return "unknown";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
timestamp_t timestamp_option_parse(const char *arg)
|
||||
{
|
||||
timestamp_t timestamp = TIMESTAMP_24HOUR; // Default
|
||||
|
||||
if (arg != NULL)
|
||||
{
|
||||
if (strcmp(arg, "24hour") == 0)
|
||||
{
|
||||
return TIMESTAMP_24HOUR;
|
||||
}
|
||||
else if (strcmp(arg, "24hour-start") == 0)
|
||||
{
|
||||
return TIMESTAMP_24HOUR_START;
|
||||
}
|
||||
else if (strcmp(arg, "24hour-delta") == 0)
|
||||
{
|
||||
return TIMESTAMP_24HOUR_DELTA;
|
||||
}
|
||||
else if (strcmp(arg, "iso8601") == 0)
|
||||
{
|
||||
return TIMESTAMP_ISO8601;
|
||||
}
|
||||
}
|
||||
|
||||
return timestamp;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue