#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_lock.h"
#include "manhat-lib/shared_cs_util.h"



	
static void
delete_log( char *logfile)
{
  char fname[MAX_PATH +1];

  snprintf(fname, MAX_PATH+1, "../%s/%s/%s", USERS_DIR, LOGS_DIR, logfile);
  unlink(fname);
  
}

void
read_parameters( char *key,  char *logfile, int *verify)
{
    char temp[10];
    cs_get_required_parameter ("id", key, MAX_KEY);
    cs_get_required_parameter ("logfile", logfile, MAX_FILENAME);
    cs_get_optional_parameter ("verify", temp, 10);
    *verify = atoi(temp);
}
void set_data()
{
   cs_set_int_value("display", 1);
}

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

  cs_cgi_init();
  read_parameters ( key, logfile, &verify);
  validate_super_key (key, &user);	/* shared_super_util.c*/
  if(verify ==0)
     set_data();
  else
    delete_log(logfile);
  cs_cgi_display("super_delete_stat_log", 1);
  cs_cgi_destroy(); 

  return 0;			/* exit successfully */

}

