From 7ca399c0755e186508a4ed9796cbbbe6f50181e9 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 14 Feb 2007 21:55:29 +0000 Subject: r21351: Change ldb ejs bindings return codes. We were returning just true/false and discarding error number and string. This checking probably breaks swat, will fix it in next round as swat is what made me look into this as I had no way to get back error messages to show to the users. Simo. (This used to be commit 35886b4ae68be475b0fc8b2689ca04d766661261) --- source4/scripting/ejs/mprutil.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'source4/scripting/ejs/mprutil.c') diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c index cfed69dbe0..459f198dca 100644 --- a/source4/scripting/ejs/mprutil.c +++ b/source4/scripting/ejs/mprutil.c @@ -223,19 +223,32 @@ failed: /* - turn an array of ldb_messages into a ejs object variable + build a MprVar result object for ldb operations with lots of funky properties */ -struct MprVar mprLdbArray(struct ldb_context *ldb, - struct ldb_message **msg, int count, const char *name) +struct MprVar mprLdbResult(struct ldb_context *ldb, int err, struct ldb_result *result) { - struct MprVar res; - int i; + struct MprVar ret; + struct MprVar ary; + + ret = mprObject("ldbret"); + + mprSetVar(&ret, "error", mprCreateIntegerVar(err)); + mprSetVar(&ret, "errstr", mprString(ldb_errstring(ldb))); + + ary = mprArray("ldb_message"); + if (result) { + int i; - res = mprArray(name); - for (i=0;icount; i++) { + mprAddArray(&ary, i, mprLdbMessage(ldb, result->msgs[i])); + } } - return res; + + mprSetVar(&ret, "msgs", ary); + + /* TODO: add referrals, exteded ops, and controls */ + + return ret; } -- cgit