/* sys/ioctl1.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */

#include <errno.h>
#include <os2emx.h>
#include <emx/syscalls.h>
#include "syscalls.h"


int __ioctl1 (int handle, int code)
{
  ULONG rc;
  ULONG htype, hflags;

  if (code != 0)
    {
      errno = EINVAL;
      return -1;
    }
  rc = DosQueryHType (handle, &htype, &hflags);
  if (rc != 0)
    {
      _sys_set_errno (rc);
      return -1;
    }
  if ((htype & 0xff) == 0)
    return 0;
  return (hflags & 0x0f) | 0x80;
}
