|  | 
#include <sys/fsext.h>
#include <conio.h>
/* A simple example of a write handler which converts DOS I/O to the
   screen into direct writes to video RAM.  */
static int
my_screen_write (__FSEXT_Fnumber func, int *retval, va_list rest_args)
{
  char *buf, *mybuf;
  size_t buflen;
  int fd = va_arg (rest_args, int);
  if (func != __FSEXT_write || !isatty (fd))
    return 0;  /* and the usual DOS call will be issued */
  buf = va_arg (rest_args, char *);
  buflen = va_arg (rest_args, size_t);
  mybuf = alloca (buflen + 1);
  memcpy (mybuf, buf, buflen);
  mybuf[buflen] = '\0';
  cputs (mybuf);
  *retval = buflen;
  return 1;  /* meaning that we handled the call */
}
/* Install our handler.  The `attribute constructor' causes this
   function to be called by the startup code.  */
static void __attribute__((constructor))
install_screen_write_handler (void)
{
  __FSEXT_set_function (fileno (stdout), my_screen_write);
}
 |