From 38b18dbdd3fe25853680f5e5b749457ee73022a4 Mon Sep 17 00:00:00 2001 From: Alex Denes Date: Thu, 29 Oct 2020 21:33:37 +0100 Subject: [PATCH] Add new options and tweak stuff around --- CMakeLists.txt | 13 +++++++++++-- README.md | 11 ++++++----- include/functions.h | 2 ++ include/mappings.h | 2 ++ src/helpers.h | 11 +++++++++++ src/validators.h | 2 ++ 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c6a98a..90e2382 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,22 +13,31 @@ OPTION(CMAKE_BUILD_TYPE "Debug") OPTION(BUILD_TESTS "Build tests for ctest" OFF) OPTION(BUILD_IRCV3 "Build IRCv3 components" ON) OPTION(BUILD_HELPERS "Build message helpers" ON) +OPTION(BUILD_VALIDATORS "Build message validators" ON) if ( BUILD_IRCV3 ) message(STATUS "IRCv3 capabilities are going to be built.") add_compile_definitions(UIRC_IRCV3) endif() +if ( BUILD_VALIDATORS ) + message(STATUS "Message validators are going to be built.") + add_compile_definitions(UIRC_VALIDATORS) + set(build_FILES ${build_FILES} src/validators.c) +endif() + set(build_FILES src/assemblers.c src/misc.c src/tokenizers.c - src/validators.c ) if ( BUILD_HELPERS ) message(STATUS "Helper functions are going to be built.") - set(build_FILES ${build_FILES} src/helpers.c src/taghelpers.c) + set(build_FILES ${build_FILES} src/helpers.c) + if ( BUILD_IRCV3 ) + set(build_FILES ${build_FILES} src/taghelpers.c) + endif() endif() add_library(uirc SHARED ${build_FILES}) diff --git a/README.md b/README.md index 4459387..dc7bb60 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,12 @@ First, create the required build files (usually the Makefile) ```sh cmake -H . -B build/ -DCMAKE_BUILD_TYPE=Release ``` -| Option | Description | Type | Default | Supported since | -|:-------------:|:---------------------------------------------------------------------:|:--------:|:-------:|:---------------:| -| BUILD_HELPERS | Build simple assemblers and tokenizers that handle the heavy lifting | boolean | true | - | -| BUILD_TESTS | Build tests that check if the build results behave as they should | boolean | false | - | -| BUILD_IRCV3 | Build IRCv3 support (WIP) | boolean | true | - | +| Option | Description | Type | Default | Supported since | +|:------------------:|:----------------------------------------------------------------------:|:--------:|:-------:|:---------------:| +| BUILD_HELPERS | Build simple assemblers and tokenizers that handle the heavy lifting | boolean | true | - | +| BUILD_VALIDATORS | Build validators that check if the messages follow the standards (WIP) | boolean | true | 2020.10.29 | +| BUILD_TESTS | Build tests that check if the build results behave as they should | boolean | false | - | +| BUILD_IRCV3 | Build IRCv3 support (WIP) | boolean | true | - | Following that, just use your build system and compile it diff --git a/include/functions.h b/include/functions.h index ac3628e..f49cd67 100644 --- a/include/functions.h +++ b/include/functions.h @@ -36,11 +36,13 @@ extern signed long Assm_tags(char* buf, IRC_Tags* in, size_t len); #endif /* Validators: They check that the parsed message is valid and follows the standard */ +#ifdef UIRC_VALIDATORS extern signed int Val_mesg(IRC_Message* mesg); extern signed int Val_channame(char* chan); extern signed int Val_type_nocrlf(char* str); extern signed int Val_type_nospcl(char* str); extern signed int Val_type_noblcm(char* str); +#endif /* Converters: They convert from one format to another */ extern signed int Ircmd_stoi(char* str); diff --git a/include/mappings.h b/include/mappings.h index ef48545..068a6d1 100644 --- a/include/mappings.h +++ b/include/mappings.h @@ -31,6 +31,7 @@ #define MBMASK_INVIS 4 /* 100 */ /* IRCv3 Supported features bitmask */ +#ifdef UIRC_IRCV3 #define CAP_AWAY_NOTIFY 1 << 3 #define CAP_BATCH 1 << 4 #define CAP_CAP_NOTIFY 1 << 5 @@ -48,6 +49,7 @@ #define CAP_SETNAME 1 << 17 #define CAP_TLS 1 << 18 #define CAP_USERHOST_IN_NAMES 1 << 19 +#endif extern const char* const IRC_Cmds[]; diff --git a/src/helpers.h b/src/helpers.h index 513a935..cd38310 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -89,6 +89,17 @@ IRC_Message* Assm_cmd_SUMMON(char* user, char* target, char* channel); IRC_Message* Assm_cmd_USERHOST(char* users[]); IRC_Message* Assm_cmd_ISON(char* users[]); +#ifdef UIRC_IRCV3 +#define Assm_cmd_CAP_END() Assm_AUTO(CAP, false, (char*[]){NULL}, 0) +#define Assm_cmd_CAP_LIST() Assm_AUTO(CAP, false, (char*[]){NULL}, 0) + +#define Assm_cmd_CAP_LS(version) Assm_AUTO(CAP, false, (char*[]){version, NULL}, 0) +#define Assm_cmd_CAP_REQ(caps) Assm_AUTO(CAP, true, (char*[]){caps, NULL}, 1) + +#define Assm_cmd_CAP_NEW(nick, caps) Assm_AUTO(CAP, true, (char*[]){nick, caps, NULL}, 2) +#define Assm_cmd_CAP_DEL(nick, caps) Assm_AUTO(CAP, true, (char*[]){nick, caps, NULL}, 2) +#endif + void Tok_cmd_PING(IRC_Message* mesg, char** source, char** target); void Tok_FArgOpt(IRC_Message* mesg, char** optarg, char** reqarg); #endif diff --git a/src/validators.h b/src/validators.h index 9593e3b..e77920e 100644 --- a/src/validators.h +++ b/src/validators.h @@ -21,6 +21,7 @@ #include #include +#ifdef UIRC_VALIDATORS #ifndef UIRC_INCLUDED_VALIDATORS #define UIRC_INCLUDED_VALIDATORS signed int Val_mesg(IRC_Message* mesg); @@ -29,4 +30,5 @@ signed int Val_type_nospcl(char* str); signed int Val_type_noblcm(char* str); signed int Val_channame(char* chan); #endif +#endif