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: From: Eli Zaretskii 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 > 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.