#include "intern.h"

static char		*glob_str = NULL;
static short	msg[8];

void send_vastart(int id, char *str)
{
	if (!glob_str)
		glob_str = (char *)cf_malloc(256, "send_vastart", TRUE);
		
	strcpy(glob_str, str);
	msg[0] = 0x4711;		/* VA_START */
	msg[1] = gl_apid;
	msg[2] = 0;
	ol2ts((long)glob_str, &msg[3], &msg[4]);
	msg[5] = 0;
	msg[6] = 0;
	msg[7] = 0;
	appl_write(id, (int)sizeof(msg), msg);
}

void send_m_special(int mode, int app)
{
	if (gl_magx)
	{
		int	id;

		msg[0] = SM_M_SPECIAL;
		msg[1] = gl_apid;
		msg[2] = 0;
		msg[3] = 0;
		msg[4] = 0x4D41;	/* 'MA' */
		msg[5] = 0x4758;	/* 'GX' */
		msg[6] = mode;
		msg[7] = app;
		id = appl_find("SCRENMGR");
		appl_write(id, (int)sizeof(msg), msg);
	}
}

void send_scchanged(void)
{
	int	d, i;

	/* gibts Broadcast? */
	if (((appl_xgetinfo(10, &i, &d, &d, &d)) && ((i&0x00FF) >= 7))
		 || (gl_magx >= 0x400))
	{
		msg[0] = SC_CHANGED;	/* alle anderen Applikationen */
		msg[1] = gl_apid;
		msg[2] = 0;
		msg[3] = 0x0002;	/* Text */
		msg[4] = 0x2E54;	/* '.T' */
		msg[5] = 0x5845;	/* 'XT' */
		msg[6] = 0;
		msg[7] = 0;
		shel_write(7, 0, 0, (char *)msg, NULL);
	}
}
