-static int draw_graph (graph_def_t *gd) /* {{{ */
-{
- str_array_t *args;
- rrd_info_t *info;
- size_t i;
-
- args = array_create ();
- if (args == NULL)
- return (ENOMEM);
-
- array_append (args, "graph");
- array_append (args, "-");
- array_append (args, "--imgformat");
- array_append (args, "PNG");
-
- for (i = 0; i < gd->data_sources_num; i++)
- draw_graph_ds (gd, i, args);
-
- rrd_clear_error ();
- info = rrd_graph_v (array_argc (args), array_argv (args));
- if ((info == NULL) || rrd_test_error ())
- {
- printf ("Content-Type: text/plain\n\n");
- printf ("rrd_graph_v failed: %s\n", rrd_get_error ());
- emulate_graph (array_argc (args), array_argv (args));
- }
- else
- {
- int status;
-
- status = output_graph (info);
- if (status != 0)
- {
- rrd_info_t *ptr;
-
- printf ("Content-Type: text/plain\n\n");
- printf ("output_graph failed. Maybe the \"image\" info was not found?\n\n");
-
- for (ptr = info; ptr != NULL; ptr = ptr->next)
- {
- ag_info_print (ptr);
- }
- }
- }
-
- if (info != NULL)
- rrd_info_free (info);
-
- array_destroy (args);
-
- return (0);
-} /* }}} int draw_graph */
+#define OUTPUT_ERROR(...) do { \
+ printf ("Content-Type: text/plain\n\n"); \
+ printf (__VA_ARGS__); \
+ return (0); \
+} while (0)