aboutsummaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/main.cc b/src/main.cc
index 1c5e283..7b98597 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -39,21 +39,12 @@
39#define _GNU_SOURCE 39#define _GNU_SOURCE
40#endif // _GNU_SOURCE 40#endif // _GNU_SOURCE
41 41
42#ifdef HAVE_CSTDIO
43 #include <cstdio>
44#else
45 #include <stdio.h>
46#endif
47#ifdef HAVE_CSTDLIB 42#ifdef HAVE_CSTDLIB
48 #include <cstdlib> 43 #include <cstdlib>
49#else 44#else
50 #include <stdlib.h> 45 #include <stdlib.h>
51#endif 46#endif
52#ifdef HAVE_CSTRING 47
53 #include <cstring>
54#else
55 #include <string.h>
56#endif
57#include <iostream> 48#include <iostream>
58#include <fstream> 49#include <fstream>
59#include <stdexcept> 50#include <stdexcept>
@@ -199,17 +190,18 @@ int main(int argc, char **argv) {
199 190
200 int i; 191 int i;
201 for (i = 1; i < argc; ++i) { 192 for (i = 1; i < argc; ++i) {
202 if (! strcmp(argv[i], "-rc")) { 193 string arg(argv[i]);
194 if (arg == "-rc") {
203 // look for alternative rc file to use 195 // look for alternative rc file to use
204 196
205 if ((++i) >= argc) { 197 if ((++i) >= argc) {
206 cerr<<_FB_CONSOLETEXT(main, RCRequiresArg, 198 cerr<<_FB_CONSOLETEXT(main, RCRequiresArg,
207 "error: '-rc' requires an argument", "the -rc option requires a file argument")<<endl; 199 "error: '-rc' requires an argument", "the -rc option requires a file argument")<<endl;
208 exit(1); 200 exit(EXIT_FAILURE);
209 } 201 }
210 202
211 rc_file = argv[i]; 203 rc_file = arg;
212 } else if (! strcmp(argv[i], "-display")) { 204 } else if (arg == "-display") {
213 // check for -display option... to run on a display other than the one 205 // check for -display option... to run on a display other than the one
214 // set by the environment variable DISPLAY 206 // set by the environment variable DISPLAY
215 207
@@ -217,10 +209,10 @@ int main(int argc, char **argv) {
217 cerr<<_FB_CONSOLETEXT(main, DISPLAYRequiresArg, 209 cerr<<_FB_CONSOLETEXT(main, DISPLAYRequiresArg,
218 "error: '-display' requires an argument", 210 "error: '-display' requires an argument",
219 "")<<endl; 211 "")<<endl;
220 exit(1); 212 exit(EXIT_FAILURE);
221 } 213 }
222 214
223 session_display = argv[i]; 215 session_display = arg;
224 string display_env = "DISPLAY=" + session_display; 216 string display_env = "DISPLAY=" + session_display;
225 if (putenv(const_cast<char *>(display_env.c_str()))) { 217 if (putenv(const_cast<char *>(display_env.c_str()))) {
226 cerr<<_FB_CONSOLETEXT(main, WarnDisplayEnv, 218 cerr<<_FB_CONSOLETEXT(main, WarnDisplayEnv,
@@ -228,17 +220,17 @@ int main(int argc, char **argv) {
228 "")<<endl; 220 "")<<endl;
229 perror("putenv()"); 221 perror("putenv()");
230 } 222 }
231 } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "-v") == 0) { 223 } else if (arg == "-version" || arg == "-v") {
232 // print current version string 224 // print current version string
233 cout << "Fluxbox " << __fluxbox_version << " : (c) 2001-2007 Henrik Kinnunen " << endl << endl; 225 cout << "Fluxbox " << __fluxbox_version << " : (c) 2001-2007 Henrik Kinnunen " << endl << endl;
234 exit(0); 226 exit(EXIT_SUCCESS);
235 } else if (strcmp(argv[i], "-log") == 0 ) { 227 } else if (arg == "-log") {
236 if (i + 1 >= argc) { 228 if (i + 1 >= argc) {
237 cerr<<_FB_CONSOLETEXT(main, LOGRequiresArg, "error: '-log' needs an argument", "")<<endl; 229 cerr<<_FB_CONSOLETEXT(main, LOGRequiresArg, "error: '-log' needs an argument", "")<<endl;
238 exit(1); 230 exit(EXIT_FAILURE);
239 } 231 }
240 log_filename = argv[++i]; 232 log_filename = argv[++i];
241 } else if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-h") == 0) { 233 } else if (arg == "-help" || arg == "-h") {
242 // print program usage and command line options 234 // print program usage and command line options
243 printf(_FB_CONSOLETEXT(main, Usage, 235 printf(_FB_CONSOLETEXT(main, Usage,
244 "Fluxbox %s : (c) %s Henrik Kinnunen\n" 236 "Fluxbox %s : (c) %s Henrik Kinnunen\n"
@@ -253,11 +245,11 @@ int main(int argc, char **argv) {
253 245
254 "Main usage string. Please lay it out nicely. There is one %s that is given the version").c_str(), 246 "Main usage string. Please lay it out nicely. There is one %s that is given the version").c_str(),
255 __fluxbox_version, "2001-2007"); 247 __fluxbox_version, "2001-2007");
256 exit(0); 248 exit(EXIT_SUCCESS);
257 } else if (strcmp(argv[i], "-info") == 0 || strcmp(argv[i], "-i") == 0) { 249 } else if (arg == "-info" || arg == "-i") {
258 showInfo(cout); 250 showInfo(cout);
259 exit(0); 251 exit(EXIT_SUCCESS);
260 } else if (strcmp(argv[i], "-verbose") == 0) { 252 } else if (arg == "-verbose") {
261 FbTk::ThemeManager::instance().setVerbose(true); 253 FbTk::ThemeManager::instance().setVerbose(true);
262 } 254 }
263 } 255 }