open stdin a second time

F

fbertasso

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
 
R

rahul

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)?
 
C

Chris Dollin

rahul said:
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` ...)
 
R

Richard Tobin

rahul said:
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
 
C

Chris Dollin

Richard said:
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)
 
R

Richard Tobin

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
 
A

Antoninus Twink

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?
 
R

Richard Tobin

Antoninus Twink said:
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
 
H

Herbert Rosenau

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!
 
D

David Thompson

Paper tape, some card readers, drum memory (provided it's refreshed),

I assume this means classic punched or optical-mark; not newer
(plastic) cards like mag-stripe and RFID, mostly for ID, access and
payment rather than data as such. I knew of some readers that could
'catch' a card in the path after reading e.g. for an alternate stacker
but none that could actually go backward. (Or skip forward either.)
magnetic tape in its many varieties, optical tape,

But usually not to arbitrary bytes, thus fitting the fget,setpos model
rather than the fseek (tell/seek) model. Except as noted DECtape.
CDs and DVDs, flash > memory, RAM "disks".

- formerly david.thompson1 || achar(64) || worldnet.att.net
 
R

Richard Tobin

Paper tape, some card readers, drum memory (provided it's refreshed),
[/QUOTE]
I assume this means classic punched or optical-mark; not newer
(plastic) cards like mag-stripe and RFID, mostly for ID, access and
payment rather than data as such. I knew of some readers that could
'catch' a card in the path after reading e.g. for an alternate stacker
but none that could actually go backward. (Or skip forward either.)

I was thinking of ones that could re-read the whole deck. You don't
have to go backwards to seek.
But usually not to arbitrary bytes, thus fitting the fget,setpos model

That's equally true of magnetic disks! The byte-level seeking can be
simulated in software, while the hardware deals in blocks.

-- Richard
 
W

Walter Roberson

On 10 Jun 2008 08:54:44 GMT, (e-mail address removed) (Richard Tobin)
wrote:
I assume this means classic punched or optical-mark; not newer
(plastic) cards like mag-stripe and RFID, mostly for ID, access and
payment rather than data as such. I knew of some readers that could
'catch' a card in the path after reading e.g. for an alternate stacker
but none that could actually go backward. (Or skip forward either.)

A "tub file" perhaps??
http://en.wikipedia.org/wiki/Tub_file
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top