61 #define AGS_DBG(x) STB_SPDebugWrite x 72 E_AGS_SEARCH_FIELDS search_fields;
73 E_AGS_MATCH_TYPE match_type;
74 E_AGS_SEARCH_DAYS search_days;
77 E_AGS_MATCH_ACTION match_action;
83 U16BIT cur_service_idx;
92 static BOOLEAN CheckMatch(U8BIT *search_string, U8BIT *compare_string, E_AGS_MATCH_TYPE type);
108 E_AGS_MATCH_TYPE match_type, E_AGS_SEARCH_DAYS search_days,
S_AGS_TIME_RANGE *search_times,
109 E_AGS_MATCH_ACTION match_action)
117 AGS_DBG((
"AGS_OpenSearch"));
120 if (ags_handle != NULL)
125 if (this_search->service != NULL)
127 ADB_GetEventSchedule(FALSE, this_search->service, &this_search->event_list, &this_search->num_entries);
131 this_search->num_entries = 0;
133 this_search->cur_service_idx = 0;
134 this_search->cur_event_idx = 0;
139 this_search->search_fields = search_fields;
140 this_search->match_type = match_type;
141 this_search->search_days = search_days;
142 if (search_times != NULL)
144 this_search->min_time = (search_times->min_hour * 60 * 60) + (search_times->min_minutes * 60) + search_times->min_seconds;
145 this_search->max_time = (search_times->max_hour * 60 * 60) + (search_times->max_minutes * 60) + search_times->max_seconds;
150 this_search->min_time = 0;
151 this_search->max_time = (24 * 60 * 60);
154 this_search->match_action = match_action;
174 U8BIT *event_name = NULL;
175 U8BIT *event_desc = NULL;
176 U8BIT *event_ext_desc = NULL;
177 U32DHMS utc_event_time = 0;
178 U32DHMS loc_event_time = 0;
179 U8BIT event_weekday = 0;
182 BOOLEAN match = FALSE;
186 AGS_DBG((
"AGS_GetNextResult"));
188 while ((match == FALSE) &&
189 (this_search->cur_service_idx < this_search->max_services) &&
190 (this_search->cur_event_idx < this_search->num_entries))
192 cur_event_ptr = this_search->event_list[this_search->cur_event_idx];
193 cur_service = this_search->service;
195 if (cur_event_ptr != NULL)
203 event_time = (DHMS_HOUR32(loc_event_time) * 60 * 60) +
204 (DHMS_MINS32(loc_event_time) * 60) +
205 DHMS_SECS(loc_event_time);
207 AGS_DBG((
"Event day %d search days %02x", event_weekday, this_search->search_days));
212 if (((U8BIT)pow(2, event_weekday - 1) & this_search->search_days) == 0)
215 AGS_DBG((
"Not comparing... weekday not in search"));
218 if ((event_time < this_search->min_time) || (event_time > this_search->max_time))
221 AGS_DBG((
"Not comparing... time not in search range"));
225 if (do_compare == TRUE)
227 AGS_DBG((
"Comparing against..."));
229 if (this_search->search_fields & AGS_SEARCH_TITLE)
232 AGS_DBG((
"Event Name [%s]", event_name));
233 match = CheckMatch(this_search->search_str, event_name, this_search->match_type);
236 if ((match == FALSE) && (this_search->search_fields & AGS_SEARCH_DESC))
239 AGS_DBG((
"Event Desc [%s]", event_desc));
240 match = CheckMatch(this_search->search_str, event_desc, this_search->match_type);
243 if ((match == FALSE) && (this_search->search_fields & AGS_SEARCH_EXT_DESC))
246 AGS_DBG((
"Event Extended Desc [%s]", event_ext_desc));
247 match = CheckMatch(this_search->search_str, event_ext_desc, this_search->match_type);
256 *serv_ptr = cur_service;
260 this_search->cur_event_idx++;
263 if (this_search->cur_event_idx >= this_search->num_entries)
267 this_search->event_list = NULL;
268 this_search->num_entries = 0;
274 if (this_search->service != NULL)
276 AGS_DBG((
"Populating event list"));
277 ADB_GetEventSchedule(FALSE, this_search->service, &this_search->event_list, &this_search->num_entries);
278 AGS_DBG((
"Finished copying events"));
282 AGS_DBG((
"No more services"));
283 this_search->num_entries = 0;
284 this_search->event_list = NULL;
287 this_search->cur_service_idx++;
288 this_search->cur_event_idx = 0;
307 AGS_DBG((
"AGS_CloseSearch"));
322 static BOOLEAN CheckMatch(U8BIT *search_string, U8BIT *compare_string, E_AGS_MATCH_TYPE type)
324 BOOLEAN result = FALSE;
327 U8BIT *save_ptr = NULL;
328 U32BIT unicode_str_size;
329 BOOLEAN ignore_case = FALSE;
332 if ((search_string == NULL) || (compare_string == NULL))
335 if ((type & AGS_MATCH_IGNORE_CASE) != 0)
338 type &= ~AGS_MATCH_IGNORE_CASE;
343 case AGS_MATCH_ANY_WORD:
344 case AGS_MATCH_ALL_WORDS:
349 if (tmp_string != NULL)
351 memcpy(tmp_string, search_string, unicode_str_size);
355 while (token != NULL)
361 if (type == AGS_MATCH_ANY_WORD)
367 if (type == AGS_MATCH_ALL_WORDS)
376 if (tmp_string != NULL)
385 case AGS_MATCH_EXACT_PHRASE:
394 case AGS_MATCH_NOT_EQUAL:
405 case AGS_MATCH_CONTAINS_PHRASE:
U16BIT ADB_GetNumServices(void)
Returns the total number of services in the database.
U8BIT * STB_UnicodeStrStr(U8BIT *str1, U8BIT *str2, BOOLEAN ignore_case)
Finds the first occurence of str2 in str1 and returns a pointer to the substring (as per strstr) ...
U8BIT * STB_UnicodeStringTokenise(U8BIT *str, U8BIT **save_ptr)
Divides the (space separated) string up into individual words and returns them one per call...
Application configuration.
Header file - macros and function prototypes for public use.
Header file for NVM data handling functions.
U32DHMS ADB_GetEventStartDateTime(void *event_ptr)
Returns a value representing the date and time of the start of the given event.
void * STB_AppGetMemory(U32BIT bytes)
Attempts to allocate memory from the application heap.
U8BIT * ADB_GetEventDescription(void *event_ptr)
Returns the short event description text of the event as a UTF-8 string. The returned string should b...
U8BIT * STB_ConvertStringToUTF8(U8BIT *string, U16BIT *nchar, BOOLEAN strip_DVB_cntrl_char, U32BIT lang_code)
Converts the given DVB coded string into a UTF-8 unicode string. The returned string will be preceded...
U32DHMS STB_GCConvertDHMS(U32DHMS dhms, E_STB_GC_CONVTYPE conv)
Converts the given date/time to local or GMT.
S8BIT STB_CompareUnicodeStrings(U8BIT *string1_ptr, U8BIT *string2_ptr, BOOLEAN exact_match, BOOLEAN ignore_case)
Compares the contents of the two given unicode strings and returns the status (as per strcmp) ...
void STB_ReleaseUnicodeString(U8BIT *string)
Releases the specified unicode string, freeing associated heap resources.
Debug functions header file.
Header file - Function prototypes for linked lists.
Header file - macros and function prototypes for public use.
Header file - macros and function prototypes for public use.
Database access defines, structures and public functions.
Header for STB unicode string handling routines.
U32BIT STB_GetNumBytesInString(U8BIT *string_ptr)
Determines the no of bytes of the given string.
Header file - Function prototypes for operating system.
System Wide Global Technical Data Type Definitions.
void STB_AppFreeMemory(void *addr)
Releases previously allocated application heap memory.
Header file - Function prototypes for heap memory.
U8BIT * ADB_GetEventExtendedDescription(void *event_ptr)
Returns the extended event description text of the event as a UTF-8 string. The returned string shoul...
BOOLEAN AGS_GetNextResult(void *ags_handle, U16BIT *event_id, void **serv_ptr)
Gets the next matching result for an open search.
void * ADB_GetNextServiceInList(U32BIT list_type, void *serv)
Returns the next service, in LCN order, for the given list type, starting from the given service...
void ADB_GetEventSchedule(BOOLEAN include_old_events, void *serv_ptr, void ***elist_ptr, U16BIT *num_entries_ptr)
Allocates and returns an array containing copies of events for the given service from the service's E...
U16BIT ADB_GetEventId(void *event_ptr)
Returns the event id for the given event.
U8BIT * ADB_GetEventName(void *event_ptr)
Returns the name of the event as a UTF-8 string. The returned string should be freed using STB_Releas...
void ADB_ReleaseEventList(void **elist, U16BIT num_entries)
Frees all teh events in the given list and all associated memory for those events.
Application database access functions.
void AGS_CloseSearch(void *ags_handle)
Closes an open search and frees all associated resources.
Header file - macros and function prototypes for public use.
void * AGS_OpenSearch(U8BIT *search_str, E_AGS_SEARCH_FIELDS search_fields, E_AGS_MATCH_TYPE match_type, E_AGS_SEARCH_DAYS search_days, S_AGS_TIME_RANGE *search_times, E_AGS_MATCH_ACTION match_action)
Opens an EPG Search.
E_STB_GC_WEEKDAY STB_GCGetDateWeekDay(U16BIT code)
Returns the weekday number of the specified date code.
macros and function prototypes for public use