/* * Init for Go testing. */ #include #include #include #include #include #include "networkconfig.h" /* * 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 /* end of file */