Commit ed8798e8 authored by Max Kellermann's avatar Max Kellermann

output/shout: refactor check_block_param() to a function

Don't use macro magic, don't dereference the block_param.
parent 38474961
...@@ -97,13 +97,17 @@ static void free_shout_data(struct shout_data *sd) ...@@ -97,13 +97,17 @@ static void free_shout_data(struct shout_data *sd)
g_free(sd); g_free(sd);
} }
#define check_block_param(name) { \ gcc_pure
block_param = config_get_block_param(param, name); \ static const char *
if (!block_param) { \ require_block_string(const struct config_param *param, const char *name)
MPD_ERROR("no \"%s\" defined for shout device defined at line " \ {
"%i\n", name, param->line); \ const char *value = config_get_block_string(param, name, NULL);
} \ if (value == NULL)
} MPD_ERROR("no \"%s\" defined for shout device defined at line " \
"%i\n", name, param->line); \
return value;
}
static bool static bool
my_shout_configure(struct shout_data *sd, const struct config_param *param, my_shout_configure(struct shout_data *sd, const struct config_param *param,
...@@ -120,12 +124,8 @@ my_shout_configure(struct shout_data *sd, const struct config_param *param, ...@@ -120,12 +124,8 @@ my_shout_configure(struct shout_data *sd, const struct config_param *param,
return NULL; return NULL;
} }
const struct block_param *block_param; const char *host = require_block_string(param, "host");
check_block_param("host"); const char *mount = require_block_string(param, "mount");
char *host = block_param->value;
check_block_param("mount");
char *mount = block_param->value;
unsigned port = config_get_block_unsigned(param, "port", 0); unsigned port = config_get_block_unsigned(param, "port", 0);
if (port == 0) { if (port == 0) {
...@@ -134,11 +134,8 @@ my_shout_configure(struct shout_data *sd, const struct config_param *param, ...@@ -134,11 +134,8 @@ my_shout_configure(struct shout_data *sd, const struct config_param *param,
return false; return false;
} }
check_block_param("password"); const char *passwd = require_block_string(param, "password");
const char *passwd = block_param->value; const char *name = require_block_string(param, "name");
check_block_param("name");
const char *name = block_param->value;
bool public = config_get_block_bool(param, "public", false); bool public = config_get_block_bool(param, "public", false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment