home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
newc_dev
/
autores.lha
/
AutoRes.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-07
|
2KB
|
61 lines
/* autores.c
*
* autores, a small resident stub, you add it to the resident list, with
* the name of the program you really want to be resident, and when it is
* run first, it makes the real program resident, and then runs it..
*
*/
#include <exec/types.h>
#include <exec/execbase.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
extern struct ExecBase *SysBase;
extern void _exit(int); /* don't know where the real prototype is */
int
_main(arglen, argptr)
int arglen;
char *argptr;
{
char buf[35] = "C:"; /* only allows for 32 char filenames */
char *name = buf+2;
int rc = RETURN_FAIL; /* default fail return */
if( GetProgramName(name,30) ) {
BPTR L;
if( L = Lock(buf,SHARED_LOCK) ) {
BPTR S;
if( S = LoadSeg(buf) ) {
/* is this a bug in dos.library? should be *
* passing 0 here according to the v37 AutoDocs*/
if( AddSegment(name,S,1) ) {
struct Segment *Seg;
Forbid();
if( Seg = FindSegment(name,NULL,0) ) {
/* I wouldn't have got past the Lock() if I was a Task */
long stack = ((struct Process *)SysBase->ThisTask)->pr_StackSize;
Seg->seg_UC += 1;
Permit();
rc = RunCommand(Seg->seg_Seg,stack,argptr,arglen);
Forbid();
Seg->seg_UC -= 1;
}
Permit();
} else
UnLoadSeg(S); /* only if AddSegment failed */
}
UnLock(L);
}
}
_exit(rc);
}