1 Commits

Author SHA1 Message Date
idk
292767eaa8 work on boost compatibility, does not work yet 2022-06-02 16:20:59 -04:00
3 changed files with 32 additions and 1 deletions

View File

@ -7,9 +7,13 @@ TARGET=libi2psam.a
$(TARGET): $(OBJS)
$(AR) $(ARFLAGS) $(TARGET) $(OBJS)
LOADLIBES=-L./ -li2psam
LOADLIBES=-L./ -li2psam -lboost_system -lboost_thread -lpthread
eepget: eepget.cpp $(TARGET)
export USE_BOOST=1
boost: boost.cpp $(TARGET)
clean:
$(RM) $(TARGET) $(OBJS) eepget

View File

@ -13,6 +13,7 @@
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
#include <boost/asio.hpp>
// Was 65536, seemed unnecessarily large
#define SAM_BUFSIZE 4096
@ -169,6 +170,22 @@ void I2pSocket::write(const std::string& msg)
}
}
std::size_t I2pSocket::write_some(boost::asio::const_buffers_1 buffer, boost::system::error_code ec) {
// get a string from the buffer
std::string str(boost::asio::buffers_begin(buffer), boost::asio::buffers_end(buffer));
// get the buffer size
std::size_t size = boost::asio::buffer_size(buffer);
write(str);
return size;
}
std::size_t I2pSocket::read_some(boost::asio::mutable_buffers_1 buffer, boost::system::error_code ec) {
// get a string from the buffer
//std::string str(boost::asio::buffers_begin(buffer), boost::asio::buffers_end(buffer));
std::string str = read();
return str.size();
}
std::string I2pSocket::read()
{
if (!isOk())

View File

@ -45,12 +45,15 @@
#ifdef __cplusplus // __cplusplus
#include "compat.h"
#include <boost/asio.hpp>
#include <string>
#include <list>
#include <stdint.h>
#include <memory>
#include <utility>
using namespace boost::asio;
namespace SAM
{
@ -213,6 +216,13 @@ public:
void write(const std::string& msg);
std::string read();
// only include these if we're compiling with boost
//#ifdef USE_BOOST
std::size_t write_some(boost::asio::const_buffers_1 buffer, boost::system::error_code error);
std::size_t read_some(boost::asio::mutable_buffers_1 buffer, boost::system::error_code error);
//#endif
SOCKET release();
void close();