36 #include "cmdhandler.h" 38 #include "clientpipe.h" 44 static const char *module_str =
"verbosity_cmd";
57 client_printf(sockfd,
"Set verbosity.\n\n" 62 run(
int sockfd, cmdhandler_ctx_type* context,
const char *cmd)
66 char buf[ODS_SE_MAXLINE];
69 char *endptr, *errorstr;
71 strncpy(buf, cmd,
sizeof(buf));
72 buf[
sizeof(buf)-1] =
'\0';
73 argc = ods_str_explode(buf, NARGV, argv);
75 ods_log_debug(
"[%s] verbosity command", module_str);
77 client_printf(sockfd,
"Current verbosity is set to %d.\n",
89 }
else if (argc == 2) {
91 val = strtol(argv[1], &endptr, 10);
92 if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
93 || (errno != 0 && val == 0)) {
94 errorstr = strerror(errno);
95 client_printf(sockfd,
"Error parsing verbosity value: %s.\n", errorstr);
98 if (endptr == argv[1]) {
99 client_printf(sockfd,
"Error parsing verbosity value: No digits were found.\n");
103 client_printf(sockfd,
"Error parsing verbosity value: must be >= 0.\n");
106 ods_log_setverbosity(val);
107 client_printf(sockfd,
"Verbosity level set to %i.\n", val);
110 client_printf(sockfd,
"Too many arguments.\n");
117 "verbosity", &usage, &help, NULL, &run
struct cmd_func_block verbosity_funcblock