/*
**      $VER: runback.c 1.0 (4.4.99)
**
**      RunBack replacement
**
**      (C) 1999 by Andreas R. Kleinert
**      All rights reserved.
*/

#define __USE_SYSBASE

#include <exec/types.h>

#include <dos/dos.h>
#include <dos/dostags.h>

#include <proto/exec.h>
#include <proto/dos.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

UBYTE __aligned version[] = "\0$VER: RunBack 1.0 (4.4.99)";

int main(int argc, char **argv)
{
 ULONG retval = 0;
 ULONG i;
 struct TagItem tags[4];
 UBYTE args[256];

 if(!argc) return(retval); /* Workbench */

 args[0] = (UBYTE) 0;

 for(i=1; i<argc; i++)
  {
   strcat(args, "\42");
   strcat(args, argv[i]);
   strcat(args, "\42 ");
  }

 args[strlen(args)-1] = (UBYTE) 0;

 tags[0].ti_Tag  = NP_StackSize;
 tags[0].ti_Data = 32768;

 tags[1].ti_Tag  = NP_Input;
 tags[1].ti_Data = Open("NULL:", MODE_NEWFILE);

 tags[2].ti_Tag  = NP_Output;
 tags[2].ti_Data = Open("NULL:", MODE_OLDFILE);

 tags[3].ti_Tag  = TAG_DONE;
 tags[3].ti_Data = NULL;

 retval = SystemTagList(args, &tags[0]);
 if(retval == -1) retval = 20;

 exit(retval);
}
