2013-09-05 18:23:15 +02:00
|
|
|
/*
|
2015-01-01 19:48:13 +01:00
|
|
|
* Copyright (C) 2003-2015 The Music Player Daemon Project
|
2013-09-05 18:23:15 +02:00
|
|
|
* http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "TagConfig.hxx"
|
2013-09-05 18:34:12 +02:00
|
|
|
#include "TagSettings.h"
|
2013-09-05 18:23:15 +02:00
|
|
|
#include "Tag.hxx"
|
2014-01-24 00:20:01 +01:00
|
|
|
#include "config/ConfigGlobal.hxx"
|
|
|
|
#include "config/ConfigOption.hxx"
|
2013-09-05 18:23:15 +02:00
|
|
|
#include "system/FatalError.hxx"
|
2014-01-07 23:33:46 +01:00
|
|
|
#include "util/Alloc.hxx"
|
2013-10-20 23:09:51 +02:00
|
|
|
#include "util/ASCII.hxx"
|
2014-02-17 22:37:43 +01:00
|
|
|
#include "util/StringUtil.hxx"
|
2013-09-05 18:23:15 +02:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
2014-01-07 23:33:46 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2013-09-05 18:23:15 +02:00
|
|
|
void
|
|
|
|
TagLoadConfig()
|
|
|
|
{
|
2015-06-26 08:05:20 +02:00
|
|
|
const char *value = config_get_string(ConfigOption::METADATA_TO_USE);
|
2013-09-05 18:23:15 +02:00
|
|
|
if (value == nullptr)
|
|
|
|
return;
|
|
|
|
|
2015-08-24 11:10:15 +02:00
|
|
|
global_tag_mask = 0;
|
2013-09-05 18:23:15 +02:00
|
|
|
|
2013-10-20 23:09:51 +02:00
|
|
|
if (StringEqualsCaseASCII(value, "none"))
|
2013-09-05 18:23:15 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
bool quit = false;
|
|
|
|
char *temp, *c, *s;
|
2014-01-07 23:33:46 +01:00
|
|
|
temp = c = s = xstrdup(value);
|
2013-09-05 18:23:15 +02:00
|
|
|
do {
|
|
|
|
if (*s == ',' || *s == '\0') {
|
|
|
|
if (*s == '\0')
|
|
|
|
quit = true;
|
|
|
|
*s = '\0';
|
|
|
|
|
2014-02-17 22:37:43 +01:00
|
|
|
c = Strip(c);
|
2013-09-05 18:23:15 +02:00
|
|
|
if (*c == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const auto type = tag_name_parse_i(c);
|
|
|
|
if (type == TAG_NUM_OF_ITEM_TYPES)
|
|
|
|
FormatFatalError("error parsing metadata item \"%s\"",
|
|
|
|
c);
|
|
|
|
|
2015-08-24 11:10:15 +02:00
|
|
|
global_tag_mask |= tag_mask_t(1) << unsigned(type);
|
2013-09-05 18:23:15 +02:00
|
|
|
|
|
|
|
s++;
|
|
|
|
c = s;
|
|
|
|
}
|
|
|
|
s++;
|
|
|
|
} while (!quit);
|
|
|
|
|
2014-01-07 23:33:46 +01:00
|
|
|
free(temp);
|
2013-09-05 18:23:15 +02:00
|
|
|
}
|