]> icculus.org git repositories - dana/openbox.git/blob - src/main.cc
libtool stuff
[dana/openbox.git] / src / main.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2
3 #include "../version.h"
4
5 #ifdef    HAVE_CONFIG_H
6 #  include "../config.h"
7 #endif // HAVE_CONFIG_H
8
9 extern "C" {
10 #ifdef    HAVE_STDIO_H
11 #  include <stdio.h>
12 #endif // HAVE_STDIO_H
13
14 #ifdef HAVE_STDLIB_H
15 #  include <stdlib.h>
16 #endif // HAVE_STDLIB_H
17
18 #ifdef HAVE_STRING_H
19 #  include <string.h>
20 #endif // HAVE_STRING_H
21
22 #ifdef    HAVE_UNISTD_H
23 #include <sys/types.h>
24 #endif // HAVE_UNISTD_H
25
26 #ifdef    HAVE_SYS_PARAM_H
27 #  include <sys/param.h>
28 #endif // HAVE_SYS_PARAM_H
29 }
30
31 #include <string>
32 using std::string;
33
34 #include "blackbox.hh"
35
36
37 static void showHelp(int exitval) {
38   // print program usage and command line options
39   printf("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
40          "  -display <string>\t\tuse display connection.\n"
41          "  -rc <string>\t\t\tuse alternate resource file.\n"
42          "  -menu <string>\t\tuse alternate menu file.\n"
43          "  -version\t\t\tdisplay version and exit.\n"
44          "  -help\t\t\t\tdisplay this help text and exit.\n\n",
45          OPENBOX_VERSION);
46
47   // some people have requested that we print out compile options
48   // as well
49   printf("Compile time options:\n"
50          "  Debugging:\t\t\t%s\n"
51          "  Shape:\t\t\t%s\n"
52          "  Xft:\t\t\t\t%s\n"
53          "  Xinerama:\t\t\t%s\n"
54          "  8bpp Ordered Dithering:\t%s\n\n",
55 #ifdef    DEBUG
56          "yes",
57 #else // !DEBUG
58          "no",
59 #endif // DEBUG
60
61 #ifdef    SHAPE
62          "yes",
63 #else // !SHAPE
64          "no",
65 #endif // SHAPE
66
67 #ifdef    XFT
68          "yes",
69 #else // !XFT
70          "no",
71 #endif // XFT
72
73 #ifdef    XINERAMA
74          "yes",
75 #else // !XINERAMA
76          "no",
77 #endif // XINERAMA
78
79 #ifdef    ORDEREDPSEUDO
80          "yes"
81 #else // !ORDEREDPSEUDO
82          "no"
83 #endif // ORDEREDPSEUDO
84           );
85
86   ::exit(exitval);
87 }
88
89 int main(int argc, char **argv) {
90   char *session_display = (char *) 0;
91   char *rc_file = (char *) 0;
92   char *menu_file = (char *) 0;
93
94   for (int i = 1; i < argc; ++i) {
95     if (! strcmp(argv[i], "-rc")) {
96       // look for alternative rc file to use
97
98       if ((++i) >= argc) {
99         fprintf(stderr, "error: '-rc' requires and argument\n");
100
101         ::exit(1);
102       }
103
104       rc_file = argv[i];
105     } else if (! strcmp(argv[i], "-menu")) {
106       // look for alternative menu file to use
107
108       if ((++i) >= argc) {
109         fprintf(stderr, "error: '-menu' requires and argument\n");
110
111         ::exit(1);
112       }
113
114       menu_file = argv[i];
115     } else if (! strcmp(argv[i], "-display")) {
116       // check for -display option... to run on a display other than the one
117       // set by the environment variable DISPLAY
118
119       if ((++i) >= argc) {
120         fprintf(stderr, "error: '-display' requires an argument\n");
121
122         ::exit(1);
123       }
124
125       session_display = argv[i];
126       string dtmp = "DISPLAY=";
127       dtmp += session_display;
128
129       if (putenv(const_cast<char*>(dtmp.c_str()))) {
130         fprintf(stderr,
131                 "warning: couldn't set environment variable 'DISPLAY'\n");
132         perror("putenv()");
133       }
134     } else if (! strcmp(argv[i], "-version")) {
135       // print current version string
136       printf("Openbox %s : (c) 2002 - 2002 Ben Jansens\n",
137              OPENBOX_VERSION);
138
139       ::exit(0);
140     } else if (! strcmp(argv[i], "-help")) {
141       showHelp(0);
142     } else { // invalid command line option
143       showHelp(-1);
144     }
145   }
146
147 #ifdef    __EMX__
148   _chdir2(getenv("X11ROOT"));
149 #endif // __EMX__
150
151   Blackbox blackbox(argv, session_display, rc_file);
152   blackbox.eventLoop();
153
154   return(0);
155 }