| 615 | |
| 616 | |
| 617 | int my_load_defaults(const char *conf_file, const char **groups, |
| 618 | int *argc, char ***argv, const char ***default_directories) |
| 619 | { |
| 620 | DYNAMIC_ARRAY args; |
| 621 | TYPELIB group; |
| 622 | my_bool found_print_defaults= 0; |
| 623 | uint args_used= 0; |
| 624 | int error= 0; |
| 625 | MEM_ROOT alloc; |
| 626 | char *ptr,**res; |
| 627 | struct handle_option_ctx ctx; |
| 628 | const char **dirs; |
| 629 | uint args_sep= my_getopt_use_args_separator ? 1 : 0; |
| 630 | DBUG_ENTER("load_defaults"); |
| 631 | |
| 632 | init_alloc_root(&alloc,512,0); |
| 633 | if ((dirs= init_default_directories(&alloc)) == NULL) |
| 634 | goto err; |
| 635 | /* |
| 636 | Check if the user doesn't want any default option processing |
| 637 | --no-defaults is always the first option |
| 638 | */ |
| 639 | if (*argc >= 2 && !strcmp(argv[0][1], "--no-defaults")) |
| 640 | found_no_defaults= TRUE; |
| 641 | |
| 642 | group.count=0; |
| 643 | group.name= "defaults"; |
| 644 | group.type_names= groups; |
| 645 | |
| 646 | for (; *groups ; groups++) |
| 647 | group.count++; |
| 648 | |
| 649 | if (my_init_dynamic_array(&args, sizeof(char*),*argc, 32)) |
| 650 | goto err; |
| 651 | |
| 652 | ctx.alloc= &alloc; |
| 653 | ctx.args= &args; |
| 654 | ctx.group= &group; |
| 655 | |
| 656 | if ((error= my_search_option_files(conf_file, argc, argv, |
| 657 | &args_used, handle_default_option, |
| 658 | (void *) &ctx, dirs))) |
| 659 | { |
| 660 | free_root(&alloc,MYF(0)); |
| 661 | DBUG_RETURN(error); |
| 662 | } |
| 663 | |
| 664 | /* Read options from login group. */ |
| 665 | is_login_file= TRUE; |
| 666 | if (my_default_get_login_file(my_login_file, sizeof(my_login_file)) && |
| 667 | (error= my_search_option_files(my_login_file,argc, argv, &args_used, |
| 668 | handle_default_option, (void *) &ctx, |
| 669 | dirs))) |
| 670 | { |
| 671 | free_root(&alloc,MYF(0)); |
| 672 | DBUG_RETURN(error); |
| 673 | } |
| 674 | is_login_file= FALSE; |
no test coverage detected