#ifndef lint
static char *RCSid = "$Header: sendclient.c,v 1.4 90/03/19 11:29:50 mr-frog Exp $";
#endif

/*
 * sendclient.c
 *
 * send and recieve commands
 *
 * Dave Pare, 1986
 */

#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <errno.h>
#include "proto.h"
#include "user.h"
#include "misc.h"

#include "io.h"

void
sendclient(iop, val, str)
	struct iop *iop;
	int	val;
	s_char	*str;
{
	s_char	buf[255];

	if (val != 0 && str != NULL)
		(void) sprintf(buf, "%d %s\n", val, str);
	else if (str != NULL)
		(void) sprintf(buf, "%s\n", str);
	else if (val != 0)
		(void) sprintf(buf, "%d\n", val);
	(void) io_puts(iop, buf);
}

int
recvclient(iop, cmd, bp)
	struct iop *iop;
	s_char	*cmd;
	s_char	*bp;
{
	s_char	buf[255];

	*buf = 0;
	if (io_gets(iop, buf, sizeof(buf)) < 0)
		return 0;
	*bp = 0;
	*cmd = 0;
	(void) sscanf(buf, "%s %[^\n]s", cmd, bp);
	return 1;
}
