00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef DBUS_SOCKET_SET_H
00027 #define DBUS_SOCKET_SET_H
00028
00029 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00030
00031 #include <dbus/dbus.h>
00032
00033 typedef struct {
00034 int fd;
00035 unsigned int flags;
00036 } DBusSocketEvent;
00037
00038 typedef struct DBusSocketSet DBusSocketSet;
00039
00040 typedef struct DBusSocketSetClass DBusSocketSetClass;
00041 struct DBusSocketSetClass {
00042 void (*free) (DBusSocketSet *self);
00043 dbus_bool_t (*add) (DBusSocketSet *self,
00044 int fd,
00045 unsigned int flags,
00046 dbus_bool_t enabled);
00047 void (*remove) (DBusSocketSet *self,
00048 int fd);
00049 void (*enable) (DBusSocketSet *self,
00050 int fd,
00051 unsigned int flags);
00052 void (*disable) (DBusSocketSet *self,
00053 int fd);
00054 int (*poll) (DBusSocketSet *self,
00055 DBusSocketEvent *revents,
00056 int max_events,
00057 int timeout_ms);
00058 };
00059
00060 struct DBusSocketSet {
00061 DBusSocketSetClass *cls;
00062 };
00063
00064 DBusSocketSet *_dbus_socket_set_new (int size_hint);
00065
00066 static inline void
00067 _dbus_socket_set_free (DBusSocketSet *self)
00068 {
00069 (self->cls->free) (self);
00070 }
00071
00072 static inline dbus_bool_t
00073 _dbus_socket_set_add (DBusSocketSet *self,
00074 int fd,
00075 unsigned int flags,
00076 dbus_bool_t enabled)
00077 {
00078 return (self->cls->add) (self, fd, flags, enabled);
00079 }
00080
00081 static inline void
00082 _dbus_socket_set_remove (DBusSocketSet *self,
00083 int fd)
00084 {
00085 (self->cls->remove) (self, fd);
00086 }
00087
00088 static inline void
00089 _dbus_socket_set_enable (DBusSocketSet *self,
00090 int fd,
00091 unsigned int flags)
00092 {
00093 (self->cls->enable) (self, fd, flags);
00094 }
00095
00096 static inline void
00097 _dbus_socket_set_disable (DBusSocketSet *self,
00098 int fd)
00099 {
00100 (self->cls->disable) (self, fd);
00101 }
00102
00103
00104 static inline int
00105 _dbus_socket_set_poll (DBusSocketSet *self,
00106 DBusSocketEvent *revents,
00107 int max_events,
00108 int timeout_ms)
00109 {
00110 return (self->cls->poll) (self, revents, max_events, timeout_ms);
00111 }
00112
00113
00114
00115 extern DBusSocketSetClass _dbus_socket_set_poll_class;
00116 extern DBusSocketSetClass _dbus_socket_set_epoll_class;
00117
00118 DBusSocketSet *_dbus_socket_set_poll_new (int size_hint);
00119 DBusSocketSet *_dbus_socket_set_epoll_new (void);
00120
00121 #endif
00122 #endif