4 * Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <sys/types.h>
29 * Manipulate command arguments.
32 /* List of argument values. */
33 TAILQ_HEAD(args_values
, args_value
);
35 /* Single arguments flag. */
38 struct args_values values
;
42 #define ARGS_ENTRY_OPTIONAL_VALUE 0x1
44 RB_ENTRY(args_entry
) entry
;
47 /* Parsed argument flags and values. */
49 struct args_tree tree
;
51 struct args_value
*values
;
54 /* Prepared command state. */
55 struct args_command_state
{
56 struct cmd_list
*cmdlist
;
58 struct cmd_parse_input pi
;
61 static struct args_entry
*args_find(struct args
*, u_char
);
63 static int args_cmp(struct args_entry
*, struct args_entry
*);
64 RB_GENERATE_STATIC(args_tree
, args_entry
, entry
, args_cmp
);
66 /* Arguments tree comparison function. */
68 args_cmp(struct args_entry
*a1
, struct args_entry
*a2
)
70 return (a1
->flag
- a2
->flag
);
73 /* Find a flag in the arguments tree. */
74 static struct args_entry
*
75 args_find(struct args
*args
, u_char flag
)
77 struct args_entry entry
;
80 return (RB_FIND(args_tree
, &args
->tree
, &entry
));
85 args_copy_value(struct args_value
*to
, struct args_value
*from
)
87 to
->type
= from
->type
;
92 to
->cmdlist
= from
->cmdlist
;
93 to
->cmdlist
->references
++;
96 to
->string
= xstrdup(from
->string
);
101 /* Type to string. */
103 args_type_to_string (enum args_type type
)
117 /* Get value as string. */
119 args_value_as_string(struct args_value
*value
)
121 switch (value
->type
) {
125 if (value
->cached
== NULL
)
126 value
->cached
= cmd_list_print(value
->cmdlist
, 0);
127 return (value
->cached
);
129 return (value
->string
);
131 fatalx("unexpected argument type");
134 /* Create an empty arguments set. */
140 args
= xcalloc(1, sizeof *args
);
141 RB_INIT(&args
->tree
);
145 /* Parse a single flag. */
147 args_parse_flag_argument(struct args_value
*values
, u_int count
, char **cause
,
148 struct args
*args
, u_int
*i
, const char *string
, int flag
,
149 int optional_argument
)
151 struct args_value
*argument
, *new;
154 new = xcalloc(1, sizeof *new);
155 if (*string
!= '\0') {
156 new->type
= ARGS_STRING
;
157 new->string
= xstrdup(string
);
164 argument
= &values
[*i
];
165 if (argument
->type
!= ARGS_STRING
) {
166 xasprintf(cause
, "-%c argument must be a string", flag
);
170 if (argument
== NULL
) {
171 if (optional_argument
) {
172 log_debug("%s: -%c (optional)", __func__
, flag
);
173 args_set(args
, flag
, NULL
, ARGS_ENTRY_OPTIONAL_VALUE
);
174 args_free_value(new);
176 return (0); /* either - or end */
178 xasprintf(cause
, "-%c expects an argument", flag
);
181 args_copy_value(new, argument
);
185 s
= args_value_as_string(new);
186 log_debug("%s: -%c = %s", __func__
, flag
, s
);
187 args_set(args
, flag
, new, 0);
191 /* Parse flags argument. */
193 args_parse_flags(const struct args_parse
*parse
, struct args_value
*values
,
194 u_int count
, char **cause
, struct args
*args
, u_int
*i
)
196 struct args_value
*value
;
198 const char *found
, *string
;
199 int optional_argument
;
202 if (value
->type
!= ARGS_STRING
)
205 string
= value
->string
;
206 log_debug("%s: next %s", __func__
, string
);
207 if (*string
++ != '-' || *string
== '\0')
210 if (string
[0] == '-' && string
[1] == '\0')
219 if (!isalnum(flag
)) {
220 xasprintf(cause
, "invalid flag -%c", flag
);
224 found
= strchr(parse
->template, flag
);
226 xasprintf(cause
, "unknown flag -%c", flag
);
229 if (found
[1] != ':') {
230 log_debug("%s: -%c", __func__
, flag
);
231 args_set(args
, flag
, NULL
, 0);
234 optional_argument
= (found
[2] == ':');
235 return (args_parse_flag_argument(values
, count
, cause
, args
, i
,
236 string
, flag
, optional_argument
));
240 /* Parse arguments into a new argument set. */
242 args_parse(const struct args_parse
*parse
, struct args_value
*values
,
243 u_int count
, char **cause
)
247 enum args_parse_type type
;
248 struct args_value
*value
, *new;
253 return (args_create());
255 args
= args_create();
256 for (i
= 1; i
< count
; /* nothing */) {
257 stop
= args_parse_flags(parse
, values
, count
, cause
, args
, &i
);
265 log_debug("%s: flags end at %u of %u", __func__
, i
, count
);
267 for (/* nothing */; i
< count
; i
++) {
270 s
= args_value_as_string(value
);
271 log_debug("%s: %u = %s (type %s)", __func__
, i
, s
,
272 args_type_to_string (value
->type
));
274 if (parse
->cb
!= NULL
) {
275 type
= parse
->cb(args
, args
->count
, cause
);
276 if (type
== ARGS_PARSE_INVALID
) {
281 type
= ARGS_PARSE_STRING
;
283 args
->values
= xrecallocarray(args
->values
,
284 args
->count
, args
->count
+ 1, sizeof *args
->values
);
285 new = &args
->values
[args
->count
++];
288 case ARGS_PARSE_INVALID
:
289 fatalx("unexpected argument type");
290 case ARGS_PARSE_STRING
:
291 if (value
->type
!= ARGS_STRING
) {
293 "argument %u must be \"string\"",
298 args_copy_value(new, value
);
300 case ARGS_PARSE_COMMANDS_OR_STRING
:
301 args_copy_value(new, value
);
303 case ARGS_PARSE_COMMANDS
:
304 if (value
->type
!= ARGS_COMMANDS
) {
306 "argument %u must be { commands }",
311 args_copy_value(new, value
);
317 if (parse
->lower
!= -1 && args
->count
< (u_int
)parse
->lower
) {
319 "too few arguments (need at least %u)",
324 if (parse
->upper
!= -1 && args
->count
> (u_int
)parse
->upper
) {
326 "too many arguments (need at most %u)",
334 /* Copy and expand a value. */
336 args_copy_copy_value(struct args_value
*to
, struct args_value
*from
, int argc
,
342 to
->type
= from
->type
;
343 switch (from
->type
) {
347 expanded
= xstrdup(from
->string
);
348 for (i
= 0; i
< argc
; i
++) {
349 s
= cmd_template_replace(expanded
, argv
[i
], i
+ 1);
353 to
->string
= expanded
;
356 to
->cmdlist
= cmd_list_copy(from
->cmdlist
, argc
, argv
);
361 /* Copy an arguments set. */
363 args_copy(struct args
*args
, int argc
, char **argv
)
365 struct args
*new_args
;
366 struct args_entry
*entry
;
367 struct args_value
*value
, *new_value
;
370 cmd_log_argv(argc
, argv
, "%s", __func__
);
372 new_args
= args_create();
373 RB_FOREACH(entry
, args_tree
, &args
->tree
) {
374 if (TAILQ_EMPTY(&entry
->values
)) {
375 for (i
= 0; i
< entry
->count
; i
++)
376 args_set(new_args
, entry
->flag
, NULL
, 0);
379 TAILQ_FOREACH(value
, &entry
->values
, entry
) {
380 new_value
= xcalloc(1, sizeof *new_value
);
381 args_copy_copy_value(new_value
, value
, argc
, argv
);
382 args_set(new_args
, entry
->flag
, new_value
, 0);
385 if (args
->count
== 0)
387 new_args
->count
= args
->count
;
388 new_args
->values
= xcalloc(args
->count
, sizeof *new_args
->values
);
389 for (i
= 0; i
< args
->count
; i
++) {
390 new_value
= &new_args
->values
[i
];
391 args_copy_copy_value(new_value
, &args
->values
[i
], argc
, argv
);
398 args_free_value(struct args_value
*value
)
400 switch (value
->type
) {
407 cmd_list_free(value
->cmdlist
);
415 args_free_values(struct args_value
*values
, u_int count
)
419 for (i
= 0; i
< count
; i
++)
420 args_free_value(&values
[i
]);
423 /* Free an arguments set. */
425 args_free(struct args
*args
)
427 struct args_entry
*entry
;
428 struct args_entry
*entry1
;
429 struct args_value
*value
;
430 struct args_value
*value1
;
432 args_free_values(args
->values
, args
->count
);
435 RB_FOREACH_SAFE(entry
, args_tree
, &args
->tree
, entry1
) {
436 RB_REMOVE(args_tree
, &args
->tree
, entry
);
437 TAILQ_FOREACH_SAFE(value
, &entry
->values
, entry
, value1
) {
438 TAILQ_REMOVE(&entry
->values
, value
, entry
);
439 args_free_value(value
);
448 /* Convert arguments to vector. */
450 args_to_vector(struct args
*args
, int *argc
, char ***argv
)
458 for (i
= 0; i
< args
->count
; i
++) {
459 switch (args
->values
[i
].type
) {
463 cmd_append_argv(argc
, argv
, args
->values
[i
].string
);
466 s
= cmd_list_print(args
->values
[i
].cmdlist
, 0);
467 cmd_append_argv(argc
, argv
, s
);
474 /* Convert arguments from vector. */
476 args_from_vector(int argc
, char **argv
)
478 struct args_value
*values
;
481 values
= xcalloc(argc
, sizeof *values
);
482 for (i
= 0; i
< argc
; i
++) {
483 values
[i
].type
= ARGS_STRING
;
484 values
[i
].string
= xstrdup(argv
[i
]);
490 static void printflike(3, 4)
491 args_print_add(char **buf
, size_t *len
, const char *fmt
, ...)
498 slen
= xvasprintf(&s
, fmt
, ap
);
502 *buf
= xrealloc(*buf
, *len
);
504 strlcat(*buf
, s
, *len
);
508 /* Add value to string. */
510 args_print_add_value(char **buf
, size_t *len
, struct args_value
*value
)
512 char *expanded
= NULL
;
515 args_print_add(buf
, len
, " ");
517 switch (value
->type
) {
521 expanded
= cmd_list_print(value
->cmdlist
, 0);
522 args_print_add(buf
, len
, "{ %s }", expanded
);
525 expanded
= args_escape(value
->string
);
526 args_print_add(buf
, len
, "%s", expanded
);
532 /* Print a set of arguments. */
534 args_print(struct args
*args
)
539 struct args_entry
*entry
;
540 struct args_entry
*last
= NULL
;
541 struct args_value
*value
;
544 buf
= xcalloc(1, len
);
546 /* Process the flags first. */
547 RB_FOREACH(entry
, args_tree
, &args
->tree
) {
548 if (entry
->flags
& ARGS_ENTRY_OPTIONAL_VALUE
)
550 if (!TAILQ_EMPTY(&entry
->values
))
554 args_print_add(&buf
, &len
, "-");
555 for (j
= 0; j
< entry
->count
; j
++)
556 args_print_add(&buf
, &len
, "%c", entry
->flag
);
559 /* Then the flags with arguments. */
560 RB_FOREACH(entry
, args_tree
, &args
->tree
) {
561 if (entry
->flags
& ARGS_ENTRY_OPTIONAL_VALUE
) {
563 args_print_add(&buf
, &len
, " -%c", entry
->flag
);
565 args_print_add(&buf
, &len
, "-%c", entry
->flag
);
569 if (TAILQ_EMPTY(&entry
->values
))
571 TAILQ_FOREACH(value
, &entry
->values
, entry
) {
573 args_print_add(&buf
, &len
, " -%c", entry
->flag
);
575 args_print_add(&buf
, &len
, "-%c", entry
->flag
);
576 args_print_add_value(&buf
, &len
, value
);
580 if (last
&& (last
->flags
& ARGS_ENTRY_OPTIONAL_VALUE
))
581 args_print_add(&buf
, &len
, " --");
583 /* And finally the argument vector. */
584 for (i
= 0; i
< args
->count
; i
++)
585 args_print_add_value(&buf
, &len
, &args
->values
[i
]);
590 /* Escape an argument. */
592 args_escape(const char *s
)
594 static const char dquoted
[] = " #';${}%";
595 static const char squoted
[] = " \"";
596 char *escaped
, *result
;
597 int flags
, quotes
= 0;
600 xasprintf(&result
, "''");
603 if (s
[strcspn(s
, dquoted
)] != '\0')
605 else if (s
[strcspn(s
, squoted
)] != '\0')
610 (quotes
!= 0 || s
[0] == '~')) {
611 xasprintf(&escaped
, "\\%c", s
[0]);
615 flags
= VIS_OCTAL
|VIS_CSTYLE
|VIS_TAB
|VIS_NL
;
618 utf8_stravis(&escaped
, s
, flags
);
621 xasprintf(&result
, "'%s'", escaped
);
622 else if (quotes
== '"') {
624 xasprintf(&result
, "\"\\%s\"", escaped
);
626 xasprintf(&result
, "\"%s\"", escaped
);
629 xasprintf(&result
, "\\%s", escaped
);
631 result
= xstrdup(escaped
);
637 /* Return if an argument is present. */
639 args_has(struct args
*args
, u_char flag
)
641 struct args_entry
*entry
;
643 entry
= args_find(args
, flag
);
646 return (entry
->count
);
649 /* Set argument value in the arguments tree. */
651 args_set(struct args
*args
, u_char flag
, struct args_value
*value
, int flags
)
653 struct args_entry
*entry
;
655 entry
= args_find(args
, flag
);
657 entry
= xcalloc(1, sizeof *entry
);
660 entry
->flags
= flags
;
661 TAILQ_INIT(&entry
->values
);
662 RB_INSERT(args_tree
, &args
->tree
, entry
);
665 if (value
!= NULL
&& value
->type
!= ARGS_NONE
)
666 TAILQ_INSERT_TAIL(&entry
->values
, value
, entry
);
671 /* Get argument value. Will be NULL if it isn't present. */
673 args_get(struct args
*args
, u_char flag
)
675 struct args_entry
*entry
;
677 if ((entry
= args_find(args
, flag
)) == NULL
)
679 if (TAILQ_EMPTY(&entry
->values
))
681 return (TAILQ_LAST(&entry
->values
, args_values
)->string
);
684 /* Get first argument. */
686 args_first(struct args
*args
, struct args_entry
**entry
)
688 *entry
= RB_MIN(args_tree
, &args
->tree
);
691 return ((*entry
)->flag
);
694 /* Get next argument. */
696 args_next(struct args_entry
**entry
)
698 *entry
= RB_NEXT(args_tree
, &args
->tree
, *entry
);
701 return ((*entry
)->flag
);
704 /* Get argument count. */
706 args_count(struct args
*args
)
708 return (args
->count
);
711 /* Get argument values. */
713 args_values(struct args
*args
)
715 return (args
->values
);
718 /* Get argument value. */
720 args_value(struct args
*args
, u_int idx
)
722 if (idx
>= args
->count
)
724 return (&args
->values
[idx
]);
727 /* Return argument as string. */
729 args_string(struct args
*args
, u_int idx
)
731 if (idx
>= args
->count
)
733 return (args_value_as_string(&args
->values
[idx
]));
736 /* Make a command now. */
738 args_make_commands_now(struct cmd
*self
, struct cmdq_item
*item
, u_int idx
,
741 struct args_command_state
*state
;
743 struct cmd_list
*cmdlist
;
745 state
= args_make_commands_prepare(self
, item
, idx
, NULL
, 0, expand
);
746 cmdlist
= args_make_commands(state
, 0, NULL
, &error
);
747 if (cmdlist
== NULL
) {
748 cmdq_error(item
, "%s", error
);
752 cmdlist
->references
++;
753 args_make_commands_free(state
);
757 /* Save bits to make a command later. */
758 struct args_command_state
*
759 args_make_commands_prepare(struct cmd
*self
, struct cmdq_item
*item
, u_int idx
,
760 const char *default_command
, int wait
, int expand
)
762 struct args
*args
= cmd_get_args(self
);
763 struct cmd_find_state
*target
= cmdq_get_target(item
);
764 struct client
*tc
= cmdq_get_target_client(item
);
765 struct args_value
*value
;
766 struct args_command_state
*state
;
770 state
= xcalloc(1, sizeof *state
);
772 if (idx
< args
->count
) {
773 value
= &args
->values
[idx
];
774 if (value
->type
== ARGS_COMMANDS
) {
775 state
->cmdlist
= value
->cmdlist
;
776 state
->cmdlist
->references
++;
781 if (default_command
== NULL
)
782 fatalx("argument out of range");
783 cmd
= default_command
;
788 state
->cmd
= format_single_from_target(item
, cmd
);
790 state
->cmd
= xstrdup(cmd
);
791 log_debug("%s: %s", __func__
, state
->cmd
);
794 state
->pi
.item
= item
;
795 cmd_get_source(self
, &file
, &state
->pi
.line
);
797 state
->pi
.file
= xstrdup(file
);
799 if (state
->pi
.c
!= NULL
)
800 state
->pi
.c
->references
++;
801 cmd_find_copy_state(&state
->pi
.fs
, target
);
806 /* Return argument as command. */
808 args_make_commands(struct args_command_state
*state
, int argc
, char **argv
,
811 struct cmd_parse_result
*pr
;
815 if (state
->cmdlist
!= NULL
) {
817 return (state
->cmdlist
);
818 return (cmd_list_copy(state
->cmdlist
, argc
, argv
));
821 cmd
= xstrdup(state
->cmd
);
822 log_debug("%s: %s", __func__
, cmd
);
823 cmd_log_argv(argc
, argv
, __func__
);
824 for (i
= 0; i
< argc
; i
++) {
825 new_cmd
= cmd_template_replace(cmd
, argv
[i
], i
+ 1);
826 log_debug("%s: %%%u %s: %s", __func__
, i
+ 1, argv
[i
], new_cmd
);
830 log_debug("%s: %s", __func__
, cmd
);
832 pr
= cmd_parse_from_string(cmd
, &state
->pi
);
834 switch (pr
->status
) {
835 case CMD_PARSE_ERROR
:
838 case CMD_PARSE_SUCCESS
:
839 return (pr
->cmdlist
);
841 fatalx("invalid parse return state");
844 /* Free commands state. */
846 args_make_commands_free(struct args_command_state
*state
)
848 if (state
->cmdlist
!= NULL
)
849 cmd_list_free(state
->cmdlist
);
850 if (state
->pi
.c
!= NULL
)
851 server_client_unref(state
->pi
.c
);
852 free((void *)state
->pi
.file
);
857 /* Get prepared command. */
859 args_make_commands_get_command(struct args_command_state
*state
)
865 if (state
->cmdlist
!= NULL
) {
866 first
= cmd_list_first(state
->cmdlist
);
868 return (xstrdup(""));
869 return (xstrdup(cmd_get_entry(first
)->name
));
871 n
= strcspn(state
->cmd
, " ,");
872 xasprintf(&s
, "%.*s", n
, state
->cmd
);
876 /* Get first value in argument. */
878 args_first_value(struct args
*args
, u_char flag
)
880 struct args_entry
*entry
;
882 if ((entry
= args_find(args
, flag
)) == NULL
)
884 return (TAILQ_FIRST(&entry
->values
));
887 /* Get next value in argument. */
889 args_next_value(struct args_value
*value
)
891 return (TAILQ_NEXT(value
, entry
));
894 /* Convert an argument value to a number. */
896 args_strtonum(struct args
*args
, u_char flag
, long long minval
,
897 long long maxval
, char **cause
)
901 struct args_entry
*entry
;
902 struct args_value
*value
;
904 if ((entry
= args_find(args
, flag
)) == NULL
) {
905 *cause
= xstrdup("missing");
908 value
= TAILQ_LAST(&entry
->values
, args_values
);
910 value
->type
!= ARGS_STRING
||
911 value
->string
== NULL
) {
912 *cause
= xstrdup("missing");
916 ll
= strtonum(value
->string
, minval
, maxval
, &errstr
);
917 if (errstr
!= NULL
) {
918 *cause
= xstrdup(errstr
);
926 /* Convert an argument value to a number, and expand formats. */
928 args_strtonum_and_expand(struct args
*args
, u_char flag
, long long minval
,
929 long long maxval
, struct cmdq_item
*item
, char **cause
)
934 struct args_entry
*entry
;
935 struct args_value
*value
;
937 if ((entry
= args_find(args
, flag
)) == NULL
) {
938 *cause
= xstrdup("missing");
941 value
= TAILQ_LAST(&entry
->values
, args_values
);
943 value
->type
!= ARGS_STRING
||
944 value
->string
== NULL
) {
945 *cause
= xstrdup("missing");
949 formatted
= format_single_from_target(item
, value
->string
);
950 ll
= strtonum(formatted
, minval
, maxval
, &errstr
);
952 if (errstr
!= NULL
) {
953 *cause
= xstrdup(errstr
);
961 /* Convert an argument to a number which may be a percentage. */
963 args_percentage(struct args
*args
, u_char flag
, long long minval
,
964 long long maxval
, long long curval
, char **cause
)
967 struct args_entry
*entry
;
969 if ((entry
= args_find(args
, flag
)) == NULL
) {
970 *cause
= xstrdup("missing");
973 if (TAILQ_EMPTY(&entry
->values
)) {
974 *cause
= xstrdup("empty");
977 value
= TAILQ_LAST(&entry
->values
, args_values
)->string
;
978 return (args_string_percentage(value
, minval
, maxval
, curval
, cause
));
981 /* Convert a string to a number which may be a percentage. */
983 args_string_percentage(const char *value
, long long minval
, long long maxval
,
984 long long curval
, char **cause
)
988 size_t valuelen
= strlen(value
);
992 *cause
= xstrdup("empty");
995 if (value
[valuelen
- 1] == '%') {
996 copy
= xstrdup(value
);
997 copy
[valuelen
- 1] = '\0';
999 ll
= strtonum(copy
, 0, 100, &errstr
);
1001 if (errstr
!= NULL
) {
1002 *cause
= xstrdup(errstr
);
1005 ll
= (curval
* ll
) / 100;
1007 *cause
= xstrdup("too small");
1011 *cause
= xstrdup("too large");
1015 ll
= strtonum(value
, minval
, maxval
, &errstr
);
1016 if (errstr
!= NULL
) {
1017 *cause
= xstrdup(errstr
);
1027 * Convert an argument to a number which may be a percentage, and expand
1031 args_percentage_and_expand(struct args
*args
, u_char flag
, long long minval
,
1032 long long maxval
, long long curval
, struct cmdq_item
*item
, char **cause
)
1035 struct args_entry
*entry
;
1037 if ((entry
= args_find(args
, flag
)) == NULL
) {
1038 *cause
= xstrdup("missing");
1041 if (TAILQ_EMPTY(&entry
->values
)) {
1042 *cause
= xstrdup("empty");
1045 value
= TAILQ_LAST(&entry
->values
, args_values
)->string
;
1046 return (args_string_percentage_and_expand(value
, minval
, maxval
, curval
,
1051 * Convert a string to a number which may be a percentage, and expand formats.
1054 args_string_percentage_and_expand(const char *value
, long long minval
,
1055 long long maxval
, long long curval
, struct cmdq_item
*item
, char **cause
)
1059 size_t valuelen
= strlen(value
);
1062 if (value
[valuelen
- 1] == '%') {
1063 copy
= xstrdup(value
);
1064 copy
[valuelen
- 1] = '\0';
1066 f
= format_single_from_target(item
, copy
);
1067 ll
= strtonum(f
, 0, 100, &errstr
);
1070 if (errstr
!= NULL
) {
1071 *cause
= xstrdup(errstr
);
1074 ll
= (curval
* ll
) / 100;
1076 *cause
= xstrdup("too small");
1080 *cause
= xstrdup("too large");
1084 f
= format_single_from_target(item
, value
);
1085 ll
= strtonum(f
, minval
, maxval
, &errstr
);
1087 if (errstr
!= NULL
) {
1088 *cause
= xstrdup(errstr
);