/* * SCRIPT */ #include #include #include #include #include "global.h" #include "script.h" #include "sfunc.h" #include "file.h" #include "kbd.h" #include "aspi_rw.h" static struct SCRIPT_OBJ script; /* * Script Commands * * All script commands must have a preceeding '*'. */ static struct SCRIPT_OP_DEF script_cmd[] = { {"SINGLE_STEP", sf_single_step}, {"ECHO", sf_echo}, {"REM", sf_rem}, {"ABORT", sf_abort}, {"ASPI", sf_aspi}, {"FREE_RUN", sf_free_run}, {"PAUSE", sf_pause}, {"DIAGNOSTICS", sf_diagnostics}, {"REQ_OUTSTANDING", sf_req_outs}, {"ASPI_REQ_DELAY", sf_aspi_req_delay}, {"AL6000_RESET", sf_al6_reset}, {"LOOP", sf_loop}, {"LOOP", sf_loop}, {"AUTO_INIT", sf_auto_init}, {"VER_COMPAT", sf_nop}, {"NOP", sf_nop}, {NULL, NULL} }; static FLAG dispatch_op(void); /*************************************************************************** * * script_file(...) * ***************************************************************************/ FLAG script_file(name) char *name; { if (!name) return (fclose(script.file)); script.file_op_num = 0; script.single_step = FALSE; script.file = file_open(name); script.abort = FALSE; script.aspi_allow_reqs = 1; script.loop = FALSE; return (script.file != 0); } /*************************************************************************** * * script_parse(...) * ***************************************************************************/ void script_parse() { diag_msg("Parsing script file...\n"); while (dispatch_op()) { aspi_poll(); } aspi_flush(); // Flush ASPI reqs } /*************************************************************************** * * dispatch_op(...) * ***************************************************************************/ static FLAG dispatch_op() { int i; char *op_str; FLAG ret_val; U16 vc_num; static FLAG vc_num_verified = FALSE; if (kbd_double_esc()) { diag_msg("User abort during parsing of script file.\n"); return (FALSE); } if (script.single_step) kbd_any_key(); op_str = file_get_str(script.file); if (!op_str) { diag_msg("Done parsing script file.\n"); return (FALSE); } for (i = 0; script_cmd[i].str; i++) { if (op_str[0] != '*') break; // // Special-case, in order to start decoding script file, first // a version compatibiliity number must be verified. // if (!vc_num_verified) if (stricmp("VER_COMPAT",&op_str[1]) == 0) { file_get_int(script.file,&vc_num); printf("SCRIPT Version Compatibility number %u.\n",vc_num); if (vc_num < MIN_VC_NUM) { error("Version compatibility number too low or illegal.\n"); return (FALSE); } vc_num_verified = TRUE; return (TRUE); } else { error("Version compatibility number not specified.\n"); return (FALSE); } if (stricmp(script_cmd[i].str,&op_str[1]) == 0) { script.file_op_num++; ret_val = (*(script_cmd[i].func))(&script); if (script.abort) { diag_msg("Done parsing script file.\n"); return (FALSE); } return (ret_val); } } error("Not a legal Script Operation"); printf("\tOperation number: %d\n",script.file_op_num); printf("\tOperation str: %s\n",op_str); return (FALSE); }