aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am29
-rw-r--r--src/ArchiveInternal.hxx (renamed from src/archive_internal.h)6
-rw-r--r--src/ArchiveList.cxx (renamed from src/archive_list.c)12
-rw-r--r--src/ArchiveList.hxx (renamed from src/archive_list.h)6
-rw-r--r--src/ArchiveLookup.cxx (renamed from src/archive_api.c)4
-rw-r--r--src/ArchiveLookup.hxx (renamed from src/archive_api.h)12
-rw-r--r--src/ArchivePlugin.cxx (renamed from src/archive_plugin.c)6
-rw-r--r--src/ArchivePlugin.hxx (renamed from src/archive_plugin.h)8
-rw-r--r--src/CommandLine.cxx4
-rw-r--r--src/InputRegistry.cxx2
-rw-r--r--src/Main.cxx4
-rw-r--r--src/UpdateArchive.cxx7
-rw-r--r--src/archive/Bzip2ArchivePlugin.cxx (renamed from src/archive/bz2_archive_plugin.c)77
-rw-r--r--src/archive/Bzip2ArchivePlugin.hxx (renamed from src/archive/bz2_archive_plugin.h)6
-rw-r--r--src/archive/Iso9660ArchivePlugin.cxx (renamed from src/archive/iso9660_archive_plugin.c)46
-rw-r--r--src/archive/Iso9660ArchivePlugin.hxx (renamed from src/archive/iso9660_archive_plugin.h)6
-rw-r--r--src/archive/ZzipArchivePlugin.cxx (renamed from src/archive/zzip_archive_plugin.c)86
-rw-r--r--src/archive/ZzipArchivePlugin.hxx (renamed from src/archive/zzip_archive_plugin.h)6
-rw-r--r--src/input/ArchiveInputPlugin.cxx (renamed from src/input/archive_input_plugin.c)23
-rw-r--r--src/input/ArchiveInputPlugin.hxx (renamed from src/input/archive_input_plugin.h)6
-rw-r--r--test/dump_text_file.cxx4
-rw-r--r--test/run_input.cxx4
22 files changed, 202 insertions, 162 deletions
diff --git a/Makefile.am b/Makefile.am
index 852c2870..b900b24d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -130,14 +130,6 @@ mpd_headers = \
src/string_util.h \
src/zeroconf.h src/zeroconf-internal.h \
src/timer.h \
- src/archive_api.h \
- src/archive_internal.h \
- src/archive_list.h \
- src/archive_plugin.h \
- src/archive/bz2_archive_plugin.h \
- src/archive/iso9660_archive_plugin.h \
- src/archive/zzip_archive_plugin.h \
- src/input/archive_input_plugin.h \
src/mpd_error.h
src_mpd_SOURCES = \
@@ -414,10 +406,11 @@ src_mpd_SOURCES += \
src/UpdateArchive.cxx src/UpdateArchive.hxx
libarchive_a_SOURCES = \
- src/archive_api.c \
- src/archive_list.c \
- src/archive_plugin.c \
- src/input/archive_input_plugin.c
+ src/ArchiveLookup.cxx src/ArchiveLookup.hxx \
+ src/ArchiveList.cxx src/ArchiveList.hxx \
+ src/ArchivePlugin.cxx src/ArchivePlugin.hxx \
+ src/ArchiveInternal.hxx \
+ src/input/ArchiveInputPlugin.cxx src/input/ArchiveInputPlugin.hxx
libarchive_a_CPPFLAGS = $(AM_CPPFLAGS) \
$(BZ2_CFLAGS) \
$(ISO9660_CFLAGS) \
@@ -430,15 +423,21 @@ ARCHIVE_LIBS = \
$(ZZIP_LIBS)
if HAVE_BZ2
-libarchive_a_SOURCES += src/archive/bz2_archive_plugin.c
+libarchive_a_SOURCES += \
+ src/archive/Bzip2ArchivePlugin.cxx \
+ src/archive/Bzip2ArchivePlugin.hxx
endif
if HAVE_ZZIP
-libarchive_a_SOURCES += src/archive/zzip_archive_plugin.c
+libarchive_a_SOURCES += \
+ src/archive/ZzipArchivePlugin.cxx \
+ src/archive/ZzipArchivePlugin.hxx
endif
if HAVE_ISO9660
-libarchive_a_SOURCES += src/archive/iso9660_archive_plugin.c
+libarchive_a_SOURCES += \
+ src/archive/Iso9660ArchivePlugin.cxx \
+ src/archive/Iso9660ArchivePlugin.hxx
endif
else
diff --git a/src/archive_internal.h b/src/ArchiveInternal.hxx
index 0d885e91..f0bf2e10 100644
--- a/src/archive_internal.h
+++ b/src/ArchiveInternal.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_ARCHIVE_INTERNAL_H
-#define MPD_ARCHIVE_INTERNAL_H
+#ifndef MPD_ARCHIVE_INTERNAL_HXX
+#define MPD_ARCHIVE_INTERNAL_HXX
struct archive_file {
const struct archive_plugin *plugin;
diff --git a/src/archive_list.c b/src/ArchiveList.cxx
index e23567bd..02b19ce7 100644
--- a/src/archive_list.c
+++ b/src/ArchiveList.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,12 +18,12 @@
*/
#include "config.h"
-#include "archive_list.h"
-#include "archive_plugin.h"
+#include "ArchiveList.hxx"
+#include "ArchivePlugin.hxx"
#include "string_util.h"
-#include "archive/bz2_archive_plugin.h"
-#include "archive/iso9660_archive_plugin.h"
-#include "archive/zzip_archive_plugin.h"
+#include "archive/Bzip2ArchivePlugin.hxx"
+#include "archive/Iso9660ArchivePlugin.hxx"
+#include "archive/ZzipArchivePlugin.hxx"
#include <string.h>
#include <glib.h>
diff --git a/src/archive_list.h b/src/ArchiveList.hxx
index f944583e..057c351d 100644
--- a/src/archive_list.h
+++ b/src/ArchiveList.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_ARCHIVE_LIST_H
-#define MPD_ARCHIVE_LIST_H
+#ifndef MPD_ARCHIVE_LIST_HXX
+#define MPD_ARCHIVE_LIST_HXX
struct archive_plugin;
diff --git a/src/archive_api.c b/src/ArchiveLookup.cxx
index be3c35f7..747f5c7e 100644
--- a/src/archive_api.c
+++ b/src/ArchiveLookup.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,7 +18,7 @@
*/
#include "config.h" /* must be first for large file support */
-#include "archive_api.h"
+#include "ArchiveLookup.hxx"
#include <stdio.h>
diff --git a/src/archive_api.h b/src/ArchiveLookup.hxx
index 4e0f603f..6e7669cb 100644
--- a/src/archive_api.h
+++ b/src/ArchiveLookup.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_ARCHIVE_API_H
-#define MPD_ARCHIVE_API_H
+#ifndef MPD_ARCHIVE_LOOKUP_HXX
+#define MPD_ARCHIVE_LOOKUP_HXX
/*
* This is the public API which is used by archive plugins to
@@ -26,12 +26,6 @@
*
*/
-#include "archive_internal.h"
-#include "archive_plugin.h"
-#include "input_stream.h"
-
-#include <stdbool.h>
-
bool archive_lookup(char *pathname, char **archive, char **inpath, char **suffix);
#endif
diff --git a/src/archive_plugin.c b/src/ArchivePlugin.cxx
index cf23e639..b5cb0f07 100644
--- a/src/archive_plugin.c
+++ b/src/ArchivePlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "archive_plugin.h"
-#include "archive_internal.h"
+#include "ArchivePlugin.hxx"
+#include "ArchiveInternal.hxx"
#include <assert.h>
diff --git a/src/archive_plugin.h b/src/ArchivePlugin.hxx
index b7b92446..fe701460 100644
--- a/src/archive_plugin.h
+++ b/src/ArchivePlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,13 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_ARCHIVE_PLUGIN_H
-#define MPD_ARCHIVE_PLUGIN_H
+#ifndef MPD_ARCHIVE_PLUGIN_HXX
+#define MPD_ARCHIVE_PLUGIN_HXX
#include <glib.h>
-#include <stdbool.h>
-
struct input_stream;
struct archive_file;
diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx
index e9766dfa..732e3eb6 100644
--- a/src/CommandLine.cxx
+++ b/src/CommandLine.cxx
@@ -39,8 +39,8 @@
#endif
#ifdef ENABLE_ARCHIVE
-#include "archive_list.h"
-#include "archive_plugin.h"
+#include "ArchiveList.hxx"
+#include "ArchivePlugin.hxx"
#endif
#include <glib.h>
diff --git a/src/InputRegistry.cxx b/src/InputRegistry.cxx
index fa468724..342720d2 100644
--- a/src/InputRegistry.cxx
+++ b/src/InputRegistry.cxx
@@ -22,7 +22,7 @@
#include "input/FileInputPlugin.hxx"
#ifdef ENABLE_ARCHIVE
-#include "input/archive_input_plugin.h"
+#include "input/ArchiveInputPlugin.hxx"
#endif
#ifdef ENABLE_CURL
diff --git a/src/Main.cxx b/src/Main.cxx
index 44adf2e2..1bacc0e3 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -69,11 +69,9 @@ extern "C" {
#include "StickerDatabase.hxx"
#endif
-extern "C" {
#ifdef ENABLE_ARCHIVE
-#include "archive_list.h"
+#include "ArchiveList.hxx"
#endif
-}
#include <glib.h>
diff --git a/src/UpdateArchive.cxx b/src/UpdateArchive.cxx
index 0765b1ba..3088e942 100644
--- a/src/UpdateArchive.cxx
+++ b/src/UpdateArchive.cxx
@@ -25,11 +25,8 @@
#include "song.h"
#include "Mapper.hxx"
#include "fs/Path.hxx"
-
-extern "C" {
-#include "archive_list.h"
-#include "archive_plugin.h"
-}
+#include "ArchiveList.hxx"
+#include "ArchivePlugin.hxx"
#include <glib.h>
diff --git a/src/archive/bz2_archive_plugin.c b/src/archive/Bzip2ArchivePlugin.cxx
index e2420048..31adb98a 100644
--- a/src/archive/bz2_archive_plugin.c
+++ b/src/archive/Bzip2ArchivePlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -22,8 +22,9 @@
*/
#include "config.h"
-#include "archive/bz2_archive_plugin.h"
-#include "archive_api.h"
+#include "Bzip2ArchivePlugin.hxx"
+#include "ArchiveInternal.hxx"
+#include "ArchivePlugin.hxx"
#include "input_internal.h"
#include "input_plugin.h"
#include "refcount.h"
@@ -47,6 +48,21 @@ struct bz2_archive_file {
char *name;
bool reset;
struct input_stream *istream;
+
+ bz2_archive_file() {
+ archive_file_init(&base, &bz2_archive_plugin);
+ refcount_init(&ref);
+ }
+
+ void Unref() {
+ if (!refcount_dec(&ref))
+ return;
+
+ g_free(name);
+
+ input_stream_close(istream);
+ delete this;
+ }
};
struct bz2_input_stream {
@@ -61,7 +77,7 @@ struct bz2_input_stream {
char buffer[5000];
};
-static const struct input_plugin bz2_inputplugin;
+extern const struct input_plugin bz2_inputplugin;
static inline GQuark
bz2_quark(void)
@@ -80,7 +96,7 @@ bz2_alloc(struct bz2_input_stream *data, GError **error_r)
data->bzstream.bzfree = NULL;
data->bzstream.opaque = NULL;
- data->bzstream.next_in = (void *) data->buffer;
+ data->bzstream.next_in = (char *) data->buffer;
data->bzstream.avail_in = 0;
ret = BZ2_bzDecompressInit(&data->bzstream, 0, 0);
@@ -111,13 +127,9 @@ bz2_destroy(struct bz2_input_stream *data)
static struct archive_file *
bz2_open(const char *pathname, GError **error_r)
{
- struct bz2_archive_file *context;
+ struct bz2_archive_file *context = new bz2_archive_file();
int len;
- context = g_malloc(sizeof(*context));
- archive_file_init(&context->base, &bz2_archive_plugin);
- refcount_init(&context->ref);
-
//open archive
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
context->istream = input_stream_open(pathname,
@@ -125,7 +137,7 @@ bz2_open(const char *pathname, GError **error_r)
NULL,
error_r);
if (context->istream == NULL) {
- g_free(context);
+ delete context;
return NULL;
}
@@ -166,13 +178,7 @@ bz2_close(struct archive_file *file)
{
struct bz2_archive_file *context = (struct bz2_archive_file *) file;
- if (!refcount_dec(&context->ref))
- return;
-
- g_free(context->name);
-
- input_stream_close(context->istream);
- g_free(context);
+ context->Unref();
}
/* single archive handling */
@@ -254,7 +260,7 @@ bz2_is_read(struct input_stream *is, void *ptr, size_t length,
return 0;
bzstream = &bis->bzstream;
- bzstream->next_out = ptr;
+ bzstream->next_out = (char *)ptr;
bzstream->avail_out = length;
do {
@@ -296,19 +302,30 @@ static const char *const bz2_extensions[] = {
NULL
};
-static const struct input_plugin bz2_inputplugin = {
- .close = bz2_is_close,
- .read = bz2_is_read,
- .eof = bz2_is_eof,
+const struct input_plugin bz2_inputplugin = {
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ bz2_is_close,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ bz2_is_read,
+ bz2_is_eof,
+ nullptr,
};
const struct archive_plugin bz2_archive_plugin = {
- .name = "bz2",
- .open = bz2_open,
- .scan_reset = bz2_scan_reset,
- .scan_next = bz2_scan_next,
- .open_stream = bz2_open_stream,
- .close = bz2_close,
- .suffixes = bz2_extensions
+ "bz2",
+ nullptr,
+ nullptr,
+ bz2_open,
+ bz2_scan_reset,
+ bz2_scan_next,
+ bz2_open_stream,
+ bz2_close,
+ bz2_extensions,
};
diff --git a/src/archive/bz2_archive_plugin.h b/src/archive/Bzip2ArchivePlugin.hxx
index 46c69a66..a7933a7a 100644
--- a/src/archive/bz2_archive_plugin.h
+++ b/src/archive/Bzip2ArchivePlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_ARCHIVE_BZ2_H
-#define MPD_ARCHIVE_BZ2_H
+#ifndef MPD_ARCHIVE_BZ2_HXX
+#define MPD_ARCHIVE_BZ2_HXX
extern const struct archive_plugin bz2_archive_plugin;
diff --git a/src/archive/iso9660_archive_plugin.c b/src/archive/Iso9660ArchivePlugin.cxx
index bb6cb958..3f12912a 100644
--- a/src/archive/iso9660_archive_plugin.c
+++ b/src/archive/Iso9660ArchivePlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -22,8 +22,9 @@
*/
#include "config.h"
-#include "archive/iso9660_archive_plugin.h"
-#include "archive_api.h"
+#include "Iso9660ArchivePlugin.hxx"
+#include "ArchiveInternal.hxx"
+#include "ArchivePlugin.hxx"
#include "input_internal.h"
#include "input_plugin.h"
#include "refcount.h"
@@ -46,7 +47,7 @@ struct iso9660_archive_file {
GSList *iter;
};
-static const struct input_plugin iso9660_input_plugin;
+extern const struct input_plugin iso9660_input_plugin;
static inline GQuark
iso9660_quark(void)
@@ -76,7 +77,7 @@ listdir_recur(const char *psz_path, struct iso9660_archive_file *context)
strcpy(pathname, psz_path);
strcat(pathname, statbuf->filename);
- if (_STAT_DIR == statbuf->type ) {
+ if (iso9660_stat_s::_STAT_DIR == statbuf->type ) {
if (strcmp(statbuf->filename, ".") && strcmp(statbuf->filename, "..")) {
strcat(pathname, "/");
listdir_recur(pathname, context);
@@ -133,7 +134,7 @@ iso9660_archive_scan_next(struct archive_file *file)
char *data = NULL;
if (context->iter != NULL) {
///fetch data and goto next
- data = context->iter->data;
+ data = (char *)context->iter->data;
context->iter = g_slist_next(context->iter);
}
return data;
@@ -273,18 +274,29 @@ static const char *const iso9660_archive_extensions[] = {
NULL
};
-static const struct input_plugin iso9660_input_plugin = {
- .close = iso9660_input_close,
- .read = iso9660_input_read,
- .eof = iso9660_input_eof,
+const struct input_plugin iso9660_input_plugin = {
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ iso9660_input_close,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ iso9660_input_read,
+ iso9660_input_eof,
+ nullptr,
};
const struct archive_plugin iso9660_archive_plugin = {
- .name = "iso",
- .open = iso9660_archive_open,
- .scan_reset = iso9660_archive_scan_reset,
- .scan_next = iso9660_archive_scan_next,
- .open_stream = iso9660_archive_open_stream,
- .close = iso9660_archive_close,
- .suffixes = iso9660_archive_extensions
+ "iso",
+ nullptr,
+ nullptr,
+ iso9660_archive_open,
+ iso9660_archive_scan_reset,
+ iso9660_archive_scan_next,
+ iso9660_archive_open_stream,
+ iso9660_archive_close,
+ iso9660_archive_extensions,
};
diff --git a/src/archive/iso9660_archive_plugin.h b/src/archive/Iso9660ArchivePlugin.hxx
index 47dc6e47..6fbab615 100644
--- a/src/archive/iso9660_archive_plugin.h
+++ b/src/archive/Iso9660ArchivePlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_ARCHIVE_ISO9660_H
-#define MPD_ARCHIVE_ISO9660_H
+#ifndef MPD_ARCHIVE_ISO9660_HXX
+#define MPD_ARCHIVE_ISO9660_HXX
extern const struct archive_plugin iso9660_archive_plugin;
diff --git a/src/archive/zzip_archive_plugin.c b/src/archive/ZzipArchivePlugin.cxx
index ad96b5f8..00e689fb 100644
--- a/src/archive/zzip_archive_plugin.c
+++ b/src/archive/ZzipArchivePlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -22,9 +22,9 @@
*/
#include "config.h"
-#include "archive/zzip_archive_plugin.h"
-#include "archive_api.h"
-#include "archive_api.h"
+#include "ZzipArchivePlugin.hxx"
+#include "ArchiveInternal.hxx"
+#include "ArchivePlugin.hxx"
#include "input_internal.h"
#include "input_plugin.h"
#include "refcount.h"
@@ -41,9 +41,30 @@ struct zzip_archive {
ZZIP_DIR *dir;
GSList *list;
GSList *iter;
+
+ zzip_archive() {
+ archive_file_init(&base, &zzip_archive_plugin);
+ refcount_init(&ref);
+ }
+
+ void Unref() {
+ if (!refcount_dec(&ref))
+ return;
+
+ if (list) {
+ //free list
+ for (GSList *tmp = list; tmp != NULL; tmp = g_slist_next(tmp))
+ g_free(tmp->data);
+ g_slist_free(list);
+ }
+ //close archive
+ zzip_dir_close (dir);
+
+ delete this;
+ }
};
-static const struct input_plugin zzip_input_plugin;
+extern const struct input_plugin zzip_input_plugin;
static inline GQuark
zzip_quark(void)
@@ -56,12 +77,9 @@ zzip_quark(void)
static struct archive_file *
zzip_archive_open(const char *pathname, GError **error_r)
{
- struct zzip_archive *context = g_malloc(sizeof(*context));
+ struct zzip_archive *context = new zzip_archive();
ZZIP_DIRENT dirent;
- archive_file_init(&context->base, &zzip_archive_plugin);
- refcount_init(&context->ref);
-
// open archive
context->list = NULL;
context->dir = zzip_dir_open(pathname, NULL);
@@ -97,7 +115,7 @@ zzip_archive_scan_next(struct archive_file *file)
char *data = NULL;
if (context->iter != NULL) {
///fetch data and goto next
- data = context->iter->data;
+ data = (char *)context->iter->data;
context->iter = g_slist_next(context->iter);
}
return data;
@@ -108,19 +126,7 @@ zzip_archive_close(struct archive_file *file)
{
struct zzip_archive *context = (struct zzip_archive *) file;
- if (!refcount_dec(&context->ref))
- return;
-
- if (context->list) {
- //free list
- for (GSList *tmp = context->list; tmp != NULL; tmp = g_slist_next(tmp))
- g_free(tmp->data);
- g_slist_free(context->list);
- }
- //close archive
- zzip_dir_close (context->dir);
-
- g_free(context);
+ context->Unref();
}
/* single archive handling */
@@ -228,19 +234,29 @@ static const char *const zzip_archive_extensions[] = {
NULL
};
-static const struct input_plugin zzip_input_plugin = {
- .close = zzip_input_close,
- .read = zzip_input_read,
- .eof = zzip_input_eof,
- .seek = zzip_input_seek,
+const struct input_plugin zzip_input_plugin = {
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ zzip_input_close,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ zzip_input_read,
+ zzip_input_eof,
+ zzip_input_seek,
};
const struct archive_plugin zzip_archive_plugin = {
- .name = "zzip",
- .open = zzip_archive_open,
- .scan_reset = zzip_archive_scan_reset,
- .scan_next = zzip_archive_scan_next,
- .open_stream = zzip_archive_open_stream,
- .close = zzip_archive_close,
- .suffixes = zzip_archive_extensions
+ "zzip",
+ nullptr,
+ nullptr,
+ zzip_archive_open,
+ zzip_archive_scan_reset,
+ zzip_archive_scan_next,
+ zzip_archive_open_stream,
+ zzip_archive_close,
+ zzip_archive_extensions,
};
diff --git a/src/archive/zzip_archive_plugin.h b/src/archive/ZzipArchivePlugin.hxx
index 2b2c01e5..4ba16849 100644
--- a/src/archive/zzip_archive_plugin.h
+++ b/src/archive/ZzipArchivePlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_ARCHIVE_ZZIP_H
-#define MPD_ARCHIVE_ZZIP_H
+#ifndef MPD_ARCHIVE_ZZIP_HXX
+#define MPD_ARCHIVE_ZZIP_HXX
extern const struct archive_plugin zzip_archive_plugin;
diff --git a/src/input/archive_input_plugin.c b/src/input/ArchiveInputPlugin.cxx
index e608dd4a..560c6584 100644
--- a/src/input/archive_input_plugin.c
+++ b/src/input/ArchiveInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,9 +18,10 @@
*/
#include "config.h"
-#include "input/archive_input_plugin.h"
-#include "archive_api.h"
-#include "archive_list.h"
+#include "ArchiveInputPlugin.hxx"
+#include "ArchiveLookup.hxx"
+#include "ArchiveList.hxx"
+#include "ArchivePlugin.hxx"
#include "input_plugin.h"
#include <glib.h>
@@ -78,6 +79,16 @@ input_archive_open(const char *pathname,
}
const struct input_plugin input_plugin_archive = {
- .name = "archive",
- .open = input_archive_open,
+ "archive",
+ nullptr,
+ nullptr,
+ input_archive_open,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
};
diff --git a/src/input/archive_input_plugin.h b/src/input/ArchiveInputPlugin.hxx
index 51095f37..96fcd0dd 100644
--- a/src/input/archive_input_plugin.h
+++ b/src/input/ArchiveInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_INPUT_ARCHIVE_H
-#define MPD_INPUT_ARCHIVE_H
+#ifndef MPD_INPUT_ARCHIVE_HXX
+#define MPD_INPUT_ARCHIVE_HXX
extern const struct input_plugin input_plugin_archive;
diff --git a/test/dump_text_file.cxx b/test/dump_text_file.cxx
index 60da1c31..28a645a4 100644
--- a/test/dump_text_file.cxx
+++ b/test/dump_text_file.cxx
@@ -26,11 +26,11 @@
extern "C" {
#include "text_input_stream.h"
+}
#ifdef ENABLE_ARCHIVE
-#include "archive_list.h"
+#include "ArchiveList.hxx"
#endif
-}
#include <glib.h>
diff --git a/test/run_input.cxx b/test/run_input.cxx
index 1508d0d9..55f60b9f 100644
--- a/test/run_input.cxx
+++ b/test/run_input.cxx
@@ -26,11 +26,9 @@
#include "InputInit.hxx"
#include "IOThread.hxx"
-extern "C" {
#ifdef ENABLE_ARCHIVE
-#include "archive_list.h"
+#include "ArchiveList.hxx"
#endif
-}
#include <glib.h>