uint8_t mysql_send_message(char *message) { if (!mysql_conn) { MYDEBUG ("no mysql_conn available.\n"); return 1; } if (mysql_conn->appstate.mysql.stage < MYSQL_CONNECTED) { MYDEBUG ("mysql_conn not in connected state.\n"); return 1; } if (*mysql_conn->appstate.mysql.u.stmtbuf) { MYDEBUG ("mysql_conn statement buffer busy.\n"); return 1; } if (strlen (message) >= MYSQL_STMTBUF_LEN) { MYDEBUG ("query too long.\n"); return 1; } strcpy(mysql_conn->appstate.mysql.u.stmtbuf, message); MYDEBUG ("successfully queued query.\n"); return 0; }
void cTokenizer::Tokenize(bool trim) { Clear(); MYDEBUG("String wird in Token zerlegt"); char *buffer = NULL; char *token = NULL; char *tok_pointer; buffer = strdup(String); if(trim) buffer = stripspace(buffer); for(token = strtok_r(buffer, Delim, &tok_pointer); token; token = strtok_r(NULL, Delim, &tok_pointer)) { MYDEBUG("Token gefunden: %s", token); if(!trim) Add(new cToken(token)); else Add(new cToken(stripspace(token))); } free(buffer); }
eOSState cCMDImage::Burn(char *file) { MYDEBUG("DVD Schreiben '%s'", file); cFileInfo *info = new cFileInfo(DVDSwitchSetup.DVDWriteScript); if(!info->isExists()) { MYDEBUG("Writescript existiert nicht"); DELETENULL(info); OSD_ERRMSG(tr("Specified Writescript not exist!")); return osContinue; } if(!info->isExecutable()) { MYDEBUG("Writescript l�sst sich nicht ausf�hren"); DELETENULL(info); OSD_ERRMSG(tr("Cannot execute Writescript!")); return osContinue; } DELETENULL(info); info = new cFileInfo(file); if(Interface->Confirm(tr("Burn Now?"))) { MYDEBUG("Starte Burn-Thread"); cCMDImageBurnThread *burn = new cCMDImageBurnThread(file, info->Type()); burn->Start(); cRemote::CallPlugin("bgprocess"); } return osContinue; }
eOSState cCMDDir::New(void) { MYDEBUG("Verzeichnis: Neu"); cFileInfo *info = new cFileInfo(CurrentDir()); if(!info->isWriteable()) { MYDEBUG("Verzeichnis: Neu: Keine Berechtigung in %s", CurrentDir()); OSD_ERRMSG(tr("no rights to create")); } else { State = csDirNew; SetCols(5); SetTitle(CurrentDir()); SetDir(); cMainMenuItem *mItem = (cMainMenuItem*)First(); Ins(new cMenuEditStrItem(tr("New"), Dir, MaxFileName, trVDR(FileNameChars)), true, mItem); while(mItem) { mItem->SetSelectable(false); mItem = (cMainMenuItem*)Next(mItem); } Display(); cOsdMenu::ProcessKey(kRight); } return osContinue; }
eOSState cCMD::Eject(bool close) { char *cmd = NULL; asprintf(&cmd, "eject %s %s", close ? "-t" : "", DVDSwitchSetup.DVDLinkOrg); MYDEBUG("Eject: %i - %s", close, cmd); int rc = SystemExec(cmd); MYDEBUG("Eject-Rückgabe: %i", rc); free(cmd); return osContinue; }
cOsdObject *cPluginDvdswitch::MainMenuAction(void) { // Perform the action when selected from the main VDR menu. MYDEBUG("MainMenuAction"); if (CheckError()) { MYDEBUG("Fehler entdeckt. Keine OSDOBJECT Rueckgabe"); return NULL; } else return new cMainMenu(listThread); }
void mysql_init(void) { MYDEBUG ("initializing mysql client\n"); uip_ipaddr_t ip; set_CONF_MYSQL_IP(&ip); mysql_conn = uip_connect(&ip, HTONS(3306), mysql_main); if (! mysql_conn) { MYDEBUG ("no uip_conn available.\n"); return; } }
void cDVDListThread::BuildDisp0(void) { if (refreshList) { delete(DVDList); DVDList = new cDVDList(&RunningMenu); } cMainMenuItem *mItem = NULL; MYDEBUG("Bilde Menu nach DisplayMode 0"); if(DVDSwitchSetup.DisplayDVDDevice) { MYDEBUG("Füge Eintrag für das DVD-Device hinzu"); Add(new cMainMenuItem(iDevice)); if(!MainMenuOptions.getLastSelectItemName() && MainMenuOptions.LastSelectItemType() == iDevice) FirstSelectable = 0; } if (refreshList) DVDList->Create(dir, ImageList.GetExtensions(), ImageList.GetDirContains(), (eFileList)DVDSwitchSetup.SortMode, true); cImageListItem *iItem = ImageList.First(); while(iItem) { printf(" -- %s \"%s\" : %d \n", iItem->GetSName(), iItem->GetValue(), iItem->GetFType()); iItem = ImageList.Next(iItem); } printf(" \n ** %s \n",ImageList.GetExtensions()); printf(" \n ** %s \n",ImageList.GetDirContains()); MYDEBUG("DVDList erstellt"); cDVDListItem *item = DVDList->First(); while(menu && item) { Add(new cMainMenuItem(iDVD, item->FileName())); if(MainMenuOptions.getLastSelectItemName() && !strcasecmp(item->FileName(), MainMenuOptions.getLastSelectItemName())) { mItem = (cMainMenuItem*) menu->Last(); FirstSelectable = mItem->Index(); mItem = NULL; } item = DVDList->Next(item); } if(menu && menu->Count() && FirstSelectable < 0) FirstSelectable = 0; //delete(DVDList); }
static void mysql_main(void) { if (uip_aborted() || uip_timedout()) { MYDEBUG ("connection aborted\n"); mysql_conn = NULL; } if (uip_closed()) { MYDEBUG ("connection closed\n"); mysql_conn = NULL; } if (uip_connected()) { MYDEBUG ("new connection\n"); STATE->stage = MYSQL_WAIT_GREETING; STATE->sent = MYSQL_WAIT_GREETING; STATE->packetid = 0; } if (uip_newdata() && uip_len) { #ifdef DEBUG_MYSQL MYDEBUG ("received data: %s\n", uip_appdata); for (uint16_t i = 0; i < uip_len; i ++) debug_putchar (((unsigned char *) uip_appdata)[i]); debug_putchar (10); #endif if (mysql_parse ()) { uip_close (); /* Parse error */ return; } } if (uip_rexmit()) { STATE->packetid --; mysql_send_data (STATE->sent); } else if ((STATE->stage > STATE->sent || STATE->stage == MYSQL_CONNECTED) && (uip_newdata() || uip_acked() || uip_connected())) mysql_send_data (STATE->stage); else if (STATE->stage == MYSQL_CONNECTED && uip_poll() && *STATE->u.stmtbuf) mysql_send_data(STATE->stage); }
cCMDImage::cCMDImage(cMainMenu *osdobject) { MYDEBUG("CMDImage"); File = NULL; strcpy(NewFile, "\0"); OsdObject = osdobject; }
char *cFileInfo::FileNameWithoutExt(void) { char *ext = NULL; char *filename = NULL; if(Extension()) ext = strdup(Extension()); if(FileName()) filename = strdup(FileName()); FREENULL(buffer); if(ext && filename) { int len = strlen(filename) - strlen(ext) + 1; buffer = (char*)malloc(len); strn0cpy(buffer, filename, len); } else if(filename) buffer = strdup(filename); free(ext); free(filename); MYDEBUG("FileInfo: FileNameWithoutExt: %s", buffer); return buffer; }
int my_main(int argc, char *argv[]) { std::string configFileName; int ch; while ((ch = slib::getopt(argc, argv, "dhf:")) != -1) { switch (ch) { case 'f': configFileName = slib::optarg; if (!CONFIG->parseFromFile(configFileName)){ std::cout << "load config file fail\n"; return -1; } break; case 'd': CONFIG->enableEventDebug = true; break; case 'h': case '?': default: usage(); return -1; } } MYDEBUG("start"); std::shared_ptr<IRunnable> r=std::make_shared<LibeventThread>(); MyThread thr(r); thr.run(); unsigned ret=thr.wait(); return ret; }
void cCMDMove::Build(char *dir) { MYDEBUG("Verzeichnis: Move: Erstelle Verzeichnisliste: %s", dir); if(!dir) dir = CurrentDir(); Clear(); cDirHandling *DirHand = new cDirHandling(this, this); SetCurrent(Get(DirHand->Build(dir, true))); delete(DirHand); if(Count()) { cMainMenuItem *item = (cMainMenuItem*)First(); while(item) { if(!strcasecmp(item->FileName(), File)) { Del(item->Index()); break; } item = (cMainMenuItem*)Next(item); } } Display(); SetHelp(); }
void Listener::on_delete(){ MYDEBUG("delete listener"); event_del(listener); if (this->flags & LEV_OPT_CLOSE_ON_FREE) evutil_closesocket(event_get_fd(this->listener)); event_free(this->listener); }
eOSState cCMDMove::ProcessKey(eKeys Key) { cMainMenuItem *mItem = (cMainMenuItem*)Get(Current()); cDirHandling *DirHand = NULL; cFileMoveThread *move = NULL; switch(Key) { case kUp: case kUp|k_Repeat: case kDown: case kDown|k_Repeat: cOsdMenu::ProcessKey(Key); SetHelp(); mItem = (cMainMenuItem*)Get(Current()); if(mItem) LastSelDir(mItem->FileName()); return osContinue; break; case kOk: DirHand = new cDirHandling(this, this); DirHand->ProcessKey(mItem); DELETENULL(DirHand); Build(); break; case kBlue: MYDEBUG("Verzeichnis: Move: Verschiede in: %s", CurrentDir()); move = new cFileMoveThread(File, CurrentDir()); if(move->OK()) { MYDEBUG("Verzeichnis: Move: Erfolgreich"); move->Start(); cCondWait::SleepMs(1 * 500); OsdObject->SetState(mmsReInit); } else DELETENULL(move); if(!Dir && !Direct) cRemote::Put(kBack); return osBack; break; default: break; } return cOsdMenu::ProcessKey(Key); }
eOSState cCMDDir::Edit(cMainMenuItem *mItem) { MYDEBUG("Verzeichnis: Edit: %s", mItem->FileName()); cFileInfo *info = new cFileInfo(mItem->FileName()); if(!info->isWriteable()) { DELETENULL(info); info = new cFileInfo(CurrentDir()); if(!info->isWriteable()) { MYDEBUG("Verzeichnis: Edit: Keine Rechte"); OSD_ERRMSG(tr("no rights to rename")); DELETENULL(info); return osContinue; } } DELETENULL(info); info = new cFileInfo(mItem->FileName()); SetDir(info->FileName()); DELETENULL(info); State = csDirEdit; SetCols(11); SetTitle(CurrentDir()); cMainMenuItem *dmItem = NULL; mItem = (cMainMenuItem*)First(); while(mItem) { if(!strcasecmp(mItem->FileName(), LastSelDir())) { MYDEBUG("Verzeichnis: Edit: Item gefunden: %s", mItem->FileName()); Ins(new cMenuEditStrItem(tr("Rename"), Dir, MaxFileName, trVDR(FileNameChars)), true, mItem); dmItem = mItem; } mItem->SetSelectable(false); mItem = (cMainMenuItem*)Next(mItem); } if(dmItem) Del(dmItem->Index()); Display(); cOsdMenu::ProcessKey(kRight); return osContinue; }
void cCMDImageBurnThread::Action(void) { MYDEBUG("BurnThread gestartet"); if(File && FileType != tNone) { MYDEBUG("Aktion wird ausgefuehrt"); char *cmd; asprintf(&cmd, "'%s' '%s' '%s'", DVDSwitchSetup.DVDWriteScript, File, FileType == tFile ? "IMAGE" : "DIR"); MYDEBUG("Aufruf: %s", &cmd); int rc = SystemExec(cmd); cStatusThread* burn_status = new cStatusThread(BurnMode,"/var/log/dvdswitch_burn.log","Writing DVD"); burn_status->Start(); MYDEBUG("Rueckgabe Aufruf: %i", rc); FREENULL(cmd); } delete(this); };
cCMDImageBurnThread::cCMDImageBurnThread(char *file, eFileInfo type) { MYDEBUG("BurnThread created"); File = NULL; FileType = tNone; if(file && type != tNone) { File = strdup(file); FileType = type; } }
eOSState cCMD::Play(cMainMenuItem *item) { MYDEBUG(" --------- %s item: %s \n", __PRETTY_FUNCTION__,item->FileName()); if(item) MYDEBUG("Play Image %s, %i", item->FileName(), item->Type()); else MYDEBUG("Play Image: Kein Image angegeben"); if(!item || item->Type() == iDevice) cXinePlugin::Start(); else if (item && item->Type() == iDVD) { cXinePlugin::Start(item->FileName()); } if (item->Type() == iDataBase ) { std::string str= tr("Please insert DVD: "); //TODO stop mediaD from detecting the inserted DVD. str += item->FileName(); std::cout<<str<<std::endl; bool flag =Interface->Confirm( str.c_str() ); std::cout<<str<<" "<<flag<<std::endl; if( flag ) { ///TODO check if DVD/media inserted is the correct one. /// item->FileName() == Vobcopy -I ? //cXinePlugin::Start(); // play the DVD std::vector<std::string> playlistEntries; //empty list Xinemediaplayer_Xine_Play_mrl xinePlayData; xinePlayData.mrl = "dvd://"; xinePlayData.instance = -1; xinePlayData.playlist = false; xinePlayData.playlistEntries = playlistEntries; cPluginManager::CallAllServices("Xine Play mrl", &xinePlayData); } } return osEnd; }
char* cCMDImage::Rename(char *file) { MYDEBUG("CMDImage Rename"); if(file) { FREENULL(File); File = strdup(file); } return File; }
cCMDImageReadThread::cCMDImageReadThread(char *file, char *dir, int imgtype) { MYDEBUG("ReadThread created"); File = NULL; Dir = NULL; FileType = tNone; MYDEBUG ( " File: %s dir : %s imgType %d " , file, dir ,imgtype); cImageListItem *item = ImageList.Get(imgtype); if(imgtype >= 0 && file && dir) { if(item->GetFType() == tFile) { asprintf(&File, "%s%s", file, item->GetValue()); MYDEBUG ( " File: %s itemValue %s ", file, item->GetValue()); } else { File = strdup(file); MYDEBUG ( " File: %s itemValue %s ", file); } Dir = strdup(dir); FileType = item->GetFType(); } }
bool cPluginDvdswitch::Initialize(void) { // Initialize any background activities the plugin shall perform. MYDEBUG("Plugin wird initialisiert"); DVDSwitchSetup.SetConfDir((char*)ConfigDirectory(Name())); ImageList.Init(); DVDSwitchSetup.Init(); listThread = new cDVDListThread(); return true; }
eOSState cCMDImage::Delete(char *file) { MYDEBUG("l�sche DVD '%s'", file); if(file) { if(Interface->Confirm(tr("really delete?"))) { cFileDelThread *del = new cFileDelThread(file); if(del->OK()) { MYDEBUG("l�schen OK"); del->Start(); OsdObject->SetState(mmsReInitCur); } else DELETENULL(del); } } return osBack; }
eOSState cCMDDir::New(eKeys Key) { switch(Key) { case kOk: if(!isempty(Dir)) { char *buffer = NULL; asprintf(&buffer, "%s/%s", CurrentDir(), stripspace(Dir)); MYDEBUG("Verzeichnis: Neu: Anlegen: %s", buffer); cFileInfo *info = new cFileInfo(buffer); if(info->isExists()) { MYDEBUG("Verzeichnis existiert bereits"); OSD_WARNMSG(tr("Directory exists")); FREENULL(buffer); DELETENULL(info); return osContinue; } if(cFileCMD::Mkdir(buffer)) { MYDEBUG("Verzeichnis anlegen erfolgreich"); LastSelDir(buffer); if(!Select) OsdObject->SetState(mmsReInit); } FREENULL(buffer); DELETENULL(info); } case kBack: State = csNone; Build(); return osContinue; break; default: break; } return cOsdMenu::ProcessKey(Key); }
void cDVDListThread::BuildDisp2(void) { cMainMenuItem *mItem = NULL; if (refreshList) { delete (DVDList); DVDList = new cDVDList(&RunningMenu); } cDVDListItem *dItem = NULL; cDirHandling *DirHand = new cDirHandling(menu, &MainMenuOptions); FirstSelectable = DirHand->Build(dir, !DVDSwitchSetup.HideEmptyDirs); delete(DirHand); if(DVDSwitchSetup.DisplayDVDDevice && !strcasecmp(dir, MainMenuOptions.ImageDir())) { MYDEBUG("Füge Eintrag für das DVD-Device hinzu"); Add(new cMainMenuItem(iDevice)); if(!MainMenuOptions.getLastSelectItemName() && MainMenuOptions.LastSelectItemType() == iDevice) { mItem = (cMainMenuItem*) menu->Last(); FirstSelectable = mItem->Index(); } } if(DVDList->Create(dir, ImageList.GetExtensions(), ImageList.GetDirContains(), (eFileList)DVDSwitchSetup.SortMode, false)) { dItem = DVDList->First(); while(menu && dItem) { Add(new cMainMenuItem(iDVD, dItem->FileName())); if(MainMenuOptions.getLastSelectItemName() && !strcasecmp(dItem->FileName(), MainMenuOptions.getLastSelectItemName())) { mItem = (cMainMenuItem*) menu->Last(); FirstSelectable = mItem->Index(); mItem = NULL; } dItem = DVDList->Next(dItem); } } //delete(DVDList); if(menu) { mItem = (cMainMenuItem*) menu->First(); if(FirstSelectable < 0) FirstSelectable = 0; } }
eOSState cCMDDir::Edit(eKeys Key) { switch(Key) { case kOk: if(!isempty(Dir)) { char *buffer = NULL; asprintf(&buffer, "%s/%s", CurrentDir(), stripspace(Dir)); MYDEBUG("Verzeichnis: Edit: OK: %s", buffer); cFileInfo *info = new cFileInfo(buffer); if(info->isExists()) { MYDEBUG("Verzeichnis: Edit: Existiert schon"); OSD_WARNMSG(tr("Directory exists")); FREENULL(buffer); DELETENULL(info); return osUnknown; } if(cFileCMD::Rn(LastSelDir(), buffer)) { MYDEBUG("Verzeichnis: Edit: Rename OK"); LastSelDir(buffer); OsdObject->SetState(mmsReInit); } FREENULL(buffer); DELETENULL(info); } case kBack: State = csNone; Build(); return osContinue; break; default: break; } return cOsdMenu::ProcessKey(Key); }
bool cPluginDvdswitch::CheckError(void) { MYDEBUG("Fehlercheck"); MYDEBUG("Check ImageDir"); if(!DirectoryOk(DVDSwitchSetup.ImageDir)) { esyslog("ImageDir '%s' not readable or does not exist", DVDSwitchSetup.ImageDir); OSD_ERRMSG(tr("Image Directory not readable or does not exist")); return true; } MYDEBUG("Check DVD Plugin"); if(!cPluginManager::GetPlugin("xinemediaplayer")) { esyslog("DVDPlugin is not available!"); OSD_INFOMSG(tr("DVD-Plugin not found! Function deactivated!")); } else DVDSwitchSetup.HaveXinePlugin = true; return false; }
bool cDVDList::Load(char *dir, eFileList smode, bool sub) { MYDEBUG("DVDList: Load"); bool ret = false; int i = 0; cFileInfo *fInfo = NULL; cFileList *fList = new cFileList(); fList->OptExclude("^lost\\+found$"); // lost+found Dir fList->OptExclude("^\\."); // hidden Files fList->OptExclude("\\.sdel$"); // del Files fList->OptExclude("\\.smove$"); // move Files if(DVDExts) { cTokenizer *token = new cTokenizer(DVDExts, "@"); char *extexp = NULL; for(i = 1; i <= token->Count(); i++) { asprintf(&extexp, "%s$", token->GetToken(i)); fList->OptInclude(extexp, tFile); FREENULL(extexp); } delete(token); } if(DVDDirs) fList->OptInclude(".*", tDir); fList->OptSort(smode, true); ret = fList->Load(dir, sub); cFileListItem *fItem = fList->First(); while(*RunningMenu && fItem) { fInfo = new cFileInfo(fItem->Value()); if(fInfo->Type() == tFile || (fInfo->Type() == tDir && fList->DirIsIn(fItem, DVDDirs))) Add(new cDVDListItem(fItem->Value())); DELETENULL(fInfo); fItem = fList->Next(fItem); } delete(fList); delete(fInfo); return ret; }
LibEventInit::LibEventInit() { event_set_log_callback(my_libevent_log_cb); #ifdef OS_WIN evthread_use_windows_threads(); #else evthread_use_pthreads(); #endif evdns_set_log_fn(logfn); if (CONFIG->enableEventDebug){ MYDEBUG("enable libevent debug"); event_enable_debug_mode(); } }
cFileInfo::cFileInfo(char *file) { MYDEBUG("FileInfo: %s", file); File = (file && !isempty(file)) ? strdup(file) : NULL; if(File && File[strlen(File) - 1] == '/') File[strlen(File) - 1] = '\0'; buffer = NULL; if(isExists()) stat64(File, &Info); size = 0; }