"Fossies" - the Fresh Open Source Software Archive 
Member "darkstat-3.0.721/html.c" (12 Jan 2022, 2012 Bytes) of package /linux/privat/darkstat-3.0.721.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "html.c" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
3.0.719_vs_3.0.721.
1 /* darkstat 3
2 *
3 * html.c: HTML header/footer templating for web interface.
4 * copyright (c) 2006 Ben Stewart.
5 * copyright (c) 2010 Malte S. Stretz.
6 *
7 * You may use, modify and redistribute this file under the terms of the
8 * GNU General Public License version 2. (see COPYING.GPL)
9 */
10
11 #include "config.h"
12 #include "str.h"
13 #include "html.h"
14 #include "opt.h"
15
16 #include <assert.h>
17
18 static const char *relpaths[] = {
19 ".",
20 "..",
21 "../.."
22 };
23
24 void html_open(struct str *buf, const char *title,
25 const unsigned int path_depth, const int want_graph_js)
26 {
27 const char *root;
28 assert(path_depth < (sizeof(relpaths)/sizeof(*relpaths)));
29 root = relpaths[path_depth];
30
31 str_appendf(buf,
32 "<!DOCTYPE html>\n"
33 "<html>\n"
34 "<head>\n"
35 "<title>%s (darkstat %s)</title>\n"
36 "<meta name=\"generator\" content=\"" PACKAGE_STRING "\">\n"
37 "<meta name=\"robots\" content=\"noindex, noarchive\">\n"
38 "<meta name=\"viewport\" "
39 "content=\"width=device-width, initial-scale=1\">\n"
40 "<link rel=\"stylesheet\" href=\"%s/style.css\" type=\"text/css\">\n",
41 title, title_interfaces, root);
42
43 if (want_graph_js)
44 str_appendf(buf,
45 "<script src=\"%s/graph.js\" type=\"text/javascript\"></script>\n"
46 , root);
47
48 str_appendf(buf,
49 "</head>\n"
50 "<body>\n"
51 "<div class=\"menu\">\n"
52 "<ul class=\"menu\">" /* no whitespace (newlines) in list */
53 "<li class=\"label\">" PACKAGE_STRING "</li>"
54 "<li><a href=\"%s/\">graphs</a></li>"
55 "<li><a href=\"%s/hosts/\">hosts</a></li>"
56 "<li><a href=\"" PACKAGE_URL "\">homepage</a></li>"
57 "</ul>\n"
58 "</div>\n"
59 "<div class=\"content\">\n"
60 "<h2 class=\"pageheader\">%s</h2>\n"
61 , root, root, title);
62 }
63
64 void html_close(struct str *buf)
65 {
66 str_append(buf,
67 "</div>\n"
68 "</body>\n"
69 "</html>\n");
70 }
71
72 /* vim:set ts=4 sw=4 tw=80 et: */