/*
 * greint - interrupt grep search gracefully
 *
 * EDITS:
 *       28-Jan-86   lmf   Initial implementation
 */
#define IDENT "x1.0.a"
#include <stdio.h>
#include "grep.h"

#ifdef rsx
#include <cx.h>
#include <qiottd.h>

extern   quit_it ;

/*
 * establish unsolicited character AST on stderr lun
 */
astarm(flag)
int   flag ;
{
   int   iosb[2], param[6], dsw ;
   int   astsrv() ;

   param[0] = astsrv ;
   param[1] = param[2] = param[3] = param[4] = param[5] = 0 ;

   if((dsw = qiow(IO_ATA, 1, 1, iosb, 0, param)) != IS_SUC)
      error("Can''t arm ast, $DSW= %o %o %o\n", dsw, iosb[0], iosb[1]) ;
}

static
astsrv()
{
   astset() ;
   quit_it = gtdp(0) ;
   astx(1) ;
}

astchk()
{
   return(quit_it) ;
}

#endif

#ifdef rt11

static active = FALSE ;
/*
 * establish unsolicited character AST on stderr lun
 */
astarm(flag)
int   flag ;
{
   active = flag ;
   fprintf(stderr, "\035S\035U\n") ;   /* send TSX single char leadin */
}

astchk()
{
   int   c ;
   if(active && (c = kbinr()) != EOF)
      return(c) ;
   else
      return(0) ;
}

#endif
#ifdef vms
astarm(flag)
int   flag ;
{
return(0);
}
/* dummy entries for VMS */
astchk()
{
return(0) ;
}

#endif
