X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=action_list_graphs.c;fp=action_list_graphs.c;h=0000000000000000000000000000000000000000;hb=0ab3085f89e64eecd67d3179ea87f0463e918a10;hp=29e3d8b887839b3c3424578280e38e68e89c691a;hpb=af2ed61b280e1ec169aba2bcb9df30ac76b006d2;p=collection4.git diff --git a/action_list_graphs.c b/action_list_graphs.c deleted file mode 100644 index 29e3d8b..0000000 --- a/action_list_graphs.c +++ /dev/null @@ -1,126 +0,0 @@ -#include -#include -#include -#include - -#include "action_list_graphs.h" -#include "graph.h" -#include "graph_list.h" -#include "utils_params.h" - -#include -#include - -static int print_graph_inst_json (__attribute__((unused)) graph_config_t *cfg, /* {{{ */ - graph_instance_t *inst, - void *user_data) -{ - _Bool *first; - graph_ident_t *ident; - char *json; - - first = user_data; - - ident = inst_get_selector (inst); - if (ident == NULL) - return (-1); - - json = ident_to_json (ident); - if (json == NULL) - { - ident_destroy (ident); - return (ENOMEM); - } - - if (*first) - printf ("%s", json); - else - printf (",\n%s", json); - - *first = 0; - - ident_destroy (ident); - return (0); -} /* }}} int print_graph_inst_json */ - -static int print_graph_json (graph_config_t *cfg, /* {{{ */ - void *user_data) -{ - return (gl_graph_instance_get_all (cfg, print_graph_inst_json, user_data)); -} /* }}} int print_graph_json */ - -static int list_graphs_json (void) /* {{{ */ -{ - _Bool first = 1; - - printf ("Content-Type: application/json\n\n"); - - printf ("[\n"); - gl_graph_get_all (print_graph_json, /* user_data = */ &first); - printf ("\n]"); - - return (0); -} /* }}} int list_graphs_json */ - -static int print_graph_inst_html (graph_config_t *cfg, /* {{{ */ - graph_instance_t *inst, - __attribute__((unused)) void *user_data) -{ - char params[1024]; - char desc[1024]; - - memset (params, 0, sizeof (params)); - inst_get_params (cfg, inst, params, sizeof (params)); - - memset (desc, 0, sizeof (desc)); - inst_describe (cfg, inst, desc, sizeof (desc)); - - printf ("
  • %s
  • \n", - params, desc); - - return (0); -} /* }}} int print_graph_inst_html */ - -static int print_graph_html (graph_config_t *cfg, /* {{{ */ - __attribute__((unused)) void *user_data) -{ - char buffer[1024]; - - memset (buffer, 0, sizeof (buffer)); - graph_get_title (cfg, buffer, sizeof (buffer)); - - printf ("
  • %s\n
      \n", buffer); - gl_graph_instance_get_all (cfg, print_graph_inst_html, /* user_data = */ NULL); - printf ("
  • \n"); - - return (0); -} /* }}} int print_graph_html */ - -static int list_graphs_html (void) /* {{{ */ -{ - printf ("Content-Type: text/html\n\n"); - - printf ("
      \n"); - gl_graph_get_all (print_graph_html, /* user_data = */ NULL); - printf ("
    \n"); - - return (0); -} /* }}} int list_graphs_html */ - -int action_list_graphs (void) /* {{{ */ -{ - const char *format; - - gl_update (); - - format = param ("format"); - if (format == NULL) - format = "html"; - - if (strcmp ("json", format) == 0) - return (list_graphs_json ()); - else - return (list_graphs_html ()); -} /* }}} int action_list_graphs */ - -/* vim: set sw=2 sts=2 et fdm=marker : */