Browse Source

Added "exit" back in as a standardised command.

tags/v0.9.3
Michael Brown 18 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
 	cmd->printf = in;
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
 int cmdl_printf(cmd_line* cmd, const char *format, ...)
27
 int cmdl_printf(cmd_line* cmd, const char *format, ...)
45
 {
28
 {
46
 	int ret;
29
 	int ret;
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
 void cmdl_enterloop(cmd_line* cmd)
84
 void cmdl_enterloop(cmd_line* cmd)
90
 {
85
 {
91
-	while(!cmdl_getexit(cmd)){
86
+	cmdl_exit = 0;
87
+	do {
92
 		if(cmd->refresh){
88
 		if(cmd->refresh){
93
 			cmd->printf("%s %s", cmd->prompt, cmd->buffer);
89
 			cmd->printf("%s %s", cmd->prompt, cmd->buffer);
94
 			cmd->refresh = 0;
90
 			cmd->refresh = 0;
95
 		}
91
 		}
96
 //		cmd->printf("Got %d\n", cmd->getchar());
92
 //		cmd->printf("Got %d\n", cmd->getchar());
97
 		cmdl_parsechar(cmd, cmd->getchar());
93
 		cmdl_parsechar(cmd, cmd->getchar());
98
-	}
94
+	} while ( ! cmdl_exit );
99
 }
95
 }
100
 
96
 
101
 void cmdl_addreplace(cmd_line* cmd, char in)
97
 void cmdl_addreplace(cmd_line* cmd, char in)
367
 	
363
 	
368
 	this->cursor = 0;
364
 	this->cursor = 0;
369
 	//this->has_output = 0;
365
 	//this->has_output = 0;
370
-	this->exit = 0;
371
 	this->refresh = 1;
366
 	this->refresh = 1;
372
 	this->tabstate = 0;
367
 	this->tabstate = 0;
373
 	this->insert = 0;
368
 	this->insert = 0;
386
 	for ( cmd = cmd_start ; cmd < cmd_end ; cmd++ ) {
381
 	for ( cmd = cmd_start ; cmd < cmd_end ; cmd++ ) {
387
 		printf("%s ", cmd->name);
382
 		printf("%s ", cmd->name);
388
 	}
383
 	}
389
-	printf("exit\n\n");
384
+	printf("\n\n");
390
 
385
 
391
 	return this;
386
 	return this;
392
 }
387
 }

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

11
 static int cmd_help_exec ( int argc, char **argv ) {
11
 static int cmd_help_exec ( int argc, char **argv ) {
12
 
12
 
13
 	struct command *ccmd;
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
 	for ( ccmd = cmd_start ; ccmd < cmd_end ; ccmd++ ) {
17
 	for ( ccmd = cmd_start ; ccmd < cmd_end ; ccmd++ ) {
20
 		printf ("  %s\n", ccmd->name );
18
 		printf ("  %s\n", ccmd->name );

Loading…
Cancel
Save