mirror of
https://github.com/novatiq/packages.git
synced 2026-07-29 23:03:06 +01:00
ipfs-http-client: initial commit
IPFS C++ HTTP API client library allows C++ applications to communicate with an IPFS node. It implements IPFS API bindings for C++. Not all methods are implemented. https://github.com/vasild/cpp-ipfs-http-client Signed-off-by: Leonid Esman <leonid.esman@gmail.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# IPFS C++ HTTP API client library
|
||||
#
|
||||
VER_MAJOR:=0
|
||||
VER_MINOR:=4
|
||||
VER_PATCH:=0
|
||||
VERSION:=$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
|
||||
|
||||
HEADERS := include/ipfs/client.h include/ipfs/http/transport-curl.h include/ipfs/http/transport.h
|
||||
TESTPROGS := ipfs-block ipfs-dht ipfs-files ipfs-key ipfs-object ipfs-swarm ipfs-config ipfs-generic ipfs-name ipfs-pin
|
||||
CXXFLAGS := -Wall -Wpedantic -Wextra -Werror -Os -std=gnu++11 -I./include
|
||||
|
||||
.PHONY: testprogs lib all clean
|
||||
|
||||
all: lib testprogs test/ipfs-demo
|
||||
|
||||
lib: libipfs-http-client.a libipfs-http-client.so.$(VERSION)
|
||||
|
||||
libipfs-http-client.a: src/client.o src/http/transport-curl.o
|
||||
$(AR) rc libipfs-http-client.a src/client.o src/http/transport-curl.o
|
||||
|
||||
libipfs-http-client.so.$(VERSION): src/client.o src/http/transport-curl.o
|
||||
$(CXX) $(CXXFLAGS) -shared -Wl,-soname,libipfs-http-client.so.$(VER_MAJOR) -o libipfs-http-client.so.$(VERSION) src/client.o src/http/transport-curl.o
|
||||
ln -sf libipfs-http-client.so.$(VERSION) libipfs-http-client.so.$(VER_MAJOR)
|
||||
ln -sf libipfs-http-client.so.$(VER_MAJOR) libipfs-http-client.so
|
||||
|
||||
testprogs: $(addprefix test/,$(TESTPROGS))
|
||||
|
||||
$(addprefix test/,$(TESTPROGS)):test/ipfs-%:test/%.cc include/ipfs/client.h include/ipfs/test/utils.h libipfs-http-client.a
|
||||
$(CXX) $(CXXFLAGS) $< -L. -lipfs-http-client -lcurl -o $@
|
||||
|
||||
src/client.o: src/client.cc $(HEADERS)
|
||||
$(CXX) $(CXXFLAGS) -fPIC -o src/client.o -c src/client.cc
|
||||
|
||||
src/http/transport-curl.o: src/http/transport-curl.cc $(HEADERS) include/ipfs/test/utils.h
|
||||
$(CXX) $(CXXFLAGS) -fPIC -o src/http/transport-curl.o -c src/http/transport-curl.cc
|
||||
|
||||
test/ipfs-demo: test/demo.cpp
|
||||
$(CXX) -std=c++11 -I./include -L. test/demo.cpp -lipfs-http-client -lcurl -o test/ipfs-demo
|
||||
# $(CXX) -std=c++11 -I./include -L. -Wl,-rpath,. test/demo.cpp -lipfs-http-client -lcurl -o test/ipfs-demo
|
||||
# $(CXX) -std=c++11 -I./include test/demo.cpp ./libipfs-http-client.a -lcurl -o test/ipfs-demo
|
||||
|
||||
clean:
|
||||
$(RM) src/client.o src/http/transport-curl.o libipfs-http-client.a libipfs-http-client.so* $(addprefix test/,$(TESTPROGS)) test/ipfs-demo
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// g++ -std=c++11 -I./include test1.cpp libipfs-http-client.a -lcurl -o ipfs-test
|
||||
// g++ -std=c++11 -I./include test1.cpp -lipfs-http-client -lcurl -o ipfs-test
|
||||
// g++ -std=c++11 -I./include -L. -Wl,-rpath,. test1.cpp -lipfs-http-client -lcurl -o ipfs-test
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <ipfs/client.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::stringstream contents;
|
||||
char addr127001[]="127.0.0.1";
|
||||
char *addr;
|
||||
if (argc<2)
|
||||
addr=addr127001;
|
||||
else
|
||||
addr=argv[1];
|
||||
ipfs::Client client(addr, 5001);
|
||||
client.FilesGet("/ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme", &contents);
|
||||
std::cout << contents.str() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user