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

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. /*
  3.  * D_CREATN.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/dosio.h>
  13. #include <go32.h>
  14. #include <dpmi.h>
  15. #include <errno.h>
  16. #include <dos.h>
  17.  
  18. unsigned int _dos_creatnew(const char *filename, unsigned int attr, int *handle)
  19. {
  20.   __dpmi_regs r;
  21.  
  22.   _put_path(filename);
  23.   r.h.ah = 0x5B;
  24.   r.x.cx = attr & 0xFFFF;
  25.   r.x.dx = __tb & 15;
  26.   r.x.ds = __tb / 16;
  27.   __dpmi_int(0x21, &r);
  28.   if ( r.x.flags & 1 )
  29.   {
  30.     errno  = __doserr_to_errno(r.x.ax);
  31.     *handle = (unsigned)-1;
  32.     return r.x.ax;
  33.   }
  34.   *handle = r.x.ax;
  35.   return 0;
  36. }
  37.