27 |
#include "alloc.h" |
#include "alloc.h" |
28 |
#include "dictionary.h" |
#include "dictionary.h" |
29 |
#include "error.h" |
#include "error.h" |
30 |
|
#include "glob.h" |
31 |
#include "getline.h" |
#include "getline.h" |
32 |
#include "lexer.h" |
#include "lexer.h" |
33 |
#include "main.h" |
#include "main.h" |
64 |
int (*func) (void); /* Function to call. */ |
int (*func) (void); /* Function to call. */ |
65 |
int skip_entire_name; /* If zero, we don't skip the |
int skip_entire_name; /* If zero, we don't skip the |
66 |
final token in the command name. */ |
final token in the command name. */ |
67 |
|
short debug; /* Set if this cmd available only in test mode*/ |
68 |
}; |
}; |
69 |
|
|
70 |
/* Define the command array. */ |
/* Define the command array. */ |
71 |
#define DEFCMD(NAME, T1, T2, T3, T4, FUNC) \ |
#define DEFCMD(NAME, T1, T2, T3, T4, FUNC) \ |
72 |
{NAME, {T1, T2, T3, T4}, FUNC, 1}, |
{NAME, {T1, T2, T3, T4}, FUNC, 1, 0}, |
73 |
|
#define DBGCMD(NAME, T1, T2, T3, T4, FUNC) \ |
74 |
|
{NAME, {T1, T2, T3, T4}, FUNC, 1, 1}, |
75 |
#define SPCCMD(NAME, T1, T2, T3, T4, FUNC) \ |
#define SPCCMD(NAME, T1, T2, T3, T4, FUNC) \ |
76 |
{NAME, {T1, T2, T3, T4}, FUNC, 0}, |
{NAME, {T1, T2, T3, T4}, FUNC, 0, 0}, |
77 |
#define UNIMPL(NAME, T1, T2, T3, T4) \ |
#define UNIMPL(NAME, T1, T2, T3, T4) \ |
78 |
{NAME, {T1, T2, T3, T4}, NULL, 1}, |
{NAME, {T1, T2, T3, T4}, NULL, 1, 0}, |
79 |
static const struct command commands[] = |
static const struct command commands[] = |
80 |
{ |
{ |
81 |
#include "command.def" |
#include "command.def" |
82 |
}; |
}; |
83 |
#undef DEFCMD |
#undef DEFCMD |
84 |
|
#undef DBGCMD |
85 |
#undef UNIMPL |
#undef UNIMPL |
86 |
|
|
87 |
|
|
104 |
|
|
105 |
cmd = &commands[state + skip]; |
cmd = &commands[state + skip]; |
106 |
|
|
107 |
if ( cmd->transition[pgm_state] == STATE_ERROR ) |
if ( cmd->transition[pgm_state] == STATE_ERROR || ( cmd->debug && ! test_mode ) ) |
108 |
{ |
{ |
109 |
skip++; |
skip++; |
110 |
continue; |
continue; |
548 |
{ |
{ |
549 |
if (command->skip_entire_name) |
if (command->skip_entire_name) |
550 |
lex_get (); |
lex_get (); |
551 |
|
if ( command->debug & !test_mode ) |
552 |
|
goto error; |
553 |
free_words (words, word_cnt); |
free_words (words, word_cnt); |
554 |
return command; |
return command; |
555 |
} |
} |
593 |
free (words[word_cnt]); |
free (words[word_cnt]); |
594 |
} |
} |
595 |
|
|
596 |
|
if ( command->debug && !test_mode ) |
597 |
|
goto error; |
598 |
|
|
599 |
free_words (words, word_cnt); |
free_words (words, word_cnt); |
600 |
return command; |
return command; |
601 |
} |
} |
602 |
|
|
603 |
|
error: |
604 |
unknown_command_error (words, word_cnt); |
unknown_command_error (words, word_cnt); |
605 |
free_words (words, word_cnt); |
free_words (words, word_cnt); |
606 |
return NULL; |
return NULL; |