diff options
author | Christian Hesse <mail@eworm.de> | 2020-07-07 00:01:00 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2020-07-07 00:01:00 +0200 |
commit | d8b2055fbce578884dfac36fca372101c14cd8af (patch) | |
tree | 5b9345974373dadf1a76ebee4aa2ff250051c16a | |
parent | e1b45f13f5f415a0422d88921b07e2f667d6f396 (diff) |
global-functions: add $VersionToNum
-rw-r--r-- | global-functions | 30 |
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; |