1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

r8484: switched the sys_*() calls to the OO interface

tim, do you want to do the cli_*() calls now?
This commit is contained in:
Andrew Tridgell 2005-07-15 07:45:40 +00:00 committed by Gerald (Jerry) Carter
parent 57d7a585e8
commit 9991e924e9
2 changed files with 34 additions and 18 deletions

View File

@ -170,17 +170,31 @@ static int ejs_sys_file_save(MprVarHandle eid, int argc, char **argv)
}
/*
initialise sys ejs subsystem
*/
static int ejs_sys_init(MprVarHandle eid, int argc, struct MprVar **argv)
{
struct MprVar obj = mprObject("sys");
mprSetCFunction(&obj, "interfaces", ejs_sys_interfaces);
mprSetCFunction(&obj, "hostname", ejs_sys_hostname);
mprSetCFunction(&obj, "nttime", ejs_sys_nttime);
mprSetCFunction(&obj, "gmtime", ejs_sys_gmtime);
mprSetCFunction(&obj, "ldaptime", ejs_sys_ldaptime);
mprSetStringCFunction(&obj, "unlink", ejs_sys_unlink);
mprSetStringCFunction(&obj, "file_load", ejs_sys_file_load);
mprSetStringCFunction(&obj, "file_save", ejs_sys_file_save);
mpr_Return(eid, obj);
return 0;
}
/*
setup C functions that be called from ejs
*/
void smb_setup_ejs_system(void)
{
ejsDefineCFunction(-1, "sys_interfaces", ejs_sys_interfaces, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "sys_hostname", ejs_sys_hostname, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "sys_nttime", ejs_sys_nttime, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "sys_gmtime", ejs_sys_gmtime, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "sys_ldaptime", ejs_sys_ldaptime, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineStringCFunction(-1, "sys_unlink", ejs_sys_unlink, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineStringCFunction(-1, "sys_file_load", ejs_sys_file_load, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineStringCFunction(-1, "sys_file_save", ejs_sys_file_save, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "sys_init", ejs_sys_init, NULL, MPR_VAR_SCRIPT_HANDLE);
}

View File

@ -7,6 +7,8 @@
/* used to generate sequence numbers for records */
provision_next_usn = 1;
sys = sys_init();
/*
find a user or group from a list of possibilities
*/
@ -59,7 +61,7 @@ unixName: ${UNIXNAME}
*/
function nttime()
{
return "" + sys_nttime();
return "" + sys.nttime();
}
/*
@ -67,7 +69,7 @@ function nttime()
*/
function ldaptime()
{
return sys_ldaptime(sys_nttime());
return sys.ldaptime(sys.nttime());
}
/*
@ -75,7 +77,7 @@ function ldaptime()
*/
function datestring()
{
var t = sys_gmtime(sys_nttime());
var t = sys.gmtime(sys.nttime());
return sprintf("%04u%02u%02u%02u",
t.tm_year+1900, t.tm_mon+1, t.tm_mday, t.tm_hour);
}
@ -85,7 +87,7 @@ function datestring()
*/
function hostip()
{
var list = sys_interfaces();
var list = sys.interfaces();
return list[0];
}
@ -103,7 +105,7 @@ function nextusn()
*/
function hostname()
{
var s = split(".", sys_hostname());
var s = split(".", sys.hostname());
return s[0];
}
@ -123,9 +125,9 @@ function setup_ldb(ldif, dbname, subobj)
var db = lpGet("private dir") + "/" + dbname;
var src = lpGet("setup directory") + "/" + ldif;
sys_unlink(db);
sys.unlink(db);
var data = sys_file_load(src);
var data = sys.file_load(src);
data = data + extra;
data = substitute_var(data, subobj);
@ -141,12 +143,12 @@ function setup_file(template, fname, subobj)
var f = lpGet("private dir") + "/" + fname;
var src = lpGet("setup directory") + "/" + template;
sys_unlink(f);
sys.unlink(f);
var data = sys_file_load(src);
var data = sys.file_load(src);
data = substitute_var(data, subobj);
ok = sys_file_save(f, data);
ok = sys.file_save(f, data);
assert(ok);
}