/* hotkey.c -- support function for creating Commodities hotkey triad	*/

#include "sysall.h"

#include	"cx/cxusr.h"
#define D(x)	;

extern struct Library	*CxBase;

CxObj	*
HotKey(descr, port, ID)
char			*descr;
struct MsgPort	*port;
LONG			ID;
{
	CxObj	*filter;
	LONG	error;

	/*	create filter	*/
	filter = CxFilter( descr );
	if (!filter)
	{
		D( printf("HotKey: Failed filter\n") );
		return (NULL);
	}

	/*	create sender	*/
	AttachCxObj(filter, CxSender(port, ID) );

	/*	create swallow	*/
	AttachCxObj(filter, CxTranslate(NULL) );

	/* if any problems, delete all	*/
	if (error = CxObjError(filter))
	{
		D( printf("accumulated filter error: %ld\n", error) );
		DeleteCxObjAll(filter);
		return (NULL);
	}

	return (filter);
}
