home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progc
/
c_all592.arj
/
TI870.ASC
< prev
Wrap
Text File
|
1992-04-20
|
6KB
|
199 lines
PRODUCT : Borland C++ NUMBER : 870
VERSION : 3.0
OS : DOS
DATE : April 20, 1992 PAGE : 1/3
TITLE : Increasing The Number Of Available File Handles
QUESTION:
How do I increase the number of FILES available to my
program under Borland C++ 3.0?
ANSWER:
Increasing the number of FILES available to a program in
Borland C++ involves changing 3 FILES from the RTL (Run-Time
Library): _NFILE.H, files.C, and FILES2.C. The only change
you actually need to make is in _NFILE.H, where you redefine
the macro _NFILE_. The FILES files.C and FILES2.C just need
to be recompiled to reflect the changes to this macro.
Assigning a value to this macro will set the maximum number
of FILES available to your program including the 5 standard
FILES ( stdin, stdout, stderr, stdaux, stdprn ).
The changes can be made in two different ways. One, you can
simply recompile files.C and FILES2.C in the appropriate
memory model and link them in with your program. In the
IDE, this means adding the two .C FILES to your project. On
the command line, this means adding them to your BCC line.
For example:
BCC myprog.c FILES.c files2.c
The effect of this will be that you redefine the symbols in
the two FILES which have been previously defined in the
standard libraries, and precedence will go to yours. You
can ignore the warnings you will get from the linker if you
have the Warn Duplicate Symbols option set (/d).
The other way is to replace the files.C and FILES2.C in the
standard library with your own. The advantage of doing this
is if you always want to have access to more than 20 FILES
in your programs, you will not always have to add those two
FILES to your project. You can replace them by first
recompiling the FILES using BCC like this:
BCC -c -mX FILES.c files2.c
where the X in -mX refers to the memory model of the library
you want to replace them in ( you will have to do this
repeatedly if you want to replace all the memory models ).
PRODUCT : Borland C++ NUMBER : 870
VERSION : 3.0
OS : DOS
DATE : April 20, 1992 PAGE : 2/3
TITLE : Increasing The Number Of Available File Handles
This will result in files.OBJ and FILES2.OBJ which you can
then add to the appropriate library in the LIB directory
using TLIB. For the large model it would look like this:
TLIB ml.lib +-files.obj +-files2.obj
Below is the source for the three FILES you need to replace,
if you do not already have the RTL for Borland C++ 3.0 ( in
your \BORLANDC\CLIB dir ). If you choose to add the FILES
directly to your program, you can merge them into one FILE
if you choose. It is not required that the variables be
defined in separate FILES, this is just how it is done in
the RTL.
One final note is that if you want this to be extended to
Windows programs, you will have to add a call to the Windows
API funciton SetHandleCount to tell Windows that your
program needs more FILE HANDLES.
SOURCE:
// _NFILE.H
// Copyright (C) 1992 Borland International, Inc.
// All Rights Reserved
// Maximum number of open FILES
#define _NFILE_ 20
//..........................................................
// FILES.C
// Copyright (C) 1992 Borland International, Inc.
// All Rights Reserved
#include <stdio.h>
#include <_nfile.h>
#define _F_STDIN (_F_READ | _F_TERM | _F_LBUF)
#define _F_STDOUT (_F_WRIT | _F_TERM | _F_LBUF)
#define _F_STDERR (_F_WRIT | _F_TERM)
#define _F_STDAUX (_F_RDWR | _F_TERM | _F_BIN)
#define _F_STDPRN (_F_WRIT | _F_TERM | _F_BIN)
PRODUCT : Borland C++ NUMBER : 870
VERSION : 3.0
OS : DOS
DATE : April 20, 1992 PAGE : 3/3
TITLE : Increasing The Number Of Available File Handles
#if !defined( _RTLDLL )
file _streams [_NFILE_] =
{
{0, _F_STDIN, 0, 0, 0, NULL, NULL, 0, (short) stdin},
{0, _F_STDOUT, 1, 0, 0, NULL, NULL, 0, (short) stdout},
{0, _F_STDERR, 2, 0, 0, NULL, NULL, 0, (short) stderr},
{0, _F_STDAUX, 3, 0, 0, NULL, NULL, 0, (short) stdaux},
{0, _F_STDPRN, 4, 0, 0, NULL, NULL, 0, (short) stdprn}
};
#endif // _RTLDLL
//..........................................................
// FILES2.C
// Copyright (C) 1992 Borland International, Inc.
// All Rights Reserved
#include <io.h>
#include <fcntl.h>
#include <_nfile.h>
unsigned _nfile = _NFILE_;
unsigned int _openfd[_NFILE_] =
{
O_RDONLY | O_DEVICE | O_TEXT,
O_WRONLY | O_DEVICE | O_TEXT,
O_WRONLY | O_DEVICE | O_TEXT,
O_RDWR | O_DEVICE | O_BINARY,
O_WRONLY | O_DEVICE | O_BINARY
};
//..........................................................