home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / dos / compat / d_findf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-09  |  982 b   |  43 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. /*
  3.  * D_FINDF.C.
  4.  *
  5.  * Written by Peter Sulyok 1995 <sulyok@math.klte.hu>.
  6.  *
  7.  * This file is distributed WITHOUT ANY WARRANTY; without even the implied
  8.  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9.  *
  10.  */
  11.  
  12. #include <libc/stubs.h>
  13. #include <libc/dosio.h>
  14. #include <go32.h>
  15. #include <errno.h>
  16. #include <dpmi.h>
  17. #include <string.h>
  18. #include <dos.h>
  19.  
  20. unsigned int _dos_findfirst(char *name, unsigned int attr, struct _find_t *result)
  21. {
  22.   __dpmi_regs r;
  23.  
  24.   _put_path(name);
  25.   r.x.dx = (__tb & 15) + strlen(name) + 1;
  26.   r.x.ds = __tb / 16;
  27.   r.h.ah = 0x1A;
  28.   __dpmi_int(0x21, &r);
  29.  
  30.   r.h.ah = 0x4E;
  31.   r.x.dx = (__tb & 15);
  32.   r.x.ds = __tb / 16;
  33.   r.x.cx = attr;
  34.   __dpmi_int(0x21, &r);
  35.   if ( r.x.flags & 1 )
  36.   {
  37.     errno = __doserr_to_errno(r.x.ax);
  38.     return r.x.ax;
  39.   }
  40.   dosmemget(__tb + strlen(name) + 1, sizeof(struct _find_t), result);
  41.   return 0;
  42. }
  43.