#include <stdio.h>
#include <string.h>
#include <unistd.h>		


#include "global.h"
#include "custom.h"		/* for date FORMAT strings */

#include "manhat-lib/shared_util.h"
#include "manhat-lib/shared_super_util.h"
#include "manhat-lib/shared_authenticate.h"
#include "manhat-lib/shared_strtrm.h"
#include "manhat-lib/shared_cs_util.h"




static void
set_chat_log(  const char *key)
{
#define MAX_TMP_NAME 30	
  FILE *fp;
  char line[300];
  char name[MAX_TMP_NAME];
  int i =0;
  
  cs_set_current_time();
  
  fp = fopen(CHAT_SYSTEM_LOG_PATH, "r");
  if(fp)
   {
    while(fgets(line,300,fp))
    {
      snprintf(name, MAX_TMP_NAME, "line.%d", i);
      cs_set_value(name, line);
      i++;
    }
    fclose(fp);
   }
#undef MAX_TMP_NAME 	
}





int
main ()
{
  char key[MAX_KEY + 1];	/* from id=? command line */
  SESSION user; 

  cs_cgi_init();
  read_param ( key);
  validate_super_key (key, &user);	/* shared_super_util.c*/

  set_chat_log ( key);
  cs_cgi_display("super_chat_log", 1);
  cs_cgi_destroy();
  return 0;			/* exit successfully */

}

