aboutsummaryrefslogtreecommitdiff
path: root/include/libssh/callbacks.h
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2015-07-21 15:21:12 +0200
committerAndreas Schneider <asn@cryptomilk.org>2016-05-02 16:56:05 +0200
commit5dddebd3382f37e8ebdb881b315a1325b30907d2 (patch)
tree6cf37080a45d3097256e4be22709193703f7869c /include/libssh/callbacks.h
parent80d88dd3d904948ceabe1e8e53eef2fad72b08ce (diff)
downloadlibssh-5dddebd3382f37e8ebdb881b315a1325b30907d2.tar.gz
libssh-5dddebd3382f37e8ebdb881b315a1325b30907d2.tar.xz
libssh-5dddebd3382f37e8ebdb881b315a1325b30907d2.zip
callbacks: Add macro for callbacks execute list
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'include/libssh/callbacks.h')
-rw-r--r--include/libssh/callbacks.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/libssh/callbacks.h b/include/libssh/callbacks.h
index 6b07b087..9a6f2418 100644
--- a/include/libssh/callbacks.h
+++ b/include/libssh/callbacks.h
@@ -435,6 +435,34 @@ typedef struct ssh_socket_callbacks_struct *ssh_socket_callbacks;
((p)-> c != NULL) \
)
+/**
+ * @internal
+ *
+ * @brief Iterate through a list of callback structures
+ *
+ * This tests for their validity and executes them. The userdata argument is
+ * automatically passed through.
+ *
+ * @param list list of callbacks
+ *
+ * @param cbtype type of the callback
+ *
+ * @param c callback name
+ *
+ * @param va_args parameters to be passed
+ */
+#define ssh_callbacks_execute_list(list, cbtype, c, ...) \
+ do { \
+ struct ssh_iterator *i = ssh_list_get_iterator(list); \
+ cbtype cb; \
+ while (i != NULL){ \
+ cb = ssh_iterator_value(cbtype, i); \
+ if (ssh_callbacks_exists(cb, c)) \
+ cb-> c (__VA_ARGS__, cb->userdata); \
+ i = i->next; \
+ } \
+ } while(0)
+
/** @brief Prototype for a packet callback, to be called when a new packet arrives
* @param session The current session of the packet
* @param type packet type (see ssh2.h)