#ifndef __EPGSEARCH_TOOLS_INC__
#define __EPGSEARCH_TOOLS_INC__

#include <vdr/config.h> // For VDRVERSNUM only
#include <vdr/font.h>

#undef CHANNELNAME
#if VDRVERSNUM && VDRVERSNUM >= 10315
#define CHANNELNAME(x) (x ? (EPGSearchConfig.useShortChNames==1?x->ShortName(true):x->Name()) : "")
#else
#define CHANNELNAME(x) (x ? x->Name() : "")
#endif

#undef GETDATESTRING
#if VDRVERSNUM && VDRVERSNUM >= 10318
#define GETDATESTRING(x) *(x->GetDateString()) 
#else
#define GETDATESTRING(x) x->GetDateString()
#endif

#undef GETTIMESTRING
#if VDRVERSNUM && VDRVERSNUM >= 10318
#define GETTIMESTRING(x) *(x->GetTimeString()) 
#else
#define GETTIMESTRING(x) x->GetTimeString()
#endif

#undef PRINTDAY
#if VDRVERSNUM && VDRVERSNUM >= 10318
#define PRINTDAY *cTimer::PrintDay
#else
#define PRINTDAY cTimer::PrintDay
#endif

#undef DAYDATETIMESTRING
#if VDRVERSNUM && VDRVERSNUM >= 10318
#define DAYDATETIME(x) *DayDateTime(x) 
#else
#define DAYDATETIME(x) DayDateTime(x)
#endif

#undef CHANNELSTRING
#if VDRVERSNUM && VDRVERSNUM >= 10318
#define CHANNELSTRING(x) (*x->GetChannelID().ToString()) 
#else
#define CHANNELSTRING(x) (x->GetChannelID().ToString()) 
#endif

#undef ADDDIR
#if VDRVERSNUM && VDRVERSNUM >= 10318
#define ADDDIR *AddDirectory 
#else
#define ADDDIR AddDirectory
#endif


#undef CONFIGDIR
#define CONFIGDIR (!ConfigDir?cPlugin::ConfigDirectory():ConfigDir)

#define CHNUMWIDTH  (numdigits(Channels.MaxNumber()) + 2)

extern char* ConfigDir;

// Helper functions
class cSearchExtCat;
class cEvent;

char* IndentMenuItem(const char*);
void PatchFont(eDvbFont);
bool MatchesSearchMode(char* test, char* values, int searchmode, const char* delim);
char* GetExtEPGValue(const cEvent* e, cSearchExtCat* SearchExtCat);
void ToLower(char* szText);
char* strstri(const char* s1, const char* s2);
char *strreplacei(char *s, const char *s1, const char *s2);
void sleepMSec(long ms);
void sleepSec(long s);
void SendViaSVDRP(const char* SVDRPcmd);
void SendMsg(const char* Message);
bool InEditMode(const char* ItemText, const char* ItemName, const char* ItemValue);

#if VDRVERSNUM <= 10310    
time_t LastModifiedTime(const char *FileName);
#endif
#endif
