Commit fd5d4283 authored by Max Kellermann's avatar Max Kellermann

Client: add WriteString()

parent 4eaa82fd
...@@ -110,6 +110,11 @@ public: ...@@ -110,6 +110,11 @@ public:
bool Write(const void *data, size_t length); bool Write(const void *data, size_t length);
/** /**
* Write a null-terminated string.
*/
bool Write(const char *data);
/**
* returns the uid of the client process, or a negative value * returns the uid of the client process, or a negative value
* if the uid is unknown * if the uid is unknown
*/ */
......
...@@ -30,17 +30,23 @@ Client::Write(const void *data, size_t length) ...@@ -30,17 +30,23 @@ Client::Write(const void *data, size_t length)
return !IsExpired() && FullyBufferedSocket::Write(data, length); return !IsExpired() && FullyBufferedSocket::Write(data, length);
} }
bool
Client::Write(const char *data)
{
return Write(data, strlen(data));
}
void void
client_puts(Client &client, const char *s) client_puts(Client &client, const char *s)
{ {
client.Write(s, strlen(s)); client.Write(s);
} }
void void
client_vprintf(Client &client, const char *fmt, va_list args) client_vprintf(Client &client, const char *fmt, va_list args)
{ {
char *p = FormatNewV(fmt, args); char *p = FormatNewV(fmt, args);
client.Write(p, strlen(p)); client.Write(p);
delete[] p; delete[] p;
} }
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "Client.hxx" #include "Client.hxx"
#include "util/FormatString.hxx" #include "util/FormatString.hxx"
#include <string.h>
bool bool
Response::Write(const void *data, size_t length) Response::Write(const void *data, size_t length)
{ {
...@@ -33,7 +31,7 @@ Response::Write(const void *data, size_t length) ...@@ -33,7 +31,7 @@ Response::Write(const void *data, size_t length)
bool bool
Response::Write(const char *data) Response::Write(const char *data)
{ {
return Write(data, strlen(data)); return client.Write(data);
} }
bool bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment