25 #ifndef DBUS_SYSDEPS_H
26 #define DBUS_SYSDEPS_H
29 #warning Please include config.h before dbus-sysdeps.h
37 #ifdef HAVE_INTTYPES_H
41 #include <dbus/dbus-errors.h>
42 #include <dbus/dbus-file.h>
43 #include <dbus/dbus-string.h>
51 #if !defined(BROKEN_POLL) && (defined(__APPLE__) || defined(__INTERIX))
88 #include "dbus-sysdeps-wince-glue.h"
98 #define _DBUS_PATH_SEPARATOR ";"
100 #define _DBUS_PATH_SEPARATOR ":"
139 #define DBUS_PID_UNSET ((dbus_pid_t) -1)
141 #define DBUS_UID_UNSET ((dbus_uid_t) -1)
143 #define DBUS_GID_UNSET ((dbus_gid_t) -1)
146 #define DBUS_PID_FORMAT "%lu"
148 #define DBUS_UID_FORMAT "%lu"
150 #define DBUS_GID_FORMAT "%lu"
158 # define DBUS_SOCKET_FORMAT "Iu"
159 # define DBUS_SOCKET_INIT { INVALID_SOCKET }
162 _dbus_socket_printable (
DBusSocket s) {
return s.sock; }
165 _dbus_socket_is_valid (
DBusSocket s) {
return s.sock != INVALID_SOCKET; }
168 _dbus_socket_invalidate (
DBusSocket *s) { s->sock = INVALID_SOCKET; }
171 _dbus_socket_get_int (
DBusSocket s) {
return (
int)s.sock; }
176 # define DBUS_SOCKET_FORMAT "d"
177 # define DBUS_SOCKET_INIT { -1 }
180 _dbus_socket_printable (
DBusSocket s) {
return s.fd; }
183 _dbus_socket_is_valid (
DBusSocket s) {
return s.fd >= 0; }
186 _dbus_socket_invalidate (
DBusSocket *s) { s->fd = -1; }
189 _dbus_socket_get_int (
DBusSocket s) {
return s.fd; }
194 _dbus_socket_get_invalid (
void)
228 unsigned int *n_fds);
230 int _dbus_write_socket_with_unix_fds (
DBusSocket fd,
236 int _dbus_write_socket_with_unix_fds_two (
DBusSocket fd,
250 DBusSocket _dbus_connect_tcp_socket_with_nonce (
const char *host,
253 const char *noncefile,
280 dbus_gid_t **group_ids,
290 dbus_bool_t _dbus_daemon_is_session_bus_address_published (
const char *scope);
292 dbus_bool_t _dbus_daemon_publish_session_bus_address (
const char* address,
const char* shm_name);
294 void _dbus_daemon_unpublish_session_bus_address (
void);
329 # define DBUS_POLLABLE_FORMAT "Iu"
331 static inline DBusPollable
332 _dbus_socket_get_pollable (
DBusSocket s) {
return s; }
335 _dbus_pollable_printable (DBusPollable p) {
return p.sock; }
338 _dbus_pollable_is_valid (DBusPollable p) {
return _dbus_socket_is_valid (p); }
341 _dbus_pollable_invalidate (DBusPollable *p) { _dbus_socket_invalidate (p); }
344 _dbus_pollable_equals (DBusPollable a, DBusPollable b) {
return a.sock == b.sock; }
353 typedef int DBusPollable;
354 # define DBUS_POLLABLE_FORMAT "d"
356 static inline DBusPollable
357 _dbus_socket_get_pollable (
DBusSocket s) {
return s.fd; }
360 _dbus_pollable_printable (DBusPollable p) {
return p; }
363 _dbus_pollable_is_valid (DBusPollable p) {
return p >= 0; }
366 _dbus_pollable_invalidate (DBusPollable *p) { *p = -1; }
369 _dbus_pollable_equals (DBusPollable a, DBusPollable b) {
return a == b; }
373 #if defined(HAVE_POLL) && !defined(BROKEN_POLL)
381 #define _DBUS_POLLIN POLLIN
383 #define _DBUS_POLLPRI POLLPRI
385 #define _DBUS_POLLOUT POLLOUT
387 #define _DBUS_POLLERR POLLERR
389 #define _DBUS_POLLHUP POLLHUP
391 #define _DBUS_POLLNVAL POLLNVAL
405 #define _DBUS_POLLIN 0x0001
407 #define _DBUS_POLLPRI 0x0002
409 #define _DBUS_POLLOUT 0x0004
411 #define _DBUS_POLLERR 0x0008
413 #define _DBUS_POLLHUP 0x0010
415 #define _DBUS_POLLNVAL 0x0020
421 int timeout_milliseconds);
482 _DBUS_GNUC_WARN_UNUSED_RESULT
499 int _dbus_save_socket_errno (
void);
500 void _dbus_restore_socket_errno (
int saved_errno);
513 void _dbus_exit (
int code) _DBUS_GNUC_NORETURN;
517 va_list args) _DBUS_GNUC_PRINTF (1, 0);
519 #ifdef DBUS_ENABLE_VERBOSE_MODE
521 void _dbus_print_thread (
void);
562 dbus_pid_t pid_to_write,
574 DBUS_LOG_FLAGS_STDERR = (1 << 0),
575 DBUS_LOG_FLAGS_SYSTEM_LOG = (1 << 1)
583 DBUS_SYSTEM_LOG_INFO,
584 DBUS_SYSTEM_LOG_WARNING,
585 DBUS_SYSTEM_LOG_SECURITY,
586 DBUS_SYSTEM_LOG_ERROR
587 } DBusSystemLogSeverity;
590 void _dbus_log (DBusSystemLogSeverity severity,
592 ...) _DBUS_GNUC_PRINTF (2, 3);
594 void _dbus_logv (DBusSystemLogSeverity severity,
596 va_list args) _DBUS_GNUC_PRINTF (2, 0);
601 #if !defined (DBUS_VA_COPY)
602 # if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
603 # define DBUS_VA_COPY(ap1, ap2) (*(ap1) = *(ap2))
604 # elif defined (DBUS_VA_COPY_AS_ARRAY)
605 # define DBUS_VA_COPY(ap1, ap2) memcpy ((ap1), (ap2), sizeof (va_list))
607 # define DBUS_VA_COPY(ap1, ap2) ((ap1) = (ap2))
616 #define _DBUS_BYTE_OF_PRIMITIVE(p, i) \
617 (((const char*)&(p))[(i)])
623 #define _DBUS_DOUBLES_BITWISE_EQUAL(a, b) \
624 (_DBUS_BYTE_OF_PRIMITIVE (a, 0) == _DBUS_BYTE_OF_PRIMITIVE (b, 0) && \
625 _DBUS_BYTE_OF_PRIMITIVE (a, 1) == _DBUS_BYTE_OF_PRIMITIVE (b, 1) && \
626 _DBUS_BYTE_OF_PRIMITIVE (a, 2) == _DBUS_BYTE_OF_PRIMITIVE (b, 2) && \
627 _DBUS_BYTE_OF_PRIMITIVE (a, 3) == _DBUS_BYTE_OF_PRIMITIVE (b, 3) && \
628 _DBUS_BYTE_OF_PRIMITIVE (a, 4) == _DBUS_BYTE_OF_PRIMITIVE (b, 4) && \
629 _DBUS_BYTE_OF_PRIMITIVE (a, 5) == _DBUS_BYTE_OF_PRIMITIVE (b, 5) && \
630 _DBUS_BYTE_OF_PRIMITIVE (a, 6) == _DBUS_BYTE_OF_PRIMITIVE (b, 6) && \
631 _DBUS_BYTE_OF_PRIMITIVE (a, 7) == _DBUS_BYTE_OF_PRIMITIVE (b, 7))
696 #define DBUS_DEFAULT_MESSAGE_UNIX_FDS 16
698 typedef struct DBusRLimit DBusRLimit;
700 DBusRLimit *_dbus_rlimit_save_fd_limit (
DBusError *error);
702 dbus_bool_t _dbus_rlimit_restore_fd_limit (DBusRLimit *saved,
704 void _dbus_rlimit_free (DBusRLimit *lim);
706 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
707 _DBUS_GNUC_WARN_UNUSED_RESULT
711 _DBUS_GNUC_WARN_UNUSED_RESULT
722 #include "dbus-sysdeps-win.h"