~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleslap.cc

  • Committer: Vijay Samuel
  • Date: 2010-07-30 18:50:30 UTC
  • mto: (1675.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 1677.
  • Revision ID: vijay@vijay-20100730185030-io2zvgt35ehdeso9
Merge new user config file processing system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
848
848
 
849
849
 * long_options is the union of commandline_options, slap_options and client_options.
850
850
 
851
 
 * There are two configuration files per set of options, one which is defined by the user and
852
 
 * which is found at ~/.drizzle directory and the other which is the system configuration
853
 
 * file which is found in the SYSCONFDIR/drizzle directory.
 
851
 * There are two configuration files per set of options, one which is defined by the user
 
852
 * which is found at either $XDG_CONFIG_HOME/drizzle or ~/.config/drizzle directory and the other which 
 
853
 * is the system configuration file which is found in the SYSCONFDIR/drizzle directory.
854
854
 
855
855
 * The system configuration file is over ridden by the user's configuration file which
856
856
 * in turn is over ridden by the command line.
979
979
    std::string system_config_dir_client(SYSCONFDIR); 
980
980
    system_config_dir_client.append("/drizzle/client.cnf");
981
981
 
 
982
    std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config"));
 
983
 
982
984
    uint64_t temp_drizzle_port= 0;
983
985
    drizzle_con_st con;
984
986
    OptionString *eptr;
989
991
    po::store(po::command_line_parser(argc, argv).options(long_options).
990
992
            extra_parser(parse_password_arg).run(), vm);
991
993
 
992
 
    ifstream user_slap_ifs("~/.drizzle/drizzleslap.cnf");
 
994
    std::string user_config_dir_slap(user_config_dir);
 
995
    user_config_dir_slap.append("/drizzle/drizzleslap.cnf"); 
 
996
 
 
997
    std::string user_config_dir_client(user_config_dir);
 
998
    user_config_dir_client.append("/drizzle/client.cnf");
 
999
 
 
1000
    ifstream user_slap_ifs(user_config_dir_slap.c_str());
993
1001
    po::store(parse_config_file(user_slap_ifs, slap_options), vm);
994
1002
 
 
1003
    ifstream user_client_ifs(user_config_dir_client.c_str());
 
1004
    po::store(parse_config_file(user_client_ifs, client_options), vm);
 
1005
 
995
1006
    ifstream system_slap_ifs(system_config_dir_slap.c_str());
996
1007
    store(parse_config_file(system_slap_ifs, slap_options), vm);
997
1008
 
998
 
    ifstream user_client_ifs("~/.drizzle/client.cnf");
999
 
    po::store(parse_config_file(user_client_ifs, client_options), vm);
1000
 
 
1001
1009
    ifstream system_client_ifs(system_config_dir_client.c_str());
1002
1010
    store(parse_config_file(system_client_ifs, client_options), vm);
1003
1011
 
1006
1014
    if (process_options())
1007
1015
      exit(1);
1008
1016
 
1009
 
    if( vm.count("help") || vm.count("info"))
 
1017
    if ( vm.count("help") || vm.count("info"))
1010
1018
    {
1011
1019
      printf("%s  Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION,
1012
1020
          drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU);
1015
1023
          \nand you are welcome to modify and redistribute it under the GPL \
1016
1024
          license\n");
1017
1025
      puts("Run a query multiple times against the server\n");
1018
 
      cout<<long_options<<endl;
 
1026
      cout << long_options << endl;
1019
1027
      exit(0);
1020
1028
    }   
1021
1029
 
1022
 
    if(vm.count("port")) 
 
1030
    if (vm.count("port")) 
1023
1031
    {
1024
1032
      temp_drizzle_port= vm["port"].as<uint32_t>();
1025
1033
 
1034
1042
      }
1035
1043
    }
1036
1044
 
1037
 
  if( vm.count("password") )
 
1045
  if ( vm.count("password") )
1038
1046
  {
1039
1047
    if (!opt_password.empty())
1040
1048
      opt_password.erase();
1055
1063
 
1056
1064
 
1057
1065
 
1058
 
    if( vm.count("version") )
 
1066
    if ( vm.count("version") )
1059
1067
    {
1060
1068
      printf("%s  Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION,
1061
1069
          drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU);