#include <stdio.h>
#include <stdlib.h>
#include "global.h"
#include "survey.h"

#include "manhat-lib/shared_survey_util.h"
#include "manhat-lib/shared_survey_modify.h"
#include "manhat-lib/shared_survey_read_param.h"
#include "manhat-lib/shared_survey_path_util.h"
#include "manhat-lib/shared_cs_util.h"

SURVEY_DATA *
read_parameters(int *is_admin, char *key, char *count)
{
   int id;

   read_com_parameters(is_admin, key, count, &id);  /* shared_survey_read_param.c */
   return read_likert_parameters(id);     /* shared_survey_read_param.c */
   
}






int 
main()
{
   int  is_admin;
   char key[MAX_KEY +1];
   char count[MAX_PATH +1];
   SURVEY_DATA *data;
   SESSION user;

   cs_cgi_init();   /* shared_cs_util.c */
   data = read_parameters(&is_admin, key, count); 
   verify_key_path(&user, key, is_admin);   /* shared_survey_path_util.c */

   modify_action( &user, count, data);  /* shared_survey_modify.c */
   printf("Location: %s?admin=%d&id=%s&count=%s&target=%d#%d\n\n", 
		   "survey_new", is_admin, key, count, data->id, data->id);
   free_survey_data(data);
   cs_cgi_destroy();   /* shared_cs_util.c */

   return 0;
}
