#ifndef lint
static char *RCSid = "$Header: send.c,v 1.2 90/03/19 10:41:16 mr-frog Exp $";
#endif

/*
 * send.c
 *
 * send something to a client.
 *
 * Dave Pare, 1986
 */


#include <stdio.h>
#include <sys/types.h>
#include "misc.h"
#include "user.h"
#include "tm.h"

extern	struct user userlist;

sendnum(iop, seq, n)
	struct iop *iop;
	int	seq;
	int	n;
{
	s_char	buf[30];

	(void) sprintf(buf, "%d %d\n", n, seq);
	(void) io_puts(iop, buf);
}

sendstr(iop, p)
	struct iop *iop;
	s_char	*p;
{
	(void) io_puts(iop, p);
}

bcast(p)
	s_char	*p;
{
	register struct user *up;
	register struct qelem *qp;

	for (qp=userlist.queue.q_forw; qp != &userlist.queue; qp=qp->q_forw) {
		up = (struct user *) qp;
		if (up->u_iop == 0)
			continue;
		(void) io_puts(up->u_iop, p);
	}
}

mcast(p, cnum)
	s_char	*p;
	int	cnum;
{
	register struct user *up;
	register struct qelem *qp;

	for (qp=userlist.queue.q_forw; qp != &userlist.queue; qp=qp->q_forw) {
		up = (struct user *) qp;
		if (up->u_cnum != cnum)
			continue;
		(void) io_puts(up->u_iop, p);
	}
}
