#ifndef IMDB_SEARCH_H #define IMDB_SEARCH_H #include "ratings.h" #include // Structure to store languages, regions, and other title information typedef struct { char titleId[13]; // pointer to corresponding ttitleEntry tconst char *language; // Array of languages char *region; // Array of regions char *title; // Array of alternate titles int isOriginalTitle; // Flag for original title } TitleLanguages; typedef struct { char tconst[13]; // Unique title identifier char primaryTitle[256]; char originalTitle[256]; char titleType[64]; char runtimeMinutesgenres[256]; int startYear; int endYear; int isAdult; RatingInfo *ratingInfo; int languageCount; int languageCount_max; TitleLanguages* languages; // Languages associated with the title pthread_mutex_t lock; // Mutex for thread-safe access } TitleEntry; // Struct for search results typedef struct { char tconst[13]; char primaryTitle[256]; TitleEntry *title; char selected[15]; int selected_id; float score; } SearchResult; void trim_whitespace(char *str); int load_languages_and_regions(TitleEntry *titles, int title_count); // Function to load titles from the TSV file int load_titles(TitleEntry **titles, int *title_count, RatingInfo*, int rating_count); int load_title_languages(TitleLanguages **title_languages, int *title_count); // Function to search titles int search_titles(const char *query, TitleEntry *titles, int title_count, SearchResult *results, int max_results); // Function to display search results in a menu and select one SearchResult* select_result(SearchResult *results, int found, const char* search_query); SearchResult* search_and_select(const char *query, TitleEntry *titles, int title_count); #endif // IMDB_SEARCH_H