#ifndef SHARED_COURSE_INFO_H
#define SHARED_COURSE_INFO_H

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

#include "../global.h"
#include "shared_cs_util.h"
#include "shared_util.h"
#include "shared_roster_xml_parser.h"
#include "shared_survey_string.h"
#include "shared_file_util.h"

typedef struct sub_dir_id_node
{
   char subdir_id[MAX_COURSE_SUBDIR +1];
   struct sub_dir_id_node *next;
}SUB_DIR_ID_NODE;


typedef struct src_list
{
	char src_id[MAX_COURSE_ID +1];
	struct src_list *next;
}SRC_LIST;

typedef struct course_id_src_list
{
	char manhat_course_id[MAX_COURSE_ID +1];
        COURSE_TYPE crs_type;
        SRC_LIST *src_head;
	struct course_id_src_list *next;
}COURSE_ID_SRC_LIST;


typedef struct subdir_course_list
{
     char subdir[MAX_COURSE_SUBDIR + 1];
     COURSE_ID_SRC_LIST *course_head;
     struct subdir_course_list *next;
} SUBDIR_COURSE_LIST;


int find_manhat_course_id(SUBDIR_COURSE_LIST *sub_list,  const char *sub_dir, const char *dir_id, char *manhat_course_id, COURSE_TYPE *crs_type);

SUB_DIR_ID_NODE *build_unique_subdir_list(XML_COURSE_INFO_LIST *list);
SUBDIR_COURSE_LIST *build_sub_list_info( SUB_DIR_ID_NODE *unique_dir_list);
void free_sub_list_info(SUB_DIR_ID_NODE *list);
void free_subdir_course_list(SUBDIR_COURSE_LIST *list);



int
list_courses(XML_COURSE_INFO_LIST *list, const char *key,  char *roster_path, SUBDIR_COURSE_LIST *sub_list);  
#endif
