Bump version and add option for libconfig, fix resize logic

This commit is contained in:
Alex D. 2021-01-04 18:07:06 +00:00
parent 58acf3e337
commit 9b07bcb10b
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
3 changed files with 25 additions and 18 deletions

View File

@ -1,13 +1,17 @@
cmake_minimum_required(VERSION 3.16)
project(microircd LANGUAGES C)
project(
uIRCd
VERSION 2021.01.04
DESCRIPTION "High performance IRC daemon based on uIRC"
LANGUAGES C
)
include(GNUInstallDirs)
set(UIRCD_VERSION "${PROJECT_VERSION}")
add_compile_definitions(UIRCD_VERSION="${UIRCD_VERSION}")
set(UIRCD_VERSION "2021.01.03")
add_compile_definitions(UIRCD_VERSION="${UIRC_VERSION}")
OPTION(CODE_ANALYZER "Analyze the code statically" OFF)
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
OPTION(BUILD_LIBCONFIG "Build support for configurations" ON )
OPTION(CODE_ANALYZER "Analyze the code statically" OFF)
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
add_executable(uircd
src/buffer.c
@ -24,17 +28,18 @@ add_executable(uircd
find_library(UIRC_PATH NAMES uirc REQUIRED)
target_link_libraries(uircd ${UIRC_PATH})
find_library(LIBCONFIG_PATH NAMES config)
if(NOT LIBCONFIG_PATH)
message(WARNING "libconfig not found. uIRCd will not support configuration files")
else()
message(STATUS "Building with libconfig support")
add_compile_definitions(UIRCD_FEATURE_LIBCONFIG)
target_link_libraries(uircd ${LIBCONFIG_PATH})
if(BUILD_LIBCONFIG)
find_library(LIBCONFIG_PATH NAMES config)
if(NOT LIBCONFIG_PATH)
message(WARNING "libconfig not found. uIRCd will not support configuration files")
else()
message(STATUS "Building with libconfig support")
add_compile_definitions(UIRCD_FEATURE_LIBCONFIG)
target_link_libraries(uircd ${LIBCONFIG_PATH})
endif()
endif()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Werror")
add_compile_options(-pedantic)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
add_compile_options(
-Wall
@ -53,6 +58,7 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
-Wunsafe-loop-optimizations
-Wparentheses
-fstack-check
-pedantic
)
if (CODE_ANALYZER)
add_compile_options(-fanalyzer)
@ -62,6 +68,7 @@ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
-Weverything
-Wno-padded
-Wno-disabled-macro-expansion
-pedantic
)
if (CODE_COVERAGE)
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
@ -73,7 +80,7 @@ endif()
set_target_properties(uircd PROPERTIES
C_STANDARD 99
VERSION "${UIRCD_VERSION}"
VERSION ${UIRCD_VERSION}
)
install(

View File

@ -15,6 +15,7 @@ cmake -B build/ -DCMAKE_BUILD_TYPE=Release .
```
| Option | Description | Type | Default | Supported since |
|:------------------:|:----------------------------------------------------------------------:|:--------:|:-------:|:---------------:|
| BUILD_LIBCONFIG | Build and link against libconfig | boolean | true | 2020.01.04 |
| CODE_ANALYZER | Use static analysis tools | boolean | false | 2020.10.30 |
| CODE_COVERAGE | Generate code coverage output | boolean | false | 2020.10.30 |

View File

@ -52,17 +52,16 @@ parse_configfile(char* config_path, Connection* conn)
config_setting_t* chans;
if ((chans = config_lookup(&conf, ".channels")) != NULL) {
// TODO: Check if config_setting_length can return negative values
resize_chanarray(&conn->info.channels);
for (unsigned int i = 0; i < (unsigned int) config_setting_length(chans); i++) {
config_setting_t* chanelem = config_setting_get_elem(chans, i);
const char * name = NULL, *key = NULL;
config_setting_lookup_string(chanelem, "name", &name);
config_setting_lookup_string(chanelem, "key", &key);
LOG(LOG_DEBUG, "Got channel #%i: %s", i, name);
resize_chanarray(&conn->info.channels);
if (name != NULL) {
set_channel(&conn->info.channels[get_channelindex(name, conn->info.channels)], name, key, true);
}
resize_chanarray(&conn->info.channels);
}
}