Exemple #1
0
int
ttyflush(int drop)
{
    int n, n0, n1;

    n0 = ring_full_count(&ttyoring);
    if ((n1 = n = ring_full_consecutive(&ttyoring)) > 0) {
	if (drop) {
	    TerminalFlushOutput();
	    /* we leave 'n' alone! */
	} else {
	    n = TerminalWrite(ttyoring.consume, n);
	}
    }
    if (n > 0) {
	if (termdata && n) {
	    Dump('>', ttyoring.consume, n);
	}
	/*
	 * If we wrote everything, and the full count is
	 * larger than what we wrote, then write the
	 * rest of the buffer.
	 */
	if (n1 == n && n0 > n) {
		n1 = n0 - n;
		if (!drop)
			n1 = TerminalWrite(ttyoring.bottom, n1);
		if (n1 > 0)
			n += n1;
	}
	ring_consumed(&ttyoring, n);
    }
    if (n < 0) {
	if (errno == EAGAIN || errno == EINTR) {
	    return -1;
	} else {
	    ring_consumed(&ttyoring, ring_full_count(&ttyoring));
	    setconnmode(0);
	    setcommandmode();
	    NetClose(net);
	    fprintf(stderr, "Write error on local output.\n");
	    exit(1);
	}
	return -1;
    }
    if (n == n0) {
	if (n0)
	    return -1;
	return 0;
    }
    return n0 - n + 1;
}
Exemple #2
0
    int
Scheduler(int block) /* should we block in the select ? */
{
		/* One wants to be a bit careful about setting returnValue
		 * to one, since a one implies we did some useful work,
		 * and therefore probably won't be called to block next
		 * time (TN3270 mode only).
		 */
    int returnValue;
    int netin, netout, netex, ttyin, ttyout;

    /* Decide which rings should be processed */

    netout = ring_full_count(&netoring) &&
	    (flushline ||
		(my_want_state_is_wont(TELOPT_LINEMODE)
#ifdef	KLUDGELINEMODE
			&& (!kludgelinemode || my_want_state_is_do(TELOPT_SGA))
#endif
		) ||
			my_want_state_is_will(TELOPT_BINARY));
    ttyout = ring_full_count(&ttyoring);

    ttyin = ring_empty_count(&ttyiring);

    netin = !ISend && ring_empty_count(&netiring);

    netex = !SYNCHing;

    /* If we have seen a signal recently, reset things */

    if (scheduler_lockout_tty) {
        ttyin = ttyout = 0;
    }

    /* Call to system code to process rings */

    returnValue = process_rings(netin, netout, netex, ttyin, ttyout, !block);

    /* Now, look at the input rings, looking for work to do. */

    if (ring_full_count(&ttyiring)) {
	    returnValue |= telsnd();
    }

    if (ring_full_count(&netiring)) {
	returnValue |= telrcv();
    }
    return returnValue;
}
Exemple #3
0
void
SetForExit (void)
{
  setconnmode (0);
#if defined TN3270
  if (In3270)
    {
      Finish3270 ();
    }
#else /* defined(TN3270) */
  do
    {
      telrcv ();		/* Process any incoming data */
      EmptyTerminal ();
    }
  while (ring_full_count (&netiring));	/* While there is any */
#endif /* defined(TN3270) */
  setcommandmode ();
  fflush (stdout);
  fflush (stderr);
#if defined TN3270
  if (In3270)
    {
      StopScreen (1);
    }
#endif /* defined(TN3270) */
  setconnmode (0);
  EmptyTerminal ();		/* Flush the path to the tty */
  setcommandmode ();
}
Exemple #4
0
    int
Push3270(void)
{
    int save = ring_full_count(&netiring);

    if (save) {
	if (Ifrontp+save > Ibuf+sizeof Ibuf) {
	    if (Ibackp != Ibuf) {
		memmove(Ibuf, Ibackp, Ifrontp-Ibackp);
		Ifrontp -= (Ibackp-Ibuf);
		Ibackp = Ibuf;
	    }
	}
	if (Ifrontp+save < Ibuf+sizeof Ibuf) {
	    (void)telrcv();
	}
    }
    return save != ring_full_count(&netiring);
}
Exemple #5
0
int
ttyflush (int drop)
{
  register int n, n0, n1;

  n0 = ring_full_count (&ttyoring);
  if ((n1 = n = ring_full_consecutive (&ttyoring)) > 0)
    {
      if (drop)
	{
	  TerminalFlushOutput ();
	  /* we leave 'n' alone! */
	}
      else
	{
	  n = TerminalWrite ((char *) ttyoring.consume, n);
	}
    }
  if (n > 0)
    {
      if (termdata && n)
	{
	  Dump ('>', ttyoring.consume, n);
	}
      /*
       * If we wrote everything, and the full count is
       * larger than what we wrote, then write the
       * rest of the buffer.
       */
      if (n1 == n && n0 > n)
	{
	  n1 = n0 - n;
	  if (!drop)
	    n1 = TerminalWrite ((char *) ttyoring.bottom, n1);
	  if (n1 > 0)
	    n += n1;
	}
      ring_consumed (&ttyoring, n);
    }
  if (n < 0)
    return -1;
  if (n == n0)
    {
      if (n0)
	return -1;
      return 0;
    }
  return n0 - n + 1;
}
Exemple #6
0
static void
SetForExit(void)
{
    setconnmode(0);
    do {
	(void)telrcv();			/* Process any incoming data */
	EmptyTerminal();
    } while (ring_full_count(&netiring));	/* While there is any */
    setcommandmode();
    fflush(stdout);
    fflush(stderr);
    setconnmode(0);
    EmptyTerminal();			/* Flush the path to the tty */
    setcommandmode();
}