D-Bus: dbus-watch.c Source File

D-Bus 1.10.22

dbus-watch.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-watch.c DBusWatch implementation
3 *
4 * Copyright (C) 2002, 2003 Red Hat Inc.
5 *
6 * Licensed under the Academic Free License version 2.1
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 */
23
24 #include <config.h>
25 #include "dbus-internals.h"
26 #include "dbus-watch.h"
27 #include "dbus-list.h"
28
40 struct DBusWatch
41 {
42 int refcount;
43 DBusPollable fd;
44 unsigned int flags;
46 DBusWatchHandler handler;
47 void *handler_data;
48 DBusFreeFunction free_handler_data_function;
50 void *data;
51 DBusFreeFunction free_data_function;
52 unsigned int enabled : 1;
53 unsigned int oom_last_time : 1;
54 };
55
56 dbus_bool_t
57 _dbus_watch_get_enabled (DBusWatch *watch)
58 {
59 return watch->enabled;
60 }
61
62 dbus_bool_t
63 _dbus_watch_get_oom_last_time (DBusWatch *watch)
64 {
65 return watch->oom_last_time;
66 }
67
68 void
69 _dbus_watch_set_oom_last_time (DBusWatch *watch,
70 dbus_bool_t oom)
71 {
72 watch->oom_last_time = oom;
73 }
74
87 DBusWatch*
88 _dbus_watch_new (DBusPollable fd,
89 unsigned int flags,
90 dbus_bool_t enabled,
91 DBusWatchHandler handler,
92 void *data,
93 DBusFreeFunction free_data_function)
94 {
95 DBusWatch *watch;
96
97 #define VALID_WATCH_FLAGS (DBUS_WATCH_WRITABLE | DBUS_WATCH_READABLE)
98
99 _dbus_assert ((flags & VALID_WATCH_FLAGS) == flags);
100
101 watch = dbus_new0 (DBusWatch, 1);
102 if (watch == NULL)
103 return NULL;
104
105 watch->refcount = 1;
106 watch->fd = fd;
107 watch->flags = flags;
108 watch->enabled = enabled;
109
110 watch->handler = handler;
111 watch->handler_data = data;
112 watch->free_handler_data_function = free_data_function;
113
114 return watch;
115 }
116
123 DBusWatch *
124 _dbus_watch_ref (DBusWatch *watch)
125 {
126 watch->refcount += 1;
127
128 return watch;
129 }
130
137 void
138 _dbus_watch_unref (DBusWatch *watch)
139 {
140 _dbus_assert (watch != NULL);
141 _dbus_assert (watch->refcount > 0);
142
143 watch->refcount -= 1;
144 if (watch->refcount == 0)
145 {
146 if (_dbus_pollable_is_valid (watch->fd))
147 _dbus_warn ("this watch should have been invalidated");
148
149 dbus_watch_set_data (watch, NULL, NULL); /* call free_data_function */
150
151 if (watch->free_handler_data_function)
152 (* watch->free_handler_data_function) (watch->handler_data);
153
154 dbus_free (watch);
155 }
156 }
157
168 void
169 _dbus_watch_invalidate (DBusWatch *watch)
170 {
171 _dbus_pollable_invalidate (&watch->fd);
172 watch->flags = 0;
173 }
174
184 void
185 _dbus_watch_sanitize_condition (DBusWatch *watch,
186 unsigned int *condition)
187 {
188 if (!(watch->flags & DBUS_WATCH_READABLE))
189 *condition &= ~DBUS_WATCH_READABLE;
190 if (!(watch->flags & DBUS_WATCH_WRITABLE))
191 *condition &= ~DBUS_WATCH_WRITABLE;
192 }
193
194
214 struct DBusWatchList
215 {
216 DBusList *watches;
218 DBusAddWatchFunction add_watch_function;
219 DBusRemoveWatchFunction remove_watch_function;
220 DBusWatchToggledFunction watch_toggled_function;
221 void *watch_data;
222 DBusFreeFunction watch_free_data_function;
223 };
224
231 DBusWatchList*
232 _dbus_watch_list_new (void)
233 {
234 DBusWatchList *watch_list;
235
236 watch_list = dbus_new0 (DBusWatchList, 1);
237 if (watch_list == NULL)
238 return NULL;
239
240 return watch_list;
241 }
242
248 void
249 _dbus_watch_list_free (DBusWatchList *watch_list)
250 {
251 /* free watch_data and removes watches as a side effect */
252 _dbus_watch_list_set_functions (watch_list,
253 NULL, NULL, NULL, NULL, NULL);
254 _dbus_list_foreach (&watch_list->watches,
255 (DBusForeachFunction) _dbus_watch_unref,
256 NULL);
257 _dbus_list_clear (&watch_list->watches);
258
259 dbus_free (watch_list);
260 }
261
262 #ifdef DBUS_ENABLE_VERBOSE_MODE
263 static const char*
264 watch_flags_to_string (int flags)
265 {
266 const char *watch_type;
267
268 if ((flags & DBUS_WATCH_READABLE) &&
269 (flags & DBUS_WATCH_WRITABLE))
270 watch_type = "readwrite";
271 else if (flags & DBUS_WATCH_READABLE)
272 watch_type = "read";
273 else if (flags & DBUS_WATCH_WRITABLE)
274 watch_type = "write";
275 else
276 watch_type = "not read or write";
277 return watch_type;
278 }
279 #endif /* DBUS_ENABLE_VERBOSE_MODE */
280
295 dbus_bool_t
296 _dbus_watch_list_set_functions (DBusWatchList *watch_list,
297 DBusAddWatchFunction add_function,
298 DBusRemoveWatchFunction remove_function,
299 DBusWatchToggledFunction toggled_function,
300 void *data,
301 DBusFreeFunction free_data_function)
302 {
303 /* Add watches with the new watch function, failing on OOM */
304 if (add_function != NULL)
305 {
306 DBusList *link;
307
308 link = _dbus_list_get_first_link (&watch_list->watches);
309 while (link != NULL)
310 {
311 DBusList *next = _dbus_list_get_next_link (&watch_list->watches,
312 link);
313 #ifdef DBUS_ENABLE_VERBOSE_MODE
314 DBusWatch *watch = link->data;
315
316 _dbus_verbose ("Adding a %s watch on fd %" DBUS_POLLABLE_FORMAT " using newly-set add watch function\n",
317 watch_flags_to_string (dbus_watch_get_flags (link->data)),
318 _dbus_pollable_printable (watch->fd));
319 #endif
320
321 if (!(* add_function) (link->data, data))
322 {
323 /* remove it all again and return FALSE */
324 DBusList *link2;
325
326 link2 = _dbus_list_get_first_link (&watch_list->watches);
327 while (link2 != link)
328 {
329 DBusList *next = _dbus_list_get_next_link (&watch_list->watches,
330 link2);
331 #ifdef DBUS_ENABLE_VERBOSE_MODE
332 DBusWatch *watch2 = link2->data;
333
334 _dbus_verbose ("Removing watch on fd %" DBUS_POLLABLE_FORMAT " using newly-set remove function because initial add failed\n",
335 _dbus_pollable_printable (watch2->fd));
336 #endif
337
338 (* remove_function) (link2->data, data);
339
340 link2 = next;
341 }
342
343 return FALSE;
344 }
345
346 link = next;
347 }
348 }
349
350 /* Remove all current watches from previous watch handlers */
351
352 if (watch_list->remove_watch_function != NULL)
353 {
354 _dbus_verbose ("Removing all pre-existing watches\n");
355
356 _dbus_list_foreach (&watch_list->watches,
357 (DBusForeachFunction) watch_list->remove_watch_function,
358 watch_list->watch_data);
359 }
360
361 if (watch_list->watch_free_data_function != NULL)
362 (* watch_list->watch_free_data_function) (watch_list->watch_data);
363
364 watch_list->add_watch_function = add_function;
365 watch_list->remove_watch_function = remove_function;
366 watch_list->watch_toggled_function = toggled_function;
367 watch_list->watch_data = data;
368 watch_list->watch_free_data_function = free_data_function;
369
370 return TRUE;
371 }
372
381 dbus_bool_t
382 _dbus_watch_list_add_watch (DBusWatchList *watch_list,
383 DBusWatch *watch)
384 {
385 if (!_dbus_list_append (&watch_list->watches, watch))
386 return FALSE;
387
388 _dbus_watch_ref (watch);
389
390 if (watch_list->add_watch_function != NULL)
391 {
392 _dbus_verbose ("Adding watch on fd %" DBUS_POLLABLE_FORMAT "\n",
393 _dbus_pollable_printable (watch->fd));
394
395 if (!(* watch_list->add_watch_function) (watch,
396 watch_list->watch_data))
397 {
398 _dbus_list_remove_last (&watch_list->watches, watch);
399 _dbus_watch_unref (watch);
400 return FALSE;
401 }
402 }
403
404 return TRUE;
405 }
406
414 void
415 _dbus_watch_list_remove_watch (DBusWatchList *watch_list,
416 DBusWatch *watch)
417 {
418 if (!_dbus_list_remove (&watch_list->watches, watch))
419 _dbus_assert_not_reached ("Nonexistent watch was removed");
420
421 if (watch_list->remove_watch_function != NULL)
422 {
423 _dbus_verbose ("Removing watch on fd %" DBUS_POLLABLE_FORMAT "\n",
424 _dbus_pollable_printable (watch->fd));
425
426 (* watch_list->remove_watch_function) (watch,
427 watch_list->watch_data);
428 }
429
430 _dbus_watch_unref (watch);
431 }
432
441 void
442 _dbus_watch_list_toggle_watch (DBusWatchList *watch_list,
443 DBusWatch *watch,
444 dbus_bool_t enabled)
445 {
446 enabled = !!enabled;
447
448 if (enabled == watch->enabled)
449 return;
450
451 watch->enabled = enabled;
452
453 if (watch_list->watch_toggled_function != NULL)
454 {
455 _dbus_verbose ("Toggling watch %p on fd %" DBUS_POLLABLE_FORMAT " to %d\n",
456 watch,
457 _dbus_pollable_printable (watch->fd),
458 watch->enabled);
459
460 (* watch_list->watch_toggled_function) (watch,
461 watch_list->watch_data);
462 }
463 }
464
472 void
473 _dbus_watch_list_toggle_all_watches (DBusWatchList *watch_list,
474 dbus_bool_t enabled)
475 {
476 DBusList *link;
477
478 for (link = _dbus_list_get_first_link (&watch_list->watches);
479 link != NULL;
480 link = _dbus_list_get_next_link (&watch_list->watches, link))
481 {
482 _dbus_watch_list_toggle_watch (watch_list, link->data, enabled);
483 }
484 }
485
498 void
499 _dbus_watch_set_handler (DBusWatch *watch,
500 DBusWatchHandler handler,
501 void *data,
502 DBusFreeFunction free_data_function)
503 {
504 if (watch->free_handler_data_function)
505 (* watch->free_handler_data_function) (watch->handler_data);
506
507 watch->handler = handler;
508 watch->handler_data = data;
509 watch->free_handler_data_function = free_data_function;
510 }
511
543 int
544 dbus_watch_get_fd (DBusWatch *watch)
545 {
546 _dbus_return_val_if_fail (watch != NULL, -1);
547
548 return dbus_watch_get_unix_fd(watch);
549 }
550
564 int
565 dbus_watch_get_unix_fd (DBusWatch *watch)
566 {
567 _dbus_return_val_if_fail (watch != NULL, -1);
568
569 /* FIXME remove #ifdef and do this on a lower level
570 * (watch should have set_socket and set_unix_fd and track
571 * which it has, and the transport should provide the
572 * appropriate watch type)
573 */
574 #ifdef DBUS_UNIX
575 return watch->fd;
576 #else
577 return dbus_watch_get_socket( watch );
578 #endif
579 }
580
593 int
594 dbus_watch_get_socket (DBusWatch *watch)
595 {
596 _dbus_return_val_if_fail (watch != NULL, -1);
597
598 #ifdef DBUS_UNIX
599 return watch->fd;
600 #else
601 return _dbus_socket_get_int (watch->fd);
602 #endif
603 }
604
605 DBusSocket
606 _dbus_watch_get_socket (DBusWatch *watch)
607 {
608 DBusSocket s;
609
610 _dbus_assert (watch != NULL);
611
612 #ifdef DBUS_UNIX
613 s.fd = watch->fd;
614 #else
615 s = watch->fd;
616 #endif
617
618 return s;
619 }
620
621 DBusPollable
622 _dbus_watch_get_pollable (DBusWatch *watch)
623 {
624 _dbus_assert (watch != NULL);
625
626 return watch->fd;
627 }
628
642 unsigned int
643 dbus_watch_get_flags (DBusWatch *watch)
644 {
645 _dbus_return_val_if_fail (watch != NULL, 0);
646 _dbus_assert ((watch->flags & VALID_WATCH_FLAGS) == watch->flags);
647
648 return watch->flags;
649 }
650
658 void*
659 dbus_watch_get_data (DBusWatch *watch)
660 {
661 _dbus_return_val_if_fail (watch != NULL, NULL);
662
663 return watch->data;
664 }
665
677 void
678 dbus_watch_set_data (DBusWatch *watch,
679 void *data,
680 DBusFreeFunction free_data_function)
681 {
682 _dbus_return_if_fail (watch != NULL);
683
684 _dbus_verbose ("Setting watch fd %" DBUS_POLLABLE_FORMAT " data to data = %p function = %p from data = %p function = %p\n",
685 _dbus_pollable_printable (watch->fd),
686 data, free_data_function, watch->data, watch->free_data_function);
687
688 if (watch->free_data_function != NULL)
689 (* watch->free_data_function) (watch->data);
690
691 watch->data = data;
692 watch->free_data_function = free_data_function;
693 }
694
702 dbus_bool_t
703 dbus_watch_get_enabled (DBusWatch *watch)
704 {
705 _dbus_return_val_if_fail (watch != NULL, FALSE);
706
707 return watch->enabled;
708 }
709
710
733 dbus_bool_t
734 dbus_watch_handle (DBusWatch *watch,
735 unsigned int flags)
736 {
737 _dbus_return_val_if_fail (watch != NULL, FALSE);
738
739 #ifndef DBUS_DISABLE_CHECKS
740 if (!_dbus_pollable_is_valid (watch->fd) || watch->flags == 0)
741 {
742 _dbus_warn_check_failed ("Watch is invalid, it should have been removed\n");
743 return TRUE;
744 }
745 #endif
746
747 _dbus_return_val_if_fail (_dbus_pollable_is_valid (watch->fd) /* fails if watch was removed */, TRUE);
748
749 _dbus_watch_sanitize_condition (watch, &flags);
750
751 if (flags == 0)
752 {
753 _dbus_verbose ("After sanitization, watch flags on fd %" DBUS_POLLABLE_FORMAT " were 0\n",
754 _dbus_pollable_printable (watch->fd));
755 return TRUE;
756 }
757 else
758 return (* watch->handler) (watch, flags,
759 watch->handler_data);
760 }
761
762
_dbus_watch_new
DBusWatch * _dbus_watch_new(DBusPollable fd, unsigned int flags, dbus_bool_t enabled, DBusWatchHandler handler, void *data, DBusFreeFunction free_data_function)
Creates a new DBusWatch.
Definition: dbus-watch.c:88
DBusWatch
Implementation of DBusWatch.
Definition: dbus-watch.c:40
NULL
#define NULL
A null pointer, defined appropriately for C or C++.
DBusFreeFunction
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
Definition: dbus-memory.h:64
dbus_free
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition: dbus-memory.c:701
DBusWatchList::watch_free_data_function
DBusFreeFunction watch_free_data_function
Free function for watch callback data.
Definition: dbus-watch.c:222
DBusWatch::handler_data
void * handler_data
Watch handler data.
Definition: dbus-watch.c:47
DBusWatchToggledFunction
void(* DBusWatchToggledFunction)(DBusWatch *watch, void *data)
Called when dbus_watch_get_enabled() may return a different value than it did before.
Definition: dbus-connection.h:97
dbus_watch_get_enabled
DBUS_EXPORT dbus_bool_t dbus_watch_get_enabled(DBusWatch *watch)
Returns whether a watch is enabled or not.
Definition: dbus-watch.c:703
_dbus_assert
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
Definition: dbus-internals.h:148
DBusList::data
void * data
Data stored at this element.
Definition: dbus-list.h:38
_dbus_warn_check_failed
void _dbus_warn_check_failed(const char *format,...)
Prints a "critical" warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...
Definition: dbus-internals.c:258
DBusWatchHandler
dbus_bool_t(* DBusWatchHandler)(DBusWatch *watch, unsigned int flags, void *data)
function to run when the watch is handled
Definition: dbus-watch.h:43
_dbus_watch_list_toggle_watch
void _dbus_watch_list_toggle_watch(DBusWatchList *watch_list, DBusWatch *watch, dbus_bool_t enabled)
Sets a watch to the given enabled state, invoking the application&#39;s DBusWatchToggledFunction if appro...
Definition: dbus-watch.c:442
DBusWatchList::add_watch_function
DBusAddWatchFunction add_watch_function
Callback for adding a watch.
Definition: dbus-watch.c:218
DBusWatch::free_data_function
DBusFreeFunction free_data_function
Free the application data.
Definition: dbus-watch.c:51
_dbus_watch_list_free
void _dbus_watch_list_free(DBusWatchList *watch_list)
Frees a DBusWatchList.
Definition: dbus-watch.c:249
DBusWatchList::watch_toggled_function
DBusWatchToggledFunction watch_toggled_function
Callback on toggling enablement.
Definition: dbus-watch.c:220
_dbus_watch_list_new
DBusWatchList * _dbus_watch_list_new(void)
Creates a new watch list.
Definition: dbus-watch.c:232
DBusWatchList::watch_data
void * watch_data
Data for watch callbacks.
Definition: dbus-watch.c:221
_dbus_list_remove
dbus_bool_t _dbus_list_remove(DBusList **list, void *data)
Removes a value from the list.
Definition: dbus-list.c:415
DBusWatch::flags
unsigned int flags
Conditions to watch.
Definition: dbus-watch.c:44
_dbus_list_get_next_link
#define _dbus_list_get_next_link(list, link)
Gets the next link in the list, or NULL if there are no more links.
Definition: dbus-list.h:116
_dbus_watch_list_set_functions
dbus_bool_t _dbus_watch_list_set_functions(DBusWatchList *watch_list, DBusAddWatchFunction add_function, DBusRemoveWatchFunction remove_function, DBusWatchToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
Sets the watch functions.
Definition: dbus-watch.c:296
DBusSocket
Socket interface.
Definition: dbus-sysdeps.h:148
_dbus_list_remove_last
dbus_bool_t _dbus_list_remove_last(DBusList **list, void *data)
Removes a value from the list.
Definition: dbus-list.c:446
dbus_new0
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
Definition: dbus-memory.h:59
DBUS_WATCH_WRITABLE
As in POLLOUT.
Definition: dbus-connection.h:61
dbus_bool_t
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
dbus_watch_get_socket
DBUS_EXPORT int dbus_watch_get_socket(DBusWatch *watch)
Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...
Definition: dbus-watch.c:594
_dbus_warn
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
Definition: dbus-internals.c:230
_dbus_list_append
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
Definition: dbus-list.c:270
_dbus_watch_sanitize_condition
void _dbus_watch_sanitize_condition(DBusWatch *watch, unsigned int *condition)
Sanitizes the given condition so that it only contains flags that the DBusWatch requested.
Definition: dbus-watch.c:185
_dbus_list_foreach
void _dbus_list_foreach(DBusList **list, DBusForeachFunction function, void *data)
Calls the given function for each element in the list.
Definition: dbus-list.c:759
_dbus_watch_list_toggle_all_watches
void _dbus_watch_list_toggle_all_watches(DBusWatchList *watch_list, dbus_bool_t enabled)
Sets all watches to the given enabled state, invoking the application&#39;s DBusWatchToggledFunction if a...
Definition: dbus-watch.c:473
_dbus_watch_invalidate
void _dbus_watch_invalidate(DBusWatch *watch)
Clears the file descriptor from a now-invalid watch object so that no one tries to use it...
Definition: dbus-watch.c:169
DBusWatch::oom_last_time
unsigned int oom_last_time
Whether it was OOM last time.
Definition: dbus-watch.c:53
DBusWatch::data
void * data
Application data.
Definition: dbus-watch.c:50
dbus_watch_get_unix_fd
DBUS_EXPORT int dbus_watch_get_unix_fd(DBusWatch *watch)
Returns a UNIX file descriptor to be watched, which may be a pipe, socket, or other type of descripto...
Definition: dbus-watch.c:565
DBusWatch::refcount
int refcount
Reference count.
Definition: dbus-watch.c:42
TRUE
#define TRUE
Expands to "1".
_dbus_assert_not_reached
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
Definition: dbus-internals.h:159
_dbus_watch_list_add_watch
dbus_bool_t _dbus_watch_list_add_watch(DBusWatchList *watch_list, DBusWatch *watch)
Adds a new watch to the watch list, invoking the application DBusAddWatchFunction if appropriate...
Definition: dbus-watch.c:382
dbus_watch_get_fd
DBUS_EXPORT DBUS_DEPRECATED int dbus_watch_get_fd(DBusWatch *watch)
Deprecated former name of dbus_watch_get_unix_fd().
Definition: dbus-watch.c:544
DBusAddWatchFunction
dbus_bool_t(* DBusAddWatchFunction)(DBusWatch *watch, void *data)
Called when libdbus needs a new watch to be monitored by the main loop.
Definition: dbus-connection.h:91
dbus_watch_set_data
DBUS_EXPORT void dbus_watch_set_data(DBusWatch *watch, void *data, DBusFreeFunction free_data_function)
Sets data which can be retrieved with dbus_watch_get_data().
Definition: dbus-watch.c:678
DBusRemoveWatchFunction
void(* DBusRemoveWatchFunction)(DBusWatch *watch, void *data)
Called when libdbus no longer needs a watch to be monitored by the main loop.
Definition: dbus-connection.h:103
DBusWatchList
DBusWatchList implementation details.
Definition: dbus-watch.c:214
DBusWatch::enabled
unsigned int enabled
Whether it&#39;s enabled.
Definition: dbus-watch.c:52
dbus_watch_get_data
DBUS_EXPORT void * dbus_watch_get_data(DBusWatch *watch)
Gets data previously set with dbus_watch_set_data() or NULL if none.
Definition: dbus-watch.c:659
_dbus_watch_list_remove_watch
void _dbus_watch_list_remove_watch(DBusWatchList *watch_list, DBusWatch *watch)
Removes a watch from the watch list, invoking the application&#39;s DBusRemoveWatchFunction if appropriat...
Definition: dbus-watch.c:415
DBusList
A node in a linked list.
Definition: dbus-list.h:34
_dbus_watch_unref
void _dbus_watch_unref(DBusWatch *watch)
Decrements the reference count of a DBusWatch object and finalizes the object if the count reaches ze...
Definition: dbus-watch.c:138
DBusForeachFunction
void(* DBusForeachFunction)(void *element, void *data)
Used to iterate over each item in a collection, such as a DBusList.
Definition: dbus-internals.h:283
_dbus_list_get_first_link
DBusList * _dbus_list_get_first_link(DBusList **list)
Gets the first link in the list.
Definition: dbus-list.c:567
FALSE
#define FALSE
Expands to "0".
dbus_watch_handle
DBUS_EXPORT dbus_bool_t dbus_watch_handle(DBusWatch *watch, unsigned int flags)
Called to notify the D-Bus library when a previously-added watch is ready for reading or writing...
Definition: dbus-watch.c:734
_dbus_watch_ref
DBusWatch * _dbus_watch_ref(DBusWatch *watch)
Increments the reference count of a DBusWatch object.
Definition: dbus-watch.c:124
DBusWatch::fd
DBusPollable fd
File descriptor.
Definition: dbus-watch.c:43
dbus_watch_get_flags
DBUS_EXPORT unsigned int dbus_watch_get_flags(DBusWatch *watch)
Gets flags from DBusWatchFlags indicating what conditions should be monitored on the file descriptor...
Definition: dbus-watch.c:643
DBUS_WATCH_READABLE
As in POLLIN.
Definition: dbus-connection.h:60
DBusWatch::free_handler_data_function
DBusFreeFunction free_handler_data_function
Free the watch handler data.
Definition: dbus-watch.c:48
_dbus_watch_set_handler
void _dbus_watch_set_handler(DBusWatch *watch, DBusWatchHandler handler, void *data, DBusFreeFunction free_data_function)
Sets the handler for the watch.
Definition: dbus-watch.c:499
DBusWatchList::remove_watch_function
DBusRemoveWatchFunction remove_watch_function
Callback for removing a watch.
Definition: dbus-watch.c:219
DBusWatch::handler
DBusWatchHandler handler
Watch handler.
Definition: dbus-watch.c:46
DBusWatchList::watches
DBusList * watches
Watch objects.
Definition: dbus-watch.c:216
_dbus_list_clear
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL.
Definition: dbus-list.c:542