From 0d222f31e35b3834e8bd4ced2e537fbb78f8b358 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 22 Dec 2005 08:52:19 +0000
Subject: [PATCH] New properties: system.version_num and system.version_hex,
 initialized with the values of the newly defined macros of the same names.
 These allow easy comparison for scripts. Example:     if(system.version_num <
 31301) /* v3.13b */         print("version 3.13b or later required");
 system.version_hex allows easy major/minor version number checking, parsing
 or printing using right-shift operations instead of division/rounding.
 Example:     31301/100 == 313.01     0x31301>>8 == 0x313

---
 src/sbbs3/js_system.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/sbbs3/js_system.c b/src/sbbs3/js_system.c
index 42b4d19797..11fc5312b5 100644
--- a/src/sbbs3/js_system.c
+++ b/src/sbbs3/js_system.c
@@ -484,6 +484,8 @@ static char* sys_prop_desc[] = {
 	,"Synchronet alpha/beta designation (e.g. ' beta')"
 	,"Synchronet full version information (e.g. '3.10k Beta Debug')"
 	,"Synchronet version notice (includes version and platform)"
+	,"Synchronet version number in decimal (e.g. 31301 for v3.13b)"
+	,"Synchronet version number in hexadecimal (e.g. 0x31301 for v3.13b)"
 	,"platform description (e.g. 'Win32', 'Linux', 'FreeBSD')"
 	,"socket library version information"
 	,"message base library version information"
@@ -1676,6 +1678,17 @@ JSObject* DLLCALL js_CreateSystemObject(JSContext* cx, JSObject* parent
 	if(!JS_SetProperty(cx, sysobj, "version_notice", &val))
 		return(NULL);
 
+	/* Numeric version properties */
+	if(!JS_NewNumberValue(cx, VERSION_NUM, &val))
+		return(NULL);
+	if(!JS_SetProperty(cx, sysobj, "version_num", &val))
+		return(NULL);
+
+	if(!JS_NewNumberValue(cx, VERSION_HEX, &val))
+		return(NULL);
+	if(!JS_SetProperty(cx, sysobj, "version_hex", &val))
+		return(NULL);
+
 	if((js_str=JS_NewStringCopyZ(cx, PLATFORM_DESC))==NULL)
 		return(NULL);
 	val = STRING_TO_JSVAL(js_str);
-- 
GitLab