Skip to content

Commit

Permalink
Add 64bit build settings
Browse files Browse the repository at this point in the history
  • Loading branch information
fboes committed Apr 2, 2019
1 parent 2bf6c6c commit 4cf5d3d
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Change log
==========

* 💊 Remove unsecure functions
* 🎁 Add 64bit build settings

1.1.1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The <i>Aerofly Wettergerät</i> is capable of setting weather values which you c
Requirements
------------

* Microsoft Windows 10 has to be installed. See below for other operating systems.
* Microsoft Windows 10 - 64 bit has to be installed. See below for other operating systems.
* IPACS Aerofly FS 2 has to be installed.
* A `main.mcf` has to be located at `%USERPROFILE%\Documents\Aerofly FS2\main.mcf`. If this is not the case point the tool to the file location by setting the `--file <FILE>` parameter.
* An internet connection to the [AVWX REST API](http://avwx.rest/) is required. If there is an internet connection but AVWX is not reachable, start the tool with the `--url <URL>` parameter set to a different METAR REST API.
Expand Down
14 changes: 7 additions & 7 deletions src/MetarParserSimple/MetarParserSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,16 @@ double MetarParserSimple::getHumidity()
void MetarParserSimple::setDate(short day, short hours, short minutes)
{
time_t rawtime;
struct tm * ptm;
struct tm ptm;

time(&rawtime);

ptm = gmtime(&rawtime);
this->observed.year = ptm->tm_year + 1900;
this->observed.month = ptm->tm_mon + 1;
this->observed.day = (day >= 0) ? day : ptm->tm_mday;
this->observed.hours = (hours >= 0) ? hours : ptm->tm_hour;
this->observed.minutes = (minutes >= 0) ? minutes : ptm->tm_min;
gmtime_s(&ptm, &rawtime);
this->observed.year = ptm.tm_year + 1900;
this->observed.month = ptm.tm_mon + 1;
this->observed.day = (day >= 0) ? day : ptm.tm_mday;
this->observed.hours = (hours >= 0) ? hours : ptm.tm_hour;
this->observed.minutes = (minutes >= 0) ? minutes : ptm.tm_min;
this->fixTimeDate();
}

Expand Down
1 change: 0 additions & 1 deletion src/MetarParserSimple/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#pragma once

#define _CRT_SECURE_NO_WARNINGS
#include "targetver.h"

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
Expand Down
10 changes: 6 additions & 4 deletions src/WettergeraetCli/WettergeraetCli.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@
COPY "$(SolutionDir)*.txt" "$(TargetDir)"
MKDIR "$(TargetDir)docs\"
COPY "$(SolutionDir)docs\" "$(TargetDir)docs\"
DEL "$(TargetDir)..\aerofly-wettergeraet.zip"
"C:\Program Files\7-Zip\7z.exe" a "$(TargetDir)..\aerofly-wettergeraet.zip" "$(TargetDir)*" -r "-x!*.iobj" "-x!*.ipdb" "-x!*.pdb" "-x!*.exp" "-x!*.lib" "-x!Test*"</Command>
SET ZIPFILE="$(TargetDir)..\..\aerofly-wettergeraet-$(Platform).zip"
DEL %ZIPFILE%
"C:\Program Files\7-Zip\7z.exe" a %ZIPFILE% "$(TargetDir)*" -r "-x!*.iobj" "-x!*.ipdb" "-x!*.pdb" "-x!*.exp" "-x!*.lib" "-x!Test*"</Command>
<Message>Build final ZIP</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
Expand Down Expand Up @@ -180,8 +181,9 @@ DEL "$(TargetDir)..\aerofly-wettergeraet.zip"
COPY "$(SolutionDir)*.txt" "$(TargetDir)"
MKDIR "$(TargetDir)docs\"
COPY "$(SolutionDir)docs\" "$(TargetDir)docs\"
DEL "$(TargetDir)..\aerofly-wettergeraet.zip"
"C:\Program Files\7-Zip\7z.exe" a "$(TargetDir)..\aerofly-wettergeraet.zip" "$(TargetDir)*" -r "-x!*.iobj" "-x!*.ipdb" "-x!*.pdb" "-x!*.exp" "-x!*.lib" "-x!Test*"</Command>
SET ZIPFILE="$(TargetDir)..\..\aerofly-wettergeraet-$(Platform).zip"
DEL %ZIPFILE%
"C:\Program Files\7-Zip\7z.exe" a %ZIPFILE% "$(TargetDir)*" -r "-x!*.iobj" "-x!*.ipdb" "-x!*.pdb" "-x!*.exp" "-x!*.lib" "-x!Test*"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Build final zip</Message>
Expand Down
25 changes: 17 additions & 8 deletions src/WettergeraetCli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ std::string getIcaoFromFlightplan(std::string inIcao, std::tuple<std::string, st
}

// Show error, exit with failure.
void dieWithError(std::invalid_argument e) {
int dieWithError(std::invalid_argument e) {
std::cerr << "\x1B[31m" << e.what() << "\033[0m" << endl;
exit(EXIT_FAILURE);
return EXIT_FAILURE;
}

// ----------------------------------------------------------------------------
Expand All @@ -93,6 +93,15 @@ int main(int argc, char* argv[])
Argumentor argumentor;
argumentor.getArgs(argc, argv);

if (argumentor.isShowHelp) {
std::cout << argumentor.showHelp(argv[0]) << endl;
exit(EXIT_FAILURE);
}
else if (argumentor.isShowVersion) {
std::cout << argumentor.showVersion() << endl;
exit(EXIT_FAILURE);
}

#ifdef _DEBUG
strcpy_s(argumentor.icaoCode, 8, "KSFO");
//strcpy_s(argumentor.url, "https://3960.org/metar/XXXX.txt");
Expand All @@ -112,7 +121,7 @@ int main(int argc, char* argv[])
mainConfig.load();
}
catch (std::invalid_argument& e) {
dieWithError(e);
return dieWithError(e);
}

// Fetch remote data via HTTP(S)
Expand All @@ -139,15 +148,15 @@ int main(int argc, char* argv[])
strcpy_s(argumentor.metarString, 512, urlFetcher.fetch(argumentor.url, argumentor.icaoCode, argumentor.response, argumentor.apikey).c_str());
}
catch (std::invalid_argument& e) {
dieWithError(e);
return dieWithError(e);
}
}
if (argumentor.verbosity > 0) {
std::cout << "METAR " << argumentor.metarString << endl;
}

if (strlen(argumentor.metarString) == 0) {
dieWithError(std::invalid_argument("No METAR code found"));
return dieWithError(std::invalid_argument("No METAR code found"));
}

// Parse METAR data
Expand All @@ -158,7 +167,7 @@ int main(int argc, char* argv[])
metar.addHours(argumentor.hours);
}
catch (std::invalid_argument& e) {
dieWithError(e);
return dieWithError(e);
}
if (argumentor.verbosity > 1) {
showMetar(metar);
Expand All @@ -184,9 +193,9 @@ int main(int argc, char* argv[])
mainConfig.save();
}
catch (std::invalid_argument& e) {
dieWithError(e);
return dieWithError(e);
}
}

return 0;
return EXIT_SUCCESS;
}
3 changes: 1 addition & 2 deletions src/WettergeraetDesktop/Frame.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#define wxUSE_DATEPICKCTRL 1
#define MY_APP_VERSION_STRING "1.2.0"

#include <wx/wx.h>
#include <wx/datectrl.h>
Expand Down Expand Up @@ -359,7 +358,7 @@ void Frame::actionAbout(wxCommandEvent& WXUNUSED(event))
{
wxAboutDialogInfo aboutInfo;
aboutInfo.SetName("Aerofly Wetterger\u00E4t");
aboutInfo.SetVersion(MY_APP_VERSION_STRING);
aboutInfo.SetVersion(this->argumentor.APP_VERSION + std::string(" ") + this->argumentor.APP_TARGET);
aboutInfo.SetDescription(_("Copy METAR weather information into IPCAS' Aerofly FS 2.\n\nCurrentAPI:\n") + this->argumentor.url);
aboutInfo.SetCopyright("\u00A9 2019");
aboutInfo.SetWebSite("https://github.com/fboes/aerofly-wettergeraet");
Expand Down
18 changes: 10 additions & 8 deletions src/WettergeraetDesktop/WettergeraetDesktop.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WXUSINGDLL;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WXUSINGDLL;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>..\MetarParserSimple;..\WettergeraetLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Expand All @@ -122,7 +122,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WXUSINGDLL;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WXUSINGDLL;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>..\MetarParserSimple;..\WettergeraetLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Expand All @@ -140,7 +140,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WXUSINGDLL;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WXUSINGDLL;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>..\MetarParserSimple;..\WettergeraetLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Expand All @@ -156,8 +156,9 @@
COPY "$(SolutionDir)*.txt" "$(TargetDir)"
MKDIR "$(TargetDir)docs\"
COPY "$(SolutionDir)docs\" "$(TargetDir)docs\"
DEL "$(TargetDir)..\aerofly-wettergeraet.zip"
"C:\Program Files\7-Zip\7z.exe" a "$(TargetDir)..\aerofly-wettergeraet.zip" "$(TargetDir)*" -r "-x!*.iobj" "-x!*.ipdb" "-x!*.pdb" "-x!*.exp" "-x!*.lib" "-x!Test*"</Command>
SET ZIPFILE="$(TargetDir)..\..\aerofly-wettergeraet-$(Platform).zip"
DEL %ZIPFILE%
"C:\Program Files\7-Zip\7z.exe" a %ZIPFILE% "$(TargetDir)*" -r "-x!*.iobj" "-x!*.ipdb" "-x!*.pdb" "-x!*.exp" "-x!*.lib" "-x!Test*"</Command>
<Message>Build final zip</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
Expand All @@ -169,7 +170,7 @@ DEL "$(TargetDir)..\aerofly-wettergeraet.zip"
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WXUSINGDLL;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WXUSINGDLL;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>..\MetarParserSimple;..\WettergeraetLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Expand All @@ -185,8 +186,9 @@ DEL "$(TargetDir)..\aerofly-wettergeraet.zip"
COPY "$(SolutionDir)*.txt" "$(TargetDir)"
MKDIR "$(TargetDir)docs\"
COPY "$(SolutionDir)docs\" "$(TargetDir)docs\"
DEL "$(TargetDir)..\aerofly-wettergeraet.zip"
"C:\Program Files\7-Zip\7z.exe" a "$(TargetDir)..\aerofly-wettergeraet.zip" "$(TargetDir)*" -r "-x!*.iobj" "-x!*.ipdb" "-x!*.pdb" "-x!*.exp" "-x!*.lib" "-x!Test*"</Command>
SET ZIPFILE="$(TargetDir)..\..\aerofly-wettergeraet-$(Platform).zip"
DEL %ZIPFILE%
"C:\Program Files\7-Zip\7z.exe" a %ZIPFILE% "$(TargetDir)*" -r "-x!*.iobj" "-x!*.ipdb" "-x!*.pdb" "-x!*.exp" "-x!*.lib" "-x!Test*"</Command>
<Message>Build final zip</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
Expand Down
22 changes: 20 additions & 2 deletions src/WettergeraetLib/Argumentor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include "stdafx.h"
#include "Argumentor.h"

const char* Argumentor::APP_VERSION = "1.2.0";
#if _WIN64
const char* Argumentor::APP_TARGET = "64bit";
#else
const char* Argumentor::APP_TARGET = "32bit";
#endif

char * Argumentor::getEnv(const char * varName)
{
char *pValue;
Expand Down Expand Up @@ -39,9 +46,18 @@ std::string Argumentor::showHelp(std::string cmd)
+ " --dry-run Do not save 'main.mcf'\n"
+ " --quiet No console output\n"
+ " --verbose Show debug output\n"
+ " --version Show version information and exit\n"
+ " --help Display this help and exit\n";
}

std::string Argumentor::showVersion(std::string appname)
{
return ((appname != "") ? appname + " " : "")
+ std::string(Argumentor::APP_VERSION)
+ " (" + std::string(Argumentor::APP_TARGET) + ")"
;
}

Argumentor::Argumentor()
{
// Getting ENV variable values
Expand Down Expand Up @@ -80,8 +96,10 @@ void Argumentor::getArgs(int argc, char * argv[])
currentArg = std::string(argv[i]);

if (currentArg == "--help") {
this->showHelp(argv[0]);
exit(EXIT_FAILURE);
this->isShowHelp = true;
}
else if (currentArg == "--version") {
this->isShowVersion = true;
}
else if (currentArg == "--dry-run") {
this->isDryRun = true;
Expand Down
8 changes: 8 additions & 0 deletions src/WettergeraetLib/Argumentor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class Argumentor
char * getEnv(const char* varName);

public:
static const char* APP_VERSION;
static const char* APP_TARGET;

char icaoCode[8] = "";

char url[512] = "http://avwx.rest/api/metar/XXXX?options=&format=json&onfail=cache";
Expand All @@ -24,6 +27,8 @@ class Argumentor
int hours = 0;

bool isDryRun = false;
bool isShowHelp = false;
bool isShowVersion = false;

// 0: quiet; 1: normal; 2: verbose
unsigned short verbosity = 1;
Expand All @@ -34,6 +39,9 @@ class Argumentor
// Show help output for CLI parameters
std::string showHelp(std::string cmd);

// Show version information
std::string showVersion(std::string appname = "Aerofly Wettergeraet");

Argumentor();
~Argumentor();

Expand Down

0 comments on commit 4cf5d3d

Please sign in to comment.