From 26a55c330a8cd79da290b2ad0e15aaf94be6ebcf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 12 Jul 2005 06:57:25 +0000 Subject: r8355: - added a vsprintf() function - removed the --outputdir option from provision, as its not used any more (as ejs knows the real paths) (This used to be commit abbf9c703c17c2edc2d978dade3619a96c38d0d9) --- source4/scripting/ejs/smbcalls_string.c | 36 +++++++++++++++++++++++++++++++++ source4/scripting/libjs/base.js | 8 ++++++++ source4/setup/provision | 2 -- testprogs/ejs/bugs.js | 34 ++++++++++++++++++++++++++++++- testprogs/ejs/sprintf.js | 7 +++++++ 5 files changed, 84 insertions(+), 3 deletions(-) diff --git a/source4/scripting/ejs/smbcalls_string.c b/source4/scripting/ejs/smbcalls_string.c index 7a19ecdf2c..ad998701f6 100644 --- a/source4/scripting/ejs/smbcalls_string.c +++ b/source4/scripting/ejs/smbcalls_string.c @@ -271,6 +271,41 @@ failed: return -1; } +/* + used to build your own print function + str = vsprintf(args); +*/ +static int ejs_vsprintf(MprVarHandle eid, int argc, struct MprVar **argv) +{ + struct MprVar **args, *len, *v; + int i, ret, length; + if (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) { + ejsSetErrorMsg(eid, "vsprintf invalid arguments"); + return -1; + } + v = argv[0]; + len = mprGetProperty(v, "length", NULL); + if (len == NULL) { + ejsSetErrorMsg(eid, "vsprintf takes an array"); + return -1; + } + length = mprToInt(len); + args = talloc_array(mprMemCtx(), struct MprVar *, length); + if (args == NULL) { + return -1; + } + + for (i=0;i