ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2011/03/16/06:27:43

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Date: Wed, 16 Mar 2011 06:27:33 -0400
Message-Id: <E1Pznwz-0000IM-BM@fencepost.gnu.org>
From: Eli Zaretskii <eliz AT gnu DOT org>
To: djgpp AT delorie DOT com
In-reply-to:
<5b55a372-17c3-4bc6-b1c3-7ca7ab9a1612 AT u6g2000vbh DOT googlegroups DOT com>
(message from RayeR on Wed, 16 Mar 2011 02:07:00 -0700 (PDT))
Subject: Re: What DOS call is used by libc/fopen("w") and fprints() in djgpp 2.04 beta?
References: <5b55a372-17c3-4bc6-b1c3-7ca7ab9a1612 AT u6g2000vbh DOT googlegroups DOT com>
Reply-To: djgpp AT delorie DOT com

> From: RayeR <glaux AT centrum DOT cz>
> Newsgroups: comp.os.msdos.djgpp
> Date: Wed, 16 Mar 2011 02:07:00 -0700 (PDT)
> 
> Under msdos I got null pointer as expected according to ansi c spec.
> If I then tried to write to NULL by fwrite() program crashed.
> Under freedos it opened something (NUL device?) and fopen returned a
> valid pointer. fwrite() didn't crashed, fclose() didn't return error.
> But of course file was not created. I think this is a bad idea because

You can see the system calls in djlsr203.zip (assuming you use DJGPP
v2.03, that is).  What happens is that fwrite copies data to a buffer
until it is full, then calls _flsbuf (see flsbuf.c in djlsr203.zip),
which in turn calls _write (see _write.c) which invokes Int 21h with
the AH register set to 40h, the DOS Write To File Or Device function.

As for fopen, the exact sequence of system calls depends on the flags
you passed to it.  I think it eventually calls Int 21h AH=3Ch (Create
File), but I cannot tell for sure without seeing your code.

- Raw text -


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