# include "basic.h"

int config          PROTO((int, char **));
int exec_sleep      PROTO((int, char **));
int exec_usleep     PROTO((int, char **));
int cd              PROTO((int, char **));
int date            PROTO((int, char **));
int echo            PROTO((int, char **));
int exec_break      PROTO((int, char **));
int exec_continue   PROTO((int, char **));
int file            PROTO((int, char **));
int getchr_func     PROTO((int, char **));
int help       	    PROTO((int, char **));
int input      	    PROTO((int, char **));
int list       	    PROTO((int, char **));
int list_help  	    PROTO((int, char **));
int list_vars  	    PROTO((int, char **));
int local           PROTO((int, char **)); /* data? */
int macro      	    PROTO((int, char **));
int memory          PROTO((int, char **));
int output     	    PROTO((int, char **));
int pwd        	    PROTO((int, char **));
int quit       	    PROTO((int, char **));
int run_for    	    PROTO((int, char **));
int run_if     	    PROTO((int, char **));
int run_while  	    PROTO((int, char **));
int scan       	    PROTO((int, char **));
int shell      	    PROTO((int, char **));
int sprintf_opihi   PROTO((int, char **));
int strlen_func     PROTO((int, char **));
int substr_func     PROTO((int, char **));
int wait       	    PROTO((int, char **));
int which      	    PROTO((int, char **));

/** mapping of the command names to command functions **/
static Command cmds[] = {  
  {"config",        config,             "(re)load config file?"},
  {"sleep",         exec_sleep,         "sleep for N seconds"},
  {"usleep",        exec_usleep,        "sleep for N microseconds"},
  {"cd",      	    cd,                 "change directory"},
  {"date",    	    date,               "get current date"},
  {"echo",    	    echo,               "type this line *"},
  {"break",   	    exec_break,         "escape from function *"},
  {"continue",	    exec_continue,      "next loop iteration"},
  {"file",          file,               "test file existence"},
  {"getchr",        getchr_func,        "find character in string"},
  {"help",    	    help,               "get help on a function *"},
  {"input",   	    input,              "read command lines from a file *"},
  {"list",    	    list,               "get variable list"},
  {"?",       	    list_help,          "list commands *"},
  {"??",      	    list_vars,          "list variables *"},
  {"local",  	    local,              "define local variables"},
  {"macro",   	    macro,              "deal with the macros *"}, 
  {"memory",        memory,             "long listing of the allocated memory"},
  {"output",  	    output,             "redirect output to file"},
  {"pwd",     	    pwd,                "print current working directory"},
  {"exit",    	    quit,               "exit program *"}, 
  {"quit",    	    quit,               "exit program *"},
  {"for",     	    run_for,            "for loop"}, 
  {"if",      	    run_if,             "logical cases *"}, 
  {"while",   	    run_while,          "while loop"}, 
  {"scan",    	    scan,               "scan line from keyboard or file to variable *"},
  {"!",       	    shell,              "system call"},
  {"exec",    	    shell,              "system call"},
  {"sprintf",       sprintf_opihi,      "formatted print to a variable"},
  {"strlen",        strlen_func,        "string length"},
  {"substr",        substr_func,        "substring"},
  {"wait",    	    wait,               "wait until return is typed"},
  {"which",   	    which,              "show command *"}
};

void InitBasic () {
  
  int i;

  for (i = 0; i < sizeof (cmds) / sizeof (Command); i++) {
    AddCommand (&cmds[i]);
  }

}
