diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ff33cbf --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*.c] +indent_style = tab +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b4b23c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.DS_STORE +*.o +*.log +*.gcov +*.gcda +*.gcno +binary +test +example +coverage diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..3216cf8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: c +compiler: +# - clang +- gcc +script: make run-test +after_script: sudo pip install cpp-coveralls && make run-coverage && coveralls --exclude test.c + +notifications: + email: false diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b6f24b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +PREFIX ?= /usr/local + +SRC = cli.c deps/binary.c/binary.c + +OBJ_SRC = $(SRC:.c=.o) + +CFLAGS = -D_GNU_SOURCE -std=c99 -I deps/binary.c/ + +LFLAGS = -Wall -Wno-format-y2k -W -Wstrict-prototypes \ + -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \ + -Wshadow -Wcast-align -Wbad-function-cast -Wchar-subscripts -Winline \ + -Wnested-externs -Wredundant-decls + +binary: $(OBJ_SRC) + $(CC) $(OBJ_SRC) -o $@ + +.SUFFIXES: .c .o +.c.o: + $(CC) $< $(CFLAGS) $(LFLAGS) -c -o $@ + +install: binary + cp -f binary $(PREFIX)/bin/binary + +uninstall: + rm -f $(PREFIX)/bin/binary + +run-test: binary + bash ./test.sh + +clean: + rm -f binary *.o deps/**/*.o *.gc{ov,da,no} + +.PHONY: clean run-test install uninstall diff --git a/cli.c b/cli.c new file mode 100644 index 0000000..2b03415 --- /dev/null +++ b/cli.c @@ -0,0 +1,81 @@ +// +// See for more details: +// https://github.com/abranhe/binary.c +// +// cli.c +// +// MIT licensed. +// Copyright (c) Abraham Hernandez +// + +#include +#include +#include +#include "binary.h" + +const char +*show_help() { + return "\n\ + An small library to work with binary numbers\n\n\ + Usage:\n\n\ + $ binary