/* * 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$ */ #include #include #include #include #if defined(MAIN_USE_NETWORKING) #include #include "networkconfig.h" #endif #if defined(ENABLE_UNTAR_ROOT_FILESYSTEM) #include /* * The tarfile image is built automatically externally. */ #include "FilesystemImage.h" #endif /* * Using GNAT's Distributed Systems Annex support requires * each node in the system to have different pid's. In a * single CPU RTEMS system, it is always one. This lets the * user override the RTEMS default. */ #ifdef GNAT_PID #include pid_t getpid() { return GNAT_PID; } #endif /* * Set up first argument */ static int argc = 1; static char arg0[20] = "rtems"; static char *argv[20] = { arg0 }; #if defined(MAIN_USE_REQUIRES_COMMAND_LINE) #define COMMAND_LINE_MAXIMUM 200 #include #include void parse_arguments( char *buffer, size_t maximum_length ) { char *cp; char *linebuf = buffer; size_t length; for (;;) { #if defined(MAIN_COMMAND_LINE) strncpy (linebuf, MAIN_COMMAND_LINE, maximum_length); #else /* * Read a line */ printf (">>> %s ", argv[0]); fflush (stdout); fgets (linebuf, maximum_length, stdin); length = strnlen( linebuf, maximum_length ); if ( linebuf[length - 1] == '\n' || linebuf[length - 1] == '\r' ) { linebuf[length - 1] = '\0'; } #endif /* * Break line into arguments */ cp = linebuf; for (;;) { while (isspace (*cp)) *cp++ = '\0'; if (*cp == '\0') break; if (argc >= ((sizeof argv / sizeof argv[0]) - 1)) { printf ("Too many arguments.\n"); argc = 0; break; } argv[argc++] = cp; while (!isspace (*cp)) { if (*cp == '\0') break; cp++; } } if (argc > 1) { argv[argc] = NULL; break; } printf ("You must give some arguments!\n"); } #if defined(DEBUG_COMMAND_LINE_ARGUMENTS) { int i; for (i=0; i