Message-ID: <33721B44.2FDB@bo.dada.it> Date: Thu, 08 May 1997 20:28:20 +0200 From: Diego Zuccato Organization: CyberSpace Software Labs BBS MIME-Version: 1.0 To: Eli Zaretskii CC: djgpp-workers AT delorie DOT com Subject: Re: write() modified to handle __FSEXT funcs on text files References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk 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...