1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-12-04 14:46:31 -05:00

Merge branch 'feature/config_refactor' into feature/unit_tests

This commit is contained in:
Moritz Grimm 2015-05-11 23:48:50 +02:00
commit 8355fde68a
2 changed files with 21 additions and 34 deletions

View File

@ -326,23 +326,7 @@ cfg_set_server_client_key(const char *client_key, const char **errstrp)
int
cfg_set_server_reconnect_attempts(const char *num_str, const char **errstrp)
{
const char *errstr;
unsigned int num;
if (!num_str || !num_str[0]) {
if (errstrp)
*errstrp = "empty";
return (-1);
}
num = strtonum(num_str, 0, UINT_MAX, &errstr);
if (errstr) {
if (errstrp)
*errstrp = errstr;
return (-1);
}
cfg.server.reconnect_attempts = num;
SET_UINTNUM(cfg.server.reconnect_attempts, num_str, errstrp);
return (0);
}
@ -525,23 +509,7 @@ cfg_set_metadata_format_str(const char *format_str, const char **errstrp)
int
cfg_set_metadata_refresh_interval(const char *num_str, const char **errstrp)
{
const char *errstr;
unsigned int num;
if (!num_str || !num_str[0]) {
if (errstrp)
*errstrp = "empty";
return (-1);
}
num = strtonum(num_str, 0, UINT_MAX, &errstr);
if (errstr) {
if (errstrp)
*errstrp = errstr;
return (-1);
}
cfg.metadata.refresh_interval = num;
SET_UINTNUM(cfg.metadata.refresh_interval, num_str, errstrp);
return (0);
}

View File

@ -126,6 +126,25 @@ struct cfg {
(t) = val; \
} while (0)
#define SET_UINTNUM(t, s, e) do { \
const char *errstr; \
unsigned int num; \
\
if (!(s) || !(s)[0]) { \
if ((e)) \
*(e) = "empty"; \
return (-1); \
} \
\
num = strtonum((s), 0, UINT_MAX, &errstr); \
if (errstr) { \
if ((e)) \
*(e) = errstr; \
return (-1); \
} \
(t) = num; \
} while (0)
#define CHECKPH_PROHIBITED(s, p) do { \
if (NULL != strstr((s), (p))) { \
if (errstrp) \