test/...: use OS/Args.hpp
[xcsoar.git] / test / src / RunInputParser.cpp
blob517a3d91f0f15bc6c6ed8ea86835ecc552a81095
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "Input/InputParser.hpp"
25 #include "Input/InputConfig.hpp"
26 #include "Input/InputLookup.hpp"
27 #include "Menu/MenuData.hpp"
28 #include "IO/FileLineReader.hpp"
29 #include "OS/Args.hpp"
31 #include <stdio.h>
32 #include <tchar.h>
34 pt2Event
35 InputEvents::findEvent(const TCHAR *data)
37 union {
38 const TCHAR *in;
39 pt2Event out;
40 } u;
42 u.in = data;
43 return u.out;
46 int
47 InputEvents::findGCE(const TCHAR *data)
49 return -1;
52 int
53 InputEvents::findNE(const TCHAR *data)
55 return -1;
58 static void
59 Dump(InputConfig::Event &event, unsigned id)
61 _tprintf(_T(" Event[%u]: '%s' misc='%s'\n"), id,
62 (const TCHAR *)event.event, event.misc);
65 int main(int argc, char **argv)
67 Args args(argc, argv, "PATH");
68 const char *path = args.ExpectNext();
69 args.ExpectEnd();
71 FileLineReader reader(path);
72 if (reader.error()) {
73 fprintf(stderr, "Failed to open input file\n");
74 return 1;
77 InputConfig config;
78 config.SetDefaults();
79 ParseInputFile(config, reader);
81 for (unsigned mode = 0; mode < config.modes.size(); ++mode) {
82 _tprintf(_T("Mode '%s'\n"), config.modes[mode].c_str());
84 for (unsigned key = 0; key < InputConfig::MAX_KEY; ++key) {
85 unsigned event = config.Key2Event[mode][key];
86 assert(event < InputConfig::MAX_EVENTS);
87 if (event == 0)
88 continue;
90 printf(" Key 0x%x\n", key);
91 do {
92 Dump(config.events[event], event);
93 assert(config.events[event].next < InputConfig::MAX_EVENTS);
94 event = config.events[event].next;
95 } while (event > 0);
98 for (unsigned i = 0; i < Menu::MAX_ITEMS; ++i) {
99 const MenuItem &mi = config.menus[mode][i];
100 if (mi.IsDefined()) {
101 _tprintf(_T(" Menu[%u] = '%s'\n"), i, mi.label);
102 unsigned event = mi.event;
103 assert(event < InputConfig::MAX_EVENTS);
104 do {
105 Dump(config.events[event], event);
106 assert(config.events[event].next < InputConfig::MAX_EVENTS);
107 event = config.events[event].next;
108 } while (event > 0);
113 return 0;