delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/05/08/08:23:42

Message-ID: <33721B44.2FDB@bo.dada.it>
Date: Thu, 08 May 1997 20:28:20 +0200
From: Diego Zuccato <dz AT bo DOT dada DOT it>
Organization: CyberSpace Software Labs BBS
MIME-Version: 1.0
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
CC: djgpp-workers AT delorie DOT com
Subject: Re: write() modified to handle __FSEXT funcs on text files
References: <Pine DOT SUN DOT 3 DOT 91 DOT 970508103905 DOT 19087C-100000 AT is>

Eli Zaretskii wrote:

> Thanks, but I think the call to the __FSEXT function should be *before*
> the conversion,
I too. But it's quite anti-intuitive. After all, text files are DOS
specific, right ?
I wrote a 'portable' locker for a database and a friend told me that in
Linux O_BINARY and O_TEXT aren't defined.

> for two reasons:
>         1) The hook might not need the conversion at all, in which
> case you are just waisting cycles.
Right. But if I don't want conversion, I open it in binary format...

>         2) It is usually a bad idea to call a function after data has
> been put into the transfer buffer, but *before* you call DOS.  That's
> because many library functions overwrite the transfer buffer; if the
> __FSEXT hook uses any of them and then returns zero (meaning it didn't
> handle the call), you will write garbage to the file.
This could be a quite hard trouble. Calling __FSEXT_write without
converting the buffer could be really easy (just 2 lines to add to the
original code...). Or we could call a user-defined function to handle
text conversion (__FSEXT_txt_conv ?)...

> I also think that the code is incorrect:
[...]
> That `else' clause shouldn't be there: you need also call DOS if
> `func' is non-NULL, i.e. a handler *was* installed, but calling it
> returned zero, meaning that it didn't handle this particular call.
You're right. I didn't notice that because I handle all the calls...
Well, if it's right for all to call __FSEXT_write BEFORE converting the
buffer, I'll post the new source tomorrow...

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019