From 8a3bb35b1ca7c667cd4bff4d70ca8bcd26656593 Mon Sep 17 00:00:00 2001 From: Abraham Hernandez Date: Fri, 9 Nov 2018 15:09:58 -0500 Subject: [PATCH] init --- .editorconfig | 8 ++++ .gitignore | 10 +++++ .travis.yml | 9 +++++ Makefile | 33 ++++++++++++++++ cli.c | 81 ++++++++++++++++++++++++++++++++++++++ deps/binary.c/binary.c | 61 ++++++++++++++++++++++++++++ deps/binary.c/binary.h | 29 ++++++++++++++ deps/binary.c/package.json | 14 +++++++ license | 21 ++++++++++ package.json | 17 ++++++++ readme.md | 80 +++++++++++++++++++++++++++++++++++++ test.sh | 58 +++++++++++++++++++++++++++ 12 files changed, 421 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 Makefile create mode 100644 cli.c create mode 100644 deps/binary.c/binary.c create mode 100644 deps/binary.c/binary.h create mode 100644 deps/binary.c/package.json create mode 100644 license create mode 100644 package.json create mode 100644 readme.md create mode 100644 test.sh 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