/* The original version of this program can be found at http://damb.dk */
#include <curses.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/socket.h>
#include <fcntl.h>

const char *const ben[] =
{
  "  )))",
  "  |||",
  "  (((",
  "  |||"
};

void TextOut(int x, int y, const char *text)
{
  while(*text)
  {
    move(y, x++);
    addch(*text);
    text++;
  }
  refresh();
}

void MySleep(int ms)
{
  struct timeval Time;
  Time.tv_sec = 0;
  Time.tv_usec = ms*1000;
  select(0, 0, 0, 0, &Time);
}

int main(void)
{
   int i;
   initscr();
   cbreak();
   noecho();
   intrflush(stdscr, FALSE);

   for(i = 0; i < 3; i++)
   {
      TextOut(0, i, "                                                  ");
   }

   for(i = 0; i < 40; i++)
   {
      TextOut(i, 0, ben[i%4]);
      TextOut(i, 1, " -OOOO:");
      TextOut(i, 2, ben[i%4]);
      MySleep(300);
   }

   return 0;
}