From 46ffc90598bf53cbf9adbbd45e0e0e2fede1bfd0 Mon Sep 17 00:00:00 2001
From: "raphael.bach" <raphael.bach@etu.hesge.ch>
Date: Sat, 19 Jan 2019 17:25:00 +0100
Subject: [PATCH] Add file_io.h and file_io.c

---
 include/file_io.h | 39 +++++++++++++++++++++++++++++++++++++++
 makefile          | 10 +++++++++-
 src/file_io.c     | 44 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100644 include/file_io.h
 create mode 100644 src/file_io.c

diff --git a/include/file_io.h b/include/file_io.h
new file mode 100644
index 0000000..8c69488
--- /dev/null
+++ b/include/file_io.h
@@ -0,0 +1,39 @@
+/*!
+    @file
+    @date 18.01.2019
+    @author Raphael Bach
+    @copyright
+
+The MIT License (MIT)
+
+Copyright (c) 2019 Raphael Bach
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    @brief
+    @details
+*/
+/*==============================================================================
+    GUARD
+==============================================================================*/
+#ifndef FILE_IO_H_20190118185317
+#define FILE_IO_H_20190118185317
+/*==============================================================================
+    GUARD
+==============================================================================*/
+#endif // FILE_IO_H_20190118185317
diff --git a/makefile b/makefile
index b26b8b6..0618774 100644
--- a/makefile
+++ b/makefile
@@ -200,11 +200,13 @@ LFLAGS += -o ./$@.out
 SPARSE2IMG_DEP :=                                                              \
     sparse2img.o \
     sparse.o \
+    file_io.o \
     log.o
 
 IMG2SPARSE_DEP :=                                                              \
     img2sparse.o \
     sparse.o \
+    file_io.o \
     log.o
 
 SPARSE2IMG_OBJ_LIST_PATH := $(addprefix $(OBJECT_PATH)/, $(SPARSE2IMG_DEP))
@@ -216,6 +218,10 @@ I2S_DEP :=                                                                     \
     $(SOURCE_FOLDER)/img2sparse.c
 SPARSE_DEP :=                                                                  \
     $(SOURCE_FOLDER)/sparse.c                                                  \
+    $(HEADER_FOLDER)/file_io.h                                                 \
+    $(HEADER_FOLDER)/log.h
+FILE_IO_DEP :=                                                                 \
+    $(SOURCE_FOLDER)/file_io.c                                                 \
     $(HEADER_FOLDER)/log.h
 LOG_DEP :=                                                                     \
     $(SOURCE_FOLDER)/log.c
@@ -234,6 +240,8 @@ img2sparse.o: $(I2S_DEP)
 	$(CFLAGS)
 sparse.o: $(SPARSE_DEP)
 	$(CFLAGS)
+file_io.o: $(FILE_IO_DEP)
+	$(CFLAGS)
 log.o: $(LOG_DEP)
 	$(CFLAGS)
 
@@ -245,7 +253,7 @@ tests:
 	$(SCANBUILD)
 	$(CPPCHECK)
 	$(VALGRIND) ./sparse2img.out x x 2> $(ANALYZE_PATH)/valgrind
-	$(VALGRIND) ./img2sparse.out test.simg x 2>> $(ANALYZE_PATH)/valgrind
+	#$(VALGRIND) ./img2sparse.out test.simg x 2>> $(ANALYZE_PATH)/valgrind
 
 %.info: %.o
 	$(LCOV)
diff --git a/src/file_io.c b/src/file_io.c
new file mode 100644
index 0000000..b8699c9
--- /dev/null
+++ b/src/file_io.c
@@ -0,0 +1,44 @@
+/*!
+    @file
+    @date 18.01.2019
+    @author Raphael Bach
+    @copyright
+
+The MIT License (MIT)
+
+Copyright (c) 2019 Raphael Bach
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    @brief
+    @details
+*/
+/*==============================================================================
+    INCLUDE
+==============================================================================*/
+// Own header
+#include "file_io.h"
+// Internal
+#include "log.h"
+/*==============================================================================
+    STATIC
+==============================================================================*/
+static struct Logger s_logger = {
+    .level_flag = LOG_LEVEL_ALL,
+    .output     = LOG_OUTPUT_STDERR
+};
-- 
GitLab