Skip to content

Commit

Permalink
Merge pull request #279 from arogge/dev/arogge/master/internalize-fastlz
Browse files Browse the repository at this point in the history
internalize fastlz
  • Loading branch information
arogge committed Oct 1, 2019
2 parents 561891e + 8af88c1 commit f20ce50
Show file tree
Hide file tree
Showing 31 changed files with 4,676 additions and 122 deletions.
2 changes: 0 additions & 2 deletions core/CMakeLists.txt
Expand Up @@ -505,7 +505,6 @@ set(have_tls "${HAVE_TLS}" )
set(have_crypto "${HAVE_CRYPTO}" )
set(have_openssl "${HAVE_OPENSSL}" )
set(have_zlib "${ZLIB_FOUND}" )
set(have_fastlz "${HAVE_FASTLZLIB_H}" )

set(HAVE_CAPABILITY "${HAVE_CAPABILITY_H}" CACHE BOOL "compile with capability support")
if ("${HAVE_CAPABILITY}")
Expand Down Expand Up @@ -692,7 +691,6 @@ MESSAGE(" OpenSSL support: ${OPENSSL_FOUND} ${OPENSSL_VERSION} ${
MESSAGE(" PAM support: ${PAM_FOUND} ${PAM_LIBRARIES} ${PAM_INCLUDE_DIRS} ")
MESSAGE(" ZLIB support: ${ZLIB_FOUND} ${ZLIB_LIBRARIES} ${ZLIB_INCLUDE_DIRS} ")
MESSAGE(" LZO2 support: ${LZO2_FOUND} ${LZO2_LIBRARIES} ${LZO2_INCLUDE_DIRS} ")
MESSAGE(" FASTLZ support: ${FASTLZ_FOUND} ${FASTLZ_LIBRARIES} ${FASTLZ_INCLUDE_DIRS} ")
MESSAGE(" JANSSON support: ${JANSSON_FOUND} ${JANSSON_LIBRARIES} ${JANSSON_INCLUDE_DIRS} ")
MESSAGE(" LMDB support: ${lmdb} ")
MESSAGE(" NDMP support: ${ndmp} ")
Expand Down
2 changes: 0 additions & 2 deletions core/cmake/BareosCheckIncludes.cmake
Expand Up @@ -93,8 +93,6 @@ CHECK_INCLUDE_FILES(cxxabi.h HAVE_CXXABI_H)
CHECK_INCLUDE_FILES(ucontext.h HAVE_UCONTEXT_H)
CHECK_INCLUDE_FILES(demangle.h HAVE_DEMANGLE_H)

CHECK_INCLUDE_FILES(fastlzlib.h HAVE_FASTLZLIB_H)
CHECK_INCLUDE_FILES(capability.h HAVE_FASTLZLIB_H)
CHECK_INCLUDE_FILES(acl.h HAVE_ACL_H)
CHECK_INCLUDE_FILES(sys/extattr.h HAVE_SYS_EXTATTR_H)
CHECK_INCLUDE_FILES(libutil.h HAVE_LIBUTIL_H)
Expand Down
1 change: 0 additions & 1 deletion core/cmake/BareosFindAllLibraries.cmake
Expand Up @@ -50,7 +50,6 @@ endif()

INCLUDE(BareosFindLibraryAndHeaders)

BareosFindLibraryAndHeaders("fastlz" "fastlzlib.h")
BareosFindLibraryAndHeaders("jansson" "jansson.h")
BareosFindLibraryAndHeaders("rados" "rados/librados.h")
BareosFindLibraryAndHeaders("radosstriper" "radosstriper/libradosstriper.h")
Expand Down
1 change: 1 addition & 0 deletions core/debian/bareos-common.install.in
@@ -1,4 +1,5 @@
@libdir@/libbareos.so*
@libdir@/libbareosfastlz.so*
@libdir@/libbareosfind.so*
@libdir@/libbareoslmdb.so*
@libdir@/libbareosndmp.so*
Expand Down
Expand Up @@ -2,8 +2,8 @@

PORTNAME=bareos.com
#PKGNAMESUFFIX?= .com
DISTVERSIONPREFIX=Release/
DISTVERSION=18.2.4-rc1
DISTVERSIONPREFIX=
DISTVERSION=
PKGCATEGORY=sysutils
CATEGORIES=sysutils

Expand Down

This file was deleted.

Expand Up @@ -44,19 +44,16 @@ POST-DEINSTALL)
bareos.com-director*)
echo "shutting down bareos-dir..."
service bareos-dir status && service bareos-dir stop || echo " already stopped"
#sysrc -x bareosdir_enable
;;

bareos.com-filedaemon*)
echo "shutting down bareos-fd..."
service bareos-fd status && service bareos-fd stop || echo " already stopped"
#sysrc -x bareosfd_enable
;;

bareos.com-storage*)
echo "shutting down bareos-fd..."
service bareos-sd status && service bareos-sd stop || echo " already stopped"
#sysrc -x bareossd_enable
;;
esac
;;
Expand Down
Expand Up @@ -22,6 +22,9 @@
lib/libbareos.so.%%DISTVERSION%%
lib/libbareos.so.%%LIBVERSION%%
lib/libbareos.so
lib/libbareosfastlz.so.%%DISTVERSION%%
lib/libbareosfastlz.so.%%LIBVERSION%%
lib/libbareosfastlz.so
lib/libbareosfind.so.%%DISTVERSION%%
lib/libbareosfind.so.%%LIBVERSION%%
lib/libbareosfind.so
Expand Down
2 changes: 1 addition & 1 deletion core/platforms/packaging/bareos.spec
Expand Up @@ -182,7 +182,6 @@ BuildRequires: openssl-devel
BuildRequires: libacl-devel
BuildRequires: pkgconfig
BuildRequires: lzo-devel
BuildRequires: libfastlz-devel
BuildRequires: logrotate
%if 0%{?build_sqlite3}
%if 0%{?suse_version}
Expand Down Expand Up @@ -1182,6 +1181,7 @@ echo "This is a meta package to install a full bareos system" > %{buildroot}%{_d
%endif
%endif
%dir %{backend_dir}
%{library_dir}/libbareosfastlz.so*
%{library_dir}/libbareos.so*
%{library_dir}/libbareosfind.so*
%{library_dir}/libbareoslmdb.so*
Expand Down
2 changes: 2 additions & 0 deletions core/platforms/win32/winbareos.nsi
Expand Up @@ -576,6 +576,7 @@ SectionIn 1 2 3 4
File "bareos-config-deploy.bat"
File "bareos-fd.exe"
File "libbareos.dll"
File "libbareosfastlz.dll"
File "libbareosfind.dll"
File "libbareoslmdb.dll"
File "libbareossql.dll"
Expand Down Expand Up @@ -2151,6 +2152,7 @@ ConfDeleteSkip:
Delete "$INSTDIR\bareos-config-deploy.bat"

Delete "$INSTDIR\libbareos.dll"
Delete "$INSTDIR\libbareosfastlz.dll"
Delete "$INSTDIR\libbareossd.dll"
Delete "$INSTDIR\libbareosfind.dll"
Delete "$INSTDIR\libbareoslmdb.dll"
Expand Down
1 change: 1 addition & 0 deletions core/src/CMakeLists.txt
Expand Up @@ -38,6 +38,7 @@ add_subdirectory(lib)
add_subdirectory(findlib)
add_subdirectory(filed)
add_subdirectory(plugins)
add_subdirectory(fastlz)

if (${traymonitor})
add_subdirectory(qt-tray-monitor)
Expand Down
31 changes: 31 additions & 0 deletions core/src/fastlz/CMakeLists.txt
@@ -0,0 +1,31 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2019 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation and included
# in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
cmake_minimum_required(VERSION 3.0)
project(bareosfastlz LANGUAGES C)

add_library(bareosfastlz SHARED src/fastlzlib.c src/fastlz.c src/lz4.c src/lz4hc.c)
target_include_directories(bareosfastlz PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE src)
target_compile_definitions(bareosfastlz PRIVATE "-DDLL_EXPORT")
install(TARGETS bareosfastlz DESTINATION ${libdir})
set_target_properties(bareosfastlz PROPERTIES VERSION "${BAREOS_NUMERIC_VERSION}"
SOVERSION "${SOVERSION}"
)
117 changes: 117 additions & 0 deletions core/src/fastlz/include/fastlz/fastlz.h
@@ -0,0 +1,117 @@
/*
FastLZ - lightning-fast lossless compression library
Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
Copyright (C) 2005 Ariya Hidayat (ariya@kde.org)
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.
*/

#ifndef FASTLZ_H
#define FASTLZ_H

#define FASTLZ_VERSION 0x000100

#define FASTLZ_VERSION_MAJOR 0
#define FASTLZ_VERSION_MINOR 0
#define FASTLZ_VERSION_REVISION 0

#define FASTLZ_VERSION_STRING "0.1.0"

#if defined (__cplusplus)
extern "C" {
#endif

/* optional conf.h file if build with -DFASTLZ_INCLUDE_CONF_H */
#ifdef FASTLZ_INCLUDE_CONF_H
#include "conf.h"
#endif
#ifndef ZFASTEXTERN
#ifdef _WIN32
#if defined(FASTLZ_DLL) || defined(DLL_EXPORT)
#define ZFASTEXTERN __declspec(dllexport)
#else
#define ZFASTEXTERN __declspec(dllimport)
#endif
#else
#define ZFASTEXTERN extern
#endif
#define ZFASTINLINE
#endif

/**
Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The
minimum input buffer size is 16.
The output buffer must be at least 5% larger than the input buffer
and can not be smaller than 66 bytes.
If the input is not compressible, the return value might be larger than
length (input buffer size).
The input buffer and the output buffer can not overlap.
*/

ZFASTEXTERN int fastlz_compress(const void* input, int length, void* output);

/**
Decompress a block of compressed data and returns the size of the
decompressed block. If error occurs, e.g. the compressed data is
corrupted or the output buffer is not large enough, then 0 (zero)
will be returned instead.
The input buffer and the output buffer can not overlap.
Decompression is memory safe and guaranteed not to write the output buffer
more than what is specified in maxout.
*/

ZFASTEXTERN int fastlz_decompress(const void* input, int length, void* output, int maxout);

/**
Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The
minimum input buffer size is 16.
The output buffer must be at least 5% larger than the input buffer
and can not be smaller than 66 bytes.
If the input is not compressible, the return value might be larger than
length (input buffer size).
The input buffer and the output buffer can not overlap.
Compression level can be specified in parameter level. At the moment,
only level 1 and level 2 are supported.
Level 1 is the fastest compression and generally useful for short data.
Level 2 is slightly slower but it gives better compression ratio.
Note that the compressed data, regardless of the level, can always be
decompressed using the function fastlz_decompress above.
*/

ZFASTEXTERN int fastlz_compress_level(int level, const void* input, int length, void* output);

#if defined (__cplusplus)
}
#endif

#endif /* FASTLZ_H */

0 comments on commit f20ce50

Please sign in to comment.