Utilities and portability
[D-BUS internal implementation details]

Utility functions (_dbus_assert(), _dbus_warn(), etc. More...

Data Structures

struct  DBusBabysitter
 Babysitter implementation details. More...
struct  DBusDirIter
 Internals of directory iterator. More...

Defines

#define _dbus_assert(condition)   _dbus_real_assert ((condition) != 0, #condition, __FILE__, __LINE__, _DBUS_FUNCTION_NAME)
 Aborts with an error message if the condition is false.
#define _dbus_assert_not_reached(explanation)   _dbus_real_assert_not_reached (explanation, __FILE__, __LINE__)
 Aborts with an error message if called.
#define _DBUS_N_ELEMENTS(array)   ((int) (sizeof ((array)) / sizeof ((array)[0])))
 Computes the number of elements in a fixed-size array using sizeof().
#define _DBUS_POINTER_TO_INT(pointer)   ((long)(pointer))
 Safely casts a void* to an integer; should only be used on void* that actually contain integers, for example one created with _DBUS_INT_TO_POINTER.
#define _DBUS_INT_TO_POINTER(integer)   ((void*)((long)(integer)))
 Safely stuffs an integer into a pointer, to be extracted later with _DBUS_POINTER_TO_INT.
#define _DBUS_ZERO(object)   (memset (&(object), '\0', sizeof ((object))))
 Sets all bits in an object to zero.
#define _DBUS_INT16_MIN   ((dbus_int16_t) 0x8000)
 Minimum value of type "int16".
#define _DBUS_INT16_MAX   ((dbus_int16_t) 0x7fff)
 Maximum value of type "int16".
#define _DBUS_UINT16_MAX   ((dbus_uint16_t)0xffff)
 Maximum value of type "uint16".
#define _DBUS_INT32_MIN   ((dbus_int32_t) 0x80000000)
 Minimum value of type "int32".
#define _DBUS_INT32_MAX   ((dbus_int32_t) 0x7fffffff)
 Maximum value of type "int32".
#define _DBUS_UINT32_MAX   ((dbus_uint32_t)0xffffffff)
 Maximum value of type "uint32".
#define _DBUS_INT_MIN   _DBUS_INT32_MIN
 Minimum value of type "int".
#define _DBUS_INT_MAX   _DBUS_INT32_MAX
 Maximum value of type "int".
#define _DBUS_UINT_MAX   _DBUS_UINT32_MAX
 Maximum value of type "uint".
#define _DBUS_LOCK_NAME(name)   _dbus_lock_##name
 Expands to name of a global lock variable.
#define _DBUS_DEFINE_GLOBAL_LOCK(name)   DBusMutex *_dbus_lock_##name
 Defines a global lock variable with the given name.
#define _DBUS_DECLARE_GLOBAL_LOCK(name)   extern DBusMutex *_dbus_lock_##name
 Expands to declaration of a global lock defined with _DBUS_DEFINE_GLOBAL_LOCK.
#define _DBUS_LOCK(name)   _dbus_mutex_lock (_dbus_lock_##name)
 Locks a global lock.
#define _DBUS_UNLOCK(name)   _dbus_mutex_unlock (_dbus_lock_##name)
 Unlocks a global lock.
#define PTHREAD_IN_VERBOSE   0
#define LIVE_CHILDREN(sitter)   ((sitter)->socket_to_babysitter >= 0 || (sitter)->error_pipe_from_child >= 0)
 Macro returns TRUE if the babysitter still has live sockets open to the babysitter child or the grandchild.
#define READ_END   0
 Helps remember which end of the pipe is which.
#define WRITE_END   1
 Helps remember which end of the pipe is which.
#define _DBUS_MAX_SUN_PATH_LENGTH   99
 Maximum length of the path to a UNIX domain socket, sockaddr_un::sun_path member.
#define NANOSECONDS_PER_SECOND   1000000000
 nanoseconds in a second
#define MICROSECONDS_PER_SECOND   1000000
 microseconds in a second
#define MILLISECONDS_PER_SECOND   1000
 milliseconds in a second
#define NANOSECONDS_PER_MILLISECOND   1000000
 nanoseconds in a millisecond
#define MICROSECONDS_PER_MILLISECOND   1000
 microseconds in a millisecond

Typedefs

typedef void(* DBusForeachFunction )(void *element, void *data)
 Used to iterate over each item in a collection, such as a DBusList.

Enumerations

enum  ReadStatus { READ_STATUS_OK, READ_STATUS_ERROR, READ_STATUS_EOF }
 Enumeration for status of a read(). More...
enum  { CHILD_EXITED, CHILD_FORK_FAILED, CHILD_EXEC_FAILED, CHILD_PID }

Functions

void _dbus_warn (const char *format,...)
 Prints a warning message to stderr.
void _dbus_verbose_real (const char *format,...)
 Prints a warning message to stderr if the user has enabled verbose mode.
void _dbus_verbose_reset_real (void)
 Reinitializes the verbose logging code, used as a hack in dbus-spawn.c so that a child process re-reads its pid.
char * _dbus_strdup (const char *str)
 Duplicates a string.
void * _dbus_memdup (const void *mem, size_t n_bytes)
 Duplicates a block of memory.
char ** _dbus_dup_string_array (const char **array)
 Duplicates a string array.
dbus_bool_t _dbus_string_array_contains (const char **array, const char *str)
 Checks whether a string array contains the given string.
const char * _dbus_header_field_to_string (int header_field)
 Returns a string describing the given name.
void _dbus_real_assert (dbus_bool_t condition, const char *condition_text, const char *file, int line, const char *func)
 Internals of _dbus_assert(); it's a function rather than a macro with the inline code so that the assertion failure blocks don't show up in test suite coverage, and to shrink code size.
void _dbus_real_assert_not_reached (const char *explanation, const char *file, int line)
 Internals of _dbus_assert_not_reached(); it's a function rather than a macro with the inline code so that the assertion failure blocks don't show up in test suite coverage, and to shrink code size.
dbus_bool_t _dbus_test_oom_handling (const char *description, DBusTestMemoryFunction func, void *data)
 Tests how well the given function responds to out-of-memory situations.
DBusBabysitter_dbus_babysitter_ref (DBusBabysitter *sitter)
 Increment the reference count on the babysitter object.
void _dbus_babysitter_unref (DBusBabysitter *sitter)
 Decrement the reference count on the babysitter object.
void _dbus_babysitter_kill_child (DBusBabysitter *sitter)
 Blocks until the babysitter process gives us the PID of the spawned grandchild, then kills the spawned grandchild.
dbus_bool_t _dbus_babysitter_get_child_exited (DBusBabysitter *sitter)
 Checks whether the child has exited, without blocking.
void _dbus_babysitter_set_child_exit_error (DBusBabysitter *sitter, DBusError *error)
 Sets the DBusError with an explanation of why the spawned child process exited (on a signal, or whatever).
dbus_bool_t _dbus_babysitter_set_watch_functions (DBusBabysitter *sitter, DBusAddWatchFunction add_function, DBusRemoveWatchFunction remove_function, DBusWatchToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
 Sets watch functions to notify us when the babysitter object needs to read/write file descriptors.
dbus_bool_t _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, char **argv, DBusSpawnChildSetupFunc child_setup, void *user_data, DBusError *error)
 Spawns a new process.
dbus_bool_t _dbus_become_daemon (const DBusString *pidfile, int print_pid_fd, DBusError *error)
 Does the chdir, fork, setsid, etc.
dbus_bool_t _dbus_write_pid_file (const DBusString *filename, unsigned long pid, DBusError *error)
 Creates a file containing the process ID.
dbus_bool_t _dbus_change_identity (dbus_uid_t uid, dbus_gid_t gid, DBusError *error)
 Changes the user and group the bus is running as.
void _dbus_set_signal_handler (int sig, DBusSignalHandler handler)
 Installs a UNIX signal handler.
dbus_bool_t _dbus_delete_directory (const DBusString *filename, DBusError *error)
 Removes a directory; Directory must be empty.
dbus_bool_t _dbus_file_exists (const char *file)
 Checks if a file exists.
dbus_bool_t _dbus_user_at_console (const char *username, DBusError *error)
 Checks if user is at the console.
dbus_bool_t _dbus_path_is_absolute (const DBusString *filename)
 Checks whether the filename is an absolute path.
dbus_bool_t _dbus_stat (const DBusString *filename, DBusStat *statbuf, DBusError *error)
 stat() wrapper.
DBusDirIter_dbus_directory_open (const DBusString *filename, DBusError *error)
 Open a directory to iterate over.
dbus_bool_t _dbus_directory_get_next_file (DBusDirIter *iter, DBusString *filename, DBusError *error)
 Get next file in the directory.
void _dbus_directory_close (DBusDirIter *iter)
 Closes a directory iteration.
dbus_bool_t _dbus_group_info_fill (DBusGroupInfo *info, const DBusString *groupname, DBusError *error)
 Initializes the given DBusGroupInfo struct with information about the given group name.
dbus_bool_t _dbus_group_info_fill_gid (DBusGroupInfo *info, dbus_gid_t gid, DBusError *error)
 Initializes the given DBusGroupInfo struct with information about the given group ID.
void _dbus_group_info_free (DBusGroupInfo *info)
 Frees the members of info (but not info itself).
void _dbus_abort (void)
 Aborts the program with SIGABRT (dumping core).
dbus_bool_t _dbus_setenv (const char *varname, const char *value)
 Wrapper for setenv().
const char * _dbus_getenv (const char *varname)
 Wrapper for getenv().
int _dbus_read (int fd, DBusString *buffer, int count)
 Thin wrapper around the read() system call that appends the data it reads to the DBusString buffer.
int _dbus_write (int fd, const DBusString *buffer, int start, int len)
 Thin wrapper around the write() system call that writes a part of a DBusString and handles EINTR for you.
int _dbus_write_two (int fd, const DBusString *buffer1, int start1, int len1, const DBusString *buffer2, int start2, int len2)
 Like _dbus_write() but will use writev() if possible to write both buffers in sequence.
int _dbus_connect_unix_socket (const char *path, dbus_bool_t abstract, DBusError *error)
 Creates a socket and connects it to the UNIX domain socket at the given path.
int _dbus_listen_unix_socket (const char *path, dbus_bool_t abstract, DBusError *error)
 Creates a socket and binds it to the given path, then listens on the socket.
int _dbus_connect_tcp_socket (const char *host, dbus_uint32_t port, DBusError *error)
 Creates a socket and connects to a socket at the given host and port.
int _dbus_listen_tcp_socket (const char *host, dbus_uint32_t port, DBusError *error)
 Creates a socket and binds it to the given path, then listens on the socket.
dbus_bool_t _dbus_read_credentials_unix_socket (int client_fd, DBusCredentials *credentials, DBusError *error)
 Reads a single byte which must be nul (an error occurs otherwise), and reads unix credentials if available.
dbus_bool_t _dbus_send_credentials_unix_socket (int server_fd, DBusError *error)
 Sends a single nul byte with our UNIX credentials as ancillary data.
int _dbus_accept (int listen_fd)
 Accepts a connection on a listening socket.
dbus_bool_t _dbus_user_info_fill (DBusUserInfo *info, const DBusString *username, DBusError *error)
 Gets user info for the given username.
dbus_bool_t _dbus_user_info_fill_uid (DBusUserInfo *info, dbus_uid_t uid, DBusError *error)
 Gets user info for the given user ID.
void _dbus_user_info_free (DBusUserInfo *info)
 Frees the members of info (but not info itself).
void _dbus_credentials_clear (DBusCredentials *credentials)
 Sets fields in DBusCredentials to DBUS_PID_UNSET, DBUS_UID_UNSET, DBUS_GID_UNSET.
void _dbus_credentials_from_current_process (DBusCredentials *credentials)
 Gets the credentials of the current process.
dbus_bool_t _dbus_credentials_match (const DBusCredentials *expected_credentials, const DBusCredentials *provided_credentials)
 Checks whether the provided_credentials are allowed to log in as the expected_credentials.
unsigned long _dbus_getpid (void)
 Gets our process ID.
dbus_uid_t _dbus_getuid (void)
 Gets our UID.
dbus_gid_t _dbus_getgid (void)
 Gets our GID.
dbus_int32_t _dbus_atomic_inc (DBusAtomic *atomic)
 Atomically increments an integer.
dbus_int32_t _dbus_atomic_dec (DBusAtomic *atomic)
 Atomically decrement an integer.
int _dbus_poll (DBusPollFD *fds, int n_fds, int timeout_milliseconds)
 Wrapper for poll().
void _dbus_sleep_milliseconds (int milliseconds)
 Sleeps the given number of milliseconds.
void _dbus_get_current_time (long *tv_sec, long *tv_usec)
 Get current time, as in gettimeofday().
dbus_bool_t _dbus_file_get_contents (DBusString *str, const DBusString *filename, DBusError *error)
 Appends the contents of the given file to the string, returning error code.
dbus_bool_t _dbus_string_save_to_file (const DBusString *str, const DBusString *filename, DBusError *error)
 Writes a string out to a file.
dbus_bool_t _dbus_create_file_exclusively (const DBusString *filename, DBusError *error)
 Creates the given file, failing if the file already exists.
dbus_bool_t _dbus_delete_file (const DBusString *filename, DBusError *error)
 Deletes the given file.
dbus_bool_t _dbus_create_directory (const DBusString *filename, DBusError *error)
 Creates a directory; succeeds if the directory is created or already existed.
dbus_bool_t _dbus_concat_dir_and_file (DBusString *dir, const DBusString *next_component)
 Appends the given filename to the given directory.
void _dbus_generate_random_bytes_buffer (char *buffer, int n_bytes)
 Fills n_bytes of the given buffer with random bytes.
dbus_bool_t _dbus_generate_random_bytes (DBusString *str, int n_bytes)
 Generates the given number of random bytes, using the best mechanism we can come up with.
dbus_bool_t _dbus_generate_random_ascii (DBusString *str, int n_bytes)
 Generates the given number of random bytes, where the bytes are chosen from the alphanumeric ASCII subset.
const char * _dbus_strerror (int error_number)
 A wrapper around strerror() because some platforms may be lame and not have strerror().
void _dbus_disable_sigpipe (void)
 signal (SIGPIPE, SIG_IGN);
void _dbus_fd_set_close_on_exec (int fd)
 Sets the file descriptor to be close on exec.
const char * _dbus_error_from_errno (int error_number)
 Converts a UNIX errno into a DBusError name.
void _dbus_exit (int code)
 Exit the process, returning the given value.
dbus_bool_t _dbus_close (int fd, DBusError *error)
 Closes a file descriptor.
dbus_bool_t _dbus_set_fd_nonblocking (int fd, DBusError *error)
 Sets a file descriptor to be nonblocking.
void _dbus_print_backtrace (void)
 On GNU libc systems, print a crude backtrace to the verbose log.
dbus_bool_t _dbus_parse_uid (const DBusString *uid_str, dbus_uid_t *uid)
 Gets a UID from a UID string.
dbus_bool_t _dbus_full_duplex_pipe (int *fd1, int *fd2, dbus_bool_t blocking, DBusError *error)
 Creates a full-duplex pipe (as in socketpair()).
dbus_bool_t _dbus_is_console_user (dbus_uid_t uid, DBusError *error)
 Checks to see if the UID sent in is the console user.
dbus_bool_t _dbus_credentials_from_uid (dbus_uid_t uid, DBusCredentials *credentials)
 Gets the credentials corresponding to the given UID.
dbus_bool_t _dbus_get_user_id (const DBusString *username, dbus_uid_t *uid)
 Gets user ID given username.
dbus_bool_t _dbus_get_group_id (const DBusString *groupname, dbus_gid_t *gid)
 Gets group ID given groupname.
DBusGroupInfo_dbus_user_database_lookup_group (DBusUserDatabase *db, dbus_gid_t gid, const DBusString *groupname, DBusError *error)
 Looks up a gid or group name in the user database.
dbus_bool_t _dbus_user_database_get_groupname (DBusUserDatabase *db, const DBusString *groupname, const DBusGroupInfo **info, DBusError *error)
 Gets the user information for the given group name, returned group info should not be freed.
dbus_bool_t _dbus_user_database_get_gid (DBusUserDatabase *db, dbus_gid_t gid, const DBusGroupInfo **info, DBusError *error)
 Gets the user information for the given GID, returned group info should not be freed.
dbus_bool_t _dbus_user_database_get_groups (DBusUserDatabase *db, dbus_uid_t uid, dbus_gid_t **group_ids, int *n_group_ids, DBusError *error)
 Gets all groups for a particular user.
void _dbus_user_info_free_allocated (DBusUserInfo *info)
 Frees the given DBusUserInfo's members with _dbus_user_info_free() and also calls dbus_free() on the block itself.
void _dbus_group_info_free_allocated (DBusGroupInfo *info)
 Frees the given DBusGroupInfo's members with _dbus_group_info_free() and also calls dbus_free() on the block itself.
dbus_bool_t _dbus_is_a_number (const DBusString *str, unsigned long *num)
 Checks if a given string is actually a number and converts it if it is.
DBusUserInfo_dbus_user_database_lookup (DBusUserDatabase *db, dbus_uid_t uid, const DBusString *username, DBusError *error)
 Looks up a uid or username in the user database.
void _dbus_user_database_lock_system (void)
 Locks global system user database.
void _dbus_user_database_unlock_system (void)
 Unlocks global system user database.
DBusUserDatabase * _dbus_user_database_get_system (void)
 Gets the system global user database; must be called with lock held (_dbus_user_database_lock_system()).
dbus_bool_t _dbus_username_from_current_process (const DBusString **username)
 Gets username of user owning current process.
dbus_bool_t _dbus_homedir_from_current_process (const DBusString **homedir)
 Gets homedir of user owning current process.
dbus_bool_t _dbus_homedir_from_username (const DBusString *username, DBusString *homedir)
 Gets the home directory for the given user.
dbus_bool_t _dbus_credentials_from_username (const DBusString *username, DBusCredentials *credentials)
 Gets the credentials corresponding to the given username.
DBusUserDatabase * _dbus_user_database_new (void)
 Creates a new user database object used to look up and cache user information.
DBusUserDatabase * _dbus_user_database_ref (DBusUserDatabase *db)
 Increments refcount of user database.
void _dbus_user_database_unref (DBusUserDatabase *db)
 Decrements refcount of user database.
dbus_bool_t _dbus_user_database_get_uid (DBusUserDatabase *db, dbus_uid_t uid, const DBusUserInfo **info, DBusError *error)
 Gets the user information for the given UID, returned user info should not be freed.
dbus_bool_t _dbus_user_database_get_username (DBusUserDatabase *db, const DBusString *username, const DBusUserInfo **info, DBusError *error)
 Gets the user information for the given username.

Variables

const char _dbus_no_memory_message [] = "Not enough memory"
 Fixed "out of memory" error message, just to avoid making up a different string every time and wasting space.
const char _dbus_return_if_fail_warning_format []
 String used in _dbus_return_if_fail macro.

Detailed Description

Utility functions (_dbus_assert(), _dbus_warn(), etc.

)


Define Documentation

#define _dbus_assert condition   )     _dbus_real_assert ((condition) != 0, #condition, __FILE__, __LINE__, _DBUS_FUNCTION_NAME)
 

Aborts with an error message if the condition is false.

Parameters:
condition condition which must be true.

Definition at line 107 of file dbus-internals.h.

Referenced by _dbus_auth_decode_data(), _dbus_auth_encode_data(), _dbus_auth_get_buffer(), _dbus_auth_get_bytes_to_send(), _dbus_auth_get_guid_from_server(), _dbus_auth_ref(), _dbus_auth_return_buffer(), _dbus_auth_unref(), _dbus_babysitter_ref(), _dbus_babysitter_unref(), _dbus_connection_block_pending_call(), _dbus_connection_message_sent(), _dbus_connection_queue_received_message_link(), _dbus_connection_ref_unlocked(), _dbus_connection_send_and_unlock(), _dbus_connection_toggle_watch_unlocked(), _dbus_connection_unref_unlocked(), _dbus_counter_ref(), _dbus_counter_unref(), _dbus_credentials_from_current_process(), _dbus_credentials_from_uid(), _dbus_data_slot_allocator_alloc(), _dbus_data_slot_allocator_free(), _dbus_data_slot_list_get(), _dbus_data_slot_list_set(), _dbus_decompose_path(), _dbus_generate_random_ascii(), _dbus_hash_iter_get_int_key(), _dbus_hash_iter_get_string_key(), _dbus_hash_iter_get_two_strings_key(), _dbus_hash_iter_get_ulong_key(), _dbus_hash_iter_get_value(), _dbus_hash_iter_init(), _dbus_hash_iter_lookup(), _dbus_hash_iter_next(), _dbus_hash_iter_remove_entry(), _dbus_hash_iter_set_value(), _dbus_hash_table_free_preallocated_entry(), _dbus_hash_table_insert_int(), _dbus_hash_table_insert_pointer(), _dbus_hash_table_insert_string(), _dbus_hash_table_insert_string_preallocated(), _dbus_hash_table_insert_two_strings(), _dbus_hash_table_insert_ulong(), _dbus_hash_table_lookup_int(), _dbus_hash_table_lookup_pointer(), _dbus_hash_table_lookup_string(), _dbus_hash_table_lookup_two_strings(), _dbus_hash_table_lookup_ulong(), _dbus_hash_table_new(), _dbus_hash_table_remove_int(), _dbus_hash_table_remove_pointer(), _dbus_hash_table_remove_string(), _dbus_hash_table_remove_two_strings(), _dbus_hash_table_remove_ulong(), _dbus_hash_test(), _dbus_header_create(), _dbus_header_delete_field(), _dbus_header_get_field_basic(), _dbus_header_get_message_type(), _dbus_header_have_message_untrusted(), _dbus_header_load(), _dbus_header_set_field_basic(), _dbus_header_set_serial(), _dbus_keyring_new_homedir(), _dbus_list_copy(), _dbus_marshal_byteswap(), _dbus_marshal_read_basic(), _dbus_marshal_read_fixed_multi(), _dbus_marshal_read_uint32(), _dbus_marshal_set_basic(), _dbus_marshal_skip_basic(), _dbus_marshal_write_basic(), _dbus_marshal_write_fixed_multi(), _dbus_mem_pool_alloc(), _dbus_mem_pool_dealloc(), _dbus_mem_pool_new(), _dbus_message_get_network_data(), _dbus_message_iter_get_args_valist(), _dbus_message_loader_get_buffer(), _dbus_message_loader_get_is_corrupted(), _dbus_message_loader_queue_messages(), _dbus_message_loader_return_buffer(), _dbus_message_lock(), _dbus_message_remove_size_counter(), _dbus_message_set_serial(), _dbus_message_test(), _dbus_object_tree_get_user_data_unlocked(), _dbus_object_tree_ref(), _dbus_object_tree_register(), _dbus_object_tree_unref(), _dbus_object_tree_unregister_and_unlock(), _dbus_pending_call_complete_and_unlock(), _dbus_pending_call_new(), _dbus_pending_call_notify(), _dbus_read(), _dbus_read_credentials_unix_socket(), _dbus_server_finalize_base(), _dbus_server_ref_unlocked(), _dbus_server_toggle_watch(), _dbus_server_unref_unlocked(), _dbus_setenv(), _dbus_signature_test(), _dbus_string_append(), _dbus_string_append_len(), _dbus_string_copy_data(), _dbus_string_copy_data_len(), _dbus_string_copy_len(), _dbus_string_copy_to_buffer(), _dbus_string_delete(), _dbus_string_ends_with_c_str(), _dbus_string_equal_c_str(), _dbus_string_equal_substring(), _dbus_string_find_blank(), _dbus_string_find_byte_backward(), _dbus_string_find_to(), _dbus_string_get_byte(), _dbus_string_get_const_data_len(), _dbus_string_get_data_len(), _dbus_string_get_dirname(), _dbus_string_get_unichar(), _dbus_string_hex_decode(), _dbus_string_hex_encode(), _dbus_string_init_const(), _dbus_string_init_const_len(), _dbus_string_init_preallocated(), _dbus_string_insert_8_aligned(), _dbus_string_insert_alignment(), _dbus_string_insert_byte(), _dbus_string_insert_bytes(), _dbus_string_lengthen(), _dbus_string_move(), _dbus_string_move_len(), _dbus_string_parse_double(), _dbus_string_parse_uint(), _dbus_string_pop_line(), _dbus_string_replace_len(), _dbus_string_set_byte(), _dbus_string_set_length(), _dbus_string_shorten(), _dbus_string_skip_blank(), _dbus_string_skip_white(), _dbus_string_starts_with_c_str(), _dbus_string_steal_data(), _dbus_string_steal_data_len(), _dbus_string_test(), _dbus_string_validate_ascii(), _dbus_string_validate_nul(), _dbus_string_validate_utf8(), _dbus_swap_array(), _dbus_timeout_set_interval(), _dbus_timeout_unref(), _dbus_transport_disconnect(), _dbus_transport_do_iteration(), _dbus_transport_get_is_authenticated(), _dbus_transport_handle_watch(), _dbus_transport_init_base(), _dbus_transport_open(), _dbus_transport_queue_messages(), _dbus_transport_ref(), _dbus_transport_set_connection(), _dbus_transport_unref(), _dbus_type_reader_delete(), _dbus_type_reader_get_array_length(), _dbus_type_reader_get_current_type(), _dbus_type_reader_get_element_type(), _dbus_type_reader_greater_than(), _dbus_type_reader_init_types_only_from_mark(), _dbus_type_reader_read_basic(), _dbus_type_reader_read_fixed_multi(), _dbus_type_reader_read_raw(), _dbus_type_reader_recurse(), _dbus_type_reader_save_mark(), _dbus_type_reader_set_basic(), _dbus_type_signature_next(), _dbus_type_writer_unrecurse(), _dbus_type_writer_write_fixed_multi(), _dbus_unpack_uint16(), _dbus_unpack_uint32(), _dbus_user_database_get_system(), _dbus_user_database_lookup(), _dbus_user_database_ref(), _dbus_user_database_unref(), _dbus_validate_body_with_reason(), _dbus_validate_bus_name(), _dbus_validate_interface(), _dbus_validate_member(), _dbus_validate_path(), _dbus_validate_signature(), _dbus_validate_signature_with_reason(), _dbus_verbose_bytes(), _dbus_verbose_bytes_of_string(), _dbus_watch_new(), _dbus_watch_unref(), _dbus_write_two(), dbus_address_entry_get_value(), dbus_address_unescape_value(), dbus_bus_set_unique_name(), dbus_connection_borrow_message(), dbus_connection_ref(), dbus_connection_return_message(), dbus_connection_send_with_reply_and_block(), dbus_connection_steal_borrowed_message(), dbus_connection_unref(), dbus_error_has_name(), dbus_error_init(), dbus_error_is_set(), dbus_free(), dbus_message_ref(), dbus_message_unref(), dbus_parse_address(), dbus_pending_call_unref(), dbus_server_disconnect(), dbus_server_ref(), dbus_server_unref(), dbus_set_error(), dbus_set_error_const(), dbus_threads_init(), dbus_watch_get_enabled(), and dbus_watch_get_flags().

#define _dbus_assert_not_reached explanation   )     _dbus_real_assert_not_reached (explanation, __FILE__, __LINE__)
 

Aborts with an error message if called.

The given explanation will be printed.

Parameters:
explanation explanation of what happened if the code was reached.

Definition at line 117 of file dbus-internals.h.

Referenced by _dbus_become_daemon(), _dbus_hash_table_new(), _dbus_hash_test(), _dbus_header_have_message_untrusted(), _dbus_header_set_field_basic(), _dbus_marshal_read_basic(), _dbus_marshal_set_basic(), _dbus_marshal_skip_basic(), _dbus_marshal_write_basic(), _dbus_marshal_write_fixed_multi(), _dbus_mem_pool_dealloc(), _dbus_memory_test(), _dbus_message_test(), _dbus_signature_test(), _dbus_spawn_async_with_babysitter(), _dbus_string_test(), _dbus_timeout_list_remove_timeout(), _dbus_type_get_alignment(), _dbus_type_reader_recurse(), _dbus_type_writer_write_basic(), _dbus_type_writer_write_fixed_multi(), _dbus_watch_list_remove_watch(), and dbus_connection_dispatch().

#define _DBUS_DECLARE_GLOBAL_LOCK name   )     extern DBusMutex *_dbus_lock_##name
 

Expands to declaration of a global lock defined with _DBUS_DEFINE_GLOBAL_LOCK.

The lock must be added to the list to initialize in dbus_threads_init().

Definition at line 268 of file dbus-internals.h.

#define _DBUS_DEFINE_GLOBAL_LOCK name   )     DBusMutex *_dbus_lock_##name
 

Defines a global lock variable with the given name.

The lock must be added to the list to initialize in dbus_threads_init().

Definition at line 269 of file dbus-internals.h.

#define _DBUS_INT_TO_POINTER integer   )     ((void*)((long)(integer)))
 

Safely stuffs an integer into a pointer, to be extracted later with _DBUS_POINTER_TO_INT.

Only guaranteed to preserve 32 bits.

Parameters:
integer the integer to stuff into a pointer.

Definition at line 148 of file dbus-internals.h.

Referenced by _dbus_hash_table_insert_int(), _dbus_hash_table_lookup_int(), _dbus_hash_table_remove_int(), _dbus_hash_test(), and _dbus_validate_signature_with_reason().

#define _DBUS_MAX_SUN_PATH_LENGTH   99
 

Maximum length of the path to a UNIX domain socket, sockaddr_un::sun_path member.

POSIX requires that all systems support at least 100 bytes here, including the nul termination. We use 99 for the max value to allow for the nul.

We could probably also do sizeof (addr.sun_path) but this way we are the same on all platforms which is probably a good idea.

Referenced by _dbus_connect_unix_socket(), and _dbus_listen_unix_socket().

#define _DBUS_N_ELEMENTS array   )     ((int) (sizeof ((array)) / sizeof ((array)[0])))
 

Computes the number of elements in a fixed-size array using sizeof().

Parameters:
array the array to count elements in.

Definition at line 145 of file dbus-internals.h.

Referenced by _dbus_hash_table_new(), _dbus_mem_pool_test(), _dbus_message_test(), and _dbus_string_test().

#define _DBUS_POINTER_TO_INT pointer   )     ((long)(pointer))
 

Safely casts a void* to an integer; should only be used on void* that actually contain integers, for example one created with _DBUS_INT_TO_POINTER.

Only guaranteed to preserve 32 bits. (i.e. it's used to store 32-bit ints in pointers, but can't be used to store 64-bit pointers in ints.)

Parameters:
pointer pointer to extract an integer from.

Definition at line 147 of file dbus-internals.h.

Referenced by _dbus_hash_iter_get_int_key(), and _dbus_validate_signature_with_reason().

#define _DBUS_ZERO object   )     (memset (&(object), '\0', sizeof ((object))))
 

Sets all bits in an object to zero.

Parameters:
object the object to be zeroed.

Definition at line 150 of file dbus-internals.h.

Referenced by _dbus_connect_tcp_socket(), _dbus_connect_unix_socket(), _dbus_listen_tcp_socket(), and _dbus_listen_unix_socket().


Enumeration Type Documentation

enum ReadStatus
 

Enumeration for status of a read().

Enumerator:
READ_STATUS_OK  Read succeeded.
READ_STATUS_ERROR  Some kind of error.
READ_STATUS_EOF  EOF returned.

Definition at line 50 of file dbus-spawn.c.


Function Documentation

int _dbus_accept int  listen_fd  ) 
 

Accepts a connection on a listening socket.

Handles EINTR for you.

Parameters:
listen_fd the listen file descriptor
Returns:
the connection fd of the client, or -1 on error

Definition at line 1044 of file dbus-sysdeps.c.

dbus_int32_t _dbus_atomic_dec DBusAtomic atomic  ) 
 

Atomically decrement an integer.

Parameters:
atomic pointer to the integer to decrement
Returns:
the value before decrementing
Todo:
implement arch-specific faster atomic ops

Definition at line 1895 of file dbus-sysdeps.c.

References _DBUS_LOCK, _DBUS_UNLOCK, and DBusAtomic::value.

Referenced by _dbus_connection_unref_unlocked(), _dbus_server_unref_unlocked(), dbus_connection_unref(), dbus_message_unref(), dbus_pending_call_unref(), and dbus_server_unref().

dbus_int32_t _dbus_atomic_inc DBusAtomic atomic  ) 
 

Atomically increments an integer.

Parameters:
atomic pointer to the integer to increment
Returns:
the value before incrementing
Todo:
implement arch-specific faster atomic ops

Definition at line 1872 of file dbus-sysdeps.c.

References _DBUS_LOCK, _DBUS_UNLOCK, and DBusAtomic::value.

Referenced by _dbus_connection_ref_unlocked(), _dbus_server_ref_unlocked(), dbus_connection_ref(), dbus_message_ref(), dbus_pending_call_ref(), and dbus_server_ref().

dbus_bool_t _dbus_babysitter_get_child_exited DBusBabysitter sitter  ) 
 

Checks whether the child has exited, without blocking.

Parameters:
sitter the babysitter

Definition at line 611 of file dbus-spawn.c.

References FALSE, and LIVE_CHILDREN.

Referenced by _dbus_babysitter_set_child_exit_error().

void _dbus_babysitter_kill_child DBusBabysitter sitter  ) 
 

Blocks until the babysitter process gives us the PID of the spawned grandchild, then kills the spawned grandchild.

Parameters: