cryptutils

Cryptographic Software Utilities
git clone http://git.omkov.net/cryptutils
Log | Tree | Refs | README | LICENCE | Download

AuthorJamozed <[email protected]>
Date2020-07-26 11:09:46
Commit30b524183d5166708cc86c1083110798123f923e
Parent16c2724bb7444ba8d8d27dc1fed923ef2cf05d2a

meta: Replace libokv with local library

Diffstat

D .gitmodules | 3 ---
M CMakeLists.txt | 11 ++++++-----
A src/lib/error.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A src/lib/error.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++

4 files changed, 110 insertions, 8 deletions

diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index dc1733b..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "ext/libokv"]
-	path = ext/libokv
-	url = https://git.omkov.net/Jamozed/libokv
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 41c6ce4..3f4ab93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,14 +5,15 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
 PROJECT(cryptutils C)
 
 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
-SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
-
-ADD_SUBDIRECTORY(ext/libokv)
+SET(CMAKE_STATIC_LIBRARY_PREFIX "")
 
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/ext)
-INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/ext/libokv/include)
 
-LINK_LIBRARIES(libokv.a)
+FILE(GLOB LIBSRC ${PROJECT_SOURCE_DIR}/src/lib/*)
+
+ADD_LIBRARY(lib STATIC ${LIBSRC})
+
+LINK_LIBRARIES(lib)
 
 ADD_EXECUTABLE(crc32 ${PROJECT_SOURCE_DIR}/src/crc32.c)
diff --git a/ext/libokv b/ext/libokv
deleted file mode 160000
index 3fece55..0000000
--- a/ext/libokv
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 3fece553c7da25130cf628bfacff1308d18adcc9
diff --git a/src/lib/error.c b/src/lib/error.c
new file mode 100644
index 0000000..4576890
--- /dev/null
+++ b/src/lib/error.c
@@ -0,0 +1,58 @@
+// error.c
+// Error source file for OMKOV cryptutils lib
+// Copyright (C) 2020, Jakob Wakeling
+// All rights reserved.
+
+/*
+OMKOV Permissive Licence, version 1.0
+
+Copyright (C) 2020, Jakob Wakeling
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+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:
+
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimers.
+* Redistributions in binary form must reproduce the above copyright notice, this
+  list of conditions and the following disclaimers in the documentation and/or
+  other materials provided with the distribution.
+* Neither the names of the copyright holders, nor the names of its contributors
+  may be used to endorse or promote products derived from this Software without
+  specific prior written permission.
+
+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 COPYRIGHT
+HOLDERS OR CONTRIBUTORS 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 WITH THE SOFTWARE.
+*/
+
+#include "error.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+char *A0 = NULL;
+
+void error(int status, const char *format, ...) {
+	fflush(stdout); if (A0) { fputs(A0, stderr); fputs(": ", stderr); }
+	va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);
+	fputc('\n', stderr); exit(status);
+}
+
+void warn(const char *format, ...) {
+	fflush(stdout); if (A0) { fputs(A0, stderr); fputs(": ", stderr); }
+	va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);
+	fputc('\n', stderr); return;
+}
+
+char *serr(void) { return strerror(errno); }
diff --git a/src/lib/error.h b/src/lib/error.h
new file mode 100644
index 0000000..a2214d7
--- /dev/null
+++ b/src/lib/error.h
@@ -0,0 +1,46 @@
+// error.h
+// Error header file for OMKOV cryptutils lib
+// Copyright (C) 2020, Jakob Wakeling
+// All rights reserved.
+
+/*
+OMKOV Permissive Licence, version 1.0
+
+Copyright (C) 2020, Jakob Wakeling
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+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:
+
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimers.
+* Redistributions in binary form must reproduce the above copyright notice, this
+  list of conditions and the following disclaimers in the documentation and/or
+  other materials provided with the distribution.
+* Neither the names of the copyright holders, nor the names of its contributors
+  may be used to endorse or promote products derived from this Software without
+  specific prior written permission.
+
+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 COPYRIGHT
+HOLDERS OR CONTRIBUTORS 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 WITH THE SOFTWARE.
+*/
+
+#ifndef OMKOV_CRYPTUTILS_ERROR_H_38W06M3W
+#define OMKOV_CRYPTUTILS_ERROR_H_38W06M3W
+
+extern char *A0;
+
+extern void error(int status, const char *format, ...);
+extern void warn(const char *format, ...);
+
+extern char *serr(void);
+
+#endif // OMKOV_LIBOKV_ERROR_H_38W06M3W