Compare commits
No commits in common. "e599dd2f349028a8a7ce724560cd491bb2a83c40" and "30a59c950ee6ca37df9283de778e85d02639930a" have entirely different histories.
e599dd2f34
...
30a59c950e
47 changed files with 67 additions and 155 deletions
3
.github/FUNDING.yml
vendored
3
.github/FUNDING.yml
vendored
|
@ -1,3 +0,0 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
custom: https://www.blockchain.com/btc/payment_request?address=1AFGT5gVj7xhfjgHTuwEoaV56WTCh7Gjf1#BITCOIN_ONLY
|
7
.gitmodules
vendored
7
.gitmodules
vendored
|
@ -1,7 +0,0 @@
|
|||
[submodule "c-libp2p"]
|
||||
path = c-libp2p
|
||||
url = https://github.com/Agorise/c-libp2p.git
|
||||
[submodule "lmdb"]
|
||||
path = lmdb
|
||||
url = https://github.com/jmjatlanta/lmdb.git
|
||||
branch = mdb.master
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 AGORISE, LTD.
|
||||
Copyright (c) 2017 AGORISE, LTD.
|
||||
An International Business Company, Cyprus Reg# ΗΕ375959
|
||||
|
||||
Contains works from BitShares Munich IVS
|
||||
|
|
5
Makefile
5
Makefile
|
@ -3,8 +3,7 @@ DEBUG = true
|
|||
export DEBUG
|
||||
|
||||
all:
|
||||
cd c-libp2p; make all;
|
||||
cd lmdb/libraries/liblmdb; make all;
|
||||
#cd ../c-libp2p; make all;
|
||||
cd blocks; make all;
|
||||
cd cid; make all;
|
||||
cd cmd; make all;
|
||||
|
@ -30,8 +29,6 @@ all:
|
|||
cd test; make all;
|
||||
|
||||
clean:
|
||||
cd c-libp2p; make clean;
|
||||
cd lmdb/libraries/liblmdb; make clean;
|
||||
cd blocks; make clean;
|
||||
cd cid; make clean;
|
||||
cd cmd; make clean;
|
||||
|
|
|
@ -12,7 +12,7 @@ IPFS implementation in C, (not just an API client library).
|
|||
* [getting started](https://github.com/ipfs/community/issues/177)
|
||||
* [libp2p](https://github.com/libp2p/specs)
|
||||
|
||||
## Prerequisites: To compile the C version you will need, all included as submodules:
|
||||
## Prerequisites: To compile the C version you will need:
|
||||
* [lmdb](https://github.com/jmjatlanta/lmdb)
|
||||
* [c-protobuf](https://github.com/Agorise/c-protobuf)
|
||||
* [c-multihash](https://github.com/Agorise/c-multihash)
|
||||
|
@ -21,8 +21,4 @@ IPFS implementation in C, (not just an API client library).
|
|||
|
||||
And of course this project at https://github.com/Agorise/c-ipfs
|
||||
|
||||
## How to compile the C version:
|
||||
```
|
||||
git submodule update --init --recursive
|
||||
make all
|
||||
```
|
||||
The compilation at this point is simple, but not very flexible. Place all of these projects in a directory. Compile all (the order above is recommended) by going into each one and running "make all".
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
1
c-libp2p
1
c-libp2p
|
@ -1 +0,0 @@
|
|||
Subproject commit d0c319a88cd1f2cb3a219420b5a0b930e72562e2
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../../include -I../../c-libp2p/include -I../../c-libp2p/c-multiaddr/include -I../../c-libp2p/c-protobuf -Wall
|
||||
CFLAGS = -O0 -I../../include -I../../../c-libp2p/include -I../../../c-multiaddr/include -I../../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -Wall -std=c99
|
||||
LFLAGS =
|
||||
DEPS = ../include/ipfs/commands/argument.h ../include/ipfs/commands/command_option.h \
|
||||
../include/ipfs/commands/command.h ../include/ipfs/commands/context.h \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../../include -I../../c-libp2p/include -Wall
|
||||
CFLAGS = -O0 -I../../include -I../../../c-libp2p/include -Wall
|
||||
LFLAGS =
|
||||
DEPS = parse.h
|
||||
OBJS = parse.o
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multiaddr/include -I../../c-protobuf -Wall -std=c11
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -750,7 +750,7 @@ int api_start (struct IpfsNode* local_node, int max_conns, int timeout)
|
|||
return 0;
|
||||
}
|
||||
|
||||
libp2p_logger_info("api", "API server listening on %d.\n", port);
|
||||
libp2p_logger_debug("api", "Started API on localhost port %d.\n", port);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,9 +70,8 @@ int ipfs_daemon (int argc, char **argv)
|
|||
{
|
||||
char* repo_path = NULL;
|
||||
|
||||
libp2p_logger_add_class("daemon");
|
||||
if (!ipfs_repo_get_directory(argc, argv, &repo_path)) {
|
||||
libp2p_logger_error("daemon", "Unable to open repo: %s\n", repo_path);
|
||||
fprintf(stderr, "Unable to open repo: %s\n", repo_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ struct Libp2pVector* ipfs_node_online_build_protocol_handlers(struct IpfsNode* n
|
|||
// yamux
|
||||
libp2p_utils_vector_add(retVal, libp2p_yamux_build_protocol_handler());
|
||||
// identify
|
||||
libp2p_utils_vector_add(retVal, libp2p_identify_build_protocol_handler(node->identity->peer->id, node->identity->peer->id_size));
|
||||
libp2p_utils_vector_add(retVal, libp2p_identify_build_protocol_handler(retVal));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ void* ipfs_null_listen (void *ptr)
|
|||
return (void*) 2;
|
||||
}
|
||||
|
||||
libp2p_logger_info("null", "Ipfs listening on %d\n", listen_param->port);
|
||||
libp2p_logger_error("null", "Ipfs listening on %d\n", listen_param->port);
|
||||
|
||||
// when we have nothing to do, check on the connections to see if we're still connected
|
||||
struct Libp2pLinkedList* current_peer_entry = NULL;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../lmdb/libraries/liblmdb -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../lmdb/libraries/liblmdb -I../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../../include -I../../c-libp2p/include -I../../c-libp2p/c-multiaddr/include -I../../c-libp2p/c-multihash/include -I../../c-libp2p/c-protobuf -Wall -std=c99
|
||||
CFLAGS = -O0 -I../../include -I../../../c-libp2p/include -I../../../c-multiaddr/include -I../../../c-multihash/include -I../../../c-protobuf -Wall -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CC = gcc
|
||||
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall -std=c11
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "ipfs/repo/init.h"
|
||||
#include "ipfs/core/ipfs_node.h"
|
||||
#include "libp2p/utils/logger.h"
|
||||
#include "ipfs/namesys/name.h"
|
||||
#include "ipfs/repo/fsrepo/jsmn.h"
|
||||
|
||||
/**
|
||||
* pull objects from ipfs
|
||||
|
@ -288,23 +286,8 @@ int ipfs_exporter_object_cat(struct CliArguments* args, FILE* output_file) {
|
|||
}
|
||||
|
||||
if (local_node->mode == MODE_API_AVAILABLE) {
|
||||
const char ipns_prefix[] = "/ipns/";
|
||||
const char ipfs_prefix[] = "/ipfs/";
|
||||
char* hash = args->argv[args->verb_index + 1];
|
||||
libp2p_logger_debug("exporter", "We're attempting to use the API for this object get of %s.\n", hash);
|
||||
if (memcmp(hash, ipfs_prefix, sizeof(ipfs_prefix)-1) == 0) {
|
||||
// skip ipfs_prefix;
|
||||
hash += sizeof(ipfs_prefix)-1;
|
||||
} else if (memcmp(hash, ipns_prefix, sizeof(ipns_prefix)-1) == 0) {
|
||||
char *response = NULL;
|
||||
size_t response_size;
|
||||
if (ipfs_name_resolve(local_node, hash, &response, &response_size) && response && response_size > 0) {
|
||||
hash = jsmn_simple_parser(response, response_size, "Path");
|
||||
if (!hash) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
struct HttpRequest* request = ipfs_core_http_request_new();
|
||||
char* response = NULL;
|
||||
request->command = "object";
|
||||
|
|
|
@ -2,16 +2,6 @@
|
|||
|
||||
#include "ipfs/cmd/cli.h"
|
||||
|
||||
/***
|
||||
* Publish IPNS name
|
||||
*/
|
||||
int ipfs_name_publish(struct IpfsNode* local_node, char* name, char **response, size_t *response_size);
|
||||
|
||||
/***
|
||||
* Resolve IPNS name
|
||||
*/
|
||||
int ipfs_name_resolve(struct IpfsNode* local_node, char* name, char **response, size_t *response_size);
|
||||
|
||||
/**
|
||||
* We received a cli command "ipfs name". Do the right thing.
|
||||
* @param argc number of arguments on the command line
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-protobuf -I../lmdb/libraries/liblmdb -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multiaddr/include -I../../c-multihash/include -I../../c-protobuf -I../../lmdb/libraries/liblmdb -Wall -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
1
lmdb
1
lmdb
|
@ -1 +0,0 @@
|
|||
Subproject commit 6b62ada62a10b3185b2dcd51e512dea27e5e3c8e
|
|
@ -1,6 +1,6 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -g3 -Wall -std=gnu99
|
||||
LFLAGS = -L../c-libp2p -L../c-libp2p/c-multihash -L../c-libp2p/c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread -lresolv -lcurl
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -g3 -Wall -std=c99
|
||||
LFLAGS = -L../../c-libp2p -L../../c-multihash -L../../c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread -lresolv -lcurl
|
||||
DEPS = cmd/ipfs/test_init.h repo/test_repo_bootstrap_peers.h repo/test_repo_config.h repo/test_repo_identity.h cid/test_cid.h
|
||||
OBJS = main.o \
|
||||
../blocks/block.o ../blocks/blockstore.o \
|
||||
|
@ -27,7 +27,7 @@ OBJS = main.o \
|
|||
../routing/*.o \
|
||||
../thirdparty/ipfsaddr/ipfs_addr.o \
|
||||
../unixfs/unixfs.o \
|
||||
../c-libp2p/c-protobuf/protobuf.o ../c-libp2p/c-protobuf/varint.o \
|
||||
../../c-protobuf/protobuf.o ../../c-protobuf/varint.o \
|
||||
../util/errs.o \
|
||||
../util/time.o \
|
||||
../util/thread_pool.o
|
||||
|
@ -36,7 +36,7 @@ OBJS = main.o \
|
|||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
ipfs: $(OBJS)
|
||||
$(CC) -o $@ $^ $(LFLAGS) ../lmdb/libraries/liblmdb/liblmdb.a
|
||||
$(CC) -o $@ $^ $(LFLAGS) ../../lmdb/libraries/liblmdb/liblmdb.a
|
||||
|
||||
all: ipfs
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -11,43 +11,39 @@
|
|||
/***
|
||||
* Publish IPNS name
|
||||
*/
|
||||
int ipfs_name_publish(struct IpfsNode* local_node, char* name, char **response, size_t *response_size) {
|
||||
int ipfs_name_publish(struct IpfsNode* local_node, char* name) {
|
||||
// call api.
|
||||
char* response = NULL;
|
||||
struct HttpRequest* request = ipfs_core_http_request_new();
|
||||
if (request == NULL)
|
||||
return 0;
|
||||
request->command = "name";
|
||||
request->sub_command = "publish";
|
||||
libp2p_utils_vector_add(request->arguments, name);
|
||||
int retVal = ipfs_core_http_request_post(local_node, request, response, response_size, "", 0);
|
||||
size_t response_size = 0;
|
||||
int retVal = ipfs_core_http_request_post(local_node, request, &response, &response_size, "", 0);
|
||||
if (response != NULL && response_size > 0) {
|
||||
fwrite(response, 1, response_size, stdout);
|
||||
free(response);
|
||||
}
|
||||
ipfs_core_http_request_free(request);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/***
|
||||
* Resolve IPNS name
|
||||
*/
|
||||
int ipfs_name_resolve(struct IpfsNode* local_node, char* name, char **response, size_t *response_size) {
|
||||
int ipfs_name_resolve(struct IpfsNode* local_node, char* name) {
|
||||
// ask api
|
||||
const char prefix[] = "/ipns/";
|
||||
char *ipns = NULL;
|
||||
char* response = NULL;
|
||||
struct HttpRequest* request = ipfs_core_http_request_new();
|
||||
if (request == NULL)
|
||||
return 0;
|
||||
request->command = "name";
|
||||
request->sub_command = "resolve";
|
||||
if (memcmp(name, prefix, sizeof(prefix)-1)!=0) {
|
||||
ipns = malloc(sizeof(prefix) + strlen(name));
|
||||
if (ipns) {
|
||||
strcpy(ipns, prefix);
|
||||
strcat(ipns, name);
|
||||
name = ipns;
|
||||
}
|
||||
}
|
||||
libp2p_utils_vector_add(request->arguments, name);
|
||||
int retVal = ipfs_core_http_request_post(local_node, request, response, response_size, "", 0);
|
||||
if (ipns) {
|
||||
free(ipns);
|
||||
size_t response_size = 0;
|
||||
int retVal = ipfs_core_http_request_post(local_node, request, &response, &response_size, "", 0);
|
||||
if (response != NULL && response_size > 0) {
|
||||
fwrite(response, 1, response_size, stdout);
|
||||
free(response);
|
||||
}
|
||||
ipfs_core_http_request_free(request);
|
||||
return retVal;
|
||||
|
@ -81,21 +77,15 @@ int ipfs_name(struct CliArguments* args) {
|
|||
goto exit;
|
||||
}
|
||||
|
||||
char *response = NULL;
|
||||
size_t response_size;
|
||||
// determine what we're doing
|
||||
if (strcmp(which, "publish") == 0) {
|
||||
retVal = ipfs_name_publish(client_node, path, &response, &response_size);
|
||||
retVal = ipfs_name_publish(client_node, path);
|
||||
} else if (strcmp(which, "resolve") == 0) {
|
||||
retVal = ipfs_name_resolve(client_node, path, &response, &response_size);
|
||||
retVal = ipfs_name_resolve(client_node, path);
|
||||
} else {
|
||||
libp2p_logger_error("name", "Nothing found on command line. Should be \"name resolve\" or \"name publish\".\n");
|
||||
goto exit;
|
||||
}
|
||||
if (response != NULL && response_size > 0) {
|
||||
fwrite(response, 1, response_size, stdout);
|
||||
free(response);
|
||||
}
|
||||
|
||||
exit:
|
||||
// shut everything down
|
||||
|
|
|
@ -35,6 +35,8 @@ func NewNameSystem(r routing.ValueStore, ds ds.Datastore, cachesize int) NameSys
|
|||
}
|
||||
}*/
|
||||
|
||||
const int DefaultResolverCacheTTL = 60;
|
||||
|
||||
// ipfs_namesys_resolve implements Resolver.
|
||||
int ipfs_namesys_resolve(char **path, char *name)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../../include -I../../c-libp2p/include -I../../c-libp2p/c-multiaddr/include -I../../c-libp2p/c-multihash/include -I../../c-libp2p/c-protobuf -Wall -std=c99
|
||||
CFLAGS = -O0 -I../../include -I../../../c-libp2p/include -I../../../c-multiaddr/include -I../../../c-multihash/include -I../../../c-protobuf -Wall -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../../include -I../../c-libp2p/include -I../../lmdb/libraries/liblmdb -I../../c-libp2p/c-protobuf -I../../c-libp2p/c-multiaddr/include -Wall -std=c99
|
||||
CFLAGS = -O0 -I../../include -I../../../c-libp2p/include -I../../../lmdb/libraries/liblmdb -I../../../c-protobuf -I../../../c-multiaddr/include -Wall -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "ipfs/repo/fsrepo/fs_repo.h"
|
||||
#include "libp2p/os/utils.h"
|
||||
#include "ipfs/repo/fsrepo/lmdb_datastore.h"
|
||||
#include "ipfs/repo/fsrepo/jsmn.h"
|
||||
#include "jsmn.h"
|
||||
#include "multiaddr/multiaddr.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#include "ipfs/repo/fsrepo/jsmn.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "jsmn.h"
|
||||
|
||||
/**
|
||||
* Allocates a fresh unused token from the token pull.
|
||||
|
@ -313,32 +311,3 @@ void jsmn_init(jsmn_parser *parser) {
|
|||
parser->toknext = 0;
|
||||
parser->toksuper = -1;
|
||||
}
|
||||
|
||||
char *jsmn_simple_parser(char *full_json, int json_len, char *key) {
|
||||
int num_tokens = 256, len, i;
|
||||
if (!full_json || !key) {
|
||||
return NULL;
|
||||
}
|
||||
jsmn_parser parser;
|
||||
jsmn_init(&parser);
|
||||
jsmntok_t tokens[num_tokens];
|
||||
num_tokens = jsmn_parse(&parser, full_json, json_len, tokens, 256);
|
||||
if (num_tokens <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
len = strlen(key);
|
||||
for (i = 0; i < num_tokens; i++) {
|
||||
jsmntok_t curr_token = tokens[i];
|
||||
if (len == (curr_token.end - curr_token.start) && memcmp(full_json + curr_token.start, key, len) == 0) {
|
||||
curr_token = tokens[i+1];
|
||||
len = curr_token.end - curr_token.start;
|
||||
char *ret = malloc(len + 1);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
strncpy(ret, full_json + curr_token.start, len);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,6 @@ void jsmn_init(jsmn_parser *parser);
|
|||
int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
|
||||
jsmntok_t *tokens, unsigned int num_tokens);
|
||||
|
||||
char *jsmn_simple_parser(char *full_json, int json_len, char *key);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multiaddr/include -I../../c-protobuf -Wall -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -I../lmdb/libraries/liblmdb -g3 -Wall -std=gnu99
|
||||
LFLAGS = -L../c-libp2p -L../c-libp2p/c-multihash -L../c-libp2p/c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread -lcurl
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -I../../lmdb/libraries/liblmdb -g3 -Wall -std=c99
|
||||
LFLAGS = -L../../c-libp2p -L../../c-multihash -L../../c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread -lcurl
|
||||
DEPS = cmd/ipfs/test_init.h repo/test_repo_bootstrap_peers.h repo/test_repo_config.h repo/test_repo_identity.h cid/test_cid.h
|
||||
OBJS = testit.o test_helper.o \
|
||||
../blocks/block.o ../blocks/blockstore.o \
|
||||
|
@ -30,13 +30,13 @@ OBJS = testit.o test_helper.o \
|
|||
../thirdparty/ipfsaddr/ipfs_addr.o \
|
||||
../unixfs/unixfs.o \
|
||||
../util/thread_pool.o \
|
||||
../c-libp2p/c-protobuf/protobuf.o ../c-libp2p/c-protobuf/varint.o
|
||||
../../c-protobuf/protobuf.o ../../c-protobuf/varint.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
test_ipfs: $(OBJS)
|
||||
$(CC) -o $@ $^ $(LFLAGS) ../lmdb/libraries/liblmdb/liblmdb.a
|
||||
$(CC) -o $@ $^ $(LFLAGS) ../../lmdb/libraries/liblmdb/liblmdb.a
|
||||
|
||||
all: test_ipfs
|
||||
|
||||
|
|
|
@ -19,13 +19,12 @@ int test_compat_go_join_swarm() {
|
|||
libp2p_logger_add_class("test_api");
|
||||
libp2p_logger_add_class("identify");
|
||||
libp2p_logger_add_class("null");
|
||||
libp2p_logger_add_class("multistream");
|
||||
libp2p_logger_add_class("swarm");
|
||||
libp2p_logger_add_class("secio");
|
||||
*/
|
||||
libp2p_logger_add_class("dialer");
|
||||
libp2p_logger_add_class("yamux");
|
||||
libp2p_logger_add_class("multistream");
|
||||
libp2p_logger_add_class("threadsafe_buffer");
|
||||
|
||||
// Here is the connection information for the GO version:
|
||||
char* remote_string = "/ip4/10.211.55.2/tcp/4001/ipfs/QmacSE6bCZiAu7nrYkhPATaSoL2q9BszkKzbX6fCiXuBGA";
|
||||
|
|
2
thirdparty/ipfsaddr/Makefile
vendored
2
thirdparty/ipfsaddr/Makefile
vendored
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../../include -I../../c-libp2p/include
|
||||
CFLAGS = -O0 -I../../include -I../../../c-libp2p/include
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = ipfs_addr.o
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=gnu99
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
|
Loading…
Reference in a new issue