/* * common.c: TVM2VDR plugin for the Video Disk Recorder * * See the README file for copyright information and how to reach the author. * */ #include "common.h" #ifndef __LV_LIB #include "config.h" cMutex logMutex; //*************************************************************************** // Debug //*************************************************************************** void tell(int eloquence, const char* format, ...) { if (TVM2VDRConfig.loglevel < eloquence) return ; const int sizeBuffer = 100000; char t[sizeBuffer+100]; *t = 0; va_list ap; cMutexLock lock(&logMutex); va_start(ap, format); // snprintf(t, sizeBuffer, "TVM2VDR: "); vsnprintf(t+strlen(t), sizeBuffer-strlen(t), format, ap); syslog(LOG_ERR, "%s", t); va_end(ap); } #endif // __LV_LIB //*************************************************************************** // String Operations //*************************************************************************** void removeChars(string& str, string chars) { int pos = 0; while ((pos = str.find_first_of(chars, pos)) != string::npos) str.erase(pos, 1); } void removeWord(string& pattern, string word) { int pos; if ((pos = pattern.find(word)) != string::npos) pattern.swap(pattern.erase(pos, word.length())); }