aboutsummaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc309
1 files changed, 128 insertions, 181 deletions
diff --git a/src/main.cc b/src/main.cc
index 19ed631..0ab2b24 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -1,3 +1,6 @@
1// main.cc for Fluxbox Window manager
2// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3//
1// main.cc for Blackbox - an X11 Window manager 4// main.cc for Blackbox - an X11 Window manager
2// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) 5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3// 6//
@@ -19,46 +22,72 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
21 24
22// stupid macros needed to access some functions in version 2 of the GNU C 25// $Id: main.cc,v 1.6 2002/04/04 11:28:19 fluxgen Exp $
23// library 26
24#ifndef _GNU_SOURCE 27//use GNU extensions
25#define _GNU_SOURCE 28#ifndef _GNU_SOURCE
29#define _GNU_SOURCE
26#endif // _GNU_SOURCE 30#endif // _GNU_SOURCE
27 31
28#include "../version.h" 32#include "../version.h"
29 33
30#ifdef HAVE_CONFIG_H 34#ifdef HAVE_CONFIG_H
31# include "../config.h" 35# include "../config.h"
32#endif // HAVE_CONFIG_H 36#endif // HAVE_CONFIG_H
33 37
34#include "i18n.hh" 38#include "i18n.hh"
35#include "fluxbox.hh" 39#include "fluxbox.hh"
36 40
37#ifdef HAVE_STDIO_H 41#ifdef HAVE_STDIO_H
38# include <stdio.h> 42# include <stdio.h>
39#endif // HAVE_STDIO_H 43#endif // HAVE_STDIO_H
40 44
41#ifdef STDC_HEADERS 45#ifdef STDC_HEADERS
42# include <stdlib.h> 46# include <stdlib.h>
43# include <string.h> 47# include <string.h>
44#endif // STDC_HEADERS 48#endif // STDC_HEADERS
45 49
46#ifdef HAVE_UNISTD_H 50#ifdef HAVE_UNISTD_H
47#include <sys/types.h> 51#include <sys/types.h>
48#endif // HAVE_UNISTD_H 52#endif // HAVE_UNISTD_H
49 53
50#ifdef HAVE_SYS_PARAM_H 54#ifdef HAVE_SYS_PARAM_H
51# include <sys/param.h> 55# include <sys/param.h>
52#endif // HAVE_SYS_PARAM_H 56#endif // HAVE_SYS_PARAM_H
53 57
54#ifndef MAXPATHLEN 58#ifndef MAXPATHLEN
55#define MAXPATHLEN 255 59#define MAXPATHLEN 255
56#endif // MAXPATHLEN 60#endif // MAXPATHLEN
57 61
58#include <iostream> 62#include <iostream>
59using namespace std; 63using namespace std;
60 64
65#ifdef DEBUG_UDS
66
67#include <uds/init.hh>
68#include <uds/uds.hh>
69
70// configure UDS
71uds::uds_flags_t uds::flags = uds::leak_check;
72
73#endif //!DEBUG_UDS
74const char *getNLSYesNoMsg(bool val) {
75 if (val) {
76 return I18n::instance()->getMessage(
77 FBNLS::CommonSet, FBNLS::CommonYes,
78 "yes");
79 }
80
81 return I18n::instance()->getMessage(
82 FBNLS::CommonSet, FBNLS::CommonNo,
83 "no");
84}
85
61int main(int argc, char **argv) { 86int main(int argc, char **argv) {
87 #ifdef DEBUG_UDS
88 uds::Init uds_init;
89 #endif //!DEBUG_UDS
90
62 char *session_display = (char *) 0; 91 char *session_display = (char *) 0;
63 char *rc_file = (char *) 0; 92 char *rc_file = (char *) 0;
64 93
@@ -72,192 +101,110 @@ int main(int argc, char **argv) {
72 101
73 if ((++i) >= argc) { 102 if ((++i) >= argc) {
74 fprintf(stderr, 103 fprintf(stderr,
75 i18n->getMessage( 104 i18n->getMessage(
76#ifdef NLS 105 FBNLS::mainSet, FBNLS::mainRCRequiresArg,
77 mainSet, mainRCRequiresArg, 106 "error: '-rc' requires and argument\n"));
78#else // !NLS 107 exit(1);
79 0, 0, 108 }
80#endif // NLS
81 "error: '-rc' requires and argument\n"));
82
83 ::exit(1);
84 }
85 109
86 rc_file = argv[i]; 110 rc_file = argv[i];
87 } else if (! strcmp(argv[i], "-display")) { 111 } else if (! strcmp(argv[i], "-display")) {
88 // check for -display option... to run on a display other than the one 112 // check for -display option... to run on a display other than the one
89 // set by the environment variable DISPLAY 113 // set by the environment variable DISPLAY
90 114
91 if ((++i) >= argc) { 115 if ((++i) >= argc) {
92 fprintf(stderr, 116 fprintf(stderr,
93 i18n->getMessage( 117 i18n->getMessage(
94#ifdef NLS 118 FBNLS::mainSet, FBNLS::mainDISPLAYRequiresArg,
95 mainSet, mainDISPLAYRequiresArg, 119 "error: '-display' requires an argument\n"));
96#else // !NLS 120 exit(1);
97 0, 0, 121 }
98#endif // NLS
99 "error: '-display' requires an argument\n"));
100
101 ::exit(1);
102 }
103 122
104 session_display = argv[i]; 123 session_display = argv[i];
105 char dtmp[MAXPATHLEN]; 124 char dtmp[MAXPATHLEN];
106 sprintf(dtmp, "DISPLAY=%s", session_display); 125 sprintf(dtmp, "DISPLAY=%s", session_display);
107 126
108 if (putenv(dtmp)) { 127 if (putenv(dtmp)) {
109 fprintf(stderr, 128 fprintf(stderr,
110 i18n-> 129 i18n->
111 getMessage( 130 getMessage(
112#ifdef NLS 131 FBNLS::mainSet, FBNLS::mainWarnDisplaySet,
113 mainSet, mainWarnDisplaySet, 132 "warning: couldn't set environment variable 'DISPLAY'\n"));
114#else // !NLS
115 0, 0,
116#endif // NLS
117 "warning: couldn't set environment variable 'DISPLAY'\n"));
118 perror("putenv()"); 133 perror("putenv()");
119 } 134 }
120 } else if (! strcmp(argv[i], "-version")) { 135 } else if (! strcmp(argv[i], "-version")) {
121 // print current version string 136 // print current version string
122 printf("Fluxbox %s : (c) 2001 Henrik Kinnunen \n\n", 137 printf("Fluxbox %s : (c) 2001-2002 Henrik Kinnunen \n\n",
123 __fluxbox_version); 138 __fluxbox_version);
124 139
125 ::exit(0); 140 exit(0);
126 } else if (! strcmp(argv[i], "-help")) { 141 } else if (! strcmp(argv[i], "-help")) {
127 // print program usage and command line options 142 // print program usage and command line options
128 printf(i18n-> 143 printf(i18n->
129 getMessage( 144 getMessage(
130#ifdef NLS 145 FBNLS::mainSet, FBNLS::mainUsage,
131 mainSet, mainUsage, 146 "Fluxbox %s : (c) 2001-2002 Henrik Kinnunen\n\n"
132#else // !NLS 147 " -display <string>\t\tuse display connection.\n"
133 0, 0, 148 " -rc <string>\t\t\tuse alternate resource file.\n"
134#endif // NLS 149 " -version\t\t\tdisplay version and exit.\n"
135 "Fluxbox %s : (c) 2001 Henrik Kinnunen\n\n" 150 " -help\t\t\t\tdisplay this help text and exit.\n\n"),
136 " -display <string>\t\tuse display connection.\n" 151 __fluxbox_version);
137 " -rc <string>\t\t\tuse alternate resource file.\n" 152
138 " -version\t\t\tdisplay version and exit.\n" 153 // some people have requested that we print out command line options
139 " -help\t\t\t\tdisplay this help text and exit.\n\n"), 154 // as well
140 __fluxbox_version); 155 printf(i18n->
141 156 getMessage(
142 // some people have requested that we print out command line options 157 FBNLS::mainSet, FBNLS::mainCompileOptions,
143 // as well
144 printf(i18n->
145 getMessage(
146#ifdef NLS
147 mainSet, mainCompileOptions,
148#else // !NLS
149 0, 0,
150#endif // NLS
151 "Compile time options:\n" 158 "Compile time options:\n"
152 " Debugging:\t\t\t%s\n" 159 " Debugging:\t\t\t%s\n"
153 " Interlacing:\t\t\t%s\n" 160 " Interlacing:\t\t\t%s\n"
154 " Shape:\t\t\t%s\n" 161 " Shape:\t\t\t%s\n"
155 " Slit:\t\t\t\t%s\n" 162 " Slit:\t\t\t\t%s\n"
156 " 8bpp Ordered Dithering:\t%s\n\n"), 163 " 8bpp Ordered Dithering:\t%s\n\n"),
157#ifdef DEBUG 164 #ifdef DEBUG
158 i18n->getMessage( 165 getNLSYesNoMsg(true),
159#ifdef NLS 166 #else // !DEBUG
160 CommonSet, CommonYes, 167 getNLSYesNoMsg(false),
161#else // !NLS 168 #endif // DEBUG
162 0, 0, 169
163#endif // NLS 170 #ifdef INTERLACE
164 "yes"), 171 getNLSYesNoMsg(true),
165#else // !DEBUG 172 #else // !INTERLACE
166 i18n->getMessage( 173 getNLSYesNoMsg(false),
167#ifdef NLS 174 #endif // INTERLACE
168 CommonSet, CommonNo, 175
169#else // !NLS 176 #ifdef SHAPE
170 0, 0, 177 getNLSYesNoMsg(true),
171#endif // NLS 178 #else // !SHAPE
172 "no"), 179 getNLSYesNoMsg(false),
173#endif // DEBUG 180 #endif // SHAPE
174 181
175#ifdef INTERLACE 182 #ifdef SLIT
176 i18n->getMessage( 183 getNLSYesNoMsg(true),
177#ifdef NLS 184 #else // !SLIT
178 CommonSet, CommonYes, 185 getNLSYesNoMsg(false),
179#else // !NLS 186 #endif // SLIT
180 0, 0, 187
181#endif // NLS 188 #ifdef ORDEREDPSEUDO
182 "yes"), 189 getNLSYesNoMsg(true)
183#else // !INTERLACE 190 #else // !ORDEREDPSEUDO
184 i18n->getMessage( 191 getNLSYesNoMsg(false)
185#ifdef NLS 192 #endif // ORDEREDPSEUDO
186 CommonSet, CommonNo, 193
187#else // !NLS 194 );
188 0, 0, 195
189#endif // NLS 196 ::exit(0);
190 "no"), 197 }
191#endif // INTERLACE 198 }
192
193#ifdef SHAPE
194 i18n->getMessage(
195#ifdef NLS
196 CommonSet, CommonYes,
197#else // !NLS
198 0, 0,
199#endif // NLS
200 "yes"),
201#else // !SHAPE
202 i18n->getMessage(
203#ifdef NLS
204 CommonSet, CommonNo,
205#else // !NLS
206 0, 0,
207#endif // NLS
208 "no"),
209#endif // SHAPE
210
211#ifdef SLIT
212 i18n->getMessage(
213#ifdef NLS
214 CommonSet, CommonYes,
215#else // !NLS
216 0, 0,
217#endif // NLS
218 "yes"),
219#else // !SLIT
220 i18n->getMessage(
221#ifdef NLS
222 CommonSet, CommonNo,
223#else // !NLS
224 0, 0,
225#endif // NLS
226 "no"),
227#endif // SLIT
228
229#ifdef ORDEREDPSEUDO
230 i18n->getMessage(
231#ifdef NLS
232 CommonSet, CommonYes,
233#else // !NLS
234 0, 0,
235#endif // NLS
236 "yes")
237#else // !ORDEREDPSEUDO
238 i18n->getMessage(
239#ifdef NLS
240 CommonSet, CommonNo,
241#else // !NLS
242 0, 0,
243#endif // NLS
244 "no")
245#endif // ORDEREDPSEUDO
246
247 );
248
249 ::exit(0);
250 }
251 }
252 199
253#ifdef __EMX__ 200#ifdef __EMX__
254 _chdir2(getenv("X11ROOT")); 201 _chdir2(getenv("X11ROOT"));
255#endif // __EMX__ 202#endif // __EMX__
256 Fluxbox *fluxbox=0; 203 Fluxbox *fluxbox=0;
257 int exitcode=EXIT_SUCCESS; 204 int exitcode=EXIT_SUCCESS;
258 try { 205 try {
259 206
260 fluxbox = new Fluxbox(argc, argv, session_display, rc_file); 207 fluxbox = new Fluxbox(argc, argv, session_display, rc_file);
261 fluxbox->eventLoop(); 208 fluxbox->eventLoop();
262 209
263 } catch (int _exitcode) { 210 } catch (int _exitcode) {
@@ -268,5 +215,5 @@ int main(int argc, char **argv) {
268 215
269 if (fluxbox) 216 if (fluxbox)
270 delete fluxbox; 217 delete fluxbox;
271 exit(exitcode); 218 exit(exitcode);
272} 219}