Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!mtune!westmark!dave From: dave@westmark.UUCP Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: MS C open file limit on PC Message-ID: <173@westmark.UUCP> Date: Sun, 20-Sep-87 10:42:55 EDT Article-I.D.: westmark.173 Posted: Sun Sep 20 10:42:55 1987 Date-Received: Sun, 20-Sep-87 20:53:48 EDT References: <1576@dicome.UUCP> Organization: Westmark, Inc., Warren, NJ, USA Lines: 32 Keywords: help! Xref: utgpu comp.sys.ibm.pc:7021 comp.lang.c:4247 Summary: MS-DOS, not MS-C In article <1576@dicome.UUCP>, stryker@dicome.UUCP (don Stryker) writes: > I've run up against a disturbing feature of the Microsoft C compiler > for the PC. Microsoft limits an applicaton to 20 open files, 5 of > which are taken up by the standard file handles. I can open my files > using DOS system calls to bypass the compiler, ... This limit is imposed by MS-DOS itself, not by the C compiler. There is a far pointer in the psp at offset 0x34 which points to an array of unsigned char called the open file list. The length of this array is stored as an int at psp offset 0x32. When MS-DOS builds the psp, the array, itself, begins at psp offset 0x18 and is 20 bytes long. To allow, for example, 40 files in a process, do the following: First: set the FILES= parameter in config.sys to a large number. (>40) Then, in your code: 1. Allocate a static array of 40 unsigned char. 2. Initialize each element of the array to 0xff. 3. Copy the 20 bytes from the original array in psp:18 into your array. (This preserves the 5 pre-opened handles.) 4. Store a far pointer to your array at psp:34. 5. Change the int at psp:32 to 40. This works in MS-DOS 3.2, and probably in earlier versions. -- Dave Levenson Westmark, Inc. A node for news. Warren, NJ USA {rutgers | clyde | mtune | ihnp4}!westmark!dave