Example #1
0
void initPermissions(void)
{
	char *password;
	unsigned permission;
	const struct config_param *param;

	permission_passwords = g_hash_table_new_full(g_str_hash, g_str_equal,
						     g_free, NULL);

	permission_default = PERMISSION_READ | PERMISSION_ADD |
	    PERMISSION_CONTROL | PERMISSION_ADMIN;

	param = config_get_next_param(CONF_PASSWORD, NULL);

	if (param) {
		permission_default = 0;

		do {
			const char *separator =
				strchr(param->value, PERMISSION_PASSWORD_CHAR);

			if (separator == NULL)
				MPD_ERROR("\"%c\" not found in password string "
					"\"%s\", line %i",
					PERMISSION_PASSWORD_CHAR,
					param->value, param->line);

			password = g_strndup(param->value,
					     separator - param->value);

			permission = parsePermissions(separator + 1);

			g_hash_table_replace(permission_passwords,
					     password,
					     GINT_TO_POINTER(permission));
		} while ((param = config_get_next_param(CONF_PASSWORD, param)));
	}

	param = config_get_param(CONF_DEFAULT_PERMS);

	if (param)
		permission_default = parsePermissions(param->value);
}
static const struct config_param *
find_named_config_block(const char *block, const char *name)
{
	const struct config_param *param = NULL;

	while ((param = config_get_next_param(block, param)) != NULL) {
		const char *current_name =
			config_get_block_string(param, "name", NULL);
		if (current_name != NULL && strcmp(current_name, name) == 0)
			return param;
	}

	return NULL;
}
Example #3
0
/**
 * Find the "decoder" configuration block for the specified plugin.
 *
 * @param plugin_name the name of the decoder plugin
 * @return the configuration block, or NULL if none was configured
 */
static const struct config_param *
decoder_plugin_config(const char *plugin_name)
{
	const struct config_param *param = NULL;

	while ((param = config_get_next_param(CONF_DECODER, param)) != NULL) {
		const char *name =
			config_get_block_string(param, "plugin", NULL);
		if (name == NULL)
			g_error("decoder configuration without 'plugin' name in line %d",
				param->line);

		if (strcmp(name, plugin_name) == 0)
			return param;
	}

	return NULL;
}
/**
 * Find the "playlist" configuration block for the specified plugin.
 *
 * @param plugin_name the name of the playlist plugin
 * @return the configuration block, or NULL if none was configured
 */
static const struct config_param *
playlist_plugin_config(const char *plugin_name)
{
	const struct config_param *param = NULL;

	assert(plugin_name != NULL);

	while ((param = config_get_next_param(CONF_PLAYLIST_PLUGIN, param)) != NULL) {
		const char *name =
			config_get_block_string(param, "name", NULL);
		if (name == NULL)
			g_error("playlist configuration without 'plugin' name in line %d",
				param->line);

		if (strcmp(name, plugin_name) == 0)
			return param;
	}

	return NULL;
}
Example #5
0
/**
 * Find the "input" configuration block for the specified plugin.
 *
 * @param plugin_name the name of the input plugin
 * @return the configuration block, or NULL if none was configured
 */
static const struct config_param *
input_plugin_config(const char *plugin_name, GError **error_r)
{
	const struct config_param *param = NULL;

	while ((param = config_get_next_param(CONF_INPUT, param)) != NULL) {
		const char *name =
			config_get_block_string(param, "plugin", NULL);
		if (name == NULL) {
			g_set_error(error_r, input_quark(), 0,
				    "input configuration without 'plugin' name in line %d",
				    param->line);
			return NULL;
		}

		if (strcmp(name, plugin_name) == 0)
			return param;
	}

	return NULL;
}