[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <debug/redir.h> int redir_cmdline_parse (const char *args, cmdline_t *cmd); |
For the rationale and general description of the debugger redirection issue, see redir_debug_init.
This function parses a command-line tail (i.e., without the program to
be invoked) passed as a string in args. For every redirection
directive in args, like `>> foo', it opens the file that is
the target of the redirection, and records in cmd the information
about these redirections. (See section redir_debug_init, for details of the
cmdline_t
structure that is used to hold this information.) The
command line with redirections removed is placed into
cmd->command
(typically, it will be used to call
v2loadimage
, see section v2loadimage), while the rest of information
is used by redir_to_child
and redir_to_debugger
to
redirect standard handles before and after calling run_child
.
The function returns zero in case of success, -1 otherwise. Failure usually means some kind of syntax error, like `>' without a file name following it; or a file name that isn't allowed by the underlying OS, like `lost+found' on DOS.
ANSI/ISO C | No |
POSIX | No |
/* Init command line storage. */ if (redir_debug_init (&child_cmd) == -1) fatal ("Cannot allocate redirection storage: not enough memory.\n"); /* Parse the command line and create redirections. */ if (strpbrk (args, "<>")) { if (redir_cmdline_parse (args, &child_cmd) == 0) args = child_cmd.command; else error ("Syntax error in command line."); } else child_cmd.command = strdup (args); cmdline = (char *) alloca (strlen (args) + 4); cmdline[0] = strlen (args); strcpy (cmdline + 1, args); cmdline[strlen (args) + 1] = 13; if (v2loadimage (exec_file, cmdline, start_state)) { printf ("Load failed for image %s\n", exec_file); exit (1); } |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |