Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > open stdin a second time

Reply
Thread Tools

open stdin a second time

 
 
fbertasso
Guest
Posts: n/a
 
      06-09-2008
Hi,

I´m opening stdin to get a file and pass it through a pipe.

razor=popen ("/var/qmail/bin/razor-check -home=/var/qmail/razor",
"w");
while( (ret=fread(linha,1,sizeof(linha),stdin) ) > 0 ) {
fwrite(linha,1,sizeof(linha),razor);
}
pclose(razor)

After that, if razor returns me an error I want to send an email with
the original message attached...but how can I re-read stdin to do
that.

I do not want to save the message to a temp file or save it to memory
for i/o questions. Is there a way to re-read stdin ?

Fernando
 
Reply With Quote
 
 
 
 
rahul
Guest
Posts: n/a
 
      06-10-2008
On Jun 9, 6:46 pm, fbertasso <fberta...@gmail.com> wrote:
> Hi,
>
> I´m opening stdin to get a file and pass it through a pipe.
>
> razor=popen ("/var/qmail/bin/razor-check -home=/var/qmail/razor",
> "w");
> while( (ret=fread(linha,1,sizeof(linha),stdin) ) > 0 ) {
> fwrite(linha,1,sizeof(linha),razor);}
>
> pclose(razor)
>
> After that, if razor returns me an error I want to send an email with
> the original message attached...but how can I re-read stdin to do
> that.
>
> I do not want to save the message to a temp file or save it to memory
> for i/o questions. Is there a way to re-read stdin ?
>
> Fernando


Of course fgetpos and fsetpos or other seeking techniques are not
going to work
if you are taking the input from the keyboard. If you are reading from
a file
then ftell/fseek or fgetpos/fsetpos are at you disposable.

To everyone else:
Apart from disk files, is there any other stream which can be
repositioned ( in the
sense of seeking)?
 
Reply With Quote
 
 
 
 
Chris Dollin
Guest
Posts: n/a
 
      06-10-2008
rahul wrote:

> To everyone else:
> Apart from disk files, is there any other stream which can be
> repositioned ( in the
> sense of seeking)?


DECtape springs immediately to mind. This new-fangled flash memory
which pretends to be a disk hobbles along soon afterward.

Are there reversible paper tape readers?

(Fondly remembering `revInFromFile` ...)

--
"I am afraid that this theory is quite untenable." /The Caves of Steel/

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      06-10-2008
In article <08550e04-d4ee-435b-9377->,
rahul <> wrote:

>Apart from disk files, is there any other stream which can be
>repositioned ( in the
>sense of seeking)?


Paper tape, some card readers, drum memory (provided it's refreshed),
magnetic tape in its many varieties, optical tape, CDs and DVDs, flash
memory, RAM "disks".

-- Richard


--
In the selection of the two characters immediately succeeding the numeral 9,
consideration shall be given to their replacement by the graphics 10 and 11 to
facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)
 
Reply With Quote
 
Chris Dollin
Guest
Posts: n/a
 
      06-10-2008
Richard Tobin wrote:

> In article <08550e04-d4ee-435b-9377->,
> rahul <> wrote:
>
>>Apart from disk files, is there any other stream which can be
>>repositioned ( in the
>>sense of seeking)?

>
> Paper tape, some card readers, drum memory (provided it's refreshed),
> magnetic tape in its many varieties, optical tape,


(fx:linebreak)

> CDs and DVDs,


Apart from silly marketing tricks, all the CDs and DVDs I've seen
are disks ...

(fx:linebreak)

> flash memory, RAM "disks".



--
"I don't make decisions. I'm a bird." /A Fine and Private Place/

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      06-10-2008
In article <g2lh7g$oj2$>,
Chris Dollin <> wrote:
>>>Apart from disk files, is there any other stream which can be
>>>repositioned ( in the
>>>sense of seeking)?


>> CDs and DVDs,

>
>Apart from silly marketing tricks, all the CDs and DVDs I've seen
>are disks ...


I was thinking of their use as linear storage (dump 0f /dev/acd0 /home),
which makes them "disks" but not "disk files". Of course, by that
reasoning I could have included magnetic disks of all kinds.

-- Richard
--
In the selection of the two characters immediately succeeding the numeral 9,
consideration shall be given to their replacement by the graphics 10 and 11 to
facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)
 
Reply With Quote
 
Antoninus Twink
Guest
Posts: n/a
 
      06-10-2008
On 10 Jun 2008 at 4:43, rahul wrote:
> To everyone else: Apart from disk files, is there any other stream
> which can be repositioned ( in the sense of seeking)?


Maybe it would be quicker to list the streams that can't be
repositioned... tty, pipes, sockets - any others?

 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      06-10-2008
In article <>,
Antoninus Twink <> wrote:

>Maybe it would be quicker to list the streams that can't be
>repositioned... tty, pipes, sockets - any others?


Many physical devices - TV tuners, modems, random number generators...

-- Richard



--
In the selection of the two characters immediately succeeding the numeral 9,
consideration shall be given to their replacement by the graphics 10 and 11 to
facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)
 
Reply With Quote
 
Walter Roberson
Guest
Posts: n/a
 
      06-10-2008
In article <g2lb50$ftn$>,
Chris Dollin <> wrote:

>Are there reversible paper tape readers?


http://www.freepatentsonline.com/3014092.html
United States Patent 3014092 "High speed reversible tape reader"
(December 19, 1961)
--
"And believe me, I was very lousy yesterday.
I had nothing to say, and, by God, I said it."
-- Walter Wellesley Smith
 
Reply With Quote
 
Herbert Rosenau
Guest
Posts: n/a
 
      06-15-2008
On Tue, 10 Jun 2008 10:10:13 UTC, Antoninus Twink
<> wrote:

> On 10 Jun 2008 at 4:43, rahul wrote:
> > To everyone else: Apart from disk files, is there any other stream
> > which can be repositioned ( in the sense of seeking)?

>
> Maybe it would be quicker to list the streams that can't be
> repositioned... tty, pipes, sockets - any others?
>

punch cards, magnetic cards, paper types

There are even devices who are write only:

printers, card writer, plotters, graphic tablets

Some of the above are limited in the ability to be repositioned, some
not, some totally unable depending on the specific type.

There are devices you can read multiple times like disk but write only
once depending on the media inserted:

CD ROM, DVD ROM, EPROM


--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2R Deutsch ist da!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
peek at stdin, flush stdin Johnathan Doe C Programming 5 4 Weeks Ago 04:30 PM
open stdin a second time FBert C Programming 2 11-12-2011 01:12 AM
open stdin a second time amit khan C Programming 3 05-25-2010 07:24 PM
How to pass stdin of a C++ program to the stdin of a process createdwith ShellExecute() Ben C Programming 2 08-29-2009 09:47 PM
Reading stdin once confuses second stdin read Charlie Zender C Programming 6 06-21-2004 01:39 PM



Advertisments