[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha6-1215-ge2f37ec

Stefan Metzmacher metze at samba.org
Wed Feb 25 13:39:40 GMT 2009


The branch, master has been updated
       via  e2f37ec106fb51ec894e0d6160949545e80dfe69 (commit)
      from  01d1aaf63e8170936139a01814211f6567c4b125 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e2f37ec106fb51ec894e0d6160949545e80dfe69
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 25 14:29:31 2009 +0100

    tevent: add private_print function feature to tevent_req
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 lib/tevent/tevent.h     |   11 +++++++++++
 lib/tevent/tevent_req.c |   27 ++++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index b361122..185a8fa 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -212,6 +212,15 @@ struct tevent_req {
 	void *private_state;
 
 	/**
+	 * @brief A function to overwrite the default print function
+	 *
+	 * The implementation doing the work may want to imeplement a
+	 * custom function to print the text representation of the async
+	 * request.
+	 */
+	char *(*private_print)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+
+	/**
 	 * @brief Internal state of the request
 	 *
 	 * Callers should only access this via functions and never directly.
@@ -267,6 +276,8 @@ struct tevent_req {
 	} internal;
 };
 
+char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+
 char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req);
 
 struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
diff --git a/lib/tevent/tevent_req.c b/lib/tevent/tevent_req.c
index c17587b..e243c7d 100644
--- a/lib/tevent/tevent_req.c
+++ b/lib/tevent/tevent_req.c
@@ -28,14 +28,17 @@
 #include "tevent_util.h"
 
 /**
- * @brief Print an tevent_req structure in debug messages
- * @param[in] mem_ctx	The memory context for the result
+ * @brief The default print function for creating debug messages
  * @param[in] req	The request to be printed
+ * @param[in] mem_ctx	The memory context for the result
  * @retval		Text representation of req
  *
+ * The function should not be used by users of the asynx API,
+ * but custom print function can use it and append custom text
+ * to the string.
  */
 
-char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
+char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx)
 {
 	return talloc_asprintf(mem_ctx,
 			       "tevent_req[%p/%s]: state[%d] error[%lld (0x%llX)] "
@@ -51,6 +54,24 @@ char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
 }
 
 /**
+ * @brief Print an tevent_req structure in debug messages
+ * @param[in] mem_ctx	The memory context for the result
+ * @param[in] req	The request to be printed
+ * @retval		Text representation of req
+ *
+ * This function should be used by callers of the async API
+ */
+
+char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
+{
+	if (!req->private_print) {
+		return tevent_req_default_print(req, mem_ctx);
+	}
+
+	return req->private_print(req, mem_ctx);
+}
+
+/**
  * @brief Create an async request
  * @param[in] mem_ctx	The memory context for the result
  * @param[in] ev	The event context this async request will be driven by


-- 
Samba Shared Repository


More information about the samba-cvs mailing list