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
9ebbdb9b
Commit
9ebbdb9b
authored
Jun 12, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archive_list: add _for_each() macros
parent
48da345e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
archive_list.c
src/archive_list.c
+17
-25
archive_list.h
src/archive_list.h
+8
-0
No files found.
src/archive_list.c
View file @
9ebbdb9b
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include <string.h>
#include <string.h>
#include <glib.h>
#include <glib.h>
static
const
struct
archive_plugin
*
const
archive_plugins
[]
=
{
const
struct
archive_plugin
*
const
archive_plugins
[]
=
{
#ifdef HAVE_BZ2
#ifdef HAVE_BZ2
&
bz2_archive_plugin
,
&
bz2_archive_plugin
,
#endif
#endif
...
@@ -44,44 +44,38 @@ static const struct archive_plugin *const archive_plugins[] = {
...
@@ -44,44 +44,38 @@ static const struct archive_plugin *const archive_plugins[] = {
/** which plugins have been initialized successfully? */
/** which plugins have been initialized successfully? */
static
bool
archive_plugins_enabled
[
G_N_ELEMENTS
(
archive_plugins
)
-
1
];
static
bool
archive_plugins_enabled
[
G_N_ELEMENTS
(
archive_plugins
)
-
1
];
#define archive_plugins_for_each_enabled(plugin) \
archive_plugins_for_each(plugin) \
if (archive_plugins_enabled[archive_plugin_iterator - archive_plugins])
const
struct
archive_plugin
*
const
struct
archive_plugin
*
archive_plugin_from_suffix
(
const
char
*
suffix
)
archive_plugin_from_suffix
(
const
char
*
suffix
)
{
{
if
(
suffix
==
NULL
)
if
(
suffix
==
NULL
)
return
NULL
;
return
NULL
;
for
(
unsigned
i
=
0
;
archive_plugins
[
i
]
!=
NULL
;
++
i
)
{
archive_plugins_for_each_enabled
(
plugin
)
const
struct
archive_plugin
*
plugin
=
archive_plugins
[
i
];
if
(
plugin
->
suffixes
!=
NULL
&&
if
(
archive_plugins_enabled
[
i
]
&&
string_array_contains
(
plugin
->
suffixes
,
suffix
))
plugin
->
suffixes
!=
NULL
&&
string_array_contains
(
plugin
->
suffixes
,
suffix
))
{
++
i
;
return
plugin
;
return
plugin
;
}
}
return
NULL
;
return
NULL
;
}
}
const
struct
archive_plugin
*
const
struct
archive_plugin
*
archive_plugin_from_name
(
const
char
*
name
)
archive_plugin_from_name
(
const
char
*
name
)
{
{
for
(
unsigned
i
=
0
;
archive_plugins
[
i
]
!=
NULL
;
++
i
)
{
archive_plugins_for_each_enabled
(
plugin
)
const
struct
archive_plugin
*
plugin
=
archive_plugins
[
i
];
if
(
strcmp
(
plugin
->
name
,
name
)
==
0
)
if
(
archive_plugins_enabled
[
i
]
&&
strcmp
(
plugin
->
name
,
name
)
==
0
)
return
plugin
;
return
plugin
;
}
return
NULL
;
return
NULL
;
}
}
void
archive_plugin_print_all_suffixes
(
FILE
*
fp
)
void
archive_plugin_print_all_suffixes
(
FILE
*
fp
)
{
{
const
char
*
const
*
suffixes
;
archive_plugins_for_each
(
plugin
)
{
const
char
*
const
*
suffixes
=
plugin
->
suffixes
;
for
(
unsigned
i
=
0
;
archive_plugins
[
i
]
!=
NULL
;
++
i
)
{
const
struct
archive_plugin
*
plugin
=
archive_plugins
[
i
];
suffixes
=
plugin
->
suffixes
;
while
(
suffixes
&&
*
suffixes
)
{
while
(
suffixes
&&
*
suffixes
)
{
fprintf
(
fp
,
"%s "
,
*
suffixes
);
fprintf
(
fp
,
"%s "
,
*
suffixes
);
suffixes
++
;
suffixes
++
;
...
@@ -102,10 +96,8 @@ void archive_plugin_init_all(void)
...
@@ -102,10 +96,8 @@ void archive_plugin_init_all(void)
void
archive_plugin_deinit_all
(
void
)
void
archive_plugin_deinit_all
(
void
)
{
{
for
(
unsigned
i
=
0
;
archive_plugins
[
i
]
!=
NULL
;
++
i
)
{
archive_plugins_for_each_enabled
(
plugin
)
const
struct
archive_plugin
*
plugin
=
archive_plugins
[
i
];
if
(
plugin
->
finish
!=
NULL
)
if
(
archive_plugins_enabled
[
i
]
&&
plugin
->
finish
!=
NULL
)
plugin
->
finish
();
archive_plugins
[
i
]
->
finish
();
}
}
}
src/archive_list.h
View file @
9ebbdb9b
...
@@ -24,6 +24,14 @@
...
@@ -24,6 +24,14 @@
struct
archive_plugin
;
struct
archive_plugin
;
extern
const
struct
archive_plugin
*
const
archive_plugins
[];
#define archive_plugins_for_each(plugin) \
for (const struct archive_plugin *plugin, \
*const*archive_plugin_iterator = &archive_plugins[0]; \
(plugin = *archive_plugin_iterator) != NULL; \
++archive_plugin_iterator)
/* interface for using plugins */
/* interface for using plugins */
const
struct
archive_plugin
*
const
struct
archive_plugin
*
...
...
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