Skip to content

Commit

Permalink
parse_params(): allow processing of lone tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
f00b4r0 committed Sep 2, 2024
1 parent cd5e4c1 commit 57e1e63
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion acarsdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ char * parse_params(char **paramsp, struct params_s *sp, const int np)
while ((param = strsep(paramsp, ","))) {
sep = strchr(param, '=');
if (!sep)
continue;
return param;

*sep++ = '\0';

Expand Down
2 changes: 1 addition & 1 deletion fileout.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fileout_t *Fileoutinit(char *params)

retp = parse_params(&params, filep, ARRAY_SIZE(filep));
if (retp) {
fprintf(stderr, ERRPFX "unknown parameter '%s'\n", retp);
fprintf(stderr, ERRPFX "invalid parameter '%s'\n", retp);
return NULL;
}

Expand Down
7 changes: 5 additions & 2 deletions mqttout.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ mqttout_t *MQTTinit(char *params)
do {
retp = parse_params(&params, mqttp, ARRAY_SIZE(mqttp));
if (retp) {
sep = strchr(retp, '='); // guaranteed to exist due to parse_params()
sep = strchr(retp, '=');
if (!sep)
goto unknown;
*sep++ = '\0';
if (!strcmp("uri", retp)) {
if (url > &urls[14])
Expand All @@ -59,7 +61,8 @@ mqttout_t *MQTTinit(char *params)
*url++ = sep;
}
else {
fprintf(stderr, ERRPFX "unknown parameter '%s'\n", retp);
unknown:
fprintf(stderr, ERRPFX "invalid parameter '%s'\n", retp);
return NULL;

}
Expand Down
2 changes: 1 addition & 1 deletion netout.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ netout_t *Netoutinit(char *params)

retp = parse_params(&params, netp, ARRAY_SIZE(netp));
if (retp) {
fprintf(stderr, ERRPFX "unknown parameter '%s'\n", retp);
fprintf(stderr, ERRPFX "invalid parameter '%s'\n", retp);
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion statsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int statsd_init(char *params, const char *idstation)

retp = parse_params(&params, statsdp, ARRAY_SIZE(statsdp));
if (retp) {
fprintf(stderr, ERRPFX "unknown parameter '%s'\n", retp);
fprintf(stderr, ERRPFX "invalid parameter '%s'\n", retp);
return -1;
}

Expand Down

0 comments on commit 57e1e63

Please sign in to comment.