27 #include "dbus-internals.h"
28 #include "dbus-list.h"
29 #include "dbus-memory.h"
30 #include "dbus-protocol.h"
31 #include "dbus-shell.h"
32 #include "dbus-string.h"
43 unquote_string_inplace (
char* str,
char** end)
53 if (!(*s ==
'"' || *s ==
'\''))
62 if (quote_char ==
'"')
169 _dbus_shell_unquote (
const char *quoted_string)
178 if (unquoted ==
NULL)
197 while (*start && !(*start ==
'"' || *start ==
'\''))
227 if (!unquote_string_inplace (start, &end))
332 _DBUS_SET_OOM (error);
339 _DBUS_SET_OOM (error);
347 tokenize_command_line (
const char *command_line,
DBusError *error)
355 current_quote =
'\0';
361 _DBUS_SET_OOM (error);
367 if (current_quote ==
'\\')
378 _DBUS_SET_OOM (error);
383 current_quote =
'\0';
385 else if (current_quote ==
'#')
388 while (*p && *p !=
'\n')
391 current_quote =
'\0';
396 else if (current_quote)
398 if (*p == current_quote &&
400 !(current_quote ==
'"' && quoted))
403 current_quote =
'\0';
412 _DBUS_SET_OOM (error);
421 if (!delimit_token (¤t_token, &retval, error))
428 _DBUS_SET_OOM (error);
442 if (!delimit_token (¤t_token, &retval, error))
449 _DBUS_SET_OOM (error);
468 _DBUS_SET_OOM (error);
485 _DBUS_SET_OOM (error);
503 if (!delimit_token (¤t_token, &retval, error))
553 _dbus_shell_parse_argv (
const char *command_line,
567 _dbus_verbose (
"Command line is NULL\n");
571 tokens = tokenize_command_line (command_line, error);
574 _dbus_verbose (
"No tokens for command line '%s'\n", command_line);
596 _DBUS_SET_OOM (error);
604 argv[i] = _dbus_shell_unquote (tmp_list->
data);
609 for (j = 0; j < i; j++)
613 _DBUS_SET_OOM (error);
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
#define NULL
A null pointer, defined appropriately for C or C++.
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
#define dbus_new(type, count)
Safe macro for using dbus_malloc().
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
void * data
Data stored at this element.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
#define _dbus_list_get_next_link(list, link)
Gets the next link in the list, or NULL if there are no more links.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
char * _dbus_string_get_data(DBusString *str)
Gets the raw character buffer from the string.
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.
int _dbus_string_get_length(const DBusString *str)
Gets the length of a string (not including nul termination).
Object representing an exception.
dbus_bool_t _dbus_string_append_byte(DBusString *str, unsigned char byte)
Appends a single byte to the string, returning FALSE if not enough memory.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init().
#define TRUE
Expands to "1".
void dbus_free_string_array(char **str_array)
Frees a NULL-terminated array of strings.
int _dbus_list_get_length(DBusList **list)
Gets the length of a list.
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_set_error_const(DBusError *error, const char *name, const char *message)
Assigns an error name and message to a DBusError.
char * _dbus_strdup(const char *str)
Duplicates a string.
#define DBUS_ERROR_INVALID_ARGS
Invalid arguments passed to a method call.
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL.