source: branches/samba-3.5.x/source4/libcli/composite/composite.h

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 3.8 KB
Line 
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#ifndef __COMPOSITE_H__
23#define __COMPOSITE_H__
24
25#include "libcli/raw/interfaces.h"
26
27struct tevent_context;
28
29/*
30 this defines the structures associated with "composite"
31 requests. Composite requests are libcli requests that are internally
32 implemented as multiple async calls, but can be treated as a
33 single call via these composite calls. The composite calls are
34 particularly designed to be used in async applications.
35 you can also stack multiple level of composite call
36*/
37
38/*
39 a composite call moves between the following 3 states.
40*/
41enum composite_state { COMPOSITE_STATE_INIT, /* we are creating the request */
42 COMPOSITE_STATE_IN_PROGRESS, /* the request is in the outgoing socket Q */
43 COMPOSITE_STATE_DONE, /* the request is received by the caller finished */
44 COMPOSITE_STATE_ERROR }; /* a packet or transport level error has occurred */
45
46/* the context of one "composite" call */
47struct composite_context {
48 /* the external state - will be queried by the caller */
49 enum composite_state state;
50
51 /* a private pointer for use by the composite function
52 implementation */
53 void *private_data;
54
55 /* status code when finished */
56 NTSTATUS status;
57
58 /* the event context we are using */
59 struct tevent_context *event_ctx;
60
61 /* information on what to do on completion */
62 struct {
63 void (*fn)(struct composite_context *);
64 void *private_data;
65 } async;
66
67 bool used_wait;
68};
69
70struct irpc_request;
71struct smbcli_request;
72struct smb2_request;
73struct rpc_request;
74struct nbt_name_request;
75
76struct composite_context *composite_create(TALLOC_CTX *mem_ctx, struct tevent_context *ev);
77bool composite_nomem(const void *p, struct composite_context *ctx);
78void composite_continue(struct composite_context *ctx,
79 struct composite_context *new_ctx,
80 void (*continuation)(struct composite_context *),
81 void *private_data);
82void composite_continue_rpc(struct composite_context *ctx,
83 struct rpc_request *new_req,
84 void (*continuation)(struct rpc_request *),
85 void *private_data);
86void composite_continue_irpc(struct composite_context *ctx,
87 struct irpc_request *new_req,
88 void (*continuation)(struct irpc_request *),
89 void *private_data);
90void composite_continue_smb(struct composite_context *ctx,
91 struct smbcli_request *new_req,
92 void (*continuation)(struct smbcli_request *),
93 void *private_data);
94void composite_continue_smb2(struct composite_context *ctx,
95 struct smb2_request *new_req,
96 void (*continuation)(struct smb2_request *),
97 void *private_data);
98void composite_continue_nbt(struct composite_context *ctx,
99 struct nbt_name_request *new_req,
100 void (*continuation)(struct nbt_name_request *),
101 void *private_data);
102bool composite_is_ok(struct composite_context *ctx);
103void composite_done(struct composite_context *ctx);
104void composite_error(struct composite_context *ctx, NTSTATUS status);
105NTSTATUS composite_wait(struct composite_context *c);
106NTSTATUS composite_wait_free(struct composite_context *c);
107
108
109#endif /* __COMPOSITE_H__ */
Note: See TracBrowser for help on using the repository browser.