Commit 0949880e authored by rswindell's avatar rswindell
Browse files

Created os_version function (from sbbs3/ver.cpp).

parent 886c29bd
...@@ -132,3 +132,59 @@ int DLLCALL xp_random(int n) ...@@ -132,3 +132,59 @@ int DLLCALL xp_random(int n)
return((int)(n*f)); return((int)(n*f));
} }
/****************************************************************************/
/* Write the version details of the current operating system into str */
/****************************************************************************/
char* DLLCALL os_version(char *str)
{
#if defined(__OS2__) && defined(__BORLANDC__)
sprintf(str,"OS/2 %u.%u (%u.%u)",_osmajor/10,_osminor/10,_osmajor,_osminor);
#elif defined(_WIN32)
/* Windows Version */
char* winflavor="";
OSVERSIONINFO winver;
winver.dwOSVersionInfoSize=sizeof(winver);
GetVersionEx(&winver);
switch(winver.dwPlatformId) {
case VER_PLATFORM_WIN32_NT:
winflavor="NT ";
break;
case VER_PLATFORM_WIN32s:
winflavor="Win32s ";
break;
case VER_PLATFORM_WIN32_WINDOWS:
winver.dwBuildNumber&=0xffff;
break;
}
sprintf(str,"Windows %sVersion %u.%02u (Build %u) %s"
,winflavor
,winver.dwMajorVersion, winver.dwMinorVersion
,winver.dwBuildNumber,winver.szCSDVersion);
#elif defined(__unix__)
struct utsname unixver;
if(uname(&unixver)!=0)
sprintf(str,"Unix (uname errno: %d)",errno);
else
sprintf(str,"%s %s %s"
,unixver.sysname /* e.g. "Linux" */
,unixver.release /* e.g. "2.2.14-5.0" */
,unixver.machine /* e.g. "i586" */
);
#else /* DOS */
sprintf(str,"DOS %u.%02u",_osmajor,_osminor);
#endif
return(str);
}
...@@ -146,6 +146,7 @@ extern "C" { ...@@ -146,6 +146,7 @@ extern "C" {
#endif #endif
DLLEXPORT int DLLCALL xp_random(int); DLLEXPORT int DLLCALL xp_random(int);
DLLEXPORT char* DLLCALL os_version(char *str);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
......
/* wraptest.c */ /* wraptest.c */
/* Verification of cross-platform development wrappers */
#include <time.h> /* ctime */ #include <time.h> /* ctime */
#include "genwrap.h" #include "genwrap.h"
...@@ -19,10 +21,11 @@ typedef struct { ...@@ -19,10 +21,11 @@ typedef struct {
int main() int main()
{ {
char str[128];
char compiler[128]; char compiler[128];
char* glob_pattern = "*wrap*";
char* path = ".";
char fullpath[MAX_PATH+1]; char fullpath[MAX_PATH+1];
char* path = ".";
char* glob_pattern = "*wrap*";
int i; int i;
int ch; int ch;
uint u; uint u;
...@@ -34,9 +37,10 @@ int main() ...@@ -34,9 +37,10 @@ int main()
/* Show platform details */ /* Show platform details */
DESCRIBE_COMPILER(compiler); DESCRIBE_COMPILER(compiler);
printf("Platform: %s\n",PLATFORM_DESC); printf("%-15s: %s\n","Platform",PLATFORM_DESC);
printf("Compiler: %s\n",compiler); printf("%-15s: %s\n","Version",os_version(str));
printf("Random #: %d\n",xp_random(1000)); printf("%-15s: %s\n","Compiler" ,compiler);
printf("%-15s: %d\n","Random Number",xp_random(1000));
printf("\ngetch() test (ESC to continue)\n"); printf("\ngetch() test (ESC to continue)\n");
do { do {
...@@ -136,10 +140,10 @@ int main() ...@@ -136,10 +140,10 @@ int main()
static void getkey(void) static void getkey(void)
{ {
printf("Hit any key..."); printf("Hit any key to continue...");
fflush(stdout); fflush(stdout);
getch(); getch();
printf("\r%20s\r",""); printf("\r%30s\r","");
fflush(stdout); fflush(stdout);
} }
......
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