po: update French translation
[xcsoar.git] / src / VALI-XCS.cpp
blob15b752fae832910956e79476b4b09cdec3d9d155
1 /* Copyright_License {
3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 /* This creates the VALI-XCS.exe program
24 * This is a DOS program that is used by the OLC or a scorer in a contest
25 * to validate the GRecord of an XCSoar-generated IGC file
28 #include "OS/ConvertPathName.hpp"
29 #include "Logger/GRecord.hpp"
30 #include "Version.hpp"
32 #include <stdio.h>
33 #include <string.h>
34 #include <tchar.h>
36 #ifdef WIN32
37 #include <windows.h>
38 #endif
40 enum STATUS_t {
41 eValidationFailed,
42 eValidationPassed,
43 eValidationFileNotFound,
44 eValidationFileRead,
47 static const char szPass[] = "Validation check passed, data indicated as correct";
48 static const char szFail[] = "Validation check failed. G Record is invalid";
49 static const char szNoFile[] = "Validation check failed. File not found";
50 static const char szInfo[] = "Vali XCS for the XCSoar Flight Computer Version 1.0.2";
52 static STATUS_t
53 ValidateXCS(const TCHAR *FileName, GRecord &oGRecord)
55 STATUS_t eStatus = eValidationFileNotFound;
57 FILE *inFile = NULL;
58 inFile = _tfopen(FileName, _T("r"));
59 if (inFile == NULL)
60 return eStatus;
62 fclose(inFile);
64 eStatus = eValidationFailed;
66 oGRecord.Initialize();
67 if (oGRecord.VerifyGRecordInFile(FileName))
68 eStatus = eValidationPassed;
70 return eStatus;
73 static int
74 RunValidate(const TCHAR *path)
76 GRecord oGRecord;
77 STATUS_t eStatus = ValidateXCS(path, oGRecord);
78 switch (eStatus) {
79 case eValidationFailed:
80 puts(szFail);
81 return 0;
83 case eValidationPassed:
84 puts(szPass);
85 return 0; // success
87 case eValidationFileNotFound:
88 puts(szNoFile);
89 return 1;
91 default:
92 puts(szFail);
93 return 1;
97 int main(int argc, char* argv[])
99 printf("Vali XCS for the XCSoar Flight Computer Version "
100 #ifdef _UNICODE
101 "%S\n",
102 #else
103 "%s\n",
104 #endif
105 XCSoar_Version);
107 if (argc > 1 && strcmp(argv[1], "-?") != 0) {
108 PathName path(argv[1]);
109 return RunValidate(path);
110 } else
111 return 0;