Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-owner AT sourceware DOT cygnus DOT com List-Unsubscribe: List-Archive: List-Help: , Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com From: "Suhaib M. Siddiqi" To: "Cygwin AT Sourceware DOT Cygnus DOT Com" Subject: DosDevIOCtl Date: Mon, 2 Aug 1999 12:00:11 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Importance: Normal Anyone knows what are the Win32 or ANSI C equvivalents of DosDevIOCtl and DosGetInfoBlock? I need the info for Cygwin-xfree port. I got hold of a commercial porting tool, which translates (rewrites) a code for OS/2 to Win32. It does know know two OS/2 API's DosDevIOCtl and DosGetInfoBlock. If anyone knows the answer, please e-mail me directly, instead of starting an unrelated thread on Cygwin. Thanks Suhaib ---- /*************************************************************************** * E:\Release7\PortTool\Test\PortTest2\xf86sup\example\NT\consel.c (000034): [WinMain]: Must return a value, original main() may have been void main(...) E:\Release7\PortTool\Test\PortTest2\xf86sup\example\NT\consel.c (000044): DosOpen - Check access and share mode flags E:\Release7\PortTool\Test\PortTest2\xf86sup\example\NT\consel.c (000058): DosDevIOCtl - No equivalent API in Win32 E:\Release7\PortTool\Test\PortTest2\xf86sup\example\NT\consel.c (000070): DosDevIOCtl - No equivalent API in Win32 **************************************************************************** / /* Released to the public domain * Use this code freely for own developments */ /* This example is a simple receiver process for the /dev/console device. * It creates an OS/2 window which will display messages that are sent to * the /dev/console window. * Run this application with 'start consvr'. * Afterwards run one of the applications 'conexam' or 'ptyexam -l' to * test the console device. * * In order to keep the example most universal, this example program uses * the Dos* API rather than standard C library functions, which would be * also possible. */ #define INCL_DOSPROCESS #define INCL_DOSFILEMGR // #include #include #include #include #include #include #include "../api/consos2.h" // int main(int argc, char *argv[]) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char buf[200]; APIRET rc; ULONG action,arg,argsz, nread; // HFILE fd; HANDLE fd; /* open device */ // rc = DosOpen((PSZ)"\\dev\\console$", &fd, &action, 0, rc = fd = CreateFile((PSZ)"\\dev\\console$", GENERIC_READ | GENERIC_WRITE|OPEN_SHARE_DENYNONE, GENERIC_READ | GENERIC_WRITE|OPEN_SHARE_DENYNONE, NULL, FILE_OPEN, FILE_ATTRIBUTE_NORMAL, 0); if (rc) { fprintf(stderr, "!!! Cannot open console device, rc=%d\n", rc); fputs("Probably the XF86SUP device driver was not properly installed.\n", stderr); exit(1); } /* grab the console */ arg = 1; rc = DosDevIOCtl(fd, XFREE86_CONS, CONS_TIOCCONS, &arg, sizeof(arg),&argsz, NULL, 0, NULL); if (rc) { fprintf(stderr,"!!! Cannot grab console, status = %d\n",rc); fputs("Possibly another process currently owns the console\n", stderr); // DosClose(fd); CloseHandle(fd); exit(2); } rc = DosDevIOCtl(fd, XFREE86_CONS, CONS_OWNER, NULL, 0, NULL, (PULONG)&buf, sizeof(buf),&argsz); if (rc) { fprintf(stderr,"!!! Cannot get console owner, status = %d\n",rc); fputs("Possibly another process currently owns the console\n", stderr); // DosClose(fd); CloseHandle(fd); exit(2); } printf("Owner of console is: %s\n",buf); fd = _imphandle(fd); for(;;) { fd_set rfds,wfds,efds; int rc; /* read some chars */ memset(buf,0,200); FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&efds); FD_SET(fd,&rfds); printf("%d %x %x %x\n",fd+1,(&rfds)[0],(&rfds)[1],(&rfds)[2]); rc = select(fd+1,&rfds,&wfds,&efds,NULL); printf("rc(select)=%d\n",rc); // rc = DosRead(fd,(PVOID)buf,199,&nread); rc = ReadFile(fd, (PVOID)buf, 199, &nread, NULL); if (rc) { fprintf(stderr, "!!! Read from console returned status=%d\n", rc); break; } if (nread) { fputs(buf,stdout); if (nread < 199) { /* wait some time */ // DosSleep(50); /* 50 msec */ Sleep(50); /* 50 msec */ } } } // DosClose(fd); CloseHandle(fd); exit(0); return 0; } -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com