Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!ddl From: ddl@husc6.UUCP (Dan Lanciani) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: MS C open file limit on PC Message-ID: <2853@husc6.UUCP> Date: Sun, 20-Sep-87 16:57:00 EDT Article-I.D.: husc6.2853 Posted: Sun Sep 20 16:57:00 1987 Date-Received: Sun, 20-Sep-87 22:56:56 EDT References: <1576@dicome.UUCP> <173@westmark.UUCP> Organization: Harvard University Computer Services Lines: 46 Summary: a little more complicated... Xref: mnetor comp.sys.ibm.pc:8052 comp.lang.c:4448 In article <173@westmark.UUCP>, dave@westmark.UUCP (Dave Levenson) writes: | 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. Unfortunately, the limit is also imposed by the C library which maintains its own table of open file descriptors. This table contains information about the binary/text mode of the file and whether it is open (don't know why they really need the second). (This is for MSC 4.0.) | 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. Then find crt0dat.asm on your startup source disk and enlarge the file descriptor table from 20 to whatever size you need. Build the small, medium, compact, large, and huge versions of crt0dat.obj and replace them in your libraries. | This works in MS-DOS 3.2, and probably in earlier versions. It works in 3.1... Note also that you may close some of those 5 initial descriptors to make a few free ones. Dan Lanciani ddl@harvard.*