16 #include <my_global.h>
19 #include <mysys_err.h>
20 #include <my_getopt.h>
23 #include "my_default.h"
25 typedef void (*init_func_p)(
const struct my_option *
option,
void *variable,
28 static void default_reporter(
enum loglevel
level,
const char *format, ...);
29 my_error_reporter my_getopt_error_reporter= &default_reporter;
31 static int findopt(
char *, uint,
const struct my_option **,
const char **);
32 my_bool getopt_compare_strings(
const char *,
const char *, uint);
33 static longlong getopt_ll(
char *arg,
const struct my_option *optp,
int *err);
34 static ulonglong getopt_ull(
char *,
const struct my_option *,
int *);
35 static double getopt_double(
char *arg,
const struct my_option *optp,
int *err);
36 static void init_variables(
const struct my_option *, init_func_p);
37 static void init_one_value(
const struct my_option *,
void *, longlong);
38 static void fini_one_value(
const struct my_option *,
void *, longlong);
39 static int setval(
const struct my_option *,
void *,
char *, my_bool);
40 static char *check_struct_option(
char *cur_arg,
char *key_name);
41 static void print_cmdline_password_warning();
42 static my_bool get_bool_argument(
const struct my_option *opts,
50 static const char *special_opt_prefix[]=
51 {
"skip",
"disable",
"enable",
"maximum",
"loose", 0};
52 static const uint special_opt_prefix_lengths[]=
55 { OPT_SKIP, OPT_DISABLE, OPT_ENABLE, OPT_MAXIMUM, OPT_LOOSE};
57 char *disabled_my_option= (
char*)
"0";
58 char *enabled_my_option= (
char*)
"1";
66 my_bool my_getopt_print_errors= 1;
73 my_bool my_getopt_skip_unknown= 0;
75 static void default_reporter(
enum loglevel
level,
76 const char *format, ...)
79 va_start(args, format);
80 if (level == WARNING_LEVEL)
81 fprintf(stderr,
"%s",
"Warning: ");
82 else if (level == INFORMATION_LEVEL)
83 fprintf(stderr,
"%s",
"Info: ");
84 vfprintf(stderr, format, args);
90 static my_getopt_value getopt_get_addr;
92 void my_getopt_register_get_addr(my_getopt_value func_addr)
94 getopt_get_addr= func_addr;
110 int handle_options(
int *argc,
char ***argv,
112 my_get_one_option get_one_option)
114 return my_handle_options(argc, argv, longopts, get_one_option, NULL);
127 ulonglong getopt_double2ulonglong(
double v)
131 compile_time_assert(
sizeof(ulonglong) >=
sizeof(
double));
139 double getopt_ulonglong2double(ulonglong v)
212 int my_handle_options(
int *argc,
char ***argv,
214 my_get_one_option get_one_option,
215 const char **command_list)
217 uint UNINIT_VAR(opt_found), argvpos= 0, length;
218 my_bool end_of_options= 0, must_be_var, set_maximum_value,
220 char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN];
221 const char *UNINIT_VAR(prev_found);
225 my_bool is_cmdline_arg= 1;
228 DBUG_ASSERT(argc && *argc >= 1);
229 DBUG_ASSERT(argv && *argv);
232 init_variables(longopts, init_one_value);
238 for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
240 if (my_getopt_is_args_separator(*pos))
247 for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
252 if (!is_cmdline_arg && (my_getopt_is_args_separator(cur_arg)))
257 if (my_getopt_skip_unknown)
258 (*argv)[argvpos++]= cur_arg;
263 if (cur_arg[0] ==
'-' && cur_arg[1] && !end_of_options)
267 set_maximum_value= 0;
280 opt_str= check_struct_option(cur_arg, key_name);
281 optend= strcend(opt_str,
'=');
282 length= (uint) (optend - opt_str);
293 if (!(opt_found= findopt(opt_str, length, &optp, &prev_found)))
303 for (i= 0; special_opt_prefix[
i]; i++)
305 if (!getopt_compare_strings(special_opt_prefix[i], opt_str,
306 special_opt_prefix_lengths[i]) &&
307 (opt_str[special_opt_prefix_lengths[
i]] ==
'-' ||
308 opt_str[special_opt_prefix_lengths[
i]] ==
'_'))
313 opt_str+= special_opt_prefix_lengths[
i] + 1;
314 length-= special_opt_prefix_lengths[
i] + 1;
317 if ((opt_found= findopt(opt_str, length, &optp, &prev_found)))
321 if (my_getopt_print_errors)
322 my_getopt_error_reporter(ERROR_LEVEL,
323 "%s: ambiguous option '--%s-%s' (--%s-%s)",
324 my_progname, special_opt_prefix[i],
325 opt_str, special_opt_prefix[i],
327 return EXIT_AMBIGUOUS_OPTION;
336 optend= (optend && *optend ==
'0' && !(*(optend + 1))) ?
337 enabled_my_option : disabled_my_option;
340 optend= (optend && *optend ==
'0' && !(*(optend + 1))) ?
341 disabled_my_option : enabled_my_option;
344 set_maximum_value= 1;
356 if (my_getopt_skip_unknown)
360 (*argv)[argvpos++]= *first++;
361 }
while (first <= pos);
366 if (my_getopt_print_errors)
367 my_getopt_error_reporter(option_is_loose ?
368 WARNING_LEVEL : ERROR_LEVEL,
369 "%s: unknown variable '%s'",
370 my_progname, cur_arg);
371 if (!option_is_loose)
372 return EXIT_UNKNOWN_VARIABLE;
376 if (my_getopt_print_errors)
377 my_getopt_error_reporter(option_is_loose ?
378 WARNING_LEVEL : ERROR_LEVEL,
379 "%s: unknown option '--%s'",
380 my_progname, cur_arg);
381 if (!option_is_loose)
382 return EXIT_UNKNOWN_OPTION;
395 if (my_getopt_print_errors)
396 my_getopt_error_reporter(ERROR_LEVEL,
397 "%s: variable prefix '%s' is not unique",
398 my_progname, opt_str);
399 return EXIT_VAR_PREFIX_NOT_UNIQUE;
403 if (my_getopt_print_errors)
404 my_getopt_error_reporter(ERROR_LEVEL,
405 "%s: ambiguous option '--%s' (%s, %s)",
406 my_progname, opt_str, prev_found,
408 return EXIT_AMBIGUOUS_OPTION;
411 if ((optp->
var_type & GET_TYPE_MASK) == GET_DISABLED)
413 if (my_getopt_print_errors)
415 "%s: %s: Option '%s' used, but is disabled\n", my_progname,
416 option_is_loose ?
"WARNING" :
"ERROR", opt_str);
422 return EXIT_OPTION_DISABLED;
425 value= optp->
var_type & GET_ASK_ADDR ?
426 (*getopt_get_addr)(key_name, (uint) strlen(key_name), optp, &error) :
431 if (optp->arg_type == NO_ARG)
438 if (optend && (optp->var_type & GET_TYPE_MASK) != GET_BOOL)
440 if (my_getopt_print_errors)
441 my_getopt_error_reporter(ERROR_LEVEL,
442 "%s: option '--%s' cannot take an argument",
443 my_progname, optp->name);
444 return EXIT_NO_ARGUMENT_ALLOWED;
446 if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL)
455 *((my_bool*) value)= (my_bool) 1;
460 ret= get_bool_argument(optp, optend, &error);
463 my_getopt_error_reporter(WARNING_LEVEL,
464 "%s: ignoring option '--%s' "
465 "due to invalid value '%s'",
466 my_progname, optp->name, optend);
470 *((my_bool*) value)=
ret;
472 if (get_one_option && get_one_option(optp->id, optp,
473 *((my_bool*) value) ?
474 enabled_my_option : disabled_my_option))
475 return EXIT_ARGUMENT_INVALID;
480 else if (optp->arg_type == REQUIRED_ARG && !optend)
486 if (!is_cmdline_arg || !*++pos)
488 if (my_getopt_print_errors)
489 my_getopt_error_reporter(ERROR_LEVEL,
490 "%s: option '--%s' requires an argument",
491 my_progname, optp->name);
492 return EXIT_ARGUMENT_REQUIRED;
500 if (optp->var_type == GET_PASSWORD && is_cmdline_arg && argument)
501 print_cmdline_password_warning();
505 for (optend= cur_arg; *optend; optend++)
508 for (optp= longopts; optp->
name; optp++)
510 if (optp->id && optp->id == (
int) (uchar) *optend)
514 if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED)
516 if (my_getopt_print_errors)
518 "%s: ERROR: Option '-%c' used, but is disabled\n",
519 my_progname, optp->id);
520 return EXIT_OPTION_DISABLED;
522 if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL &&
523 optp->arg_type == NO_ARG)
525 *((my_bool*) optp->value)= (my_bool) 1;
526 if (get_one_option && get_one_option(optp->id, optp, argument))
527 return EXIT_UNSPECIFIED_ERROR;
530 else if (optp->arg_type == REQUIRED_ARG ||
531 optp->arg_type == OPT_ARG)
536 argument= optend + 1;
539 if (optp->var_type == GET_PASSWORD && is_cmdline_arg)
540 print_cmdline_password_warning();
544 if (optp->arg_type == OPT_ARG)
546 if (optp->var_type == GET_BOOL)
547 *((my_bool*) optp->value)= (my_bool) 1;
548 if (get_one_option && get_one_option(optp->id, optp, argument))
549 return EXIT_UNSPECIFIED_ERROR;
555 if (my_getopt_print_errors)
556 my_getopt_error_reporter(ERROR_LEVEL,
557 "%s: option '-%c' requires an argument",
558 my_progname, optp->id);
559 return EXIT_ARGUMENT_REQUIRED;
566 if ((error= setval(optp, optp->value, argument,
569 if (get_one_option && get_one_option(optp->id, optp, argument))
570 return EXIT_UNSPECIFIED_ERROR;
576 if (my_getopt_skip_unknown)
585 DBUG_ASSERT(optend > *pos);
586 DBUG_ASSERT(optend >= cur_arg);
587 DBUG_ASSERT(optend <= *pos + strlen(*pos));
588 DBUG_ASSERT(*optend);
591 (*argv)[argvpos++]= optend;
600 if (my_getopt_print_errors)
601 my_getopt_error_reporter(ERROR_LEVEL,
602 "%s: unknown option '-%c'",
603 my_progname, *optend);
604 return EXIT_UNKNOWN_OPTION;
612 if ((error= setval(optp, value, argument, set_maximum_value)))
614 if (get_one_option && get_one_option(optp->id, optp, argument))
615 return EXIT_UNSPECIFIED_ERROR;
623 while (* command_list)
625 if (!strcmp(*command_list, cur_arg))
628 (*argv)[argvpos ++]= cur_arg;
631 while ((++ pos) != pos_end)
632 (*argv)[argvpos ++]= *pos;
638 (*argv)[argvpos ++]= cur_arg;
659 static void print_cmdline_password_warning()
661 static my_bool password_warning_announced= FALSE;
663 if (!password_warning_announced)
665 fprintf(stderr,
"Warning: Using a password on the command line "
666 "interface can be insecure.\n");
667 (void) fflush(stderr);
668 password_warning_announced= TRUE;
687 static char *check_struct_option(
char *cur_arg,
char *key_name)
691 ptr= strcend(cur_arg + 1,
'.');
692 end= strcend(cur_arg,
'=');
703 uint len= (uint) (ptr - cur_arg);
704 set_if_smaller(len, FN_REFLEN-1);
705 strmake(key_name, cur_arg, len);
725 static my_bool get_bool_argument(
const struct my_option *opts,
726 const char *argument,
729 if (!my_strcasecmp(&my_charset_latin1, argument,
"true") ||
730 !my_strcasecmp(&my_charset_latin1, argument,
"on") ||
731 !my_strcasecmp(&my_charset_latin1, argument,
"1"))
733 else if (!my_strcasecmp(&my_charset_latin1, argument,
"false") ||
734 !my_strcasecmp(&my_charset_latin1, argument,
"off") ||
735 !my_strcasecmp(&my_charset_latin1, argument,
"0"))
749 static int setval(
const struct my_option *opts,
void *value,
char *argument,
750 my_bool set_maximum_value)
756 argument= enabled_my_option;
760 if (set_maximum_value && !(value= opts->
u_max_value))
762 my_getopt_error_reporter(ERROR_LEVEL,
763 "%s: Maximum value of '%s' cannot be set",
764 my_progname, opts->
name);
765 return EXIT_NO_PTR_TO_VARIABLE;
768 switch ((opts->
var_type & GET_TYPE_MASK)) {
770 *((my_bool*) value)= get_bool_argument(opts, argument, &error);
772 my_getopt_error_reporter(WARNING_LEVEL,
773 "option '%s': boolean value '%s' wasn't recognized. Set to OFF.",
774 opts->
name, argument);
777 *((
int*) value)= (int) getopt_ll(argument, opts, &err);
780 *((uint*) value)= (uint) getopt_ull(argument, opts, &err);
783 *((
long*) value)= (long) getopt_ll(argument, opts, &err);
786 *((
long*) value)= (long) getopt_ull(argument, opts, &err);
789 *((longlong*) value)= getopt_ll(argument, opts, &err);
792 *((ulonglong*) value)= getopt_ull(argument, opts, &err);
795 *((
double*) value)= getopt_double(argument, opts, &err);
799 if (argument == enabled_my_option)
801 *((
char**) value)= argument;
804 if (argument == enabled_my_option)
806 my_free(*((
char**) value));
807 if (!(*((
char**) value)= my_strdup(argument, MYF(MY_WME))))
809 res= EXIT_OUT_OF_MEMORY;
815 int type= find_type(argument, opts->
typelib, FIND_TYPE_BASIC);
822 ulong arg= strtoul(argument, &endptr, 10);
823 if (*endptr || arg >= opts->
typelib->count)
825 res= EXIT_ARGUMENT_INVALID;
832 res= EXIT_AMBIGUOUS_OPTION;
836 *(ulong*)value= type - 1;
840 *((ulonglong*)value)= find_typeset(argument, opts->
typelib, &err);
845 ulonglong arg= (ulonglong) strtol(argument, &endptr, 10);
846 if (*endptr || (arg >> 1) >= (1ULL << (opts->
typelib->count-1)))
848 res= EXIT_ARGUMENT_INVALID;
851 *(ulonglong*)value= arg;
860 *((ulonglong*)value)=
863 argument, strlen(argument),
867 res= EXIT_ARGUMENT_INVALID;
878 res= EXIT_UNKNOWN_SUFFIX;
885 my_getopt_error_reporter(ERROR_LEVEL,
886 "%s: Error while setting value '%s' to '%s'",
887 my_progname, argument, opts->
name);
914 static int findopt(
char *optpat, uint length,
920 my_bool is_prefix= FALSE;
922 for (count= 0; opt->
name; opt++)
924 if (!getopt_compare_strings(opt->
name, optpat, length))
927 if (!opt->
name[length])
935 if (opt->
name[length])
938 else if (strcmp(*ffname, opt->
name))
948 if (is_prefix && count == 1)
949 my_getopt_error_reporter(WARNING_LEVEL,
950 "Using unique option prefix %.*s instead of %s "
951 "is deprecated and will be removed in a future "
952 "release. Please use the full name instead.",
953 length, optpat, *ffname);
965 my_bool getopt_compare_strings(
register const char *s,
register const char *t,
968 char const *end= s + length;
969 for (;s != end ; s++, t++)
971 if ((*s !=
'-' ? *s :
'_') != (*t !=
'-' ? *t :
'_'))
984 static longlong eval_num_suffix(
char *argument,
int *error,
char *option_name)
991 num= strtoll(argument, &endchar, 10);
994 my_getopt_error_reporter(ERROR_LEVEL,
995 "Incorrect integer value: '%s'", argument);
999 if (*endchar ==
'k' || *endchar ==
'K')
1001 else if (*endchar ==
'm' || *endchar ==
'M')
1002 num*= 1024L * 1024L;
1003 else if (*endchar ==
'g' || *endchar ==
'G')
1004 num*= 1024L * 1024L * 1024L;
1008 "Unknown suffix '%c' used for variable '%s' (value '%s')\n",
1009 *endchar, option_name, argument);
1027 static longlong getopt_ll(
char *arg,
const struct my_option *optp,
int *err)
1029 longlong num=eval_num_suffix(arg, err, (
char*) optp->
name);
1030 return getopt_ll_limit_value(num, optp, NULL);
1039 ulonglong max_of_int_range(
int var_type)
1048 return LONGLONG_MAX;
1054 return ULONGLONG_MAX;
1069 longlong getopt_ll_limit_value(longlong num,
const struct my_option *optp,
1073 my_bool adjusted= FALSE;
1074 char buf1[255], buf2[255];
1076 const longlong max_of_type=
1077 (longlong)max_of_int_range(optp->
var_type & GET_TYPE_MASK);
1079 if (num > 0 && ((ulonglong) num > (ulonglong) optp->
max_value) &&
1086 if (num > max_of_type)
1093 num= (longlong) (num * block_size);
1098 if (old < optp->min_value)
1105 my_getopt_error_reporter(WARNING_LEVEL,
1106 "option '%s': signed value %s adjusted to %s",
1107 optp->
name, llstr(old, buf1), llstr(num, buf2));
1118 static ulonglong getopt_ull(
char *arg,
const struct my_option *optp,
int *err)
1120 ulonglong num= eval_num_suffix(arg, err, (
char*) optp->
name);
1121 return getopt_ull_limit_value(num, optp, NULL);
1125 ulonglong getopt_ull_limit_value(ulonglong num,
const struct my_option *optp,
1128 my_bool adjusted= FALSE;
1130 char buf1[255], buf2[255];
1131 const ulonglong max_of_type=
1132 max_of_int_range(optp->
var_type & GET_TYPE_MASK);
1134 if ((ulonglong) num > (ulonglong) optp->
max_value &&
1141 if (num > max_of_type)
1163 my_getopt_error_reporter(WARNING_LEVEL,
1164 "option '%s': unsigned value %s adjusted to %s",
1165 optp->
name, ullstr(old, buf1), ullstr(num, buf2));
1170 double getopt_double_limit_value(
double num,
const struct my_option *optp,
1173 my_bool adjusted= FALSE;
1177 max= getopt_ulonglong2double(optp->
max_value);
1178 min= getopt_ulonglong2double(optp->
min_value);
1179 if (max && num > max)
1192 my_getopt_error_reporter(WARNING_LEVEL,
1193 "option '%s': value %g adjusted to %g",
1194 optp->
name, old, num);
1210 static double getopt_double(
char *arg,
const struct my_option *optp,
int *err)
1214 char *end= arg + 1000;
1215 num= my_strtod(arg, &end, &error);
1216 if (end[0] != 0 || error)
1218 my_getopt_error_reporter(ERROR_LEVEL,
1219 "Invalid decimal value for option '%s'\n", optp->
name);
1220 *err= EXIT_ARGUMENT_INVALID;
1223 return getopt_double_limit_value(num, optp, NULL);
1235 static void init_one_value(
const struct my_option *option,
void *variable,
1238 DBUG_ENTER(
"init_one_value");
1239 switch ((option->
var_type & GET_TYPE_MASK)) {
1241 *((my_bool*) variable)= (my_bool) value;
1244 *((
int*) variable)= (int) getopt_ll_limit_value((
int)
value, option, NULL);
1247 *((ulong*) variable)= (ulong) value;
1250 *((uint*) variable)= (uint) getopt_ull_limit_value((uint)
value, option, NULL);
1253 *((
long*) variable)= (long) getopt_ll_limit_value((
long)
value, option, NULL);
1256 *((ulong*) variable)= (ulong) getopt_ull_limit_value((ulong)
value, option, NULL);
1259 *((longlong*) variable)= (longlong) getopt_ll_limit_value((longlong)
value, option, NULL);
1262 *((ulonglong*) variable)= (ulonglong) getopt_ull_limit_value((ulonglong)
value, option, NULL);
1266 *((ulonglong*) variable)= (ulonglong) value;
1269 *((
double*) variable)= getopt_ulonglong2double(value);
1279 if ((
char*) (intptr) value)
1280 *((
char**) variable)= (
char*) (intptr)
value;
1289 if ((
char*) (intptr) value)
1291 char **pstr= (
char **) variable;
1293 *pstr= my_strdup((
char*) (intptr) value, MYF(MY_WME));
1312 static void fini_one_value(
const struct my_option *option,
void *variable,
1313 longlong value __attribute__ ((unused)))
1315 DBUG_ENTER(
"fini_one_value");
1316 switch ((option->
var_type & GET_TYPE_MASK)) {
1318 my_free(*((
char**) variable));
1319 *((
char**) variable)= NULL;
1328 void my_cleanup_options(
const struct my_option *options)
1330 init_variables(options, fini_one_value);
1347 static void init_variables(
const struct my_option *options,
1348 init_func_p init_one_value)
1350 DBUG_ENTER(
"init_variables");
1351 for (; options->
name; options++)
1354 DBUG_PRINT(
"options", (
"name: '%s'", options->
name));
1362 value= (options->
var_type & GET_ASK_ADDR ?
1363 (*getopt_get_addr)(
"", 0, options, 0) : options->value);
1365 init_one_value(options, value, options->def_value);
1371 static uint print_name(
const struct my_option *optp)
1373 const char *s= optp->
name;
1375 putchar(*s ==
'_' ?
'-' : *s);
1376 return s - optp->
name;
1385 void my_print_help(
const struct my_option *options)
1387 uint col, name_space= 22, comment_space= 57;
1388 const char *line_end;
1391 for (optp= options; optp->
name; optp++)
1393 if (optp->
id && optp->
id < 256)
1395 printf(
" -%c%s", optp->
id, strlen(optp->
name) ?
", " :
" ");
1403 if (strlen(optp->
name))
1406 col+= 2 + print_name(optp);
1408 (optp->
var_type & GET_TYPE_MASK) == GET_BOOL)
1413 else if ((optp->
var_type & GET_TYPE_MASK) == GET_STR ||
1414 (optp->
var_type & GET_TYPE_MASK) == GET_PASSWORD ||
1415 (optp->
var_type & GET_TYPE_MASK) == GET_STR_ALLOC ||
1416 (optp->
var_type & GET_TYPE_MASK) == GET_ENUM ||
1417 (optp->
var_type & GET_TYPE_MASK) == GET_SET ||
1418 (optp->
var_type & GET_TYPE_MASK) == GET_FLAGSET )
1420 printf(
"%s=name%s ", optp->
arg_type == OPT_ARG ?
"[" :
"",
1421 optp->
arg_type == OPT_ARG ?
"]" :
"");
1422 col+= (optp->
arg_type == OPT_ARG) ? 8 : 6;
1426 printf(
"%s=#%s ", optp->
arg_type == OPT_ARG ?
"[" :
"",
1427 optp->
arg_type == OPT_ARG ?
"]" :
"");
1428 col+= (optp->
arg_type == OPT_ARG) ? 5 : 3;
1436 for (; col < name_space; col++)
1442 while ((uint) (end - comment) > comment_space)
1444 for (line_end= comment + comment_space; *line_end !=
' '; line_end--)
1446 for (; comment != line_end; comment++)
1450 for (col= 0; col < name_space; col++)
1453 printf(
"%s", comment);
1456 if ((optp->
var_type & GET_TYPE_MASK) == GET_BOOL)
1460 printf(
"%*s(Defaults to on; use --skip-", name_space,
"");
1462 printf(
" to disable.)\n");
1475 void my_print_variables(
const struct my_option *options)
1477 uint name_space= 34, length, nr;
1482 for (optp= options; optp->
name; optp++)
1484 length= strlen(optp->
name)+1;
1485 if (length > name_space)
1489 printf(
"\nVariables (--variable-name=value)\n");
1490 printf(
"%-*s%s", name_space,
"and boolean options {FALSE|TRUE}",
1491 "Value (after reading options)\n");
1492 for (length=1; length < 75; length++)
1493 putchar(length == name_space ?
' ' :
'-');
1496 for (optp= options; optp->
name; optp++)
1498 void *value= (optp->
var_type & GET_ASK_ADDR ?
1499 (*getopt_get_addr)(
"", 0, optp, 0) : optp->value);
1502 length= print_name(optp);
1503 for (; length < name_space; length++)
1505 switch ((optp->var_type & GET_TYPE_MASK)) {
1507 if (!(llvalue= *(ulonglong*) value))
1510 for (nr= 0; llvalue && nr < optp->typelib->count; nr++, llvalue >>=1)
1513 printf( llvalue > 1 ?
"%s," :
"%s\n", get_type(optp->typelib, nr));
1517 llvalue= *(ulonglong*) value;
1518 for (nr= 0; llvalue && nr < optp->typelib->count; nr++, llvalue >>=1)
1520 printf(
"%s%s=", (nr ?
"," :
""), get_type(optp->typelib, nr));
1521 printf(llvalue & 1 ?
"on" :
"off");
1526 printf(
"%s\n", get_type(optp->typelib, *(ulong*) value));
1531 printf(
"%s\n", *((
char**) value) ? *((
char**) value) :
1532 "(No default value)");
1535 printf(
"%s\n", *((my_bool*) value) ?
"TRUE" :
"FALSE");
1538 printf(
"%d\n", *((
int*) value));
1541 printf(
"%d\n", *((uint*) value));
1544 printf(
"%ld\n", *((
long*) value));
1547 printf(
"%lu\n", *((ulong*) value));
1550 printf(
"%s\n", llstr(*((longlong*) value), buff));
1553 longlong2str(*((ulonglong*) value), buff, 10);
1554 printf(
"%s\n", buff);
1557 printf(
"%g\n", *(
double*) value);
1560 printf(
"(No default value)\n");
1563 printf(
"(Disabled)\n");