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 "CommandLine.hpp"
25 #include "Profile/Profile.hpp"
26 #include "OS/Args.hpp"
27 #include "OS/ConvertPathName.hpp"
28 #include "Hardware/Display.hpp"
29 #include "Simulator.hpp"
30 #include "LocalPath.hpp"
33 #include <windows.h> /* for AllocConsole() */
36 namespace CommandLine
{
37 #if !defined(_WIN32_WCE)
38 unsigned width
= 640, height
= 480;
41 #ifdef HAVE_CMDLINE_FULLSCREEN
42 bool full_screen
= false;
45 #ifdef HAVE_CMDLINE_RESIZABLE
46 bool resizable
= false;
51 CommandLine::Parse(Args
&args
)
53 while (!args
.IsEmpty()) {
54 const char *s
= args
.GetNext();
64 // Also accept "--" prefix for arguments. Usually used on UNIX for long options
68 if (strncmp(s
, "-profile=", 9) == 0) {
71 Profile::SetFiles(convert
);
72 } else if (strncmp(s
, "-datapath=", 10) == 0) {
75 SetPrimaryDataPath(convert
);
77 #ifdef SIMULATOR_AVAILABLE
78 else if (strcmp(s
, "-simulator") == 0) {
79 global_simulator_flag
= true;
80 sim_set_in_cmd_line_flag
= true;
82 else if (strcmp(s
, "-fly") == 0) {
83 global_simulator_flag
=false;
84 sim_set_in_cmd_line_flag
=true;
87 #if !defined(_WIN32_WCE)
88 else if (isdigit(s
[1])) {
90 width
= strtol(s
+1, &p
, 10);
91 if (*p
!= 'x' && *p
!= 'X')
94 height
= strtol(s
+1, &p
, 10);
96 else if (strcmp(s
, "-portrait") == 0) {
100 else if (strcmp(s
, "-square") == 0) {
104 else if (strcmp(s
, "-small") == 0) {
109 #ifdef HAVE_CMDLINE_FULLSCREEN
110 else if (strcmp(s
, "-fullscreen") == 0) {
114 #ifdef HAVE_CMDLINE_RESIZABLE
115 else if (strcmp(s
, "-resizable") == 0) {
119 #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__WINE__)
120 else if (strcmp(s
, "-console") == 0) {
122 freopen("CONOUT$", "wb", stdout
);
125 #if !defined(ANDROID) && !defined(_WIN32_WCE)
126 else if (strncmp(s
, "-dpi=", 5) == 0) {
127 unsigned x_dpi
, y_dpi
;
129 x_dpi
= strtol(s
+5, &p
, 10);
130 if (*p
== 'x' || *p
== 'X') {
132 y_dpi
= strtol(s
+1, &p
, 10);
136 if (x_dpi
< 32 || x_dpi
> 512 || y_dpi
< 32 || y_dpi
> 512)
139 Display::SetDPI(x_dpi
, y_dpi
);
148 #if !defined(_WIN32_WCE)
149 if (width
< 240 || width
> 4096 ||
150 height
< 240 || height
> 4096)