2009-07-28 17:17:23 +02:00
|
|
|
/*
|
2016-02-26 17:54:05 +01:00
|
|
|
* Copyright 2003-2016 The Music Player Daemon Project
|
2009-07-28 17:17:23 +02:00
|
|
|
* http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2009-11-12 09:12:38 +01:00
|
|
|
#include "config.h"
|
2015-08-06 10:32:18 +02:00
|
|
|
#include "Client.hxx"
|
2013-10-19 16:58:45 +02:00
|
|
|
#include "util/FormatString.hxx"
|
2016-04-12 22:27:15 +02:00
|
|
|
#include "util/AllocatedString.hxx"
|
2013-08-08 00:14:13 +02:00
|
|
|
|
2009-07-28 17:17:23 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2015-08-06 10:31:53 +02:00
|
|
|
bool
|
|
|
|
Client::Write(const void *data, size_t length)
|
2009-07-28 17:17:23 +02:00
|
|
|
{
|
|
|
|
/* if the client is going to be closed, do nothing */
|
2015-08-06 10:31:53 +02:00
|
|
|
return !IsExpired() && FullyBufferedSocket::Write(data, length);
|
2009-07-28 17:17:23 +02:00
|
|
|
}
|
|
|
|
|
2016-04-12 22:32:35 +02:00
|
|
|
bool
|
|
|
|
Client::Write(const char *data)
|
|
|
|
{
|
|
|
|
return Write(data, strlen(data));
|
|
|
|
}
|
|
|
|
|
2013-01-03 17:27:26 +01:00
|
|
|
void
|
2013-10-19 18:48:38 +02:00
|
|
|
client_puts(Client &client, const char *s)
|
2009-07-28 17:17:23 +02:00
|
|
|
{
|
2016-04-12 22:32:35 +02:00
|
|
|
client.Write(s);
|
2009-07-28 17:17:23 +02:00
|
|
|
}
|
|
|
|
|
2013-01-03 17:27:26 +01:00
|
|
|
void
|
2013-10-19 18:48:38 +02:00
|
|
|
client_vprintf(Client &client, const char *fmt, va_list args)
|
2009-07-28 17:17:23 +02:00
|
|
|
{
|
2016-04-12 22:27:15 +02:00
|
|
|
client.Write(FormatStringV(fmt, args).c_str());
|
2009-07-28 17:17:23 +02:00
|
|
|
}
|
|
|
|
|
2013-01-03 17:27:26 +01:00
|
|
|
void
|
2013-10-19 18:48:38 +02:00
|
|
|
client_printf(Client &client, const char *fmt, ...)
|
2009-07-28 17:17:23 +02:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
client_vprintf(client, fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|