sw: Added further small things, links, etc
[pdp8.git] / sw / tools_pc / tropf.c
diff --git a/sw/tools_pc/tropf.c b/sw/tools_pc/tropf.c
new file mode 100644 (file)
index 0000000..d0245ce
--- /dev/null
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <readline/readline.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define DELAY 140000
+main(int argc, char ** argv){
+    int fd=0; // stdin;
+    int byte=0;
+    
+    if (argc==2) {
+    fd=open(argv[1],O_RDONLY);
+       if (fd<0){
+           perror("Schade");
+           exit (-4);
+       }
+    }
+        
+    
+    unsigned char  akt;
+    rl_instream=stdin;
+    rl_outstream=stderr;
+    char buffer [100];
+    while(read (fd, &akt,1)){
+    if (fd!=0) {
+    sprintf(buffer,"Byte No.:%6i DEC:%03i HEX:%02x OCT:%03o   Press enter -->",byte++,akt,akt,akt);    
+    readline(buffer);
+    }
+    else {
+       usleep(DELAY);
+       fprintf(stderr,"Byte No.:%6i DEC:%03i HEX:%02x OCT:%03o\n",byte++,akt,akt,akt);
+       }
+    write(1,&akt,1); 
+    }
+    
+}