#define EXTERN #define MAIN 1 /*-------------------------- ** include files **-------------------------- */ #include #include #include #include #include #include #include #include "ir1.h" /*-------------------------------------- ** structures **-------------------------------------- */ /*--------------------------- ** function prototypes **--------------------------- */ int cmd_execute( char * cmd_buf); int do_help( char *par ); int do_quit( char *par ); int do_test( char *par ); int do_show( char *par ); /*------------------------------------- * Global variables *------------------------------------- */ struct PARSE_TABLE { char * kw; /* The opcode string */ int (* pfi)(); /* pfi is pointer to function returning an integer */ char * desc; /* Description of command */ }; struct PARSE_TABLE parse_table[] = { { "Help", do_help, "Help - Lists the available commands." }, { "Quit", do_quit, "Quit - Quit the application." }, { "test", do_test, "test" }, { "s", do_show, "s - show data" }, }; int num_parse_item = { sizeof(parse_table) / sizeof(struct PARSE_TABLE) }; int Quit; int Verbose; /*********** position data **********************/ struct pt_t { double x; double y; }; #define NDATA 10 // moris data struct pt_t M[NDATA] = { { 75, 433 }, { 91, 229 }, { 217, 198 }, { 188, 399 }, { 325, 342 }, { 343, 412 }, { 360, 94 }, { 379, 253 }, { 504, 74 }, { 491, 228 }, }; // spex data struct pt_t S[NDATA] = { { 19, 392 }, { 31, 192 }, { 154, 157 }, { 128, 355 }, { 264, 297 }, { 283, 365 }, { 293, 52 }, { 315, 208 }, { 433, 30 }, { 425, 180 }, }; struct pt_t A[NDATA]; struct pt_t B[NDATA]; struct pt_t C[NDATA]; /*--------------------------------- ** main() **--------------------------------- */ int main( int argc, char * argv[]) { char buf[80]; /* main loop for commands */ Quit = FALSE; while( !Quit ) { /* Get command */ printf("Enter Command: "); gets( buf ); cmd_execute( buf ); } return 0; } /*------------------------------------------------------------- ** cmd_execute() - Executes a command line instruction **------------------------------------------------------------- */ int cmd_execute( char * cmd_buf ) { char copy_buf[80]; int error, found, i; char * kw, * par; /* ** Search table for keyword */ strxcpy( copy_buf, cmd_buf, sizeof(copy_buf)); kw = strtok(copy_buf, " "); if( (kw == NULL) || (*kw=='#') ) return( ERR_NONE ); if( (par = strtok( (char*)NULL, "")) != NULL ) unpad( par, ' ' ); /* ** Search table for keyword. If found call function. */ error = ERR_INV_KW; for(i=0, found = FALSE; i