r23792: convert Samba4 to GPLv3
[tprouty/samba.git] / source4 / libcli / composite / composite.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    composite request interfaces
5
6    Copyright (C) Andrew Tridgell 2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "libcli/raw/interfaces.h"
23
24 /*
25   this defines the structures associated with "composite"
26   requests. Composite requests are libcli requests that are internally
27   implemented as multiple async calls, but can be treated as a
28   single call via these composite calls. The composite calls are
29   particularly designed to be used in async applications.
30   you can also stack multiple level of composite call
31 */
32
33 /*
34   a composite call moves between the following 3 states.
35 */
36 enum composite_state { COMPOSITE_STATE_INIT,         /* we are creating the request */
37                        COMPOSITE_STATE_IN_PROGRESS,  /* the request is in the outgoing socket Q */
38                        COMPOSITE_STATE_DONE,         /* the request is received by the caller finished */
39                        COMPOSITE_STATE_ERROR };      /* a packet or transport level error has occurred */
40
41 /* the context of one "composite" call */
42 struct composite_context {
43         /* the external state - will be queried by the caller */
44         enum composite_state state;
45
46         /* a private pointer for use by the composite function
47            implementation */
48         void *private_data;
49
50         /* status code when finished */
51         NTSTATUS status;
52
53         /* the event context we are using */
54         struct event_context *event_ctx;
55
56         /* information on what to do on completion */
57         struct {
58                 void (*fn)(struct composite_context *);
59                 void *private_data;
60         } async;
61
62         BOOL used_wait;
63 };
64
65 struct irpc_request;
66 struct smbcli_request;
67 struct smb2_request;
68 struct rpc_request;
69 struct nbt_name_request;
70
71 #include "libcli/composite/proto.h"