home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / mfile.c < prev    next >
C/C++ Source or Header  |  1994-03-04  |  1KB  |  38 lines

  1. /*
  2.  * Allows MSDOS program to open more than 20 files
  3.  *
  4.  * Use as:
  5.  * mfile (size, array)
  6.  *   int size;           - sizeof(array) is new maximum number of open files
  7.  *   char far* array; - array for the new table of file handlers
  8.  *
  9.  * Modified for Turbo C version of the MFILE.ASM from LISTSERV@VM1.NODAK.EDU
  10.  *
  11.  * Author: A.Galtchenko (alex@mars.ibioc.serpukhov.su)
  12.  * Date: 8 jul 1991
  13.  */
  14. #include    <dos.h>
  15.  
  16. typedef    char far* FARPTR;
  17.  
  18. void mfile (int size, char far* array)
  19.  
  20. {
  21.     unsigned    psp;
  22.     int far*    pl;
  23.     FARPTR far*    pt;
  24.     int        i;
  25.  
  26.     psp = getpsp();            /* get PSP */
  27.     pl = (int far*)MK_FP(psp,0x32);    /* pointer to size of the filetable header */
  28.     pt = (FARPTR far*)MK_FP(psp,0x34);    /* pointer to filetable header */
  29.     if (size > *pl) {
  30.     for (i = 0; i < *pl; i++)    /* save current filetable header */
  31.         array[i] = (*pt)[i];        /* into new table         */
  32.     for (i = *pl; i < size; i++)    /* fill rem of new table         */
  33.         array[i] = 0xff;
  34.     *pt = array;                    /* new address of program's actual file table */
  35.     *pl = size;            /* new maximum number of open files */
  36.     }
  37. }
  38.