29#include "dbus-internals.h"
31#include "dbus-memory.h"
32#include "dbus-protocol.h"
33#include "dbus-shell.h"
34#include "dbus-string.h"
45unquote_string_inplace (
char* str,
char** end)
55 if (!(*s ==
'"' || *s ==
'\''))
64 if (quote_char ==
'"')
171_dbus_shell_unquote (
const char *quoted_string)
180 if (unquoted ==
NULL)
199 while (*start && !(*start ==
'"' || *start ==
'\''))
229 if (!unquote_string_inplace (start, &end))
334 _DBUS_SET_OOM (error);
341 _DBUS_SET_OOM (error);
349tokenize_command_line (
const char *command_line,
DBusError *error)
357 current_quote =
'\0';
363 _DBUS_SET_OOM (error);
369 if (current_quote ==
'\\')
380 _DBUS_SET_OOM (error);
385 current_quote =
'\0';
387 else if (current_quote ==
'#')
390 while (*p && *p !=
'\n')
393 current_quote =
'\0';
398 else if (current_quote)
400 if (*p == current_quote &&
402 !(current_quote ==
'"' && quoted))
405 current_quote =
'\0';
414 _DBUS_SET_OOM (error);
423 if (!delimit_token (¤t_token, &retval, error))
430 _DBUS_SET_OOM (error);
444 if (!delimit_token (¤t_token, &retval, error))
451 _DBUS_SET_OOM (error);
470 _DBUS_SET_OOM (error);
487 _DBUS_SET_OOM (error);
505 if (!delimit_token (¤t_token, &retval, error))
550_dbus_shell_parse_argv (
const char *command_line,
564 _dbus_verbose (
"Command line is NULL\n");
568 tokens = tokenize_command_line (command_line, error);
571 _dbus_verbose (
"No tokens for command line '%s'\n", command_line);
593 _DBUS_SET_OOM (error);
601 argv[i] = _dbus_shell_unquote (tmp_list->
data);
606 for (j = 0; j < i; j++)
610 _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.
char * _dbus_string_get_data(DBusString *str)
Gets the raw character buffer from the 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_IN...
int _dbus_string_get_length(const DBusString *str)
Gets the length of a string (not including nul termination).
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.
Object representing an exception.
void * data
Data stored at this element.