diff --git a/README.md b/README.md index 81e4cdd..15f7ebe 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,13 @@ This allows you to get updates later easily as follows: There is a file "captured_data" in the repo, which you can use to test the tek4010 emulator. "captured_data" was produced in 2.11 BSD using my program "dodekagon". Type - ./tek4010 /bin/cat captured_data -noexit + ./tek4010 cat captured_data -noexit If you want to test text output, type for example - ./tek4010 /usr/bin/head -n 32 tek4010.c -noexit + ./tek4010 head -n 32 tek4010.c -noexit -Don't forget the absolute path to "cat" or "head" and the LAST argument "-noexit", which tells +Don't forget the LAST argument "-noexit", which tells tek4010 to stay alive after cat has finished so that you have a chance to look at the output. By the way, the "-noexit" as the LAST argument might also be helpful if you want to experiment with other commands. Let me know if you find anything which works and makes sense. @@ -54,7 +54,8 @@ or This can either be a real historical computer, or a virtual system using simh such as the PiDP-11. -First, you need to login remotely from your client machine into your historical system, using +First, you need to test the remote login from your client machine into your historical +system, using rsh -l user_name system or @@ -69,13 +70,12 @@ or If this works properly, you can use the tek4010 emulator. Call it as follows: - ./tek4010 /usr/bin/rsh -l user_name system + ./tek4010 rsh -l user_name system or - ./tek4010 /usr/bin/telnet system + ./tek4010 telnet system -In the current alpha-testing version, there are very few useful error messages if this does -not work. If the terminal window is closed right away, there is a problem with your rsh or -telnet call or you forgot to use the absolute path for rsh or telnet. +If the terminal window is closed right away, there is a problem with your rsh or +telnet call. The following keys are not transmitted to the Unix system, but are executed locally in the terminal emulator and clear the persistent screen: @@ -112,7 +112,7 @@ the Raspberry Pi. You cannot use telnet here. Now start tek4010 as follows: - ./tek4010 /usr/bin/rsh -l pi localhost + ./tek4010 rsh -l pi localhost This should give you a login prompt into your Raspberry Pi. If not, test the rsh call first. diff --git a/main.c b/main.c index 224c3a3..d0b6764 100644 --- a/main.c +++ b/main.c @@ -47,7 +47,6 @@ extern FILE *putKeys; static cairo_surface_t *global_surface, *global_surface2; static int global_firstcall; -int global_noexit; int globalClearPersistent; static void do_drawing(cairo_t *, GtkWidget *); @@ -141,14 +140,7 @@ int main (int argc, char *argv[]) { GtkWidget *darea; GtkWidget *window; - - if (strcmp(argv[argc-1],"-noexit") == 0) { - global_noexit = 1; - argc--; - } - else - global_noexit = 0; - + gtk_init(&argc, &argv); global_firstcall = TRUE; diff --git a/main.h b/main.h index b7b6931..c899380 100644 --- a/main.h +++ b/main.h @@ -3,7 +3,8 @@ void tek4010_init(int argc, char* argv[]); void tek4010_draw(cairo_t *cr, cairo_t *cr2, int width, int height, int first); -int tek4010_on_timer_event(); -int tek4010_clicked(int button, int x, int y); +int tek4010_on_timer_event(); +int tek4010_clicked(int button, int x, int y); void tek4010_quit(); + diff --git a/tek4010 b/tek4010 index fe72f31..df09599 100755 Binary files a/tek4010 and b/tek4010 differ diff --git a/tek4010.c b/tek4010.c index e4c3f46..d7e48ec 100644 --- a/tek4010.c +++ b/tek4010.c @@ -6,13 +6,14 @@ * Copyright 2016,2019 rricharz * */ - + #define MEM 128 #define TODO 6 // for speed reasons, draw multiple objects until screen updates #include #include +#include #include #include #include @@ -25,7 +26,7 @@ extern void gtk_main_quit(); extern int globalClearPersistent; -extern int global_noexit; +int noexit; /* not yet used, for dsrk mode int memx1[MEM], memy1[MEM], memx2[MEM], memy2[MEM]; @@ -82,10 +83,40 @@ void tek4010_init(int argc, char* argv[]) // put any code here to initialize the tek4010 { char *argv2[10]; + size_t bufsize = 127; if ((argc<2) || (argc>9)) { printf("Error:number of arguments\n"); exit(1); } + + if (strcmp(argv[argc-1],"-noexit") == 0) { + noexit = 1; + argc--; + } + else + noexit = 0; + + // expand argv[1] to full path and check, whether it exists + char *str = (char *) malloc(bufsize * sizeof(char)); + if (str == NULL) { + printf("Cannot allocate memory for absolute path\n"); + exit(1); + } + strcpy(str,"which "); + strcat(str, argv[1]); + FILE *fullPath = popen(str,"r"); + if (fullPath) { + getline(&str, &bufsize,fullPath); + // remove the endline character + str[strlen(str)-1] = 0; + argv[1] = str; + pclose(fullPath); + } + else { + printf("Cannot find command %s\n", argv[1]); + exit(1); + } + hDotsPerChar = WINDOW_WIDTH / 74; vDotsPerChar = WINDOW_HEIGHT / 35; globalClearPersistent = 1; @@ -127,10 +158,13 @@ void tek4010_init(int argc, char* argv[]) // run rsh in the child process execv(argv2[0],argv2+1); - exit(1); + free(str); + exit(0); } // parent process + + free(str); close(getDataPipe[1]); // not used close(putKeysPipe[0]); // not used @@ -412,9 +446,10 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int width, int height, int first) // is child process still running? int status; - if ((! global_noexit) && (waitpid(-1, &status, WNOHANG))) { // Is child process terminated? + if ((! noexit) && (waitpid(-1, &status, WNOHANG))) { // Is child process terminated? tek4010_quit(); gtk_main_quit(); + printf("Child process has been terminated\n"); exit(0); } }