Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
d06ef76e
Commit
d06ef76e
authored
Jul 17, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/File: implement the "include" directive
This is an experimental draft. More needs to be done.
parent
57729683
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
2 deletions
+26
-2
NEWS
NEWS
+2
-0
user.xml
doc/user.xml
+8
-0
File.cxx
src/config/File.cxx
+16
-2
No files found.
NEWS
View file @
d06ef76e
ver 0.21 (not yet released)
* configuration
- add "include" directive, allows including config files
* protocol
- "tagtypes" can be used to hide tags
- "find" and "search" can sort
...
...
doc/user.xml
View file @
d06ef76e
...
...
@@ -410,6 +410,14 @@ systemctl start mpd.socket</programlisting>
device "iec958:CARD=Intel,DEV=0"
mixer_control "PCM"
}
</programlisting>
<para>
The
<varname>
include
</varname>
directive can be used to
include settings from another file; the given file name is
relative to the current file:
</para>
<programlisting>
include "other.conf"
</programlisting>
</section>
<section
id=
"config_music_directory"
>
...
...
src/config/File.cxx
View file @
d06ef76e
...
...
@@ -25,6 +25,7 @@
#include "Templates.hxx"
#include "util/Tokenizer.hxx"
#include "util/StringStrip.hxx"
#include "util/StringAPI.hxx"
#include "util/Domain.hxx"
#include "util/RuntimeError.hxx"
#include "fs/Path.hxx"
...
...
@@ -152,8 +153,11 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
reader
.
GetLineNumber
()));
}
/**
* @param directory the directory used to resolve relative paths
*/
static
void
ReadConfigFile
(
ConfigData
&
config_data
,
BufferedReader
&
reader
)
ReadConfigFile
(
ConfigData
&
config_data
,
BufferedReader
&
reader
,
Path
directory
)
{
while
(
true
)
{
char
*
line
=
reader
.
ReadLine
();
...
...
@@ -171,6 +175,16 @@ ReadConfigFile(ConfigData &config_data, BufferedReader &reader)
const
char
*
name
=
tokenizer
.
NextWord
();
assert
(
name
!=
nullptr
);
if
(
StringIsEqual
(
name
,
"include"
))
{
// TODO: allow absolute path specifications
// TODO: detect recusion
// TODO: Config{Block,Param} have only line number but no file name
// TODO: support wildcards (include "conf.d/*.conf")
// TODO: add "include_optional"
ReadConfigFile
(
config_data
,
directory
/
AllocatedPath
::
FromUTF8Throw
(
ExpectValueAndEnd
(
tokenizer
)));
continue
;
}
/* get the definition of that option, and check the
"repeatable" flag */
...
...
@@ -202,7 +216,7 @@ ReadConfigFile(ConfigData &config_data, Path path)
BufferedReader
reader
(
file
);
try
{
ReadConfigFile
(
config_data
,
reader
);
ReadConfigFile
(
config_data
,
reader
,
path
.
GetDirectoryName
()
);
}
catch
(...)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Error in %s line %u"
,
path_utf8
.
c_str
(),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment