Subject: Re: FVWM: Make fvwm-root read from stdin?

From: Dan Espen <[email-masked]>
Date: Fri, 03 Jun 2005 13:44:44 -0400

"Mark A. Nicolosi" <[email-masked]> writes:
> On Fri, 2005-06-03 at 10:58 -0400, Dan Espen wrote:
> > I don't think it's a bug.
> > 
> > If you use strace to follow what goes on, Fvwm first checks
> > to see if the file is an XPM file.  It does that by reading
> > the first 4K of the file:
> > 
> > open("/dev/stdin", O_RDONLY)            = 4
> > read(4, "\211PNG\r\n\32\n\0\0\0\rIHDR\0\0\1@\0\0\0\360\10\2\0\0"..., 4096) 
> = 4096
> > close(4)                                = 0
> > 
> > Since the file is PNG, that fails and it then tries XPM:
> > 
> > open("/dev/stdin", O_RDONLY)            = 4
> > read(4, "\350\362\201\217\24W\2425_\7 \365T\316rV\267\331\f\30\274"..., 409
> 6) = 4096
> > close(4)                                = 0
> > 
> > That fails too, since the first 4K of stdin has already been read.
> > Notice how the input data is different.
> > 
> > The problem is that /dev/stdin is a FIFO, once you read it, you can't
> > close it and expect to read the same thing again.
> > 
> > If you use convert to change the file to an XPM, fvwm-root HAPPENS to
> > work, but that's just because right now it tries XPM first.
> 
> That makes perfect sense, thanks. Yeah, converting to an xpm does work.
> Just out of curiosity why is the file closed and reopened if it isn't an
> xpm? Couldn't that buffer be reused when testing if it's a png?

Respond to the list please.

The file is opened and closed by the respective libraries.

Fvwm just passes the filename to libxpm, then libxpm opens and reads
the file. If that fails, Fvwm then passes the file to libpng.

The only exception is when the file has an extension, then it passes
the file to the corresponding library first, if that fails, it tries the
other libraries.

In no case does Fvwm read the file and buffer it anywhere.

-- 
Dan Espen                           E-mail: [email-masked]
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: "Mark A. Nicolosi" <[email-masked]>
Date: Fri, 03 Jun 2005 12:55:31 -0500

> Respond to the list please.

Sorry, didn't realize the mailing list sets the reply-to to that person.
Sorry to Mikhael, too.

> In no case does Fvwm read the file and buffer it anywhere.

Okay, maybe when I get some time, I'll download cvs and check it out.

-- 
Mark A. Nicolosi <[email-masked]>