///////////////////////////////ct.p////////////////////////////////////////
template <class Policy>
-prefix_ std::string satcom::lib::ClientSocketHandle<Policy>::read()
+prefix_ std::string satcom::lib::ClientSocketHandle<Policy>::read(unsigned limit)
{
std::string rv;
- this->read(rv);
+ this->read(rv,limit);
return rv;
}
template <class Policy>
-prefix_ void satcom::lib::ClientSocketHandle<Policy>::read(std::string & buffer)
+prefix_ void satcom::lib::ClientSocketHandle<Policy>::read(std::string & buffer, unsigned limit)
{
unsigned nread = available();
+ if (limit>0 && nread>limit)
+ nread = limit;
// FIXME: This is not necessary correct and more or less a hack ...
buffer.assign(nread,0);
unsigned rv = this->read(const_cast<char *>(buffer.data()),nread);
///@{
// read from socket (connected or unconnected)
- std::string read ();
- void read (std::string & buffer);
+ std::string read (unsigned limit=0);
+ void read (std::string & buffer, unsigned limit=0);
unsigned read (char * buffer, unsigned size);
// read from unconnected socket returning peer address
switch (errno) {
case EWOULDBLOCK:
return -1;
- break;
case EINTR:
break;
default:
return body().valid();
}
-prefix_ satcom::lib::FileHandle::operator bool ()
+prefix_ bool satcom::lib::FileHandle::boolean_test()
const
{
return valid() && !eof();
}
-prefix_ bool satcom::lib::FileHandle::operator!()
- const
-{
- return ! (valid() && !eof());
-}
-
prefix_ int satcom::lib::FileHandle::fd()
const
{
return handle;
}
+prefix_ int satcom::lib::retrieve_filehandle(FileHandle handle)
+{
+ return handle.fd();
+}
+
///////////////////////////////cci.e///////////////////////////////////////
#undef prefix_
// Custom includes
#include <memory> // std::auto_ptr
+#include "Utils/SafeBool.hh"
//#include "FileHandle.mpp"
///////////////////////////////hh.p////////////////////////////////////////
/** \brief
*/
class FileHandle
+ : public SafeBool<FileHandle>
{
public:
///////////////////////////////////////////////////////////////////////////
bool eof() const;
bool valid() const;
- operator bool () const;
- bool operator!() const;
+ bool boolean_test() const;
int fd() const;
FileBody::ptr body_;
};
+ int retrieve_filehandle(FileHandle handle);
+
}}
///////////////////////////////hh.e////////////////////////////////////////
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2006
+
+// Definition of inline non-template functions
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+prefix_ satcom::lib::GenericSockAddr::GenericSockAddr()
+{}
+
+prefix_ struct sockaddr * satcom::lib::GenericSockAddr::sockaddr_p()
+{
+ return reinterpret_cast<sockaddr *>(&addr_);
+}
+
+prefix_ struct sockaddr const * satcom::lib::GenericSockAddr::sockaddr_p()
+ const
+{
+ return reinterpret_cast<sockaddr const *>(&addr_);
+}
+
+prefix_ unsigned satcom::lib::GenericSockAddr::sockaddr_len()
+ const
+{
+ return sizeof(addr_);
+}
+
+///////////////////////////////cci.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2006
+
+#ifndef HH_GenericSockAddr_
+#define HH_GenericSockAddr_ 1
+
+// Custom includes
+#include <sys/socket.h>
+
+//#include "GenericSockAddr.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace satcom {
+namespace lib {
+
+ class GenericSockAddr
+ {
+ public:
+ GenericSockAddr();
+
+ struct sockaddr * sockaddr_p();
+ struct sockaddr const * sockaddr_p() const;
+ unsigned sockaddr_len() const;
+
+ private:
+ struct ::sockaddr_storage addr_;
+ };
+
+}}
+
+///////////////////////////////hh.e////////////////////////////////////////
+#include "GenericSockAddr.cci"
+//#include "GenericSockAddr.ct"
+//#include "GenericSockAddr.cti"
+//#include "GenericSockAddr.mpp"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// End:
return false;
if (contains(i2,i2_end,'.'))
// the longer string is a sub-'directory' of the shorter
+ // FIXME: shouldn't this be *i2 == '.' ?
return true;
return *i1 < *i2;
}
else if (i2 == i2_end) { // && i1 != i1_end
if (contains(i1,i1_end,'.'))
// the longer string is a sub-'directory' of the shorter
+ // FIXME: shouldn't this be *i1 == '.' ?
return false;
return *i1 < *i2;
}
#include <boost/mpl/and.hpp>
#include <boost/utility.hpp> // for enable_if
+#include "GenericSockAddr.hh"
+
///////////////////////////////ih.p////////////////////////////////////////
namespace satcom {
{
virtual ~ AddressingPolicyBase() {}
- class Address
- {
- private:
- Address();
- };
+ typedef GenericSockAddr Address;
};
# define SP_DeclareBase(x1,x2,SomePolicy) \