output/shout: refactor check_block_param() to a function
Don't use macro magic, don't dereference the block_param.
This commit is contained in:
@@ -97,12 +97,16 @@ 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)
|
||||||
|
{
|
||||||
|
const char *value = config_get_block_string(param, name, NULL);
|
||||||
|
if (value == NULL)
|
||||||
MPD_ERROR("no \"%s\" defined for shout device defined at line " \
|
MPD_ERROR("no \"%s\" defined for shout device defined at line " \
|
||||||
"%i\n", name, param->line); \
|
"%i\n", name, param->line); \
|
||||||
} \
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@@ -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,
|
|||||||
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);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user