From 86ca5b3f16bb5804d26bff91b4e16a458173b70d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 25 Jan 2014 23:29:42 +0100 Subject: input/smbclient: move code to lib/smbclient/Init.cxx --- Makefile.am | 1 + src/input/plugins/SmbclientInputPlugin.cxx | 21 ++---------- src/lib/smbclient/Init.cxx | 51 ++++++++++++++++++++++++++++++ src/lib/smbclient/Init.hxx | 33 +++++++++++++++++++ 4 files changed, 87 insertions(+), 19 deletions(-) create mode 100644 src/lib/smbclient/Init.cxx create mode 100644 src/lib/smbclient/Init.hxx 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 -#include - 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 ¶m, 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 + +#include + +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 -- cgit v1.2.3