r17317: - add a composite_create() function that allocates and initialize
authorStefan Metzmacher <metze@samba.org>
Sun, 30 Jul 2006 16:48:41 +0000 (16:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:15:10 +0000 (14:15 -0500)
  the composite_context structue, we should try to convert all code
  to use this because there're a lot of places where the we have
  bugs with this task...
- add a composite_continue_smb2() helper

We should try to hide the internals of the composite code from the users
to avoid errors (and I found a lot of them... and will fix then step by step)

metze

source/libcli/composite/composite.c
source/libcli/composite/composite.h

index 9a745e3013e2579f0f69a0d46fd749819610c747..aea25f183efee0a41aca48db2959f3b21f732f53 100644 (file)
 #include "includes.h"
 #include "lib/events/events.h"
 #include "libcli/raw/libcliraw.h"
+#include "libcli/smb2/smb2.h"
 #include "libcli/composite/composite.h"
 #include "lib/messaging/irpc.h"
 #include "librpc/rpc/dcerpc.h"
 #include "libcli/nbt/libnbt.h"
 
+/*
+ create a new composite_context structure
+ and initialize it
+*/
+_PUBLIC_ struct composite_context *composite_create(TALLOC_CTX *mem_ctx,
+                                                   struct event_context *ev)
+{
+       struct composite_context *c;
+
+       c = talloc_zero(mem_ctx, struct composite_context);
+       if (!c) return NULL;
+       c->state = COMPOSITE_STATE_IN_PROGRESS;
+       c->event_ctx = ev;
+
+       return c;
+}
+
 /*
   block until a composite function has completed, then return the status
 */
@@ -156,6 +174,16 @@ _PUBLIC_ void composite_continue_smb(struct composite_context *ctx,
        new_req->async.private = private_data;
 }
 
+_PUBLIC_ void composite_continue_smb2(struct composite_context *ctx,
+                                     struct smb2_request *new_req,
+                                     void (*continuation)(struct smb2_request *),
+                                     void *private_data)
+{
+       if (composite_nomem(new_req, ctx)) return;
+       new_req->async.fn = continuation;
+       new_req->async.private = private_data;
+}
+
 _PUBLIC_ void composite_continue_nbt(struct composite_context *ctx,
                                     struct nbt_name_request *new_req,
                                     void (*continuation)(struct nbt_name_request *),
index dc04f5a8833b47544331816cad6daf9dbd699a7f..d8873684fc0d77f919559bf3fdc411eaf92f0cfe 100644 (file)
@@ -63,6 +63,7 @@ struct composite_context {
 
 struct irpc_request;
 struct smbcli_request;
+struct smb2_request;
 struct rpc_request;
 struct nbt_name_request;