2 * Copyright (C) 2015 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 void *null
, vici_res_t
*res
, char *name
, void *value
, int len
)
23 if (chunk_printable(chunk_create(value
, len
), NULL
, ' '))
25 printf(" %s[%.*s]\n", name
, len
, value
);
31 void *null
, vici_res_t
*res
, char *name
)
33 printf("%s:\n", name
);
34 return vici_parse_cb(res
, NULL
, algs
, NULL
, NULL
);
37 static int algorithms(vici_conn_t
*conn
)
42 command_format_options_t format
= COMMAND_FORMAT_NONE
;
47 switch (command_getopt(&arg
))
50 return command_usage(NULL
);
52 format
|= COMMAND_FORMAT_PRETTY
;
53 /* fall through to raw */
55 format
|= COMMAND_FORMAT_RAW
;
60 return command_usage("invalid --list-algs option");
65 req
= vici_begin("get-algorithms");
66 res
= vici_submit(req
, conn
);
70 fprintf(stderr
, "get-algorithms request failed: %s\n", strerror(errno
));
73 if (format
& COMMAND_FORMAT_RAW
)
75 vici_dump(res
, "get-algorithms reply", format
& COMMAND_FORMAT_PRETTY
,
80 if (vici_parse_cb(res
, types
, NULL
, NULL
, NULL
) != 0)
82 fprintf(stderr
, "parsing get-algorithms reply failed: %s\n",
91 * Register the command.
93 static void __attribute__ ((constructor
))reg()
95 command_register((command_t
) {
96 algorithms
, 'g', "list-algs", "show loaded algorithms",
99 {"help", 'h', 0, "show usage information"},
100 {"raw", 'r', 0, "dump raw response message"},
101 {"pretty", 'P', 0, "dump raw response message in pretty print"},