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

#include "global.h"

#include "manhat-lib/shared_util.h"
#include "manhat-lib/shared_cs_util.h"
#include "manhat-lib/shared_news_util.h"
#include "manhat-lib/shared_file_util.h"


static void
read_parameters (char *course, char *key)
{
  char temp[20];

  cs_get_required_parameter ("validate", temp, 9);	/* shared_cgi_util.c */
  cs_get_required_parameter ("crs", course, MAX_PATH);	/* shared_cgi_util.c */
  cs_get_required_parameter ("id", key, MAX_KEY);
}




int
main (void)
{
  char course[MAX_PATH + 1];	/* from crs=? command line */
  char key[MAX_KEY + 1];	/* from id=? command line */
  char clipboard_path[MAX_PATH + 1];	/* complete path to this user's clipboard directory */
  SESSION user;
  CONFIG_STRUCT conf;		/* the configuration read from config file */

  cs_cgi_init();
  read_parameters (course, key);
  read_configuration_file (course, &conf);	/* shared_util.c */
  validate_key (key, &user, &conf);	/* shared_util.c */

  if (user.group != FACULTY)
    cs_critical_error (ERR_REQUEST_DENIED, "");

  snprintf (clipboard_path, MAX_PATH + 1, "%s%s/", CLIPBOARD_PATH, user.id);

  kill_directory (clipboard_path);	/* shared_file_util.c */
  printf ("Location:%s?crs=%s&id=%s\n\n", "admin_main_menu", course, key);
  cs_cgi_destroy();
  return 0;
}

