Updated so that we only need a single binary to cover 3 possible use cases, wd, datadir and bundle.
This commit is contained in:
parent
b350d44c4d
commit
9e53683ca0
6 changed files with 52 additions and 39 deletions
|
@ -921,27 +921,20 @@ static void _opentv_prov_load ( htsmsg_t *m )
|
|||
void opentv_init ( void )
|
||||
{
|
||||
htsmsg_t *m;
|
||||
const char *dr = tvheadend_dataroot();
|
||||
|
||||
/* Load dictionaries */
|
||||
if ((m = hts_settings_load("epggrab/opentv/dict")))
|
||||
_opentv_dict_load(m);
|
||||
if ((m = hts_settings_load("%s/data/epggrab/opentv/dict", dr)))
|
||||
_opentv_dict_load(m);
|
||||
tvhlog(LOG_DEBUG, "opentv", "dictonaries loaded");
|
||||
|
||||
/* Load genres */
|
||||
if ((m = hts_settings_load("epggrab/opentv/genre")))
|
||||
_opentv_genre_load(m);
|
||||
if ((m = hts_settings_load("%s/data/epggrab/opentv/genre", dr)))
|
||||
_opentv_genre_load(m);
|
||||
tvhlog(LOG_DEBUG, "opentv", "genre maps loaded");
|
||||
|
||||
/* Load providers */
|
||||
if ((m = hts_settings_load("epggrab/opentv/prov")))
|
||||
_opentv_prov_load(m);
|
||||
if ((m = hts_settings_load("%s/data/epggrab/opentv/prov", dr)))
|
||||
_opentv_prov_load(m);
|
||||
tvhlog(LOG_DEBUG, "opentv", "providers loaded");
|
||||
}
|
||||
|
||||
|
|
|
@ -175,20 +175,39 @@ int fb_stat ( const char *path, struct filebundle_stat *st )
|
|||
* Directory processing
|
||||
* *************************************************************************/
|
||||
|
||||
/* Open directory (directly) */
|
||||
static fb_dir *_fb_opendir ( const char *root, const char *path )
|
||||
{
|
||||
DIR *dir;
|
||||
char buf[512];
|
||||
fb_dir *ret = NULL;
|
||||
|
||||
/* Pre-pend root */
|
||||
if (root) {
|
||||
snprintf(buf, sizeof(buf), "%s/%s", root, path);
|
||||
path = buf;
|
||||
}
|
||||
|
||||
/* Open */
|
||||
if ((dir = opendir(path))) {
|
||||
ret = calloc(1, sizeof(fb_dir));
|
||||
ret->type = FB_DIRECT;
|
||||
ret->d.root = strdup(path);
|
||||
ret->d.cur = dir;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Open directory */
|
||||
fb_dir *fb_opendir ( const char *path )
|
||||
{
|
||||
fb_dir *ret = NULL;
|
||||
const char *root;
|
||||
|
||||
/* Use settings path */
|
||||
if (*path != '/')
|
||||
root = tvheadend_dataroot();
|
||||
else
|
||||
root = "";
|
||||
|
||||
/* Bundle */
|
||||
if (!root) {
|
||||
/* In-direct (search) */
|
||||
if (*path != '/') {
|
||||
|
||||
/* Bundle */
|
||||
#if ENABLE_BUNDLE
|
||||
char *tmp1 = strdup(path);
|
||||
char *tmp2 = strtok(tmp1, "/");
|
||||
filebundle_entry_t *fb = filebundle_root;
|
||||
|
@ -209,18 +228,17 @@ fb_dir *fb_opendir ( const char *path )
|
|||
ret->b.root = fb;
|
||||
ret->b.cur = fb->d.child;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Local */
|
||||
if (!ret) ret = _fb_opendir(tvheadend_cwd, path);
|
||||
|
||||
/* System */
|
||||
if (!ret) ret = _fb_opendir(TVHEADEND_DATADIR, path);
|
||||
|
||||
/* Direct */
|
||||
} else {
|
||||
DIR *dir;
|
||||
char buf[512];
|
||||
snprintf(buf, sizeof(buf), "%s/%s", root, path);
|
||||
if ((dir = opendir(buf))) {
|
||||
ret = calloc(1, sizeof(fb_dir));
|
||||
ret->type = FB_DIRECT;
|
||||
ret->d.root = strdup(buf);
|
||||
ret->d.cur = dir;
|
||||
}
|
||||
ret = _fb_opendir(NULL, path);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
12
src/main.c
12
src/main.c
|
@ -72,6 +72,7 @@ static int log_decorate;
|
|||
int log_debug_to_syslog;
|
||||
int log_debug_to_console;
|
||||
|
||||
char *tvheadend_cwd;
|
||||
|
||||
static void
|
||||
handle_sigpipe(int x)
|
||||
|
@ -261,6 +262,9 @@ main(int argc, char **argv)
|
|||
uint32_t adapter_mask = 0xffffffff;
|
||||
int crash = 0;
|
||||
|
||||
/* Get current directory */
|
||||
tvheadend_cwd = dirname(strdup(argv[0]));
|
||||
|
||||
// make sure the timezone is set
|
||||
tzset();
|
||||
|
||||
|
@ -403,7 +407,7 @@ main(int argc, char **argv)
|
|||
#endif
|
||||
http_server_init();
|
||||
|
||||
webui_init(tvheadend_dataroot());
|
||||
webui_init();
|
||||
|
||||
serviceprobe_init();
|
||||
|
||||
|
@ -450,11 +454,9 @@ main(int argc, char **argv)
|
|||
pthread_sigmask(SIG_UNBLOCK, &set, NULL);
|
||||
|
||||
tvhlog(LOG_NOTICE, "START", "HTS Tvheadend version %s started, "
|
||||
"running as PID:%d UID:%d GID:%d, settings located in '%s', "
|
||||
"dataroot: %s",
|
||||
"running as PID:%d UID:%d GID:%d, settings located in '%s'",
|
||||
tvheadend_version,
|
||||
getpid(), getuid(), getgid(), hts_settings_get_root(),
|
||||
tvheadend_dataroot() ?: "<Embedded file system>");
|
||||
getpid(), getuid(), getgid(), hts_settings_get_root());
|
||||
|
||||
if(crash)
|
||||
abort();
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/time.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include "queue.h"
|
||||
#include "avg.h"
|
||||
|
@ -34,7 +35,7 @@
|
|||
#include "redblack.h"
|
||||
|
||||
extern const char *tvheadend_version;
|
||||
extern const char *tvheadend_dataroot();
|
||||
extern char *tvheadend_cwd;
|
||||
|
||||
#define PTS_UNSET INT64_C(0x8000000000000000)
|
||||
|
||||
|
|
|
@ -773,8 +773,7 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
|
|||
*
|
||||
*/
|
||||
static void
|
||||
webui_static_content(const char *content_path, const char *http_path,
|
||||
const char *source)
|
||||
webui_static_content(const char *http_path, const char *source)
|
||||
{
|
||||
http_path_add(http_path, strdup(source), page_static_file, ACCESS_WEB_INTERFACE);
|
||||
}
|
||||
|
@ -796,7 +795,7 @@ int page_statedump(http_connection_t *hc, const char *remain, void *opaque);
|
|||
* WEB user interface
|
||||
*/
|
||||
void
|
||||
webui_init(const char *contentpath)
|
||||
webui_init(void)
|
||||
{
|
||||
http_path_add("/", NULL, page_root, ACCESS_WEB_INTERFACE);
|
||||
|
||||
|
@ -808,9 +807,9 @@ webui_init(const char *contentpath)
|
|||
|
||||
http_path_add("/stream", NULL, http_stream, ACCESS_STREAMING);
|
||||
|
||||
webui_static_content(contentpath, "/static", "src/webui/static");
|
||||
webui_static_content(contentpath, "/docs", "docs/html");
|
||||
webui_static_content(contentpath, "/docresources", "docs/docresources");
|
||||
webui_static_content("/static", "src/webui/static");
|
||||
webui_static_content("/docs", "docs/html");
|
||||
webui_static_content("/docresources", "docs/docresources");
|
||||
|
||||
simpleui_start();
|
||||
extjs_start();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "htsmsg.h"
|
||||
|
||||
void webui_init(const char *contentpath);
|
||||
void webui_init(void);
|
||||
|
||||
void simpleui_start(void);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue