145 lines
2.0 KiB
C
145 lines
2.0 KiB
C
/*
|
|
* $Id$
|
|
*/
|
|
|
|
#include <extend.h>
|
|
|
|
#ifdef __WATCOMC__
|
|
#include <i86.h>
|
|
#endif
|
|
|
|
HARBOUR OS()
|
|
{
|
|
#ifdef __GNUC__
|
|
|
|
_retc("UNKNOWN");
|
|
|
|
#else
|
|
|
|
/* TODO: add MSVC support but MSVC cannot detect any OS except Windows! */
|
|
#if defined(__TURBOC__) || defined(__BORLANDC__)
|
|
|
|
#if defined(_Windows)
|
|
_retc( "Windows" );
|
|
#else
|
|
/* detect OS/2 */
|
|
_AX = 0x2B01;
|
|
_CX = 0x4445;
|
|
_DX = 0x5351;
|
|
_AH = 0x30;
|
|
geninterrupt(0x21);
|
|
if(_AL >= 10)
|
|
{
|
|
_retc("OS/2");
|
|
}
|
|
|
|
/* detect Windows */
|
|
/* TODO: get Windows version (major, minor) */
|
|
_AX = 0x160A;
|
|
geninterrupt(0x2F);
|
|
if(_AX == 0)
|
|
{
|
|
_retc("Windows");
|
|
}
|
|
#endif
|
|
|
|
#else
|
|
|
|
union REGS regs;
|
|
|
|
/* detect OS/2 */
|
|
regs.h.ah = 0x30;
|
|
|
|
#if defined(__WATCOMC__) && defined(__386__)
|
|
|
|
int386(0x21, ®s, ®s);
|
|
|
|
#else
|
|
|
|
#if defined(__EMX__)
|
|
|
|
_int86(0x21, ®s, ®s);
|
|
|
|
#else
|
|
|
|
int86(0x21, ®s, ®s);
|
|
|
|
#endif /* __EMX__ */
|
|
|
|
if(regs.h.al >= 10)
|
|
{
|
|
_retc("OS/2");
|
|
return();
|
|
}
|
|
|
|
#endif /* WATCOMC */
|
|
|
|
/* TODO: get Windows version (major, minor) */
|
|
/* detect Windows */
|
|
regs.w.ax = 0x160A;
|
|
|
|
#if defined(__WATCOMC__) && defined(__386__)
|
|
|
|
int386(0x2F, ®s, ®s);
|
|
|
|
#else
|
|
|
|
#if defined(__EMX__)
|
|
|
|
_int86(0x2F, ®s, ®s);
|
|
|
|
#else
|
|
|
|
int86(0x2F, ®s, ®s);
|
|
|
|
#endif /* EMX */
|
|
|
|
if(regs.x.ax == 0)
|
|
{
|
|
_retc("Windows");
|
|
return();
|
|
}
|
|
|
|
#endif /* WATCOMC */
|
|
|
|
#endif /* __TURBOC__ or __BORLANDC__ */
|
|
|
|
/* fall through to MS-DOS */
|
|
/* TODO: detect other OSes */
|
|
/* TODO: detect MS-DOS version */
|
|
_retc("MS-DOS");
|
|
|
|
#endif /* __GNUC__ */
|
|
}
|
|
|
|
HARBOUR VERSION()
|
|
{
|
|
_retc( "Harbour alpha version" );
|
|
}
|
|
|
|
HARBOUR GETENV()
|
|
{
|
|
if( _pcount() == 1 )
|
|
{
|
|
char *szName = _parc(1);
|
|
long lName = _parclen(1);
|
|
|
|
while( lName && szName[lName - 1] == '=' )
|
|
{
|
|
/* strip the '=' or else it will clear the variable! */
|
|
szName[lName - 1] = 0;
|
|
lName--;
|
|
}
|
|
if( lName )
|
|
{
|
|
char *Value = getenv(szName);
|
|
_retc(Value? Value: "");
|
|
}
|
|
else
|
|
_retc("");
|
|
}
|
|
else
|
|
_retc("");
|
|
}
|
|
|