~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Elan Ruusamäe
  • Date: 2008-12-02 20:06:31 UTC
  • mfrom: (637 drizzle)
  • mto: (641.3.10 devel)
  • mto: This revision was merged to the branch mainline in revision 649.
  • Revision ID: glen@haarber.alkohol.ee-20081202200631-f6h3vbnjaojvk3uq
- merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1250
1250
 
1251
1251
 
1252
1252
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
1253
 
RETSIGTYPE window_resize(int sig __attribute__((unused)))
 
1253
RETSIGTYPE window_resize(int)
1254
1254
{
1255
1255
  struct winsize window_size;
1256
1256
 
1458
1458
 
1459
1459
 
1460
1460
extern "C" bool
1461
 
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
1462
 
               char *argument)
 
1461
get_one_option(int optid, const struct my_option *, char *argument)
1463
1462
{
1464
1463
  switch(optid) {
1465
1464
  case OPT_CHARSETS_DIR:
1466
 
    strmake(drizzle_charsets_dir, argument, sizeof(drizzle_charsets_dir) - 1);
 
1465
    strncpy(drizzle_charsets_dir, argument, sizeof(drizzle_charsets_dir) - 1);
1467
1466
    charsets_dir = drizzle_charsets_dir;
1468
1467
    break;
1469
1468
  case  OPT_DEFAULT_CHARSET:
1479
1478
      /* Check that delimiter does not contain a backslash */
1480
1479
      if (!strstr(argument, "\\"))
1481
1480
      {
1482
 
        strmake(delimiter, argument, sizeof(delimiter) - 1);
 
1481
        strncpy(delimiter, argument, sizeof(delimiter) - 1);
1483
1482
      }
1484
1483
      else
1485
1484
      {
1517
1516
      if (argument && strlen(argument))
1518
1517
      {
1519
1518
        default_pager_set= 1;
1520
 
        strmake(pager, argument, sizeof(pager) - 1);
 
1519
        strncpy(pager, argument, sizeof(pager) - 1);
1521
1520
        my_stpcpy(default_pager, pager);
1522
1521
      }
1523
1522
      else if (default_pager_set)
1586
1585
    status.add_to_history= 0;
1587
1586
    set_if_bigger(opt_silent,1);                         // more silent
1588
1587
    break;
1589
 
    break;
1590
1588
  case 'V':
1591
1589
    usage(1);
1592
1590
    exit(0);
2082
2080
  on command names if this is the first word in the line, or on filenames
2083
2081
  if not.
2084
2082
*/
2085
 
static char *no_completion(const char * a __attribute__((unused)),
2086
 
                           int b __attribute__((unused)))
 
2083
static char *no_completion(const char *, int)
2087
2084
{
2088
2085
  /* No filename completion */
2089
2086
  return 0;
2178
2175
  entire line in case we want to do some simple parsing.  Return the
2179
2176
  array of matches, or NULL if there aren't any.
2180
2177
*/
2181
 
char **mysql_completion (const char *text,
2182
 
                        int start __attribute__((unused)),
2183
 
                        int end __attribute__((unused)))
 
2178
char **mysql_completion (const char *text, int, int)
2184
2179
{
2185
2180
  if (!status.batch && !quick)
2186
2181
    return rl_completion_matches(text, new_command_generator);
2493
2488
}
2494
2489
 
2495
2490
 
2496
 
static int com_server_help(string *buffer,
2497
 
                           const char *line __attribute__((unused)),
2498
 
                           const char *help_arg)
 
2491
static int com_server_help(string *buffer, const char *, const char *help_arg)
2499
2492
{
2500
2493
  DRIZZLE_ROW cur;
2501
2494
  const char *server_cmd= buffer->c_str();
2588
2581
}
2589
2582
 
2590
2583
static int
2591
 
com_help(string *buffer __attribute__((unused)),
2592
 
         const char *line __attribute__((unused)))
 
2584
com_help(string *buffer, const char *line)
2593
2585
{
2594
2586
  register int i, j;
2595
2587
  const char *help_arg= strchr(line,' ');
2620
2612
 
2621
2613
 
2622
2614
static int
2623
 
com_clear(string *buffer,
2624
 
          const char *line __attribute__((unused)))
 
2615
com_clear(string *buffer, const char *)
2625
2616
{
2626
2617
  if (status.add_to_history)
2627
2618
    fix_history(buffer);
2637
2628
  1  if fatal error
2638
2629
*/
2639
2630
static int
2640
 
com_go(string *buffer,
2641
 
       const char *line __attribute__((unused)))
 
2631
com_go(string *buffer, const char *)
2642
2632
{
2643
2633
  char          buff[200]; /* about 110 chars used so far */
2644
2634
  char          time_buff[52+3+1]; /* time max + space&parens + NUL */
2822
2812
    return;
2823
2813
  }
2824
2814
  OUTFILE = new_outfile;
2825
 
  strmake(outfile, file_name, FN_REFLEN-1);
 
2815
  strncpy(outfile, file_name, FN_REFLEN-1);
2826
2816
  tee_fprintf(stdout, "Logging to file '%s'\n", file_name);
2827
2817
  opt_outfile= 1;
2828
2818
  return;
3280
3270
}
3281
3271
 
3282
3272
static int
3283
 
com_tee(string *buffer __attribute__((unused)), const char *line )
 
3273
com_tee(string *, const char *line )
3284
3274
{
3285
3275
  char file_name[FN_REFLEN], *end;
3286
3276
  const char *param;
3308
3298
  /* eliminate the spaces before the parameters */
3309
3299
  while (my_isspace(charset_info,*param))
3310
3300
    param++;
3311
 
  end= strmake(file_name, param, sizeof(file_name) - 1);
 
3301
  strncpy(file_name, param, sizeof(file_name) - 1);
 
3302
  end= file_name + strlen(file_name);
3312
3303
  /* remove end space from command line */
3313
3304
  while (end > file_name && (my_isspace(charset_info,end[-1]) ||
3314
3305
                             my_iscntrl(charset_info,end[-1])))
3325
3316
 
3326
3317
 
3327
3318
static int
3328
 
com_notee(string *buffer __attribute__((unused)),
3329
 
          const char *line __attribute__((unused)))
 
3319
com_notee(string *, const char *)
3330
3320
{
3331
3321
  if (opt_outfile)
3332
3322
    end_tee();
3339
3329
*/
3340
3330
 
3341
3331
static int
3342
 
com_pager(string *buffer __attribute__((unused)),
3343
 
          const char *line __attribute__((unused)))
 
3332
com_pager(string *, const char *line)
3344
3333
{
3345
3334
  char pager_name[FN_REFLEN], *end;
3346
3335
  const char *param;
3369
3358
  }
3370
3359
  else
3371
3360
  {
3372
 
    end= strmake(pager_name, param, sizeof(pager_name)-1);
 
3361
    end= strncpy(pager_name, param, sizeof(pager_name)-1);
 
3362
    end+= strlen(pager_name);
3373
3363
    while (end > pager_name && (my_isspace(charset_info,end[-1]) ||
3374
3364
                                my_iscntrl(charset_info,end[-1])))
3375
3365
      end--;
3384
3374
 
3385
3375
 
3386
3376
static int
3387
 
com_nopager(string *buffer __attribute__((unused)),
3388
 
            const char *line __attribute__((unused)))
 
3377
com_nopager(string *, const char *)
3389
3378
{
3390
3379
  my_stpcpy(pager, "stdout");
3391
3380
  opt_nopager=1;
3397
3386
/* If arg is given, exit without errors. This happens on command 'quit' */
3398
3387
 
3399
3388
static int
3400
 
com_quit(string *buffer __attribute__((unused)),
3401
 
         const char *line __attribute__((unused)))
 
3389
com_quit(string *, const char *)
3402
3390
{
3403
3391
  /* let the screen auto close on a normal shutdown */
3404
3392
  status.exit_status=0;
3406
3394
}
3407
3395
 
3408
3396
static int
3409
 
com_rehash(string *buffer __attribute__((unused)),
3410
 
           const char *line __attribute__((unused)))
 
3397
com_rehash(string *, const char *)
3411
3398
{
3412
3399
  build_completion_hash(1, 0);
3413
3400
  return 0;
3416
3403
 
3417
3404
 
3418
3405
static int
3419
 
com_print(string *buffer,const char *line __attribute__((unused)))
 
3406
com_print(string *buffer,const char *)
3420
3407
{
3421
3408
  tee_puts("--------------", stdout);
3422
3409
  (void) tee_fputs(buffer->c_str(), stdout);
3443
3430
      Two null bytes are needed in the end of buff to allow
3444
3431
      get_arg to find end of string the second time it's called.
3445
3432
    */
3446
 
    tmp= strmake(buff, line, sizeof(buff)-2);
 
3433
    tmp= strncpy(buff, line, sizeof(buff)-2);
3447
3434
#ifdef EXTRA_DEBUG
3448
3435
    tmp[1]= 0;
3449
3436
#endif
3485
3472
}
3486
3473
 
3487
3474
 
3488
 
static int com_source(string *buffer __attribute__((unused)), const char *line)
 
3475
static int com_source(string *, const char *line)
3489
3476
{
3490
3477
  char source_name[FN_REFLEN], *end;
3491
3478
  const char *param;
3502
3489
                    INFO_ERROR, 0,0);
3503
3490
  while (my_isspace(charset_info,*param))
3504
3491
    param++;
3505
 
  end=strmake(source_name,param,sizeof(source_name)-1);
 
3492
  end= strncpy(source_name,param,sizeof(source_name)-1);
 
3493
  end+= strlen(source_name);
3506
3494
  while (end > source_name && (my_isspace(charset_info,end[-1]) ||
3507
3495
                               my_iscntrl(charset_info,end[-1])))
3508
3496
    end--;
3544
3532
 
3545
3533
/* ARGSUSED */
3546
3534
static int
3547
 
com_delimiter(string *buffer __attribute__((unused)), const char *line)
 
3535
com_delimiter(string *, const char *line)
3548
3536
{
3549
3537
  char buff[256], *tmp;
3550
3538
 
3551
 
  strmake(buff, line, sizeof(buff) - 1);
 
3539
  strncpy(buff, line, sizeof(buff) - 1);
3552
3540
  tmp= get_arg(buff, 0);
3553
3541
 
3554
3542
  if (!tmp || !*tmp)
3566
3554
      return 0;
3567
3555
    }
3568
3556
  }
3569
 
  strmake(delimiter, tmp, sizeof(delimiter) - 1);
 
3557
  strncpy(delimiter, tmp, sizeof(delimiter) - 1);
3570
3558
  delimiter_length= (int)strlen(delimiter);
3571
3559
  delimiter_str= delimiter;
3572
3560
  return 0;
3574
3562
 
3575
3563
/* ARGSUSED */
3576
3564
static int
3577
 
com_use(string *buffer __attribute__((unused)), const char *line)
 
3565
com_use(string *, const char *line)
3578
3566
{
3579
3567
  char *tmp, buff[FN_REFLEN + 1];
3580
3568
  int select_db;
3581
3569
 
3582
3570
  memset(buff, 0, sizeof(buff));
3583
 
  strmake(buff, line, sizeof(buff) - 1);
 
3571
  strncpy(buff, line, sizeof(buff) - 1);
3584
3572
  tmp= get_arg(buff, 0);
3585
3573
  if (!tmp || !*tmp)
3586
3574
  {
3646
3634
}
3647
3635
 
3648
3636
static int
3649
 
com_warnings(string *buffer __attribute__((unused)),
3650
 
             const char *line __attribute__((unused)))
 
3637
com_warnings(string *, const char *)
3651
3638
{
3652
3639
  show_warnings = 1;
3653
3640
  put_info("Show warnings enabled.",INFO_INFO, 0, 0);
3655
3642
}
3656
3643
 
3657
3644
static int
3658
 
com_nowarnings(string *buffer __attribute__((unused)),
3659
 
               const char *line __attribute__((unused)))
 
3645
com_nowarnings(string *, const char *)
3660
3646
{
3661
3647
  show_warnings = 0;
3662
3648
  put_info("Show warnings disabled.",INFO_INFO, 0, 0);
3778
3764
 
3779
3765
 
3780
3766
static int
3781
 
com_status(string *buffer __attribute__((unused)),
3782
 
           const char *line __attribute__((unused)))
 
3767
com_status(string *, const char *)
3783
3768
{
3784
3769
  char buff[40];
3785
3770
  uint64_t id;
4192
4177
        break;
4193
4178
      case PROMPT_CHAR:
4194
4179
        {
4195
 
          char c= PROMPT_CHAR;
4196
 
          processed_prompt->append(&c, 1);
 
4180
          processed_prompt->append(PROMPT_CHAR, 1);
4197
4181
        }
4198
4182
        break;
4199
4183
      case 'n':
4200
4184
        {
4201
 
          char c= '\n';
4202
 
          processed_prompt->append(&c, 1);
 
4185
          processed_prompt->append('\n', 1);
4203
4186
        }
4204
4187
        break;
4205
4188
      case ' ':
4206
4189
      case '_':
4207
4190
        {
4208
 
          char c= ' ';
4209
 
          processed_prompt->append(&c, 1);
 
4191
          processed_prompt->append(' ', 1);
4210
4192
        }
4211
4193
        break;
4212
4194
      case 'R':
4304
4286
  }
4305
4287
}
4306
4288
 
4307
 
static int com_prompt(string *buffer __attribute__((unused)),
4308
 
                      const char *line)
 
4289
static int com_prompt(string *, const char *line)
4309
4290
{
4310
4291
  const char *ptr=strchr(line, ' ');
4311
4292
  prompt_counter = 0;