2 Unix SMB/CIFS implementation.
4 provide hooks into smbd C calls from ejs scripts
6 Copyright (C) Jelmer Vernooij 2007
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "scripting/ejs/smbcalls.h"
24 #include "lib/appweb/ejs/ejs.h"
25 #include "dsdb/samdb/samdb.h"
26 #include "librpc/ndr/libndr.h"
27 #include "lib/registry/registry.h"
32 static struct registry_context *ejs_get_reg_context(int eid)
34 struct registry_context *rctx = (struct registry_context *)mprGetThisPtr(eid, "registry");
36 ejsSetErrorMsg(eid, "unable to find registry");
41 static int ejs_apply_patchfile(MprVarHandle eid, int argc, struct MprVar **argv)
43 struct registry_context *rctx;
46 /* validate arguments */
48 ejsSetErrorMsg(eid, "reg.apply_patchfile invalid number of arguments");
52 rctx = ejs_get_reg_context(eid);
57 error = reg_diff_apply(mprToString(argv[0]), rctx);
59 mpr_Return(eid, mprWERROR(error));
65 initialise registry ejs subsystem
67 static int ejs_reg_open(MprVarHandle eid, int argc, struct MprVar **argv)
69 struct MprVar *reg = mprInitObject(eid, "registry", argc, argv);
70 struct registry_context *rctx;
73 error = reg_open_samba(mprMemCtx(), &rctx, NULL, NULL);
74 SMB_ASSERT(W_ERROR_IS_OK(error));
76 mprSetPtrChild(reg, "registry", rctx);
77 mprSetCFunction(reg, "apply_patchfile", ejs_apply_patchfile);
84 setup C functions that be called from ejs
86 NTSTATUS smb_setup_ejs_reg(void)
88 ejsDefineCFunction(-1, "reg_open", ejs_reg_open, NULL, MPR_VAR_SCRIPT_HANDLE);