diff options
author | anbr <vdr07@deltab.de> | 2010-12-21 20:57:28 +0100 |
---|---|---|
committer | anbr <vdr07@deltab.de> | 2010-12-21 20:57:28 +0100 |
commit | 3837f9ab492bcb791d278908cc2e7e4dc9a12217 (patch) | |
tree | 106f1089da730c02a8c5f27e1b21f9767fc3d66a | |
parent | 2906f2d1b7e1c5931b3d05156569d6061eb6b9b5 (diff) | |
download | vdr-plugin-dvdswitch-3837f9ab492bcb791d278908cc2e7e4dc9a12217.tar.gz vdr-plugin-dvdswitch-3837f9ab492bcb791d278908cc2e7e4dc9a12217.tar.bz2 |
release 0.1.5 from http://www.vdr-portal.de/board/thread.php?postid=845575#post8455750.1.5
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | dvdlist.c | 7 | ||||
-rw-r--r-- | dvdplugin.c | 125 | ||||
-rw-r--r-- | dvdswitch.c | 2 | ||||
-rw-r--r-- | helpers.c | 44 | ||||
-rw-r--r-- | imagelist-item.c | 7 | ||||
-rw-r--r-- | imagelist-item.h | 6 | ||||
-rw-r--r-- | tools.c | 7 | ||||
-rw-r--r-- | tools.h | 17 |
9 files changed, 119 insertions, 99 deletions
@@ -1,6 +1,9 @@ VDR Plugin 'dvdswitch' Revision History --------------------------------------- +2009-10-03: Version 0.1.5 +- Fix some GCC-4.4 warnings + 2009-10-03: Version 0.1.4 - Update to vdr 1.6.0 @@ -39,9 +39,10 @@ bool cDVDList::Load(const char *dir, eFileList smode, bool sub) char *extexp = NULL; for(i = 1; i <= token->Count(); i++) { - asprintf(&extexp, "%s$", token->GetToken(i)); - fList->OptInclude(extexp, tFile); - FREENULL(extexp); + if(0 < asprintf(&extexp, "%s$", token->GetToken(i))) { + fList->OptInclude(extexp, tFile); + FREENULL(extexp); + } } delete(token); } diff --git a/dvdplugin.c b/dvdplugin.c index c68d89f..5a613f4 100644 --- a/dvdplugin.c +++ b/dvdplugin.c @@ -67,59 +67,59 @@ void cDVDPlugin::DetectDevice(void) char *output = NULL; char *dvd = NULL; - asprintf(&cmd, "ps -p %i -o cmd --no-header", getpid()); - dsyslog("Commando: %s", cmd); + if(0 < asprintf(&cmd, "ps -p %i -o cmd --no-header", getpid())) { + dsyslog("Commando: %s", cmd); - FILE *p = popen(cmd, "r"); - if(p) - { -#if VDRVERSNUM >= 10318 - cReadLine rl; - output = rl.Read(p); -#else - output = readline(p); -#endif - pclose(p); - } + FILE *p = popen(cmd, "r"); + if(p) + { + #if VDRVERSNUM >= 10318 + cReadLine rl; + output = rl.Read(p); + #else + output = readline(p); + #endif + pclose(p); + } - cTokenizer *token = new cTokenizer(output, " "); - for(int i = 1; i <= token->Count(); i++) - { - if(RegIMatch(token->GetToken(i), "^--plugin=dvd") || - (RegIMatch(token->GetToken(i - 1), "^-P$") && - RegIMatch(token->GetToken(i), "^dvd$"))) + cTokenizer *token = new cTokenizer(output, " "); + for(int i = 1; i <= token->Count(); i++) { - if(RegIMatch(token->GetToken(i + 1), "^-C$") && - token->GetToken(i + 2)) + if(RegIMatch(token->GetToken(i), "^--plugin=dvd") || + (RegIMatch(token->GetToken(i - 1), "^-P$") && + RegIMatch(token->GetToken(i), "^dvd$"))) { - dvd = strdup(token->GetToken(i + 2)); - break; - } - if(RegIMatch(token->GetToken(i + 1), "^--dvd=")) - { - char *p = strchr(token->GetToken(i + 1), '='); - p++; - dvd = strdup(p); - break; + if(RegIMatch(token->GetToken(i + 1), "^-C$") && + token->GetToken(i + 2)) + { + dvd = strdup(token->GetToken(i + 2)); + break; + } + if(RegIMatch(token->GetToken(i + 1), "^--dvd=")) + { + const char *p = strchr(token->GetToken(i + 1), '='); + p++; + dvd = strdup(p); + break; + } } } + DELETENULL(token); + + if(dvd) + { + isyslog("Used DVD Device: %s", dvd); + DVDSwitchSetup.SetDVDDevice(dvd); + free(dvd); + } + else + { + isyslog("Use Default-DVD Device /dev/dvd"); + DVDSwitchSetup.SetDVDDevice("/dev/dvd"); + } + + free(cmd); } - DELETENULL(token); - - if(dvd) - { - isyslog("Used DVD Device: %s", dvd); - DVDSwitchSetup.SetDVDDevice(dvd); - } - else - { - isyslog("Use Default-DVD Device /dev/dvd"); - DVDSwitchSetup.SetDVDDevice("/dev/dvd"); - } - - free(cmd); - free(dvd); - //free(output); } void cDVDPlugin::SetLink(void) @@ -127,19 +127,21 @@ void cDVDPlugin::SetLink(void) int argc = 2; char *argv[2] = { NULL, NULL }; - asprintf(&argv[0], "%s", "dvd"); - asprintf(&argv[1], "--dvd=%s", DVDSwitchSetup.DVDLink); + if(0 < asprintf(&argv[0], "%s", "dvd")) { + if(0 < asprintf(&argv[1], "--dvd=%s", DVDSwitchSetup.DVDLink)) { - cPlugin *plugin = cPluginManager::GetPlugin("dvd"); + cPlugin *plugin = cPluginManager::GetPlugin("dvd"); - if(plugin) - { - optind = 0; //reset for getopt - plugin->ProcessArgs(argc, argv); - } + if(plugin) + { + optind = 0; //reset for getopt + plugin->ProcessArgs(argc, argv); + } - free(argv[0]); - free(argv[1]); + free(argv[1]); + } + free(argv[0]); + } } void cDVDPlugin::Start(char *image) @@ -164,10 +166,11 @@ void cDVDPlugin::ChangeLink(char *target) char *cmd = NULL; int rc = 0; - asprintf(&cmd, LINK, target, DVDSwitchSetup.DVDLink); - dsyslog("Change link: %s", cmd); - rc = system(cmd); - dsyslog("Change link got: %i", rc); - free(cmd); + if(0 < asprintf(&cmd, LINK, target, DVDSwitchSetup.DVDLink)) { + dsyslog("Change link: %s", cmd); + rc = system(cmd); + dsyslog("Change link got: %i", rc); + free(cmd); + } } } diff --git a/dvdswitch.c b/dvdswitch.c index 40c0d70..34e9e59 100644 --- a/dvdswitch.c +++ b/dvdswitch.c @@ -19,7 +19,7 @@ #error "VDR-1.6.0 API version or greater is required!" #endif -static const char *VERSION = "0.1.4"; +static const char *VERSION = "0.1.5"; static const char *DESCRIPTION = tr("Allowed to play DVD-Images"); //static const char *MAINMENUENTRY = tr("DVDSwitch"); @@ -424,10 +424,14 @@ cFileListItem::cFileListItem(const char *dir, const char *file) { if(file && !isempty(file) && dir && !isempty(dir)) { - if(dir[strlen(dir) - 1] == '/') - asprintf(&File, "%s%s", dir, file); - else - asprintf(&File, "%s/%s", dir, file); + if(dir[strlen(dir) - 1] == '/') { + if(0 >= asprintf(&File, "%s%s", dir, file)) + return; + } + else { + if(0 >= asprintf(&File, "%s/%s", dir, file)) + return; + } } else File = NULL; @@ -514,9 +518,10 @@ bool cFileList::Read(const char *dir, bool withsub) CheckType(dir, DirData->d_name, tDir) && !RegIMatch(DirData->d_name, "^\\.{1,2}$")) { - asprintf(&buffer, "%s/%s", dir, DirData->d_name); - Read(buffer, withsub); - FREENULL(buffer); + if(0 < asprintf(&buffer, "%s/%s", dir, DirData->d_name)) { + Read(buffer, withsub); + FREENULL(buffer); + } } } ret = true; @@ -541,7 +546,8 @@ void cFileList::SortIn(const char *dir, const char *file) case sDesc: if(Item) { - asprintf(&NewItem, "%s/%s", dir, file); + if(0 >= asprintf(&NewItem, "%s/%s", dir, file)) + break; NewItemInfo = SortToFilename ? new cFileInfo(NewItem) : NULL; while(Item) { @@ -618,15 +624,14 @@ bool cFileList::CheckType(const char *dir, const char *file, eFileInfo type) char *buffer = NULL; - asprintf(&buffer, "%s/%s", dir, file); - - cFileInfo *info = new cFileInfo(buffer); - if(info->Type() == type) - ret = true; - delete(info); - - free(buffer); + if(0 < asprintf(&buffer, "%s/%s", dir, file)) { + cFileInfo *info = new cFileInfo(buffer); + if(info->Type() == type) + ret = true; + delete(info); + free(buffer); + } return ret; } @@ -670,9 +675,10 @@ bool cFileList::DirIsIn(const char *file, const char *strings) cTokenizer *token = new cTokenizer(strings, "@"); for(int i = 1; i <= token->Count(); i++) { - asprintf(&buffer, "^%s$", token->GetToken(i)); - fList->OptInclude(buffer); - free(buffer); + if(0 < asprintf(&buffer, "^%s$", token->GetToken(i))) { + fList->OptInclude(buffer); + free(buffer); + } } DELETENULL(token); diff --git a/imagelist-item.c b/imagelist-item.c index 4201c4a..04b1b78 100644 --- a/imagelist-item.c +++ b/imagelist-item.c @@ -32,8 +32,11 @@ void cImageListItem::Edit(const char *lname, const char *sname, eFileInfo type, LName = lname ? strdup(lname) : NULL; SName = sname ? strdup(sname) : NULL; - if(type == tFile && value && value[0] != '.') - asprintf(&Value, ".%s", value); + if(type == tFile && value && value[0] != '.') { + if(0 >= asprintf(&Value, ".%s", value)) { + return; + } + } else Value = value ? strdup(value) : NULL; diff --git a/imagelist-item.h b/imagelist-item.h index 3ff10cf..1b2e874 100644 --- a/imagelist-item.h +++ b/imagelist-item.h @@ -17,10 +17,10 @@ class cImageListItem : public cListObject void MakeSetupString(void) { - dsyslog("Neuer SetupString"); FREENULL(SString); - asprintf(&SString, "%s|%s|%i|%s|%i", LName, SName, (int)fType, Value, HideExt); - dsyslog("...%s", SString); + if(0 < asprintf(&SString, "%s|%s|%i|%s|%i", LName, SName, (int)fType, Value, HideExt)) { + dsyslog("...%s", SString); + } }; void debug(void); @@ -15,9 +15,10 @@ cDirList::cDirList(cImageList &ImageList) cTokenizer *token = new cTokenizer(ImageList.GetDirContains(), "@"); for(int i = 1; i <= token->Count(); i++) { - asprintf(&buffer, "^%s$", token->GetToken(i)); - OptExclude(buffer); - FREENULL(buffer); + if(0 < asprintf(&buffer, "^%s$", token->GetToken(i))) { + OptExclude(buffer); + FREENULL(buffer); + } } OptSort((eFileList)DVDSwitchSetup.SortMode); @@ -46,8 +46,9 @@ class cFileDelThread : public cThread Ok = true; if(file) { - asprintf(&File, "%s.sdel", file); - cFileCMD::Rn(file, File); + if(0 < asprintf(&File, "%s.sdel", file)) { + cFileCMD::Rn(file, File); + } } } } @@ -80,9 +81,10 @@ class cFileMoveThread : public cThread if(FileName && File && Dest) { char *buffer = NULL; - asprintf(&buffer, "%s/%s", Dest, FileName); - cFileCMD::Rn(File, buffer); - free(buffer); + if(0 < asprintf(&buffer, "%s/%s", Dest, FileName)) { + cFileCMD::Rn(File, buffer); + free(buffer); + } } delete(this); }; @@ -104,8 +106,9 @@ class cFileMoveThread : public cThread cFileInfo *info = new cFileInfo(file); FileName = strdup(info->FileName()); DELETENULL(info); - asprintf(&File, "%s.smove", file); - cFileCMD::Rn(file, File); + if(0 < asprintf(&File, "%s.smove", file)) { + cFileCMD::Rn(file, File); + } } Dest = dest ? strdup(dest) : NULL; } |