This commit is contained in:
fluxgen 2002-03-08 12:21:46 +00:00
parent c92e9899e9
commit 91d51a4d16

View file

@ -22,42 +22,42 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: main.cc,v 1.4 2002/02/02 21:54:31 pekdon Exp $ // $Id: main.cc,v 1.5 2002/03/08 12:21:46 fluxgen Exp $
// stupid macros needed to access some functions in version 2 of the GNU C // stupid macros needed to access some functions in version 2 of the GNU C
// library // library
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#endif // _GNU_SOURCE #endif // _GNU_SOURCE
#include "../version.h" #include "../version.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "../config.h" # include "../config.h"
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
#include "i18n.hh" #include "i18n.hh"
#include "fluxbox.hh" #include "fluxbox.hh"
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
# include <stdio.h> # include <stdio.h>
#endif // HAVE_STDIO_H #endif // HAVE_STDIO_H
#ifdef STDC_HEADERS #ifdef STDC_HEADERS
# include <stdlib.h> # include <stdlib.h>
# include <string.h> # include <string.h>
#endif // STDC_HEADERS #endif // STDC_HEADERS
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <sys/types.h> #include <sys/types.h>
#endif // HAVE_UNISTD_H #endif // HAVE_UNISTD_H
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
# include <sys/param.h> # include <sys/param.h>
#endif // HAVE_SYS_PARAM_H #endif // HAVE_SYS_PARAM_H
#ifndef MAXPATHLEN #ifndef MAXPATHLEN
#define MAXPATHLEN 255 #define MAXPATHLEN 255
#endif // MAXPATHLEN #endif // MAXPATHLEN
#include <iostream> #include <iostream>
@ -72,6 +72,17 @@ using namespace std;
uds::uds_flags_t uds::flags = uds::leak_check; uds::uds_flags_t uds::flags = uds::leak_check;
#endif //!DEBUG_UDS #endif //!DEBUG_UDS
const char *getNLSYesNoMsg(bool val) {
if (val) {
return I18n::instance()->getMessage(
CommonSet, CommonYes,
"yes");
}
return I18n::instance()->getMessage(
CommonSet, CommonNo,
"no");
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef DEBUG_UDS #ifdef DEBUG_UDS
@ -91,192 +102,114 @@ int main(int argc, char **argv) {
if ((++i) >= argc) { if ((++i) >= argc) {
fprintf(stderr, fprintf(stderr,
i18n->getMessage( i18n->getMessage(
#ifdef NLS mainSet, mainRCRequiresArg,
mainSet, mainRCRequiresArg, "error: '-rc' requires and argument\n"));
#else // !NLS exit(1);
0, 0, }
#endif // NLS
"error: '-rc' requires and argument\n"));
::exit(1);
}
rc_file = argv[i]; rc_file = argv[i];
} else if (! strcmp(argv[i], "-display")) { } else if (! strcmp(argv[i], "-display")) {
// check for -display option... to run on a display other than the one // check for -display option... to run on a display other than the one
// set by the environment variable DISPLAY // set by the environment variable DISPLAY
if ((++i) >= argc) { if ((++i) >= argc) {
fprintf(stderr, fprintf(stderr,
i18n->getMessage( i18n->getMessage(
#ifdef NLS mainSet, mainDISPLAYRequiresArg,
mainSet, mainDISPLAYRequiresArg, "error: '-display' requires an argument\n"));
#else // !NLS exit(1);
0, 0, }
#endif // NLS
"error: '-display' requires an argument\n"));
::exit(1); session_display = argv[i];
} char dtmp[MAXPATHLEN];
sprintf(dtmp, "DISPLAY=%s", session_display);
session_display = argv[i]; if (putenv(dtmp)) {
char dtmp[MAXPATHLEN];
sprintf(dtmp, "DISPLAY=%s", session_display);
if (putenv(dtmp)) {
fprintf(stderr, fprintf(stderr,
i18n-> i18n->
getMessage( getMessage(
#ifdef NLS mainSet, mainWarnDisplaySet,
mainSet, mainWarnDisplaySet, "warning: couldn't set environment variable 'DISPLAY'\n"));
#else // !NLS
0, 0,
#endif // NLS
"warning: couldn't set environment variable 'DISPLAY'\n"));
perror("putenv()"); perror("putenv()");
} }
} else if (! strcmp(argv[i], "-version")) { } else if (! strcmp(argv[i], "-version")) {
// print current version string // print current version string
printf("Fluxbox %s : (c) 2001-2002 Henrik Kinnunen \n\n", printf("Fluxbox %s : (c) 2001-2002 Henrik Kinnunen \n\n",
__fluxbox_version); __fluxbox_version);
::exit(0); exit(0);
} else if (! strcmp(argv[i], "-help")) { } else if (! strcmp(argv[i], "-help")) {
// print program usage and command line options // print program usage and command line options
printf(i18n-> printf(i18n->
getMessage( getMessage(
#ifdef NLS
mainSet, mainUsage, mainSet, mainUsage,
#else // !NLS
0, 0,
#endif // NLS
"Fluxbox %s : (c) 2001-2002 Henrik Kinnunen\n\n" "Fluxbox %s : (c) 2001-2002 Henrik Kinnunen\n\n"
" -display <string>\t\tuse display connection.\n" " -display <string>\t\tuse display connection.\n"
" -rc <string>\t\t\tuse alternate resource file.\n" " -rc <string>\t\t\tuse alternate resource file.\n"
" -version\t\t\tdisplay version and exit.\n" " -version\t\t\tdisplay version and exit.\n"
" -help\t\t\t\tdisplay this help text and exit.\n\n"), " -help\t\t\t\tdisplay this help text and exit.\n\n"),
__fluxbox_version); __fluxbox_version);
// some people have requested that we print out command line options // some people have requested that we print out command line options
// as well // as well
printf(i18n-> printf(i18n->
getMessage( getMessage(
#ifdef NLS #ifdef NLS
mainSet, mainCompileOptions, mainSet, mainCompileOptions,
#else // !NLS #else // !NLS
0, 0, 0, 0,
#endif // NLS #endif // NLS
"Compile time options:\n" "Compile time options:\n"
" Debugging:\t\t\t%s\n" " Debugging:\t\t\t%s\n"
" Interlacing:\t\t\t%s\n" " Interlacing:\t\t\t%s\n"
" Shape:\t\t\t%s\n" " Shape:\t\t\t%s\n"
" Slit:\t\t\t\t%s\n" " Slit:\t\t\t\t%s\n"
" 8bpp Ordered Dithering:\t%s\n\n"), " 8bpp Ordered Dithering:\t%s\n\n"),
#ifdef DEBUG #ifdef DEBUG
i18n->getMessage( getNLSYesNoMsg(true),
#ifdef NLS #else // !DEBUG
CommonSet, CommonYes, getNLSYesNoMsg(false),
#else // !NLS #endif // DEBUG
0, 0,
#endif // NLS
"yes"),
#else // !DEBUG
i18n->getMessage(
#ifdef NLS
CommonSet, CommonNo,
#else // !NLS
0, 0,
#endif // NLS
"no"),
#endif // DEBUG
#ifdef INTERLACE #ifdef INTERLACE
i18n->getMessage( getNLSYesNoMsg(true),
#ifdef NLS #else // !INTERLACE
CommonSet, CommonYes, getNLSYesNoMsg(false),
#else // !NLS #endif // INTERLACE
0, 0,
#endif // NLS
"yes"),
#else // !INTERLACE
i18n->getMessage(
#ifdef NLS
CommonSet, CommonNo,
#else // !NLS
0, 0,
#endif // NLS
"no"),
#endif // INTERLACE
#ifdef SHAPE #ifdef SHAPE
i18n->getMessage( getNLSYesNoMsg(true),
#ifdef NLS #else // !SHAPE
CommonSet, CommonYes, getNLSYesNoMsg(false),
#else // !NLS #endif // SHAPE
0, 0,
#endif // NLS
"yes"),
#else // !SHAPE
i18n->getMessage(
#ifdef NLS
CommonSet, CommonNo,
#else // !NLS
0, 0,
#endif // NLS
"no"),
#endif // SHAPE
#ifdef SLIT #ifdef SLIT
i18n->getMessage( getNLSYesNoMsg(true),
#ifdef NLS #else // !SLIT
CommonSet, CommonYes, getNLSYesNoMsg(false),
#else // !NLS #endif // SLIT
0, 0,
#endif // NLS
"yes"),
#else // !SLIT
i18n->getMessage(
#ifdef NLS
CommonSet, CommonNo,
#else // !NLS
0, 0,
#endif // NLS
"no"),
#endif // SLIT
#ifdef ORDEREDPSEUDO #ifdef ORDEREDPSEUDO
i18n->getMessage( getNLSYesNoMsg(true)
#ifdef NLS #else // !ORDEREDPSEUDO
CommonSet, CommonYes, getNLSYesNoMsg(false)
#else // !NLS #endif // ORDEREDPSEUDO
0, 0,
#endif // NLS
"yes")
#else // !ORDEREDPSEUDO
i18n->getMessage(
#ifdef NLS
CommonSet, CommonNo,
#else // !NLS
0, 0,
#endif // NLS
"no")
#endif // ORDEREDPSEUDO
); );
::exit(0); ::exit(0);
} }
} }
#ifdef __EMX__ #ifdef __EMX__
_chdir2(getenv("X11ROOT")); _chdir2(getenv("X11ROOT"));
#endif // __EMX__ #endif // __EMX__
Fluxbox *fluxbox=0; Fluxbox *fluxbox=0;
int exitcode=EXIT_SUCCESS; int exitcode=EXIT_SUCCESS;
try { try {
fluxbox = new Fluxbox(argc, argv, session_display, rc_file); fluxbox = new Fluxbox(argc, argv, session_display, rc_file);
fluxbox->eventLoop(); fluxbox->eventLoop();
} catch (int _exitcode) { } catch (int _exitcode) {
@ -287,5 +220,5 @@ int main(int argc, char **argv) {
if (fluxbox) if (fluxbox)
delete fluxbox; delete fluxbox;
exit(exitcode); exit(exitcode);
} }