diff options
Diffstat (limited to 'src/main.cc')
-rw-r--r-- | src/main.cc | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/main.cc b/src/main.cc index 22862fa..1c62744 100644 --- a/src/main.cc +++ b/src/main.cc | |||
@@ -59,8 +59,21 @@ | |||
59 | #include <stdexcept> | 59 | #include <stdexcept> |
60 | #include <typeinfo> | 60 | #include <typeinfo> |
61 | 61 | ||
62 | using namespace std; | 62 | using std::cout; |
63 | void showInfo(ostream &ostr) { | 63 | using std::cerr; |
64 | using std::endl; | ||
65 | using std::string; | ||
66 | using std::ostream; | ||
67 | using std::ofstream; | ||
68 | using std::streambuf; | ||
69 | using std::auto_ptr; | ||
70 | using std::out_of_range; | ||
71 | using std::runtime_error; | ||
72 | using std::bad_cast; | ||
73 | using std::bad_alloc; | ||
74 | using std::exception; | ||
75 | |||
76 | static void showInfo(ostream &ostr) { | ||
64 | _FB_USES_NLS; | 77 | _FB_USES_NLS; |
65 | ostr<<_FB_CONSOLETEXT(Common, FluxboxVersion, "Fluxbox version", "Fluxbox version heading")<<": "<<__fluxbox_version<<endl; | 78 | ostr<<_FB_CONSOLETEXT(Common, FluxboxVersion, "Fluxbox version", "Fluxbox version heading")<<": "<<__fluxbox_version<<endl; |
66 | 79 | ||
@@ -73,7 +86,7 @@ void showInfo(ostream &ostr) { | |||
73 | ostr<<_FB_CONSOLETEXT(Common, Compiler, "Compiler", "Compiler used to build fluxbox")<<": "<<__fluxbox_compiler<<endl; | 86 | ostr<<_FB_CONSOLETEXT(Common, Compiler, "Compiler", "Compiler used to build fluxbox")<<": "<<__fluxbox_compiler<<endl; |
74 | #endif // __fluxbox_compiler | 87 | #endif // __fluxbox_compiler |
75 | #ifdef __fluxbox_compiler_version | 88 | #ifdef __fluxbox_compiler_version |
76 | ostr<<_FB_CONSOLETEXT(Common, CompilerVersion, "Compiler version", "Compiler version used to build fluxbox")<<": "<<__fluxbox_compiler_version<<endl; | 89 | ostr<<_FB_CONSOLETEXT(Common, CompilerVersion, "Compiler version", "Compiler version used to build fluxbox")<<": "<<__fluxbox_compiler_version<<endl; |
77 | #endif // __fluxbox_compiler_version | 90 | #endif // __fluxbox_compiler_version |
78 | 91 | ||
79 | ostr<<endl<<_FB_CONSOLETEXT(Common, Defaults, "Defaults", "Default values compiled in")<<":"<<endl; | 92 | ostr<<endl<<_FB_CONSOLETEXT(Common, Defaults, "Defaults", "Default values compiled in")<<":"<<endl; |
@@ -177,9 +190,9 @@ void showInfo(ostream &ostr) { | |||
177 | 190 | ||
178 | int main(int argc, char **argv) { | 191 | int main(int argc, char **argv) { |
179 | 192 | ||
180 | std::string session_display = ""; | 193 | string session_display = ""; |
181 | std::string rc_file; | 194 | string rc_file; |
182 | std::string log_filename; | 195 | string log_filename; |
183 | 196 | ||
184 | FbTk::NLSInit("fluxbox.cat"); | 197 | FbTk::NLSInit("fluxbox.cat"); |
185 | _FB_USES_NLS; | 198 | _FB_USES_NLS; |
@@ -191,7 +204,7 @@ int main(int argc, char **argv) { | |||
191 | 204 | ||
192 | if ((++i) >= argc) { | 205 | if ((++i) >= argc) { |
193 | cerr<<_FB_CONSOLETEXT(main, RCRequiresArg, | 206 | cerr<<_FB_CONSOLETEXT(main, RCRequiresArg, |
194 | "error: '-rc' requires an argument", "the -rc option requires a file argument")<<endl;; | 207 | "error: '-rc' requires an argument", "the -rc option requires a file argument")<<endl; |
195 | exit(1); | 208 | exit(1); |
196 | } | 209 | } |
197 | 210 | ||
@@ -208,7 +221,7 @@ int main(int argc, char **argv) { | |||
208 | } | 221 | } |
209 | 222 | ||
210 | session_display = argv[i]; | 223 | session_display = argv[i]; |
211 | std::string display_env = "DISPLAY=" + session_display; | 224 | string display_env = "DISPLAY=" + session_display; |
212 | if (putenv(const_cast<char *>(display_env.c_str()))) { | 225 | if (putenv(const_cast<char *>(display_env.c_str()))) { |
213 | cerr<<_FB_CONSOLETEXT(main, WarnDisplayEnv, | 226 | cerr<<_FB_CONSOLETEXT(main, WarnDisplayEnv, |
214 | "warning: couldn't set environment variable 'DISPLAY'", | 227 | "warning: couldn't set environment variable 'DISPLAY'", |
@@ -252,7 +265,7 @@ int main(int argc, char **argv) { | |||
252 | #ifdef __EMX__ | 265 | #ifdef __EMX__ |
253 | _chdir2(getenv("X11ROOT")); | 266 | _chdir2(getenv("X11ROOT")); |
254 | #endif // __EMX__ | 267 | #endif // __EMX__ |
255 | std::auto_ptr<Fluxbox> fluxbox; | 268 | auto_ptr<Fluxbox> fluxbox; |
256 | int exitcode=EXIT_FAILURE; | 269 | int exitcode=EXIT_FAILURE; |
257 | 270 | ||
258 | streambuf *outbuf = 0; | 271 | streambuf *outbuf = 0; |
@@ -279,17 +292,17 @@ int main(int argc, char **argv) { | |||
279 | 292 | ||
280 | exitcode = EXIT_SUCCESS; | 293 | exitcode = EXIT_SUCCESS; |
281 | 294 | ||
282 | } catch (std::out_of_range &oor) { | 295 | } catch (out_of_range &oor) { |
283 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorOutOfRange, "Out of range", "Error message")<<": "<<oor.what()<<endl; | 296 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorOutOfRange, "Out of range", "Error message")<<": "<<oor.what()<<endl; |
284 | } catch (std::runtime_error &re) { | 297 | } catch (runtime_error &re) { |
285 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorRuntime, "Runtime error", "Error message")<<": "<<re.what()<<endl; | 298 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorRuntime, "Runtime error", "Error message")<<": "<<re.what()<<endl; |
286 | } catch (std::bad_cast &bc) { | 299 | } catch (bad_cast &bc) { |
287 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorBadCast, "Bad cast", "Error message")<<": "<<bc.what()<<endl; | 300 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorBadCast, "Bad cast", "Error message")<<": "<<bc.what()<<endl; |
288 | } catch (std::bad_alloc &ba) { | 301 | } catch (bad_alloc &ba) { |
289 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorBadAlloc, "Bad Alloc", "Error message")<<": "<<ba.what()<<endl; | 302 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorBadAlloc, "Bad Alloc", "Error message")<<": "<<ba.what()<<endl; |
290 | } catch (std::exception &e) { | 303 | } catch (exception &e) { |
291 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorStandardException, "Standard Exception", "Error message")<<": "<<e.what()<<endl; | 304 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorStandardException, "Standard Exception", "Error message")<<": "<<e.what()<<endl; |
292 | } catch (std::string error_str) { | 305 | } catch (string error_str) { |
293 | cerr<<_FB_CONSOLETEXT(Common, Error, "Error", "Error message header")<<": "<<error_str<<endl; | 306 | cerr<<_FB_CONSOLETEXT(Common, Error, "Error", "Error message header")<<": "<<error_str<<endl; |
294 | } catch (...) { | 307 | } catch (...) { |
295 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorUnknown, "Unknown error", "Error message")<<"."<<endl; | 308 | cerr<<"Fluxbox: "<<_FB_CONSOLETEXT(main, ErrorUnknown, "Unknown error", "Error message")<<"."<<endl; |
@@ -297,11 +310,11 @@ int main(int argc, char **argv) { | |||
297 | } | 310 | } |
298 | 311 | ||
299 | bool restarting = false; | 312 | bool restarting = false; |
300 | std::string restart_argument; | 313 | string restart_argument; |
301 | 314 | ||
302 | if (fluxbox.get()) { | 315 | if (fluxbox.get()) { |
303 | restarting = fluxbox->isRestarting(); | 316 | restarting = fluxbox->isRestarting(); |
304 | restart_argument = fluxbox->getRestartArgument(); | 317 | restart_argument = fluxbox->getRestartArgument(); |
305 | } | 318 | } |
306 | 319 | ||
307 | // destroy fluxbox | 320 | // destroy fluxbox |