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
72070f29
Commit
72070f29
authored
Jan 30, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConfigFile: add struct ConfigData
parent
823c618d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
+26
-9
ConfigData.hxx
src/ConfigData.hxx
+18
-0
ConfigFile.cxx
src/ConfigFile.cxx
+8
-9
No files found.
src/ConfigData.hxx
View file @
72070f29
...
...
@@ -20,11 +20,19 @@
#ifndef MPD_CONFIG_DATA_HXX
#define MPD_CONFIG_DATA_HXX
#include "ConfigOption.hxx"
#include "gerror.h"
#include "gcc.h"
#ifdef __cplusplus
#include <glib.h>
#include <array>
#endif
#include <stdbool.h>
#ifdef __cplusplus
struct
block_param
{
char
*
name
;
char
*
value
;
...
...
@@ -37,6 +45,8 @@ struct block_param {
bool
used
;
};
#endif
struct
config_param
{
char
*
value
;
unsigned
int
line
;
...
...
@@ -52,6 +62,14 @@ struct config_param {
};
#ifdef __cplusplus
struct
ConfigData
{
std
::
array
<
GSList
*
,
std
::
size_t
(
CONF_MAX
)
>
params
;
};
#endif
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
src/ConfigFile.cxx
View file @
72070f29
...
...
@@ -47,7 +47,7 @@ extern "C" {
#define CONF_COMMENT '#'
static
GSList
*
config_params
[
unsigned
(
CONF_MAX
)]
;
static
ConfigData
config_data
;
static
void
config_param_free_callback
(
gpointer
data
,
G_GNUC_UNUSED
gpointer
user_data
)
...
...
@@ -59,10 +59,9 @@ config_param_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
void
config_global_finish
(
void
)
{
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
config_params
);
++
i
)
{
g_slist_foreach
(
config_params
[
i
],
config_param_free_callback
,
NULL
);
g_slist_free
(
config_params
[
i
]);
for
(
auto
i
:
config_data
.
params
)
{
g_slist_foreach
(
i
,
config_param_free_callback
,
NULL
);
g_slist_free
(
i
);
}
}
...
...
@@ -92,8 +91,8 @@ config_param_check(gpointer data, G_GNUC_UNUSED gpointer user_data)
void
config_global_check
(
void
)
{
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
config_params
);
++
i
)
g_slist_foreach
(
config_params
[
i
]
,
config_param_check
,
NULL
);
for
(
auto
i
:
config_data
.
params
)
g_slist_foreach
(
i
,
config_param_check
,
NULL
);
}
static
bool
...
...
@@ -244,7 +243,7 @@ ReadConfigFile(const Path &path, GError **error_r)
const
unsigned
i
=
ParseConfigOptionName
(
name
);
const
ConfigTemplate
&
option
=
config_templates
[
i
];
GSList
*&
params
=
config_params
[
i
];
GSList
*&
params
=
config_
data
.
params
[
i
];
if
(
params
!=
NULL
&&
!
option
.
repeatable
)
{
param
=
(
struct
config_param
*
)
params
->
data
;
...
...
@@ -323,7 +322,7 @@ ReadConfigFile(const Path &path, GError **error_r)
const
struct
config_param
*
config_get_next_param
(
ConfigOption
option
,
const
struct
config_param
*
last
)
{
GSList
*
node
=
config_params
[
unsigned
(
option
)];
GSList
*
node
=
config_
data
.
params
[
unsigned
(
option
)];
if
(
last
)
{
node
=
g_slist_find
(
node
,
last
);
...
...
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