- for (event_ptr = event_queue.first_event;
- event_ptr != NULL;
- event_ptr = event_ptr->next_event)
- {
- /* Call the handler for the event. */
+ /* Now call the procedure associated with the event. */
+ if ((*proc) (fd))
+ return -1;
+ return 1;
+ }
+
+ /* This is the case if there are no event on the event queue. */
+ return 0;
+}
+
+/* Append PROC to the callback list.
+ The result is the "id" of the callback that can be passed back to
+ delete_callback_event. */
+
+int
+append_callback_event (callback_handler_func *proc, gdb_client_data data)
+{
+ struct callback_event *event_ptr = XNEW (struct callback_event);
+
+ event_ptr->id = callback_list.num_callbacks++;
+ event_ptr->proc = proc;
+ event_ptr->data = data;
+ event_ptr->next = NULL;
+ if (callback_list.first == NULL)
+ callback_list.first = event_ptr;
+ if (callback_list.last != NULL)
+ callback_list.last->next = event_ptr;
+ callback_list.last = event_ptr;
+ return event_ptr->id;
+}