pax_global_header 0000666 0000000 0000000 00000000064 14071536445 0014523 g ustar 00root root 0000000 0000000 52 comment=7525f6f31f36a17893c69b51bf8c1a1a2613e9c4
centreon-clib-21.04.2/ 0000775 0000000 0000000 00000000000 14071536445 0014415 5 ustar 00root root 0000000 0000000 centreon-clib-21.04.2/.clang-format 0000664 0000000 0000000 00000000212 14071536445 0016763 0 ustar 00root root 0000000 0000000 # Defines the Chromium style for automatic reformatting.
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Chromium
centreon-clib-21.04.2/.gitignore 0000664 0000000 0000000 00000000051 14071536445 0016401 0 ustar 00root root 0000000 0000000 build/*
inc/com/centreon/clib/version.hh
centreon-clib-21.04.2/CHANGELOG.md 0000664 0000000 0000000 00000000622 14071536445 0016226 0 ustar 00root root 0000000 0000000 # Changelog
## 21.04.2
*Libraries loading*
Libraries are loaded lazily now. This allows not to check all link issues during
the load.
## 21.04.1
*Compilation in C++14 with conan-center*
bintray has stopped. We had to switch to the conan-center. And then our conan
dependencies had to upgrade and then we had to switch to C++14. So here is the
corresponding compilation.
## 21.04.0
New release.
centreon-clib-21.04.2/CMakeLists.txt 0000664 0000000 0000000 00000020413 14071536445 0017155 0 ustar 00root root 0000000 0000000 ##
## Copyright 2011-2014,2018-2019 Centreon
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## For more information : contact@centreon.com
##
# Global options.
cmake_minimum_required(VERSION 2.8)
project("Centreon Clib" C CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions("-D_GLIBCXX_USE_CXX11_ABI=1")
# Set directories.
set(INCLUDE_DIR "${PROJECT_SOURCE_DIR}/inc")
set(INC_DIR "${INCLUDE_DIR}/com/centreon")
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(SCRIPT_DIR "${PROJECT_SOURCE_DIR}/script")
# Version.
set(CLIB_MAJOR 21)
set(CLIB_MINOR 04)
set(CLIB_PATCH 2)
set(CLIB_VERSION "${CLIB_MAJOR}.${CLIB_MINOR}.${CLIB_PATCH}")
# Include module to check existing libraries.
include(CheckLibraryExists)
# Include module CTest if necessary.
if (WITH_TESTING)
include(CTest)
endif ()
# Code coverage on unit tests
option(WITH_COVERAGE "Add code coverage on unit tests." OFF)
if (WITH_TESTING AND WITH_COVERAGE)
set(CMAKE_BUILD_TYPE "Debug")
include(cmake/CodeCoverage.cmake)
APPEND_COVERAGE_COMPILER_FLAGS()
endif ()
set(CMAKE_THREAD_PREFER_PTHREAD)
include(FindThreads)
if (NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "Could not find pthreads library.")
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" AND CMAKE_COMPILER_IS_GNUCXX)
set(LIB_THREAD "-pthread -lpthread")
else ()
set(LIB_THREAD "${CMAKE_THREAD_LIBS_INIT}")
endif ()
# Find real time library.
if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD"
OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(LIB_RT "")
else ()
set(LIB_RT "rt")
endif ()
check_library_exists(
"${LIB_RT}"
"clock_gettime"
"${CMAKE_LIBRARY_PATH}"
FIND_LIB_RT
)
if (NOT FIND_LIB_RT)
message(FATAL_ERROR "Could not find real time library.")
endif ()
# Find dynamic linking library.
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(LIB_DL "dl")
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD"
OR CMAKE_SYSTEM_NAME STREQUAL "NetBSD"
OR CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
set(LIB_DL "c")
else ()
set(LIB_DL "")
endif ()
check_library_exists(
"${LIB_DL}"
"dlopen"
"${CMAKE_LIBRARY_PATH}"
FIND_LIB_DL
)
if (NOT FIND_LIB_DL)
message(FATAL_ERROR "Could not find dynamic linking library.")
endif ()
# Set path.
if (WITH_PREFIX)
set(PREFIX "${WITH_PREFIX}")
set(CMAKE_INSTALL_PREFIX "${PREFIX}")
else ()
set(PREFIX "${CMAKE_INSTALL_PREFIX}")
endif ()
if (WITH_PREFIX_LIB)
set(PREFIX_LIB "${WITH_PREFIX_LIB}")
else ()
set(PREFIX_LIB "${CMAKE_INSTALL_PREFIX}/lib")
endif ()
if (WITH_PREFIX_INC)
set(PREFIX_INC "${WITH_PREFIX_INC}")
else ()
set(PREFIX_INC "${CMAKE_INSTALL_PREFIX}/include")
endif ()
# Set pkg-config options.
option(WITH_PKGCONFIG_SCRIPT "Generate and install pkg-config script." ON)
if (WITH_PKGCONFIG_SCRIPT)
# Generate pkg-config file.
message(STATUS "Generating pkg-config file.")
configure_file(
"${SCRIPT_DIR}/centreon-clib.pc.in"
"${SCRIPT_DIR}/centreon-clib.pc"
@ONLY
)
# pkg-config file install directory.
if (WITH_PKGCONFIG_DIR)
set(PKGCONFIG_DIR "${WITH_PKGCONFIG_DIR}")
else ()
set(PKGCONFIG_DIR "${PREFIX_LIB}/pkgconfig")
endif ()
# Install rule.
install(
FILES "${SCRIPT_DIR}/centreon-clib.pc"
DESTINATION "${PKGCONFIG_DIR}"
COMPONENT "runtime"
)
endif ()
# Set options.
set(UNIT_TEST "No")
if (WITH_TESTING)
set(UNIT_TEST "Yes")
endif ()
set(DEB_PACKAGE "No")
if (CPACK_BINARY_DEB)
set(DEB_PACKAGE "Yes")
endif ()
set(RPM_PACKAGE "No")
if (CPACK_BINARY_RPM)
set(RPM_PACKAGE "Yes")
endif ()
# Set libraries.
if (NOT WITH_SHARED_LIB AND NOT WITH_STATIC_LIB)
set(WITH_SHARED_LIB 1)
endif ()
set(SHARED_LIB "No")
if (WITH_SHARED_LIB)
set(SHARED_LIB "Yes")
endif()
set(STATIC_LIB "No")
if (WITH_STATIC_LIB)
set(STATIC_LIB "Yes")
endif ()
if (WITH_SHARED_LIB)
set(DEFAULT_LINK_NAME "centreon_clib_shared")
else ()
set(DEFAULT_LINK_NAME "centreon_clib_static")
endif ()
# Find headers.
include(CheckIncludeFileCXX)
check_include_file_cxx("spawn.h" HAVE_SPAWN_H)
if (HAVE_SPAWN_H)
add_definitions(-DHAVE_SPAWN_H)
else ()
message(WARNING "Your plateform does not have spawn.h. Some features might "
"be disabled.")
endif ()
# Set sources.
set(
SOURCES
"${SRC_DIR}/library.cc"
"${SRC_DIR}/process_manager.cc"
"${SRC_DIR}/process.cc"
"${SRC_DIR}/handle_manager.cc"
"${SRC_DIR}/handle_action.cc"
"${SRC_DIR}/task_manager.cc"
"${SRC_DIR}/timestamp.cc"
)
# Set headers.
set(
HEADERS
${SPECIFIC_HEADERS}
"${INC_DIR}/clib.hh"
"${INC_DIR}/handle.hh"
"${INC_DIR}/handle_action.hh"
"${INC_DIR}/handle_listener.hh"
"${INC_DIR}/handle_manager.hh"
"${INC_DIR}/hash.hh"
"${INC_DIR}/library.hh"
"${INC_DIR}/namespace.hh"
"${INC_DIR}/process_manager.hh"
"${INC_DIR}/process.hh"
"${INC_DIR}/task.hh"
"${INC_DIR}/task_manager.hh"
"${INC_DIR}/timestamp.hh"
"${INC_DIR}/unique_array_ptr.hh"
"${INC_DIR}/unordered_hash.hh"
)
# Include directories.
include_directories("${INCLUDE_DIR}")
# Add subdirectories.
add_subdirectory(src/clib)
add_subdirectory(src/exceptions)
add_subdirectory(src/logging)
add_subdirectory(src/misc)
add_subdirectory(src/io)
if (WITH_TESTING)
add_subdirectory(test)
endif ()
if (WITH_SHARED_LIB)
# Create shared library.
add_library(
"centreon_clib_shared"
SHARED
${SOURCES}
${HEADERS}
)
# Link target with required libraries.
target_link_libraries(
"centreon_clib_shared"
${LIB_THREAD}
${LIB_RT}
${LIB_DL}
)
# Set output name for the shared library.
set_target_properties(
"centreon_clib_shared"
PROPERTIES
OUTPUT_NAME
"centreon_clib"
)
# Install shared library.
install(
TARGETS "centreon_clib_shared"
DESTINATION "${PREFIX_LIB}"
COMPONENT "runtime"
)
endif ()
if (WITH_STATIC_LIB)
# Create static library.
add_library(
"centreon_clib_static"
STATIC
${SOURCES}
${HEADERS}
)
# Link target with required libraries.
target_link_libraries(
"centreon_clib_static"
${LIB_THREAD}
${LIB_RT}
${LIB_DL}
)
# Set output name for the static library.
set_target_properties(
"centreon_clib_static"
PROPERTIES
OUTPUT_NAME
"centreon_clib"
)
# Install static library.
install(
TARGETS "centreon_clib_static"
DESTINATION "${PREFIX_LIB}"
COMPONENT "runtime"
)
endif ()
# Install header files for devel.
install(
DIRECTORY "${INCLUDE_DIR}/"
DESTINATION "${PREFIX_INC}"
COMPONENT "development"
FILES_MATCHING PATTERN "*.hh"
)
# Include build package.
include(cmake/package.cmake)
# Print summary.
message(STATUS "")
message(STATUS "Configuration Summary")
message(STATUS "---------------------")
message(STATUS "")
message(STATUS " Project")
message(STATUS " - Name ${PROJECT_NAME}")
message(STATUS " - Version ${CLIB_VERSION}")
message(STATUS " - With shared library ${SHARED_LIB}")
message(STATUS " - With static library ${STATIC_LIB}")
message(STATUS "")
message(STATUS " System")
message(STATUS " - Name ${CMAKE_SYSTEM_NAME}")
message(STATUS " - Version ${CMAKE_SYSTEM_VERSION}")
message(STATUS " - Processor ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "")
message(STATUS " Build")
message(STATUS " - Compiler ${CMAKE_CXX_COMPILER} "
"(${CMAKE_CXX_COMPILER_ID})")
message(STATUS " - Extra compilation flags ${CMAKE_CXX_FLAGS}")
message(STATUS " - Build unit tests ${UNIT_TEST}")
message(STATUS "")
message(STATUS " Installation")
message(STATUS " - Prefix ${PREFIX}")
message(STATUS " - Library directory ${PREFIX_LIB}")
message(STATUS " - Include directory ${PREFIX_INC}")
message(STATUS " - Package ${PACKAGE_LIST}")
if (WITH_PKGCONFIG_SCRIPT)
message(STATUS " - pkg-config directory ${PKGCONFIG_DIR}")
endif ()
message(STATUS "")
centreon-clib-21.04.2/Jenkinsfile 0000664 0000000 0000000 00000005722 14071536445 0016607 0 ustar 00root root 0000000 0000000 import groovy.json.JsonSlurper
/*
** Variables.
*/
def serie = '21.04'
def maintenanceBranch = "${serie}.x"
if (env.BRANCH_NAME.startsWith('release-')) {
env.BUILD = 'RELEASE'
} else if ((env.BRANCH_NAME == 'master') || (env.BRANCH_NAME == maintenanceBranch)) {
env.BUILD = 'REFERENCE'
} else {
env.BUILD = 'CI'
}
/*
** Pipeline code.
*/
stage('Source') {
node {
sh 'setup_centreon_build.sh'
dir('centreon-clib') {
checkout scm
}
sh "./centreon-build/jobs/clib/${serie}/mon-clib-source.sh"
source = readProperties file: 'source.properties'
env.VERSION = "${source.VERSION}"
env.RELEASE = "${source.RELEASE}"
publishHTML([
allowMissing: false,
keepAll: true,
reportDir: 'summary',
reportFiles: 'index.html',
reportName: 'Centreon Clib Build Artifacts',
reportTitles: ''
])
withSonarQubeEnv('SonarQubeDev') {
sh "./centreon-build/jobs/clib/${serie}/mon-clib-analysis.sh"
}
}
}
try {
// sonarQube step to get qualityGate result
stage('Quality gate') {
node {
sleep 120
def qualityGate = waitForQualityGate()
if (qualityGate.status != 'OK') {
currentBuild.result = 'FAIL'
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error("Quality gate failure: ${qualityGate.status}.");
}
}
}
stage('Package') {
parallel 'centos7': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/clib/${serie}/mon-clib-package.sh centos7"
}
},
'centos8': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/clib/${serie}/mon-clib-package.sh centos8"
}
},
'debian10': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/clib/${serie}/mon-clib-package.sh debian10"
}
},
'debian10-armhf': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/clib/${serie}/mon-clib-package.sh debian10-armhf"
}
/*
},
'opensuse-leap': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/clib/${serie}/mon-clib-package.sh opensuse-leap"
}
*/
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Package stage failure.');
}
}
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
stage('Delivery') {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/clib/${serie}/mon-clib-delivery.sh"
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Delivery stage failure.');
}
}
}
}
finally {
buildStatus = currentBuild.result ?: 'SUCCESS';
if ((buildStatus != 'SUCCESS') && ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE'))) {
slackSend channel: '#monitoring-metrology', message: "@channel Centreon Clib build ${env.BUILD_NUMBER} of branch ${env.BRANCH_NAME} was broken by ${source.COMMITTER}. Please fix it ASAP."
}
}
centreon-clib-21.04.2/LICENSE 0000664 0000000 0000000 00000026136 14071536445 0015432 0 ustar 00root root 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
centreon-clib-21.04.2/README.md 0000664 0000000 0000000 00000010121 14071536445 0015667 0 ustar 00root root 0000000 0000000 # Centreon Clib
Centreon Clib is an open-source utility library used by some Centreon
software. It is a low-level component of the
[Centreon software suite](https://www.centreon.com).
Centreon Clib is released under the General Public License version 2
and is endorsed by the [Centreon company](https://www.centreon.com).
## Documentation
*Coming soon on https://docs.centreon.com*
## Installing from binaries
> Centreon Clib is a low-level component of the Centreon
> software suite. If this is your first installation you would probably
> want to [install it entirely](https://docs.centreon.com/current/en/installation/installation-of-a-central-server/using-sources.html).
Centreon ([the company behind the Centreon software suite](http://www.centreon.com))
provides binary packages for RedHat / CentOS. They are available either
as part of the [Centreon Platform](https://www.centreon.com/en/platform/)
or as individual packages on [our RPM repository](https://docs.centreon.com/current/en/installation/installation-of-a-poller/using-packages.html).
Once the repository installed a simple command will be needed to install
Centreon Clib.
```shell
yum install centreon-clib
```
## Fetching sources
Beware that the repository hosts in-development sources and that it
might not work at all.
Stable releases are available as gziped tarballs on [Centreon's
download site](https://download.centreon.com).
## Compilation
This paragraph is only a quickstart guide for the compilation of
Centreon Clib.
### CentOS / Debian / Raspbian
Compilation of these distributions is pretty straightforward.
You'll need to download the project and launch the *cmake.sh* script
to prepare the compilation environment.
Here are the command lines to launch:
```shell
git clone https://github.com/centreon/centreon-clib
cd centreon-clib
./cmake.sh
cd build
make
make install
```
### Other distributions
If you are on another distribution, then follow the steps below.
Check if you have these packages installed (Note that packages names
come from CentOS distributions, so if some packages names don't match
on your distribution try to find their equivalent names): git, make,
cmake.
Once the sources of Centreon Clib extracted, create the *build/*
directory and from that directory launch the CMake command as proposed below:
```shell
git clone https://github.com/centreon/centreon-clib
mkdir -p centreon-clib/build
cd centreon-clib/build
cmake -DWITH_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DWITH_PREFIX_LIB=/usr/lib64 -DWITH_TESTING=On ..
```
Now launch the compilation using the *make* command and then install the
software by running *make install* as priviledged user:
```shell
make
make install
```
You're done!
## Bug reports / Feature requests
The best way to report a bug or to request a feature is to open an issue
in GitHub's [issue tracker](https://github.com/centreon/centreon-clib/issues/).
Please note that Centreon Clib follows the
[same workflow as Centreon](https://github.com/centreon/centreon/issues/new/choose)
to process issues.
For a quick resolution of a bug your message should contain:
- The problem description
- Precise steps on how to reproduce the issue (if you're using Centreon
web UI tell us where you click)
- The expected behavior
- The Centreon product**s** version**s**
- The operating system you're using (name and version)
- If possible configuration, log and debug files
## Contributing
Contributions are much welcome! If possible provide them as
pull-requests on GitHub. If not, patches will do but describe against
which version/commit they apply.
For any question or remark feel free to send a mail to the project
maintainers:
centreon-clib-21.04.2/SECURITY.md 0000664 0000000 0000000 00000011044 14071536445 0016206 0 ustar 00root root 0000000 0000000 # Security Policy
Centreon takes the security of our software products seriously.
If you believe you have found a security vulnerability, please report it to us as described below.
## Reporting a Vulnerability
**Please do not report security vulnerabilities through public GitHub issues.**
Send an email to security@centreon.com. If possible, encrypt your message with our PGP key below.
You should receive a response within 48 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
To help us better understand the nature and scope of the possible issue, please describe as much as you can:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
## PGP information
### Public key
```
-----BEGIN PGP PUBLIC KEY BLOCK-----
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
oWAyTvK/VwbB77CTz1yTUSE=
=3kAj
-----END PGP PUBLIC KEY BLOCK-----
```
| Tag | Value |
| -- | -- |
| ID | BEAF6EBF631106F9 |
| Type | RSA |
| Size | 4096 |
| Created | 2020-02-11 |
| Expires | 2021-02-10 |
| Cipher |AES-256|
| Fingerprint | C377 E9D5 2D5C 137D 3DD5 73B5 BEA F6EBF 6311 06F9 |
## Bug bounty
We don't have a bug bounty program but this is something we are thinking about.
centreon-clib-21.04.2/cmake.sh 0000775 0000000 0000000 00000010175 14071536445 0016040 0 ustar 00root root 0000000 0000000 #!/bin/bash
# Usage info
show_help() {
cat << EOF
Usage: ${0##*/} -n=[yes|no] -v
This program build Centreon-clib
-f|--force : force rebuild
-r|--release : Build on release mode
-h|--help : help
EOF
}
force=0
BUILD_TYPE="Debug"
for i in "$@"
do
case $i in
-f|--force)
force=1
shift
;;
-r|--release)
BUILD_TYPE="Release"
;;
-h|--help)
show_help
exit 2
;;
*)
# unknown option
;;
esac
done
# Am I root?
my_id=$(id -u)
if [ -r /etc/centos-release ] ; then
maj="centos$(cat /etc/centos-release | awk '{print $4}' | cut -f1 -d'.')"
v=$(cmake --version)
if [[ $v =~ "version 3" ]] ; then
cmake='cmake'
else
if rpm -q cmake3 ; then
cmake='cmake3'
elif [ $maj = "centos7" ] ; then
yum -y install epel-release
yum -y install cmake3
cmake='cmake3'
else
dnf -y install cmake
cmake='cmake'
fi
fi
if ! rpm -q gcc-c++ ; then
yum -y install gcc-c++
fi
pkgs=(
ninja-build
)
for i in "${pkgs[@]}"; do
if ! rpm -q $i ; then
if [ $maj = 'centos7' ] ; then
yum install -y $i
else
dnf -y --enablerepo=PowerTools install $i
fi
fi
done
elif [ -r /etc/issue ] ; then
maj=$(cat /etc/issue | awk '{print $1}')
version=$(cat /etc/issue | awk '{print $3}')
v=$(cmake --version)
if [[ $v =~ "version 3" ]] ; then
cmake='cmake'
elif [ $maj = "Debian" ] ; then
if [ $version = "9" ] ; then
dpkg="dpkg"
else
dpkg="dpkg --no-pager"
fi
if $dpkg -l --no-pager cmake ; then
echo "Bad version of cmake..."
exit 1
else
if [ $my_id -eq 0 ] ; then
apt install -y cmake
cmake='cmake'
else
echo -e "cmake is not installed, you could enter, as root:\n\tapt install -y cmake\n\n"
exit 1
fi
fi
pkgs=(
gcc
g++
ninja-build
pkg-config
)
for i in "${pkgs[@]}"; do
if ! $dpkg -l --no-pager $i | grep "^ii" ; then
if [ $my_id -eq 0 ] ; then
apt install -y $i
else
echo -e "The package \"$i\" is not installed, you can install it, as root, with the command:\n\tapt install -y $i\n\n"
exit 1
fi
fi
done
elif [ $maj = "Raspbian" ] ; then
if [ $version = "9" ] ; then
dpkg="dpkg"
else
dpkg="dpkg --no-pager"
fi
if $dpkg -l --no-pager cmake ; then
echo "Bad version of cmake..."
exit 1
else
if [ $my_id -eq 0 ] ; then
apt install -y cmake
cmake='cmake'
else
echo -e "cmake is not installed, you could enter, as root:\n\tapt install -y cmake\n\n"
exit 1
fi
fi
pkgs=(
gcc
g++
ninja-build
pkg-config
)
for i in "${pkgs[@]}"; do
if ! $dpkg -l --no-pager $i | grep "^ii" ; then
if [ $my_id -eq 0 ] ; then
apt install -y $i
else
echo -e "The package \"$i\" is not installed, you can install it, as root, with the command:\n\tapt install -y $i\n\n"
exit 1
fi
fi
done
else
echo "Bad version of cmake..."
exit 1
fi
fi
if [ ! -d build ] ; then
mkdir build
fi
if [ "$force" = "1" ] ; then
rm -rf build
mkdir build
fi
cd build
if [ $maj = "Raspbian" ] ; then
CXXFLAGS="-Wall -Wextra" $cmake -DWITH_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_PREFIX_LIB=/usr/lib -DWITH_TESTING=On -DUSE_CXX11_ABI=1 $* ..
elif [ $maj = "Debian" ] ; then
CXXFLAGS="-Wall -Wextra" $cmake -DWITH_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_PREFIX_LIB=/usr/lib64 -DWITH_TESTING=On -DUSE_CXX11_ABI=1 $* ..
else
CXXFLAGS="-Wall -Wextra" $cmake -DWITH_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_PREFIX_LIB=/usr/lib64 -DWITH_TESTING=On -DUSE_CXX11_ABI=0 $* ..
fi
#CXX=/usr/bin/clang++ CC=/usr/bin/clang CXXFLAGS="-Wall -Wextra" cmake -DWITH_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DWITH_PREFIX_LIB=/usr/lib64 -DWITH_TESTING=On $* ..
#CXXFLAGS="-Wall -Wextra -O1 -fsanitize=address -fno-omit-frame-pointer" cmake -DWITH_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DWITH_PREFIX_LIB=/usr/lib64 -DWITH_TESTING=On $* ..
centreon-clib-21.04.2/cmake/ 0000775 0000000 0000000 00000000000 14071536445 0015475 5 ustar 00root root 0000000 0000000 centreon-clib-21.04.2/cmake/CodeCoverage.cmake 0000664 0000000 0000000 00000021152 14071536445 0021026 0 ustar 00root root 0000000 0000000 # Copyright (c) 2012 - 2017, Lars Bilke
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# CHANGES:
#
# 2012-01-31, Lars Bilke
# - Enable Code Coverage
#
# 2013-09-17, Joakim Söderberg
# - Added support for Clang.
# - Some additional usage instructions.
#
# 2016-02-03, Lars Bilke
# - Refactored functions to use named parameters
#
# 2017-06-02, Lars Bilke
# - Merged with modified version from github.com/ufz/ogs
#
#
# USAGE:
#
# 1. Copy this file into your cmake modules path.
#
# 2. Add the following line to your CMakeLists.txt:
# include(CodeCoverage)
#
# 3. Append necessary compiler flags:
# APPEND_COVERAGE_COMPILER_FLAGS()
#
# 4. If you need to exclude additional directories from the report, specify them
# using the COVERAGE_EXCLUDES variable before calling SETUP_TARGET_FOR_COVERAGE.
# Example:
# set(COVERAGE_EXCLUDES 'dir1/*' 'dir2/*')
#
# 5. Use the functions described below to create a custom make target which
# runs your test executable and produces a code coverage report.
#
# 6. Build a Debug build:
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# make
# make my_coverage_target
#
include(CMakeParseArguments)
# Check prereqs
find_program( GCOV_PATH gcov )
find_program( LCOV_PATH lcov )
find_program( GENHTML_PATH genhtml )
find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test)
find_program( SIMPLE_PYTHON_EXECUTABLE python )
if(NOT GCOV_PATH)
message(FATAL_ERROR "gcov not found! Aborting...")
endif() # NOT GCOV_PATH
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3)
message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
endif()
elseif(NOT CMAKE_COMPILER_IS_GNUCXX)
message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
endif()
set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage -fprofile-arcs -ftest-coverage"
CACHE INTERNAL "")
set(CMAKE_CXX_FLAGS_COVERAGE
${COVERAGE_COMPILER_FLAGS}
CACHE STRING "Flags used by the C++ compiler during coverage builds."
FORCE )
set(CMAKE_C_FLAGS_COVERAGE
${COVERAGE_COMPILER_FLAGS}
CACHE STRING "Flags used by the C compiler during coverage builds."
FORCE )
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
""
CACHE STRING "Flags used for linking binaries during coverage builds."
FORCE )
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
""
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
FORCE )
mark_as_advanced(
CMAKE_CXX_FLAGS_COVERAGE
CMAKE_C_FLAGS_COVERAGE
CMAKE_EXE_LINKER_FLAGS_COVERAGE
CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading")
endif() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
link_libraries(gcov)
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()
# Defines a target for running and collection code coverage information
# Builds dependencies, runs the given executable and outputs reports.
# NOTE! The executable should always have a ZERO as exit code otherwise
# the coverage generation will not complete.
#
# SETUP_TARGET_FOR_COVERAGE(
# NAME testrunner_coverage # New target name
# EXECUTABLE testrunner -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
# DEPENDENCIES testrunner # Dependencies to build first
# )
function(SETUP_TARGET_FOR_COVERAGE)
set(options NONE)
set(oneValueArgs NAME)
set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT LCOV_PATH)
message(FATAL_ERROR "lcov not found! Aborting...")
endif() # NOT LCOV_PATH
if(NOT GENHTML_PATH)
message(FATAL_ERROR "genhtml not found! Aborting...")
endif() # NOT GENHTML_PATH
# Setup target
add_custom_target(${Coverage_NAME}
# Cleanup lcov
COMMAND ${LCOV_PATH} --directory . --zerocounters
# Run tests
COMMAND ${Coverage_EXECUTABLE}
# Capturing lcov counters and generating report
COMMAND ${LCOV_PATH} --directory . --capture --output-file ${Coverage_NAME}.info
COMMAND ${LCOV_PATH} --remove ${Coverage_NAME}.info ${COVERAGE_EXCLUDES} --output-file ${Coverage_NAME}.info.cleaned
COMMAND ${GENHTML_PATH} -o ${Coverage_NAME} ${Coverage_NAME}.info.cleaned
COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.info ${Coverage_NAME}.info.cleaned
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
DEPENDS ${Coverage_DEPENDENCIES}
COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
)
# Show info where to find the report
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
COMMAND ;
COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report."
)
endfunction() # SETUP_TARGET_FOR_COVERAGE
# Defines a target for running and collection code coverage information
# Builds dependencies, runs the given executable and outputs reports.
# NOTE! The executable should always have a ZERO as exit code otherwise
# the coverage generation will not complete.
#
# SETUP_TARGET_FOR_COVERAGE_COBERTURA(
# NAME ctest_coverage # New target name
# EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
# DEPENDENCIES executable_target # Dependencies to build first
# )
function(SETUP_TARGET_FOR_COVERAGE_COBERTURA)
set(options NONE)
set(oneValueArgs NAME)
set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT SIMPLE_PYTHON_EXECUTABLE)
message(FATAL_ERROR "python not found! Aborting...")
endif() # NOT SIMPLE_PYTHON_EXECUTABLE
if(NOT GCOVR_PATH)
message(FATAL_ERROR "gcovr not found! Aborting...")
endif() # NOT GCOVR_PATH
# Combine excludes to several -e arguments
set(COBERTURA_EXCLUDES "")
foreach(EXCLUDE ${COVERAGE_EXCLUDES})
set(COBERTURA_EXCLUDES "-e ${EXCLUDE} ${COBERTURA_EXCLUDES}")
endforeach()
add_custom_target(${Coverage_NAME}
# Run tests
${Coverage_EXECUTABLE}
# Running gcovr
COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} ${COBERTURA_EXCLUDES}
-o ${Coverage_NAME}.xml
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
DEPENDS ${Coverage_DEPENDENCIES}
COMMENT "Running gcovr to produce Cobertura code coverage report."
)
# Show info where to find the report
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
COMMAND ;
COMMENT "Cobertura code coverage report saved in ${Coverage_NAME}.xml."
)
endfunction() # SETUP_TARGET_FOR_COVERAGE_COBERTURA
function(APPEND_COVERAGE_COMPILER_FLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
message(STATUS "Appending code coverage compiler flags: ${COVERAGE_COMPILER_FLAGS}")
endfunction() # APPEND_COVERAGE_COMPILER_FLAGS
centreon-clib-21.04.2/cmake/package.cmake 0000664 0000000 0000000 00000005560 14071536445 0020100 0 ustar 00root root 0000000 0000000 ##
## Copyright 2011-2013 Centreon
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## For more information : contact@centreon.com
##
# Packaging.
option(WITH_PACKAGE_SH "Build shell-installable package." OFF)
option(WITH_PACKAGE_TGZ "Build gziped tarball package." OFF)
option(WITH_PACKAGE_TBZ2 "Build bzip2'd tarball package." OFF)
option(WITH_PACKAGE_DEB "Build DEB package." OFF)
option(WITH_PACKAGE_RPM "Build RPM package." OFF)
option(WITH_PACKAGE_NSIS "Build NSIS package." OFF)
if (WITH_PACKAGE_SH
OR WITH_PACKAGE_TGZ
OR WITH_PACKAGE_TBZ2
OR WITH_PACKAGE_DEB
OR WITH_PACKAGE_RPM
OR WITH_PACKAGE_NSIS)
# Default settings.
set(CPACK_PACKAGE_NAME "centreon-clib")
set(CPACK_PACKAGE_VENDOR "Centreon")
set(CPACK_PACKAGE_VERSION_MAJOR "${CLIB_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${CLIB_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${CLIB_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"Centreon C/C++ library used in multiple monitoring-related projects.")
set(CPACK_PACKAGE_FILE_NAME
"centreon-clib-${CLIB_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "centreon-clib")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_CONTACT
"Matthieu Kermagoret ")
# Generators.
unset(PACKAGE_LIST)
if (WITH_PACKAGE_SH)
list(APPEND CPACK_GENERATOR "STGZ")
list(APPEND PACKAGE_LIST "Shell-installable package (.sh)")
endif ()
if (WITH_PACKAGE_TGZ)
list(APPEND CPACK_GENERATOR "TGZ")
list(APPEND PACKAGE_LIST "gziped tarball (.tar.gz)")
endif ()
if (WITH_PACKAGE_TBZ2)
list(APPEND CPACK_GENERATOR "TBZ2")
list(APPEND PACKAGE_LIST "bzip2'd tarball (.tar.bz2)")
endif ()
if (WITH_PACKAGE_DEB)
list(APPEND CPACK_GENERATOR "DEB")
list(APPEND PACKAGE_LIST "DEB package (.deb)")
set(CPACK_DEBIAN_PACKAGE_SECTION "net")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libstdc++6")
endif ()
if (WITH_PACKAGE_RPM)
list(APPEND CPACK_GENERATOR "RPM")
list(APPEND PACKAGE_LIST "RPM package (.rpm)")
set(CPACK_RPM_PACKAGE_RELEASE 1)
set(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0")
endif ()
if (WITH_PACKAGE_NSIS)
list(APPEND CPACK_GENERATOR "NSIS")
list(APPEND PACKAGE_LIST "NSIS package (.exe)")
endif ()
string(REPLACE ";" ", " PACKAGE_LIST "${PACKAGE_LIST}")
# CPack module.
include(CPack)
else ()
set(PACKAGE_LIST "None")
endif ()
centreon-clib-21.04.2/deps.go 0000664 0000000 0000000 00000005251 14071536445 0015702 0 ustar 00root root 0000000 0000000 package main
import (
"bufio"
"fmt"
"log"
"os"
"path/filepath"
"regexp"
"strings"
)
// MaxDepth Max depth in search tree
const MaxDepth = 3
func findIncludes(file string, treated *[]string, edges *[]string, depth int) {
var myList []string
file1 := file
f, err := os.Open(file1)
if err != nil {
file1 = strings.TrimPrefix(file, "inc/")
for _, pref := range []string{
"/usr/local/include/",
"inc/",
"modules/external_commands/inc/" } {
f, err = os.Open(pref + file1)
if err == nil {
file1 = pref + file1
*treated = append(*treated, file1)
break
}
}
} else {
*treated = append(*treated, file1)
}
defer f.Close()
depth++
if depth > MaxDepth {
return
}
scanner := bufio.NewScanner(f)
r, _ := regexp.Compile("^#\\s*include\\s*([<\"])(.*)[>\"]")
for scanner.Scan() {
line := scanner.Text()
match := r.FindStringSubmatch(line)
if len(match) > 0 {
/* match[0] is the global match, match[1] is '<' or '"' and match[2] is the file to include */
if match[1] == "\"" {
*edges = append(*edges, fmt.Sprintf(" \"%s\" -> \"%s\";\n", file, match[2]))
myList = append(myList, match[2])
} else {
*edges = append(*edges, fmt.Sprintf(" \"%s\" -> \"%s\";\n", file, match[2]))
}
}
}
if err := scanner.Err(); err != nil {
log.Print(file, " --- ", err)
}
for _, file2 := range myList {
found := false
for _, ff := range *treated {
if ff == file2 {
found = true
break
}
}
if !found {
findIncludes(file2, treated, edges, depth)
}
}
}
func unique(edges []string) []string {
keys := make(map[string]bool)
list := []string{}
for _, entry := range edges {
if _, value := keys[entry]; !value {
keys[entry] = true
list = append(list, entry)
}
}
return list
}
func main() {
args := os.Args[1:]
var fileList []string
var edges []string
if len(args) == 0 {
for _, searchDir := range []string{"src", "inc"} {
filepath.Walk(searchDir, func(path string, f os.FileInfo, err error) error {
if strings.HasSuffix(path, ".cc") || strings.HasSuffix(path, ".hh") {
fileList = append(fileList, path)
}
return nil
})
}
} else {
fileList = append(fileList, args[0])
}
fmt.Println("digraph deps {")
var treated []string
for _, file := range fileList {
findIncludes(file, &treated, &edges, 0)
}
edges = unique(edges)
for _, l := range edges {
fmt.Println(l)
}
fmt.Println("}")
}
centreon-clib-21.04.2/deps.sh 0000775 0000000 0000000 00000000366 14071536445 0015714 0 ustar 00root root 0000000 0000000 #!/bin/bash
go run deps.go "$*" > /tmp/deps.dot
dot -Tpng /tmp/deps.dot -o deps.png
if [ -x /usr/bin/eog ] ; then
eog deps.png&
elif [ -x /usr/bin/lximage-qt ] ; then
lximage-qt deps.png&
else
echo "No image viewer defined..."
exit 1
fi
centreon-clib-21.04.2/doc/ 0000775 0000000 0000000 00000000000 14071536445 0015162 5 ustar 00root root 0000000 0000000 centreon-clib-21.04.2/doc/README.md 0000664 0000000 0000000 00000000074 14071536445 0016442 0 ustar 00root root 0000000 0000000 # Documentation
*Coming soon on https://docs.centreon.com*
centreon-clib-21.04.2/inc/ 0000775 0000000 0000000 00000000000 14071536445 0015166 5 ustar 00root root 0000000 0000000 centreon-clib-21.04.2/inc/com/ 0000775 0000000 0000000 00000000000 14071536445 0015744 5 ustar 00root root 0000000 0000000 centreon-clib-21.04.2/inc/com/centreon/ 0000775 0000000 0000000 00000000000 14071536445 0017561 5 ustar 00root root 0000000 0000000 centreon-clib-21.04.2/inc/com/centreon/clib.hh 0000664 0000000 0000000 00000001433 14071536445 0021014 0 ustar 00root root 0000000 0000000 /*
** Copyright 2011-2013 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : contact@centreon.com
*/
#ifndef CC_CLIB_HH
#define CC_CLIB_HH
#include "com/centreon/logging/engine.hh"
#include "com/centreon/process_manager.hh"
#endif // !CC_CLIB_HH
centreon-clib-21.04.2/inc/com/centreon/clib/ 0000775 0000000 0000000 00000000000 14071536445 0020472 5 ustar 00root root 0000000 0000000 centreon-clib-21.04.2/inc/com/centreon/clib/version.hh.in 0000664 0000000 0000000 00000002746 14071536445 0023116 0 ustar 00root root 0000000 0000000 /*
** Copyright 2011-2013 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : contact@centreon.com
*/
#ifndef CC_CLIB_VERSION_HH
# define CC_CLIB_VERSION_HH
// Compile-time values.
# define CENTREON_CLIB_VERSION_MAJOR @CLIB_MAJOR@
# define CENTREON_CLIB_VERSION_MINOR @CLIB_MINOR@
# define CENTREON_CLIB_VERSION_PATCH @CLIB_PATCH@
# define CENTREON_CLIB_VERSION_STRING "@CLIB_VERSION@"
# include "com/centreon/namespace.hh"
CC_BEGIN()
namespace clib {
namespace version {
// Compile-time values.
unsigned int const major = @CLIB_MAJOR@;
unsigned int const minor = @CLIB_MINOR@;
unsigned int const patch = @CLIB_PATCH@;
char const* const string = "@CLIB_VERSION@";
// Run-time values.
unsigned int get_major() throw ();
unsigned int get_minor() throw ();
unsigned int get_patch() throw ();
char const* get_string() throw ();
}
}
CC_END()
#endif // !CC_HANDLE_HH
centreon-clib-21.04.2/inc/com/centreon/delayed_delete.hh 0000664 0000000 0000000 00000003624 14071536445 0023040 0 ustar 00root root 0000000 0000000 /*
** Copyright 2012-2013 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : contact@centreon.com
*/
#ifndef CC_DELAYED_DELETE_HH
#define CC_DELAYED_DELETE_HH
#include
#include "com/centreon/namespace.hh"
CC_BEGIN()
/**
* @class delayed_delete delayed_delete.hh "com/centreon/delayed_delete.hh"
* @brief Perform a delayed delete.
*
* This template is used to perfom delayed object deletion using a task
* manager. The pointer will be deleted when the run() method is
* called. If the run() method has not been called when delayed_delete
* is destroyed, the pointer won't be deleted.
*
* @see task_manager
*/
template
class delayed_delete : public task {
T* _ptr;
/**
* Copy internal data members.
*
* @param[in] dd Object to copy.
*/
void _internal_copy(delayed_delete const& dd) { _ptr = dd._ptr; }
public:
/**
* Default constructor.
*
* @param[in] ptr Pointer to delete.
*/
delayed_delete(T* ptr) : _ptr(ptr) {}
/**
* Destructor.
*/
~delayed_delete() noexcept {}
/**
* Copy constructor.
*
* @param[in] dd Object to copy.
*/
delayed_delete(delayed_delete const& dd) = delete;
delayed_delete& operator=(delayed_delete const& dd) = delete;
/**
* Delete pointer.
*/
void run() {
delete _ptr;
_ptr = nullptr;
}
};
CC_END()
#endif // !CC_DELAYED_DELETE_HH
centreon-clib-21.04.2/inc/com/centreon/exceptions/ 0000775 0000000 0000000 00000000000 14071536445 0021742 5 ustar 00root root 0000000 0000000 centreon-clib-21.04.2/inc/com/centreon/exceptions/basic.hh 0000664 0000000 0000000 00000003455 14071536445 0023353 0 ustar 00root root 0000000 0000000 /*
** Copyright 2011-2014 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : contact@centreon.com
*/
#ifndef CC_EXCEPTIONS_BASIC_HH
#define CC_EXCEPTIONS_BASIC_HH
#include
#include "com/centreon/misc/stringifier.hh"
CC_BEGIN()
namespace exceptions {
/**
* @class basic basic.hh "com/centreon/exceptions/basic.hh"
* @brief Base exception class.
*
* Simple exception class containing an basic error message.
*/
class basic : public std::exception {
public:
basic();
basic(char const* file, char const* function, int line);
basic(basic const& other);
virtual ~basic() throw();
virtual basic& operator=(basic const& other);
template
basic& operator<<(T t) {
_buffer << t;
return (*this);
}
virtual char const* what() const throw();
private:
void _internal_copy(basic const& other);
misc::stringifier _buffer;
};
}
CC_END()
#if defined(__GNUC__)
#define FUNCTION __PRETTY_FUNCTION__
#elif defined(_MSC_VER)
#define FUNCTION __FUNCSIG__
#else
#define FUNCTION __func__
#endif // GCC, Visual or other.
#ifndef NDEBUG
#define basic_error() \
com::centreon::exceptions::basic(__FILE__, FUNCTION, __LINE__)
#else
#define basic_error() com::centreon::exceptions::basic()
#endif // !NDEBUG
#endif // !CC_EXCEPTIONS_BASIC_HH
centreon-clib-21.04.2/inc/com/centreon/exceptions/interruption.hh 0000664 0000000 0000000 00000003642 14071536445 0025032 0 ustar 00root root 0000000 0000000 /*
** Copyright 2014 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : contact@centreon.com
*/
#ifndef CC_EXCEPTIONS_INTERRUPTION_HH
#define CC_EXCEPTIONS_INTERRUPTION_HH
#include "com/centreon/exceptions/basic.hh"
#include "com/centreon/namespace.hh"
CC_BEGIN()
namespace exceptions {
/**
* @class interruption interruption.hh
*"com/centreon/exceptions/interruption.hh"
* @brief Exception signaling an interruption in processing.
*
* Some operation that was in progress was interrupted but did not
* fail. This is mostly used to warn users of an errno of EINTR
* during a syscall.
*/
class interruption : public basic {
public:
interruption();
interruption(char const* file, char const* function, int line);
interruption(interruption const& other);
virtual ~interruption() throw();
interruption& operator=(interruption const& other);
template
interruption& operator<<(T t) {
basic::operator<<(t);
return (*this);
}
};
}
CC_END()
#if defined(__GNUC__)
#define FUNCTION __PRETTY_FUNCTION__
#elif defined(_MSC_VER)
#define FUNCTION __FUNCSIG__
#else
#define FUNCTION __func__
#endif // GCC, Visual or other.
#ifndef NDEBUG
#define interruption_error() \
com::centreon::exceptions::basic(__FILE__, FUNCTION, __LINE__)
#else
#define interruption_error() com::centreon::exceptions::basic()
#endif // !NDEBUG
#endif // !CC_EXCEPTIONS_INTERRUPTION_HH
centreon-clib-21.04.2/inc/com/centreon/handle.hh 0000664 0000000 0000000 00000002564 14071536445 0021344 0 ustar 00root root 0000000 0000000 /*
** Copyright 2011-2013,2019 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : contact@centreon.com
*/
#ifndef CC_HANDLE_HH
#define CC_HANDLE_HH
#include "com/centreon/namespace.hh"
CC_BEGIN()
typedef int native_handle;
native_handle const native_handle_null = -1;
/**
* @class handle handle.hh "com/centreon/handle.hh"
* @brief Base for all handle objetcs.
*
* This class is an interface for system handle.
*/
class handle {
public:
handle() = default;
virtual ~handle() = default;
handle(handle const& right) = delete;
handle& operator=(handle const& right) = delete;
virtual void close() = 0;
virtual native_handle get_native_handle() = 0;
virtual unsigned long read(void* data, unsigned long size) = 0;
virtual unsigned long write(void const* data, unsigned long size) = 0;
};
CC_END()
#endif // !CC_HANDLE_HH
centreon-clib-21.04.2/inc/com/centreon/handle_action.hh 0000664 0000000 0000000 00000003236 14071536445 0022676 0 ustar 00root root 0000000 0000000 /*
** Copyright 2011-2013 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : contact@centreon.com
*/
#ifndef CC_HANDLE_ACTION_HH
#define CC_HANDLE_ACTION_HH
#include
#include "com/centreon/task.hh"
CC_BEGIN()
// Forward declaration.
class handle;
class handle_listener;
/**
* @class handle_action handle_action.hh "com/centreon/handle_action.hh"
* @brief Notify a listener.
*
* Notify a listener from a handle event.
*/
class handle_action : public task {
public:
enum action { none = 0, read, write, error };
handle_action(handle* h, handle_listener* hl, bool is_threadable = false);
handle_action(handle_action const& right) = delete;
~handle_action() noexcept;
handle_action& operator=(handle_action const& right) = delete;
bool is_threadable() const noexcept;
handle* get_handle() const noexcept;
handle_listener* get_handle_listener() const noexcept;
void run();
void set_action(action a) noexcept;
private:
void _internal_copy(handle_action const& right);
std::atomic _action;
handle* _h;
handle_listener* _hl;
bool _is_threadable;
};
CC_END()
#endif // !CC_HANDLE_ACTION_HH
centreon-clib-21.04.2/inc/com/centreon/handle_listener.hh 0000664 0000000 0000000 00000002766 14071536445 0023255 0 ustar 00root root 0000000 0000000 /*
** Copyright 2011-2013 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : contact@centreon.com
*/
#ifndef CC_HANDLE_LISTENER_HH
#define CC_HANDLE_LISTENER_HH
#include "com/centreon/handle.hh"
CC_BEGIN()
/**
* @class handle_listener handle_listener.hh "com/centreon/handle_listener.hh"
* @brief Base for all handle_listener objects.
*
* This class is an interface to receive notification from
* handle_manager for specific handle.
*/
class handle_listener {
public:
handle_listener() = default;
virtual ~handle_listener() noexcept {}
handle_listener(handle_listener const&) = delete;
handle_listener& operator=(handle_listener const&) = delete;
virtual void error(handle& h) = 0;
virtual void read(handle& h) {
char buf[4096];
h.read(buf, sizeof(buf));
}
virtual bool want_read(handle&) { return false; }
virtual bool want_write(handle&) { return false; }
virtual void write(handle&) {}
};
CC_END()
#endif // !CC_HANDLE_LISTENER_HH
centreon-clib-21.04.2/inc/com/centreon/handle_manager.hh 0000664 0000000 0000000 00000003555 14071536445 0023037 0 ustar 00root root 0000000 0000000 /*
** Copyright 2011-2013 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : contact@centreon.com
*/
#ifndef CC_HANDLE_MANAGER_POSIX_HH
#define CC_HANDLE_MANAGER_POSIX_HH
#include
#include