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