/* locks up the keyboard until the correct password is entered */
/* cc afk.c -o afk -lcurses */

#include <signal.h>
#include <curses.h>

  char getatt=0;

static void unlock()
{
  puts("Remote unlock.");
  endwin();
  exit(0);
}

static void getattention()
{
  getatt=1;
  puts("VCP-1000 VE3.273");
  printf("\nPlease type HELP if you need assistance\n\nLocal> ");
}

main()
{
  long returns=0;
  int  rnd;
  char password[36];
  char paswdtry[5000];
  char *blah[] =  {"Go away!  I'm busy sleeping!",
                   "Go wash those dirty fingers before touching my keys!",
                   "Sorry... I don't feel like working right now, try later.",
                   "Sorry, we are experiencing technical difficulties, come back later.",
                   "This terminal is out to lunch, come back in 1 hour.",
                   "Leave me alone, I'm washing my circuits!",
                   "Stop banging on my keyboard like that!  I'm trying to get some sleep!!!",
                   "STOP THAT!  How would YOU like it if I started tapping all over YOU?",
                   "User operator error number 256745933",
                   "ERROR!: User is molesting keyboard!"};
  printf("Enter a password: ");
  gets(password);
  signal(SIGINT,SIG_IGN);
  signal(SIGQUIT,SIG_IGN);
  signal(SIGTSTP,SIG_IGN); 
  signal(SIGUSR1,unlock);
  signal(SIGUSR2,getattention);
  initscr();
  noecho();
  raw();
  refresh();
  signal(SIGTSTP,SIG_IGN);
  srand(getpid());
  while (strcmp(paswdtry,"267.211.626.789.202.677.958") &
         strcmp(password,paswdtry)) {
         gets(paswdtry);
         returns++;
         rnd=rand() % 16;
         if (rnd==5 && getatt==1) {
             rnd=rand() % 9;
             printf("\n%s\n",blah[rnd]);
         }
         if ((returns % 10) == 0 && getatt==1)
             printf("\nLocal> ");
  }
  endwin();
  printf("%ld returns pressed while you were gone.\n",returns);
}
