Add named output tag option (closes #1517)
This commit is contained in:
parent
64476f1c64
commit
dd8da88c5f
3 changed files with 10 additions and 4 deletions
|
@ -86,6 +86,7 @@ typedef struct r_cfg {
|
|||
int no_default_devices;
|
||||
struct r_device *devices;
|
||||
uint16_t num_r_devices;
|
||||
char *output_key;
|
||||
char *output_tag;
|
||||
list_t output_handler;
|
||||
struct dm_state *demod;
|
||||
|
|
|
@ -269,8 +269,8 @@ char const **well_known_output_fields(r_cfg_t *cfg)
|
|||
|
||||
if (cfg->verbose_bits)
|
||||
*p++ = "bits";
|
||||
if (cfg->output_tag)
|
||||
*p++ = "tag";
|
||||
if (cfg->output_key)
|
||||
*p++ = cfg->output_key;
|
||||
if (cfg->report_protocol)
|
||||
*p++ = "protocol";
|
||||
if (cfg->report_description)
|
||||
|
@ -679,7 +679,7 @@ void data_acquired_handler(r_device *r_dev, data_t *data)
|
|||
output_tag = file_basename(cfg->in_filename);
|
||||
}
|
||||
data = data_prepend(data,
|
||||
"tag", "Tag", DATA_STRING, output_tag,
|
||||
cfg->output_key, "", DATA_STRING, output_tag,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ static void usage(int exit_code)
|
|||
" Append output to file with :<filename> (e.g. -F csv:log.csv), defaults to stdout.\n"
|
||||
" Specify host/port for syslog with e.g. -F syslog:127.0.0.1:1514\n"
|
||||
" [-M time[:<options>] | protocol | level | stats | bits | help] Add various meta data to each output.\n"
|
||||
" [-K FILE | PATH | <tag>] Add an expanded token or fixed tag to every output line.\n"
|
||||
" [-K FILE | PATH | <tag> | <key>=<value>] Add an expanded token or fixed tag to every output line.\n"
|
||||
" [-C native | si | customary] Convert units in decoded output.\n"
|
||||
" [-T <seconds>] Specify number of seconds to run, also 12:34 or 1h23m45s\n"
|
||||
" [-E hop | quit] Hop/Quit after outputting successful event(s)\n"
|
||||
|
@ -1034,6 +1034,11 @@ static void parse_conf_option(r_cfg_t *cfg, int opt, char *arg)
|
|||
break;
|
||||
case 'K':
|
||||
cfg->output_tag = arg;
|
||||
cfg->output_key = asepc(&cfg->output_tag, '=');
|
||||
if (!cfg->output_tag) {
|
||||
cfg->output_tag = cfg->output_key;
|
||||
cfg->output_key = "tag";
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
if (!arg)
|
||||
|
|
Loading…
Add table
Reference in a new issue