27#include "dbus-internals.h"
29#include "dbus-memory.h"
30#include "dbus-protocol.h"
31#include "dbus-shell.h"
32#include "dbus-string.h"
43unquote_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);
347tokenize_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);
440 if (_dbus_string_get_length (¤t_token) > 0)
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))
548_dbus_shell_parse_argv (
const char *command_line,
562 _dbus_verbose (
"Command line is NULL\n");
566 tokens = tokenize_command_line (command_line, error);
569 _dbus_verbose (
"No tokens for command line '%s'\n", command_line);
591 _DBUS_SET_OOM (error);
599 argv[i] = _dbus_shell_unquote (tmp_list->
data);
604 for (j = 0; j < i; j++)
608 _DBUS_SET_OOM (error);
void dbus_set_error_const(DBusError *error, const char *name, const char *message)
Assigns an error name and message to a DBusError.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
char * _dbus_strdup(const char *str)
Duplicates a string.
void _dbus_list_clear_full(DBusList **list, DBusFreeFunction function)
Free every link and every element in the list.
int _dbus_list_get_length(DBusList **list)
Gets the length of a list.
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
#define _dbus_list_get_next_link(list, link)
Gets the next link in the list, or NULL if there are no more links.
#define NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
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().
void dbus_free_string_array(char **str_array)
Frees a NULL-terminated array of strings.
#define DBUS_ERROR_INVALID_ARGS
Invalid arguments passed to a method call.
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as #_DBUS_STRING_I...
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.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Object representing an exception.
void * data
Data stored at this element.