| Q D E V _ H L P _ R E M O T E ( )
| | | | | SOURCE: qdev_macros.txt 1.16 (12/09/2014) English
AMIGA - PUBLIC
----------------------------------------------------------------------------
NAME
QDEV_HLP_REMOTE() - Executes code that alters alien TCB.
SYNOPSIS
QDEV_HLP_REMOTE(tc, code);
QDEV_HLP_REMOTE((struct Task *), <code>);
FUNCTION
This macro allows to affect alien TCB by pretending that
SysBase->ThisTask is it. This macro does not inject code
in alien/remote task!
INPUTS
tc - Remote task address.
code - Code to be executed that will affect 'tc'.
RETURNS
No output.
BASES
SysBase
NOTES
Must use this macro in either: QDEV_HLP_NOSWITCH() and/or
QDEV_HLP_NOINTSEC() and cannot call routines that break
forbidden state!
SEE ALSO
QDEV_HLP_NOSWITCH(), QDEV_HLP_NOINTSEC()
EXAMPLE
#include <proto/exec.h>
#include <exec/execbase.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <qdev.h>
...
struct Window *win;
struct FileHandle *fh;
struct MsgPort *mp;
UBYTE *ptr;
LONG fd;
/*
* This example shows how to change screen bar text that
* the shell window sets when becomes active.
*/
if ((fd = Open("CONSOLE:", MODE_OLDFILE)))
{
if ((win = nfo_getwinaddr(fd)))
{
if (nfo_iswindow(win))
{
/*
* OK, now we are sure that the shell has its own
* window. Lets find out what is the address of a
* CON: process for this window.
*/
fh = QDEV_HLP_BADDR(fd);
mp =
(struct MsgPort *)QDEV_HLP_ABS((LONG)fh->fh_Type);
/*
* Attempt to allocate self-deallocating memory as
* if CON: did it.
*/
QDEV_HLP_NOSWITCH
(
QDEV_HLP_REMOTE
(
mp->mp_SigTask,
/*
* This memory will be deallocated upon CON:'s
* death (when you close the shell typically).
*/
ptr = mem_alloclfvec(32, MEMF_PUBLIC);
);
if (ptr)
{
/*
* Fill that mem. with some text and set it as
* a new screen bar text.
*/
*ptr = 0;
txt_strncat(ptr, "My new screen title!", 32);
/*
* Not safe to call in 'QDEV_HLP_REMOTE()' !!!
*/
SetWindowTitles(win, (UBYTE *)-1, ptr);
}
);
}
}
Close(fd);
}
...
BUGS
None known.
----------------------------------------------------------------------------
| |
| |