From: Mart Lubbers Date: Mon, 21 Nov 2016 18:26:17 +0000 (+0100) Subject: up X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=ce02e66737315fe6821272e7d7cc86a79a88060d;p=mTask.git up --- diff --git a/int/int.c b/int/int.c index 2bf2cef..f3332f7 100644 --- a/int/int.c +++ b/int/int.c @@ -39,9 +39,8 @@ bool input_available(int fd){ tv.tv_usec = 0; FD_ZERO(&fds); FD_SET(fd, &fds); - if(select(fd+1, &fds, NULL, NULL, &tv) == -1){ + if (select(fd+1, &fds, NULL, NULL, &tv) == -1) pdie("select"); - } return FD_ISSET(fd, &fds); } @@ -86,58 +85,11 @@ void read_message(int fd_in, int fd_out) void run_task(char *program) { - - (void) program; -} - -int main(void) -{ - int fd_in, fd_out; - int ct; - - fd_in = fileno(stdin); - fd_out = fileno(stdout); - - //Register signal handler - if(signal(SIGINT, killHandler) == SIG_ERR){ - die("Couldn't register signal handler...\n"); - } - if(signal(SIGTERM, killHandler) == SIG_ERR){ - die("Couldn't register signal handler...\n"); - } - - while(true){ - //Check for new tasks - if(input_available(fd_in)){ - read_message(fd_in, fd_out); - exit(1); - } - //Run tasks - for(ct = 0; ct= PROGRAMSIZE) - die("Max program size: %d\n", PROGRAMSIZE); - pl = pc; - debug("Done reading, program length: %d\n", pl); - - //Evaluate program - //Reset program counter and stack counter - pc = 0; - sp = 0; - while(pc != pl){ + int pc = 0; + int sp = 0; + int plen = strlen(program); + char stack[1024] = {0}; + while(pc != plen){ switch(program[pc++]){ case BCNOP:; break; @@ -230,6 +182,57 @@ int main(void) die("Unrecognized command: %X\n", program[--pc]); } } +} + +int main(void) +{ + int fd_in, fd_out; + int ct; + + fd_in = fileno(stdin); + fd_out = fileno(stdout); + + //Register signal handler + if(signal(SIGINT, killHandler) == SIG_ERR){ + die("Couldn't register signal handler...\n"); + } + if(signal(SIGTERM, killHandler) == SIG_ERR){ + die("Couldn't register signal handler...\n"); + } + + while(true){ + //Check for new tasks + if(input_available(fd_in)){ + read_message(fd_in, fd_out); + exit(1); + } + //Run tasks + for(ct = 0; ct= PROGRAMSIZE) + die("Max program size: %d\n", PROGRAMSIZE); + pl = pc; + debug("Done reading, program length: %d\n", pl); + + //Evaluate program + //Reset program counter and stack counter + pc = 0; + sp = 0; + while(pc != pl){ + } */ return 0; }