~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_getopt.c

  • Committer: Brian Aker
  • Date: 2008-07-13 06:35:46 UTC
  • Revision ID: brian@tangent.org-20080713063546-w1fzi89wzvf6o517
Bool cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
static void fini_one_value(const struct my_option *option, char **variable,
42
42
                           longlong value);
43
43
static int setval(const struct my_option *opts, char* *value, char *argument,
44
 
                  my_bool set_maximum_value);
 
44
                  bool set_maximum_value);
45
45
static char *check_struct_option(char *cur_arg, char *key_name);
46
46
 
47
47
/*
63
63
   it by itself
64
64
*/
65
65
 
66
 
my_bool my_getopt_print_errors= 1;
 
66
bool my_getopt_print_errors= 1;
67
67
 
68
68
/* 
69
69
   This is a flag that can be set in client programs. 1 means that
70
70
   my_getopt will skip over options it does not know how to handle.
71
71
*/
72
72
 
73
 
my_bool my_getopt_skip_unknown= 0;
 
73
bool my_getopt_skip_unknown= 0;
74
74
 
75
75
static void default_reporter(enum loglevel level,
76
76
                             const char *format, ...)
110
110
                   my_get_one_option get_one_option)
111
111
{
112
112
  uint opt_found, argvpos= 0, length;
113
 
  my_bool end_of_options= 0, must_be_var, set_maximum_value,
 
113
  bool end_of_options= 0, must_be_var, set_maximum_value,
114
114
          option_is_loose;
115
115
  char **pos, **pos_end, *optend, *prev_found=NULL,
116
116
       *opt_str, key_name[FN_REFLEN];
380
380
            (*argc)--;
381
381
            if (!optend || *optend == '1' ||
382
382
                !my_strcasecmp(&my_charset_latin1, optend, "true"))
383
 
              *((my_bool*) value)= (my_bool) 1;
 
383
              *((bool*) value)= (bool) 1;
384
384
            else if (*optend == '0' ||
385
385
                     !my_strcasecmp(&my_charset_latin1, optend, "false"))
386
 
              *((my_bool*) value)= (my_bool) 0;
 
386
              *((bool*) value)= (bool) 0;
387
387
            else
388
388
            {
389
389
              my_getopt_error_reporter(WARNING_LEVEL,
393
393
              continue;
394
394
            }
395
395
            get_one_option(optp->id, optp,
396
 
                           *((my_bool*) value) ?
 
396
                           *((bool*) value) ?
397
397
                           (char*) "1" : disabled_my_option);
398
398
            continue;
399
399
          }
403
403
                 (optp->var_type & GET_TYPE_MASK) == GET_BOOL)
404
404
        {
405
405
          if (optend == disabled_my_option)
406
 
            *((my_bool*) value)= (my_bool) 0;
 
406
            *((bool*) value)= (bool) 0;
407
407
          else
408
408
          {
409
409
            if (!optend) /* No argument -> enable option */
410
 
              *((my_bool*) value)= (my_bool) 1;
 
410
              *((bool*) value)= (bool) 1;
411
411
            else
412
412
              argument= optend;
413
413
          }
451
451
              if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL &&
452
452
                  optp->arg_type == NO_ARG)
453
453
              {
454
 
                *((my_bool*) optp->value)= (my_bool) 1;
 
454
                *((bool*) optp->value)= (bool) 1;
455
455
                get_one_option(optp->id, optp, argument);
456
456
                continue;
457
457
              }
470
470
                  if (optp->arg_type == OPT_ARG)
471
471
                  {
472
472
                    if (optp->var_type == GET_BOOL)
473
 
                      *((my_bool*) optp->value)= (my_bool) 1;
 
473
                      *((bool*) optp->value)= (bool) 1;
474
474
                    get_one_option(optp->id, optp, argument);
475
475
                    continue;
476
476
                  }
587
587
*/
588
588
 
589
589
static int setval(const struct my_option *opts, char* *value, char *argument,
590
 
                  my_bool set_maximum_value)
 
590
                  bool set_maximum_value)
591
591
{
592
592
  int err= 0;
593
593
 
601
601
 
602
602
    switch ((opts->var_type & GET_TYPE_MASK)) {
603
603
    case GET_BOOL: /* If argument differs from 0, enable option, else disable */
604
 
      *((my_bool*) result_pos)= (my_bool) atoi(argument) != 0;
 
604
      *((bool*) result_pos)= (bool) atoi(argument) != 0;
605
605
      break;
606
606
    case GET_INT:
607
607
      *((int*) result_pos)= (int) getopt_ll(argument, opts, &err);
714
714
  2.) Returns -1 if strings differ, 0 if they are equal
715
715
*/
716
716
 
717
 
my_bool getopt_compare_strings(register const char *s, register const char *t,
 
717
bool getopt_compare_strings(register const char *s, register const char *t,
718
718
                               uint length)
719
719
{
720
720
  char const *end= s + length;
790
790
*/
791
791
 
792
792
longlong getopt_ll_limit_value(longlong num, const struct my_option *optp,
793
 
                               my_bool *fix)
 
793
                               bool *fix)
794
794
{
795
795
  longlong old= num;
796
 
  my_bool adjusted= FALSE;
 
796
  bool adjusted= FALSE;
797
797
  char buf1[255], buf2[255];
798
798
  ulonglong block_size= (optp->block_size ? (ulonglong) optp->block_size : 1L);
799
799
 
859
859
 
860
860
 
861
861
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
862
 
                                 my_bool *fix)
 
862
                                 bool *fix)
863
863
{
864
 
  my_bool adjusted= FALSE;
 
864
  bool adjusted= FALSE;
865
865
  ulonglong old= num;
866
866
  char buf1[255], buf2[255];
867
867
 
963
963
  DBUG_ENTER("init_one_value");
964
964
  switch ((option->var_type & GET_TYPE_MASK)) {
965
965
  case GET_BOOL:
966
 
    *((my_bool*) variable)= (my_bool) value;
 
966
    *((bool*) variable)= (bool) value;
967
967
    break;
968
968
  case GET_INT:
969
969
    *((int*) variable)= (int) value;
1221
1221
               "(No default value)");
1222
1222
        break;
1223
1223
      case GET_BOOL:
1224
 
        printf("%s\n", *((my_bool*) value) ? "TRUE" : "FALSE");
 
1224
        printf("%s\n", *((bool*) value) ? "TRUE" : "FALSE");
1225
1225
        break;
1226
1226
      case GET_INT:
1227
1227
        printf("%d\n", *((int*) value));