sw: Added further small things, links, etc
[pdp8.git] / sw / tools_pc / tropf.c
CommitLineData
4d042122
PH
1#include <stdio.h>
2#include <readline/readline.h>
3#include <sys/types.h>
4#include <sys/stat.h>
5#include <fcntl.h>
6
7#define DELAY 140000
8main(int argc, char ** argv){
9 int fd=0; // stdin;
10 int byte=0;
11
12 if (argc==2) {
13 fd=open(argv[1],O_RDONLY);
14 if (fd<0){
15 perror("Schade");
16 exit (-4);
17 }
18 }
19
20
21 unsigned char akt;
22 rl_instream=stdin;
23 rl_outstream=stderr;
24 char buffer [100];
25 while(read (fd, &akt,1)){
26 if (fd!=0) {
27 sprintf(buffer,"Byte No.:%6i DEC:%03i HEX:%02x OCT:%03o Press enter -->",byte++,akt,akt,akt);
28 readline(buffer);
29 }
30 else {
31 usleep(DELAY);
32 fprintf(stderr,"Byte No.:%6i DEC:%03i HEX:%02x OCT:%03o\n",byte++,akt,akt,akt);
33 }
34 write(1,&akt,1);
35 }
36
37}