From 66153045beb455268b6fc899d554a2d2210c9b0e Mon Sep 17 00:00:00 2001 From: akallabeth Date: Wed, 11 Sep 2024 22:49:42 +0200 Subject: [PATCH] [winpr,timezone] Include TimeZoneNameMap as header * Update tzextract to generate header * Update TimeZoneNameMapUtils to include header --- winpr/libwinpr/timezone/CMakeLists.txt | 2 +- winpr/libwinpr/timezone/TimeZoneNameMapUtils.c | 8 ++++---- .../{TimeZoneNameMap.c => TimeZoneNameMap_static.h} | 4 ++-- winpr/libwinpr/timezone/utils/tzextract.cs | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) rename winpr/libwinpr/timezone/{TimeZoneNameMap.c => TimeZoneNameMap_static.h} (97%) diff --git a/winpr/libwinpr/timezone/CMakeLists.txt b/winpr/libwinpr/timezone/CMakeLists.txt index c224100be..6fd3b07b2 100644 --- a/winpr/libwinpr/timezone/CMakeLists.txt +++ b/winpr/libwinpr/timezone/CMakeLists.txt @@ -37,7 +37,7 @@ set(SRCS ) if (WITH_TIMEZONE_COMPILED) list(APPEND SRCS - TimeZoneNameMap.c + TimeZoneNameMap_static.h ) endif() diff --git a/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c b/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c index 1416e99fd..d3253bd56 100644 --- a/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c +++ b/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c @@ -39,6 +39,10 @@ #include "TimeZoneNameMap.h" +#if defined(WITH_TIMEZONE_COMPILED) +#include "TimeZoneNameMap_static.h" +#endif + typedef struct { size_t count; @@ -272,10 +276,6 @@ static BOOL CALLBACK load_timezones(PINIT_ONCE once, PVOID param, PVOID* pvconte #if defined(WITH_TIMEZONE_COMPILED) { - // Do not expose these, only used internally. - extern const TimeZoneNameMapEntry TimeZoneNameMap[]; - extern const size_t TimeZoneNameMapSize; - const size_t offset = context->count; if (!reallocate_context(context, TimeZoneNameMapSize)) return FALSE; diff --git a/winpr/libwinpr/timezone/TimeZoneNameMap.c b/winpr/libwinpr/timezone/TimeZoneNameMap_static.h similarity index 97% rename from winpr/libwinpr/timezone/TimeZoneNameMap.c rename to winpr/libwinpr/timezone/TimeZoneNameMap_static.h index 12a4bd4d1..b355baeb8 100644 --- a/winpr/libwinpr/timezone/TimeZoneNameMap.c +++ b/winpr/libwinpr/timezone/TimeZoneNameMap_static.h @@ -2,7 +2,7 @@ #include "TimeZoneNameMap.h" -const TimeZoneNameMapEntry TimeZoneNameMap[] = { +static const TimeZoneNameMapEntry TimeZoneNameMap[] = { { "Dateline Standard Time", "Dateline Standard Time", "(UTC-12:00) International Date Line West", "Dateline Daylight Time", "Etc/GMT+12" }, { "UTC-11", "UTC-11", "(UTC-11:00) Coordinated Universal Time-11", "UTC-11", "Etc/GMT+11" }, @@ -289,4 +289,4 @@ const TimeZoneNameMapEntry TimeZoneNameMap[] = { "Line Islands Daylight Time", "Pacific/Kiritimati" } }; -const size_t TimeZoneNameMapSize = ARRAYSIZE(TimeZoneNameMap); +static const size_t TimeZoneNameMapSize = ARRAYSIZE(TimeZoneNameMap); diff --git a/winpr/libwinpr/timezone/utils/tzextract.cs b/winpr/libwinpr/timezone/utils/tzextract.cs index df9375153..b37d5b39c 100644 --- a/winpr/libwinpr/timezone/utils/tzextract.cs +++ b/winpr/libwinpr/timezone/utils/tzextract.cs @@ -22,7 +22,7 @@ internal class Program private static bool writeZoneMapC(string path) { string fname = "TimeZoneNameMap"; - string fpath = Path.Combine(path, fname + ".c"); + string fpath = Path.Combine(path, fname + "_static.h"); using (StreamWriter fs = new StreamWriter(fpath)) { @@ -30,7 +30,7 @@ internal class Program fs.WriteLine(""); fs.WriteLine("#include \"" + fname + ".h\""); fs.WriteLine(""); - fs.WriteLine("const " + fname + "Entry " + fname + "[] ={"); + fs.WriteLine("static const " + fname + "Entry " + fname + "[] ={"); bool first = true; foreach (System.TimeZoneInfo tz in System.TimeZoneInfo.GetSystemTimeZones()) @@ -58,7 +58,7 @@ internal class Program fs.WriteLine("};"); fs.WriteLine(""); - fs.WriteLine("const size_t " + fname + "Size = ARRAYSIZE(" + fname + ");"); + fs.WriteLine("static const size_t " + fname + "Size = ARRAYSIZE(" + fname + ");"); fs.WriteLine(""); } return true;