diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-12-11 19:20:16 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-12-11 19:20:16 +0000 |
commit | 814d95887daac9891b56b0194390a087cb1248f0 (patch) | |
tree | 917f56778c637f9579a6ed7da9c66540a98ab50d /cpukit/libmisc/shell/shell_makeargs.c | |
parent | 2007-12-11 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-814d95887daac9891b56b0194390a087cb1248f0.tar.bz2 |
2007-12-11 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/Makefile.am, libmisc/shell/cmd_help.c, libmisc/shell/cmds.c,
libmisc/shell/internal.h, libmisc/shell/shell.c,
libmisc/shell/shell.h, libmisc/shell/shellconfig.h: Command set
processing now separated from main command loop. Addition of user
commands and aliases tested. Monitor registration now explicit.
* libmisc/shell/shell_cmdset.c, libmisc/shell/shell_makeargs.c,
libmisc/shell/write_file.c: New files.
Diffstat (limited to 'cpukit/libmisc/shell/shell_makeargs.c')
-rw-r--r-- | cpukit/libmisc/shell/shell_makeargs.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/cpukit/libmisc/shell/shell_makeargs.c b/cpukit/libmisc/shell/shell_makeargs.c new file mode 100644 index 0000000000..c73ff25745 --- /dev/null +++ b/cpukit/libmisc/shell/shell_makeargs.c @@ -0,0 +1,47 @@ +/* + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> + +int shell_make_args( + char *commandLine, + int *argc_p, + char **argv_p, + int max_args +) +{ + int argc; + char *command; + int status = 0; + + argc = 0; + command = commandLine; + + while ( 1 ) { + command = strtok( command, " \t\r\n" ); + if ( command == NULL ) + break; + argv_p[ argc++ ] = command; + command = '\0'; + if ( argc == (max_args-1) ) { + status = -1; + break; + } + } + argv_p[ argc ] = NULL; + *argc_p = argc; + return status; +} + |