This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| struct | my_option |
Defines | |
| #define | GET_NO_ARG 1 |
| #define | GET_BOOL 2 |
| #define | GET_INT 3 |
| #define | GET_UINT 4 |
| #define | GET_LONG 5 |
| #define | GET_ULONG 6 |
| #define | GET_LL 7 |
| #define | GET_ULL 8 |
| #define | GET_STR 9 |
| #define | GET_STR_ALLOC 10 |
| #define | GET_DISABLED 11 |
| #define | GET_ASK_ADDR 128 |
| #define | GET_TYPE_MASK 127 |
Typedefs | |
| typedef my_bool(*) | my_get_one_option (int, const struct my_option *, char *) |
| typedef void(*) | my_error_reporter (enum loglevel level, const char *format,...) |
Enumerations | |
| enum | get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG } |
Functions | |
| int | handle_options (int *argc, char ***argv, const struct my_option *longopts, my_get_one_option) |
| void | my_print_help (const struct my_option *options) |
| void | my_print_variables (const struct my_option *options) |
| void | my_getopt_register_get_addr (gptr *(*func_addr)(const char *, uint, const struct my_option *)) |
| ulonglong | getopt_ull_limit_value (ulonglong num, const struct my_option *optp) |
| my_bool | getopt_compare_strings (const char *s, const char *t, uint length) |
Variables | |
| char * | disabled_my_option |
| my_bool | my_getopt_print_errors |
| my_error_reporter | my_getopt_error_reporter |
| #define GET_ASK_ADDR 128 |
Definition at line 34 of file my_getopt.h.
Referenced by handle_options(), init_variables(), and my_print_variables().
| #define GET_BOOL 2 |
Definition at line 23 of file my_getopt.h.
Referenced by handle_options(), init_one_value(), my_print_help(), my_print_variables(), and setval().
| #define GET_DISABLED 11 |
| #define GET_INT 3 |
Definition at line 24 of file my_getopt.h.
Referenced by init_one_value(), my_print_variables(), InitConfigFileParser::parse_mycnf(), setval(), and InitConfigFileParser::store_in_properties().
| #define GET_LL 7 |
Definition at line 28 of file my_getopt.h.
Referenced by init_one_value(), my_print_variables(), InitConfigFileParser::parse_mycnf(), setval(), and InitConfigFileParser::store_in_properties().
| #define GET_LONG 5 |
Definition at line 26 of file my_getopt.h.
Referenced by init_one_value(), my_print_variables(), and setval().
| #define GET_NO_ARG 1 |
| #define GET_STR 9 |
Definition at line 30 of file my_getopt.h.
Referenced by my_print_help(), my_print_variables(), InitConfigFileParser::parse_mycnf(), setval(), and InitConfigFileParser::store_in_properties().
| #define GET_STR_ALLOC 10 |
Definition at line 31 of file my_getopt.h.
Referenced by my_print_help(), my_print_variables(), and setval().
| #define GET_TYPE_MASK 127 |
Definition at line 35 of file my_getopt.h.
Referenced by handle_options(), init_one_value(), my_print_help(), my_print_variables(), and setval().
| #define GET_UINT 4 |
Definition at line 25 of file my_getopt.h.
Referenced by init_one_value(), my_print_variables(), and setval().
| #define GET_ULL 8 |
Definition at line 29 of file my_getopt.h.
Referenced by init_one_value(), my_print_variables(), and setval().
| #define GET_ULONG 6 |
Definition at line 27 of file my_getopt.h.
Referenced by init_one_value(), my_print_variables(), and setval().
| typedef void(* ) my_error_reporter(enum loglevel level, const char *format,...) |
Definition at line 58 of file my_getopt.h.
| typedef my_bool(* ) my_get_one_option(int, const struct my_option *, char *) |
Definition at line 57 of file my_getopt.h.
| enum get_opt_arg_type |
Referenced by find_option(), findopt(), and handle_options().
Here is the caller graph for this function:

Definition at line 750 of file my_getopt.c.
References my_option::block_size, my_option::max_value, and my_option::min_value.
Referenced by getopt_ull(), sys_var_key_cache_long::update(), sys_var_key_buffer_size::update(), sys_var_thd_ulonglong::update(), sys_var_thd_ha_rows::update(), sys_var_thd_ulong::update(), sys_var_ulonglong_ptr::update(), and sys_var_long_ptr_global::update().
00751 { 00752 if ((ulonglong) num > (ulonglong) optp->max_value && 00753 optp->max_value) /* if max value is not set -> no upper limit */ 00754 num= (ulonglong) optp->max_value; 00755 if (optp->block_size > 1) 00756 { 00757 num/= (ulonglong) optp->block_size; 00758 num*= (ulonglong) optp->block_size; 00759 } 00760 if (num < (ulonglong) optp->min_value) 00761 num= (ulonglong) optp->min_value; 00762 return num; 00763 }
Here is the caller graph for this function:

| int handle_options | ( | int * | argc, | |
| char *** | argv, | |||
| const struct my_option * | longopts, | |||
| my_get_one_option | ||||
| ) |
Definition at line 89 of file my_getopt.c.
References my_option::arg_type, check_struct_option(), disabled_my_option, error, ERROR_LEVEL, EXIT_AMBIGUOUS_OPTION, EXIT_ARGUMENT_REQUIRED, EXIT_NO_ARGUMENT_ALLOWED, EXIT_OPTION_DISABLED, EXIT_UNKNOWN_OPTION, EXIT_UNKNOWN_VARIABLE, EXIT_VAR_PREFIX_NOT_UNIQUE, findopt(), FN_REFLEN, GET_ASK_ADDR, GET_BOOL, GET_DISABLED, GET_NO_ARG, get_one_option(), GET_TYPE_MASK, getopt_compare_strings(), my_option::id, init_variables(), LINT_INIT, my_charset_latin1, my_getopt_error_reporter, my_getopt_print_errors, my_progname, my_strcasecmp, my_option::name, NO_ARG, OPT_ARG, OPT_DISABLE, OPT_ENABLE, OPT_LOOSE, OPT_MAXIMUM, OPT_SKIP, pos(), REQUIRED_ARG, setval(), special_opt_prefix, special_opt_prefix_lengths, strcend(), strlen(), value, my_option::value, my_option::var_type, and WARNING_LEVEL.
Referenced by get_options(), Configuration::init(), Options::load(), load_defaults(), main(), parse_args(), and readArguments().
00092 { 00093 uint opt_found, argvpos= 0, length, i; 00094 my_bool end_of_options= 0, must_be_var, set_maximum_value, 00095 option_is_loose; 00096 char **pos, **pos_end, *optend, *prev_found, 00097 *opt_str, key_name[FN_REFLEN]; 00098 const struct my_option *optp; 00099 gptr *value; 00100 int error; 00101 00102 LINT_INIT(opt_found); 00103 (*argc)--; /* Skip the program name */ 00104 (*argv)++; /* --- || ---- */ 00105 init_variables(longopts); 00106 00107 for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++) 00108 { 00109 char *cur_arg= *pos; 00110 if (cur_arg[0] == '-' && cur_arg[1] && !end_of_options) /* must be opt */ 00111 { 00112 char *argument= 0; 00113 must_be_var= 0; 00114 set_maximum_value= 0; 00115 option_is_loose= 0; 00116 00117 cur_arg++; /* skip '-' */ 00118 if (*cur_arg == '-' || *cur_arg == 'O') /* check for long option, */ 00119 { /* --set-variable, or -O */ 00120 if (*cur_arg == 'O') 00121 { 00122 must_be_var= 1; 00123 00124 if (!(*++cur_arg)) /* If not -Ovar=# */ 00125 { 00126 /* the argument must be in next argv */ 00127 if (!*++pos) 00128 { 00129 if (my_getopt_print_errors) 00130 my_getopt_error_reporter(ERROR_LEVEL, 00131 "%s: Option '-O' requires an argument\n", 00132 my_progname); 00133 return EXIT_ARGUMENT_REQUIRED; 00134 } 00135 cur_arg= *pos; 00136 (*argc)--; 00137 } 00138 } 00139 else if (!getopt_compare_strings(cur_arg, "-set-variable", 13)) 00140 { 00141 must_be_var= 1; 00142 if (cur_arg[13] == '=') 00143 { 00144 cur_arg+= 14; 00145 if (!*cur_arg) 00146 { 00147 if (my_getopt_print_errors) 00148 my_getopt_error_reporter(ERROR_LEVEL, 00149 "%s: Option '--set-variable' requires an argument\n", 00150 my_progname); 00151 return EXIT_ARGUMENT_REQUIRED; 00152 } 00153 } 00154 else if (cur_arg[14]) /* garbage, or another option. break out */ 00155 must_be_var= 0; 00156 else 00157 { 00158 /* the argument must be in next argv */ 00159 if (!*++pos) 00160 { 00161 if (my_getopt_print_errors) 00162 my_getopt_error_reporter(ERROR_LEVEL, 00163 "%s: Option '--set-variable' requires an argument\n", 00164 my_progname); 00165 return EXIT_ARGUMENT_REQUIRED; 00166 } 00167 cur_arg= *pos; 00168 (*argc)--; 00169 } 00170 } 00171 else if (!must_be_var) 00172 { 00173 if (!*++cur_arg) /* skip the double dash */ 00174 { 00175 /* '--' means end of options, look no further */ 00176 end_of_options= 1; 00177 (*argc)--; 00178 continue; 00179 } 00180 } 00181 opt_str= check_struct_option(cur_arg, key_name); 00182 optend= strcend(opt_str, '='); 00183 length= (uint) (optend - opt_str); 00184 if (*optend == '=') 00185 optend++; 00186 else 00187 optend= 0; 00188 00189 /* 00190 Find first the right option. Return error in case of an ambiguous, 00191 or unknown option 00192 */ 00193 optp= longopts; 00194 if (!(opt_found= findopt(opt_str, length, &optp, &prev_found))) 00195 { 00196 /* 00197 Didn't find any matching option. Let's see if someone called 00198 option with a special option prefix 00199 */ 00200 if (!must_be_var) 00201 { 00202 if (optend) 00203 must_be_var= 1; /* option is followed by an argument */ 00204 for (i= 0; special_opt_prefix[i]; i++) 00205 { 00206 if (!getopt_compare_strings(special_opt_prefix[i], opt_str, 00207 special_opt_prefix_lengths[i]) && 00208 (opt_str[special_opt_prefix_lengths[i]] == '-' || 00209 opt_str[special_opt_prefix_lengths[i]] == '_')) 00210 { 00211 /* 00212 We were called with a special prefix, we can reuse opt_found 00213 */ 00214 opt_str+= (special_opt_prefix_lengths[i] + 1); 00215 if (i == OPT_LOOSE) 00216 option_is_loose= 1; 00217 if ((opt_found= findopt(opt_str, length - 00218 (special_opt_prefix_lengths[i] + 1), 00219 &optp, &prev_found))) 00220 { 00221 if (opt_found > 1) 00222 { 00223 if (my_getopt_print_errors) 00224 my_getopt_error_reporter(ERROR_LEVEL, 00225 "%s: ambiguous option '--%s-%s' (--%s-%s)\n", 00226 my_progname, special_opt_prefix[i], 00227 cur_arg, special_opt_prefix[i], 00228 prev_found); 00229 return EXIT_AMBIGUOUS_OPTION; 00230 } 00231 switch (i) { 00232 case OPT_SKIP: 00233 case OPT_DISABLE: /* fall through */ 00234 /* 00235 double negation is actually enable again, 00236 for example: --skip-option=0 -> option = TRUE 00237 */ 00238 optend= (optend && *optend == '0' && !(*(optend + 1))) ? 00239 (char*) "1" : disabled_my_option; 00240 break; 00241 case OPT_ENABLE: 00242 optend= (optend && *optend == '0' && !(*(optend + 1))) ? 00243 disabled_my_option : (char*) "1"; 00244 break; 00245 case OPT_MAXIMUM: 00246 set_maximum_value= 1; 00247 must_be_var= 1; 00248 break; 00249 } 00250 break; /* break from the inner loop, main loop continues */ 00251 } 00252 } 00253 } 00254 } 00255 if (!opt_found) 00256 { 00257 if (must_be_var) 00258 { 00259 if (my_getopt_print_errors) 00260 my_getopt_error_reporter(option_is_loose ? 00261 WARNING_LEVEL : ERROR_LEVEL, 00262 "%s: unknown variable '%s'\n", 00263 my_progname, cur_arg); 00264 if (!option_is_loose) 00265 return EXIT_UNKNOWN_VARIABLE; 00266 } 00267 else 00268 { 00269 if (my_getopt_print_errors) 00270 my_getopt_error_reporter(option_is_loose ? 00271 WARNING_LEVEL : ERROR_LEVEL, 00272 "%s: unknown option '--%s'\n", 00273 my_progname, cur_arg); 00274 if (!option_is_loose) 00275 return EXIT_UNKNOWN_OPTION; 00276 } 00277 if (option_is_loose) 00278 { 00279 (*argc)--; 00280 continue; 00281 } 00282 } 00283 } 00284 if (opt_found > 1) 00285 { 00286 if (must_be_var) 00287 { 00288 if (my_getopt_print_errors) 00289 my_getopt_error_reporter(ERROR_LEVEL, 00290 "%s: variable prefix '%s' is not unique\n", 00291 my_progname, opt_str); 00292 return EXIT_VAR_PREFIX_NOT_UNIQUE; 00293 } 00294 else 00295 { 00296 if (my_getopt_print_errors) 00297 my_getopt_error_reporter(ERROR_LEVEL, 00298 "%s: ambiguous option '--%s' (%s, %s)\n", 00299 my_progname, opt_str, prev_found, 00300 optp->name); 00301 return EXIT_AMBIGUOUS_OPTION; 00302 } 00303 } 00304 if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED) 00305 { 00306 if (my_getopt_print_errors) 00307 fprintf(stderr, 00308 "%s: %s: Option '%s' used, but is disabled\n", my_progname, 00309 option_is_loose ? "WARNING" : "ERROR", opt_str); 00310 if (option_is_loose) 00311 { 00312 (*argc)--; 00313 continue; 00314 } 00315 return EXIT_OPTION_DISABLED; 00316 } 00317 if (must_be_var && (optp->var_type & GET_TYPE_MASK) == GET_NO_ARG) 00318 { 00319 if (my_getopt_print_errors) 00320 my_getopt_error_reporter(ERROR_LEVEL, 00321 "%s: option '%s' cannot take an argument\n", 00322 my_progname, optp->name); 00323 return EXIT_NO_ARGUMENT_ALLOWED; 00324 } 00325 value= optp->var_type & GET_ASK_ADDR ? 00326 (*getopt_get_addr)(key_name, (uint) strlen(key_name), optp) : optp->value; 00327 00328 if (optp->arg_type == NO_ARG) 00329 { 00330 if (optend && (optp->var_type & GET_TYPE_MASK) != GET_BOOL) 00331 { 00332 if (my_getopt_print_errors) 00333 my_getopt_error_reporter(ERROR_LEVEL, 00334 "%s: option '--%s' cannot take an argument\n", 00335 my_progname, optp->name); 00336 return EXIT_NO_ARGUMENT_ALLOWED; 00337 } 00338 if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL) 00339 { 00340 /* 00341 Set bool to 1 if no argument or if the user has used 00342 --enable-'option-name'. 00343 *optend was set to '0' if one used --disable-option 00344 */ 00345 (*argc)--; 00346 if (!optend || *optend == '1' || 00347 !my_strcasecmp(&my_charset_latin1, optend, "true")) 00348 *((my_bool*) value)= (my_bool) 1; 00349 else if (*optend == '0' || 00350 !my_strcasecmp(&my_charset_latin1, optend, "false")) 00351 *((my_bool*) value)= (my_bool) 0; 00352 else 00353 { 00354 my_getopt_error_reporter(WARNING_LEVEL, 00355 "%s: ignoring option '--%s' due to \ 00356 invalid value '%s'\n", 00357 my_progname, optp->name, optend); 00358 continue; 00359 } 00360 get_one_option(optp->id, optp, 00361 *((my_bool*) value) ? 00362 (char*) "1" : disabled_my_option); 00363 continue; 00364 } 00365 argument= optend; 00366 } 00367 else if (optp->arg_type == OPT_ARG && 00368 (optp->var_type & GET_TYPE_MASK) == GET_BOOL) 00369 { 00370 if (optend == disabled_my_option) 00371 *((my_bool*) value)= (my_bool) 0; 00372 else 00373 { 00374 if (!optend) /* No argument -> enable option */ 00375 *((my_bool*) value)= (my_bool) 1; 00376 else 00377 argument= optend; 00378 } 00379 } 00380 else if (optp->arg_type == REQUIRED_ARG && !optend) 00381 { 00382 /* Check if there are more arguments after this one */ 00383 if (!*++pos) 00384 { 00385 if (my_getopt_print_errors) 00386 my_getopt_error_reporter(ERROR_LEVEL, 00387 "%s: option '--%s' requires an argument\n", 00388 my_progname, optp->name); 00389 return EXIT_ARGUMENT_REQUIRED; 00390 } 00391 argument= *pos; 00392 (*argc)--; 00393 } 00394 else 00395 argument= optend; 00396 } 00397 else /* must be short option */ 00398 { 00399 for (optend= cur_arg; *optend; optend++) 00400 { 00401 opt_found= 0; 00402 for (optp= longopts; optp->id; optp++) 00403 { 00404 if (optp->id == (int) (uchar) *optend) 00405 { 00406 /* Option recognized. Find next what to do with it */ 00407 opt_found= 1; 00408 if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED) 00409 { 00410 if (my_getopt_print_errors) 00411 fprintf(stderr, 00412 "%s: ERROR: Option '-%c' used, but is disabled\n", 00413 my_progname, optp->id); 00414 return EXIT_OPTION_DISABLED; 00415 } 00416 if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL && 00417 optp->arg_type == NO_ARG) 00418 { 00419 *((my_bool*) optp->value)= (my_bool) 1; 00420 get_one_option(optp->id, optp, argument); 00421 continue; 00422 } 00423 else if (optp->arg_type == REQUIRED_ARG || 00424 optp->arg_type == OPT_ARG) 00425 { 00426 if (*(optend + 1)) 00427 { 00428 /* The rest of the option is option argument */ 00429 argument= optend + 1; 00430 /* This is in effect a jump out of the outer loop */ 00431 optend= (char*) " "; 00432 } 00433 else 00434 { 00435 if (optp->arg_type == OPT_ARG) 00436 { 00437 if (optp->var_type == GET_BOOL) 00438 *((my_bool*) optp->value)= (my_bool) 1; 00439 get_one_option(optp->id, optp, argument); 00440 continue; 00441 } 00442 /* Check if there are more arguments after this one */ 00443 if (!pos[1]) 00444 { 00445 if (my_getopt_print_errors) 00446 my_getopt_error_reporter(ERROR_LEVEL, 00447 "%s: option '-%c' requires an argument\n", 00448 my_progname, optp->id); 00449 return EXIT_ARGUMENT_REQUIRED; 00450 } 00451 argument= *++pos; 00452 (*argc)--; 00453 /* the other loop will break, because *optend + 1 == 0 */ 00454 } 00455 } 00456 if ((error= setval(optp, optp->value, argument, 00457 set_maximum_value))) 00458 { 00459 my_getopt_error_reporter(ERROR_LEVEL, 00460 "%s: Error while setting value '%s' to '%s'\n", 00461 my_progname, argument, optp->name); 00462 return error; 00463 } 00464 get_one_option(optp->id, optp, argument); 00465 break; 00466 } 00467 } 00468 if (!opt_found) 00469 { 00470 if (my_getopt_print_errors) 00471 my_getopt_error_reporter(ERROR_LEVEL, 00472 "%s: unknown option '-%c'\n", 00473 my_progname, *optend); 00474 return EXIT_UNKNOWN_OPTION; 00475 } 00476 } 00477 (*argc)--; /* option handled (short), decrease argument count */ 00478 continue; 00479 } 00480 if ((error= setval(optp, value, argument, set_maximum_value))) 00481 { 00482 my_getopt_error_reporter(ERROR_LEVEL, 00483 "%s: Error while setting value '%s' to '%s'\n", 00484 my_progname, argument, optp->name); 00485 return error; 00486 } 00487 get_one_option(optp->id, optp, argument); 00488 00489 (*argc)--; /* option handled (short or long), decrease argument count */ 00490 } 00491 else /* non-option found */ 00492 (*argv)[argvpos++]= cur_arg; 00493 } 00494 /* 00495 Destroy the first, already handled option, so that programs that look 00496 for arguments in 'argv', without checking 'argc', know when to stop. 00497 Items in argv, before the destroyed one, are all non-option -arguments 00498 to the program, yet to be (possibly) handled. 00499 */ 00500 (*argv)[argvpos]= 0; 00501 return 0; 00502 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void my_getopt_register_get_addr | ( | gptr *(*)(const char *, uint, const struct my_option *) | func_addr | ) |
Definition at line 83 of file my_getopt.c.
References getopt_get_addr.
Referenced by get_options().
00085 { 00086 getopt_get_addr= func_addr; 00087 }
Here is the caller graph for this function:

| void my_print_help | ( | const struct my_option * | options | ) |
Definition at line 848 of file my_getopt.c.
References my_option::arg_type, my_option::comment, comment, GET_BOOL, GET_NO_ARG, GET_STR, GET_STR_ALLOC, GET_TYPE_MASK, my_option::id, my_option::name, OPT_ARG, options(), strend(), strlen(), and my_option::var_type.
Referenced by get_one_option(), main(), and usage().
00849 { 00850 uint col, name_space= 22, comment_space= 57; 00851 const char *line_end; 00852 const struct my_option *optp; 00853 00854 for (optp= options; optp->id; optp++) 00855 { 00856 if (optp->id < 256) 00857 { 00858 printf(" -%c%s", optp->id, strlen(optp->name) ? ", " : " "); 00859 col= 6; 00860 } 00861 else 00862 { 00863 printf(" "); 00864 col= 2; 00865 } 00866 if (strlen(optp->name)) 00867 { 00868 printf("--%s", optp->name); 00869 col+= 2 + (uint) strlen(optp->name); 00870 if ((optp->var_type & GET_TYPE_MASK) == GET_STR || 00871 (optp->var_type & GET_TYPE_MASK) == GET_STR_ALLOC) 00872 { 00873 printf("%s=name%s ", optp->arg_type == OPT_ARG ? "[" : "", 00874 optp->arg_type == OPT_ARG ? "]" : ""); 00875 col+= (optp->arg_type == OPT_ARG) ? 8 : 6; 00876 } 00877 else if ((optp->var_type & GET_TYPE_MASK) == GET_NO_ARG || 00878 (optp->var_type & GET_TYPE_MASK) == GET_BOOL) 00879 { 00880 putchar(' '); 00881 col++; 00882 } 00883 else 00884 { 00885 printf("%s=#%s ", optp->arg_type == OPT_ARG ? "[" : "", 00886 optp->arg_type == OPT_ARG ? "]" : ""); 00887 col+= (optp->arg_type == OPT_ARG) ? 5 : 3; 00888 } 00889 if (col > name_space && optp->comment && *optp->comment) 00890 { 00891 putchar('\n'); 00892 col= 0; 00893 } 00894 } 00895 for (; col < name_space; col++) 00896 putchar(' '); 00897 if (optp->comment && *optp->comment) 00898 { 00899 const char *comment= optp->comment, *end= strend(comment); 00900 00901 while ((uint) (end - comment) > comment_space) 00902 { 00903 for (line_end= comment + comment_space; *line_end != ' '; line_end--); 00904 for (; comment != line_end; comment++) 00905 putchar(*comment); 00906 comment++; /* skip the space, as a newline will take it's place now */ 00907 putchar('\n'); 00908 for (col= 0; col < name_space; col++) 00909 putchar(' '); 00910 } 00911 printf("%s", comment); 00912 } 00913 putchar('\n'); 00914 } 00915 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void my_print_variables | ( | const struct my_option * | options | ) |
Definition at line 924 of file my_getopt.c.
References GET_ASK_ADDR, GET_BOOL, GET_INT, GET_LL, GET_LONG, GET_STR, GET_STR_ALLOC, GET_TYPE_MASK, GET_UINT, GET_ULL, GET_ULONG, getopt_get_addr, my_option::id, llstr(), longlong2str, my_option::name, options(), strlen(), value, my_option::value, and my_option::var_type.
Referenced by main(), and usage().
00925 { 00926 uint name_space= 34, length; 00927 char buff[255]; 00928 const struct my_option *optp; 00929 00930 printf("\nVariables (--variable-name=value)\n"); 00931 printf("and boolean options {FALSE|TRUE} Value (after reading options)\n"); 00932 printf("--------------------------------- -----------------------------\n"); 00933 for (optp= options; optp->id; optp++) 00934 { 00935 gptr *value= (optp->var_type & GET_ASK_ADDR ? 00936 (*getopt_get_addr)("", 0, optp) : optp->value); 00937 if (value) 00938 { 00939 printf("%s", optp->name); 00940 length= (uint) strlen(optp->name); 00941 for (; length < name_space; length++) 00942 putchar(' '); 00943 switch ((optp->var_type & GET_TYPE_MASK)) { 00944 case GET_STR: 00945 case GET_STR_ALLOC: /* fall through */ 00946 printf("%s\n", *((char**) value) ? *((char**) value) : 00947 "(No default value)"); 00948 break; 00949 case GET_BOOL: 00950 printf("%s\n", *((my_bool*) value) ? "TRUE" : "FALSE"); 00951 break; 00952 case GET_INT: 00953 printf("%d\n", *((int*) value)); 00954 break; 00955 case GET_UINT: 00956 printf("%d\n", *((uint*) value)); 00957 break; 00958 case GET_LONG: 00959 printf("%lu\n", *((long*) value)); 00960 break; 00961 case GET_ULONG: 00962 printf("%lu\n", *((ulong*) value)); 00963 break; 00964 case GET_LL: 00965 printf("%s\n", llstr(*((longlong*) value), buff)); 00966 break; 00967 case GET_ULL: 00968 longlong2str(*((ulonglong*) value), buff, 10); 00969 printf("%s\n", buff); 00970 break; 00971 default: 00972 printf("(Disabled)\n"); 00973 break; 00974 } 00975 } 00976 } 00977 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* disabled_my_option |
1.4.7

