aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--global-functions30
1 files changed, 30 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index e01d807..0a6b709 100644
--- a/global-functions
+++ b/global-functions
@@ -41,6 +41,7 @@
:global SendTelegram;
:global TimeIsSync;
:global UrlEncode;
+:global VersionToNum;
:global WaitDefaultRouteReachable;
:global WaitDNSResolving;
:global WaitForFile;
@@ -760,6 +761,35 @@
:return $Return;
}
+# convert version string to numeric value
+:set VersionToNum do={
+ :local Input [ :tostr $1 ];
+ :local Multi 0x1000000;
+ :local Return 0;
+
+ :global CharacterReplace;
+
+ :set Input [ $CharacterReplace [ $CharacterReplace [ $CharacterReplace $Input \
+ "." "," ] "beta" ",beta," ] "rc" ",rc," ];
+
+ :foreach Value in=([ :toarray $Input ], 0) do={
+ :local Num [ :tonum $Value ];
+ :if ($Multi = 0x100) do={
+ :if ([ :typeof $Num ] = "num") do={
+ :set Return ($Return + 0xff00);
+ :set Multi ($Multi / 0x100);
+ } else={
+ :if ($Value = "beta") do={ :set Return ($Return + 0x3f00); }
+ :if ($Value = "rc") do={ :set Return ($Return + 0x7f00); }
+ }
+ }
+ :if ([ :typeof $Num ] = "num") do={ :set Return ($Return + ($Value * $Multi)); }
+ :set Multi ($Multi / 0x100);
+ }
+
+ :return $Return;
+}
+
# wait for default route to be reachable
:set WaitDefaultRouteReachable do={
:global DefaultRouteIsReachable;