void ConWindow::init(short x, short y, short width, short height, Style attrib) { if ((win = newwin(height, width, y, x)) == 0) exitMsg(99, "Internal error: Failed to create window"); if ((pan = new_panel(win)) == 0) exitMsg(99, "Internal error: Failed to create panel"); wbkgdset(win, attribStyle[attrib] | ' '); keypad(win, TRUE); // enable keyboard mapping clear(); } // end ConWindow::init
//-------------------------------------------------------------------- void ConWindow::resize(short width, short height) { if (wresize(win, height, width) != OK) exitMsg(99, "Internal error: Failed to resize window"); replace_panel(pan, win); clear(); } // end ConWindow::resize
//METHODS-------------------------------------------------------------------------------- //process user input and store pointers to each item in the argv //input is line from user //function causes input of the argv to change void tokenize (char *input, char *seperator) { int index=0; char *item = strtok(input, seperator); //returns pointer last string seperated by space if(strcmp(item, "exit\n") == 0) { exitMsg(); //quit program } while(item != NULL && index<maxArg) { argv[index] = item; //store token in argv item = strtok(NULL, seperator); //allows subsequent calls on input to seperate tokens index++; } argv[index] = NULL; argc = index; //set total number of arguments }
//MAIN----------------------------------------------------------------------------------- int main() { char usrInput[maxUsrIn]; //allocate space for a line of user input (static) //loop - read user input and tokenize //end loop and exit shell if user presses control-d //control-d = ^d = EOF printf("? "); while(fgets(usrInput, maxUsrIn, stdin) != NULL) { //tokenize user input tokenize(usrInput, " "); //pointer to an array of pointers processCMD(); printf("? "); } exitMsg(); return 0; }