Remove an unnecessary define.
[darkstat] / graph_db.c
index 63ecc9d..8c72102 100644 (file)
@@ -1,5 +1,5 @@
 /* darkstat 3
- * copyright (c) 2006-2008 Emil Mikulic.
+ * copyright (c) 2006-2011 Emil Mikulic.
  *
  * graph_db.c: round robin database for graph data
  *
 
 #include "cap.h"
 #include "conv.h"
-#include "darkstat.h"
 #include "db.h"
 #include "acct.h"
 #include "err.h"
 #include "str.h"
 #include "html.h"
-#include "http.h"
 #include "graph_db.h"
 #include "now.h"
+#include "opt.h"
 
 #include <assert.h>
 #include <stdlib.h>
@@ -28,8 +27,6 @@
 #define GRAPH_WIDTH "320"
 #define GRAPH_HEIGHT "200"
 
-extern const char *interface;
-
 struct graph {
    uint64_t *in, *out;
    unsigned int offset; /* i.e. seconds start at 0, days start at 1 */
@@ -302,12 +299,6 @@ graph_export(const int fd)
    return 1;
 }
 
-static void cb_headers(struct str *buf)
-{
-   str_appendf(buf, "<script src=\"%s%s\" type=\"text/javascript\">"
-      "</script>\n", base_url, "graph.js");
-}
-
 /* ---------------------------------------------------------------------------
  * Web interface: front page!
  */
@@ -319,7 +310,7 @@ html_front_page(void)
    char start_when[100];
 
    buf = str_make();
-   html_open(buf, "Graphs", interface, cb_headers);
+   html_open(buf, "Graphs", /*path_depth=*/0, /*want_graph_js=*/1);
 
    str_append(buf, "<p>\n");
    str_append(buf, "<b>Running for</b> <span id=\"rf\">");
@@ -333,15 +324,15 @@ html_front_page(void)
       "%Y-%m-%d %H:%M:%S %Z%z", localtime(&start_time)) != 0)
       str_appendf(buf, "<b>, since</b> %s", start_when);
 
-   str_appendf(buf,"<b>.</b><br/>\n"
+   str_appendf(buf,"<b>.</b><br>\n"
       "<b>Total</b> <span id=\"tb\">%'qu</span> <b>bytes, "
       "in</b> <span id=\"tp\">%'qu</span> <b>packets.</b> "
       "(<span id=\"pc\">%'u</span> <b>captured,</b> "
-      "<span id=\"pd\">%'u</span> <b>dropped)</b><br/>\n"
+      "<span id=\"pd\">%'u</span> <b>dropped)</b><br>\n"
       "</p>\n",
-      total_bytes,
-      total_packets,
-      pkts_recv, pkts_drop);
+      acct_total_bytes,
+      acct_total_packets,
+      cap_pkts_recv, cap_pkts_drop);
 
    str_append(buf,
       "<div id=\"graphs\">\n"
@@ -351,7 +342,7 @@ html_front_page(void)
       "var graph_width = " GRAPH_WIDTH ";\n"
       "var graph_height = " GRAPH_HEIGHT ";\n"
       "var bar_gap = 1;\n"
-      "var graphs_uri = \"/graphs.xml\";\n"
+      "var graphs_uri = \"graphs.xml\";\n"
       "var graphs = [\n"
    );
 
@@ -388,7 +379,7 @@ xml_graphs(void)
    struct str *buf = str_make(), *rf;
 
    str_appendf(buf, "<graphs tp=\"%qu\" tb=\"%qu\" pc=\"%u\" pd=\"%u\" rf=\"",
-      total_packets, total_bytes, pkts_recv, pkts_drop);
+      acct_total_packets, acct_total_bytes, cap_pkts_recv, cap_pkts_drop);
    rf = length_of_time(now - start_time);
    str_appendstr(buf, rf);
    str_free(rf);