int check_builtin(char *cmd) { /* Arguments: cmd = program to run Purpose: this function checks to see if the cmd specified is a built in command (in this case only "cd" is built-in) Returns: 0 -- if the cmd is built in -1 -- if the cmd is NOT built in */ if(!strcmp(cmd,"cd")) { //command was "cd" which is a builtin, so //lets handle it add_nav_history(fullPath); chdir(args[1]); //change directory to first argument get_path(); } else if(cmd[0] == '!') { //theyre requesting some sort of history exec_history(cmd); //execute the argument number } else if(cmd[0] == '@') { //requesting nav history exec_nav_history(cmd); get_path(); } else if(!strcmp(cmd,"history")) { print_history(); } else if(!strcmp(cmd, "navhist")) { print_nav_history(); } else if(!strcmp(cmd,"alias")) { //trying to set an alias if(args[1] == NULL) { //no argument, so just print all print_aliases(); } else { add_alias(args[1]); } } else if(!strcmp(cmd,"unalias")) { //trying to remove an alias (args[1] is what is being removed) remove_alias(args[1]); } else if(!strcmp(cmd,"cinterp")) { //want to use the C interpreter //quit raw mode first (will make the cinterp easier) quit_raw_mode(); cinterp(); tty_raw_mode(); //reenter raw mode } else { return -1; } return 0; }
void gettw(double x, double *tailp, double *densp) // main routine for accessing twtable { int k, n ; double x0, x1, f0, f1, f0p, f1p ; double *xx[3] ; if (twtabsize = -1) { if (settwxtable(TWXTABLE) < 0) fatalx("twtable not readable %s\n", TWXTABLE) ; k = numlines(twxtable) ; ZALLOC(twxval, k, double) ; ZALLOC(twxpdf, k, double) ; ZALLOC(twxtail, k, double) ; xx[0] = twxval ; xx[1] = twxtail ; xx[2] = twxpdf ; twtabsize = getxx(xx, k, 3, twxtable) ; } n = twtabsize ; k = firstgtx(x, twxval, n) ; if (k<=0) { *tailp = 1.0 ; *densp = 0.0 ; return ; } if (k>=n) { *tailp = twdensx(x) ; *densp = twtailx(x) ; return ; } x0 = twxval[k-1] ; x1 = twxval[k] ; f0 = twxtail[k-1] ; f0p = twxpdf[k-1] ; f1 = twxtail[k] ; f1p = twxpdf[k] ; // now do cubic interpolation cinterp(x, x0, x1, f0, -f0p, f1, -f1p, tailp, densp) ; *densp = - *densp ; /** printf("zzz %9.3f %9.3f %9.3f\n", x0, x1, x) ; printf("zz1 %9.3f %9.3f %9.3f\n", f0, f1, *tailp) ; printf("zz2 %9.3f %9.3f %9.3f\n", f0p, f1p, *densp) ; */ }