From 7d97d0ae878b4076eea3a487277396df22610374 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 20 Jul 2020 22:12:52 +0200 Subject: [PATCH] lib/smbclient/Init: move code to SmbclientContext::New() We no longer need to call smbc_init() because we don't need the compat layer anymore. --- src/lib/smbclient/Context.cxx | 19 +++++++++++++++++++ src/lib/smbclient/Init.cxx | 27 ++------------------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/lib/smbclient/Context.cxx b/src/lib/smbclient/Context.cxx index 3e122bd37..f61a80042 100644 --- a/src/lib/smbclient/Context.cxx +++ b/src/lib/smbclient/Context.cxx @@ -22,6 +22,21 @@ #include +#include + +static void +mpd_smbc_get_auth_data([[maybe_unused]] const char *srv, + [[maybe_unused]] const char *shr, + char *wg, [[maybe_unused]] int wglen, + char *un, [[maybe_unused]] int unlen, + char *pw, [[maybe_unused]] int pwlen) +{ + // TODO: implement + strcpy(wg, "WORKGROUP"); + strcpy(un, ""); + strcpy(pw, ""); +} + SmbclientContext SmbclientContext::New() { @@ -29,6 +44,10 @@ SmbclientContext::New() if (ctx == nullptr) throw MakeErrno("smbc_new_context() failed"); + constexpr int debug = 0; + smbc_setDebug(ctx, debug); + smbc_setFunctionAuthData(ctx, mpd_smbc_get_auth_data); + SMBCCTX *ctx2 = smbc_init_context(ctx); if (ctx2 == nullptr) { int e = errno; diff --git a/src/lib/smbclient/Init.cxx b/src/lib/smbclient/Init.cxx index 746b68925..0c148746a 100644 --- a/src/lib/smbclient/Init.cxx +++ b/src/lib/smbclient/Init.cxx @@ -18,33 +18,10 @@ */ #include "Init.hxx" -#include "Mutex.hxx" -#include "thread/Mutex.hxx" -#include "system/Error.hxx" - -#include - -#include - -static void -mpd_smbc_get_auth_data([[maybe_unused]] const char *srv, - [[maybe_unused]] const char *shr, - char *wg, [[maybe_unused]] int wglen, - char *un, [[maybe_unused]] int unlen, - char *pw, [[maybe_unused]] int pwlen) -{ - // TODO: implement - strcpy(wg, "WORKGROUP"); - strcpy(un, ""); - strcpy(pw, ""); -} void SmbclientInit() { - const std::lock_guard protect(smbclient_mutex); - - constexpr int debug = 0; - if (smbc_init(mpd_smbc_get_auth_data, debug) < 0) - throw MakeErrno("smbc_init() failed"); + /* this is currently a no-op, but one day, we might want to + call smbc_thread_posix() here */ }