Files
rtems/cpukit/libmisc/shell/shell_makeargs.c
Joel Sherrill a3ddb08bec 2008-03-04 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/Makefile.am, libmisc/shell/main_cp.c,
	libmisc/shell/main_cpuuse.c, libmisc/shell/main_date.c,
	libmisc/shell/main_mallocinfo.c, libmisc/shell/main_netstats.c,
	libmisc/shell/main_perioduse.c, libmisc/shell/main_stackuse.c,
	libmisc/shell/main_wkspaceinfo.c, libmisc/shell/print_heapinfo.c,
	libmisc/shell/shell.c, libmisc/shell/shell.h,
	libmisc/shell/shell_makeargs.c, libmisc/shell/shellconfig.c,
	libmisc/shell/shellconfig.h, libmisc/shell/write_file.c: Add initial
	capability to automatically execute a script from the filesystem. Add
	echo command from NetBSD and sleep command.
	* libmisc/shell/main_echo.c, libmisc/shell/main_sleep.c,
	libmisc/shell/shell_script.c: New files.
2008-03-05 02:49:35 +00:00

50 lines
876 B
C

/*
* Split string into argc/argv style argument list
*
* COPYRIGHT (c) 1989-2008.
* 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 rtems_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;
}