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);