Browse Source

Added "exit" back in as a standardised command.

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
cc697eeb1f
2 changed files with 17 additions and 24 deletions
  1. 16
    21
      src/commandline/cmdlinelib.c
  2. 1
    3
      src/commandline/commands/help.c

+ 16
- 21
src/commandline/cmdlinelib.c View File

@@ -24,23 +24,6 @@ void cmdl_setprintf(cmd_line* cmd, cmdl_printf_t in)
24 24
 	cmd->printf = in;
25 25
 }
26 26
       
27
-int cmdl_getexit(cmd_line* cmd)
28
-{
29
-	if(cmdl_check(cmd) && !cmd->exit){
30
-		return 0;
31
-	}else{
32
-		return 1;
33
-	}
34
-
35
-}
36
-
37
-void cmdl_setexit(cmd_line* cmd, int exit)
38
-{
39
-	if(cmdl_check(cmd)){
40
-		cmd->exit = exit;
41
-	}
42
-}
43
-
44 27
 int cmdl_printf(cmd_line* cmd, const char *format, ...)
45 28
 {
46 29
 	int ret;
@@ -86,16 +69,29 @@ char* cmdl_getbuffer(cmd_line* cmd){
86 69
 	}
87 70
 }
88 71
 
72
+static int cmdl_exit = 0;
73
+
74
+static int exit_exec ( int argc __unused, char **argv __unused ) {
75
+	cmdl_exit = 1;
76
+	return 0;
77
+}
78
+
79
+struct command exit_command __command = {
80
+	.name = "exit",
81
+	.exec = exit_exec,
82
+};
83
+
89 84
 void cmdl_enterloop(cmd_line* cmd)
90 85
 {
91
-	while(!cmdl_getexit(cmd)){
86
+	cmdl_exit = 0;
87
+	do {
92 88
 		if(cmd->refresh){
93 89
 			cmd->printf("%s %s", cmd->prompt, cmd->buffer);
94 90
 			cmd->refresh = 0;
95 91
 		}
96 92
 //		cmd->printf("Got %d\n", cmd->getchar());
97 93
 		cmdl_parsechar(cmd, cmd->getchar());
98
-	}
94
+	} while ( ! cmdl_exit );
99 95
 }
100 96
 
101 97
 void cmdl_addreplace(cmd_line* cmd, char in)
@@ -367,7 +363,6 @@ cmd_line* cmdl_create()
367 363
 	
368 364
 	this->cursor = 0;
369 365
 	//this->has_output = 0;
370
-	this->exit = 0;
371 366
 	this->refresh = 1;
372 367
 	this->tabstate = 0;
373 368
 	this->insert = 0;
@@ -386,7 +381,7 @@ cmd_line* cmdl_create()
386 381
 	for ( cmd = cmd_start ; cmd < cmd_end ; cmd++ ) {
387 382
 		printf("%s ", cmd->name);
388 383
 	}
389
-	printf("exit\n\n");
384
+	printf("\n\n");
390 385
 
391 386
 	return this;
392 387
 }

+ 1
- 3
src/commandline/commands/help.c View File

@@ -11,10 +11,8 @@ void help_req(){}
11 11
 static int cmd_help_exec ( int argc, char **argv ) {
12 12
 
13 13
 	struct command *ccmd;
14
-	int unknown = 1;
15 14
 
16
-
17
-	printf("Available commands:\n\n  exit - Exit the command line and boot\n");
15
+	printf("Available commands:\n\n");
18 16
 
19 17
 	for ( ccmd = cmd_start ; ccmd < cmd_end ; ccmd++ ) {
20 18
 		printf ("  %s\n", ccmd->name );

Loading…
Cancel
Save