home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ibmtool.zip
/
ioctl.c
< prev
next >
Wrap
Text File
|
1997-11-07
|
2KB
|
88 lines
/******************************************************************************/
/* */
/* FILE: IOCTL.C */
/* */
/* PURPOSE: This file contains Ioctl specific code. */
/* */
/* FUNCTIONS: Version */
/* GenIoctl */
/* */
/******************************************************************************/
#define INCL_SUB
#define INCL_BASE
#define INCL_DOS
#include <os2.h>
#include <stdio.h>
#include <stdarg.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "ndis.h"
#include "ibmtool.h"
#include "ioctl.h"
// Fix for faulty include file. Here is prototype for some API functions.
USHORT APIENTRY DosGetVersion (PUSHORT pVer);
USHORT APIENTRY DosDevIOCtl (PVOID pData, PVOID pParms, USHORT usFun,
USHORT usCategory, HFILE hDev);
USHORT DOSVersion;
void Version ()
{
/* Determine whether this is DOS or OS/2 */
if (DosGetVersion (&DOSVersion))
{
printf ("Error determining DOS version.\n");
exit (-1);
}
/* changing == to >= */
if ((DOSVersion >> 8) >= 10)
DOSVersion = OS2;
else
{
DOSVersion = DOS;
WedgeCommon->UseGDT = TRUE;
}
}
int GenIoctl (void far *IoctlDataPtr, ULONG device_fd)
{
int rc;
if (DOSVersion == OS2)
{
rc = DosDevIOCtl (IoctlDataPtr,
0L,
DIAG_BIND,
WEDGE_CATEGORY,
(USHORT) device_fd);
}
else
{
_asm {
push ds
mov bx, device_fd
mov ah, 044h
mov al, 003h
mov cx, 1
mov dx, word ptr IoctlDataPtr
mov ds, word ptr IoctlDataPtr+2
int 21h
pop ds
jc notok
xor ax, ax
notok:
mov rc, ax
}
}
return rc;
}