aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-02 22:25:17 +0100
committerMax Kellermann <max@duempel.org>2013-01-02 22:25:17 +0100
commit9ceb8a717ae940972904ef83722f71c3ee124715 (patch)
tree31fc9fed3ca5934581455ddf603a3e3f78fc66d3 /src
parent8331de424a67b137cd83ce817da0fceec647dc2f (diff)
sticker: convert to C++
Diffstat (limited to 'src')
-rw-r--r--src/AllCommands.cxx6
-rw-r--r--src/Main.cxx6
-rw-r--r--src/OtherCommands.cxx2
-rw-r--r--src/SongSticker.cxx (renamed from src/song_sticker.c)25
-rw-r--r--src/SongSticker.hxx (renamed from src/song_sticker.h)7
-rw-r--r--src/StickerCommands.cxx6
-rw-r--r--src/StickerDatabase.cxx (renamed from src/sticker.c)35
-rw-r--r--src/StickerDatabase.hxx (renamed from src/sticker.h)8
-rw-r--r--src/StickerPrint.cxx (renamed from src/sticker_print.c)11
-rw-r--r--src/StickerPrint.hxx (renamed from src/sticker_print.h)6
-rw-r--r--src/UpdateRemove.cxx6
11 files changed, 58 insertions, 60 deletions
diff --git a/src/AllCommands.cxx b/src/AllCommands.cxx
index 28e3d3eb..6026c690 100644
--- a/src/AllCommands.cxx
+++ b/src/AllCommands.cxx
@@ -29,7 +29,6 @@ extern "C" {
#include "PlaylistCommands.hxx"
#include "DatabaseCommands.hxx"
#include "OutputCommands.hxx"
-#include "StickerCommands.hxx"
#include "MessageCommands.hxx"
#include "OtherCommands.hxx"
#include "permission.h"
@@ -39,11 +38,12 @@ extern "C" {
#include "protocol/result.h"
#include "tokenizer.h"
#include "client.h"
+}
#ifdef ENABLE_SQLITE
-#include "sticker.h"
+#include "StickerCommands.hxx"
+#include "StickerDatabase.hxx"
#endif
-}
#include <assert.h>
#include <string.h>
diff --git a/src/Main.cxx b/src/Main.cxx
index 0d8f66d7..d0f88c23 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -63,16 +63,14 @@ extern "C" {
#include "InotifyUpdate.hxx"
#endif
-extern "C" {
-
#ifdef ENABLE_SQLITE
-#include "sticker.h"
+#include "StickerDatabase.hxx"
#endif
+extern "C" {
#ifdef ENABLE_ARCHIVE
#include "archive_list.h"
#endif
-
}
#include <glib.h>
diff --git a/src/OtherCommands.cxx b/src/OtherCommands.cxx
index c5aeeab2..19d5a8c7 100644
--- a/src/OtherCommands.cxx
+++ b/src/OtherCommands.cxx
@@ -50,7 +50,7 @@ extern "C" {
}
#ifdef ENABLE_SQLITE
-#include "sticker.h"
+#include "StickerDatabase.hxx"
#endif
#include <assert.h>
diff --git a/src/song_sticker.c b/src/SongSticker.cxx
index 78025906..b32ef9d4 100644
--- a/src/song_sticker.c
+++ b/src/SongSticker.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,10 +18,10 @@
*/
#include "config.h"
-#include "song_sticker.h"
+#include "SongSticker.hxx"
+#include "StickerDatabase.hxx"
#include "song.h"
#include "directory.h"
-#include "sticker.h"
#include <glib.h>
@@ -121,7 +121,8 @@ struct sticker_song_find_data {
static void
sticker_song_find_cb(const char *uri, const char *value, gpointer user_data)
{
- struct sticker_song_find_data *data = user_data;
+ struct sticker_song_find_data *data =
+ (struct sticker_song_find_data *)user_data;
struct song *song;
if (memcmp(uri, data->base_uri, data->base_uri_length) != 0)
@@ -140,14 +141,12 @@ sticker_song_find(struct directory *directory, const char *name,
gpointer user_data),
gpointer user_data)
{
- struct sticker_song_find_data data = {
- .directory = directory,
- .func = func,
- .user_data = user_data,
- };
- char *allocated;
- bool success;
+ struct sticker_song_find_data data;
+ data.directory = directory;
+ data.func = func;
+ data.user_data = user_data;
+ char *allocated;
data.base_uri = directory_get_path(directory);
if (*data.base_uri != 0)
/* append slash to base_uri */
@@ -159,8 +158,8 @@ sticker_song_find(struct directory *directory, const char *name,
data.base_uri_length = strlen(data.base_uri);
- success = sticker_find("song", data.base_uri, name,
- sticker_song_find_cb, &data);
+ bool success = sticker_find("song", data.base_uri, name,
+ sticker_song_find_cb, &data);
g_free(allocated);
return success;
diff --git a/src/song_sticker.h b/src/SongSticker.hxx
index 20ae68ce..81b76cef 100644
--- a/src/song_sticker.h
+++ b/src/SongSticker.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,10 +17,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef SONG_STICKER_H
-#define SONG_STICKER_H
+#ifndef MPD_SONG_STICKER_HXX
+#define MPD_SONG_STICKER_HXX
-#include <stdbool.h>
#include <glib.h>
struct song;
diff --git a/src/StickerCommands.cxx b/src/StickerCommands.cxx
index ad09f9b4..f4636e02 100644
--- a/src/StickerCommands.cxx
+++ b/src/StickerCommands.cxx
@@ -21,12 +21,12 @@
#include "StickerCommands.hxx"
#include "SongPrint.hxx"
#include "DatabaseLock.hxx"
+#include "SongSticker.hxx"
+#include "StickerPrint.hxx"
+#include "StickerDatabase.hxx"
extern "C" {
#include "protocol/result.h"
-#include "sticker.h"
-#include "sticker_print.h"
-#include "song_sticker.h"
#include "database.h"
}
diff --git a/src/sticker.c b/src/StickerDatabase.cxx
index 346a827a..9577ff73 100644
--- a/src/sticker.c
+++ b/src/StickerDatabase.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,8 +18,11 @@
*/
#include "config.h"
-#include "sticker.h"
+#include "StickerDatabase.hxx"
+
+extern "C" {
#include "idle.h"
+}
#include <glib.h>
#include <sqlite3.h>
@@ -47,19 +50,19 @@ enum sticker_sql {
};
static const char *const sticker_sql[] = {
- [STICKER_SQL_GET] =
+ //[STICKER_SQL_GET] =
"SELECT value FROM sticker WHERE type=? AND uri=? AND name=?",
- [STICKER_SQL_LIST] =
+ //[STICKER_SQL_LIST] =
"SELECT name,value FROM sticker WHERE type=? AND uri=?",
- [STICKER_SQL_UPDATE] =
+ //[STICKER_SQL_UPDATE] =
"UPDATE sticker SET value=? WHERE type=? AND uri=? AND name=?",
- [STICKER_SQL_INSERT] =
+ //[STICKER_SQL_INSERT] =
"INSERT INTO sticker(type,uri,name,value) VALUES(?, ?, ?, ?)",
- [STICKER_SQL_DELETE] =
+ //[STICKER_SQL_DELETE] =
"DELETE FROM sticker WHERE type=? AND uri=?",
- [STICKER_SQL_DELETE_VALUE] =
+ //[STICKER_SQL_DELETE_VALUE] =
"DELETE FROM sticker WHERE type=? AND uri=? AND name=?",
- [STICKER_SQL_FIND] =
+ //[STICKER_SQL_FIND] =
"SELECT uri,value FROM sticker WHERE type=? AND uri LIKE (? || '%') AND name=?",
};
@@ -541,7 +544,7 @@ sticker_free(struct sticker *sticker)
const char *
sticker_get_value(const struct sticker *sticker, const char *name)
{
- return g_hash_table_lookup(sticker->table, name);
+ return (const char *)g_hash_table_lookup(sticker->table, name);
}
struct sticker_foreach_data {
@@ -553,9 +556,10 @@ struct sticker_foreach_data {
static void
sticker_foreach_func(gpointer key, gpointer value, gpointer user_data)
{
- struct sticker_foreach_data *data = user_data;
+ struct sticker_foreach_data *data =
+ (struct sticker_foreach_data *)user_data;
- data->func(key, value, data->user_data);
+ data->func((const char *)key, (const char *)value, data->user_data);
}
void
@@ -564,10 +568,9 @@ sticker_foreach(const struct sticker *sticker,
gpointer user_data),
gpointer user_data)
{
- struct sticker_foreach_data data = {
- .func = func,
- .user_data = user_data,
- };
+ struct sticker_foreach_data data;
+ data.func = func;
+ data.user_data = user_data;
g_hash_table_foreach(sticker->table, sticker_foreach_func, &data);
}
diff --git a/src/sticker.h b/src/StickerDatabase.hxx
index 66f12294..90ff9b06 100644
--- a/src/sticker.h
+++ b/src/StickerDatabase.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
@@ -39,13 +39,11 @@
*
*/
-#ifndef STICKER_H
-#define STICKER_H
+#ifndef MPD_STICKER_DATABASE_HXX
+#define MPD_STICKER_DATABASE_HXX
#include "gerror.h"
-#include <stdbool.h>
-
struct sticker;
/**
diff --git a/src/sticker_print.c b/src/StickerPrint.cxx
index b19dcdc9..6099f728 100644
--- a/src/sticker_print.c
+++ b/src/StickerPrint.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,12 @@
*/
#include "config.h"
-#include "sticker_print.h"
-#include "sticker.h"
+#include "StickerPrint.hxx"
+#include "StickerDatabase.hxx"
+
+extern "C" {
#include "client.h"
+}
void
sticker_print_value(struct client *client,
@@ -32,7 +35,7 @@ sticker_print_value(struct client *client,
static void
print_sticker_cb(const char *name, const char *value, void *data)
{
- struct client *client = data;
+ struct client *client = (struct client *)data;
sticker_print_value(client, name, value);
}
diff --git a/src/sticker_print.h b/src/StickerPrint.hxx
index 7398c808..99573d23 100644
--- a/src/sticker_print.h
+++ b/src/StickerPrint.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_STICKER_PRINT_H
-#define MPD_STICKER_PRINT_H
+#ifndef MPD_STICKER_PRINT_HXX
+#define MPD_STICKER_PRINT_HXX
struct sticker;
struct client;
diff --git a/src/UpdateRemove.cxx b/src/UpdateRemove.cxx
index 71852ea9..c88eec42 100644
--- a/src/UpdateRemove.cxx
+++ b/src/UpdateRemove.cxx
@@ -29,10 +29,8 @@ extern "C" {
#include "Main.hxx"
#ifdef ENABLE_SQLITE
-extern "C" {
-#include "sticker.h"
-#include "song_sticker.h"
-}
+#include "StickerDatabase.hxx"
+#include "SongSticker.hxx"
#endif
#include <glib.h>