aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--src/input/plugins/SmbclientInputPlugin.cxx21
-rw-r--r--src/lib/smbclient/Init.cxx51
-rw-r--r--src/lib/smbclient/Init.hxx33
4 files changed, 87 insertions, 19 deletions
diff --git a/Makefile.am b/Makefile.am
index c877e7e1f..6bb3c9094 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -866,6 +866,7 @@ endif
if ENABLE_SMBCLIENT
libinput_a_SOURCES += \
+ src/lib/smbclient/Init.cxx src/lib/smbclient/Init.hxx \
src/input/plugins/SmbclientInputPlugin.cxx src/input/plugins/SmbclientInputPlugin.hxx
endif
diff --git a/src/input/plugins/SmbclientInputPlugin.cxx b/src/input/plugins/SmbclientInputPlugin.cxx
index 9fbe72b59..561e6f8fd 100644
--- a/src/input/plugins/SmbclientInputPlugin.cxx
+++ b/src/input/plugins/SmbclientInputPlugin.cxx
@@ -19,6 +19,7 @@
#include "config.h"
#include "SmbclientInputPlugin.hxx"
+#include "lib/smbclient/Init.hxx"
#include "../InputStream.hxx"
#include "../InputPlugin.hxx"
#include "util/StringUtil.hxx"
@@ -26,8 +27,6 @@
#include <libsmbclient.h>
-#include <string.h>
-
class SmbclientInputStream {
InputStream base;
@@ -80,19 +79,6 @@ public:
}
};
-static void
-mpd_smbc_get_auth_data(gcc_unused const char *srv,
- gcc_unused const char *shr,
- char *wg, gcc_unused int wglen,
- char *un, gcc_unused int unlen,
- char *pw, gcc_unused int pwlen)
-{
- // TODO: implement
- strcpy(wg, "WORKGROUP");
- strcpy(un, "foo");
- strcpy(pw, "bar");
-}
-
/*
* InputPlugin methods
*
@@ -101,11 +87,8 @@ mpd_smbc_get_auth_data(gcc_unused const char *srv,
static bool
input_smbclient_init(gcc_unused const config_param &param, Error &error)
{
- constexpr int debug = 0;
- if (smbc_init(mpd_smbc_get_auth_data, debug) < 0) {
- error.SetErrno("smbc_init() failed");
+ if (!SmbclientInit(error))
return false;
- }
// TODO: create one global SMBCCTX here?
diff --git a/src/lib/smbclient/Init.cxx b/src/lib/smbclient/Init.cxx
new file mode 100644
index 000000000..4af5c0cf4
--- /dev/null
+++ b/src/lib/smbclient/Init.cxx
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * http://www.musicpd.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+#include "Init.hxx"
+#include "util/Error.hxx"
+
+#include <libsmbclient.h>
+
+#include <string.h>
+
+static void
+mpd_smbc_get_auth_data(gcc_unused const char *srv,
+ gcc_unused const char *shr,
+ char *wg, gcc_unused int wglen,
+ char *un, gcc_unused int unlen,
+ char *pw, gcc_unused int pwlen)
+{
+ // TODO: implement
+ strcpy(wg, "WORKGROUP");
+ strcpy(un, "foo");
+ strcpy(pw, "bar");
+}
+
+bool
+SmbclientInit(Error &error)
+{
+ constexpr int debug = 0;
+ if (smbc_init(mpd_smbc_get_auth_data, debug) < 0) {
+ error.SetErrno("smbc_init() failed");
+ return false;
+ }
+
+ return true;
+}
diff --git a/src/lib/smbclient/Init.hxx b/src/lib/smbclient/Init.hxx
new file mode 100644
index 000000000..21014ec8d
--- /dev/null
+++ b/src/lib/smbclient/Init.hxx
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * http://www.musicpd.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef MPD_SMBCLIENT_INIT_HXX
+#define MPD_SMBCLIENT_INIT_HXX
+
+#include "check.h"
+
+class Error;
+
+/**
+ * Initialize libsmbclient.
+ */
+bool
+SmbclientInit(Error &error);
+
+#endif