#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "global.h"
#include "survey.h"
#include "manhat-lib/shared_util.h"
#include "manhat-lib/shared_super_key.h"
#include "manhat-lib/shared_survey_path_util.h"
#include "manhat-lib/shared_survey_www_util.h"
#include "manhat-lib/shared_survey_string.h"
#include "manhat-lib/shared_cs_util.h"


void
read_parameters(int *is_admin, char *key, char *count,  char *title)
{

     char tmp[10];

      cs_get_required_parameter("id", key, MAX_KEY);
      cs_get_required_parameter("count", count, MAX_PATH);


      cs_get_optional_parameter("admin", tmp, 9);
      *is_admin = !(*tmp)? 0 : atoi(tmp)? 1 : 0;

     cs_get_required_parameter("title", title, MAX_PATH);
     decode_space(title); 

}
	



int
main()
{
   int  is_admin;
   char key[MAX_KEY +1];
   SESSION user;
   char count[MAX_PATH + 1];
   char title[MAX_PATH + 1];
   int password;

   cs_cgi_init();

   read_parameters(&is_admin, key, count,  title);
   
   /** Hmmm.... is_admin isn't used at all ***/
   
   
   validate_super_key(key, &user);
   password = read_password(count);         /* shared_survey_www_util.c */
   set_url( count,  password);              /* shared_survey_www_util.c */
   cs_set_value("linktitle", title);
   cs_cgi_display("survey_www_info", 1);
   cs_cgi_destroy();
   
   return 0;
}

