"Fossies" - the Fresh Open Source Software Archive 
Member "bbkeys-0.9.1/src/main.cpp" (22 Dec 2008, 3581 Bytes) of package /linux/privat/old/bbkeys-0.9.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "main.cpp" see the
Fossies "Dox" file reference documentation.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // -- main.cpp --
3 // Copyright (c) 2001 - 2003 Jason 'vanRijn' Kasper <vR at movingparts dot net>
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
22
23 // E_O_H_VR
24
25 #include "KeyClient.h"
26 #include "version.h"
27 #include <string.h>
28
29 #include "main.h"
30
31 //--------------------------------------------------------
32 // parseOptions
33 //--------------------------------------------------------
34 void parseOptions (int argc, char **argv, Config & _config)
35 {
36
37 for (int i = 1; i < argc; i++) {
38 if ( (!strcmp(argv[i], "-d"))
39 || (!strcmp(argv[i], "--display")) ) {
40 if (++i == argc) {
41 usage();
42 exit(2);
43 };
44 _config.setOption("display", argv[i]);
45
46 // Applications we exec will need the proper display
47 string disp = (string)"DISPLAY=" + argv[i];
48 putenv((char *)disp.c_str());
49
50 } else if ((!strcmp(argv[i], "--config")) ||
51 (!strcmp(argv[i], "-c"))) {
52 if (++i == argc) {
53 usage();
54 exit(2);
55 };
56 _config.setOption("config", argv[i]);
57
58 } else if ((!strcmp(argv[i], "-D"))
59 || (!strcmp(argv[i], "--debug"))) {
60 _config.setOption("debug", "true");
61 } else if ((!strcmp(argv[i], "-v"))
62 || (!strcmp(argv[i], "--version"))) {
63 cout << BBTOOL << " version: [" << BBTOOL_VERSION << "]" << endl;
64 exit(2);
65 } else if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "-help"))) {
66 usage();
67 exit(2);
68
69 } else {
70 usage();
71 exit(2);
72 };
73
74 }
75 }
76
77 void usage() {
78
79 cout << BBTOOL << " version: [" << BBTOOL_VERSION << "]" << endl
80 << "Usage: " << BBTOOL << " [options]" << endl
81 << "Options:" << endl
82 << " -d or --display <display name> X server to connect to" << endl
83 << " -D or --debug print debugging information" << endl
84 << " -c or --config <filename> configuration file" << endl
85 << " (default is ~/.bbkeysrc)" << endl
86 << " -v or --version Display version number" << endl
87 << " -h or --help Display this help" << endl;
88 }
89
90
91
92 int main(int argc, char **argv)
93 {
94 Config * _config = new Config();
95 parseOptions(argc, argv, *_config);
96
97 std::string dpy_name = _config->getStringValue("display",
98 getenv("DISPLAY"));
99
100
101 KeyClient * _k=new KeyClient(argc, argv, *_config, dpy_name);
102 _k->run();
103
104 delete _k;
105 delete _config;
106
107 return 0;
108 }