#ifndef SHARED_COURSE_SEARCH_H
#define SHARED_COURSE_SEARCH_H

#include "../global.h"


#define LAST_SEARCH_FNAME "last_search.txt"
#define TEMPLATES_NAME "__templates__"
#define GROUP_DESCRIPTION_FNAME "description.txt"  /* name of the text file, stored within a course directory, which describes
                                                   ** the courses contained within that directory */

typedef struct subdir_node
  {
   char subdir[MAX_COURSE_SUBDIR + 1];
   struct subdir_node *next;
  } SUBDIR_NODE; 
   


typedef struct course_search_node
   {
    CONFIG_STRUCT conf;
    
    char subdir[MAX_COURSE_SUBDIR + 1];   /* the subdirectory where this course was found */
    char dirname[MAX_FILENAME + 1];       /* the name of the course directory */
    struct course_search_node *next;
   } COURSE_SEARCH_NODE;






typedef struct course_search_params
      {
       char search[MAX_FILENAME + 1];
       int type;
       int where;
       SUBDIR_NODE *subdir_head;
       } COURSE_SEARCH_PARAMS;



typedef struct group_info_list
    {
       char subdir[MAX_COURSE_SUBDIR +1];
       char short_description[MAX_SEMESTER + 1];
       time_t created_time;
       struct group_info_list *next;
    }GROUP_INFO_LIST;

void get_short_group_description(const char *subdir, char *short_description);
GROUP_INFO_LIST *build_course_group_list(const char *course_path);
void free_course_group_list(GROUP_INFO_LIST *head);
void print_course_group_option_list(const char *course_path, int include_description, int include_new, int include_templates, int include_all);
void print_course_group_multi_option_list(const char *course_path, const char *username, int include_description, int include_templates);
void free_subdir_list(SUBDIR_NODE *head);

COURSE_SEARCH_NODE * build_course_search_list(COURSE_SEARCH_PARAMS *params);


void free_course_search_list(COURSE_SEARCH_NODE *head);

void print_search_criteria (COURSE_SEARCH_PARAMS *params, COURSE_SEARCH_NODE *course_head, const char *key, const char *prog);
void print_search_form(const char *action, const char *key, const char *username, const char *bgcolor);
GROUP_INFO_LIST *
build_group_list(const char *course_path);

int
in_last_search(const char *subdir, COURSE_SEARCH_PARAMS *last_search);
void
get_last_search_selections(const char *username, COURSE_SEARCH_PARAMS *last_search);
 void
 write_last_search_selections(const char *username, COURSE_SEARCH_PARAMS *params);



#endif
