r10762: r13368@SERNOX (orig r10759): tridge | 2005-10-06 08:57:09 +0200
authorStefan Metzmacher <metze@samba.org>
Thu, 6 Oct 2005 07:36:29 +0000 (07:36 +0000)
committerStefan Metzmacher <metze@samba.org>
Thu, 6 Oct 2005 07:36:29 +0000 (07:36 +0000)
 make modules easier to write by allowing modules to only implement the
 functions they care about, instead of all functions. This also makes
 it more likely that future changes to ldb will not break existing
 modules

 r13369@SERNOX (orig r10760):  metze | 2005-10-06 09:04:36 +0200
 remove only one star from the pointers, and not from the stars that
 come from the array nesting

 this fixes a compiler warning and but in the eventlog.h,
 where the idl uses nstring strings[num_strings]

 metze
 r13370@SERNOX (orig r10761):  metze | 2005-10-06 09:26:05 +0200
 we need to use a pointer to a nbt_name to fix compiler warnings, because we can
 only use a pointers to unknown types in proto.h

 metze

12 files changed:
samba4-winsrepl/source/dsdb/samdb/ldb_modules/objectguid.c
samba4-winsrepl/source/dsdb/samdb/ldb_modules/samldb.c
samba4-winsrepl/source/lib/ldb/common/ldb.c
samba4-winsrepl/source/lib/ldb/common/ldb_modules.c
samba4-winsrepl/source/lib/ldb/modules/ldb_map.c
samba4-winsrepl/source/lib/ldb/modules/rdn_name.c
samba4-winsrepl/source/lib/ldb/modules/schema.c
samba4-winsrepl/source/lib/ldb/modules/timestamps.c
samba4-winsrepl/source/libcli/nbt/nbtname.c
samba4-winsrepl/source/libcli/wrepl/winsrepl.c
samba4-winsrepl/source/pidl/lib/Parse/Pidl/Samba/Header.pm
samba4-winsrepl/source/pidl/lib/Parse/Pidl/Typelist.pm

index 9e0946b17c83e8d278b104da04c9e24a10fef59d..0a7fe3a42b876cfc24a23ac358bae80056dfb420 100644 (file)
@@ -112,60 +112,11 @@ static int objectguid_add_record(struct ldb_module *module, const struct ldb_mes
        return ret;
 }
 
-/* modify_record: change modifyTimestamp as well */
-static int objectguid_modify_record(struct ldb_module *module, const struct ldb_message *msg)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_modify_record\n");
-       return ldb_next_modify_record(module, msg);
-}
-
-static int objectguid_delete_record(struct ldb_module *module, const struct ldb_dn *dn)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_delete_record\n");
-       return ldb_next_delete_record(module, dn);
-}
-
-static int objectguid_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_rename_record\n");
-       return ldb_next_rename_record(module, olddn, newdn);
-}
-
-static int objectguid_start_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_start_trans\n");
-       return ldb_next_start_trans(module);
-}
-
-static int objectguid_end_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_end_trans\n");
-       return ldb_next_end_trans(module);
-}
-
-static int objectguid_del_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_del_trans\n");
-       return ldb_next_del_trans(module);
-}
-
-static int objectguid_destructor(void *module_ctx)
-{
-       /* struct ldb_module *ctx = module_ctx; */
-       /* put your clean-up functions here */
-       return 0;
-}
 
 static const struct ldb_module_ops objectguid_ops = {
        .name          = "objectguid",
        .search_bytree = objectguid_search_bytree,
-       .add_record    = objectguid_add_record,
-       .modify_record = objectguid_modify_record,
-       .delete_record = objectguid_delete_record,
-       .rename_record = objectguid_rename_record,
-       .start_transaction = objectguid_start_trans,
-       .end_transaction = objectguid_end_trans,
-       .del_transaction = objectguid_del_trans
+       .add_record    = objectguid_add_record
 };
 
 
@@ -187,7 +138,5 @@ struct ldb_module *objectguid_module_init(struct ldb_context *ldb, const char *o
        ctx->prev = ctx->next = NULL;
        ctx->ops = &objectguid_ops;
 
-       talloc_set_destructor (ctx, objectguid_destructor);
-
        return ctx;
 }
index 89c9daa924035b6376c4ca74eb698635d9f5d9ec..906a2299f7ebb500f4bd80dcc0cd86b73750217a 100644 (file)
@@ -567,24 +567,6 @@ static int samldb_rename_record(struct ldb_module *module, const struct ldb_dn *
        return ldb_next_rename_record(module, olddn, newdn);
 }
 
-static int samldb_start_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "samldb_start_trans\n");
-       return ldb_next_start_trans(module);
-}
-
-static int samldb_end_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "samldb_end_trans\n");
-       return ldb_next_end_trans(module);
-}
-
-static int samldb_del_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "samldb_del_trans\n");
-       return ldb_next_del_trans(module);
-}
-
 static int samldb_destructor(void *module_ctx)
 {
        /* struct ldb_module *ctx = module_ctx; */
@@ -598,10 +580,7 @@ static const struct ldb_module_ops samldb_ops = {
        .add_record    = samldb_add_record,
        .modify_record = samldb_modify_record,
        .delete_record = samldb_delete_record,
-       .rename_record = samldb_rename_record,
-       .start_transaction = samldb_start_trans,
-       .end_transaction = samldb_end_trans,
-       .del_transaction = samldb_del_trans
+       .rename_record = samldb_rename_record
 };
 
 
index 29ee323ad4cdd4a7d355b73069cc34c3f78853e6..725044d3f49d7e2dc93eb0ca26fc1f53f17ce2e7 100644 (file)
@@ -114,16 +114,25 @@ static void ldb_reset_err_string(struct ldb_context *ldb)
        }
 }
 
+#define FIRST_OP(ldb, op) do { \
+       module = ldb->modules; \
+       while (module && module->ops->op == NULL) module = module->next; \
+       if (module == NULL) return -1; \
+} while (0)
+
 /*
   start a transaction
 */
 int ldb_transaction_start(struct ldb_context *ldb)
 {
+       struct ldb_module *module;
+       FIRST_OP(ldb, start_transaction);
+       
        ldb->transaction_active++;
 
        ldb_reset_err_string(ldb);
 
-       return ldb->modules->ops->start_transaction(ldb->modules);
+       return module->ops->start_transaction(module);
 }
 
 /*
@@ -131,6 +140,9 @@ int ldb_transaction_start(struct ldb_context *ldb)
 */
 int ldb_transaction_commit(struct ldb_context *ldb)
 {
+       struct ldb_module *module;
+       FIRST_OP(ldb, end_transaction);
+
        if (ldb->transaction_active > 0) {
                ldb->transaction_active--;
        } else {
@@ -139,7 +151,7 @@ int ldb_transaction_commit(struct ldb_context *ldb)
 
        ldb_reset_err_string(ldb);
 
-       return ldb->modules->ops->end_transaction(ldb->modules);
+       return module->ops->end_transaction(module);
 }
 
 /*
@@ -147,6 +159,9 @@ int ldb_transaction_commit(struct ldb_context *ldb)
 */
 int ldb_transaction_cancel(struct ldb_context *ldb)
 {
+       struct ldb_module *module;
+       FIRST_OP(ldb, del_transaction);
+
        if (ldb->transaction_active > 0) {
                ldb->transaction_active--;
        } else {
@@ -155,7 +170,7 @@ int ldb_transaction_cancel(struct ldb_context *ldb)
 
        ldb_reset_err_string(ldb);
 
-       return ldb->modules->ops->del_transaction(ldb->modules);
+       return module->ops->del_transaction(module);
 }
 
 /*
@@ -201,9 +216,12 @@ int ldb_search_bytree(struct ldb_context *ldb,
                      struct ldb_parse_tree *tree,
                      const char * const *attrs, struct ldb_message ***res)
 {
+       struct ldb_module *module;
+       FIRST_OP(ldb, search_bytree);
+
        ldb_reset_err_string(ldb);
 
-       return ldb->modules->ops->search_bytree(ldb->modules, base, scope, tree, attrs, res);
+       return module->ops->search_bytree(module, base, scope, tree, attrs, res);
 }
 
 /*
@@ -213,8 +231,11 @@ int ldb_search_bytree(struct ldb_context *ldb,
 int ldb_add(struct ldb_context *ldb, 
            const struct ldb_message *message)
 {
+       struct ldb_module *module;
        int status;
 
+       FIRST_OP(ldb, add_record);
+
        ldb_reset_err_string(ldb);
 
        status = ldb_msg_sanity_check(message);
@@ -224,12 +245,12 @@ int ldb_add(struct ldb_context *ldb,
                status = ldb_transaction_start(ldb);
                if (status != LDB_SUCCESS) return status;
 
-               status = ldb->modules->ops->add_record(ldb->modules, message);
+               status = module->ops->add_record(module, message);
                if (status != LDB_SUCCESS) return ldb_transaction_cancel(ldb);
                return ldb_transaction_commit(ldb);
        }
 
-       return ldb->modules->ops->add_record(ldb->modules, message);
+       return module->ops->add_record(module, message);
 }
 
 /*
@@ -238,8 +259,11 @@ int ldb_add(struct ldb_context *ldb,
 int ldb_modify(struct ldb_context *ldb, 
               const struct ldb_message *message)
 {
+       struct ldb_module *module;
        int status;
 
+       FIRST_OP(ldb, modify_record);
+
        ldb_reset_err_string(ldb);
 
        status = ldb_msg_sanity_check(message);
@@ -249,12 +273,12 @@ int ldb_modify(struct ldb_context *ldb,
                status = ldb_transaction_start(ldb);
                if (status != LDB_SUCCESS) return status;
 
-               status = ldb->modules->ops->modify_record(ldb->modules, message);
+               status = module->ops->modify_record(module, message);
                if (status != LDB_SUCCESS) return ldb_transaction_cancel(ldb);
                return ldb_transaction_commit(ldb);
        }
 
-       return ldb->modules->ops->modify_record(ldb->modules, message);
+       return module->ops->modify_record(module, message);
 }
 
 
@@ -263,20 +287,23 @@ int ldb_modify(struct ldb_context *ldb,
 */
 int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn)
 {
+       struct ldb_module *module;
        int status;
 
+       FIRST_OP(ldb, delete_record);
+
        ldb_reset_err_string(ldb);
 
        if (! ldb->transaction_active) {
                status = ldb_transaction_start(ldb);
                if (status != LDB_SUCCESS) return status;
 
-               status = ldb->modules->ops->delete_record(ldb->modules, dn);
+               status = module->ops->delete_record(module, dn);
                if (status != LDB_SUCCESS) return ldb_transaction_cancel(ldb);
                return ldb_transaction_commit(ldb);
        }
 
-       return ldb->modules->ops->delete_record(ldb->modules, dn);
+       return module->ops->delete_record(module, dn);
 }
 
 /*
@@ -284,20 +311,23 @@ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn)
 */
 int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
 {
+       struct ldb_module *module;
        int status;
 
+       FIRST_OP(ldb, rename_record);
+
        ldb_reset_err_string(ldb);
 
        if (! ldb->transaction_active) {
                status = ldb_transaction_start(ldb);
                if (status != LDB_SUCCESS) return status;
 
-               status = ldb->modules->ops->rename_record(ldb->modules, olddn, newdn);
+               status = module->ops->rename_record(module, olddn, newdn);
                if (status != LDB_SUCCESS) return ldb_transaction_cancel(ldb);
                return ldb_transaction_commit(ldb);
        }
 
-       return ldb->modules->ops->rename_record(ldb->modules, olddn, newdn);
+       return module->ops->rename_record(module, olddn, newdn);
 }
 
 
index 955e46b91a2b6c6ea67577b4465890ac229b877b..b0ede9893b001e22142afe0d00ce3bacb2e7eb43 100644 (file)
@@ -212,6 +212,18 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
        return 0; 
 }
 
+/*
+  by using this we allow ldb modules to only implement the functions they care about,
+  which makes writing a module simpler, and makes it more likely to keep working
+  when ldb is extended
+*/
+#define FIND_OP(module, op) do { \
+       module = module->next; \
+       while (module && module->ops->op == NULL) module = module->next; \
+       if (module == NULL) return -1; \
+} while (0)
+
+
 /*
    helper functions to call the next module in chain
 */
@@ -221,10 +233,8 @@ int ldb_next_search_bytree(struct ldb_module *module,
                           struct ldb_parse_tree *tree,
                           const char * const *attrs, struct ldb_message ***res)
 {
-       if (!module->next) {
-               return -1;
-       }
-       return module->next->ops->search_bytree(module->next, base, scope, tree, attrs, res);
+       FIND_OP(module, search_bytree);
+       return module->ops->search_bytree(module, base, scope, tree, attrs, res);
 }
 
 int ldb_next_search(struct ldb_module *module, 
@@ -235,15 +245,13 @@ int ldb_next_search(struct ldb_module *module,
 {
        struct ldb_parse_tree *tree;
        int ret;
-       if (!module->next) {
-               return -1;
-       }
+       FIND_OP(module, search_bytree);
        tree = ldb_parse_tree(module, expression);
        if (tree == NULL) {
                ldb_set_errstring(module, talloc_strdup(module, "Unable to parse search expression"));
                return -1;
        }
-       ret = module->next->ops->search_bytree(module->next, base, scope, tree, attrs, res);
+       ret = module->ops->search_bytree(module, base, scope, tree, attrs, res);
        talloc_free(tree);
        return ret;
 }
@@ -251,58 +259,44 @@ int ldb_next_search(struct ldb_module *module,
 
 int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message)
 {
-       if (!module->next) {
-               return -1;
-       }
-       return module->next->ops->add_record(module->next, message);
+       FIND_OP(module, add_record);
+       return module->ops->add_record(module, message);
 }
 
 int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message)
 {
-       if (!module->next) {
-               return -1;
-       }
-       return module->next->ops->modify_record(module->next, message);
+       FIND_OP(module, modify_record);
+       return module->ops->modify_record(module, message);
 }
 
 int ldb_next_delete_record(struct ldb_module *module, const struct ldb_dn *dn)
 {
-       if (!module->next) {
-               return -1;
-       }
-       return module->next->ops->delete_record(module->next, dn);
+       FIND_OP(module, delete_record);
+       return module->ops->delete_record(module, dn);
 }
 
 int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
 {
-       if (!module->next) {
-               return -1;
-       }
-       return module->next->ops->rename_record(module->next, olddn, newdn);
+       FIND_OP(module, rename_record);
+       return module->ops->rename_record(module, olddn, newdn);
 }
 
 int ldb_next_start_trans(struct ldb_module *module)
 {
-       if (!module->next) {
-               return -1;
-       }
-       return module->next->ops->start_transaction(module->next);
+       FIND_OP(module, start_transaction);
+       return module->ops->start_transaction(module);
 }
 
 int ldb_next_end_trans(struct ldb_module *module)
 {
-       if (!module->next) {
-               return -1;
-       }
-       return module->next->ops->end_transaction(module->next);
+       FIND_OP(module, end_transaction);
+       return module->ops->end_transaction(module);
 }
 
 int ldb_next_del_trans(struct ldb_module *module)
 {
-       if (!module->next) {
-               return -1;
-       }
-       return module->next->ops->del_transaction(module->next);
+       FIND_OP(module, del_transaction);
+       return module->ops->del_transaction(module);
 }
 
 void ldb_set_errstring(struct ldb_module *module, char *err_string)
index 1da1ef661a1803de0fe9343409056a52bd25e758..246fc5709d9843bc949af17ca88b46532f4475f9 100644 (file)
@@ -1233,31 +1233,13 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
        return (mp_ret == -1 || fb_ret == -1)?-1:0;
 }
 
-static int map_start_trans(struct ldb_module *module)
-{
-       return ldb_next_start_trans(module);
-}
-
-static int map_end_trans(struct ldb_module *module)
-{
-       return ldb_next_end_trans(module);
-}
-
-static int map_del_trans(struct ldb_module *module)
-{
-       return ldb_next_del_trans(module);
-}
-
 static const struct ldb_module_ops map_ops = {
        .name              = "map",
        .search_bytree     = map_search_bytree,
        .add_record        = map_add,
        .modify_record     = map_modify,
        .delete_record     = map_delete,
-       .rename_record     = map_rename,
-       .start_transaction = map_start_trans,
-       .end_transaction   = map_end_trans,
-       .del_transaction   = map_del_trans
+       .rename_record     = map_rename
 };
 
 static char *map_find_url(struct ldb_context *ldb, const char *name)
index 0275952780c805cdf2d63c640a118d168044a708..40ff75744e3a7156a2f96c842a1e3cb5367ed4b2 100644 (file)
@@ -194,53 +194,18 @@ static int rdn_name_modify_record(struct ldb_module *module, const struct ldb_me
        return ret;
 }
 
-static int rdn_name_delete_record(struct ldb_module *module, const struct ldb_dn *dn)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_delete_record\n");
-       return ldb_next_delete_record(module, dn);
-}
-
 static int rdn_name_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
 {
        ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename_record\n");
        return ldb_next_rename_record(module, olddn, newdn);
 }
 
-static int rdn_start_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_start_trans\n");
-       return ldb_next_start_trans(module);
-}
-
-static int rdn_end_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_end_trans\n");
-       return ldb_next_end_trans(module);
-}
-
-static int rdn_del_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_del_trans\n");
-       return ldb_next_del_trans(module);
-}
-
-static int rdn_name_destructor(void *module_ctx)
-{
-       /* struct ldb_module *ctx = module_ctx; */
-       /* put your clean-up functions here */
-       return 0;
-}
-
 static const struct ldb_module_ops rdn_name_ops = {
        .name              = "rdn_name",
        .search_bytree     = rdn_name_search_bytree,
        .add_record        = rdn_name_add_record,
        .modify_record     = rdn_name_modify_record,
-       .delete_record     = rdn_name_delete_record,
-       .rename_record     = rdn_name_rename_record,
-       .start_transaction = rdn_start_trans,
-       .end_transaction   = rdn_end_trans,
-       .del_transaction   = rdn_del_trans
+       .rename_record     = rdn_name_rename_record
 };
 
 
@@ -262,7 +227,5 @@ struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *opt
        ctx->prev = ctx->next = NULL;
        ctx->ops = &rdn_name_ops;
 
-       talloc_set_destructor (ctx, rdn_name_destructor);
-
        return ctx;
 }
index 7c1753b215742ba9716ca6d2c2517ece92f03d6b..0cae1104870215079a1da90c2ed508e5451332a0 100644 (file)
@@ -509,35 +509,13 @@ static int schema_rename_record(struct ldb_module *module, const struct ldb_dn *
        return ldb_next_rename_record(module, olddn, newdn);
 }
 
-static int schema_start_trans(struct ldb_module *module) {
-       return ldb_next_start_trans(module);
-}
-
-static int schema_end_trans(struct ldb_module *module) {
-       return ldb_next_end_trans(module);
-}
-
-static int schema_del_trans(struct ldb_module *module) {
-       return ldb_next_del_trans(module);
-}
-
-static int schema_destructor(void *module_ctx)
-{
-/*     struct ldb_module *ctx = module_ctx; */
-       /* put your clean-up functions here */
-       return 0;
-}
-
 static const struct ldb_module_ops schema_ops = {
        .name              = "schema",
        .search_bytree     = schema_search_bytree,
        .add_record        = schema_add_record,
        .modify_record     = schema_modify_record,
        .delete_record     = schema_delete_record,
-       .rename_record     = schema_rename_record,
-       .start_transaction = schema_start_trans,
-       .end_transaction   = schema_end_trans,
-       .del_transaction   = schema_del_trans
+       .rename_record     = schema_rename_record
 };
 
 #ifdef HAVE_DLOPEN_DISABLED
@@ -558,7 +536,5 @@ struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *optio
        ctx->prev = ctx->next = NULL;
        ctx->ops = &schema_ops;
 
-       talloc_set_destructor (ctx, schema_destructor);
-
        return ctx;
 }
index 5a1e54486a1307da7d06582390f0bb28885194f4..13e9c2ccc46f1ae59b2430418024f09fc6325f3c 100644 (file)
@@ -191,53 +191,12 @@ static int timestamps_modify_record(struct ldb_module *module, const struct ldb_
        return ret;
 }
 
-static int timestamps_delete_record(struct ldb_module *module, const struct ldb_dn *dn)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_delete_record\n");
-       return ldb_next_delete_record(module, dn);
-}
-
-static int timestamps_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_rename_record\n");
-       return ldb_next_rename_record(module, olddn, newdn);
-}
-
-static int timestamps_start_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_start_trans\n");
-       return ldb_next_start_trans(module);
-}
-
-static int timestamps_end_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_end_trans\n");
-       return ldb_next_end_trans(module);
-}
-
-static int timestamps_del_trans(struct ldb_module *module)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_del_trans\n");
-       return ldb_next_del_trans(module);
-}
-
-static int timestamps_destructor(void *module_ctx)
-{
-       /* struct ldb_module *ctx = module_ctx; */
-       /* put your clean-up functions here */
-       return 0;
-}
 
 static const struct ldb_module_ops timestamps_ops = {
        .name              = "timestamps",
        .search_bytree     = timestamps_search_bytree,
        .add_record        = timestamps_add_record,
-       .modify_record     = timestamps_modify_record,
-       .delete_record     = timestamps_delete_record,
-       .rename_record     = timestamps_rename_record,
-       .start_transaction = timestamps_start_trans,
-       .end_transaction   = timestamps_end_trans,
-       .del_transaction   = timestamps_del_trans
+       .modify_record     = timestamps_modify_record
 };
 
 
@@ -259,7 +218,5 @@ struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *o
        ctx->prev = ctx->next = NULL;
        ctx->ops = &timestamps_ops;
 
-       talloc_set_destructor (ctx, timestamps_destructor);
-
        return ctx;
 }
index 86309b7f6bacbbcf7f77d4e23784d67e34a99c9b..622d03c1f4a910873d90422cc63f498a36dc2f87 100644 (file)
@@ -474,8 +474,9 @@ char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name)
 /*
   pull a nbt name, WINS Replication uses another on wire format for nbt name
 */
-NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r)
+NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, const struct nbt_name **_r)
 {
+       struct nbt_name *r;
        uint8_t *namebuf;
        uint32_t namebuf_len;
 
@@ -491,6 +492,8 @@ NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt
        NDR_PULL_ALLOC_N(ndr, namebuf, namebuf_len);
        NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len));
 
+       NDR_PULL_ALLOC(ndr, r); 
+
        /* oh wow, what a nasty bug in windows ... */
        if (namebuf[0] == 0x1b && namebuf_len >= 16) {
                namebuf[0] = namebuf[15];
@@ -500,12 +503,13 @@ NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt
        if (namebuf_len < 17) {
                r->type = 0x00;
 
-               r->name = talloc_strndup(ndr->current_mem_ctx, (char *)namebuf, namebuf_len);
+               r->name = talloc_strndup(r, (char *)namebuf, namebuf_len);
                if (!r->name) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory");
 
                r->scope= NULL;
 
                talloc_free(namebuf);
+               *_r = r;
                return NT_STATUS_OK;
        }
 
@@ -513,49 +517,52 @@ NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt
 
        namebuf[15] = '\0';
        trim_string((char *)namebuf, NULL, " ");
-       r->name = talloc_strdup(ndr->current_mem_ctx, (char *)namebuf);
+       r->name = talloc_strdup(r, (char *)namebuf);
        if (!r->name) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory");
 
        if (namebuf_len > 18) {
-               r->scope = talloc_strndup(ndr->current_mem_ctx, (char *)(namebuf+17), namebuf_len-17);
+               r->scope = talloc_strndup(r, (char *)(namebuf+17), namebuf_len-17);
                if (!r->scope) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory");
        } else {
                r->scope = NULL;
        }
 
        talloc_free(namebuf);
+       *_r = r;
        return NT_STATUS_OK;
 }
 
 /*
   push a nbt name, WINS Replication uses another on wire format for nbt name
 */
-NTSTATUS ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name r)
+NTSTATUS ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r)
 {
        uint8_t *namebuf;
        uint32_t namebuf_len;
        uint32_t name_len;
        uint32_t scope_len = 0;
 
+       if (r == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;
+
        if (!(ndr_flags & NDR_SCALARS)) {
                return NT_STATUS_OK;
        }
 
-       name_len = strlen(r.name);
+       name_len = strlen(r->name);
        if (name_len > 15) {
                return NT_STATUS_INVALID_PARAMETER_MIX;
        }
 
-       if (r.scope) {
-               scope_len = strlen(r.scope);
+       if (r->scope) {
+               scope_len = strlen(r->scope);
        }
        if (scope_len > 238) {
                return NT_STATUS_INVALID_PARAMETER_MIX;
        }
 
        namebuf = (uint8_t *)talloc_asprintf(ndr, "%-15s%c%s",
-                                            r.name, 'X',
-                                            (r.scope?r.scope:""));
+                                            r->name, 'X',
+                                            (r->scope?r->scope:""));
        if (!namebuf) return ndr_push_error(ndr, NDR_ERR_ALLOC, "out of memory");
 
        namebuf_len = strlen((char *)namebuf) + 1;
@@ -564,10 +571,10 @@ NTSTATUS ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const stru
         * we need to set the type here, and use a place-holder in the talloc_asprintf()
         * as the type can be 0x00, and then the namebuf_len = strlen(namebuf); would give wrong results
         */
-       namebuf[15] = r.type;
+       namebuf[15] = r->type;
 
        /* oh wow, what a nasty bug in windows ... */
-       if (r.type == 0x1b) {
+       if (r->type == 0x1b) {
                namebuf[15] = namebuf[0];
                namebuf[0] = 0x1b;
        }
@@ -580,9 +587,9 @@ NTSTATUS ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const stru
        return NT_STATUS_OK;
 }
 
-void ndr_print_wrepl_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name r)
+void ndr_print_wrepl_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r)
 {
-       char *s = nbt_name_string(ndr, &r);
+       char *s = nbt_name_string(ndr, r);
        ndr_print_string(ndr, name, s);
        talloc_free(s);
 }
index aba3fc817e27f239f2e1da1f4aa46d2928f11bef..297dccbf388c6e27574443fa88d923544fee4415 100644 (file)
@@ -745,9 +745,8 @@ NTSTATUS wrepl_pull_names_recv(struct wrepl_request *req,
                struct wrepl_wins_name *wname = &packet->message.replication.info.reply.names[i];
                struct wrepl_name *name = &io->out.names[i];
 
-               name->name      = wname->name;
-               talloc_steal(io->out.names, wname->name.name);
-               talloc_steal(io->out.names, wname->name.scope);
+               name->name      = *wname->name;
+               talloc_steal(io->out.names, wname->name);
                name->type      = WREPL_NAME_TYPE(wname->flags);
                name->state     = WREPL_NAME_STATE(wname->flags);
                name->node      = WREPL_NAME_NODE(wname->flags);
index ed8952e746665dc60349b31a7066dba6bbbb18fe..f235a96cb8e7ff8af1f3461767a467ad05c1a05a 100644 (file)
@@ -60,13 +60,15 @@ sub HeaderElement($)
        HeaderType($element, $element->{TYPE}, "");
        pidl " ";
        my $numstar = $element->{POINTERS};
+       if ($numstar >= 1) {
+               $numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE});
+       }
        foreach (@{$element->{ARRAY_LEN}})
        {
                next if is_constant($_) and 
                        not has_property($element, "charset");
                $numstar++;
        }
-       $numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE});
        pidl "*" foreach (1..$numstar);
        pidl $element->{NAME};
        foreach (@{$element->{ARRAY_LEN}}) {
index 111ce9ba11eb2b1ada88e124e05f17b9cabaf1b0..67e348c5fe4179dd1f5315b69159cf906c6d7712 100644 (file)
@@ -129,8 +129,8 @@ my $scalars = {
                                IS_REFERENCE    => 1,
                        },
        "wrepl_nbt_name"=> {
-                               C_TYPE          => "struct nbt_name",
-                               IS_REFERENCE    => 0,
+                               C_TYPE          => "struct nbt_name *",
+                               IS_REFERENCE    => 1,
                        },
        "ipv4address"   => {
                                C_TYPE          => "const char *",