minor: fix take const in tls_param, atobv, atoiv

This commit is contained in:
Christian W. Zuckschwerdt 2021-02-01 10:18:38 +01:00
parent cf70f1592e
commit 71e21c43c1
2 changed files with 21 additions and 21 deletions

View file

@ -26,51 +26,51 @@
/// TLS settings.
typedef struct tls_opts {
/// Client certificate to present to the server.
const char *tls_cert;
char const *tls_cert;
/// Private key corresponding to the certificate.
/// If tls_cert is set but tls_key is not, tls_cert is used.
const char *tls_key;
char const *tls_key;
/// Verify server certificate using this CA bundle. If set to "*", then TLS
/// is enabled but no cert verification is performed.
const char *tls_ca_cert;
char const *tls_ca_cert;
/// Colon-delimited list of acceptable cipher suites.
/// Names depend on the library used, for example:
/// ECDH-ECDSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256 (OpenSSL)
/// For OpenSSL the list can be obtained by running "openssl ciphers".
/// If NULL, a reasonable default is used.
const char *tls_cipher_suites;
char const *tls_cipher_suites;
/// Server name verification. If tls_ca_cert is set and the certificate has
/// passed verification, its subject will be verified against this string.
/// By default (if tls_server_name is NULL) hostname part of the address will
/// be used. Wildcard matching is supported. A special value of "*" disables
/// name verification.
const char *tls_server_name;
char const *tls_server_name;
/// PSK identity is a NUL-terminated string.
/// Note: Default list of cipher suites does not include PSK suites, if you
/// want to use PSK you will need to set tls_cipher_suites as well.
const char *tls_psk_identity;
char const *tls_psk_identity;
/// PSK key hex string, must be either 16 or 32 bytes (32 or 64 hex digits)
/// for AES-128 or AES-256 respectively.
const char *tls_psk_key;
char const *tls_psk_key;
} tls_opts_t;
/// Parse a TLS option.
///
/// @sa tls_opts_t
/// @return 0 if the option was valid, error code otherwise
int tls_param(tls_opts_t *tls_opts, char *key, char *val);
int tls_param(tls_opts_t *tls_opts, char const *key, char const *val);
/// Convert string to bool with fallback default.
/// Parses "true", "yes", "on", "enable" (not case-sensitive) to 1, atoi() otherwise.
int atobv(char *arg, int def);
int atobv(char const *arg, int def);
/// Convert string to int with fallback default.
int atoiv(char *arg, int def);
int atoiv(char const *arg, int def);
/// 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.
char *arg_param(char *arg);
char *arg_param(char const *arg);
/// Convert a string with optional leading equals char to a double.
///
@ -79,7 +79,7 @@ char *arg_param(char *arg);
/// @param str character string to parse
/// @param error_hint prepended to error output
/// @return parsed number value
double arg_float(const char *str, const char *error_hint);
double arg_float(char const *str, char const *error_hint);
/// Parse param string to host and port.
/// E.g. ":514", "localhost", "[::1]", "127.0.0.1:514", "[::1]:514",
@ -96,7 +96,7 @@ char *hostport_param(char *param, char **host, char **port);
/// @param str character string to parse
/// @param error_hint prepended to error output
/// @return parsed number value
uint32_t atouint32_metric(const char *str, const char *error_hint);
uint32_t atouint32_metric(char const *str, char const *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'),
@ -107,7 +107,7 @@ uint32_t atouint32_metric(const char *str, const char *error_hint);
/// @param str character string to parse
/// @param error_hint prepended to error output
/// @return parsed number value
int atoi_time(const char *str, const char *error_hint);
int atoi_time(char const *str, char const *error_hint);
/// Similar to strsep.
///

View file

@ -15,7 +15,7 @@
#include <limits.h>
#include <string.h>
int tls_param(tls_opts_t *tls_opts, char *key, char *val)
int tls_param(tls_opts_t *tls_opts, char const *key, char const *val)
{
if (!tls_opts || !key || !*key)
return 1;
@ -38,7 +38,7 @@ int tls_param(tls_opts_t *tls_opts, char *key, char *val)
return 0;
}
int atobv(char *arg, int def)
int atobv(char const *arg, int def)
{
if (!arg)
return def;
@ -47,7 +47,7 @@ int atobv(char *arg, int def)
return atoi(arg);
}
int atoiv(char *arg, int def)
int atoiv(char const *arg, int def)
{
if (!arg)
return def;
@ -58,7 +58,7 @@ int atoiv(char *arg, int def)
return val;
}
char *arg_param(char *arg)
char *arg_param(char const *arg)
{
if (!arg)
return NULL;
@ -72,7 +72,7 @@ char *arg_param(char *arg)
return p;
}
double arg_float(const char *str, const char *error_hint)
double arg_float(char const *str, char const *error_hint)
{
if (!str) {
fprintf(stderr, "%smissing number argument\n", error_hint);
@ -133,7 +133,7 @@ char *hostport_param(char *param, char **host, char **port)
return NULL;
}
uint32_t atouint32_metric(const char *str, const char *error_hint)
uint32_t atouint32_metric(char const *str, char const *error_hint)
{
if (!str) {
fprintf(stderr, "%smissing number argument\n", error_hint);
@ -195,7 +195,7 @@ uint32_t atouint32_metric(const char *str, const char *error_hint)
return (uint32_t)val;
}
int atoi_time(const char *str, const char *error_hint)
int atoi_time(char const *str, char const *error_hint)
{
if (!str) {
fprintf(stderr, "%smissing time argument\n", error_hint);