aboutsummaryrefslogtreecommitdiff
path: root/src/tests/testKeys.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/testKeys.cc')
-rw-r--r--src/tests/testKeys.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/tests/testKeys.cc b/src/tests/testKeys.cc
new file mode 100644
index 0000000..27873e0
--- /dev/null
+++ b/src/tests/testKeys.cc
@@ -0,0 +1,67 @@
1// testKeys.cc
2// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22#include "../Keys.hh"
23#include <iostream>
24#include <X11/Xlib.h>
25
26
27#ifdef UDS
28#include <uds/init.hh>
29#include <uds/uds.hh>
30// configure UDS
31uds::uds_flags_t uds::flags = uds::leak_check|uds::log_allocs;
32#endif
33
34using namespace std;
35
36void testKeys(int argc, char **argv) {
37 Display *display = XOpenDisplay(0);
38
39 if (display==0) {
40 cerr<<"Cant open display."<<endl;
41 return;
42 }
43
44 Keys *keys = new Keys(display);
45 const char default_keyfile[] = "keys";
46
47 if (argc>1) {
48 cerr<<"Loading file: "<<argv[1]<<endl;
49 keys->load(const_cast<char *>(argv[1]));
50 } else {
51 cerr<<"Using default file: "<<default_keyfile<<endl;
52 keys->load(const_cast<char *>(default_keyfile));
53 }
54
55 keys->load(const_cast<char *>(default_keyfile));
56
57 delete keys;
58
59 XCloseDisplay(display);
60}
61
62int main(int argc, char **argv) {
63#ifdef UDS
64 uds::Init uds_init;
65#endif
66 testKeys(argc, argv);
67}