Merge lp:~vjsamuel/drizzle/new-config-file-system into lp:~drizzle-trunk/drizzle/development
- new-config-file-system
- Merge into development
Proposed by
Vijay Samuel
Status: | Merged |
---|---|
Approved by: | Monty Taylor |
Approved revision: | 1673 |
Merged at revision: | 1677 |
Proposed branch: | lp:~vjsamuel/drizzle/new-config-file-system |
Merge into: | lp:~drizzle-trunk/drizzle/development |
Diff against target: |
275 lines (+77/-35) 5 files modified
client/drizzle.cc (+15/-6) client/drizzledump.cc (+14/-6) client/drizzleimport.cc (+14/-5) client/drizzleslap.cc (+20/-12) client/drizzletest.cc (+14/-6) |
To merge this branch: | bzr merge lp:~vjsamuel/drizzle/new-config-file-system |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Monty Taylor | Approve | ||
Review via email: mp+31417@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'client/drizzle.cc' | |||
2 | --- client/drizzle.cc 2010-06-19 16:36:52 +0000 | |||
3 | +++ client/drizzle.cc 2010-07-30 19:39:47 +0000 | |||
4 | @@ -9,7 +9,7 @@ | |||
5 | 9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
6 | 10 | * | 10 | * |
7 | 11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
9 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty ofm |
10 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | 14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
12 | 15 | * | 15 | * |
13 | @@ -65,6 +65,7 @@ | |||
14 | 65 | #include <sys/ioctl.h> | 65 | #include <sys/ioctl.h> |
15 | 66 | #include <drizzled/configmake.h> | 66 | #include <drizzled/configmake.h> |
16 | 67 | #include "drizzled/utf8/utf8.h" | 67 | #include "drizzled/utf8/utf8.h" |
17 | 68 | #include <cstdlib> | ||
18 | 68 | 69 | ||
19 | 69 | #if defined(HAVE_CURSES_H) && defined(HAVE_TERM_H) | 70 | #if defined(HAVE_CURSES_H) && defined(HAVE_TERM_H) |
20 | 70 | #include <curses.h> | 71 | #include <curses.h> |
21 | @@ -1488,6 +1489,8 @@ | |||
22 | 1488 | std::string system_config_dir_client(SYSCONFDIR); | 1489 | std::string system_config_dir_client(SYSCONFDIR); |
23 | 1489 | system_config_dir_client.append("/drizzle/client.cnf"); | 1490 | system_config_dir_client.append("/drizzle/client.cnf"); |
24 | 1490 | 1491 | ||
25 | 1492 | std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config")); | ||
26 | 1493 | |||
27 | 1491 | po::variables_map vm; | 1494 | po::variables_map vm; |
28 | 1492 | 1495 | ||
29 | 1493 | po::positional_options_description p; | 1496 | po::positional_options_description p; |
30 | @@ -1498,14 +1501,20 @@ | |||
31 | 1498 | 1501 | ||
32 | 1499 | if (! vm["no-defaults"].as<bool>()) | 1502 | if (! vm["no-defaults"].as<bool>()) |
33 | 1500 | { | 1503 | { |
35 | 1501 | ifstream user_drizzle_ifs("~/.drizzle/drizzle.cnf"); | 1504 | std::string user_config_dir_drizzle(user_config_dir); |
36 | 1505 | user_config_dir_drizzle.append("/drizzle/drizzle.cnf"); | ||
37 | 1506 | |||
38 | 1507 | std::string user_config_dir_client(user_config_dir); | ||
39 | 1508 | user_config_dir_client.append("/drizzle/client.cnf"); | ||
40 | 1509 | |||
41 | 1510 | ifstream user_drizzle_ifs(user_config_dir_drizzle.c_str()); | ||
42 | 1502 | po::store(parse_config_file(user_drizzle_ifs, drizzle_options), vm); | 1511 | po::store(parse_config_file(user_drizzle_ifs, drizzle_options), vm); |
44 | 1503 | 1512 | ||
45 | 1513 | ifstream user_client_ifs(user_config_dir_client.c_str()); | ||
46 | 1514 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
47 | 1515 | |||
48 | 1504 | ifstream system_drizzle_ifs(system_config_dir_drizzle.c_str()); | 1516 | ifstream system_drizzle_ifs(system_config_dir_drizzle.c_str()); |
49 | 1505 | store(parse_config_file(system_drizzle_ifs, drizzle_options), vm); | 1517 | store(parse_config_file(system_drizzle_ifs, drizzle_options), vm); |
50 | 1506 | |||
51 | 1507 | ifstream user_client_ifs("~/.drizzle/client.cnf"); | ||
52 | 1508 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
53 | 1509 | 1518 | ||
54 | 1510 | ifstream system_client_ifs(system_config_dir_client.c_str()); | 1519 | ifstream system_client_ifs(system_config_dir_client.c_str()); |
55 | 1511 | po::store(parse_config_file(system_client_ifs, client_options), vm); | 1520 | po::store(parse_config_file(system_client_ifs, client_options), vm); |
56 | 1512 | 1521 | ||
57 | === modified file 'client/drizzledump.cc' | |||
58 | --- client/drizzledump.cc 2010-06-24 10:30:53 +0000 | |||
59 | +++ client/drizzledump.cc 2010-07-30 19:39:47 +0000 | |||
60 | @@ -2590,6 +2590,8 @@ | |||
61 | 2590 | std::string system_config_dir_client(SYSCONFDIR); | 2590 | std::string system_config_dir_client(SYSCONFDIR); |
62 | 2591 | system_config_dir_client.append("/drizzle/client.cnf"); | 2591 | system_config_dir_client.append("/drizzle/client.cnf"); |
63 | 2592 | 2592 | ||
64 | 2593 | std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config")); | ||
65 | 2594 | |||
66 | 2593 | po::positional_options_description p; | 2595 | po::positional_options_description p; |
67 | 2594 | p.add("database-used", 1); | 2596 | p.add("database-used", 1); |
68 | 2595 | p.add("Table-used",-1); | 2597 | p.add("Table-used",-1); |
69 | @@ -2605,15 +2607,21 @@ | |||
70 | 2605 | 2607 | ||
71 | 2606 | if (! vm.count("no-defaults")) | 2608 | if (! vm.count("no-defaults")) |
72 | 2607 | { | 2609 | { |
74 | 2608 | ifstream user_dump_ifs("~/.drizzle/drizzledump.cnf"); | 2610 | std::string user_config_dir_dump(user_config_dir); |
75 | 2611 | user_config_dir_dump.append("/drizzle/drizzledump.cnf"); | ||
76 | 2612 | |||
77 | 2613 | std::string user_config_dir_client(user_config_dir); | ||
78 | 2614 | user_config_dir_client.append("/drizzle/client.cnf"); | ||
79 | 2615 | |||
80 | 2616 | ifstream user_dump_ifs(user_config_dir_dump.c_str()); | ||
81 | 2609 | po::store(parse_config_file(user_dump_ifs, dump_options), vm); | 2617 | po::store(parse_config_file(user_dump_ifs, dump_options), vm); |
83 | 2610 | 2618 | ||
84 | 2619 | ifstream user_client_ifs(user_config_dir_client.c_str()); | ||
85 | 2620 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
86 | 2621 | |||
87 | 2611 | ifstream system_dump_ifs(system_config_dir_dump.c_str()); | 2622 | ifstream system_dump_ifs(system_config_dir_dump.c_str()); |
89 | 2612 | store(parse_config_file(system_dump_ifs, dump_options), vm); | 2623 | po::store(parse_config_file(system_dump_ifs, dump_options), vm); |
90 | 2613 | 2624 | ||
91 | 2614 | ifstream user_client_ifs("~/.drizzle/client.cnf"); | ||
92 | 2615 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
93 | 2616 | |||
94 | 2617 | ifstream system_client_ifs(system_config_dir_client.c_str()); | 2625 | ifstream system_client_ifs(system_config_dir_client.c_str()); |
95 | 2618 | po::store(parse_config_file(system_client_ifs, client_options), vm); | 2626 | po::store(parse_config_file(system_client_ifs, client_options), vm); |
96 | 2619 | } | 2627 | } |
97 | 2620 | 2628 | ||
98 | === modified file 'client/drizzleimport.cc' | |||
99 | --- client/drizzleimport.cc 2010-06-21 11:59:50 +0000 | |||
100 | +++ client/drizzleimport.cc 2010-07-30 19:39:47 +0000 | |||
101 | @@ -468,18 +468,27 @@ | |||
102 | 468 | std::string system_config_dir_client(SYSCONFDIR); | 468 | std::string system_config_dir_client(SYSCONFDIR); |
103 | 469 | system_config_dir_client.append("/drizzle/client.cnf"); | 469 | system_config_dir_client.append("/drizzle/client.cnf"); |
104 | 470 | 470 | ||
105 | 471 | std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config")); | ||
106 | 472 | |||
107 | 471 | po::variables_map vm; | 473 | po::variables_map vm; |
108 | 474 | |||
109 | 472 | po::store(po::command_line_parser(argc, argv).options(long_options). | 475 | po::store(po::command_line_parser(argc, argv).options(long_options). |
110 | 473 | extra_parser(parse_password_arg).run(), vm); | 476 | extra_parser(parse_password_arg).run(), vm); |
111 | 474 | 477 | ||
113 | 475 | ifstream user_import_ifs("~/.drizzle/drizzleimport.cnf"); | 478 | std::string user_config_dir_import(user_config_dir); |
114 | 479 | user_config_dir_import.append("/drizzle/drizzleimport.cnf"); | ||
115 | 480 | |||
116 | 481 | std::string user_config_dir_client(user_config_dir); | ||
117 | 482 | user_config_dir_client.append("/drizzle/client.cnf"); | ||
118 | 483 | |||
119 | 484 | ifstream user_import_ifs(user_config_dir_import.c_str()); | ||
120 | 476 | po::store(parse_config_file(user_import_ifs, import_options), vm); | 485 | po::store(parse_config_file(user_import_ifs, import_options), vm); |
122 | 477 | 486 | ||
123 | 487 | ifstream user_client_ifs(user_config_dir_client.c_str()); | ||
124 | 488 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
125 | 489 | |||
126 | 478 | ifstream system_import_ifs(system_config_dir_import.c_str()); | 490 | ifstream system_import_ifs(system_config_dir_import.c_str()); |
127 | 479 | store(parse_config_file(system_import_ifs, import_options), vm); | 491 | store(parse_config_file(system_import_ifs, import_options), vm); |
128 | 480 | |||
129 | 481 | ifstream user_client_ifs("~/.drizzle/client.cnf"); | ||
130 | 482 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
131 | 483 | 492 | ||
132 | 484 | ifstream system_client_ifs(system_config_dir_client.c_str()); | 493 | ifstream system_client_ifs(system_config_dir_client.c_str()); |
133 | 485 | po::store(parse_config_file(system_client_ifs, client_options), vm); | 494 | po::store(parse_config_file(system_client_ifs, client_options), vm); |
134 | 486 | 495 | ||
135 | === modified file 'client/drizzleslap.cc' | |||
136 | --- client/drizzleslap.cc 2010-06-21 11:59:50 +0000 | |||
137 | +++ client/drizzleslap.cc 2010-07-30 19:39:47 +0000 | |||
138 | @@ -848,9 +848,9 @@ | |||
139 | 848 | 848 | ||
140 | 849 | * long_options is the union of commandline_options, slap_options and client_options. | 849 | * long_options is the union of commandline_options, slap_options and client_options. |
141 | 850 | 850 | ||
145 | 851 | * There are two configuration files per set of options, one which is defined by the user and | 851 | * There are two configuration files per set of options, one which is defined by the user |
146 | 852 | * which is found at ~/.drizzle directory and the other which is the system configuration | 852 | * which is found at either $XDG_CONFIG_HOME/drizzle or ~/.config/drizzle directory and the other which |
147 | 853 | * file which is found in the SYSCONFDIR/drizzle directory. | 853 | * is the system configuration file which is found in the SYSCONFDIR/drizzle directory. |
148 | 854 | 854 | ||
149 | 855 | * The system configuration file is over ridden by the user's configuration file which | 855 | * The system configuration file is over ridden by the user's configuration file which |
150 | 856 | * in turn is over ridden by the command line. | 856 | * in turn is over ridden by the command line. |
151 | @@ -979,6 +979,8 @@ | |||
152 | 979 | std::string system_config_dir_client(SYSCONFDIR); | 979 | std::string system_config_dir_client(SYSCONFDIR); |
153 | 980 | system_config_dir_client.append("/drizzle/client.cnf"); | 980 | system_config_dir_client.append("/drizzle/client.cnf"); |
154 | 981 | 981 | ||
155 | 982 | std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config")); | ||
156 | 983 | |||
157 | 982 | uint64_t temp_drizzle_port= 0; | 984 | uint64_t temp_drizzle_port= 0; |
158 | 983 | drizzle_con_st con; | 985 | drizzle_con_st con; |
159 | 984 | OptionString *eptr; | 986 | OptionString *eptr; |
160 | @@ -989,15 +991,21 @@ | |||
161 | 989 | po::store(po::command_line_parser(argc, argv).options(long_options). | 991 | po::store(po::command_line_parser(argc, argv).options(long_options). |
162 | 990 | extra_parser(parse_password_arg).run(), vm); | 992 | extra_parser(parse_password_arg).run(), vm); |
163 | 991 | 993 | ||
165 | 992 | ifstream user_slap_ifs("~/.drizzle/drizzleslap.cnf"); | 994 | std::string user_config_dir_slap(user_config_dir); |
166 | 995 | user_config_dir_slap.append("/drizzle/drizzleslap.cnf"); | ||
167 | 996 | |||
168 | 997 | std::string user_config_dir_client(user_config_dir); | ||
169 | 998 | user_config_dir_client.append("/drizzle/client.cnf"); | ||
170 | 999 | |||
171 | 1000 | ifstream user_slap_ifs(user_config_dir_slap.c_str()); | ||
172 | 993 | po::store(parse_config_file(user_slap_ifs, slap_options), vm); | 1001 | po::store(parse_config_file(user_slap_ifs, slap_options), vm); |
173 | 994 | 1002 | ||
174 | 1003 | ifstream user_client_ifs(user_config_dir_client.c_str()); | ||
175 | 1004 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
176 | 1005 | |||
177 | 995 | ifstream system_slap_ifs(system_config_dir_slap.c_str()); | 1006 | ifstream system_slap_ifs(system_config_dir_slap.c_str()); |
178 | 996 | store(parse_config_file(system_slap_ifs, slap_options), vm); | 1007 | store(parse_config_file(system_slap_ifs, slap_options), vm); |
179 | 997 | 1008 | ||
180 | 998 | ifstream user_client_ifs("~/.drizzle/client.cnf"); | ||
181 | 999 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
182 | 1000 | |||
183 | 1001 | ifstream system_client_ifs(system_config_dir_client.c_str()); | 1009 | ifstream system_client_ifs(system_config_dir_client.c_str()); |
184 | 1002 | store(parse_config_file(system_client_ifs, client_options), vm); | 1010 | store(parse_config_file(system_client_ifs, client_options), vm); |
185 | 1003 | 1011 | ||
186 | @@ -1006,7 +1014,7 @@ | |||
187 | 1006 | if (process_options()) | 1014 | if (process_options()) |
188 | 1007 | exit(1); | 1015 | exit(1); |
189 | 1008 | 1016 | ||
191 | 1009 | if( vm.count("help") || vm.count("info")) | 1017 | if ( vm.count("help") || vm.count("info")) |
192 | 1010 | { | 1018 | { |
193 | 1011 | printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, | 1019 | printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, |
194 | 1012 | drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); | 1020 | drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); |
195 | @@ -1015,11 +1023,11 @@ | |||
196 | 1015 | \nand you are welcome to modify and redistribute it under the GPL \ | 1023 | \nand you are welcome to modify and redistribute it under the GPL \ |
197 | 1016 | license\n"); | 1024 | license\n"); |
198 | 1017 | puts("Run a query multiple times against the server\n"); | 1025 | puts("Run a query multiple times against the server\n"); |
200 | 1018 | cout<<long_options<<endl; | 1026 | cout << long_options << endl; |
201 | 1019 | exit(0); | 1027 | exit(0); |
202 | 1020 | } | 1028 | } |
203 | 1021 | 1029 | ||
205 | 1022 | if(vm.count("port")) | 1030 | if (vm.count("port")) |
206 | 1023 | { | 1031 | { |
207 | 1024 | temp_drizzle_port= vm["port"].as<uint32_t>(); | 1032 | temp_drizzle_port= vm["port"].as<uint32_t>(); |
208 | 1025 | 1033 | ||
209 | @@ -1034,7 +1042,7 @@ | |||
210 | 1034 | } | 1042 | } |
211 | 1035 | } | 1043 | } |
212 | 1036 | 1044 | ||
214 | 1037 | if( vm.count("password") ) | 1045 | if ( vm.count("password") ) |
215 | 1038 | { | 1046 | { |
216 | 1039 | if (!opt_password.empty()) | 1047 | if (!opt_password.empty()) |
217 | 1040 | opt_password.erase(); | 1048 | opt_password.erase(); |
218 | @@ -1055,7 +1063,7 @@ | |||
219 | 1055 | 1063 | ||
220 | 1056 | 1064 | ||
221 | 1057 | 1065 | ||
223 | 1058 | if( vm.count("version") ) | 1066 | if ( vm.count("version") ) |
224 | 1059 | { | 1067 | { |
225 | 1060 | printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, | 1068 | printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname, SLAP_VERSION, |
226 | 1061 | drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); | 1069 | drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU); |
227 | 1062 | 1070 | ||
228 | === modified file 'client/drizzletest.cc' | |||
229 | --- client/drizzletest.cc 2010-07-06 04:22:48 +0000 | |||
230 | +++ client/drizzletest.cc 2010-07-30 19:39:47 +0000 | |||
231 | @@ -5380,7 +5380,7 @@ | |||
232 | 5380 | { | 5380 | { |
233 | 5381 | if (in_opt_sleep < -1) | 5381 | if (in_opt_sleep < -1) |
234 | 5382 | { | 5382 | { |
236 | 5383 | cout<<N_("Error: Invalid Value for opt_sleep"); | 5383 | cout << N_("Error: Invalid Value for opt_sleep"); |
237 | 5384 | exit(-1); | 5384 | exit(-1); |
238 | 5385 | } | 5385 | } |
239 | 5386 | opt_sleep= in_opt_sleep; | 5386 | opt_sleep= in_opt_sleep; |
240 | @@ -5476,6 +5476,8 @@ | |||
241 | 5476 | std::string system_config_dir_client(SYSCONFDIR); | 5476 | std::string system_config_dir_client(SYSCONFDIR); |
242 | 5477 | system_config_dir_client.append("/drizzle/client.cnf"); | 5477 | system_config_dir_client.append("/drizzle/client.cnf"); |
243 | 5478 | 5478 | ||
244 | 5479 | std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config")); | ||
245 | 5480 | |||
246 | 5479 | po::variables_map vm; | 5481 | po::variables_map vm; |
247 | 5480 | 5482 | ||
248 | 5481 | po::store(po::command_line_parser(argc, argv).options(long_options). | 5483 | po::store(po::command_line_parser(argc, argv).options(long_options). |
249 | @@ -5483,15 +5485,21 @@ | |||
250 | 5483 | 5485 | ||
251 | 5484 | if (! vm["no-defaults"].as<bool>()) | 5486 | if (! vm["no-defaults"].as<bool>()) |
252 | 5485 | { | 5487 | { |
254 | 5486 | ifstream user_test_ifs("~/.drizzle/drizzletest.cnf"); | 5488 | std::string user_config_dir_test(user_config_dir); |
255 | 5489 | user_config_dir_test.append("/drizzle/drizzletest.cnf"); | ||
256 | 5490 | |||
257 | 5491 | std::string user_config_dir_client(user_config_dir); | ||
258 | 5492 | user_config_dir_client.append("/drizzle/client.cnf"); | ||
259 | 5493 | |||
260 | 5494 | ifstream user_test_ifs(user_config_dir_test.c_str()); | ||
261 | 5487 | po::store(parse_config_file(user_test_ifs, test_options), vm); | 5495 | po::store(parse_config_file(user_test_ifs, test_options), vm); |
263 | 5488 | 5496 | ||
264 | 5497 | ifstream user_client_ifs(user_config_dir_client.c_str()); | ||
265 | 5498 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
266 | 5499 | |||
267 | 5489 | ifstream system_test_ifs(system_config_dir_test.c_str()); | 5500 | ifstream system_test_ifs(system_config_dir_test.c_str()); |
268 | 5490 | store(parse_config_file(system_test_ifs, test_options), vm); | 5501 | store(parse_config_file(system_test_ifs, test_options), vm); |
269 | 5491 | 5502 | ||
270 | 5492 | ifstream user_client_ifs("~/.drizzle/client.cnf"); | ||
271 | 5493 | po::store(parse_config_file(user_client_ifs, client_options), vm); | ||
272 | 5494 | |||
273 | 5495 | ifstream system_client_ifs(system_config_dir_client.c_str()); | 5503 | ifstream system_client_ifs(system_config_dir_client.c_str()); |
274 | 5496 | po::store(parse_config_file(system_client_ifs, client_options), vm); | 5504 | po::store(parse_config_file(system_client_ifs, client_options), vm); |
275 | 5497 | } | 5505 | } |
Looks great. Thanks for fixing that for me!