~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/default.cc

  • Committer: Brian Aker
  • Date: 2010-11-08 18:24:58 UTC
  • mto: (1921.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 1916.
  • Revision ID: brian@tangent.org-20101108182458-twv4hyix43ojno80
Merge in changes such that lock is now broken out into its own directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
/****************************************************************************
17
17
 Add all options from files named "group".cnf from the default_directories
181
181
    TYPELIB *group= ctx->group;
182
182
 
183
183
    if (!(extra_groups=
184
 
          (const char**)alloc_root(ctx->alloc,
 
184
          (const char**)ctx->alloc->alloc_root(
185
185
                                   (2*group->count+1)*sizeof(char*))))
186
186
      goto err;
187
187
 
191
191
      extra_groups[i]= group->type_names[i]; /** copy group */
192
192
 
193
193
      len= strlen(extra_groups[i]);
194
 
      if (!(ptr= (char *)alloc_root(ctx->alloc, len+instance_len+1)))
 
194
      if (!(ptr= (char *)ctx->alloc->alloc_root( len+instance_len+1)))
195
195
        goto err;
196
196
 
197
197
      extra_groups[i+group->count]= ptr;
289
289
 
290
290
  if (find_type((char *)group_name, ctx->group, 3))
291
291
  {
292
 
    if (!(tmp= (char *)alloc_root(ctx->alloc, strlen(option) + 1)))
 
292
    if (!(tmp= (char *)ctx->alloc->alloc_root(strlen(option) + 1)))
293
293
      return 1;
294
294
    if (insert_dynamic(ctx->args, (unsigned char*) &tmp))
295
295
      return 1;
399
399
{
400
400
  DYNAMIC_ARRAY args;
401
401
  TYPELIB group;
402
 
  bool found_print_defaults= 0;
403
402
  uint32_t args_used= 0;
404
403
  int error= 0;
405
 
  memory::Root alloc;
 
404
  memory::Root alloc(512);
406
405
  char *ptr,**res;
407
406
  struct handle_option_ctx ctx;
408
407
 
409
408
  init_default_directories();
410
 
  init_alloc_root(&alloc,512);
411
409
  /*
412
410
    Check if the user doesn't want any default option processing
413
411
    --no-defaults is always the first option
416
414
  {
417
415
    /* remove the --no-defaults argument and return only the other arguments */
418
416
    uint32_t i;
419
 
    if (!(ptr=(char*) alloc_root(&alloc,sizeof(alloc)+
420
 
                                 (*argc + 1)*sizeof(char*))))
 
417
    if (!(ptr=(char*) alloc.alloc_root(sizeof(alloc)+ (*argc + 1)*sizeof(char*))))
421
418
      goto err;
422
419
    res= (char**) (ptr+sizeof(alloc));
423
420
    memset(res,0,(*argc + 1));
451
448
    Here error contains <> 0 only if we have a fully specified conf_file
452
449
    or a forced default file
453
450
  */
454
 
  if (!(ptr=(char*) alloc_root(&alloc,sizeof(alloc)+
455
 
                               (args.elements + *argc +1) *sizeof(char*))))
 
451
  if (!(ptr=(char*) alloc.alloc_root(sizeof(alloc)+ (args.elements + *argc +1) *sizeof(char*))))
456
452
    goto err;
457
453
  res= (char**) (ptr+sizeof(alloc));
458
454
 
467
463
    Check if we wan't to see the new argument list
468
464
    This options must always be the last of the default options
469
465
  */
470
 
  if (*argc >= 2 && !strcmp(argv[0][1],"--print-defaults"))
471
 
  {
472
 
    found_print_defaults=1;
473
 
    --*argc; ++*argv;                           /* skip argument */
474
 
  }
475
 
 
476
466
  if (*argc)
477
467
    memcpy(res+1+args.elements, *argv + 1, (*argc-1)*sizeof(char*));
478
468
  res[args.elements+ *argc]=0;                  /* last null */
481
471
  *argv= static_cast<char**>(res);
482
472
  *(memory::Root*) ptr= alloc;                  /* Save alloc root for free */
483
473
  delete_dynamic(&args);
484
 
  if (found_print_defaults)
485
 
  {
486
 
    int i;
487
 
    printf("%s would have been started with the following arguments:\n",
488
 
           **argv);
489
 
    for (i=1 ; i < *argc ; i++)
490
 
      printf("%s ", (*argv)[i]);
491
 
    puts("");
492
 
    exit(0);
493
 
  }
 
474
 
494
475
  return(error);
495
476
 
496
477
 err:
503
484
{
504
485
  memory::Root ptr;
505
486
  memcpy(&ptr, (char*) argv - sizeof(ptr), sizeof(ptr));
506
 
  free_root(&ptr,MYF(0));
 
487
  ptr.free_root(MYF(0));
507
488
}
508
489
 
509
490
 
955
936
    }
956
937
  }
957
938
  puts("\nThe following options may be given as the first argument:\n\
958
 
  --print-defaults      Print the program argument list and exit\n\
959
939
  --no-defaults         Don't read default options from any options file\n\
960
940
  --defaults-file=#     Only read default options from the given file #\n\
961
941
  --defaults-extra-file=# Read this file after the global files are read");