Commit 94fffb33 authored by Max Kellermann's avatar Max Kellermann

archive/*: convert to C++

parent dc2e64c9
...@@ -130,14 +130,6 @@ mpd_headers = \ ...@@ -130,14 +130,6 @@ mpd_headers = \
src/string_util.h \ src/string_util.h \
src/zeroconf.h src/zeroconf-internal.h \ src/zeroconf.h src/zeroconf-internal.h \
src/timer.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_error.h
src_mpd_SOURCES = \ src_mpd_SOURCES = \
...@@ -414,10 +406,11 @@ src_mpd_SOURCES += \ ...@@ -414,10 +406,11 @@ src_mpd_SOURCES += \
src/UpdateArchive.cxx src/UpdateArchive.hxx src/UpdateArchive.cxx src/UpdateArchive.hxx
libarchive_a_SOURCES = \ libarchive_a_SOURCES = \
src/archive_api.c \ src/ArchiveLookup.cxx src/ArchiveLookup.hxx \
src/archive_list.c \ src/ArchiveList.cxx src/ArchiveList.hxx \
src/archive_plugin.c \ src/ArchivePlugin.cxx src/ArchivePlugin.hxx \
src/input/archive_input_plugin.c src/ArchiveInternal.hxx \
src/input/ArchiveInputPlugin.cxx src/input/ArchiveInputPlugin.hxx
libarchive_a_CPPFLAGS = $(AM_CPPFLAGS) \ libarchive_a_CPPFLAGS = $(AM_CPPFLAGS) \
$(BZ2_CFLAGS) \ $(BZ2_CFLAGS) \
$(ISO9660_CFLAGS) \ $(ISO9660_CFLAGS) \
...@@ -430,15 +423,21 @@ ARCHIVE_LIBS = \ ...@@ -430,15 +423,21 @@ ARCHIVE_LIBS = \
$(ZZIP_LIBS) $(ZZIP_LIBS)
if HAVE_BZ2 if HAVE_BZ2
libarchive_a_SOURCES += src/archive/bz2_archive_plugin.c libarchive_a_SOURCES += \
src/archive/Bzip2ArchivePlugin.cxx \
src/archive/Bzip2ArchivePlugin.hxx
endif endif
if HAVE_ZZIP if HAVE_ZZIP
libarchive_a_SOURCES += src/archive/zzip_archive_plugin.c libarchive_a_SOURCES += \
src/archive/ZzipArchivePlugin.cxx \
src/archive/ZzipArchivePlugin.hxx
endif endif
if HAVE_ISO9660 if HAVE_ISO9660
libarchive_a_SOURCES += src/archive/iso9660_archive_plugin.c libarchive_a_SOURCES += \
src/archive/Iso9660ArchivePlugin.cxx \
src/archive/Iso9660ArchivePlugin.hxx
endif endif
else else
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_ARCHIVE_INTERNAL_H #ifndef MPD_ARCHIVE_INTERNAL_HXX
#define MPD_ARCHIVE_INTERNAL_H #define MPD_ARCHIVE_INTERNAL_HXX
struct archive_file { struct archive_file {
const struct archive_plugin *plugin; const struct archive_plugin *plugin;
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
*/ */
#include "config.h" #include "config.h"
#include "archive_list.h" #include "ArchiveList.hxx"
#include "archive_plugin.h" #include "ArchivePlugin.hxx"
#include "string_util.h" #include "string_util.h"
#include "archive/bz2_archive_plugin.h" #include "archive/Bzip2ArchivePlugin.hxx"
#include "archive/iso9660_archive_plugin.h" #include "archive/Iso9660ArchivePlugin.hxx"
#include "archive/zzip_archive_plugin.h" #include "archive/ZzipArchivePlugin.hxx"
#include <string.h> #include <string.h>
#include <glib.h> #include <glib.h>
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_ARCHIVE_LIST_H #ifndef MPD_ARCHIVE_LIST_HXX
#define MPD_ARCHIVE_LIST_H #define MPD_ARCHIVE_LIST_HXX
struct archive_plugin; struct archive_plugin;
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
#include "config.h" /* must be first for large file support */ #include "config.h" /* must be first for large file support */
#include "archive_api.h" #include "ArchiveLookup.hxx"
#include <stdio.h> #include <stdio.h>
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_ARCHIVE_API_H #ifndef MPD_ARCHIVE_LOOKUP_HXX
#define MPD_ARCHIVE_API_H #define MPD_ARCHIVE_LOOKUP_HXX
/* /*
* This is the public API which is used by archive plugins to * This is the public API which is used by archive plugins to
...@@ -26,12 +26,6 @@ ...@@ -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); bool archive_lookup(char *pathname, char **archive, char **inpath, char **suffix);
#endif #endif
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "archive_plugin.h" #include "ArchivePlugin.hxx"
#include "archive_internal.h" #include "ArchiveInternal.hxx"
#include <assert.h> #include <assert.h>
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,13 +17,11 @@ ...@@ -17,13 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_ARCHIVE_PLUGIN_H #ifndef MPD_ARCHIVE_PLUGIN_HXX
#define MPD_ARCHIVE_PLUGIN_H #define MPD_ARCHIVE_PLUGIN_HXX
#include <glib.h> #include <glib.h>
#include <stdbool.h>
struct input_stream; struct input_stream;
struct archive_file; struct archive_file;
......
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
#endif #endif
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
#include "archive_list.h" #include "ArchiveList.hxx"
#include "archive_plugin.h" #include "ArchivePlugin.hxx"
#endif #endif
#include <glib.h> #include <glib.h>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "input/FileInputPlugin.hxx" #include "input/FileInputPlugin.hxx"
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
#include "input/archive_input_plugin.h" #include "input/ArchiveInputPlugin.hxx"
#endif #endif
#ifdef ENABLE_CURL #ifdef ENABLE_CURL
......
...@@ -69,11 +69,9 @@ extern "C" { ...@@ -69,11 +69,9 @@ extern "C" {
#include "StickerDatabase.hxx" #include "StickerDatabase.hxx"
#endif #endif
extern "C" {
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
#include "archive_list.h" #include "ArchiveList.hxx"
#endif #endif
}
#include <glib.h> #include <glib.h>
......
...@@ -25,11 +25,8 @@ ...@@ -25,11 +25,8 @@
#include "song.h" #include "song.h"
#include "Mapper.hxx" #include "Mapper.hxx"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "ArchiveList.hxx"
extern "C" { #include "ArchivePlugin.hxx"
#include "archive_list.h"
#include "archive_plugin.h"
}
#include <glib.h> #include <glib.h>
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -22,8 +22,9 @@ ...@@ -22,8 +22,9 @@
*/ */
#include "config.h" #include "config.h"
#include "archive/bz2_archive_plugin.h" #include "Bzip2ArchivePlugin.hxx"
#include "archive_api.h" #include "ArchiveInternal.hxx"
#include "ArchivePlugin.hxx"
#include "input_internal.h" #include "input_internal.h"
#include "input_plugin.h" #include "input_plugin.h"
#include "refcount.h" #include "refcount.h"
...@@ -47,6 +48,21 @@ struct bz2_archive_file { ...@@ -47,6 +48,21 @@ struct bz2_archive_file {
char *name; char *name;
bool reset; bool reset;
struct input_stream *istream; 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 { struct bz2_input_stream {
...@@ -61,7 +77,7 @@ struct bz2_input_stream { ...@@ -61,7 +77,7 @@ struct bz2_input_stream {
char buffer[5000]; char buffer[5000];
}; };
static const struct input_plugin bz2_inputplugin; extern const struct input_plugin bz2_inputplugin;
static inline GQuark static inline GQuark
bz2_quark(void) bz2_quark(void)
...@@ -80,7 +96,7 @@ bz2_alloc(struct bz2_input_stream *data, GError **error_r) ...@@ -80,7 +96,7 @@ bz2_alloc(struct bz2_input_stream *data, GError **error_r)
data->bzstream.bzfree = NULL; data->bzstream.bzfree = NULL;
data->bzstream.opaque = NULL; data->bzstream.opaque = NULL;
data->bzstream.next_in = (void *) data->buffer; data->bzstream.next_in = (char *) data->buffer;
data->bzstream.avail_in = 0; data->bzstream.avail_in = 0;
ret = BZ2_bzDecompressInit(&data->bzstream, 0, 0); ret = BZ2_bzDecompressInit(&data->bzstream, 0, 0);
...@@ -111,13 +127,9 @@ bz2_destroy(struct bz2_input_stream *data) ...@@ -111,13 +127,9 @@ bz2_destroy(struct bz2_input_stream *data)
static struct archive_file * static struct archive_file *
bz2_open(const char *pathname, GError **error_r) bz2_open(const char *pathname, GError **error_r)
{ {
struct bz2_archive_file *context; struct bz2_archive_file *context = new bz2_archive_file();
int len; int len;
context = g_malloc(sizeof(*context));
archive_file_init(&context->base, &bz2_archive_plugin);
refcount_init(&context->ref);
//open archive //open archive
static GStaticMutex mutex = G_STATIC_MUTEX_INIT; static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
context->istream = input_stream_open(pathname, context->istream = input_stream_open(pathname,
...@@ -125,7 +137,7 @@ bz2_open(const char *pathname, GError **error_r) ...@@ -125,7 +137,7 @@ bz2_open(const char *pathname, GError **error_r)
NULL, NULL,
error_r); error_r);
if (context->istream == NULL) { if (context->istream == NULL) {
g_free(context); delete context;
return NULL; return NULL;
} }
...@@ -166,13 +178,7 @@ bz2_close(struct archive_file *file) ...@@ -166,13 +178,7 @@ bz2_close(struct archive_file *file)
{ {
struct bz2_archive_file *context = (struct bz2_archive_file *) file; struct bz2_archive_file *context = (struct bz2_archive_file *) file;
if (!refcount_dec(&context->ref)) context->Unref();
return;
g_free(context->name);
input_stream_close(context->istream);
g_free(context);
} }
/* single archive handling */ /* single archive handling */
...@@ -254,7 +260,7 @@ bz2_is_read(struct input_stream *is, void *ptr, size_t length, ...@@ -254,7 +260,7 @@ bz2_is_read(struct input_stream *is, void *ptr, size_t length,
return 0; return 0;
bzstream = &bis->bzstream; bzstream = &bis->bzstream;
bzstream->next_out = ptr; bzstream->next_out = (char *)ptr;
bzstream->avail_out = length; bzstream->avail_out = length;
do { do {
...@@ -296,19 +302,30 @@ static const char *const bz2_extensions[] = { ...@@ -296,19 +302,30 @@ static const char *const bz2_extensions[] = {
NULL NULL
}; };
static const struct input_plugin bz2_inputplugin = { const struct input_plugin bz2_inputplugin = {
.close = bz2_is_close, nullptr,
.read = bz2_is_read, nullptr,
.eof = bz2_is_eof, nullptr,
nullptr,
bz2_is_close,
nullptr,
nullptr,
nullptr,
nullptr,
bz2_is_read,
bz2_is_eof,
nullptr,
}; };
const struct archive_plugin bz2_archive_plugin = { const struct archive_plugin bz2_archive_plugin = {
.name = "bz2", "bz2",
.open = bz2_open, nullptr,
.scan_reset = bz2_scan_reset, nullptr,
.scan_next = bz2_scan_next, bz2_open,
.open_stream = bz2_open_stream, bz2_scan_reset,
.close = bz2_close, bz2_scan_next,
.suffixes = bz2_extensions bz2_open_stream,
bz2_close,
bz2_extensions,
}; };
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_ARCHIVE_BZ2_H #ifndef MPD_ARCHIVE_BZ2_HXX
#define MPD_ARCHIVE_BZ2_H #define MPD_ARCHIVE_BZ2_HXX
extern const struct archive_plugin bz2_archive_plugin; extern const struct archive_plugin bz2_archive_plugin;
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -22,8 +22,9 @@ ...@@ -22,8 +22,9 @@
*/ */
#include "config.h" #include "config.h"
#include "archive/iso9660_archive_plugin.h" #include "Iso9660ArchivePlugin.hxx"
#include "archive_api.h" #include "ArchiveInternal.hxx"
#include "ArchivePlugin.hxx"
#include "input_internal.h" #include "input_internal.h"
#include "input_plugin.h" #include "input_plugin.h"
#include "refcount.h" #include "refcount.h"
...@@ -46,7 +47,7 @@ struct iso9660_archive_file { ...@@ -46,7 +47,7 @@ struct iso9660_archive_file {
GSList *iter; GSList *iter;
}; };
static const struct input_plugin iso9660_input_plugin; extern const struct input_plugin iso9660_input_plugin;
static inline GQuark static inline GQuark
iso9660_quark(void) iso9660_quark(void)
...@@ -76,7 +77,7 @@ listdir_recur(const char *psz_path, struct iso9660_archive_file *context) ...@@ -76,7 +77,7 @@ listdir_recur(const char *psz_path, struct iso9660_archive_file *context)
strcpy(pathname, psz_path); strcpy(pathname, psz_path);
strcat(pathname, statbuf->filename); strcat(pathname, statbuf->filename);
if (_STAT_DIR == statbuf->type ) { if (iso9660_stat_s::_STAT_DIR == statbuf->type ) {
if (strcmp(statbuf->filename, ".") && strcmp(statbuf->filename, "..")) { if (strcmp(statbuf->filename, ".") && strcmp(statbuf->filename, "..")) {
strcat(pathname, "/"); strcat(pathname, "/");
listdir_recur(pathname, context); listdir_recur(pathname, context);
...@@ -133,7 +134,7 @@ iso9660_archive_scan_next(struct archive_file *file) ...@@ -133,7 +134,7 @@ iso9660_archive_scan_next(struct archive_file *file)
char *data = NULL; char *data = NULL;
if (context->iter != NULL) { if (context->iter != NULL) {
///fetch data and goto next ///fetch data and goto next
data = context->iter->data; data = (char *)context->iter->data;
context->iter = g_slist_next(context->iter); context->iter = g_slist_next(context->iter);
} }
return data; return data;
...@@ -273,18 +274,29 @@ static const char *const iso9660_archive_extensions[] = { ...@@ -273,18 +274,29 @@ static const char *const iso9660_archive_extensions[] = {
NULL NULL
}; };
static const struct input_plugin iso9660_input_plugin = { const struct input_plugin iso9660_input_plugin = {
.close = iso9660_input_close, nullptr,
.read = iso9660_input_read, nullptr,
.eof = iso9660_input_eof, nullptr,
nullptr,
iso9660_input_close,
nullptr,
nullptr,
nullptr,
nullptr,
iso9660_input_read,
iso9660_input_eof,
nullptr,
}; };
const struct archive_plugin iso9660_archive_plugin = { const struct archive_plugin iso9660_archive_plugin = {
.name = "iso", "iso",
.open = iso9660_archive_open, nullptr,
.scan_reset = iso9660_archive_scan_reset, nullptr,
.scan_next = iso9660_archive_scan_next, iso9660_archive_open,
.open_stream = iso9660_archive_open_stream, iso9660_archive_scan_reset,
.close = iso9660_archive_close, iso9660_archive_scan_next,
.suffixes = iso9660_archive_extensions iso9660_archive_open_stream,
iso9660_archive_close,
iso9660_archive_extensions,
}; };
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_ARCHIVE_ISO9660_H #ifndef MPD_ARCHIVE_ISO9660_HXX
#define MPD_ARCHIVE_ISO9660_H #define MPD_ARCHIVE_ISO9660_HXX
extern const struct archive_plugin iso9660_archive_plugin; extern const struct archive_plugin iso9660_archive_plugin;
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
*/ */
#include "config.h" #include "config.h"
#include "archive/zzip_archive_plugin.h" #include "ZzipArchivePlugin.hxx"
#include "archive_api.h" #include "ArchiveInternal.hxx"
#include "archive_api.h" #include "ArchivePlugin.hxx"
#include "input_internal.h" #include "input_internal.h"
#include "input_plugin.h" #include "input_plugin.h"
#include "refcount.h" #include "refcount.h"
...@@ -41,9 +41,30 @@ struct zzip_archive { ...@@ -41,9 +41,30 @@ struct zzip_archive {
ZZIP_DIR *dir; ZZIP_DIR *dir;
GSList *list; GSList *list;
GSList *iter; 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 static inline GQuark
zzip_quark(void) zzip_quark(void)
...@@ -56,12 +77,9 @@ zzip_quark(void) ...@@ -56,12 +77,9 @@ zzip_quark(void)
static struct archive_file * static struct archive_file *
zzip_archive_open(const char *pathname, GError **error_r) 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; ZZIP_DIRENT dirent;
archive_file_init(&context->base, &zzip_archive_plugin);
refcount_init(&context->ref);
// open archive // open archive
context->list = NULL; context->list = NULL;
context->dir = zzip_dir_open(pathname, NULL); context->dir = zzip_dir_open(pathname, NULL);
...@@ -97,7 +115,7 @@ zzip_archive_scan_next(struct archive_file *file) ...@@ -97,7 +115,7 @@ zzip_archive_scan_next(struct archive_file *file)
char *data = NULL; char *data = NULL;
if (context->iter != NULL) { if (context->iter != NULL) {
///fetch data and goto next ///fetch data and goto next
data = context->iter->data; data = (char *)context->iter->data;
context->iter = g_slist_next(context->iter); context->iter = g_slist_next(context->iter);
} }
return data; return data;
...@@ -108,19 +126,7 @@ zzip_archive_close(struct archive_file *file) ...@@ -108,19 +126,7 @@ zzip_archive_close(struct archive_file *file)
{ {
struct zzip_archive *context = (struct zzip_archive *) file; struct zzip_archive *context = (struct zzip_archive *) file;
if (!refcount_dec(&context->ref)) context->Unref();
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);
} }
/* single archive handling */ /* single archive handling */
...@@ -228,19 +234,29 @@ static const char *const zzip_archive_extensions[] = { ...@@ -228,19 +234,29 @@ static const char *const zzip_archive_extensions[] = {
NULL NULL
}; };
static const struct input_plugin zzip_input_plugin = { const struct input_plugin zzip_input_plugin = {
.close = zzip_input_close, nullptr,
.read = zzip_input_read, nullptr,
.eof = zzip_input_eof, nullptr,
.seek = zzip_input_seek, nullptr,
zzip_input_close,
nullptr,
nullptr,
nullptr,
nullptr,
zzip_input_read,
zzip_input_eof,
zzip_input_seek,
}; };
const struct archive_plugin zzip_archive_plugin = { const struct archive_plugin zzip_archive_plugin = {
.name = "zzip", "zzip",
.open = zzip_archive_open, nullptr,
.scan_reset = zzip_archive_scan_reset, nullptr,
.scan_next = zzip_archive_scan_next, zzip_archive_open,
.open_stream = zzip_archive_open_stream, zzip_archive_scan_reset,
.close = zzip_archive_close, zzip_archive_scan_next,
.suffixes = zzip_archive_extensions zzip_archive_open_stream,
zzip_archive_close,
zzip_archive_extensions,
}; };
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_ARCHIVE_ZZIP_H #ifndef MPD_ARCHIVE_ZZIP_HXX
#define MPD_ARCHIVE_ZZIP_H #define MPD_ARCHIVE_ZZIP_HXX
extern const struct archive_plugin zzip_archive_plugin; extern const struct archive_plugin zzip_archive_plugin;
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,9 +18,10 @@ ...@@ -18,9 +18,10 @@
*/ */
#include "config.h" #include "config.h"
#include "input/archive_input_plugin.h" #include "ArchiveInputPlugin.hxx"
#include "archive_api.h" #include "ArchiveLookup.hxx"
#include "archive_list.h" #include "ArchiveList.hxx"
#include "ArchivePlugin.hxx"
#include "input_plugin.h" #include "input_plugin.h"
#include <glib.h> #include <glib.h>
...@@ -78,6 +79,16 @@ input_archive_open(const char *pathname, ...@@ -78,6 +79,16 @@ input_archive_open(const char *pathname,
} }
const struct input_plugin input_plugin_archive = { const struct input_plugin input_plugin_archive = {
.name = "archive", "archive",
.open = input_archive_open, nullptr,
nullptr,
input_archive_open,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
}; };
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_INPUT_ARCHIVE_H #ifndef MPD_INPUT_ARCHIVE_HXX
#define MPD_INPUT_ARCHIVE_H #define MPD_INPUT_ARCHIVE_HXX
extern const struct input_plugin input_plugin_archive; extern const struct input_plugin input_plugin_archive;
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
extern "C" { extern "C" {
#include "text_input_stream.h" #include "text_input_stream.h"
}
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
#include "archive_list.h" #include "ArchiveList.hxx"
#endif #endif
}
#include <glib.h> #include <glib.h>
......
...@@ -26,11 +26,9 @@ ...@@ -26,11 +26,9 @@
#include "InputInit.hxx" #include "InputInit.hxx"
#include "IOThread.hxx" #include "IOThread.hxx"
extern "C" {
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
#include "archive_list.h" #include "ArchiveList.hxx"
#endif #endif
}
#include <glib.h> #include <glib.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment