diff --git a/.gitignore b/.gitignore index e0292b1..4d3cce1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o *.a +eepget diff --git a/Makefile b/Makefile index 96382cd..be6b7bc 100644 --- a/Makefile +++ b/Makefile @@ -7,5 +7,9 @@ TARGET=libi2psam.a $(TARGET): $(OBJS) $(AR) $(ARFLAGS) $(TARGET) $(OBJS) +LOADLIBES=-L./ -li2psam + +eepget: eepget.cpp $(TARGET) + clean: - $(RM) $(TARGET) $(OBJS) + $(RM) $(TARGET) $(OBJS) eepget diff --git a/README.md b/README.md index 92f0397..7d7c7c4 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,5 @@ Pre-release (ongoing refactoring work and migration to C++11) ## Usage Copy the files into your codebase, or build and link to the library. + +See `eepget.cpp` for example client usage (build with `make eepget`). diff --git a/eepget.cpp b/eepget.cpp new file mode 100644 index 0000000..ba670a3 --- /dev/null +++ b/eepget.cpp @@ -0,0 +1,28 @@ +// Copyright (c) 2017 The I2P Project +// Distributed under the MIT software license, see the accompanying +// file LICENSE or http://www.opensource.org/licenses/mit-license.php. +//-------------------------------------------------------------------------------------------------- + +#include "i2psam.h" + +#include + +int main(int argc, char **argv) +{ + if (argc < 2) { + std::cerr << "Usage: eepget " << std::endl; + return 1; + } + std::string target(argv[1]); + SAM::StreamSession s("eepget"); + auto lookupResult = s.namingLookup(target); + auto connResult = s.connect(lookupResult.value, false); + auto conn = connResult.value.get(); + conn->write("GET / HTTP/1.1\r\n\r\n"); + auto reply = conn->read(); + while (!reply.empty()) { + std::cout << reply << std::flush; + reply = conn->read(); + } + conn->close(); +}