home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 9
/
FreshFishVol9-CD2.bin
/
bbs
/
util
/
rsys-1.3.lha
/
RSys
/
Goodies
/
TBreak
/
TBreak.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-22
|
2KB
|
101 lines
#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>
#include <stdio.h>
#include <string.h>
#define STRINGEND '\0'
char *
B2CStr(char *ret, BSTR inp)
{
register int i;
char *help = (char *)BADDR(inp);
for (i = 0; i < *help; i++)
*(ret + i) = *(help + i + 1);
*(ret + i) = STRINGEND;
return (ret);
}
int
main(int argc,char **argv)
{
struct DOSBase *DOSBase = NULL;
extern struct ExecBase *SysBase;
int ret = RETURN_FAIL;
if(DOSBase = (struct DOSBase *)OpenLibrary((STRPTR)"dos.library", 33L))
{
struct Node *node,*membernode[200];
struct CommandLineInterface *CLI;
char modname[200];
int i,j,out;
if(argc != 2)
Printf((STRPTR)"Aufruf: %s <taskname>\n",argv[0]);
else
{
Forbid();
Disable();
for (node = SysBase->TaskWait.lh_Head;
node->ln_Succ&& i < 200; node = node->ln_Succ)
membernode[i++] = node;
for (node = SysBase->TaskReady.lh_Head;
node->ln_Succ && i < 200; node = node->ln_Succ)
membernode[i++] = node;
if (i < 200)
membernode[i++] = &SysBase->ThisTask->tc_Node;
Enable();
out = FALSE;
for (j = 0; j < i && !out && i < 200; j++)
{
struct Process *proc = (struct Process *)membernode[j];
if(CLI = (struct CommandLineInterface *)BADDR(proc->pr_CLI))
{
B2CStr(modname,CLI->cli_CommandName);
if (!strcmp(argv[1],modname))
{
Signal((struct Task *)proc,
SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D |
SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F);
out = TRUE;
}
}
}
Permit();
if(out == TRUE)
Printf((STRPTR)"Task with command \'%s\' signaled...\n",argv[1]);
if(i >= 200)
PutStr((UBYTE *)"More than 200 tasks read!\n");
ret = RETURN_OK;
}
CloseLibrary((struct Library *)DOSBase);
}
return(ret);
}