dbus-sysdeps.c
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-sysdeps.c Wrappers around system/libc features shared between UNIX and Windows (internal to D-Bus implementation)
*
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
*
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <config.h>
#include "dbus-internals.h"
#include "dbus-sysdeps.h"
#include "dbus-threads.h"
#include "dbus-protocol.h"
#include "dbus-string.h"
#include "dbus-list.h"
#include "dbus-misc.h"
/* NOTE: If you include any unix/windows-specific headers here, you are probably doing something
* wrong and should be putting some code in dbus-sysdeps-unix.c or dbus-sysdeps-win.c.
*
* These are the standard ANSI C headers...
*/
#if HAVE_LOCALE_H
#include <locale.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef DBUS_WIN
#include <stdlib.h>
#elif (defined __APPLE__)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#elif HAVE_DECL_ENVIRON && defined(HAVE_UNISTD_H)
# include <unistd.h>
#else
extern char **environ;
#endif
#ifdef DBUS_WIN
#include "dbus-sockets-win.h"
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#endif
void
_dbus_abort (void)
{
const char *s;
_dbus_print_backtrace ();
s = _dbus_getenv ("DBUS_BLOCK_ON_ABORT");
if (s && *s)
{
/* don't use _dbus_warn here since it can _dbus_abort() */
fprintf (stderr, " Process %lu sleeping for gdb attach\n", _dbus_pid_for_log ());
_dbus_sleep_milliseconds (1000 * 180);
}
abort ();
_dbus_exit (1); /* in case someone manages to ignore SIGABRT ? */
}
dbus_bool_t
dbus_setenv (const char *varname,
const char *value)
{
_dbus_assert (varname != NULL);
if (value == NULL)
{
#ifdef HAVE_UNSETENV
unsetenv (varname);
return TRUE;
#else
char *putenv_value;
size_t len;
len = strlen (varname);
/* Use system malloc to avoid memleaks that dbus_malloc
* will get upset about.
*/
putenv_value = malloc (len + 2);
if (putenv_value == NULL)
return FALSE;
strcpy (putenv_value, varname);
#if defined(DBUS_WIN)
strcat (putenv_value, "=");
#endif
return (putenv (putenv_value) == 0);
#endif
}
else
{
#ifdef HAVE_SETENV
return (setenv (varname, value, TRUE) == 0);
#else
char *putenv_value;
size_t len;
size_t varname_len;
size_t value_len;
varname_len = strlen (varname);
value_len = strlen (value);
len = varname_len + value_len + 1 /* '=' */ ;
/* Use system malloc to avoid memleaks that dbus_malloc
* will get upset about.
*/
putenv_value = malloc (len + 1);
if (putenv_value == NULL)
return FALSE;
strcpy (putenv_value, varname);
strcpy (putenv_value + varname_len, "=");
strcpy (putenv_value + varname_len + 1, value);
return (putenv (putenv_value) == 0);
#endif
}
}
const char*
_dbus_getenv (const char *varname)
{
/* Don't respect any environment variables if the current process is
* setuid. This is the equivalent of glibc's __secure_getenv().
*/
if (_dbus_check_setuid ())
return NULL;
return getenv (varname);
}
dbus_bool_t
_dbus_clearenv (void)
{
dbus_bool_t rc = TRUE;
#ifdef HAVE_CLEARENV
if (clearenv () != 0)
rc = FALSE;
#else
if (environ != NULL)
environ[0] = NULL;
#endif
return rc;
}
dbus_bool_t
_dbus_split_paths_and_append (DBusString *dirs,
const char *suffix,
DBusList **dir_list)
{
int start;
int i;
int len;
char *cpath;
DBusString file_suffix;
start = 0;
i = 0;
_dbus_string_init_const (&file_suffix, suffix);
len = _dbus_string_get_length (dirs);
while (_dbus_string_find (dirs, start, _DBUS_PATH_SEPARATOR, &i))
{
DBusString path;
if (!_dbus_string_init (&path))
goto oom;
if (!_dbus_string_copy_len (dirs,
start,
i - start,
&path,
0))
{
_dbus_string_free (&path);
goto oom;
}
_dbus_string_chop_white (&path);
/* check for an empty path */
if (_dbus_string_get_length (&path) == 0)
goto next;
if (!_dbus_concat_dir_and_file (&path,
&file_suffix))
{
_dbus_string_free (&path);
goto oom;
}
if (!_dbus_string_copy_data(&path, &cpath))
{
_dbus_string_free (&path);
goto oom;
}
if (!_dbus_list_append (dir_list, cpath))
{
_dbus_string_free (&path);
dbus_free (cpath);
goto oom;
}
next:
_dbus_string_free (&path);
start = i + 1;
}
if (start != len)
{
DBusString path;
if (!_dbus_string_init (&path))
goto oom;
if (!_dbus_string_copy_len (dirs,
start,
len - start,
&path,
0))
{
_dbus_string_free (&path);
goto oom;
}
if (!_dbus_concat_dir_and_file (&path,
&file_suffix))
{
_dbus_string_free (&path);
goto oom;
}
if (!_dbus_string_copy_data(&path, &cpath))
{
_dbus_string_free (&path);
goto oom;
}
if (!_dbus_list_append (dir_list, cpath))
{
_dbus_string_free (&path);
dbus_free (cpath);
goto oom;
}
_dbus_string_free (&path);
}
return TRUE;
oom:
_dbus_list_clear_full (dir_list, dbus_free);
return FALSE;
}
dbus_bool_t
_dbus_string_parse_int (const DBusString *str,
int start,
long *value_return,
int *end_return)
{
long v;
const char *p;
char *end;
p = _dbus_string_get_const_data_len (str, start,
_dbus_string_get_length (str) - start);
end = NULL;
_dbus_set_errno_to_zero ();
v = strtol (p, &end, 0);
if (end == NULL || end == p || errno != 0)
return FALSE;
if (value_return)
*value_return = v;
if (end_return)
*end_return = start + (end - p);
return TRUE;
}
dbus_bool_t
_dbus_string_parse_uint (const DBusString *str,
int start,
unsigned long *value_return,
int *end_return)
{
unsigned long v;
const char *p;
char *end;
p = _dbus_string_get_const_data_len (str, start,
_dbus_string_get_length (str) - start);
end = NULL;
_dbus_set_errno_to_zero ();
v = strtoul (p, &end, 0);
if (end == NULL || end == p || errno != 0)
return FALSE;
if (value_return)
*value_return = v;
if (end_return)
*end_return = start + (end - p);
return TRUE;
}
dbus_bool_t
_dbus_string_parse_int64 (const DBusString *str,
int start,
dbus_int64_t *value_return,
int *end_return)
{
dbus_int64_t v;
const char *p;
char *end;
p = _dbus_string_get_const_data_len (str, start,
_dbus_string_get_length (str) - start);
end = NULL;
_dbus_set_errno_to_zero ();
v = strtoll (p, &end, 0);
if (end == NULL || end == p || errno != 0)
return FALSE;
if (value_return)
*value_return = v;
if (end_return)
*end_return = start + (end - p);
return TRUE;
}
/* DBusString group */
dbus_bool_t
_dbus_generate_random_bytes_buffer (char *buffer,
int n_bytes,
DBusError *error)
{
DBusString str;
if (!_dbus_string_init (&str))
{
_DBUS_SET_OOM (error);
return FALSE;
}
if (!_dbus_generate_random_bytes (&str, n_bytes, error))
{
_dbus_string_free (&str);
return FALSE;
}
_dbus_string_copy_to_buffer (&str, buffer, n_bytes);
_dbus_string_free (&str);
return TRUE;
}
dbus_bool_t
_dbus_generate_random_ascii (DBusString *str,
int n_bytes,
DBusError *error)
{
static const char letters[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
int i;
int len;
if (!_dbus_generate_random_bytes (str, n_bytes, error))
return FALSE;
len = _dbus_string_get_length (str);
i = len - n_bytes;
while (i < len)
{
_dbus_string_set_byte (str, i,
letters[_dbus_string_get_byte (str, i) %
(sizeof (letters) - 1)]);
++i;
}
_dbus_assert (_dbus_string_validate_ascii (str, len - n_bytes,
n_bytes));
return TRUE;
}
const char*
_dbus_error_from_errno (int error_number)
{
switch (error_number)
{
case 0:
return DBUS_ERROR_FAILED;
#ifdef EPROTONOSUPPORT
case EPROTONOSUPPORT:
return DBUS_ERROR_NOT_SUPPORTED;
#elif defined(WSAEPROTONOSUPPORT)
case WSAEPROTONOSUPPORT:
return DBUS_ERROR_NOT_SUPPORTED;
#endif
#ifdef EAFNOSUPPORT
case EAFNOSUPPORT:
return DBUS_ERROR_NOT_SUPPORTED;
#elif defined(WSAEAFNOSUPPORT)
case WSAEAFNOSUPPORT:
return DBUS_ERROR_NOT_SUPPORTED;
#endif
#ifdef ENFILE
case ENFILE:
return DBUS_ERROR_LIMITS_EXCEEDED; /* kernel out of memory */
#endif
#ifdef EMFILE
case EMFILE:
return DBUS_ERROR_LIMITS_EXCEEDED;
#endif
#ifdef EACCES
case EACCES:
return DBUS_ERROR_ACCESS_DENIED;
#endif
#ifdef EPERM
case EPERM:
return DBUS_ERROR_ACCESS_DENIED;
#endif
#ifdef ENOBUFS
case ENOBUFS:
return DBUS_ERROR_NO_MEMORY;
#endif
#ifdef ENOMEM
case ENOMEM:
return DBUS_ERROR_NO_MEMORY;
#endif
#ifdef ECONNREFUSED
case ECONNREFUSED:
return DBUS_ERROR_NO_SERVER;
#elif defined(WSAECONNREFUSED)
case WSAECONNREFUSED:
return DBUS_ERROR_NO_SERVER;
#endif
#ifdef ETIMEDOUT
case ETIMEDOUT:
return DBUS_ERROR_TIMEOUT;
#elif defined(WSAETIMEDOUT)
case WSAETIMEDOUT:
return DBUS_ERROR_TIMEOUT;
#endif
#ifdef ENETUNREACH
case ENETUNREACH:
return DBUS_ERROR_NO_NETWORK;
#elif defined(WSAENETUNREACH)
case WSAENETUNREACH:
return DBUS_ERROR_NO_NETWORK;
#endif
#ifdef EADDRINUSE
case EADDRINUSE:
return DBUS_ERROR_ADDRESS_IN_USE;
#elif defined(WSAEADDRINUSE)
case WSAEADDRINUSE:
return DBUS_ERROR_ADDRESS_IN_USE;
#endif
#ifdef EEXIST
case EEXIST:
return DBUS_ERROR_FILE_EXISTS;
#endif
#ifdef ENOENT
case ENOENT:
return DBUS_ERROR_FILE_NOT_FOUND;
#endif
default:
return DBUS_ERROR_FAILED;
}
}
const char*
_dbus_error_from_system_errno (void)
{
return _dbus_error_from_errno (errno);
}
void
_dbus_set_errno_to_zero (void)
{
#ifdef DBUS_WINCE
SetLastError (0);
#else
errno = 0;
#endif
}
dbus_bool_t
_dbus_get_is_errno_enomem (int e)
{
return e == ENOMEM;
}
dbus_bool_t
_dbus_get_is_errno_eintr (int e)
{
return e == EINTR;
}
dbus_bool_t
_dbus_get_is_errno_epipe (int e)
{
return e == EPIPE;
}
dbus_bool_t
_dbus_get_is_errno_etoomanyrefs (int e)
{
#ifdef ETOOMANYREFS
return e == ETOOMANYREFS;
#else
return FALSE;
#endif
}
const char*
_dbus_strerror_from_errno (void)
{
return _dbus_strerror (errno);
}
void
_dbus_log (DBusSystemLogSeverity severity,
const char *msg,
...)
{
va_list args;
va_start (args, msg);
_dbus_logv (severity, msg, args);
va_end (args);
}
/*
* Try to convert the IPv4 or IPv6 address pointed to by
* sockaddr_pointer into a string.
*
* @param sockaddr_pointer A struct sockaddr_in or struct sockaddr_in6
* @param len The length of the struct pointed to by sockaddr_pointer
* @param string An array to write the address into
* @param string_len Length of string (should usually be at least INET6_ADDRSTRLEN)
* @param family_name Used to return "ipv4" or "ipv6", or NULL to ignore
* @param port Used to return the port number, or NULL to ignore
* @returns #FALSE with errno set if the address family was not understood
*/
dbus_bool_t
_dbus_inet_sockaddr_to_string (const void *sockaddr_pointer,
size_t len,
char *string,
size_t string_len,
const char **family_name,
dbus_uint16_t *port,
DBusError *error)
{
union
{
struct sockaddr sa;
struct sockaddr_storage storage;
struct sockaddr_in ipv4;
struct sockaddr_in6 ipv6;
} addr;
int saved_errno;
if (len > sizeof (addr))
return FALSE;
_DBUS_ZERO (addr);
memcpy (&addr, sockaddr_pointer, len);
switch (addr.sa.sa_family)
{
case AF_INET:
if (inet_ntop (AF_INET, &addr.ipv4.sin_addr, string, string_len) != NULL)
{
if (family_name != NULL)
*family_name = "ipv4";
if (port != NULL)
*port = ntohs (addr.ipv4.sin_port);
return TRUE;
}
else
{
saved_errno = _dbus_get_low_level_socket_errno ();
dbus_set_error (error, _dbus_error_from_errno (saved_errno),
"Failed to get identity of IPv4 socket: %s",
_dbus_strerror (saved_errno));
}
return FALSE;
#ifdef AF_INET6
case AF_INET6:
if (inet_ntop (AF_INET6, &addr.ipv6.sin6_addr, string, string_len) != NULL)
{
if (family_name != NULL)
*family_name = "ipv6";
if (port != NULL)
*port = ntohs (addr.ipv6.sin6_port);
return TRUE;
}
else
{
saved_errno = _dbus_get_low_level_socket_errno ();
dbus_set_error (error, _dbus_error_from_errno (saved_errno),
"Failed to get identity of IPv6 socket: %s",
_dbus_strerror (saved_errno));
}
return FALSE;
#endif
default:
dbus_set_error (error, DBUS_ERROR_FAILED,
"Failed to get identity of socket: unknown family");
return FALSE;
}
}
/*
* Format an error appropriate for saved_errno for the IPv4 or IPv6
* address pointed to by sockaddr_pointer of length sockaddr_len.
*
* @param error The error to set
* @param sockaddr_pointer A struct sockaddr_in or struct sockaddr_in6
* @param len The length of the struct pointed to by sockaddr_pointer
* @param description A prefix like "Failed to listen on socket"
* @param saved_errno The OS-level error number to use
*/
void
_dbus_set_error_with_inet_sockaddr (DBusError *error,
const void *sockaddr_pointer,
size_t len,
const char *description,
int saved_errno)
{
char string[INET6_ADDRSTRLEN];
dbus_uint16_t port;
const struct sockaddr *addr = sockaddr_pointer;
if (_dbus_inet_sockaddr_to_string (sockaddr_pointer, len,
string, sizeof (string), NULL, &port,
NULL))
{
dbus_set_error (error, _dbus_error_from_errno (saved_errno),
"%s \"%s\" port %u: %s",
description, string, port, _dbus_strerror (saved_errno));
}
else
{
dbus_set_error (error, _dbus_error_from_errno (saved_errno),
"%s <address of unknown family %d>: %s",
description, addr->sa_family,
_dbus_strerror (saved_errno));
}
}
void
_dbus_combine_tcp_errors (DBusList **sources,
const char *summary,
const char *host,
const char *port,
DBusError *dest)
{
DBusString message = _DBUS_STRING_INIT_INVALID;
if (_dbus_list_length_is_one (sources))
{
/* If there was exactly one error, just use it */
dbus_move_error (_dbus_list_get_first (sources), dest);
}
else
{
DBusList *iter;
const char *name = NULL;
/* If there was more than one error, concatenate all the
* errors' diagnostic messages, and use their common error
* name, or DBUS_ERROR_FAILED if more than one name is
* represented */
if (!_dbus_string_init (&message))
{
_DBUS_SET_OOM (dest);
goto out;
}
for (iter = _dbus_list_get_first_link (sources);
iter != NULL;
iter = _dbus_list_get_next_link (sources, iter))
{
DBusError *error = iter->data;
if (name == NULL)
{
/* no error names known yet, try to use this one */
name = error->name;
}
else if (strcmp (name, error->name) != 0)
{
/* errors of two different names exist, reconcile by
* using FAILED */
name = DBUS_ERROR_FAILED;
}
if ((_dbus_string_get_length (&message) > 0 &&
!_dbus_string_append (&message, "; ")) ||
!_dbus_string_append (&message, error->message))
{
_DBUS_SET_OOM (dest);
goto out;
}
}
if (name == NULL)
name = DBUS_ERROR_FAILED;
dbus_set_error (dest, name, "%s to \"%s\":%s (%s)",
summary, host ? host : "*", port ? port : "0",
_dbus_string_get_const_data (&message));
}
out:
_dbus_string_free (&message);
}
/* tests in dbus-sysdeps-util.c */
dbus_move_error
void dbus_move_error(DBusError *src, DBusError *dest)
Moves an error src into dest, freeing src and overwriting dest.
Definition dbus-errors.c:281
dbus_set_error
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
Definition dbus-errors.c:356
_dbus_get_is_errno_epipe
dbus_bool_t _dbus_get_is_errno_epipe(int e)
See if errno is EPIPE.
Definition dbus-sysdeps.c:700
_dbus_get_is_errno_etoomanyrefs
dbus_bool_t _dbus_get_is_errno_etoomanyrefs(int e)
See if errno is ETOOMANYREFS.
Definition dbus-sysdeps.c:710
_dbus_assert
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
Definition dbus-internals.h:153
_dbus_log
void _dbus_log(DBusSystemLogSeverity severity, const char *msg,...)
Log a message to the system log file (e.g.
Definition dbus-sysdeps.c:736
_dbus_error_from_errno
const char * _dbus_error_from_errno(int error_number)
Converts a UNIX errno, or Windows errno or WinSock error value into a DBusError name.
Definition dbus-sysdeps.c:565
_dbus_generate_random_ascii
dbus_bool_t _dbus_generate_random_ascii(DBusString *str, int n_bytes, DBusError *error)
Generates the given number of random bytes, where the bytes are chosen from the alphanumeric ASCII su...
Definition dbus-sysdeps.c:525
_dbus_error_from_system_errno
const char * _dbus_error_from_system_errno(void)
Converts the current system errno value into a DBusError name.
Definition dbus-sysdeps.c:657
_dbus_strerror_from_errno
const char * _dbus_strerror_from_errno(void)
Get error message from errno.
Definition dbus-sysdeps.c:724
_dbus_get_is_errno_eintr
dbus_bool_t _dbus_get_is_errno_eintr(int e)
See if errno is EINTR.
Definition dbus-sysdeps.c:690
_DBUS_ZERO
#define _DBUS_ZERO(object)
Sets all bits in an object to zero.
Definition dbus-internals.h:194
_dbus_set_errno_to_zero
void _dbus_set_errno_to_zero(void)
Assign 0 to the global errno variable.
Definition dbus-sysdeps.c:666
_dbus_get_is_errno_enomem
dbus_bool_t _dbus_get_is_errno_enomem(int e)
See if errno is ENOMEM.
Definition dbus-sysdeps.c:680
_dbus_generate_random_bytes_buffer
dbus_bool_t _dbus_generate_random_bytes_buffer(char *buffer, int n_bytes, DBusError *error)
Fills n_bytes of the given buffer with random bytes.
Definition dbus-sysdeps.c:491
_dbus_list_get_first_link
DBusList * _dbus_list_get_first_link(DBusList **list)
Gets the first link in the list.
Definition dbus-list.c:597
_dbus_list_length_is_one
dbus_bool_t _dbus_list_length_is_one(DBusList **list)
Check whether length is exactly one.
Definition dbus-list.c:813
_dbus_list_clear_full
void _dbus_list_clear_full(DBusList **list, DBusFreeFunction function)
Free every link and every element in the list.
Definition dbus-list.c:570
_dbus_list_get_first
void * _dbus_list_get_first(DBusList **list)
Gets the first data in the list.
Definition dbus-list.c:642
_dbus_list_append
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
Definition dbus-list.c:273
_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:121
NULL
#define NULL
A null pointer, defined appropriately for C or C++.
Definition dbus-macros.h:51
TRUE
#define TRUE
Expands to "1".
Definition dbus-macros.h:41
FALSE
#define FALSE
Expands to "0".
Definition dbus-macros.h:44
dbus_free
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition dbus-memory.c:710
dbus_setenv
dbus_bool_t dbus_setenv(const char *varname, const char *value)
Wrapper for setenv().
Definition dbus-sysdeps.c:126
DBUS_ERROR_TIMEOUT
#define DBUS_ERROR_TIMEOUT
Certain timeout errors, possibly ETIMEDOUT on a socket.
Definition dbus-protocol.h:389
DBUS_ERROR_NOT_SUPPORTED
#define DBUS_ERROR_NOT_SUPPORTED
Requested operation isn't supported (like ENOSYS on UNIX).
Definition dbus-protocol.h:375
DBUS_ERROR_ADDRESS_IN_USE
#define DBUS_ERROR_ADDRESS_IN_USE
Can't bind a socket since its address is in use (i.e.
Definition dbus-protocol.h:393
DBUS_ERROR_ACCESS_DENIED
#define DBUS_ERROR_ACCESS_DENIED
Security restrictions don't allow doing what you're trying to do.
Definition dbus-protocol.h:379
DBUS_ERROR_NO_SERVER
#define DBUS_ERROR_NO_SERVER
Unable to connect to server (probably caused by ECONNREFUSED on a socket).
Definition dbus-protocol.h:383
DBUS_ERROR_FILE_EXISTS
#define DBUS_ERROR_FILE_EXISTS
Existing file and the operation you're using does not silently overwrite.
Definition dbus-protocol.h:401
DBUS_ERROR_LIMITS_EXCEEDED
#define DBUS_ERROR_LIMITS_EXCEEDED
Some limited resource is exhausted.
Definition dbus-protocol.h:377
DBUS_ERROR_NO_NETWORK
#define DBUS_ERROR_NO_NETWORK
No network access (probably ENETUNREACH on a socket).
Definition dbus-protocol.h:391
DBUS_ERROR_FAILED
#define DBUS_ERROR_FAILED
A generic error; "something went wrong" - see the error message for more.
Definition dbus-protocol.h:361
DBUS_ERROR_NO_MEMORY
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
Definition dbus-protocol.h:363
DBUS_ERROR_FILE_NOT_FOUND
#define DBUS_ERROR_FILE_NOT_FOUND
Missing file.
Definition dbus-protocol.h:399
_dbus_string_append
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
Definition dbus-string.c:980
_dbus_string_init
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
Definition dbus-string.c:182
_dbus_string_init_const
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string.
Definition dbus-string.c:197
_dbus_string_parse_int64
dbus_bool_t _dbus_string_parse_int64(const DBusString *str, int start, dbus_int64_t *value_return, int *end_return)
Parses a dbus_int64_t integer contained in a DBusString.
Definition dbus-sysdeps.c:449
_dbus_string_find
dbus_bool_t _dbus_string_find(const DBusString *str, int start, const char *substr, int *found)
Finds the given substring in the string, returning TRUE and filling in the byte index where the subst...
Definition dbus-string.c:1666
_dbus_string_free
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as _DBUS_STRING_IN...
Definition dbus-string.c:278
_dbus_string_copy_data
dbus_bool_t _dbus_string_copy_data(const DBusString *str, char **data_return)
Copies the data from the string into a char*.
Definition dbus-string.c:717
_dbus_string_parse_uint
dbus_bool_t _dbus_string_parse_uint(const DBusString *str, int start, unsigned long *value_return, int *end_return)
Parses an unsigned integer contained in a DBusString.
Definition dbus-sysdeps.c:410
_dbus_string_parse_int
dbus_bool_t _dbus_string_parse_int(const DBusString *str, int start, long *value_return, int *end_return)
Parses an integer contained in a DBusString.
Definition dbus-sysdeps.c:371
_dbus_string_validate_ascii
dbus_bool_t _dbus_string_validate_ascii(const DBusString *str, int start, int len)
Checks that the given range of the string is valid ASCII with no nul bytes.
Definition dbus-string.c:2573
_dbus_string_chop_white
void _dbus_string_chop_white(DBusString *str)
Deletes leading and trailing whitespace.
Definition dbus-string.c:2051
_dbus_string_copy_len
dbus_bool_t _dbus_string_copy_len(const DBusString *source, int start, int len, DBusString *dest, int insert_at)
Like _dbus_string_copy(), but can copy a segment from the middle of the source string.
Definition dbus-string.c:1437
_dbus_string_copy_to_buffer
void _dbus_string_copy_to_buffer(const DBusString *str, char *buffer, int avail_len)
Copies the contents of a DBusString into a different buffer.
Definition dbus-string.c:742
_dbus_logv
void _dbus_logv(DBusSystemLogSeverity severity, const char *msg, va_list args)
Log a message to the system log file (e.g.
Definition dbus-sysdeps-unix.c:5208
_dbus_pid_for_log
unsigned long _dbus_pid_for_log(void)
The only reason this is separate from _dbus_getpid() is to allow it on Windows for logging but not fo...
Definition dbus-sysdeps-unix.c:3157
_dbus_clearenv
dbus_bool_t _dbus_clearenv(void)
Wrapper for clearenv().
Definition dbus-sysdeps.c:213
_dbus_exit
void _dbus_exit(int code)
Exit the process, returning the given value.
Definition dbus-sysdeps-unix.c:3641
_dbus_getenv
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
Definition dbus-sysdeps.c:197
_dbus_check_setuid
dbus_bool_t _dbus_check_setuid(void)
NOTE: If you modify this function, please also consider making the corresponding change in GLib.
Definition dbus-sysdeps-unix.c:5002
_dbus_sleep_milliseconds
void _dbus_sleep_milliseconds(int milliseconds)
Sleeps the given number of milliseconds.
Definition dbus-sysdeps-unix.c:3542
_dbus_generate_random_bytes
dbus_bool_t _dbus_generate_random_bytes(DBusString *str, int n_bytes, DBusError *error)
Generates the given number of securely random bytes, using the best mechanism we can come up with.
Definition dbus-sysdeps-unix.c:3572
_dbus_abort
void _dbus_abort(void)
Aborts the program with SIGABRT (dumping core).
Definition dbus-sysdeps.c:89
_dbus_concat_dir_and_file
dbus_bool_t _dbus_concat_dir_and_file(DBusString *dir, const DBusString *next_component)
Appends the given filename to the given directory.
Definition dbus-sysdeps-unix.c:3497
_dbus_split_paths_and_append
dbus_bool_t _dbus_split_paths_and_append(DBusString *dirs, const char *suffix, DBusList **dir_list)
Split paths into a list of char strings.
Definition dbus-sysdeps.c:238
_dbus_print_backtrace
void _dbus_print_backtrace(void)
On GNU libc systems, print a crude backtrace to stderr.
Definition dbus-sysdeps-unix.c:3842
dbus_uint16_t
unsigned short dbus_uint16_t
A 16-bit unsigned integer on all platforms.
Definition dbus-arch-deps.h:48
dbus_int64_t
_DBUS_GNUC_EXTENSION typedef long dbus_int64_t
A 64-bit signed integer.
Definition dbus-arch-deps.h:37
dbus_bool_t
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition dbus-types.h:37
DBusError
Object representing an exception.
Definition dbus-errors.h:51
DBusError::name
const char * name
public error name field
Definition dbus-errors.h:52
DBusError::message
const char * message
public error message field
Definition dbus-errors.h:53
DBusList
A node in a linked list.
Definition dbus-list.h:37
DBusList::data
void * data
Data stored at this element.
Definition dbus-list.h:40
DBusString
Definition dbus-string.h:47