From 2ed3be21a87adb7289468a1166b26eed3aa2b92f Mon Sep 17 00:00:00 2001 From: mazze Date: Wed, 16 May 2012 05:58:34 +0000 Subject: [PATCH] Test if the trick to get the template of a DOS command is working. That trick is necessary if we want to clone or port a tool like "R". git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@44816 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- test/dos/mmakefile.src | 4 ++-- test/dos/r.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 test/dos/r.c diff --git a/test/dos/mmakefile.src b/test/dos/mmakefile.src index 62a2cbe37d..e9010bfb12 100644 --- a/test/dos/mmakefile.src +++ b/test/dos/mmakefile.src @@ -1,4 +1,4 @@ -# Copyright © 2003-2011, The AROS Development Team. All rights reserved. +# Copyright © 2003-2012, The AROS Development Team. All rights reserved. # $Id$ include $(TOP)/config/make.cfg @@ -7,7 +7,7 @@ FILES := getenv namefromfh examinefh examinelock \ isinteractive \ notify setfiledate output setenv inhibit doslist \ readargs readitem readitemloop runcommand \ - openfromlock + openfromlock r PURE_FILES := exit EXEDIR := $(AROS_TESTS)/dos diff --git a/test/dos/r.c b/test/dos/r.c new file mode 100644 index 0000000000..249786872b --- /dev/null +++ b/test/dos/r.c @@ -0,0 +1,47 @@ +#include +#include + +#include + +TEXT buffer[100]; + +/* + * A tool like "R" http://www.geit.de/eng_r.html requires that we can + * call a command such that it prints the template and then stops. + */ + +int main(void) +{ + // in the real "R" we would check for an unused file name first + BPTR input = Open("t:00000001.request.infile", MODE_NEWFILE); + BPTR output = Open("t:00000001.request.outfile", MODE_NEWFILE); + + // shut up DOS error message + struct Process *me = (struct Process*)FindTask(NULL); + BPTR oldwin = me->pr_WindowPtr; + me->pr_WindowPtr = (BPTR)-1; + + // execute the command. The purpose of "*>NIL:" is to + // trigger an error + Execute("dir *>NIL: ?", input, output); + + // restore window ptr + me->pr_WindowPtr = oldwin; + + Seek(output, 0, OFFSET_BEGINNING); + + // read the template + if (FGets(output, buffer, sizeof buffer)) + { + bug("*****\n%s*****\n", buffer); + } + else + { + bug("%s\n", "-----"); + } + + Close(input); + Close(output); + + return 0; +} -- 2.11.4.GIT