From 4c1798b95e26af39a18a36a3ffdd61d35bd60ea0 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 19 Jun 2010 10:19:15 +0200 Subject: [PATCH] src/action_list_graphs.c: Implement a limit of instances returned. --- src/action_list_graphs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/action_list_graphs.c b/src/action_list_graphs.c index cb2e31d..b6fc039 100644 --- a/src/action_list_graphs.c +++ b/src/action_list_graphs.c @@ -66,6 +66,7 @@ static int list_graphs_json (void) /* {{{ */ struct callback_data_s { graph_config_t *cfg; + int limit; }; typedef struct callback_data_s callback_data_t; @@ -99,12 +100,19 @@ static int print_graph_inst_html (graph_config_t *cfg, /* {{{ */ printf ("
  • %s
  • \n", script_name (), params, desc); + if (data->limit > 0) + data->limit--; + + /* Abort scan if limit is reached. */ + if (data->limit == 0) + return (1); + return (0); } /* }}} int print_graph_inst_html */ static int list_graphs_html (const char *term) /* {{{ */ { - callback_data_t data = { NULL }; + callback_data_t data = { NULL, /* limit = */ 20 }; printf ("Content-Type: text/html\n\n"); printf ("\n \n"); -- 2.30.2