#include <stdio.h>

/*
 * Intended to be run at checkline < /dev/ttys0 > /dev/ttys0
 * (assumeing ttys0 is your modem).
 *
 * Gives a list of all the characters that get eaten..
 */

void main(void) {
  int i, c;
  char buff[10];
  int j;

  printf("#\n");
  while ((c = getchar()) != '#') fprintf(stderr, "(%c)", c);
  
				/* Check the control characters. */
				/* Check remote --> local first. */
  for (i = 0; i < 255; ++ i) {
    if (i > 32 && i < 96) continue;
    fprintf(stderr, "About to try character %d\n", i);
    printf("F%cG%c\n", i, 17);	/* We send an Xon, in case the */
				/* character got interpreted as an Xoff. */
    do {
      c = getchar();
      fprintf(stderr, "[%c]", c);
    } while ( c != 'D');

    j = 0;
    do {
      buff[j++] = getchar();
    } while (buff[j-1] != 'E');
    buff[j-1] = 0;

    if (j == 1) {
      fprintf(stderr, "escape %d\n", i);
      continue;
    }

    j = atoi(buff);

    if (j != i) {
      fprintf(stderr, "escape %d\n", i);
      continue; 
    }
  }


  printf("0000000\n");
}


