26 #include "dbus-internals.h"    27 #include "dbus-sysdeps.h"    28 #include "dbus-threads.h"    29 #include "dbus-protocol.h"    30 #include "dbus-string.h"    31 #include "dbus-list.h"    32 #include "dbus-misc.h"    52 #elif (defined __APPLE__)    53 # include <crt_externs.h>    54 # define environ (*_NSGetEnviron())    56 extern char **environ;
   128       len = strlen (varname);
   134       putenv_value = malloc (len + 2);
   135       if (putenv_value == 
NULL)
   138       strcpy (putenv_value, varname);
   139 #if defined(DBUS_WIN)   140       strcat (putenv_value, 
"=");
   143       return (putenv (putenv_value) == 0);
   149       return (setenv (varname, value, 
TRUE) == 0);
   156       varname_len = strlen (varname);
   157       value_len = strlen (value);
   159       len = varname_len + value_len + 1  ;
   165       putenv_value = malloc (len + 1);
   166       if (putenv_value == 
NULL)
   169       strcpy (putenv_value, varname);
   170       strcpy (putenv_value + varname_len, 
"=");
   171       strcpy (putenv_value + varname_len + 1, value);
   173       return (putenv (putenv_value) == 0);
   192   return getenv (varname);
   206   if (clearenv () != 0)
   241    len = _dbus_string_get_length (dirs);
   263         if (_dbus_string_get_length (&path) == 0)
   358 #define MAX_LONG_LEN ((sizeof (long) * 8 + 2) / 3 + 1)     363   orig_len = _dbus_string_get_length (str);
   370   snprintf (buf, MAX_LONG_LEN, 
"%ld", value);
   396 #define MAX_ULONG_LEN (MAX_LONG_LEN * 2)   401   orig_len = _dbus_string_get_length (str);
   408   snprintf (buf, MAX_ULONG_LEN, 
"%lu", value);
   444   p = _dbus_string_get_const_data_len (str, start,
   445                                        _dbus_string_get_length (str) - start);
   449   v = strtol (p, &end, 0);
   450   if (end == 
NULL || end == p || errno != 0)
   456     *end_return = start + (end - p);
   476                          unsigned long    *value_return,
   483   p = _dbus_string_get_const_data_len (str, start,
   484                                        _dbus_string_get_length (str) - start);
   488   v = strtoul (p, &end, 0);
   489   if (end == 
NULL || end == p || errno != 0)
   495     *end_return = start + (end - p);
   524       _DBUS_SET_OOM (error);
   554   static const char letters[] =
   555     "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
   562   len = _dbus_string_get_length (str);
   566       _dbus_string_set_byte (str, i,
   567                              letters[_dbus_string_get_byte (str, i) %
   568                                      (
sizeof (letters) - 1)]);
   592   switch (error_number)
   597 #ifdef EPROTONOSUPPORT   598     case EPROTONOSUPPORT:
   600 #elif defined(WSAEPROTONOSUPPORT)   601     case WSAEPROTONOSUPPORT:
   607 #elif defined(WSAEAFNOSUPPORT)   608     case WSAEAFNOSUPPORT:
   638 #elif defined(WSAECONNREFUSED)   639     case WSAECONNREFUSED:
   645 #elif defined(WSAETIMEDOUT)   652 #elif defined(WSAENETUNREACH)   659 #elif defined(WSAEADDRINUSE)   738   return e == ETOOMANYREFS;
   751   return _dbus_strerror (errno);
 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. 
void _dbus_string_copy_to_buffer(const DBusString *str, char *buffer, int avail_len)
Copies the contents of a DBusString into a different buffer. 
#define DBUS_ERROR_FILE_NOT_FOUND
Missing file. 
#define DBUS_ERROR_FILE_EXISTS
Existing file and the operation you're using does not silently overwrite. 
dbus_bool_t _dbus_split_paths_and_append(DBusString *dirs, const char *suffix, DBusList **dir_list)
Split paths into a list of char strings. 
dbus_bool_t _dbus_string_append_uint(DBusString *str, unsigned long value)
Appends an unsigned integer to a DBusString. 
#define NULL
A null pointer, defined appropriately for C or C++. 
#define DBUS_ERROR_TIMEOUT
Certain timeout errors, possibly ETIMEDOUT on a socket. 
dbus_bool_t _dbus_string_lengthen(DBusString *str, int additional_length)
Makes a string longer by the given number of bytes. 
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0(). 
#define DBUS_ERROR_NOT_SUPPORTED
Requested operation isn't supported (like ENOSYS on UNIX). 
dbus_bool_t _dbus_string_append_int(DBusString *str, long value)
Appends an integer to a DBusString. 
void _dbus_string_chop_white(DBusString *str)
Deletes leading and trailing whitespace. 
#define _dbus_assert(condition)
Aborts with an error message if the condition is false. 
dbus_bool_t _dbus_check_setuid(void)
NOTE: If you modify this function, please also consider making the corresponding change in GLib...
dbus_bool_t _dbus_concat_dir_and_file(DBusString *dir, const DBusString *next_component)
Appends the given filename to the given directory. 
char * _dbus_string_get_data_len(DBusString *str, int start, int len)
Gets a sub-portion of the raw character buffer from the string. 
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string. 
void _dbus_string_shorten(DBusString *str, int length_to_remove)
Makes a string shorter by the given number of bytes. 
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...
dbus_bool_t _dbus_get_is_errno_etoomanyrefs(int e)
See if errno is ETOOMANYREFS. 
void _dbus_abort(void)
Aborts the program with SIGABRT (dumping core). 
const char * _dbus_error_from_errno(int error_number)
Converts a UNIX errno, or Windows errno or WinSock error value into a DBusError name. 
dbus_bool_t _dbus_clearenv(void)
Wrapper for clearenv(). 
#define DBUS_ERROR_NO_SERVER
Unable to connect to server (probably caused by ECONNREFUSED on a socket). 
dbus_bool_t _dbus_get_is_errno_epipe(int e)
See if errno is EPIPE. 
dbus_bool_t _dbus_string_copy_data(const DBusString *str, char **data_return)
Copies the data from the string into a char*. 
dbus_bool_t dbus_setenv(const char *varname, const char *value)
Wrapper for setenv(). 
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE. 
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string. 
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...
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list. 
void _dbus_list_foreach(DBusList **list, DBusForeachFunction function, void *data)
Calls the given function for each element in the list. 
dbus_bool_t _dbus_get_is_errno_eintr(int e)
See if errno is EINTR. 
Object representing an exception. 
#define DBUS_ERROR_ADDRESS_IN_USE
Can't bind a socket since its address is in use (i.e. 
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(). 
#define TRUE
Expands to "1". 
#define DBUS_ERROR_FAILED
A generic error; "something went wrong" - see the error message for more. 
void _dbus_exit(int code)
Exit the process, returning the given value. 
const char * _dbus_strerror_from_errno(void)
Get error message from errno. 
const char * _dbus_error_from_system_errno(void)
Converts the current system errno value into a DBusError name. 
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...
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. 
#define DBUS_ERROR_ACCESS_DENIED
Security restrictions don't allow doing what you're trying to do. 
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...
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation. 
void(* DBusForeachFunction)(void *element, void *data)
Used to iterate over each item in a collection, such as a DBusList. 
#define FALSE
Expands to "0". 
void _dbus_print_backtrace(void)
On GNU libc systems, print a crude backtrace to stderr. 
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. 
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. 
void _dbus_sleep_milliseconds(int milliseconds)
Sleeps the given number of milliseconds. 
const char * _dbus_getenv(const char *varname)
Wrapper for getenv(). 
#define DBUS_ERROR_NO_NETWORK
No network access (probably ENETUNREACH on a socket). 
void _dbus_set_errno_to_zero(void)
Assign 0 to the global errno variable. 
#define DBUS_ERROR_LIMITS_EXCEEDED
Some limited resource is exhausted. 
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. 
dbus_bool_t _dbus_get_is_errno_enomem(int e)
See if errno is ENOMEM. 
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL.