@@ -34,17 +34,22 @@ #import "OFApplication.h" #ifdef OF_WINDOWS # include "OFStdIOStream_Win32Console.h" #endif +#import "OFInitializationFailedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_AMIGAOS -# define __USE_INLINE__ +# ifdef OF_AMIGAOS4 +# define __USE_INLINE__ +# define __NOLIBBASE__ +# define __NOGLOBALIFACE__ +# endif # include # include #endif /* References for static linking */ @@ -53,10 +58,16 @@ _reference_to_OFStdIOStream_Win32Console(void) { [OFStdIOStream_Win32Console class]; } #endif + +#ifdef OF_AMIGAOS4 +extern struct ExecIFace *IExec; +static struct Library *DOSBase = NULL; +static struct DOSIFace *IDOS = NULL; +#endif OFStdIOStream *of_stdin = nil; OFStdIOStream *of_stdout = nil; OFStdIOStream *of_stderr = nil; @@ -64,10 +75,18 @@ OF_DESTRUCTOR() { [of_stdin dealloc]; [of_stdout dealloc]; [of_stderr dealloc]; + +# ifdef OF_AMIGAOS4 + if (IDOS != NULL) + DropInterface(IDOS); + + if (DOSBase != NULL) + CloseLibrary(DOSBase); +# endif } #endif void of_log(OFConstantString *format, ...) @@ -103,15 +122,29 @@ # ifndef OF_AMIGAOS of_stdin = [[OFStdIOStream alloc] of_initWithFileDescriptor: 0]; of_stdout = [[OFStdIOStream alloc] of_initWithFileDescriptor: 1]; of_stderr = [[OFStdIOStream alloc] of_initWithFileDescriptor: 2]; # else - BPTR input = Input(), output = Output(); - BPTR error = ((struct Process *)FindTask(NULL))->pr_CES; + BPTR input, output, error; bool inputClosable = false, outputClosable = false, errorClosable = false; +# ifdef OF_AMIGAOS4 + if ((DOSBase = OpenLibrary("dos.library", 36)) == NULL) + @throw [OFInitializationFailedException + exceptionWithClass: self]; + + if ((IDOS = (struct DOSIFace *) + GetInterface(DOSBase, "main", 1, NULL)) == NULL) + @throw [OFInitializationFailedException + exceptionWithClass: self]; +# endif + + input = Input(); + output = Output(); + error = ((struct Process *)FindTask(NULL))->pr_CES; + if (input == 0) { input = Open("*", MODE_OLDFILE); inputClosable = true; }