r7225: Create a MprVar object from a NTSTATUS, e.g:
authorTim Potter <tpot@samba.org>
Fri, 3 Jun 2005 12:31:56 +0000 (12:31 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:28 +0000 (13:17 -0500)
res: {
  is_err: true,
  is_ok: false,
  errstr: "NT_STATUS_IO_TIMEOUT",
  v: -1073741643
}
(This used to be commit d81d5f8317ca82a08e6fc38ef7313fad2e631281)

source4/scripting/ejs/mprutil.c

index 3e47fdf9a36faa018889867911ddf98a3663bc0e..4aee7d1c50de29d937658b165c9e7922cd7be959 100644 (file)
@@ -166,3 +166,26 @@ const char **mprToList(TALLOC_CTX *mem_ctx, struct MprVar *v)
        return list;
 }
 
+/*
+  turn a NTSTATUS into a MprVar object with lots of funky properties
+*/
+struct MprVar mprNTSTATUS(NTSTATUS status)
+{
+       struct MprVar res, val;
+
+       res = mprCreateObjVar("ntstatus", MPR_DEFAULT_HASH_SIZE);
+
+       val = mprCreateStringVar(nt_errstr(status), 1);
+       mprCreateProperty(&res, "errstr", &val);
+
+       val = mprCreateIntegerVar(NT_STATUS_V(status));
+       mprCreateProperty(&res, "v", &val);
+
+       val = mprCreateBoolVar(NT_STATUS_IS_OK(status));
+       mprCreateProperty(&res, "is_ok", &val);
+
+       val = mprCreateBoolVar(NT_STATUS_IS_ERR(status));
+       mprCreateProperty(&res, "is_err", &val);
+
+       return res;
+}