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


#include "shared_survey_path_util.h"
#include "shared_super_key.h"
#include "../survey.h"
#include "../global.h"


void
get_survey_base(SESSION *user, char *base)
{
    if( !strcmp(user->realname, "Admin"))
	snprintf(base, MAX_PATH +1, "../%s/_%s_", SURVEY_DIR, ADMIN_DIR);
    else
	snprintf(base, MAX_PATH +1, "../%s/%s", SURVEY_DIR, user->username);
}
    


void
get_survey_path(SESSION *user, char *survey_path, const char *count)
{
    char base[MAX_PATH +1];

    get_survey_base(user, base);
    snprintf(survey_path, MAX_PATH +1, "%s/%s", base, count);
}


int
get_where_parameter(const char *temp)
{
     if(strlen(temp))
         return  atoi(temp);
     else
         return -1;
}




void
verify_key_path(SESSION *user, const char *key, int is_admin)
{
     if(is_admin)
	validate_super_key(key, user);    /* shared_super_key.c */
     else 
        validate_server_key(key, user);   /* shared_util.c */
        
}

