~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/client.c

Removed strcend.

Show diffs side-by-side

added added

removed removed

Lines of Context:
572
572
    {
573
573
      if (option[0][0] == '-' && option[0][1] == '-')
574
574
      {
575
 
  char *end=strcend(*option,'=');
576
 
  char *opt_arg=0;
577
 
  if (*end)
578
 
  {
579
 
    opt_arg=end+1;
580
 
    *end=0;        /* Remove '=' */
581
 
  }
582
 
  /* Change all '_' in variable name to '-' */
583
 
  for (end= *option ; *(end= strcend(end,'_')) ; )
584
 
    *end= '-';
585
 
  switch (find_type(*option+2,&option_types,2)) {
586
 
  case 1:        /* port */
587
 
    if (opt_arg)
588
 
      options->port=atoi(opt_arg);
589
 
    break;
590
 
  case 2:        /* socket */
591
 
    if (opt_arg)
592
 
    {
593
 
      my_free(options->unix_socket,MYF(MY_ALLOW_ZERO_PTR));
594
 
      options->unix_socket=my_strdup(opt_arg,MYF(MY_WME));
595
 
    }
596
 
    break;
597
 
  case 3:        /* compress */
598
 
    options->compress=1;
599
 
    options->client_flag|= CLIENT_COMPRESS;
600
 
    break;
601
 
  case 4:        /* password */
602
 
    if (opt_arg)
603
 
    {
604
 
      my_free(options->password,MYF(MY_ALLOW_ZERO_PTR));
605
 
      options->password=my_strdup(opt_arg,MYF(MY_WME));
606
 
    }
607
 
    break;
608
 
  case 20:      /* connect_timeout */
609
 
  case 6:        /* timeout */
610
 
    if (opt_arg)
611
 
      options->connect_timeout=atoi(opt_arg);
612
 
    break;
613
 
  case 7:        /* user */
614
 
    if (opt_arg)
615
 
    {
616
 
      my_free(options->user,MYF(MY_ALLOW_ZERO_PTR));
617
 
      options->user=my_strdup(opt_arg,MYF(MY_WME));
618
 
    }
619
 
    break;
620
 
  case 8:        /* init-command */
621
 
    add_init_command(options,opt_arg);
622
 
    break;
623
 
  case 9:        /* host */
624
 
    if (opt_arg)
625
 
    {
626
 
      my_free(options->host,MYF(MY_ALLOW_ZERO_PTR));
627
 
      options->host=my_strdup(opt_arg,MYF(MY_WME));
628
 
    }
629
 
    break;
630
 
  case 10:      /* database */
631
 
    if (opt_arg)
632
 
    {
633
 
      my_free(options->db,MYF(MY_ALLOW_ZERO_PTR));
634
 
      options->db=my_strdup(opt_arg,MYF(MY_WME));
635
 
    }
636
 
    break;
637
 
  case 12:      /* return-found-rows */
638
 
    options->client_flag|=CLIENT_FOUND_ROWS;
639
 
    break;
640
 
  case 13:        /* Ignore SSL options */
641
 
  case 14:
642
 
  case 15:
643
 
  case 16:
 
575
        char *end=strrchr(*option,'=');
 
576
        char *opt_arg=0;
 
577
        if (end != NULL)
 
578
        {
 
579
          opt_arg=end+1;
 
580
          *end=0;        /* Remove '=' */
 
581
        }
 
582
        /* Change all '_' in variable name to '-' */
 
583
        for (end= *option ; *(end= strrchr(end,'_')) ; )
 
584
          *end= '-';
 
585
        switch (find_type(*option+2,&option_types,2)) {
 
586
        case 1:        /* port */
 
587
          if (opt_arg)
 
588
            options->port=atoi(opt_arg);
 
589
          break;
 
590
        case 2:        /* socket */
 
591
          if (opt_arg)
 
592
          {
 
593
            my_free(options->unix_socket,MYF(MY_ALLOW_ZERO_PTR));
 
594
            options->unix_socket=my_strdup(opt_arg,MYF(MY_WME));
 
595
          }
 
596
          break;
 
597
        case 3:        /* compress */
 
598
          options->compress=1;
 
599
          options->client_flag|= CLIENT_COMPRESS;
 
600
          break;
 
601
        case 4:        /* password */
 
602
          if (opt_arg)
 
603
          {
 
604
            my_free(options->password,MYF(MY_ALLOW_ZERO_PTR));
 
605
            options->password=my_strdup(opt_arg,MYF(MY_WME));
 
606
          }
 
607
          break;
 
608
        case 20:      /* connect_timeout */
 
609
        case 6:        /* timeout */
 
610
          if (opt_arg)
 
611
            options->connect_timeout=atoi(opt_arg);
 
612
          break;
 
613
        case 7:        /* user */
 
614
          if (opt_arg)
 
615
          {
 
616
            my_free(options->user,MYF(MY_ALLOW_ZERO_PTR));
 
617
            options->user=my_strdup(opt_arg,MYF(MY_WME));
 
618
          }
 
619
          break;
 
620
        case 8:        /* init-command */
 
621
          add_init_command(options,opt_arg);
 
622
          break;
 
623
        case 9:        /* host */
 
624
          if (opt_arg)
 
625
          {
 
626
            my_free(options->host,MYF(MY_ALLOW_ZERO_PTR));
 
627
            options->host=my_strdup(opt_arg,MYF(MY_WME));
 
628
          }
 
629
          break;
 
630
        case 10:      /* database */
 
631
          if (opt_arg)
 
632
          {
 
633
            my_free(options->db,MYF(MY_ALLOW_ZERO_PTR));
 
634
            options->db=my_strdup(opt_arg,MYF(MY_WME));
 
635
          }
 
636
          break;
 
637
        case 12:      /* return-found-rows */
 
638
          options->client_flag|=CLIENT_FOUND_ROWS;
 
639
          break;
 
640
        case 13:        /* Ignore SSL options */
 
641
        case 14:
 
642
        case 15:
 
643
        case 16:
644
644
        case 23:
645
 
    break;
646
 
  case 17:      /* charset-lib */
647
 
    my_free(options->charset_dir,MYF(MY_ALLOW_ZERO_PTR));
 
645
          break;
 
646
        case 17:      /* charset-lib */
 
647
          my_free(options->charset_dir,MYF(MY_ALLOW_ZERO_PTR));
648
648
          options->charset_dir = my_strdup(opt_arg, MYF(MY_WME));
649
 
    break;
650
 
  case 18:
651
 
    my_free(options->charset_name,MYF(MY_ALLOW_ZERO_PTR));
 
649
          break;
 
650
        case 18:
 
651
          my_free(options->charset_name,MYF(MY_ALLOW_ZERO_PTR));
652
652
          options->charset_name = my_strdup(opt_arg, MYF(MY_WME));
653
 
    break;
654
 
  case 19:        /* Interactive-timeout */
655
 
    options->client_flag|= CLIENT_INTERACTIVE;
656
 
    break;
657
 
  case 21:
658
 
    if (!opt_arg || atoi(opt_arg) != 0)
659
 
      options->client_flag|= CLIENT_LOCAL_FILES;
660
 
    else
661
 
      options->client_flag&= ~CLIENT_LOCAL_FILES;
662
 
    break;
663
 
  case 22:
664
 
    options->client_flag&= ~CLIENT_LOCAL_FILES;
665
 
          break;
666
 
  case 24: /* max-allowed-packet */
 
653
          break;
 
654
        case 19:        /* Interactive-timeout */
 
655
          options->client_flag|= CLIENT_INTERACTIVE;
 
656
          break;
 
657
        case 21:
 
658
          if (!opt_arg || atoi(opt_arg) != 0)
 
659
            options->client_flag|= CLIENT_LOCAL_FILES;
 
660
          else
 
661
            options->client_flag&= ~CLIENT_LOCAL_FILES;
 
662
          break;
 
663
        case 22:
 
664
          options->client_flag&= ~CLIENT_LOCAL_FILES;
 
665
          break;
 
666
        case 24: /* max-allowed-packet */
667
667
          if (opt_arg)
668
 
      options->max_allowed_packet= atoi(opt_arg);
669
 
    break;
 
668
            options->max_allowed_packet= atoi(opt_arg);
 
669
          break;
670
670
        case 25: /* protocol */
671
671
          if ((options->protocol= find_type(opt_arg,
672
 
              &sql_protocol_typelib,0)) <= 0)
 
672
                                            &sql_protocol_typelib,0)) <= 0)
673
673
          {
674
674
            fprintf(stderr, "Unknown option to protocol: %s\n", opt_arg);
675
675
            exit(1);
676
676
          }
677
677
          break;
678
 
  case 27: /* multi-results */
679
 
    options->client_flag|= CLIENT_MULTI_RESULTS;
680
 
    break;
681
 
  case 28: /* multi-statements */
682
 
  case 29: /* multi-queries */
683
 
    options->client_flag|= CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS;
684
 
    break;
 
678
        case 27: /* multi-results */
 
679
          options->client_flag|= CLIENT_MULTI_RESULTS;
 
680
          break;
 
681
        case 28: /* multi-statements */
 
682
        case 29: /* multi-queries */
 
683
          options->client_flag|= CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS;
 
684
          break;
685
685
        case 30: /* secure-auth */
686
686
          options->secure_auth= true;
687
687
          break;
688
688
        case 31: /* report-data-truncation */
689
689
          options->report_data_truncation= opt_arg ? test(atoi(opt_arg)) : 1;
690
690
          break;
691
 
  default:
 
691
        default:
692
692
          break;
693
 
  }
 
693
        }
694
694
      }
695
695
    }
696
696
  }