From 8dbb80cfe9e80a5b70ada4e0b58c97a28a9fc7f7 Mon Sep 17 00:00:00 2001
From: Olivier Brunel <jjk@jjacky.com>
Date: Sun, 15 Jun 2014 19:43:07 +0200
Subject: events: Make alpm_event_t an union of all event-specific struct

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
---
 lib/libalpm/alpm.h | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

(limited to 'lib/libalpm')

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index c81b1f2d..db1e0cd1 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -443,15 +443,10 @@ typedef enum _alpm_event_type_t {
 	ALPM_EVENT_PACORIG_CREATED
 } alpm_event_type_t;
 
-/** Events.
- * This is a generic struct this is passed to the callback, that allows the
- * frontend to know which type of event was triggered. It is then possible to
- * typecast the pointer to the right structure, in order to access
- * event-specific data. */
-typedef struct _alpm_event_t {
+typedef struct _alpm_event_any_t {
 	/** Type of event. */
 	alpm_event_type_t type;
-} alpm_event_t;
+} alpm_event_any_t;
 
 typedef enum _alpm_package_operation_t {
 	/** Package (to be) installed. (No oldpkg) */
@@ -563,6 +558,26 @@ typedef struct _alpm_event_pacorig_created_t {
 	const char *file;
 } alpm_event_pacorig_created_t;
 
+/** Events.
+ * This is an union passed to the callback, that allows the frontend to know
+ * which type of event was triggered (via type). It is then possible to
+ * typecast the pointer to the right structure, or use the union field, in order
+ * to access event-specific data. */
+typedef union _alpm_event_t {
+	alpm_event_type_t type;
+	alpm_event_any_t any;
+	alpm_event_package_operation_t package_operation;
+	alpm_event_optdep_removal_t optdep_removal;
+	alpm_event_delta_patch_t delta_patch;
+	alpm_event_scriptlet_info_t scriptlet_info;
+	alpm_event_database_missing_t database_missing;
+	alpm_event_log_t log;
+	alpm_event_pkgdownload_t pkgdownload;
+	alpm_event_pacnew_created_t pacnew_created;
+	alpm_event_pacsave_created_t pacsave_created;
+	alpm_event_pacorig_created_t pacorig_created;
+} alpm_event_t;
+
 /** Event callback. */
 typedef void (*alpm_cb_event)(alpm_event_t *);
 
-- 
cgit v1.2.3-70-g09d2