ldb error codes

tridge at samba.org tridge at samba.org
Mon Oct 31 23:32:44 GMT 2005


Simo,

 > There's a 4th option I like to explore, change the return value of
 > ldb_search into a structure, and have both error code and count hanging
 > on this structure.

That gives me another idea (a 5th option?)

We could change ldb_search like this:

int ldb_search(struct ldb_context *ldb, 
	       const struct ldb_dn *base,
	       enum ldb_scope scope,
	       const char *expression,
	       const char * const *attrs, struct ldb_result **res);

where ldb_result is this:

struct ldb_result {
	uint_t count;
	struct ldb_message **msgs;
}

and ldb_search would return an error code, just like all other ldb
calls.

The advantage of this approach is it will make it easier for us to add
referral results later, as we can expand the struct ldb_result
structure with new elements at the end (thats why I made it a pointer
to a pointer - it means new elements remain binary compatible).

It means we have to change all calls to ldb_search(), but thats
actually easier than some of the other proposals as the compiler would
point out the places that need doing, and the change itself will be to
look for res->count and res->msgs instead of ret and (*res), which is
a quite simple change to make.

Cheers, Tridge


More information about the samba-technical mailing list