W3C home > Mailing lists > Public > www-lib@w3.org > April to June 1999

LineMode as WIN32 console app

From: Rick Kwan <kenobi@coruscant.lightsaber.com>
Date: Wed, 30 Jun 1999 21:14:05 -0700
Message-Id: <199907010414.VAA18237@coruscant.lightsaber.com>
To: www-lib@w3.org
I cringe a bit when I say this, but... I am trying to get LineMode
browser to run as a WIN32 console app on NT.  Ultimately, I will
capture the formatted output in a separate process via a pipe.
(What?  Not threads of a single process?)

I've generated a new project and new .mak file.  HTBrowse.c did not
compile because "lm" in readConsole() was undefined.  I had to add it
as a parameter to readConsole() and get its value in scan_command().
The changes I made are noted below.  (The line numbers will not agree
with the current CVS repository or 5.2.8 because it is a bit polluted
with my special purpose code.)

The problem now is that it hangs after displaying the first screenful
of text.  In the MSVC++ 5.0 debugger, I can see it invoke

    HTEventList_register(GetStdHandle(STD_INPUT_HANDLE),
	HTEvent_READ, ConsoleEvent);

But the code in this routine seems to be oriented toward sockets.
When passed the handle, it attempts to invoke WSAAsyncSelect(), which
returns a result < 0.  Ultimately, readConsole() never gets invoked.

I suspect readConsole() has been dead for quite some time.
Is using it for console and pipes the wrong approach?
Is there another recommended approach?

Of course, my UNIX version works fine in pipes, console, etc...

--Rick Kwan, Lightsaber Computing
  rick.kwan@lightsaber.com


*** WARNING:  Your line numbers may/will vary
*** back/HTBrowse.c Wed Jun 30 11:14:38 1999
--- HTBrowse.c Wed Jun 30 18:34:36 1999
***************
*** 1374,1380 ****
  */
  
  #ifdef WWW_WIN_CONSOLE
! PUBLIC BOOL readConsole(HANDLE conIn, char* buf, int len, int* pRed)
  {
      DWORD recordIndex, bufferIndex, toRead, red;
      PINPUT_RECORD pInput;
--- 1374,1380 ----
  */
  
  #ifdef WWW_WIN_CONSOLE
! PUBLIC BOOL readConsole(HANDLE conIn, LineMode *lm, char* buf, int len, int* pRed)
  {
      DWORD recordIndex, bufferIndex, toRead, red;
      PINPUT_RECORD pInput;
***************
*** 1495,1500 ****
--- 1495,1501 ----
      /* buf happens to == eatText's buffer but not neccesary */
      static char buf[RESPONSE_LENGTH];
  #ifdef WWW_MSWINDOWS
+     LineMode * lm;
      int red;
      int ret;
  #endif
***************
*** 1503,1511 ****
      if (type == HTEvent_TIMEOUT) return timeout_handler (s, param, type);
  
  #ifdef WWW_MSWINDOWS
      while(1) {
  #ifdef WWW_WIN_CONSOLE
! 	if (!readConsole((HANDLE)s, buf, sizeof(buf), &red)) {
          HTTRACE(PROT_TRACE, "Read Console... READ ERROR\n");
  	    return HT_ERROR;
  	}
--- 1504,1513 ----
      if (type == HTEvent_TIMEOUT) return timeout_handler (s, param, type);
  
  #ifdef WWW_MSWINDOWS
+     lm = Context_getLineMode (req);
      while(1) {
  #ifdef WWW_WIN_CONSOLE
! 	if (!readConsole((HANDLE)s, lm, buf, sizeof(buf), &red)) {
          HTTRACE(PROT_TRACE, "Read Console... READ ERROR\n");
  	    return HT_ERROR;
  	}
Received on Wednesday, 30 June 1999 23:45:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:29 GMT