summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0ab3085)
raw | patch | inline | side by side (parent: 0ab3085)
author | Florian Forster <ff@octo.it> | |
Fri, 18 Jun 2010 18:11:01 +0000 (20:11 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 18 Jun 2010 18:11:01 +0000 (20:11 +0200) |
src/action_graph.c | patch | blob | history |
diff --git a/src/action_graph.c b/src/action_graph.c
index a0f257e47b4d168571c02d0e8f2660af39194d67..f43f997a0afec28e530786d5fa5d2f6703e7662e 100644 (file)
--- a/src/action_graph.c
+++ b/src/action_graph.c
#include <fcgiapp.h>
#include <fcgi_stdio.h>
+static int get_time_args (str_array_t *args) /* {{{ */
+{
+ const char *begin_str;
+ const char *end_str;
+ long now;
+ long begin;
+ long end;
+ char *endptr;
+ long tmp;
+
+ begin_str = param ("begin");
+ end_str = param ("end");
+
+ now = (long) time (NULL);
+
+ if (begin_str != NULL)
+ {
+ endptr = NULL;
+ errno = 0;
+ tmp = strtol (begin_str, &endptr, /* base = */ 0);
+ if ((endptr == begin_str) || (errno != 0))
+ return (-1);
+ if (tmp <= 0)
+ begin = now + tmp;
+ else
+ begin = tmp;
+ }
+ else /* if (begin_str == NULL) */
+ {
+ begin = now - 86400;
+ }
+
+ if (end_str != NULL)
+ {
+ endptr = NULL;
+ errno = 0;
+ tmp = strtol (end_str, &endptr, /* base = */ 0);
+ if ((endptr == end_str) || (errno != 0))
+ return (-1);
+ end = tmp;
+ if (tmp <= 0)
+ end = now + tmp;
+ else
+ end = tmp;
+ }
+ else /* if (end_str == NULL) */
+ {
+ end = now;
+ }
+
+ if (begin == end)
+ return (-1);
+
+ if (begin > end)
+ {
+ tmp = begin;
+ begin = end;
+ end = tmp;
+ }
+
+ array_append (args, "-s");
+ array_append_format (args, "%li", begin);
+ array_append (args, "-e");
+ array_append_format (args, "%li", end);
+
+ return (0);
+} /* }}} int get_time_args */
+
static void emulate_graph (int argc, char **argv) /* {{{ */
{
int i;
array_append (args, "--imgformat");
array_append (args, "PNG");
+ get_time_args (args);
+
status = inst_get_rrdargs (cfg, inst, args);
if (status != 0)
{