/* RUNNER.C From: AMIGA.4243
*
*
* runner.c July 29/86 Rico Mariani
* runs CLI commands from the comment field of an icon
*
*/
#include <exec/types.h>
#include <workbench/startup.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <stdio.h>
struct FileLock *Lock();
struct FileLock *CurrentDir();
main(argc,WBenchMsg)
int argc;
struct WBStartup *WBenchMsg;
{
struct WBArg *arg;
struct FileLock *olddir;
char buf[80];
int stat;
if (argc) {
printf("run from workbench\n");
exit(999);
}
arg = WBenchMsg->sm_ArgList;
if (WBenchMsg->sm_NumArgs != 2 )
exit(999);
arg++;
if (arg->wa_Lock) {
olddir = CurrentDir(arg->wa_Lock);
strcpy(buf,arg->wa_Name);
stat = runit(buf);
CurrentDir(olddir);
exit (stat);
}
exit(999);
}
runit(buf)
char *buf;
{
struct FileLock *lock;
struct FileInfoBlock fib;
lock = Lock(buf,ACCESS_READ);
if (!lock) return(999);
if (!Examine(lock,&fib)) { UnLock(lock); return(999); }
UnLock(lock);
return(Execute(fib.fib_Comment,0L,0L));
}