Listing 1

cls ()
{
     char *getenv(), *term, *cl;

  term = getenv ("TERM");
  if (!strcmp(term, "ansi"))
    cl = "\033[2J\033[H";
  else if (!strcmp(term, "wy50"))
    cl = "\033*";
           /*  add other terminals ...         */
           /*  if all else fails, try a form feed  */
  else
    cl = "\f";
  fputs (cl, stderr);
}