Implemented OS detection routines provided by GS

svn path=/trunk/netsurf/; revision=11873
This commit is contained in:
Ole Loots 2011-03-01 19:27:34 +00:00
parent 46915c6b7b
commit a80af90142
4 changed files with 90 additions and 12 deletions

View File

@ -55,18 +55,24 @@ char *url_to_path(const char *url)
char *path;
/* return the absolute path including leading / */
if( atari_sysinfo.gdosversion > TOS4VER ) {
if( sys_type() & SYS_MINT ) {
path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN - 1));
} else {
/* do not include / within url_path */
path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN));
int l = strlen(path);
int i;
for( i = 0; i<l-1; i++){
char * drive = url_path + (FILE_SCHEME_PREFIX_LEN);
path = malloc( strlen(drive) + 4 );
int i=0;
path[i++] = drive[0];
path[i++] = ':';
path[i++] = 0x5C;
while( drive[i-1] != 0){
path[i] = drive[i-1];
if( path[i] == '/' ){
path[i] = 0x5C;
}
i++;
}
path[i] = 0;
LOG(("%s", path));
}
curl_free(url_path);

View File

@ -13,11 +13,52 @@
NS_ATARI_SYSINFO atari_sysinfo;
unsigned short _systype_v;
unsigned short _systype (void)
{
_systype_v = (_systype_v & ~0xF) | SYS_MINT | SYS_XAAES;
return _systype_v;
int32_t * cptr = NULL;
_systype_v = SYS_TOS;
cptr = Setexc(0x0168, -1L);
if (cptr == NULL ) {
return _systype_v; /* stone old TOS without any cookie support */
}
while (*cptr) {
if (*cptr == C_MgMc || *cptr == C_MgMx ) {
_systype_v = (_systype_v & ~0xF) | SYS_MAGIC;
} else if (*cptr == C_MiNT ) {
_systype_v = (_systype_v & ~0xF) | SYS_MINT;
} else if (*cptr == C_Gnva/*Gnva*/) {
_systype_v |= SYS_GENEVA;
} else if (*cptr == C_nAES/*nAES*/) {
_systype_v |= SYS_NAES;
}
cptr += 2;
}
if (_systype_v & SYS_MINT) { /* check for XaAES */
short out = 0, u;
if (wind_get (0, (((short)'X') <<8)|'A', &out, &u,&u,&u) && out) {
_systype_v |= SYS_XAAES;
}
}
return _systype_v;
}
void init_os_info(void)
{
int16_t out[4];
atari_sysinfo.gdosversion = Sversion();
unsigned long cookie_FSMC = 0;
atari_sysinfo.gemdos_version = Sversion();
if( tos_getcookie (C_FSMC, &cookie_FSMC ) == C_FOUND ) {
atari_sysinfo.gdos_FSMC = 1;
} else {
atari_sysinfo.gdos_FSMC = 0;
}
atari_sysinfo.large_sfont_pxh = 13;
atari_sysinfo.medium_sfont_pxh = 6;
atari_sysinfo.small_sfont_pxh = 4;
@ -28,6 +69,15 @@ void init_os_info(void)
}
if( appl_xgetinfo(AES_SMALLFONT, &out[0], &out[1], &out[2], &out[3] ) > 0 ){
atari_sysinfo.small_sfont_pxh = out[0];
}
atari_sysinfo.aes_max_win_title_len = 79;
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
if (sys_NAES()) {
atari_sysinfo.aes_max_win_title_len = 127;
}
if (sys_XAAES()) {
atari_sysinfo.aes_max_win_title_len = 200;
}
}
}
@ -36,7 +86,7 @@ int tos_getcookie(long tag, long * value)
COOKIE * cptr;
long oldsp;
if( atari_sysinfo.gdosversion > TOS4VER ){
if( atari_sysinfo.gemdos_version > TOS4VER ){
return( Getcookie(tag, value) );
}
@ -45,7 +95,9 @@ int tos_getcookie(long tag, long * value)
do {
if( cptr->c == tag ){
if(cptr->v != 0 ){
*value = cptr->v;
if( value != NULL ){
*value = cptr->v;
}
return( C_FOUND );
}
}
@ -86,7 +138,7 @@ char * gdos_realpath(const char * path, char * rpath)
if( rpath == NULL ){
return( NULL );
}
if( atari_sysinfo.gdosversion > TOS4VER ){
if( sys_type() & SYS_MINT ){
return( realpath(path, rpath) );
}

View File

@ -24,20 +24,39 @@ typedef struct {
long v;
} COOKIE;
/* System type detection added by [GS] */
#define SYS_TOS 0x0001
#define SYS_MAGIC 0x0002
#define SYS_MINT 0x0004
#define SYS_GENEVA 0x0010
#define SYS_NAES 0x0020
#define SYS_XAAES 0x0040
/* detect the system type, AES + kernel */
#define sys_type() (_systype_v ? _systype_v : _systype())
#define sys_MAGIC() ((sys_type() & SYS_MAGIC) != 0)
#define sys_NAES() ((sys_type() & SYS_NAES) != 0)
#define sys_XAAES() ((sys_type() & SYS_XAAES) != 0)
typedef struct {
unsigned short gdosversion;
unsigned short gemdos_version;
unsigned short gdos_FSMC;
unsigned short systype;
unsigned short small_sfont_pxh;
unsigned short medium_sfont_pxh;
unsigned short large_sfont_pxh;
bool sfont_monospaced;
short aes_max_win_title_len;
} NS_ATARI_SYSINFO;
extern NS_ATARI_SYSINFO atari_sysinfo;
extern unsigned short _systype_v;
#define TOS4VER 0x03000 /* this is assumed to be the last single tasking OS */
#define TOS4VER 0x03300 /* this is assumed to be the last single tasking OS */
void init_os_info(void);
int tos_getcookie( long tag, long * value );
void fix_path(char * path);
char * gdos_realpath(const char * path, char * rpath);
unsigned short _systype (void);
#endif

View File

@ -210,7 +210,8 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
} else {
vst_color( self->vdi_handle, BLACK );
}
if( atari_sysinfo.gdosversion > 0x03000 ){
if( atari_sysinfo.gdos_FSMC ){
v_ftext( self->vdi_handle, x, y, (char*)&textcpy );
} else {
v_gtext( self->vdi_handle, x, y, (char*)&textcpy );