31 #include "cmdhandler.h"
35 #include "clientpipe.h"
40 static const char *module_str =
"policy_export_cmd";
49 " --policy <policy> | --all aka -p | -a \n"
57 "Export a specified policy or all of them from the database.\n"
59 "policy|all limit the operation to a specified policy or all of them\n\n"
64 run(
int sockfd, cmdhandler_ctx_type* context,
const char *cmd)
68 const char* argv[
NARGV];
70 int argc = 0, long_index = 0, opt = 0;
77 static struct option long_options[] = {
78 {
"policy", required_argument, 0,
'p'},
79 {
"all", no_argument, 0,
'a'},
85 if (!cmd || !(buf = strdup(cmd))) {
86 client_printf_err(sockfd,
"memory error\n");
90 argc = ods_str_explode(buf,
NARGV, argv);
92 client_printf_err(sockfd,
"too many arguments\n");
93 ods_log_error(
"[%s] too many arguments for %s command",
100 while ((opt = getopt_long(argc, (
char*
const*)argv,
"p:a", long_options, &long_index)) != -1) {
109 client_printf_err(sockfd,
"unknown arguments\n");
110 ods_log_error(
"[%s] unknown arguments for %s command",
130 client_printf_err(sockfd,
"Unable to find policy %s!\n",
policy_name);
142 client_printf_err(sockfd,
"Either --all or --policy needs to be given!\n");
152 "policy export", &usage, &help, NULL, &run