diff options
author | Eduardo Chappa <echappa@gmx.com> | 2013-02-03 00:59:38 -0700 |
---|---|---|
committer | Eduardo Chappa <echappa@gmx.com> | 2013-02-03 00:59:38 -0700 |
commit | 094ca96844842928810f14844413109fc6cdd890 (patch) | |
tree | e60efbb980f38ba9308ccb4fb2b77b87bbc115f3 /contrib/utils/ansiprt.c | |
download | alpine-094ca96844842928810f14844413109fc6cdd890.tar.xz |
Initial Alpine Version
Diffstat (limited to 'contrib/utils/ansiprt.c')
-rwxr-xr-x | contrib/utils/ansiprt.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/contrib/utils/ansiprt.c b/contrib/utils/ansiprt.c new file mode 100755 index 00000000..17d6e068 --- /dev/null +++ b/contrib/utils/ansiprt.c @@ -0,0 +1,60 @@ +/* + * ansiprt.c + * + * Simple filter to wrap ANSI media copy escape sequences around + * text on stdin. Writes /dev/tty to get around things that might be + * trapping stdout. This is actually a feature because it was written + * to be used with pine's personal print option set up to take "enscript" + * output and send it displayward to be captured/printed to a postscript + * device. Pine, of course, uses popen() to invoke the personal print + * command, and interprets stdout as diagnostic messages from the command. + * + * Michael Seibel, mikes@cac.washington.edu + * + * 21 Apr 92 + * + */ +#include <stdio.h> +#include <sys/file.h> + +#define BUFSIZ 8192 + +main(argc, argv) +int argc; +char **argv; +{ + char c[BUFSIZ]; + int n, d; + int ctrld = 0; + + if(argc > 1){ + n = 0; + while(argc > ++n){ + if(argv[n][0] == '-'){ + switch(argv[n][1]){ + case 'd': + ctrld++; + break; + default : + fprintf(stderr,"unknown option: %c\n", argv[n][1]); + break; + } + } + } + } + + if((d=open("/dev/tty",O_WRONLY)) < 0){ + perror("/dev/tty"); + exit(1); + } + + write(d,"\033[5i", 4); + while((n=read(0, c, BUFSIZ)) > 0) + write(d, c, n); + + if(ctrld) + write(d, "\004", 1); + + write(d,"\033[4i", 4); + close(d); +} |