enhance: toml format
This commit is contained in:
@@ -46,6 +46,7 @@ static int parse_snowflake_section(toml_table_t *root, struct snowflake_options
|
||||
// retuun -1: failed
|
||||
static int parse_packet_io_section(toml_table_t *root, struct packet_io_options *opts)
|
||||
{
|
||||
char *temp;
|
||||
const char *ptr;
|
||||
toml_table_t *table;
|
||||
toml_array_t *mask_array;
|
||||
@@ -58,20 +59,21 @@ static int parse_packet_io_section(toml_table_t *root, struct packet_io_options
|
||||
}
|
||||
|
||||
ptr = toml_raw_in(table, "mode");
|
||||
if (ptr == NULL)
|
||||
temp = NULL;
|
||||
if (ptr == NULL || toml_rtos(ptr, &temp) != 0)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing packet_io->mode");
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(ptr, "dumpfile") == 0)
|
||||
if (strcmp(temp, "dumpfile") == 0)
|
||||
{
|
||||
opts->mode = PACKET_IO_DUMPFILE;
|
||||
}
|
||||
else if (strcmp(ptr, "dumpfilelist") == 0)
|
||||
else if (strcmp(temp, "dumpfilelist") == 0)
|
||||
{
|
||||
opts->mode = PACKET_IO_DUMPFILELIST;
|
||||
}
|
||||
else if (strcmp(ptr, "marsio") == 0)
|
||||
else if (strcmp(temp, "marsio") == 0)
|
||||
{
|
||||
opts->mode = PACKET_IO_MARSIO;
|
||||
}
|
||||
@@ -84,31 +86,33 @@ static int parse_packet_io_section(toml_table_t *root, struct packet_io_options
|
||||
if (opts->mode == PACKET_IO_DUMPFILE || opts->mode == PACKET_IO_DUMPFILELIST)
|
||||
{
|
||||
ptr = toml_raw_in(table, "dumpfile_path");
|
||||
if (ptr == NULL)
|
||||
temp = NULL;
|
||||
if (ptr == NULL || toml_rtos(ptr, &temp) != 0)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing packet_io->dumpfile_path");
|
||||
return -1;
|
||||
}
|
||||
// skip ""
|
||||
strncpy(opts->dumpfile_path, ptr + 1, strlen(ptr) - 2);
|
||||
strcpy(opts->dumpfile_path, temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = toml_raw_in(table, "app_symbol");
|
||||
if (ptr == NULL)
|
||||
temp = NULL;
|
||||
if (ptr == NULL || toml_rtos(ptr, &temp) != 0)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing packet_io->app_symbol");
|
||||
return -1;
|
||||
}
|
||||
strncpy(opts->app_symbol, ptr, sizeof(opts->app_symbol) - 1);
|
||||
strcpy(opts->app_symbol, temp);
|
||||
|
||||
ptr = toml_raw_in(table, "dev_symbol");
|
||||
if (ptr == NULL)
|
||||
temp = NULL;
|
||||
if (ptr == NULL || toml_rtos(ptr, &temp) != 0)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing packet_io->dev_symbol");
|
||||
return -1;
|
||||
}
|
||||
strncpy(opts->dev_symbol, ptr, sizeof(opts->dev_symbol) - 1);
|
||||
strcpy(opts->dev_symbol, temp);
|
||||
}
|
||||
|
||||
ptr = toml_raw_in(table, "nr_threads");
|
||||
|
||||
Reference in New Issue
Block a user