Browse Source

meta: Replace libokv with local library

master
Jake Wakeling 2 months ago
parent
commit
30b524183d
5 changed files with 110 additions and 9 deletions
  1. +0
    -3
      .gitmodules
  2. +6
    -5
      CMakeLists.txt
  3. +0
    -1
      ext/libokv
  4. +58
    -0
      src/lib/error.c
  5. +46
    -0
      src/lib/error.h

+ 0
- 3
.gitmodules View File

@@ -1,3 +0,0 @@
[submodule "ext/libokv"]
path = ext/libokv
url = https://git.omkov.net/Jamozed/libokv

+ 6
- 5
CMakeLists.txt View File

@@ -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)

+ 0
- 1
ext/libokv

@@ -1 +0,0 @@
Subproject commit 3fece553c7da25130cf628bfacff1308d18adcc9

+ 58
- 0
src/lib/error.c View File

@@ -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); }

+ 46
- 0
src/lib/error.h View File

@@ -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

Loading…
Cancel
Save