00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <libplumbing/config.h>
00019 #include <libexplain/write.h>
00020
00021 #include <libplumbing/endpoint/client/stdout.h>
00022 #include <libplumbing/logging.h>
00023
00024
00025 plumbing::endpoint_client_stdout::~endpoint_client_stdout()
00026 {
00027 }
00028
00029
00030 plumbing::endpoint_client_stdout::endpoint_client_stdout(
00031 const std::string &a_hostname, int a_port_number) :
00032 endpoint_client(a_hostname, a_port_number)
00033 {
00034 }
00035
00036
00037 plumbing::endpoint::pointer
00038 plumbing::endpoint_client_stdout::create(const std::string &a_hostname,
00039 int a_port_number)
00040 {
00041 return pointer(new endpoint_client_stdout(a_hostname, a_port_number));
00042 }
00043
00044
00045 plumbing::endpoint_client_stdout::endpoint_client_stdout(
00046 const std::string &a_hostname, const std::string &a_port_number) :
00047 endpoint_client(a_hostname, a_port_number)
00048 {
00049 }
00050
00051
00052 plumbing::endpoint::pointer
00053 plumbing::endpoint_client_stdout::create(const std::string &a_hostname,
00054 const std::string &a_port_number)
00055 {
00056 return pointer(new endpoint_client_stdout(a_hostname, a_port_number));
00057 }
00058
00059
00060 void
00061 plumbing::endpoint_client_stdout::data_received(const void *data, size_t nbytes)
00062 {
00063 if (nbytes == 0)
00064 {
00065 kill_me_now();
00066 return;
00067 }
00068 int ofd = fileno(stdout);
00069 if (ssize_t(nbytes) != ::write(ofd, data, nbytes))
00070 {
00071 log().fatal_error("%s", explain_write(ofd, data, nbytes));
00072 kill_me_now();
00073 }
00074 }
00075
00076
00077