haproxy/include/proto
William Lallemand 1e08cd819a MEDIUM: cli: register CLI keywords with cli_register_kw()
To register a new cli keyword, you need to declare a cli_kw_list
structure in your source file:

	static struct cli_kw_list cli_kws = {{ },{
		{ { "test", "list", NULL }, "test list : do some tests on the cli", test_parsing, NULL },
		{ { NULL }, NULL, NULL, NULL, NULL }
	}};

And then register it:

	cli_register_kw(&cli_kws);

The first field is an array of 5 elements, where you declare the
keywords combination which will match, it must be ended by a NULL
element.

The second field is used as a usage message, it will appear in the help
of the cli, you can set it to NULL if you don't want to show it, it's a
good idea if you want to overwrite some existing keywords.

The two last fields are callbacks.

The first one is used at parsing time, you can use it to parse the
arguments of your keywords and print small messages. The function must
return 1 in case of a failure, otherwise 0:

	#include <proto/dumpstats.h>

	static int test_parsing(char **args, struct appctx *appctx)
	{
		struct chunk out;

		if (!*args[2]) {
			appctx->ctx.cli.msg = "Error: the 3rd argument is mandatory !";
			appctx->st0 = STAT_CLI_PRINT;
			return 1;
		}
		chunk_reset(&trash);
		chunk_printf(&trash, "arg[3]: %s\n", args[2]);
		chunk_init(&out, NULL, 0);
		chunk_dup(&out, &trash);
		appctx->ctx.cli.err = out.str;
		appctx->st0 = STAT_CLI_PRINT_FREE; /* print and free in the default cli_io_handler */
		return 0;
	}

The last field is the IO handler callback, it can be set to NULL if you
want to use the default cli_io_handler() otherwise you can write your
own. You can use the private pointer in the appctx if you need to store
a context or some data. stats_dump_sess_to_buffer() is a good example of
IO handler, IO handlers often use the appctx->st2 variable for the state
machine. The handler must return 0 in case it have to be recall later
otherwise 1.
2016-10-19 19:03:40 +02:00
..
acl.h MAJOR: sample: pass a pointer to the session to each sample fetch function 2015-04-06 11:37:25 +02:00
action.h MINOR: http/tcp: fill the avalaible actions 2015-10-02 22:56:11 +02:00
applet.h MINOR: applet: rename applet_runq to applet_active_queue 2015-09-25 18:02:44 +02:00
arg.h MINOR: sample: Moves ARGS underlying type from 32 to 64 bits. 2016-03-15 22:11:52 +01:00
auth.h
backend.h REORG/MAJOR: session: rename the "session" entity to "stream" 2015-04-06 11:23:56 +02:00
channel.h BUG/MEDIUM: channel: fix inconsistent handling of 4GB-1 transfers 2016-05-04 15:26:37 +02:00
checks.h MAJOR: check: find out which port to use for health check at run time 2016-09-11 08:12:13 +02:00
compression.h REORG: filters: Prepare creation of the HTTP compression filter 2016-02-09 14:53:15 +01:00
connection.h MINOR: listener: add the "accept-netscaler-cip" option to the "bind" keyword 2016-06-20 23:02:47 +02:00
dns.h MEDIUM: dns: new DNS response parser 2016-09-12 19:54:23 +02:00
dumpstats.h MEDIUM: cli: register CLI keywords with cli_register_kw() 2016-10-19 19:03:40 +02:00
fd.h
filters.h MEDIUM: filters: Add pre and post analyzer callbacks 2016-05-18 15:11:54 +02:00
flt_http_comp.h MAJOR: filters/http: Rewrite the HTTP compression as a filter 2016-02-09 14:53:15 +01:00
freq_ctr.h
frontend.h REORG/MAJOR: session: rename the "session" entity to "stream" 2015-04-06 11:23:56 +02:00
hdr_idx.h
hlua.h BUILD/MINOR: lua: ensure that hlua_ctx_destroy is properly defined 2015-06-17 20:18:54 +02:00
hlua_fcn.h MINOR: lua: post initialization 2016-03-30 15:44:58 +02:00
lb_chash.h
lb_fas.h
lb_fwlc.h
lb_fwrr.h
lb_map.h
listener.h CLEANUP: fix inconsistency between fd->iocb, proto->accept and accept() 2016-04-14 11:18:22 +02:00
log.h MEDIUM: log: add a new log format flag "E" 2016-02-12 13:36:47 +01:00
map.h MINOR: samples: rename some struct member from "smp" to "data" 2015-08-20 17:13:46 +02:00
obj_type.h CLEANUP: applet: rename struct si_applet to applet 2015-04-23 17:56:16 +02:00
pattern.h MINOR: map: Add regex matching replacement 2016-02-10 23:38:34 +01:00
payload.h REORG/MAJOR: session: rename the "session" entity to "stream" 2015-04-06 11:23:56 +02:00
peers.h MAJOR: peers: peers protocol version 2.0 2015-05-29 15:50:33 +02:00
pipe.h
port_range.h
proto_http.h MEDIUM: http: implement http-response track-sc* directive 2016-07-26 14:31:14 +02:00
proto_tcp.h CLEANUP: actions: missplaced includes 2015-09-10 21:17:04 +02:00
proto_udp.h CLEANUP: fix inconsistency between fd->iocb, proto->accept and accept() 2016-04-14 11:18:22 +02:00
proto_uxst.h REORG/MAJOR: session: rename the "session" entity to "stream" 2015-04-06 11:23:56 +02:00
protocol.h
proxy.h CLEANUP: proxy: remove last references to appsession 2015-08-10 19:42:30 +02:00
queue.h REORG/MAJOR: session: rename the "session" entity to "stream" 2015-04-06 11:23:56 +02:00
raw_sock.h
sample.h MINOR: sample: provide smp_is_rw() and smp_make_rw() 2016-08-09 14:30:57 +02:00
server.h MEDIUM: dns: new DNS response parser 2016-09-12 19:54:23 +02:00
session.h MINOR: session: introduce session_new() 2015-04-06 11:37:33 +02:00
shctx.h
signal.h
ssl_sock.h BUG/MINOR: ssl: Be sure to use unique serial for regenerated certificates 2016-02-09 09:04:53 +01:00
stick_table.h MEDIUM: peers: Fix a peer stick-tables synchronization issue. 2016-10-17 19:44:35 +02:00
stream.h MINOR: stream: export the function 'smp_create_src_stkctr' 2016-06-13 21:21:51 +02:00
stream_interface.h BUG: stream_interface: Reuse connection even if the output channel is empty 2016-02-03 14:22:55 +01:00
task.h
template.h
vars.h BUG/MAJOR: vars: always retrieve the stream and session from the sample 2016-03-10 17:28:04 +01:00