mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-09-23 01:56:12 +00:00
dos33: re-write command parsing code
This commit is contained in:
parent
478293fe81
commit
a83c485a88
@ -1201,8 +1201,15 @@ static struct command_type {
|
||||
};
|
||||
|
||||
static int lookup_command(char *name) {
|
||||
int which=COMMAND_UNKNOWN;
|
||||
|
||||
int which=COMMAND_UNKNOWN,i;
|
||||
|
||||
for(i=1;i<MAX_COMMAND;i++) {
|
||||
if(!strncmp(name,commands[i].name,strlen(commands[i].name))) {
|
||||
which=commands[i].type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return which;
|
||||
|
||||
}
|
||||
@ -1261,50 +1268,15 @@ int main(int argc, char **argv) {
|
||||
temp_string[i]=toupper(temp_string[i]);
|
||||
}
|
||||
|
||||
if (!strncmp(temp_string,"LOAD",4)) {
|
||||
command=COMMAND_LOAD;
|
||||
}
|
||||
else if (!strncmp(temp_string,"SAVE",4)) {
|
||||
command=COMMAND_SAVE;
|
||||
}
|
||||
else if (!strncmp(temp_string,"CATALOG",7)) {
|
||||
command=COMMAND_CATALOG;
|
||||
}
|
||||
else if (!strncmp(temp_string,"DELETE",6)) {
|
||||
command=COMMAND_DELETE;
|
||||
}
|
||||
else if (!strncmp(temp_string,"UNDELETE",8)) {
|
||||
command=COMMAND_UNDELETE;
|
||||
}
|
||||
else if (!strncmp(temp_string,"LOCK",4)) {
|
||||
command=COMMAND_LOCK;
|
||||
}
|
||||
else if (!strncmp(temp_string,"UNLOCK",6)) {
|
||||
command=COMMAND_UNLOCK;
|
||||
}
|
||||
else if (!strncmp(temp_string,"INIT",4)) {
|
||||
command=COMMAND_INIT;
|
||||
}
|
||||
else if (!strncmp(temp_string,"RENAME",6)) {
|
||||
command=COMMAND_RENAME;
|
||||
}
|
||||
else if (!strncmp(temp_string,"COPY",4)) {
|
||||
command=COMMAND_COPY;
|
||||
}
|
||||
else if (!strncmp(temp_string,"DUMP",4)) {
|
||||
command=COMMAND_DUMP;
|
||||
}
|
||||
else if (!strncmp(temp_string,"HELLO",5)) {
|
||||
command=COMMAND_HELLO;
|
||||
}
|
||||
else {
|
||||
display_help(argv[0]);
|
||||
goto exit_program;
|
||||
}
|
||||
|
||||
|
||||
command=lookup_command(temp_string);
|
||||
|
||||
switch(command) {
|
||||
|
||||
case COMMAND_UNKNOWN:
|
||||
display_help(argv[0]);
|
||||
goto exit_program;
|
||||
break;
|
||||
|
||||
/* Load a file from disk image to local machine */
|
||||
case COMMAND_LOAD:
|
||||
/* check and make sure we have apple_filename */
|
||||
|
Loading…
Reference in New Issue
Block a user