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

Date: Thu, 8 May 1997 10:40:36 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Diego Zuccato <dz AT bo DOT dada DOT it>
cc: djgpp-workers AT delorie DOT com
Subject: Re: write() modified to handle __FSEXT funcs on text files
In-Reply-To: <33702E18.28BE@bo.dada.it>
Message-ID: <Pine.SUN.3.91.970508103905.19087C-100000@is>
MIME-Version: 1.0

On Wed, 7 May 1997, Diego Zuccato wrote:

> I just did a bit of C&P with DJ's code from _write()and now it's nearly
> as fast as before but supports FSEXT funcs on text files too. FSEXTwrite
> func will be called with the *already converted* buffer. I think no
> changes in documentation are required, since (IMHO) behaviour is like
> expected : first buffer is converted, THEN __FSEXT is called.

Thanks, but I think the call to the __FSEXT function should be *before*
the conversion, for two reasons: 

	1) The hook might not need the conversion at all, in which
case you are just waisting cycles.

	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.

I also think that the code is incorrect:

    /* we now have a transfer buf stuffed with data; write it out */
    if (func)
    {
     int rv;
     if (func(__FSEXT_write, &rv, &handle))
      return rv;
    }
    else
    {
     r.x.ax = 0x4000;
     r.x.bx = handle;
     r.x.cx = bytes_in_tb;
     r.x.dx = __tb & 15;
     r.x.ds = __tb / 16;
     __dpmi_int(0x21, &r);

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.

- Raw text -


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