🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #6208

Re: how to read stdin?

#6208
From: vsarkela
Date: Tue, 04 Jun 1991 09:52
47 lines
2010 bytes
In article <1991May31.105841.13048@odin.diku.dk>, 
jesper@diku.dk (Jesper L. Lauritsen) writes:
> Can someone tell me how to read standard input so CR LF does not get translated
> to LF?
> Thanks in advance.
> 
> --Jesper
> 
> --------------------
> Jesper L. Lauritsen, systems programmer
> ibtjll@vm.ibt.dk    (BITNET/EARN: IBTJLL AT DKIBT)
> Center for Applied Datalogy, University of Copenhagen

We have used this filter when printing a file from a PC to postscript
printer on a ultrix machine. 


/* This is a simple filter, which puts carriage returns (13 dec, 015 oct, */
/*  0xD hex) before each new line (line feed = 10 dec, 012 oct, 0xA hex)  */
/*  and after control-d ( 4 dec) and strips any possible control-z's (DOS */
/*  end-of-file marks) off                                                                                                                        */

#include <stdio.h>

int
main(argc, argv)
int argc;
char *argv[];
{
        register int c;      /* incoming char */

        while ((c=getchar()) != EOF) {
                if(c == 26) continue; /* control-z */
                if(c == 4) {          /* control-d */
                        puts("\004\r");
                        continue;
                }
                if(c == '\n') {          /* line feed */
                        puts("\r");      /* puts appends newline */
                        continue;
                }
                putchar(c);
        }/* while */
        return(0);
}

-- Vesa Sarkela    Finnish Pulp and Paper Research Institute
Technical Details
Message-ID: <1991Jun4.095241.1@csc.fi>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!sics.se!fuug!funic!csc.fi!vsarkela
References: <1991May31.105841.13048@odin.diku.dk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!sics.se!fuug!funic!csc.fi!vsarkela
From: vsarkela@csc.fi
Newsgroups: comp.lang.postscript
Subject: Re: how to read stdin?
Message-ID: <1991Jun4.095241.1@csc.fi>
Date: 4 Jun 91 09:52:41 GMT
References: <1991May31.105841.13048@odin.diku.dk>
Sender: usenet@nic.funet.fi
Lines: 47
Nntp-Posting-Host: csc.fi