]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
webui: simplification of the tvheadend_webroot processing.
authorAdam Sutton <dev@adamsutton.me.uk>
Tue, 1 Jan 2013 09:05:37 +0000 (09:05 +0000)
committerAdam Sutton <dev@adamsutton.me.uk>
Tue, 1 Jan 2013 09:30:28 +0000 (09:30 +0000)
src/http.c
src/main.c
src/tvheadend.h

index 7610adf1d48eb39cede7a862f0a1b10071114308..dee8e1f8e21ff3b0778478e1ff41e2d7dbb2a97f 100644 (file)
@@ -607,16 +607,12 @@ http_path_add(const char *path, void *opaque, http_callback_t *callback,
              uint32_t accessmask)
 {
   http_path_t *hp = malloc(sizeof(http_path_t));
+  char *tmp;
 
   if (tvheadend_webroot) {
-    char *tmp; const char *pre = "";
     size_t len = strlen(tvheadend_webroot) + strlen(path) + 1;
-    if (*tvheadend_webroot != '/') {
-      len++;
-      pre = "/";
-    }
     hp->hp_path     = tmp = malloc(len);
-    sprintf(tmp, "%s%s%s", pre, tvheadend_webroot, path);
+    sprintf(tmp, "%s/%s", tvheadend_webroot, path);
   } else
     hp->hp_path     = strdup(path);
   hp->hp_len      = strlen(hp->hp_path);
index baae957c1c9c04fc3f15bbdfd7e504de35716fb6..73afb0757b18fc3537ee40a450d3062f735512cd 100644 (file)
@@ -76,7 +76,7 @@ int log_debug_to_console;
 int webui_port;
 int htsp_port;
 int htsp_port_extra;
-char *tvheadend_cwd;
+const char *tvheadend_cwd;
 const char *tvheadend_webroot;
 
 const char *tvheadend_capabilities[] = {
@@ -270,6 +270,7 @@ main(int argc, char **argv)
   const char *pidpath = "/var/run/tvheadend.pid";
   struct group *grp;
   struct passwd *pw;
+  char *webroot;
   const char *usernam = NULL;
   const char *groupnam = NULL;
   int logfacility = LOG_DAEMON;
@@ -369,7 +370,16 @@ main(int argc, char **argv)
       join_transport = optarg;
       break;
     case 'W':
-      tvheadend_webroot = optarg;
+      webroot = malloc(strlen(optarg) + (*optarg == '/' ? 0 : 1));
+      if (*optarg != '/') {
+        *webroot = '/';
+        strcpy(webroot+1, optarg);
+      } else {
+        strcpy(webroot, optarg);
+      }
+      if (webroot[strlen(webroot)-1] == '/')
+        webroot[strlen(webroot)-1] = '\0';
+      tvheadend_webroot = webroot;
       break;
     default:
       usage(argv[0]);
index a601f80e0e5b67bad5bf9e2f3b53ef301f69ceeb..9bdaf1f243578b0ea79c7743764e5f1d85459dc1 100644 (file)
@@ -35,7 +35,7 @@
 #include "redblack.h"
 
 extern const char *tvheadend_version;
-extern char *tvheadend_cwd;
+extern const char *tvheadend_cwd;
 extern const char *tvheadend_capabilities[];
 extern const char *tvheadend_webroot;