#include #include #include "vesa.h" extern char**environ; // TODO quit if execve fails or child exits... //default char *argv1[]={"xterm","/bin/fsh",0}; int main(int argc, char **argv) { // we need a 640x336 window for a 80x24 terminal using the // default 7x13 pixel font +1 pixel margin so it is 8x14 int w=640; int h=336; _gui_win(0xffffffff,w<<16|h,0); // basically loads font and sets a few constants void *fb=malloc(w*h*4); // 32bit mode so we have 4bytes per pixel. first one holds alpha vesa_init(w,h, fb, NULL); // init tty and set vesa output funcs void *tty=terminal_init_vesa(); int xterm_out[2]; pipe(xterm_out); int tty_fd=_open("/dev/tty"); int pid=fork(); if(!pid) // child { close(xterm_out[0]); dup2(tty_fd,0);// stdin dup2(xterm_out[1],1);// stdout dup2(xterm_out[1],2);// stderr // replace process with our foolshell or whatever if(argc==1)_execve(argv1[1],argv1,environ); execve(argv[1],argv,environ); printf("unable to execve %s",argv[1]); // never reached hopefully while(1); } else{ close(xterm_out[1]); while(1) { char buf[1]; read(xterm_out[0],buf,1); // show what foolshell writes to its stdout/stderr terminal_put(tty,buf[0]); } } }