Commit 30a2ed07 authored by rswindell's avatar rswindell
Browse files

Changes required for proper socket library version display (system.socket_lib)

in JSexec-win32.
parent ebc9ec34
......@@ -38,6 +38,13 @@
#include "sbbs.h"
#include "cmdshell.h"
#if defined(_WINSOCKAPI_)
extern WSADATA WSAData;
#define SOCKLIB_DESC WSAData.szDescription
#else
#define SOCKLIB_DESC NULL
#endif
/****************************************************************************/
/* Returns 0 if invalid @ code. Returns length of @ code if valid. */
/****************************************************************************/
......@@ -157,7 +164,7 @@ char* sbbs_t::atcode(char* sp, char* str)
}
if(!strcmp(sp,"SOCKET_LIB"))
return(socklib_version(str));
return(socklib_version(str,SOCKLIB_DESC));
if(!strcmp(sp,"MSG_LIB")) {
sprintf(str,"SMBLIB %s",smb_lib_ver());
......
......@@ -153,6 +153,8 @@ static int lprintf(int level, char *fmt, ...)
#ifdef _WINSOCKAPI_
static WSADATA WSAData;
#define SOCKLIB_DESC WSAData.szDescription
static BOOL WSAInitialized=FALSE;
static BOOL winsock_startup(void)
......@@ -172,6 +174,7 @@ static BOOL winsock_startup(void)
#else /* No WINSOCK */
#define winsock_startup() (TRUE)
#define SOCKLIB_DESC NULL
#endif
......@@ -491,7 +494,7 @@ js_initcx(JSRuntime* runtime, SOCKET sock, JSObject** glob, JSObject** ftp)
break;
lprintf(LOG_DEBUG,"%04d JavaScript: Initializing System object",sock);
if(js_CreateSystemObject(js_cx, js_glob, &scfg, uptime, startup->host_name)==NULL)
if(js_CreateSystemObject(js_cx, js_glob, &scfg, uptime, startup->host_name, SOCKLIB_DESC)==NULL)
break;
if((*ftp=JS_DefineObject(js_cx, js_glob, "ftp", NULL
......
......@@ -1587,7 +1587,7 @@ static JSClass js_node_class = {
};
JSObject* DLLCALL js_CreateSystemObject(JSContext* cx, JSObject* parent
,scfg_t* cfg, time_t uptime, char* host_name)
,scfg_t* cfg, time_t uptime, char* host_name, char* socklib_desc)
{
char str[256];
uint i;
......@@ -1671,7 +1671,7 @@ JSObject* DLLCALL js_CreateSystemObject(JSContext* cx, JSObject* parent
if(!JS_SetProperty(cx, sysobj, "platform", &val))
return(NULL);
if((js_str=JS_NewStringCopyZ(cx, socklib_version(str)))==NULL)
if((js_str=JS_NewStringCopyZ(cx, socklib_version(str, socklib_desc)))==NULL)
return(NULL);
val = STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(cx, sysobj, "socket_lib", &val))
......
......@@ -138,6 +138,7 @@ int lprintf(int level, char *fmt, ...)
#if defined(_WINSOCKAPI_)
WSADATA WSAData;
#define SOCKLIB_DESC WSAData.szDescription
static BOOL WSAInitialized=FALSE;
static BOOL winsock_startup(void)
......@@ -156,7 +157,8 @@ static BOOL winsock_startup(void)
#else /* No WINSOCK */
#define winsock_startup() (TRUE)
#define winsock_startup() (TRUE)
#define SOCKLIB_DESC NULL
#endif
......@@ -502,7 +504,7 @@ static BOOL js_init(char** environ)
return(FALSE);
/* System Object */
if(js_CreateSystemObject(js_cx, js_glob, &scfg, time(NULL), host_name)==NULL)
if(js_CreateSystemObject(js_cx, js_glob, &scfg, time(NULL), host_name, SOCKLIB_DESC)==NULL)
return(FALSE);
/* Socket Class */
......
......@@ -125,6 +125,7 @@ static int lprintf(int level, char *fmt, ...)
#ifdef _WINSOCKAPI_
static WSADATA WSAData;
#define SOCKLIB_DESC WSAData.szDescription
static BOOL WSAInitialized=FALSE;
static BOOL winsock_startup(void)
......@@ -144,6 +145,7 @@ static BOOL winsock_startup(void)
#else /* No WINSOCK */
#define winsock_startup() (TRUE)
#define SOCKLIB_DESC NULL
#endif
......@@ -1437,7 +1439,7 @@ js_mailproc(SOCKET sock, client_t* client, user_t* user
break;
/* System Object */
if(js_CreateSystemObject(js_cx, js_glob, &scfg, uptime, startup->host_name)==NULL)
if(js_CreateSystemObject(js_cx, js_glob, &scfg, uptime, startup->host_name, SOCKLIB_DESC)==NULL)
break;
/* Socket Class */
......
......@@ -233,6 +233,33 @@ u_long resolve_ip(char *addr)
} /* extern "C" */
#ifdef _WINSOCKAPI_
WSADATA WSAData;
#define SOCKLIB_DESC WSAData.szDescription
static BOOL WSAInitialized=FALSE;
static BOOL winsock_startup(void)
{
int status; /* Status Code */
if((status = WSAStartup(MAKEWORD(1,1), &WSAData))==0) {
lprintf(LOG_INFO,"%s %s",WSAData.szDescription, WSAData.szSystemStatus);
WSAInitialized=TRUE;
return(TRUE);
}
lprintf(LOG_ERR,"!WinSock startup ERROR %d", status);
return(FALSE);
}
#else /* No WINSOCK */
#define winsock_startup() (TRUE)
#define SOCKLIB_DESC NULL
#endif
#ifdef JAVASCRIPT
static js_server_props_t js_server_props;
......@@ -863,7 +890,7 @@ bool sbbs_t::js_init()
#endif
/* System Object */
if(js_CreateSystemObject(js_cx, js_glob, &cfg, uptime, startup->host_name)==NULL)
if(js_CreateSystemObject(js_cx, js_glob, &cfg, uptime, startup->host_name, SOCKLIB_DESC)==NULL)
break;
/* Internal JS Object */
......@@ -960,31 +987,6 @@ void sbbs_t::js_create_user_objects(void)
#endif /* JAVASCRIPT */
#ifdef _WINSOCKAPI_
WSADATA WSAData;
static BOOL WSAInitialized=FALSE;
static BOOL winsock_startup(void)
{
int status; /* Status Code */
if((status = WSAStartup(MAKEWORD(1,1), &WSAData))==0) {
lprintf(LOG_INFO,"%s %s",WSAData.szDescription, WSAData.szSystemStatus);
WSAInitialized=TRUE;
return(TRUE);
}
lprintf(LOG_ERR,"!WinSock startup ERROR %d", status);
return(FALSE);
}
#else /* No WINSOCK */
#define winsock_startup() (TRUE)
#endif
static BYTE* telnet_interpret(sbbs_t* sbbs, BYTE* inbuf, int inlen,
BYTE* outbuf, int& outlen)
{
......
......@@ -931,7 +931,9 @@ extern "C" {
/* js_system.c */
DLLEXPORT JSObject* DLLCALL js_CreateSystemObject(JSContext* cx, JSObject* parent
,scfg_t* cfg, time_t uptime, char* host_name);
,scfg_t* cfg, time_t uptime
,char* host_name
,char* socklib_desc);
/* js_client.c */
DLLEXPORT JSObject* DLLCALL js_CreateClientObject(JSContext* cx, JSObject* parent
......@@ -1010,7 +1012,7 @@ BOOL md(char *path);
char * readtext(long *line, FILE *stream);
/* ver.cpp */
char* socklib_version(char* str);
char* socklib_version(char* str, char* winsock_ver);
/* sortdir.cpp */
int fnamecmp_a(char **str1, char **str2); /* for use with resort() */
......
......@@ -160,6 +160,7 @@ static int lprintf(int level, char *fmt, ...)
#ifdef _WINSOCKAPI_
static WSADATA WSAData;
#define SOCKLIB_DESC WSAData.szDescription
static BOOL WSAInitialized=FALSE;
static BOOL winsock_startup(void)
......@@ -179,6 +180,7 @@ static BOOL winsock_startup(void)
#else /* No WINSOCK */
#define winsock_startup() (TRUE)
#define SOCKLIB_DESC NULL
#endif
......@@ -811,7 +813,7 @@ js_initcx(JSRuntime* js_runtime, SOCKET sock, service_client_t* service_client,
if(!js_CreateUserObjects(js_cx, js_glob, &scfg, NULL, NULL, NULL))
break;
if(js_CreateSystemObject(js_cx, js_glob, &scfg, uptime, startup->host_name)==NULL)
if(js_CreateSystemObject(js_cx, js_glob, &scfg, uptime, startup->host_name, SOCKLIB_DESC)==NULL)
break;
#if 0
char ver[256];
......
......@@ -41,17 +41,20 @@ extern "C" const char* beta_version = " alpha"; /* Space if non-beta, " beta" ot
#if defined(_WINSOCKAPI_)
extern WSADATA WSAData;
#define SOCKLIB_DESC WSAData.szDescription
#else
#define SOCKLIB_DESC NULL
#endif
#if defined(__unix__)
#include <sys/utsname.h> /* uname() */
#endif
char* socklib_version(char* str)
char* socklib_version(char* str, char* winsock_ver)
{
#if defined(_WINSOCKAPI_)
strcpy(str,WSAData.szDescription);
strcpy(str,winsock_ver);
#elif defined(__GLIBC__)
......@@ -101,7 +104,7 @@ void sbbs_t::ver()
}
#endif
center(socklib_version(str));
center(socklib_version(str,SOCKLIB_DESC));
CRLF;
center(os_version(str));
......
......@@ -287,6 +287,7 @@ static int lprintf(int level, char *fmt, ...)
#ifdef _WINSOCKAPI_
static WSADATA WSAData;
#define SOCKLIB_DESC WSAData.szDescription
static BOOL WSAInitialized=FALSE;
static BOOL winsock_startup(void)
......@@ -306,6 +307,7 @@ static BOOL winsock_startup(void)
#else /* No WINSOCK */
#define winsock_startup() (TRUE)
#define SOCKLIB_DESC NULL
#endif
......@@ -2090,7 +2092,7 @@ js_initcx(JSRuntime* runtime, SOCKET sock, JSObject** glob, http_session_t *sess
break;
lprintf(LOG_INFO,"%04d JavaScript: Initializing System object",sock);
if(js_CreateSystemObject(js_cx, js_glob, &scfg, uptime, startup->host_name)==NULL)
if(js_CreateSystemObject(js_cx, js_glob, &scfg, uptime, startup->host_name, SOCKLIB_DESC)==NULL)
break;
#if 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment