rtl433
UNKNOWN
RTL-433 utility
|
Option parsing functions to complement getopt. More...
Go to the source code of this file.
Functions | |
int | atobv (char *arg, int def) |
Convert string to bool with fallback default. More... | |
int | atoiv (char *arg, int def) |
Convert string to int with fallback default. More... | |
char * | arg_param (char *arg) |
Get the next colon or comma separated arg, NULL otherwise. More... | |
char * | hostport_param (char *param, char **host, char **port) |
Parse param string to host and port. More... | |
uint32_t | atouint32_metric (const char *str, const char *error_hint) |
Convert a string to an unsigned integer, uses strtod() and accepts metric suffixes of 'k', 'M', and 'G' (also 'K', 'm', and 'g'). More... | |
int | atoi_time (const char *str, const char *error_hint) |
Convert a string to an integer, uses strtod() and accepts time suffixes of 'd', 'h', 'm', and 's' (also 'D', 'H', 'M', and 'S'), or the form hours:minutes[:seconds]. More... | |
char * | asepc (char **stringp, char delim) |
Similar to strsep. More... | |
char * | getkwargs (char **s, char **key, char **val) |
Parse a comma-separated list of key/value pairs into kwargs. More... | |
char * | trim_ws (char *str) |
Trim left and right whitespace in string. More... | |
char * | remove_ws (char *str) |
Remove all whitespace from string. More... | |
Option parsing functions to complement getopt.
Copyright (C) 2017 Christian Zuckschwerdt
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
char* arg_param | ( | char * | arg | ) |
Get the next colon or comma separated arg, NULL otherwise.
Returns string including comma if a comma is found first, otherwise string after colon if found, NULL otherwise.
Referenced by parse_conf_option(), and rtltcp_open().
char* asepc | ( | char ** | stringp, |
char | delim | ||
) |
Similar to strsep.
[in,out] | stringp | |
delim | the delimiter character |
Referenced by getkwargs().
int atobv | ( | char * | arg, |
int | def | ||
) |
Convert string to bool with fallback default.
Parses "true", "yes", "on", "enable" (not case-sensitive) to 1, atoi() otherwise.
Referenced by data_output_mqtt_create(), and parse_conf_option().
int atoi_time | ( | const char * | str, |
const char * | error_hint | ||
) |
Convert a string to an integer, uses strtod() and accepts time suffixes of 'd', 'h', 'm', and 's' (also 'D', 'H', 'M', and 'S'), or the form hours:minutes[:seconds].
Parse errors will fprintf(stderr, ...) and exit(1).
str | character string to parse |
error_hint | prepended to error output |
Referenced by main(), and parse_conf_option().
int atoiv | ( | char * | arg, |
int | def | ||
) |
Convert string to int with fallback default.
Referenced by parse_conf_option().
uint32_t atouint32_metric | ( | const char * | str, |
const char * | error_hint | ||
) |
Convert a string to an unsigned integer, uses strtod() and accepts metric suffixes of 'k', 'M', and 'G' (also 'K', 'm', and 'g').
Parse errors will fprintf(stderr, ...) and exit(1).
str | character string to parse |
error_hint | prepended to error output |
Referenced by main(), parse_conf_option(), and sdr_apply_settings().
char* getkwargs | ( | char ** | s, |
char ** | key, | ||
char ** | val | ||
) |
Parse a comma-separated list of key/value pairs into kwargs.
The input string will be modified and the pointer advanced. The key and val pointers will be into the original string.
[in,out] | s | String of key=value pairs, separated by commas |
[out] | key | keyword argument if found, NULL otherwise |
[out] | val | value if found, NULL otherwise |
References asepc().
Referenced by data_output_mqtt_create(), flex_create_device(), and soapysdr_gain_str_set().
char* hostport_param | ( | char * | param, |
char ** | host, | ||
char ** | port | ||
) |
Parse param string to host and port.
E.g. ":514", "localhost", "[::1]", "127.0.0.1:514", "[::1]:514", also "//localhost", "//localhost:514", "//:514". Host or port are terminated at a comma, if found.
Referenced by add_mqtt_output(), add_syslog_output(), and rtltcp_open().
char* remove_ws | ( | char * | str | ) |
Remove all whitespace from string.
[in,out] | str |
Referenced by data_output_mqtt_create(), and flex_create_device().
char* trim_ws | ( | char * | str | ) |
Trim left and right whitespace in string.
[in,out] | str |
Referenced by data_output_mqtt_create(), and flex_create_device().