From 86b1a3afc55b7987436cebba9b5aa57e0b7f8407 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Fri, 14 Sep 2012 12:02:04 +0100 Subject: [PATCH] Ensure PyEPG does not appear in basic list unless its installed. --- src/epggrab/module/pyepg.c | 8 +++++--- src/spawn.c | 8 ++++---- src/spawn.h | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/epggrab/module/pyepg.c b/src/epggrab/module/pyepg.c index a9ccd0ee..0eda3ade 100644 --- a/src/epggrab/module/pyepg.c +++ b/src/epggrab/module/pyepg.c @@ -419,10 +419,12 @@ static int _pyepg_parse void pyepg_init ( void ) { + char buf[256]; + /* Internal module */ - epggrab_module_int_create(NULL, "/usr/bin/pyepg", "PyEPG", 4, - "/usr/bin/pyepg", - NULL, _pyepg_parse, NULL, NULL); + if (find_exec("pyepg", buf, sizeof(buf)-1)) + epggrab_module_int_create(NULL, "pyepg-internal", "PyEPG", 4, buf, + NULL, _pyepg_parse, NULL, NULL); /* External module */ _pyepg_module = (epggrab_module_t*) diff --git a/src/spawn.c b/src/spawn.c index c7ffbe51..1ae74891 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -48,8 +48,8 @@ typedef struct spawn { /* * Search PATH for executable */ -static int -_find_exec ( const char *name, char *out, size_t len ) +int +find_exec ( const char *name, char *out, size_t len ) { int ret = 0; char bin[512]; @@ -161,7 +161,7 @@ spawn_and_store_stdout(const char *prog, char *argv[], char **outp) const char *local_argv[2] = { NULL, NULL }; if (*prog != '/' && *prog != '.') { - if (!_find_exec(prog, bin, sizeof(bin))) return -1; + if (!find_exec(prog, bin, sizeof(bin))) return -1; prog = bin; } @@ -233,7 +233,7 @@ spawnv(const char *prog, char *argv[]) const char *local_argv[2] = { NULL, NULL }; if (*prog != '/' && *prog != '.') { - if (!_find_exec(prog, bin, sizeof(bin))) return -1; + if (!find_exec(prog, bin, sizeof(bin))) return -1; prog = bin; } diff --git a/src/spawn.h b/src/spawn.h index 606a375b..5f89426b 100644 --- a/src/spawn.h +++ b/src/spawn.h @@ -19,6 +19,8 @@ #ifndef SPAWN_H #define SPAWN_H +int find_exec ( const char *name, char *out, size_t len ); + int spawn_and_store_stdout(const char *prog, char *argv[], char **outp); int spawnv(const char *prog, char *argv[]);