cmdlinelib.c now calls system() rather than doing its own tokenisation
(which was extremely heavy on calls to malloc()). Moved include/command.h to include/gpxe/command.h, since it's gPXE-specific.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "command.h"
|
||||
#include "console.h"
|
||||
#include <string.h>
|
||||
#include <vsprintf.h>
|
||||
#include <gpxe/tables.h>
|
||||
#include <gpxe/command.h>
|
||||
|
||||
static struct command cmd_start[0] __table_start ( commands );
|
||||
static struct command cmd_end[0] __table_end ( commands );
|
||||
@@ -12,36 +12,19 @@ static int cmd_help_exec ( int argc, char **argv ) {
|
||||
|
||||
struct command *ccmd;
|
||||
int unknown = 1;
|
||||
if(argc == 1){
|
||||
printf("Available commands:\n\n exit - Exit the command line and boot\n");
|
||||
|
||||
for ( ccmd = cmd_start ; ccmd < cmd_end ; ccmd++ ) {
|
||||
printf (" %s - %s\n", ccmd->name, ccmd->desc );
|
||||
}
|
||||
}else{
|
||||
if(!strcmp(argv[1], "exit") || !strcmp(argv[1], "quit")){
|
||||
printf("exit - Exit the command line and boot\n\nUsage:\n exit\n");
|
||||
}else{
|
||||
for ( ccmd = cmd_start ; ccmd < cmd_end ; ccmd++ ) {
|
||||
if(!strcmp(ccmd->name, argv[1])){
|
||||
unknown = 0;
|
||||
printf ("%s - %s\n\nUsage:\n %s\n", ccmd->name, ccmd->desc, ccmd->usage );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(unknown){
|
||||
printf("\"%s\" isn't compiled in (does it exist?).\n", argv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("Available commands:\n\n exit - Exit the command line and boot\n");
|
||||
|
||||
for ( ccmd = cmd_start ; ccmd < cmd_end ; ccmd++ ) {
|
||||
printf (" %s\n", ccmd->name );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct command help_command __command = {
|
||||
.name = "help",
|
||||
.usage = "help <command>\n\nExample:\n help help\n",
|
||||
.desc = "The help command",
|
||||
.exec = cmd_help_exec,
|
||||
};
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <vsprintf.h>
|
||||
#include <command.h>
|
||||
#include <getopt.h>
|
||||
#include <gpxe/nvo.h>
|
||||
#include <gpxe/dhcp.h>
|
||||
#include <gpxe/settings.h>
|
||||
#include <gpxe/command.h>
|
||||
|
||||
void nvo_cmd_req() {}
|
||||
|
||||
@@ -41,8 +42,6 @@ static int show_exec ( int argc, char **argv ) {
|
||||
|
||||
struct command show_command __command = {
|
||||
.name = "show",
|
||||
.usage = "show <identifier>\n",
|
||||
.desc = "Show stored options",
|
||||
.exec = show_exec,
|
||||
};
|
||||
|
||||
@@ -78,7 +77,5 @@ static int set_exec ( int argc, char **argv ) {
|
||||
|
||||
struct command set_command __command = {
|
||||
.name = "set",
|
||||
.usage = "set <identifier> <value>\n",
|
||||
.desc = "Set stored option",
|
||||
.exec = set_exec,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "command.h"
|
||||
#include "console.h"
|
||||
#include <vsprintf.h>
|
||||
#include <gpxe/command.h>
|
||||
|
||||
void test_req(){}
|
||||
|
||||
@@ -15,8 +15,6 @@ static int cmd_test_exec ( int argc, char **argv ) {
|
||||
|
||||
struct command test_command __command = {
|
||||
.name = "test",
|
||||
.usage = "A test command\nIt does nothing at all\n\nExample:\n\ttest",
|
||||
.desc = "Does nothing",
|
||||
.exec = cmd_test_exec,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "command.h"
|
||||
#include "console.h"
|
||||
#include <vsprintf.h>
|
||||
#include <gpxe/command.h>
|
||||
|
||||
void test2_req(){}
|
||||
|
||||
@@ -15,8 +15,6 @@ static int cmd_test2_exec ( int argc, char **argv ) {
|
||||
|
||||
struct command test2_command __command = {
|
||||
.name = "test2",
|
||||
.usage = "A test command\nIt does nothing at all\n\nExample:\n\ttest2",
|
||||
.desc = "Does nothing",
|
||||
.exec = cmd_test2_exec,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user