Added a simplistic command line.
From the command line, you can init the repository or add a file. Directories coming soon...
This commit is contained in:
parent
f8cdaf0a97
commit
7fa0fc6a7b
11 changed files with 246 additions and 35 deletions
37
main/Makefile
Normal file
37
main/Makefile
Normal file
|
@ -0,0 +1,37 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/ -I../../c-protobuf -g3 -Wall
|
||||
LFLAGS = -L../../c-libp2p -L../../c-multihash -L../../c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread
|
||||
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 \
|
||||
../cid/cid.o \
|
||||
../cmd/ipfs/init.o \
|
||||
../commands/argument.o ../commands/command_option.o ../commands/command.o ../commands/cli/parse.o \
|
||||
../core/builder.o \
|
||||
../datastore/ds_helper.o \
|
||||
../flatfs/flatfs.o \
|
||||
../importer/importer.o \
|
||||
../importer/exporter.o \
|
||||
../merkledag/merkledag.o ../merkledag/node.o \
|
||||
../multibase/multibase.o \
|
||||
../os/utils.o \
|
||||
../repo/init.o \
|
||||
../repo/fsrepo/fs_repo.o ../repo/fsrepo/jsmn.o ../repo/fsrepo/lmdb_datastore.o \
|
||||
../repo/config/config.o ../repo/config/identity.o \
|
||||
../repo/config/bootstrap_peers.o ../repo/config/datastore.o ../repo/config/gateway.o \
|
||||
../repo/config/addresses.o ../repo/config/swarm.o ../repo/config/peer.o \
|
||||
../thirdparty/ipfsaddr/ipfs_addr.o \
|
||||
../unixfs/unixfs.o \
|
||||
../../c-protobuf/protobuf.o ../../c-protobuf/varint.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
ipfs: $(OBJS)
|
||||
$(CC) -o $@ $^ $(LFLAGS) ../../lmdb/libraries/liblmdb/liblmdb.a
|
||||
|
||||
all: ipfs
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f ipfs
|
BIN
main/ipfs
Executable file
BIN
main/ipfs
Executable file
Binary file not shown.
57
main/main.c
Normal file
57
main/main.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ipfs/repo/init.h"
|
||||
#include "ipfs/importer/importer.h"
|
||||
|
||||
void stripit(int argc, char** argv) {
|
||||
char tmp[strlen(argv[argc])];
|
||||
strcpy(tmp, &argv[argc][1]);
|
||||
tmp[strlen(tmp)-1] = 0;
|
||||
strcpy(argv[argc], tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
void strip_quotes(int argc, char** argv) {
|
||||
for(int i = 0; i < argc; i++) {
|
||||
if (argv[i][0] == '\'' && argv[i][strlen(argv[i])-1] == '\'') {
|
||||
stripit(i, argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define INIT 1
|
||||
#define ADD 2
|
||||
|
||||
/***
|
||||
* Basic parsing of command line arguments to figure out where the user wants to go
|
||||
*/
|
||||
int parse_arguments(int argc, char** argv) {
|
||||
if (argc == 1) {
|
||||
printf("No parameters passed.\n");
|
||||
return 0;
|
||||
}
|
||||
if (strcmp("init", argv[1]) == 0) {
|
||||
return INIT;
|
||||
}
|
||||
if (strcmp("add", argv[1]) == 0) {
|
||||
return ADD;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/***
|
||||
* The beginning
|
||||
*/
|
||||
int main(int argc, char** argv) {
|
||||
strip_quotes(argc, argv);
|
||||
int retVal = parse_arguments(argc, argv);
|
||||
switch (retVal) {
|
||||
case (INIT):
|
||||
return ipfs_repo_init(argc, argv);
|
||||
break;
|
||||
case (ADD):
|
||||
ipfs_import(argc, argv);
|
||||
break;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue