src/utils_params.[ch]: Implement and use "script_name()".
authorFlorian Forster <ff@octo.it>
Fri, 18 Jun 2010 18:23:54 +0000 (20:23 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Fri, 18 Jun 2010 18:23:54 +0000 (20:23 +0200)
src/action_list_graphs.c
src/utils_params.c
src/utils_params.h

index 29e3d8b..395d8a1 100644 (file)
@@ -75,8 +75,8 @@ static int print_graph_inst_html (graph_config_t *cfg, /* {{{ */
   memset (desc, 0, sizeof (desc));
   inst_describe (cfg, inst, desc, sizeof (desc));
 
-  printf ("    <li><a href=\"test.fcgi?action=graph;%s\">%s</a></li>\n",
-      params, desc);
+  printf ("    <li><a href=\"%s?action=graph;%s\">%s</a></li>\n",
+      script_name (), params, desc);
 
   return (0);
 } /* }}} int print_graph_inst_html */
index 6e5dc89..2c7bcc2 100644 (file)
@@ -256,4 +256,15 @@ int uri_escape (char *dst, const char *src, size_t size) /* {{{ */
   } /* while (42) */
 } /* }}} int uri_escape */
 
+const char *script_name (void)
+{
+  char *ret;
+
+  ret = getenv ("SCRIPT_NAME");
+  if (ret == NULL)
+    ret = "collection4.fcgi";
+
+  return (ret);
+} /* }}} char *script_name */
+
 /* vim: set sw=2 sts=2 et fdm=marker : */
index 3c7ea0a..5d0c845 100644 (file)
@@ -8,4 +8,6 @@ const char *param (const char *key);
 
 int uri_escape (char *dst, const char *src, size_t size);
 
+const char *script_name (void);
+
 #endif /* UTILS_PARAMS_H */