From a599edf04cbdeef9014923ba0d3713b8ff84f266 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 06:10:23 +0000 Subject: r10913: This patch isn't as big as it looks ... most of the changes are fixes to make all the ldb code compile without warnings on gcc4. Unfortunately That required a lot of casts :-( I have also added the start of an 'operational' module, which will replace the timestamp module, plus add support for some other operational attributes In ldb_msg_*() I added some new utility functions to make the operational module sane, and remove the 'ldb' argument from the ldb_msg_add_*() functions. That argument was only needed back in the early days of ldb when we didn't use the hierarchical talloc and thus needed a place to get the allocation function from. Now its just a pain to pass around everywhere. Also added a ldb_debug_set() function that calls ldb_debug() plus sets the result using ldb_set_errstring(). That saves on some awkward coding in a few places. (This used to be commit f6818daecca95760c12f79fd307770cbe3346f57) --- source4/lib/ldb/tools/ldbtest.c | 42 +++++++++++++++++------------------ source4/lib/ldb/tools/oLschema2ldif.c | 12 +++++----- 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'source4/lib/ldb/tools') diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c index 08ce99d20f..cda912c9b2 100644 --- a/source4/lib/ldb/tools/ldbtest.c +++ b/source4/lib/ldb/tools/ldbtest.c @@ -86,43 +86,43 @@ static void add_records(struct ldb_context *ldb, el[0].name = talloc_strdup(tmp_ctx, "cn"); el[0].num_values = 1; el[0].values = vals[0]; - vals[0][0].data = name; + vals[0][0].data = (uint8_t *)name; vals[0][0].length = strlen(name); el[1].flags = 0; - el[1].name = talloc_strdup(tmp_ctx, "title"); + el[1].name = "title"; el[1].num_values = 1; el[1].values = vals[1]; - vals[1][0].data = talloc_asprintf(tmp_ctx, "The title of %s", name); - vals[1][0].length = strlen(vals[1][0].data); + vals[1][0].data = (uint8_t *)talloc_asprintf(tmp_ctx, "The title of %s", name); + vals[1][0].length = strlen((char *)vals[1][0].data); el[2].flags = 0; el[2].name = talloc_strdup(tmp_ctx, "uid"); el[2].num_values = 1; el[2].values = vals[2]; - vals[2][0].data = ldb_casefold(tmp_ctx, name); - vals[2][0].length = strlen(vals[2][0].data); + vals[2][0].data = (uint8_t *)ldb_casefold(tmp_ctx, name); + vals[2][0].length = strlen((char *)vals[2][0].data); el[3].flags = 0; el[3].name = talloc_strdup(tmp_ctx, "mail"); el[3].num_values = 1; el[3].values = vals[3]; - vals[3][0].data = talloc_asprintf(tmp_ctx, "%s@example.com", name); - vals[3][0].length = strlen(vals[3][0].data); + vals[3][0].data = (uint8_t *)talloc_asprintf(tmp_ctx, "%s@example.com", name); + vals[3][0].length = strlen((char *)vals[3][0].data); el[4].flags = 0; el[4].name = talloc_strdup(tmp_ctx, "objectClass"); el[4].num_values = 1; el[4].values = vals[4]; - vals[4][0].data = talloc_strdup(tmp_ctx, "OpenLDAPperson"); - vals[4][0].length = strlen(vals[4][0].data); + vals[4][0].data = (uint8_t *)talloc_strdup(tmp_ctx, "OpenLDAPperson"); + vals[4][0].length = strlen((char *)vals[4][0].data); el[5].flags = 0; el[5].name = talloc_strdup(tmp_ctx, "sn"); el[5].num_values = 1; el[5].values = vals[5]; - vals[5][0].data = name; - vals[5][0].length = strlen(vals[5][0].data); + vals[5][0].data = (uint8_t *)name; + vals[5][0].length = strlen((char *)vals[5][0].data); ldb_delete(ldb, msg.dn); @@ -172,15 +172,15 @@ static void modify_records(struct ldb_context *ldb, el[1].name = talloc_strdup(tmp_ctx, "mail"); el[1].num_values = 1; el[1].values = &vals[1]; - vals[1].data = talloc_asprintf(tmp_ctx, "%s@other.example.com", name); - vals[1].length = strlen(vals[1].data); + vals[1].data = (uint8_t *)talloc_asprintf(tmp_ctx, "%s@other.example.com", name); + vals[1].length = strlen((char *)vals[1].data); el[2].flags = LDB_FLAG_MOD_REPLACE; el[2].name = talloc_strdup(tmp_ctx, "mail"); el[2].num_values = 1; el[2].values = &vals[2]; - vals[2].data = talloc_asprintf(tmp_ctx, "%s@other2.example.com", name); - vals[2].length = strlen(vals[2].data); + vals[2].data = (uint8_t *)talloc_asprintf(tmp_ctx, "%s@other2.example.com", name); + vals[2].length = strlen((char *)vals[2].data); if (ldb_modify(ldb, &msg) != 0) { printf("Modify of %s failed - %s\n", name, ldb_errstring(ldb)); @@ -314,7 +314,7 @@ static void start_test_index(struct ldb_context **ldb) msg = ldb_msg_new(NULL); msg->dn = indexlist; - ldb_msg_add_string(*ldb, msg, "@IDXATTR", strdup("uid")); + ldb_msg_add_string(msg, "@IDXATTR", strdup("uid")); if (ldb_add(*ldb, msg) != 0) { printf("Add of %s failed - %s\n", ldb_dn_linearize(*ldb, msg->dn), ldb_errstring(*ldb)); @@ -325,10 +325,10 @@ static void start_test_index(struct ldb_context **ldb) memset(msg, 0, sizeof(*msg)); msg->dn = ldb_dn_build_child(msg, "cn", "test", basedn); - ldb_msg_add_string(*ldb, msg, "cn", strdup("test")); - ldb_msg_add_string(*ldb, msg, "sn", strdup("test")); - ldb_msg_add_string(*ldb, msg, "uid", strdup("test")); - ldb_msg_add_string(*ldb, msg, "objectClass", strdup("OpenLDAPperson")); + ldb_msg_add_string(msg, "cn", strdup("test")); + ldb_msg_add_string(msg, "sn", strdup("test")); + ldb_msg_add_string(msg, "uid", strdup("test")); + ldb_msg_add_string(msg, "objectClass", strdup("OpenLDAPperson")); if (ldb_add(*ldb, msg) != 0) { printf("Add of %s failed - %s\n", ldb_dn_linearize(*ldb, msg->dn), ldb_errstring(*ldb)); diff --git a/source4/lib/ldb/tools/oLschema2ldif.c b/source4/lib/ldb/tools/oLschema2ldif.c index 4e1607f314..0fcd531987 100644 --- a/source4/lib/ldb/tools/oLschema2ldif.c +++ b/source4/lib/ldb/tools/oLschema2ldif.c @@ -123,7 +123,7 @@ static char *skip_spaces(char *string) { return (string + strspn(string, " \t\n")); } -static int add_multi_string(struct ldb_context *ldb, struct ldb_message *msg, const char *attr, char *values) +static int add_multi_string(struct ldb_message *msg, const char *attr, char *values) { char *c; char *s; @@ -133,7 +133,7 @@ static int add_multi_string(struct ldb_context *ldb, struct ldb_message *msg, co while (*c) { n = strcspn(c, " \t$"); s = talloc_strndup(msg, c, n); - if (ldb_msg_add_string(ldb, msg, attr, s) != 0) { + if (ldb_msg_add_string(msg, attr, s) != 0) { return -1; } c += n; @@ -143,8 +143,8 @@ static int add_multi_string(struct ldb_context *ldb, struct ldb_message *msg, co return 0; } -#define MSG_ADD_STRING(a, v) do { if (ldb_msg_add_string(ldb_ctx, msg, a, v) != 0) goto failed; } while(0) -#define MSG_ADD_M_STRING(a, v) do { if (add_multi_string(ldb_ctx, msg, a, v) != 0) goto failed; } while(0) +#define MSG_ADD_STRING(a, v) do { if (ldb_msg_add_string(msg, a, v) != 0) goto failed; } while(0) +#define MSG_ADD_M_STRING(a, v) do { if (add_multi_string(msg, a, v) != 0) goto failed; } while(0) static char *get_def_value(TALLOC_CTX *ctx, char **string) { @@ -373,7 +373,7 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, const char *entry) ctx = talloc_new(mem_ctx); msg = ldb_msg_new(ctx); - ldb_msg_add_string(ldb_ctx, msg, "objectClass", "top"); + ldb_msg_add_string(msg, "objectClass", "top"); c = talloc_strdup(ctx, entry); if (!c) return NULL; @@ -488,7 +488,7 @@ failed: return NULL; } -static const struct schema_conv process_file(FILE *in, FILE *out) +static struct schema_conv process_file(FILE *in, FILE *out) { TALLOC_CTX *ctx; struct schema_conv ret; -- cgit