2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Guenther Deschner 2007
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "lib/netapi/netapi.h"
23 extern bool AllowDebugChange;
25 static bool libnetapi_initialized = false;
27 NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
29 struct libnetapi_ctx *ctx = NULL;
30 TALLOC_CTX *frame = NULL;
32 if (libnetapi_initialized) {
33 return W_ERROR_V(WERR_OK);
36 frame = talloc_stackframe();
38 ctx = talloc_zero(frame, struct libnetapi_ctx);
41 return W_ERROR_V(WERR_NOMEM);
45 DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
47 x_setbuf(x_stderr, NULL);
48 AllowDebugChange = false;
52 setup_logging("libnetapi", true);
54 if (!lp_load(get_dyn_CONFIGFILE(), true, false, false, false)) {
56 return W_ERROR_V(WERR_GENERAL_FAILURE);
63 BlockSignals(True, SIGPIPE);
65 libnetapi_initialized = true;
69 return W_ERROR_V(WERR_OK);
72 NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
75 return W_ERROR_V(WERR_OK);
78 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
81 TALLOC_FREE(ctx->username);
82 ctx->username = talloc_strdup(ctx, username);
84 return W_ERROR_V(WERR_NOMEM);
86 return W_ERROR_V(WERR_OK);
89 NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
92 TALLOC_FREE(ctx->password);
93 ctx->password = talloc_strdup(ctx, password);
95 return W_ERROR_V(WERR_NOMEM);
97 return W_ERROR_V(WERR_OK);
100 NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
101 const char *workgroup)
103 TALLOC_FREE(ctx->workgroup);
104 ctx->workgroup = talloc_strdup(ctx, workgroup);
105 if (!ctx->workgroup) {
106 return W_ERROR_V(WERR_NOMEM);
108 return W_ERROR_V(WERR_OK);