Esempio n. 1
0
void
replymsg(Wsysmsg *m)
{
	int n;
	static uchar *mbuf;
	static int nmbuf;

	/* T -> R msg */
	if(m->type%2 == 0)
		m->type++;
		
	if(trace) fprint(2, "-> %W\n", m);
	/* copy to output buffer */
	n = sizeW2M(m);

	qlock(&replylock);
	if(n > nmbuf){
		free(mbuf);
		mbuf = malloc(n);
		if(mbuf == nil)
			sysfatal("out of memory");
		nmbuf = n;
	}
	convW2M(m, mbuf, n);
	if(write(4, mbuf, n) != n)
		sysfatal("write: %r");
	qunlock(&replylock);
}
Esempio n. 2
0
/*
 * Reply to m.
 */
void
replymsg(Wsysmsg *m)
{
	int n;

	/* T -> R msg */
	if(m->type%2 == 0)
		m->type++;
		
	/* fprint(2, "-> %W\n", m); */
	/* copy to output buffer */
	n = sizeW2M(m);
	if(fdout.wp+n > fdout.ep)
		sysfatal("out of space for reply message");
	convW2M(m, fdout.wp, n);
	fdout.wp += n;
}
Esempio n. 3
0
uint
convW2M(Wsysmsg *m, uchar *p, uint n)
{
	int nn;
	
	nn = sizeW2M(m);
	if(n < nn || nn == 0 || n < 6)
		return 0;
	PUT(p, nn);
	p[4] = m->tag;
	p[5] = m->type;

	switch(m->type){
	default:
		return 0;
	case Trdmouse:
	case Rbouncemouse:
	case Rmoveto:
	case Rcursor:
	case Trdkbd:
	case Rlabel:
	case Rinit:
	case Trdsnarf:
	case Rwrsnarf:
	case Ttop:
	case Rtop:
	case Rresize:
		break;
	case Rerror:
		PUTSTRING(p+6, m->error);
		break;
	case Rrdmouse:
		PUT(p+6, m->mouse.xy.x);
		PUT(p+10, m->mouse.xy.y);
		PUT(p+14, m->mouse.buttons);
		PUT(p+18, m->mouse.msec);
		p[19] = m->resized;
		break;
	case Tbouncemouse:
		PUT(p+6, m->mouse.xy.x);
		PUT(p+10, m->mouse.xy.y);
		PUT(p+14, m->mouse.buttons);
		break;
	case Tmoveto:
		PUT(p+6, m->mouse.xy.x);
		PUT(p+10, m->mouse.xy.y);
		break;
	case Tcursor:
		PUT(p+6, m->cursor.offset.x);
		PUT(p+10, m->cursor.offset.y);
		memmove(p+14, m->cursor.clr, sizeof m->cursor.clr);
		memmove(p+46, m->cursor.set, sizeof m->cursor.set);
		PUT(p+78, m->cursor2.offset.x);
		PUT(p+82, m->cursor2.offset.y);
		memmove(p+86, m->cursor2.clr, sizeof m->cursor2.clr);
		memmove(p+214, m->cursor2.set, sizeof m->cursor2.set);
		p[342] = m->arrowcursor;
		break;
	case Rrdkbd:
		PUT2(p+6, m->rune);
		break;
	case Tlabel:
		PUTSTRING(p+6, m->label);
		break;
	case Tinit:
		p += 6;
		p += PUTSTRING(p, m->winsize);
		p += PUTSTRING(p, m->label);
		break;
	case Rrdsnarf:
	case Twrsnarf:
		PUTSTRING(p+6, m->snarf);
		break;
	case Rrddraw:
	case Twrdraw:
		PUT(p+6, m->count);
		memmove(p+10, m->data, m->count);
		break;
	case Trddraw:
	case Rwrdraw:
		PUT(p+6, m->count);
		break;
	case Tresize:
		PUT(p+6, m->rect.min.x);
		PUT(p+10, m->rect.min.y);
		PUT(p+14, m->rect.max.x);
		PUT(p+18, m->rect.max.y);
		break;
	}		
	return nn;
}