Skip to content

Commit

Permalink
Merge pull request #83 from ESTOS/feature/BUILDSYS-448
Browse files Browse the repository at this point in the history
Bugfix release
  • Loading branch information
JanFellner authored Sep 20, 2024
2 parents 8c3e10c + bb1ce0d commit 65f58e6
Show file tree
Hide file tree
Showing 22 changed files with 392 additions and 173 deletions.
11 changes: 8 additions & 3 deletions compiler/back-ends/c++-gen/gen-code.c
Original file line number Diff line number Diff line change
Expand Up @@ -4755,10 +4755,15 @@ void PrintCxxCode(FILE* src, FILE* hdr, if_META(MetaNameStyle printMeta _AND_) i
strcpy_s(szModuleNameUpper, 512, m->moduleName);
Str2UCase(szModuleNameUpper, 512);
Dash2Underscore(szModuleNameUpper, 512);
fprintf(hdr, "#define %s_MODULE_LASTCHANGE = \"%s\"\n", szModuleNameUpper, ConvertUnixTimeToISO(lMinorModuleVersion));

char* szISODate = ConvertUnixTimeToISO(lMinorModuleVersion);
fprintf(hdr, "#define %s_MODULE_LASTCHANGE = \"%s\"\n", szModuleNameUpper, szISODate);
free(szISODate);
fprintf(hdr, "#define %s_MODULE_MAJOR_VERSION = %i\n", szModuleNameUpper, gMajorInterfaceVersion);
fprintf(hdr, "#define %s_MODULE_MINOR_VERSION = %lld\n", szModuleNameUpper, lMinorModuleVersion);
fprintf(hdr, "#define %s_MODULE_VERSION = \"%i.%lld.0\"\n\n", szModuleNameUpper, gMajorInterfaceVersion, lMinorModuleVersion);
char* szNumericDate = ConvertUnixTimeToNumericDate(lMinorModuleVersion);
fprintf(hdr, "#define %s_MODULE_MINOR_VERSION = %s\n", szModuleNameUpper, szNumericDate);
fprintf(hdr, "#define %s_MODULE_VERSION = \"%i.0.%s\"\n\n", szModuleNameUpper, gMajorInterfaceVersion, szNumericDate);
free(szNumericDate);
}

if (genCodeCPPPrintStdAfxInclude)
Expand Down
22 changes: 16 additions & 6 deletions compiler/back-ends/java-gen/gen-java-code.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,15 @@ void PrintJAVACode(ModuleList* allMods)
{
long long lMaxMinorVersion = GetMaxModuleMinorVersion();
fprintf(src, "public class Asn1InterfaceVersion {\n");
fprintf(src, "\tpublic static final String lastChange = \"%s\";\n", ConvertUnixTimeToISO(lMaxMinorVersion));

char* szISODate = ConvertUnixTimeToISO(lMaxMinorVersion);
fprintf(src, "\tpublic static final String lastChange = \"%s\";\n", szISODate);
free(szISODate);
fprintf(src, "\tpublic static final int majorVersion = %i;\n", gMajorInterfaceVersion);
fprintf(src, "\tpublic static final long minorVersion = %lld;\n", lMaxMinorVersion);
fprintf(src, "\tpublic static final String version = \"%i.%lld.0\";\n", gMajorInterfaceVersion, lMaxMinorVersion);
char* szNumericDate = ConvertUnixTimeToNumericDate(lMaxMinorVersion);
fprintf(src, "\tpublic static final long minorVersion = %s;\n", szNumericDate);
fprintf(src, "\tpublic static final String version = \"%i.0.%s\";\n", gMajorInterfaceVersion, szNumericDate);
free(szNumericDate);
fprintf(src, "}\n");
fclose(src);
}
Expand Down Expand Up @@ -811,10 +816,15 @@ void PrintJAVACodeOneModule(ModuleList* mods, Module* m)
{
long long lMinorModuleVersion = GetModuleMinorVersion(m->moduleName);
fprintf(src, "public class %s {\n", m->moduleName);
fprintf(src, "\tpublic static final String lastChange = \"%s\";\n", ConvertUnixTimeToISO(lMinorModuleVersion));

char* szISODate = ConvertUnixTimeToISO(lMinorModuleVersion);
fprintf(src, "\tpublic static final String lastChange = \"%s\";\n", szISODate);
free(szISODate);
fprintf(src, "\tpublic static final int majorVersion = %i;\n", gMajorInterfaceVersion);
fprintf(src, "\tpublic static final long minorVersion = %lld;\n", lMinorModuleVersion);
fprintf(src, "\tpublic static final String version = \"%i.%lld.0\";\n", gMajorInterfaceVersion, lMinorModuleVersion);
char* szNumericDate = ConvertUnixTimeToNumericDate(lMinorModuleVersion);
fprintf(src, "\tpublic static final long minorVersion = %s;\n", szNumericDate);
fprintf(src, "\tpublic static final String version = \"%i.0.%s\";\n", gMajorInterfaceVersion, szNumericDate);
free(szNumericDate);
fprintf(src, "}\n");
fclose(src);
}
Expand Down
30 changes: 25 additions & 5 deletions compiler/back-ends/jsondoc-gen/gen-jsondoc-code.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,14 @@ void PrintJsonDocModule(FILE* src, ModuleList* mods, Module* m)
{
fprintf(src, ",\n\t\t\"version\": {");
long long lMinorModuleVersion = GetModuleMinorVersion(m->moduleName);
long long lMaxModuleVersion = GetMaxModuleMinorVersion();
fprintf(src, "\n\t\t\t\"lastChange\": \"%s\"", ConvertUnixTimeToISO(lMinorModuleVersion));
char* szISODate = ConvertUnixTimeToISO(lMinorModuleVersion);
fprintf(src, "\n\t\t\t\"lastChange\": \"%s\"", szISODate);
free(szISODate);
fprintf(src, ",\n\t\t\t\"majorVersion\": %i", gMajorInterfaceVersion);
fprintf(src, ",\n\t\t\t\"minorVersion\": %lld", lMinorModuleVersion);
fprintf(src, ",\n\t\t\t\"version\": \"%i.%lld.0\"", gMajorInterfaceVersion, lMinorModuleVersion);
fprintf(src, ",\n\t\t\t\"interfaceversion\": \"%i.%lld.0\"", gMajorInterfaceVersion, lMaxModuleVersion);
char* szNumericDate = ConvertUnixTimeToNumericDate(lMinorModuleVersion);
fprintf(src, ",\n\t\t\t\"minorVersion\": %s", szNumericDate);
fprintf(src, ",\n\t\t\t\"version\": \"%i.0.%s\"", gMajorInterfaceVersion, szNumericDate);
free(szNumericDate);
fprintf(src, "\n\t\t}");
}

Expand Down Expand Up @@ -843,6 +845,24 @@ void PrintJsonDocCode(ModuleList* allMods)
DefinedObj* fNames;
int fNameConflict = FALSE;

{
char* szFileName = MakeFileName("interfaceversion", ".txt");
FILE* src = NULL;
if (fopen_s(&src, szFileName, "wt") != 0 || src == NULL)
{
perror("fopen");
}
else
{
const long long lMaxModuleVersion = GetMaxModuleMinorVersion();
char* szNumericDate = ConvertUnixTimeToNumericDate(lMaxModuleVersion);
fprintf(src, "%i.0.%s", gMajorInterfaceVersion, szNumericDate);
free(szNumericDate);
fclose(src);
}
free(szFileName);
}

/*
* Make names for each module's encoder/decoder src and hdr files
* so import references can be made via include files
Expand Down
20 changes: 14 additions & 6 deletions compiler/back-ends/swift-gen/gen-swift-code.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,10 +1240,14 @@ void PrintSwiftCodeOne(FILE* src, ModuleList* mods, Module* m, long longJmpVal,
Dash2Underscore(szModuleName, 512);
fprintf(src, "struct %s_Version\n", szModuleName);
fprintf(src, "{\n");
fprintf(src, " let lastChange = Date(iso8601String:\"%s\") ?? .distantPast\n", ConvertUnixTimeToISO(lMinorModuleVersion));
char* szISODate = ConvertUnixTimeToISO(lMinorModuleVersion);
fprintf(src, " let lastChange = Date(iso8601String:\"%s\") ?? .distantPast\n", szISODate);
free(szISODate);
fprintf(src, " let majorVersion = %i\n", gMajorInterfaceVersion);
fprintf(src, " let minorVersion = %lld\n", lMinorModuleVersion);
fprintf(src, " let version = \"%i.%lld.0\"\n", gMajorInterfaceVersion, lMinorModuleVersion);
char* szNumericDate = ConvertUnixTimeToNumericDate(lMinorModuleVersion);
fprintf(src, " let minorVersion = %s\n", szNumericDate);
fprintf(src, " let version = \"%i.0.%s\"\n", gMajorInterfaceVersion, szNumericDate);
free(szNumericDate);
fprintf(src, "}\n\n");
}

Expand Down Expand Up @@ -1435,10 +1439,14 @@ void PrintSwiftCode(ModuleList* allMods, long longJmpVal, int genTypes, int genV
fprintf(versionFile, "import Foundation\n\n");
fprintf(versionFile, "struct Asn1InterfaceVersion\n");
fprintf(versionFile, "{\n");
fprintf(versionFile, " let lastChange = Date(iso8601String:\"%s\") ?? .distantPast\n", ConvertUnixTimeToISO(lMaxMinorVersion));
char* szISODate = ConvertUnixTimeToISO(lMaxMinorVersion);
fprintf(versionFile, " let lastChange = Date(iso8601String:\"%s\") ?? .distantPast\n", szISODate);
free(szISODate);
fprintf(versionFile, " let majorVersion = %i\n", gMajorInterfaceVersion);
fprintf(versionFile, " let minorVersion = %lld\n", lMaxMinorVersion);
fprintf(versionFile, " let version = \"%i.%lld.0\"\n", gMajorInterfaceVersion, lMaxMinorVersion);
char* szNumericDate = ConvertUnixTimeToNumericDate(lMaxMinorVersion);
fprintf(versionFile, " let minorVersion = %s\n", szNumericDate);
fprintf(versionFile, " let version = \"%i.0.%s\"\n", gMajorInterfaceVersion, szNumericDate);
free(szNumericDate);
fprintf(versionFile, "}\n");
fclose(versionFile);
}
Expand Down
10 changes: 7 additions & 3 deletions compiler/back-ends/ts-gen/gen-ts-code.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,10 +1005,14 @@ void PrintTSCode(ModuleList* allMods, long longJmpVal, int genTypes, int genValu
fprintf(versionFile, "/* eslint-disable */\n\n");
long long lMaxMinorVersion = GetMaxModuleMinorVersion();
fprintf(versionFile, "export class Asn1InterfaceVersion {\n");
fprintf(versionFile, "\tpublic static lastChange = \"%s\";\n", ConvertUnixTimeToISO(lMaxMinorVersion));
char* szISODate = ConvertUnixTimeToISO(lMaxMinorVersion);
fprintf(versionFile, "\tpublic static lastChange = \"%s\";\n", szISODate);
free(szISODate);
fprintf(versionFile, "\tpublic static majorVersion = %i;\n", gMajorInterfaceVersion);
fprintf(versionFile, "\tpublic static minorVersion = %lld;\n", lMaxMinorVersion);
fprintf(versionFile, "\tpublic static version = \"%i.%lld.0\";\n", gMajorInterfaceVersion, lMaxMinorVersion);
char* szNumericDate = ConvertUnixTimeToNumericDate(lMaxMinorVersion);
fprintf(versionFile, "\tpublic static minorVersion = %s;\n", szNumericDate);
fprintf(versionFile, "\tpublic static version = \"%i.0.%s\";\n", gMajorInterfaceVersion, szNumericDate);
free(szNumericDate);
fprintf(versionFile, "}\n");
fclose(versionFile);
}
Expand Down
10 changes: 7 additions & 3 deletions compiler/back-ends/ts-gen/gen-ts-combined.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ void PrintTSRootTypes(FILE* src, Module* mod, const char* szSuffix)
if (gMajorInterfaceVersion >= 0)
{
long long lMinorModuleVersion = GetModuleMinorVersion(mod->moduleName);
fprintf(src, "export const MODULE_LASTCHANGE = \"%s\";\n", ConvertUnixTimeToISO(lMinorModuleVersion));
char* szISODate = ConvertUnixTimeToISO(lMinorModuleVersion);
fprintf(src, "export const MODULE_LASTCHANGE = \"%s\";\n", szISODate);
free(szISODate);
fprintf(src, "export const MODULE_MAJOR_VERSION = %i;\n", gMajorInterfaceVersion);
fprintf(src, "export const MODULE_MINOR_VERSION = %lld;\n", lMinorModuleVersion);
fprintf(src, "export const MODULE_VERSION = \"%i.%lld.0\";\n", gMajorInterfaceVersion, lMinorModuleVersion);
char* szNumericDate = ConvertUnixTimeToNumericDate(lMinorModuleVersion);
fprintf(src, "export const MODULE_MINOR_VERSION = %s;\n", szNumericDate);
fprintf(src, "export const MODULE_VERSION = \"%i.0.%s\";\n", gMajorInterfaceVersion, szNumericDate);
free(szNumericDate);
}
}

Expand Down
10 changes: 7 additions & 3 deletions compiler/core/snacc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1585,10 +1585,14 @@ void GenCxxCode(ModuleList* allMods, long longJmpVal, int genTypes, int genValue

fprintf(versionFile, "struct Asn1InterfaceVersion\n");
fprintf(versionFile, "{\n");
fprintf(versionFile, "\tstatic constexpr const char* lastChange = \"%s\";\n", ConvertUnixTimeToISO(lMaxMinorVersion));
char* szISODate = ConvertUnixTimeToISO(lMaxMinorVersion);
fprintf(versionFile, "\tstatic constexpr const char* lastChange = \"%s\";\n", szISODate);
free(szISODate);
fprintf(versionFile, "\tstatic constexpr int majorVersion = %i;\n", gMajorInterfaceVersion);
fprintf(versionFile, "\tstatic constexpr long long minorVersion = %lld;\n", lMaxMinorVersion);
fprintf(versionFile, "\tstatic constexpr const char* version = \"%i.%lld.0\";\n", gMajorInterfaceVersion, lMaxMinorVersion);
char* szNumericDate = ConvertUnixTimeToNumericDate(lMaxMinorVersion);
fprintf(versionFile, "\tstatic constexpr long long minorVersion = %s;\n", szNumericDate);
fprintf(versionFile, "\tstatic constexpr const char* version = \"%i.0.%s\";\n", gMajorInterfaceVersion, szNumericDate);
free(szNumericDate);
fprintf(versionFile, "};\n\n");

fprintf(versionFile, "#ifndef NO_NAMESPACE\n");
Expand Down
54 changes: 46 additions & 8 deletions compiler/core/time_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string.h>
#include <stdlib.h>
#include "../../snacc_defines.h"
#include "../../c-lib/include/asn-config.h"

#if TIME_WITH_SYS_TIME
#include <sys/time.h>
Expand Down Expand Up @@ -127,26 +128,61 @@ long long ConvertDateToUnixTime(const char* szDate)
/**
* Converts a unix time into something readable
*
* Returns a pointer to a buffer that needs to get released with Free
* Returns a pointer to a buffer that needs to get released with Free "20.09.2024"
*/
char* ConvertUnixTimeToReadable(const long long tmUnixTime)
{
if (tmUnixTime <= 0)
char* szBuffer = malloc(128);
if (!szBuffer)
return NULL;

memset(szBuffer, 0x00, 127);

if (tmUnixTime == 0)
strcpy_s(szBuffer, 127, "0");
else
{
#ifdef _WIN32
struct tm timeinfo;
localtime_s(&timeinfo, &tmUnixTime);
strftime(szBuffer, 128, "%d.%m.%Y", &timeinfo);
#else
struct tm* timeinfo;
timeinfo = localtime((const time_t*)&tmUnixTime);
strftime(szBuffer, 128, "%d.%m.%Y", timeinfo);
#endif
}

return szBuffer;
}

/**
* Converts a unix time into a numeric readable date in sorted notation (20240920)
*
* Returns a pointer to a buffer that needs to get released with Free "20240920" or "0"
*/
char* ConvertUnixTimeToNumericDate(const long long tmUnixTime)
{
char* szBuffer = malloc(128);
if (!szBuffer)
return NULL;

memset(szBuffer, 0x00, 127);

if (tmUnixTime == 0)
strcpy_s(szBuffer, 127, "0");
else
{
#ifdef _WIN32
struct tm timeinfo;
localtime_s(&timeinfo, &tmUnixTime);
strftime(szBuffer, 128, "%d.%m.%Y", &timeinfo);
struct tm timeinfo;
localtime_s(&timeinfo, &tmUnixTime);
strftime(szBuffer, 128, "%Y%m%d", &timeinfo);
#else
struct tm* timeinfo;
timeinfo = localtime((const time_t*)&tmUnixTime);
strftime(szBuffer, 128, "%d.%m.%Y", timeinfo);
struct tm* timeinfo;
timeinfo = localtime((const time_t*)&tmUnixTime);
strftime(szBuffer, 128, "%Y%m%d", timeinfo);
#endif
}

return szBuffer;
}
Expand All @@ -162,6 +198,8 @@ char* ConvertUnixTimeToISO(const long long tmUnixTime)
if (!szBuffer)
return NULL;

memset(szBuffer, 0x00, 127);

#ifdef _WIN32
struct tm timeinfo;
localtime_s(&timeinfo, &tmUnixTime);
Expand Down
7 changes: 7 additions & 0 deletions compiler/core/time_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ long long ConvertDateToUnixTime(const char* szDate);
*/
char* ConvertUnixTimeToReadable(const long long tmUnixTime);

/**
* Converts a unix time into a numeric readable date in sorted notation (20240920)
*
* Returns a pointer to a buffer that needs to get released with Free
*/
char* ConvertUnixTimeToNumericDate(const long long tmUnixTime);

/**
* Converts a unix time into an ISO timestamp
*
Expand Down
2 changes: 1 addition & 1 deletion cpp-lib/jsoncpp/.clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BasedOnStyle: LLVM
DerivePointerAlignment: false
PointerAlignment: Left

SpacesBeforeTrailingComments: 1
14 changes: 12 additions & 2 deletions cpp-lib/jsoncpp/include/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#ifndef JSON_ALLOCATOR_H_INCLUDED
#define JSON_ALLOCATOR_H_INCLUDED

#include <algorithm>
#include <cstring>
#include <memory>

#pragma pack(push, 8)
#pragma pack(push)
#pragma pack()

namespace SJson {
template <typename T> class SecureAllocator {
Expand Down Expand Up @@ -37,8 +39,16 @@ template <typename T> class SecureAllocator {
* The memory block is filled with zeroes before being released.
*/
void deallocate(pointer p, size_type n) {
// memset_s is used because memset may be optimized away by the compiler
// These constructs will not be removed by the compiler during optimization,
// unlike memset.
#if defined(HAVE_MEMSET_S)
memset_s(p, n * sizeof(T), 0, n * sizeof(T));
#elif defined(_WIN32)
RtlSecureZeroMemory(p, n * sizeof(T));
#else
std::fill_n(reinterpret_cast<volatile unsigned char*>(p), n, 0);
#endif

// free using "global operator delete"
::operator delete(p);
}
Expand Down
15 changes: 7 additions & 8 deletions cpp-lib/jsoncpp/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,23 @@ using UInt = unsigned int;
using LargestInt = int;
using LargestUInt = unsigned int;
#undef JSON_HAS_INT64
#else // if defined(JSON_NO_INT64)
#else // if defined(JSON_NO_INT64)
// For Microsoft Visual use specific types as long long is not supported
// #if defined(_MSC_VER) // Microsoft Visual Studio
// using Int64 = __int64;
// using UInt64 = unsigned __int64;
// #else // if defined(_MSC_VER) // Other platforms, use long
// long
#if defined(_MSC_VER) // Microsoft Visual Studio
using Int64 = __int64;
using UInt64 = unsigned __int64;
#else // if defined(_MSC_VER) // Other platforms, use long long
using Int64 = int64_t;
using UInt64 = uint64_t;
// #endif // if defined(_MSC_VER)
#endif // if defined(_MSC_VER)
using LargestInt = Int64;
using LargestUInt = UInt64;
#define JSON_HAS_INT64
#endif // if defined(JSON_NO_INT64)

template <typename T>
using Allocator =
typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
typename std::conditional<JSONCPP_USE_SECURE_MEMORY, SecureAllocator<T>,
std::allocator<T>>::type;
using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
using IStringStream =
Expand Down
2 changes: 1 addition & 1 deletion cpp-lib/jsoncpp/include/forwards.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ class ValueIteratorBase;
class ValueIterator;
class ValueConstIterator;

} // namespace SJson
} // namespace Json

#endif // JSON_FORWARDS_H_INCLUDED
3 changes: 2 additions & 1 deletion cpp-lib/jsoncpp/include/json_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include "forwards.h"
#endif // if !defined(JSON_IS_AMALGAMATION)

#pragma pack(push, 8)
#pragma pack(push)
#pragma pack()

namespace SJson {

Expand Down
Loading

0 comments on commit 65f58e6

Please sign in to comment.