shithub: ircd

ref: 9922e90ae9072e72a7f61c8328ad1f71cee6cf0f
dir: /reply.c/

View raw version
#include <u.h>
#include <libc.h>
#include <String.h>
#include "dat.h"
#include "fns.h"

char*
getreplies(Client *c)
{
	return s_to_c((String*)c->replies.reply);
}

void
flushreplies(Client *c)
{
	String *s;
	if (!c->replies.reply)
		return;
	s = c->replies.reply;
	s_reset(s);
}

void
reply(Client *c, Reply repl, ...)
{
	char buf[1024];
	int i;
	va_list arg;
	String *s = c->replies.reply;
	
	i = snprint(buf, sizeof buf, ":%s %03d ", sysnameb, repl.nr);
	
	va_start(arg, repl);
	i += vsnprint(&buf[i], sizeof(buf) - i, repl.msg, arg);
	va_end(arg);
	
	snprint(&buf[i], sizeof(buf) - i, "\r\n");
	s_append(s, buf);
}