From 3462356059756c2095919ad0b904bd1262d4bf80 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Sat, 22 Jan 2011 16:37:24 +0000 Subject: [PATCH] increased compatibility with classic TOS systems. (Getcookie() breaks on classic TOS systems.) svn path=/trunk/netsurf/; revision=11446 --- atari/misc.c | 32 ++++++++++++++++++++++++++++++++ atari/misc.h | 10 ++++++++++ 2 files changed, 42 insertions(+) diff --git a/atari/misc.c b/atari/misc.c index 674dd8639..5bfdd7f59 100644 --- a/atari/misc.c +++ b/atari/misc.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include "desktop/cookies.h" @@ -34,6 +36,35 @@ #include "atari/misc.h" extern void * h_gem_rsrc; +unsigned short gdosversion; + +void init_os_info(void) +{ + gdosversion = Sversion(); +} + +int tos_getcookie(long tag, long * value) +{ + COOKIE * cptr; + long oldsp; + + if( gdosversion > TOS4VER ){ + return( Getcookie(tag, value) ); + } + + cptr = (COOKIE*)Setexc(0x0168, -1L); + if(cptr != NULL) { + do { + if( cptr->c == tag ){ + if(cptr->v != NULL ){ + *value = cptr->v; + return( C_FOUND ); + } + } + } while( (cptr++)->c != 0L ); + } + return( C_NOTFOUND ); +} void warn_user(const char *warning, const char *detail) { @@ -47,6 +78,7 @@ void warn_user(const char *warning, const char *detail) void die(const char *error) { printf("%s\n", error); + sleep( 3 ); exit(1); } diff --git a/atari/misc.h b/atari/misc.h index a2da94095..852a93236 100644 --- a/atari/misc.h +++ b/atari/misc.h @@ -19,6 +19,13 @@ #ifndef NS_ATARI_MISC_H #define NS_ATARI_MISC_H +typedef struct { + long c; + long v; +} COOKIE; + +#define TOS4VER 0x03000 /* this is assumed to be the last single tasking OS */ + #define SBUF8_TO_LBUF8(sbuf,lbuf)\ lbuf[0] = (long)sbuf[0];\ lbuf[1] = (long)sbuf[1];\ @@ -29,10 +36,13 @@ lbuf[6] = (long)sbuf[6];\ lbuf[7] = (long)sbuf[7]; + struct gui_window * find_root_gui_window( WINDOW * win ); struct gui_window * find_cmp_window( COMPONENT * c ); OBJECT *get_tree( int idx ); char *get_rsc_string( int idx ); void gem_set_cursor( MFORM_EX * cursor ); void dbg_grect( char * str, GRECT * r ); +void init_os_info(void); +int tos_getcookie( long tag, long * value ); #endif \ No newline at end of file