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.
This commit is contained in:
parent
f6dc9bcad6
commit
7d97d0ae87
@ -22,6 +22,21 @@
|
|||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
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
|
||||||
SmbclientContext::New()
|
SmbclientContext::New()
|
||||||
{
|
{
|
||||||
@ -29,6 +44,10 @@ SmbclientContext::New()
|
|||||||
if (ctx == nullptr)
|
if (ctx == nullptr)
|
||||||
throw MakeErrno("smbc_new_context() failed");
|
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);
|
SMBCCTX *ctx2 = smbc_init_context(ctx);
|
||||||
if (ctx2 == nullptr) {
|
if (ctx2 == nullptr) {
|
||||||
int e = errno;
|
int e = errno;
|
||||||
|
@ -18,33 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Init.hxx"
|
#include "Init.hxx"
|
||||||
#include "Mutex.hxx"
|
|
||||||
#include "thread/Mutex.hxx"
|
|
||||||
#include "system/Error.hxx"
|
|
||||||
|
|
||||||
#include <libsmbclient.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
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
|
void
|
||||||
SmbclientInit()
|
SmbclientInit()
|
||||||
{
|
{
|
||||||
const std::lock_guard<Mutex> protect(smbclient_mutex);
|
/* this is currently a no-op, but one day, we might want to
|
||||||
|
call smbc_thread_posix() here */
|
||||||
constexpr int debug = 0;
|
|
||||||
if (smbc_init(mpd_smbc_get_auth_data, debug) < 0)
|
|
||||||
throw MakeErrno("smbc_init() failed");
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user