summaryrefslogtreecommitdiff
path: root/lib/tevent/tevent_req.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2009-02-28 15:44:30 -0500
committerSimo Sorce <idra@samba.org>2009-03-02 11:02:09 -0500
commit67d41d0fc7567cf141b12e866dd227d393e33551 (patch)
tree117ee0ddd513e0d2008c02d9ff5ead1dd7818ccc /lib/tevent/tevent_req.c
parent04a2b455a0385fc3aa23850d4841ab3495efc3e6 (diff)
downloadsamba-67d41d0fc7567cf141b12e866dd227d393e33551.tar.gz
samba-67d41d0fc7567cf141b12e866dd227d393e33551.tar.bz2
samba-67d41d0fc7567cf141b12e866dd227d393e33551.zip
Make struct tevent_req opaque
Move struct tevent_req in tevent_internal, and ad getters and setters for private data and the callback function. This patch also renames 'private_state' into 'data'. What is held in this pointer is in fact data and not a state like enum tevent_req_state. Calling it 'state' is confusing. The functions addedd are: tevent_req_set_callback() - sets req->async.fn and req->async.private_data tevent_req_set_print_fn() - sets req->private_print tevent_req_callback_data() - gets req->async.private_data tevent_req_data() - gets rea->data This way it is much simpler to keep API/ABI compatibility in the future.
Diffstat (limited to 'lib/tevent/tevent_req.c')
-rw-r--r--lib/tevent/tevent_req.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/lib/tevent/tevent_req.c b/lib/tevent/tevent_req.c
index e243c7de5d..9b3e00ec8f 100644
--- a/lib/tevent/tevent_req.c
+++ b/lib/tevent/tevent_req.c
@@ -47,8 +47,8 @@ char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx)
req->internal.state,
(unsigned long long)req->internal.error,
(unsigned long long)req->internal.error,
- talloc_get_name(req->private_state),
- req->private_state,
+ talloc_get_name(req->data),
+ req->data,
req->internal.timer
);
}
@@ -81,14 +81,14 @@ char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
*/
struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
- void *pstate,
- size_t state_size,
+ void *pdata,
+ size_t data_size,
const char *type,
const char *location)
{
struct tevent_req *req;
- void **ppstate = (void **)pstate;
- void *state;
+ void **ppdata = (void **)pdata;
+ void *data;
req = talloc_zero(mem_ctx, struct tevent_req);
if (req == NULL) {
@@ -98,16 +98,16 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
req->internal.location = location;
req->internal.state = TEVENT_REQ_IN_PROGRESS;
- state = talloc_size(req, state_size);
- if (state == NULL) {
+ data = talloc_size(req, data_size);
+ if (data == NULL) {
talloc_free(req);
return NULL;
}
- talloc_set_name_const(state, type);
+ talloc_set_name_const(data, type);
- req->private_state = state;
+ req->data = data;
- *ppstate = state;
+ *ppdata = data;
return req;
}
@@ -314,3 +314,23 @@ bool tevent_req_set_endtime(struct tevent_req *req,
return true;
}
+void tevent_req_set_callback(struct tevent_req *req, tevent_req_fn fn, void *pvt)
+{
+ req->async.fn = fn;
+ req->async.private_data = pvt;
+}
+
+void *_tevent_req_callback_data(struct tevent_req *req)
+{
+ return req->async.private_data;
+}
+
+void *_tevent_req_data(struct tevent_req *req)
+{
+ return req->data;
+}
+
+void tevent_req_set_print_fn(struct tevent_req *req, tevent_req_print_fn fn)
+{
+ req->private_print = fn;
+}