- case UDEV_ACTION_REMOVE:
- rc = handle_remove_event(handler, event);
- break;
+ /* remove device from handler device array */
+ device_handler_remove(handler, device);
+
+ talloc_free(device);
+ return 0;
+}
+
+typedef int (*event_handler)(struct device_handler *, struct event *);
+
+static event_handler handlers[EVENT_TYPE_MAX][EVENT_ACTION_MAX] = {
+ [EVENT_TYPE_UDEV] = {
+ [EVENT_ACTION_ADD] = handle_add_udev_event,
+ [EVENT_ACTION_REMOVE] = handle_remove_udev_event,
+ },
+ [EVENT_TYPE_USER] = {
+ [EVENT_ACTION_ADD] = handle_add_user_event,
+ [EVENT_ACTION_REMOVE] = handle_remove_user_event,
+ }
+};
+
+int device_handler_event(struct device_handler *handler,
+ struct event *event)
+{
+ if (event->type >= EVENT_TYPE_MAX ||
+ event->action >= EVENT_ACTION_MAX ||
+ !handlers[event->type][event->action]) {
+ pb_log("%s unknown type/action: %d/%d\n", __func__,
+ event->type, event->action);
+ return 0;