const char *multivalued[] = { "objectClass", "memberOf", "privilege",
"member", NULL };
- var = mprObject(msg->dn);
+ var = mprObject(ldb_dn_linearize(msg, msg->dn));
for (i=0;i<msg->num_elements;i++) {
struct ldb_message_element *el = &msg->elements[i];
/* add the dn if it is not already specified */
if (mprGetProperty(&var, "dn", 0) == 0) {
- mprSetVar(&var, "dn", mprString(msg->dn));
+ mprSetVar(&var, "dn", mprString(ldb_dn_linearize(msg, msg->dn)));
}
return var;
return res;
}
+/*
+ create a data-blob in a mpr variable
+*/
+struct MprVar mprDataBlob(DATA_BLOB blob)
+{
+ struct MprVar res;
+ struct datablob *pblob = talloc(mprMemCtx(), struct datablob);
+ *pblob = data_blob_talloc(pblob, blob.data, blob.length);
+
+ res = mprObject("DATA_BLOB");
+
+ mprSetVar(&res, "size", mprCreateIntegerVar(blob.length));
+ mprSetPtrChild(&res, "blob", pblob);
+
+ return res;
+}
+
+/*
+ return a data blob from a mpr var created using mprDataBlob
+*/
+struct datablob *mprToDataBlob(struct MprVar *v)
+{
+ return talloc_get_type(mprGetPtr(v, "blob"), struct datablob);
+}
+
/*
turn a WERROR into a MprVar object with lots of funky properties
*/
}
/*
- set a pointer in a existing MprVar, making it a child of the property
+ set a pointer in a existing MprVar, freeing it when the property goes away
*/
void mprSetPtrChild(struct MprVar *v, const char *propname, const void *p)
{
mprSetVar(v, propname, mprCreatePtrVar(discard_const(p)));
- talloc_steal(mprGetProperty(v, propname, NULL), p);
+ v = mprGetProperty(v, propname, NULL);
+ v->allocatedData = 1;
+ talloc_steal(mprMemCtx(), p);
}
/*