Project "Tuxbox-GIT: apps":

The branch, master has been updated
       via  6b89af1d88bb6106ac17b9ae6d002f1980bf1127 (commit)
      from  1b4373ed942e3d89d6985f5476015158405a15d8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6b89af1d88bb6106ac17b9ae6d002f1980bf1127
Author: Stefan Seyfried <se...@tuxbox-git.slipkontur.de>
Date:   Mon Apr 13 09:48:59 2015 +0200

    helper: add a function to find an executable in $PATH
    
    Signed-off-by: GetAway <get-a...@t-online.de>

diff --git a/tuxbox/neutrino/src/system/helper.cpp 
b/tuxbox/neutrino/src/system/helper.cpp
index 66505f4..cb7a065 100644
--- a/tuxbox/neutrino/src/system/helper.cpp
+++ b/tuxbox/neutrino/src/system/helper.cpp
@@ -122,3 +122,34 @@ int my_system(int argc, const char *arg, ...)
        va_end(args);
        return ret;
 }
+
+std::string find_executable(const char *name)
+{
+       struct stat s;
+       char *tmpPath = getenv("PATH");
+       char *p, *n, *path;
+       if (tmpPath)
+               path = strdupa(tmpPath);
+       else
+               path = strdupa("/bin:/var/bin:/sbin:/var/sbin");
+       if (name[0] == '/') { /* full path given */
+               if (!access(name, X_OK) && !stat(name, &s) && 
S_ISREG(s.st_mode))
+                       return std::string(name);
+               return "";
+       }
+
+       p = path;
+       while (p) {
+               n = strchr(p, ':');
+               if (n)
+                       *n++ = '\0';
+               if (*p != '\0') {
+                       std::string tmp = std::string(p) + "/" + 
std::string(name);
+                       const char *f = tmp.c_str();
+                       if (!access(f, X_OK) && !stat(f, &s) && 
S_ISREG(s.st_mode))
+                               return tmp;
+               }
+               p = n;
+       }
+       return "";
+}
diff --git a/tuxbox/neutrino/src/system/helper.h 
b/tuxbox/neutrino/src/system/helper.h
index 5fd8de4..8ccc836 100644
--- a/tuxbox/neutrino/src/system/helper.h
+++ b/tuxbox/neutrino/src/system/helper.h
@@ -34,4 +34,6 @@ int my_system(int argc, const char *arg, ...); /* argc is 
number of arguments in
 
 bool file_exists(const char *filename);
 
+std::string find_executable(const char *name);
+
 #endif

-----------------------------------------------------------------------

Summary of changes:
 tuxbox/neutrino/src/system/helper.cpp |   31 +++++++++++++++++++++++++++++++
 tuxbox/neutrino/src/system/helper.h   |    2 ++
 2 files changed, 33 insertions(+), 0 deletions(-)


-- 
Tuxbox-GIT: apps

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Tuxbox-cvs-commits mailing list
Tuxbox-cvs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tuxbox-cvs-commits

Reply via email to