#include <stdio.h>
#include <string.h>
#include <time.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include "global.h"
#include "custom.h"

#include "manhat-lib/shared_util.h"
#include "manhat-lib/shared_authenticate.h"
#include "manhat-lib/shared_super_util.h"
#include "manhat-lib/shared_super_menu.h"
#include "manhat-lib/shared_cs_course_search.h"
#include "manhat-lib/shared_server_string.h"
#include "manhat-lib/shared_cs_util.h"


void
set_form_data( char *key)
{
  char server_url[MAX_URL + 1];

  cs_set_value("id", key);
  
  /** set the max length of the group and internal course name
  *** text input areas.  The Max length of these are set low to keep 
  *** people from creating ridiculously long names.  These values are 
  *** consistent with version 2.4
  **/
  cs_set_int_value("max_sub", 8);
  cs_set_int_value("max_id", 16);

  /** determine return URL for getting data back from SIS */
#ifdef WNEC_CREATE_COURSE_LINK
  get_server_string(server_url, MAX_URL);    /* shared_server_string.c */
  strcat(server_url,"/");
  strcat(server_url, SBIN_ALIAS);            /* custom.h */
  cs_set_value("sis_back_url", server_url);
  snprintf(server_url, MAX_URL +1, "%s", WNEC_CREATE_COURSE_LINK);
  cs_set_value("sis_action", server_url);
#endif
  
   snprintf(server_url, MAX_URL +1, "%s?id=%s", "super_upload_xml_roster_form", key);  
   cs_set_value("xml_url", server_url);

   snprintf(server_url, MAX_URL +1, "super_import_course_form?id=%s",key);
   cs_set_value("import_url", server_url);

   cs_set_course_group_option_list(COURSE_PATH, ""); /* shared_cs_search_course.c */
}





int
main()
{
  char key[MAX_KEY +1];
  SESSION user;

  cs_cgi_init();
  read_param( key);
  validate_super_key(key, &user);
  set_admin_page(&user, key, 0, "super_new_course_form");  /* shared_super_menu.c */
  set_form_data( key);
  cs_cgi_display("super_new_course_form", 1);
  cs_cgi_destroy();
  return 0;
}
