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);
}
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<MAXTASKS; ct++){
- if(!tasks_used[ct]){
- debug("Task %d not implemented\n", ct);
- continue;
- }
- debug("Going to execute task %d\n", ct);
- run_task(tasks[ct]);
- }
- usleep(10);
- }
-
-/* //Read program
- pc = 0;
- while ((c = getchar()) != EOF && pc < PROGRAMSIZE)
- program[pc++] = c;
- if (pc >= 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;
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<MAXTASKS; ct++){
+ if(!tasks_used[ct]){
+ debug("Task %d not implemented\n", ct);
+ continue;
+ }
+ debug("Going to execute task %d\n", ct);
+ run_task(tasks[ct]);
+ }
+ usleep(10);
+ }
+
+/* //Read program
+ pc = 0;
+ while ((c = getchar()) != EOF && pc < PROGRAMSIZE)
+ program[pc++] = c;
+ if (pc >= 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;
}