Bump version, fix inclustions and move tests outside of main repo
This commit is contained in:
parent
d1fa763dee
commit
bb6be1d8ec
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
project(
|
||||
uIRC
|
||||
VERSION 0.2.3
|
||||
VERSION 0.2.4
|
||||
DESCRIPTION "Simple and lightweight IRC protocol helper"
|
||||
LANGUAGES C
|
||||
)
|
||||
|
@ -13,7 +13,6 @@ add_compile_definitions(UIRC_VERSION="${UIRC_VERSION}")
|
|||
|
||||
OPTION(BUILD_IRCV3 "Build IRCv3 components" OFF)
|
||||
OPTION(BUILD_VALIDATORS "Build message validators" OFF)
|
||||
OPTION(BUILD_TESTS "Build tests for ctest" OFF)
|
||||
OPTION(BUILD_DOCS "Build documentation with doxygen" OFF)
|
||||
OPTION(CODE_ANALYZER "Analyze the code statically" OFF)
|
||||
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
|
||||
|
@ -28,14 +27,15 @@ set(UIRC_SOURCE
|
|||
)
|
||||
|
||||
set(UIRC_HEADERS
|
||||
src/uirc.h
|
||||
src/ctcp.h
|
||||
src/modes.h
|
||||
src/replies.h
|
||||
src/types.h
|
||||
src/assemblers/assemblers.h
|
||||
src/tokenizers/tokenizers.h
|
||||
src/memory/memory.h
|
||||
include/assemblers.h
|
||||
include/ctcp.h
|
||||
include/memory.h
|
||||
include/modes.h
|
||||
include/replies.h
|
||||
include/tokenizers.h
|
||||
include/types.h
|
||||
include/uirc.h
|
||||
include/validators.h
|
||||
)
|
||||
|
||||
# Libraries used
|
||||
|
@ -67,26 +67,6 @@ if (BUILD_VALIDATORS)
|
|||
src/validators/validators.h
|
||||
)
|
||||
endif()
|
||||
if (BUILD_TESTS)
|
||||
message(STATUS "Tests are going to be built.")
|
||||
enable_testing()
|
||||
|
||||
macro(buildtest categ name)
|
||||
add_executable("uirc-test-${categ}-${name}" "src/tests/${categ}/${name}.c" src/tests/common.c)
|
||||
target_link_libraries("uirc-test-${categ}-${name}" uirc)
|
||||
add_test(NAME "${categ}/${name}" COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uirc-test-${categ}-${name}")
|
||||
endmacro()
|
||||
|
||||
buildtest(tokenizers tag)
|
||||
buildtest(tokenizers user)
|
||||
buildtest(tokenizers message)
|
||||
|
||||
buildtest(assemblers tag)
|
||||
buildtest(assemblers user)
|
||||
buildtest(assemblers message)
|
||||
|
||||
buildtest(general fullloop)
|
||||
endif()
|
||||
if(BUILD_DOCS)
|
||||
find_package(Doxygen REQUIRED)
|
||||
if (DOXYGEN_FOUND)
|
||||
|
@ -108,6 +88,10 @@ endif()
|
|||
|
||||
add_library(uirc ${UIRC_SOURCE})
|
||||
target_link_libraries(uirc ${UIRC_LIBS})
|
||||
target_include_directories(uirc PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include/uirc>
|
||||
)
|
||||
|
||||
separate_arguments(UIRC_HEADERS)
|
||||
set_target_properties(uirc PROPERTIES
|
||||
|
|
|
@ -18,10 +18,9 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include "../types.h" // IRC_User IRC_Message
|
||||
#include "types.h" // IRC_User IRC_Message
|
||||
|
||||
#include <corelibs/llist.h> // llist_t
|
||||
#include <stdbool.h> // bool
|
||||
#include <sys/types.h> // ssize_t ssize_t
|
||||
|
||||
#ifndef UIRC_GUARD_PUBLIC_ASSEMBLERS
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
/*! \file */
|
||||
|
||||
#ifndef UIRC_GUARD_PUBLIC_CTCP
|
||||
#define UIRC_GUARD_PUBLIC_CTCP
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include "../types.h" // IRC_Tag IRC_User IRC_Meesage
|
||||
#include "types.h" // IRC_Tag IRC_User IRC_Message
|
||||
|
||||
#ifndef UIRC_GUARD_PUBLIC_MEMORY
|
||||
#define UIRC_GUARD_PUBLIC_MEMORY
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include "../types.h" // IRC_User
|
||||
#include "types.h" // IRC_User
|
||||
|
||||
#include <corelibs/llist.h> // llist_t
|
||||
#include <stdbool.h> // bool
|
|
@ -17,13 +17,10 @@
|
|||
*/
|
||||
|
||||
#include "assemblers.h"
|
||||
#include "errors.h"
|
||||
#include "ctcp.h"
|
||||
#include "memory.h"
|
||||
#include "modes.h"
|
||||
#include "replies.h"
|
||||
#include "tokenizers.h"
|
||||
#include "types.h"
|
||||
|
||||
#ifdef UIRC_FEATURE_VALIDATORS
|
||||
#include "validators.h"
|
||||
#endif /* UIRC_FEATURE_VALIDATORS */
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include "../types.h" // IRC_Message
|
||||
#include "types.h" // IRC_Message
|
||||
|
||||
#include <sys/types.h>
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../types.h" // IRC_Message IRC_Tag IRC_User
|
||||
#include "assemblers.h" // uirc_assembler_*
|
||||
#include "types.h" // IRC_Message IRC_Tag IRC_User
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <stdio.h> // NULL, snprintf()
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../types.h" // IRC_Tag
|
||||
#include "assemblers.h" // uirc_assembler_tag_*
|
||||
#include "types.h" // IRC_Tag
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <corelibs/llist.h> // llist_t
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../types.h" // IRC_User
|
||||
#include "assemblers.h" // Assm_user()
|
||||
#include "types.h" // IRC_User
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <stdbool.h> // bool
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../types.h" // IRC_*
|
||||
#include "memory.h"
|
||||
#include "types.h" // IRC_*
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <corelibs/llist.h> // llist_t remove_linked_list_elem()
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../types.h" // IRC_*
|
||||
#include "memory.h"
|
||||
#include "types.h" // IRC_*
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <corelibs/llist.h> // llist_t remove_linked_list_elem()
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||
* Copyright (c) 2019, 2020 Alex-David Denes
|
||||
*
|
||||
* uIRC is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* uIRC 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../assemblers/assemblers.h" // Assm_mesg()
|
||||
#include "../../types.h" // IRC_*
|
||||
#include "../common.h" // expect()
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <stdbool.h> // bool
|
||||
#include <stdlib.h> // EXIT_SUCCESS
|
||||
|
||||
#define KEY1 "msgid"
|
||||
#define VAL1 "lol"
|
||||
#define KEY2 "wow"
|
||||
#define NICK "bazinga"
|
||||
#define HOST "monke.uk"
|
||||
#define COMMAND "NOTICE"
|
||||
#define ARG1 "urmomgay"
|
||||
#define TRAILING "what's up retard"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
IRC_Message m[] = {
|
||||
{ .command = COMMAND, .args = { ARG1, TRAILING, NULL }, .trailing = true },
|
||||
{ .tag_list = &(llist_t) { .content = &(IRC_Tag) { .key = KEY1, .value = VAL1, .clientbound = true },
|
||||
.next = &(llist_t) { .content = &(IRC_Tag) { .key = KEY2 } } },
|
||||
.source = &(IRC_User) { .nick = NICK, .host = HOST },
|
||||
.command = COMMAND,
|
||||
.args = { ARG1, TRAILING, NULL },
|
||||
.trailing = true },
|
||||
};
|
||||
const char* str[] = { COMMAND " " ARG1 " :" TRAILING, "@+" KEY1 "=" VAL1 ";" KEY2 " :" NICK "@" HOST " " COMMAND " " ARG1 " :" TRAILING };
|
||||
|
||||
char buf[513];
|
||||
signed long ret;
|
||||
for (unsigned long i = 0; i < sizeof(str) / sizeof(*str); i++) {
|
||||
if ((ret = uirc_assembler_message(buf, &m[i], sizeof(buf) / sizeof(char))) < 0) {
|
||||
printf("Failed to convert IRC_Message struct to a string. %li\n", ret);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
size_t len = strlen(str[i]);
|
||||
if ((size_t) ret != len) {
|
||||
printf("String lenght doesn't match with amount of bytes printed. Expected %li but got %li\n", len, ret);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
expect(buf, str[i]);
|
||||
print_irc_message(&m[i]);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||
* Copyright (c) 2019, 2020 Alex-David Denes
|
||||
*
|
||||
* uIRC is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* uIRC 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../assemblers/assemblers.h" // Assm_mesg()
|
||||
#include "../common.h" // expect()
|
||||
|
||||
#include <stdlib.h> // EXIT_SUCCESS EXIT_FAILURE
|
||||
|
||||
#define key1 "msgid"
|
||||
#define val1 "30"
|
||||
#define key2 "time"
|
||||
#define key3 "x"
|
||||
#define val3 "spx"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
const char* str[] = { "+" key1 "=" val1, key2, key3 "=" val3 };
|
||||
const IRC_Tag tag[] = { { .key = key1, .value = val1, .clientbound = true }, { .key = key2 }, { .key = key3, .value = val3 } };
|
||||
char buf[513];
|
||||
signed long ret;
|
||||
for (unsigned long i = 0; i < sizeof(str) / sizeof(*str); i++) {
|
||||
if ((ret = uirc_assembler_tag(buf, &tag[i], sizeof(buf) / sizeof(char))) < 0) {
|
||||
printf("Failed to convert tag %lu to \"%s\". Error %li\n", i, str[i], ret);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
size_t len = strlen(str[i]);
|
||||
if ((size_t) ret != len) {
|
||||
printf("String lenght doesn't match with amount of bytes printed. Expected %li but got %li\n", len, ret);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
expect(buf, str[i]);
|
||||
print_irc_tag(&tag[i]);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||
* Copyright (c) 2019, 2020 Alex-David Denes
|
||||
*
|
||||
* uIRC is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* uIRC 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../assemblers/assemblers.h" // Assm_user()
|
||||
#include "../common.h" // expect()
|
||||
|
||||
#include <stdlib.h> // EXIT_SUCCESS EXIT_FAILURE
|
||||
|
||||
#define NICK "bruh"
|
||||
#define USER "sound"
|
||||
#define HOST "numero.dos"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
const char* str[] = { NICK "!" USER "@" HOST, HOST };
|
||||
IRC_User u[] = { { .nick = NICK, .user = USER, .host = HOST }, { .host = HOST } };
|
||||
char buf[513];
|
||||
signed long ret;
|
||||
for (unsigned long i = 0; i < sizeof(str) / sizeof(*str); i++) {
|
||||
if ((ret = uirc_assembler_user(buf, &u[i], sizeof(buf) / sizeof(char))) <= 0) {
|
||||
printf("Failed to convert IRC_User struct to a string. %li\n", ret);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
size_t len = strlen(str[i]);
|
||||
if ((size_t) ret != len) {
|
||||
printf("String lenght doesn't match with amount of bytes printed. Expected %li but got %li\n", len, ret);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
expect(buf, str[i]);
|
||||
print_irc_user(&u[i]);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||
* Copyright (c) 2019, 2020 Alex-David Denes
|
||||
*
|
||||
* uIRC is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* uIRC 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "../types.h" // IRC_Message
|
||||
|
||||
#include <stdio.h> // printf()
|
||||
#include <stdlib.h> // exit()
|
||||
#include <string.h> // strcmp()
|
||||
|
||||
#define DELIMITER "-------------\n"
|
||||
#define PRINTVARORNULL(VAR) ((VAR != NULL) ? VAR : "NULL")
|
||||
|
||||
void
|
||||
expect(const char* var, const char* exp)
|
||||
{
|
||||
if (strcmp(var, exp) != 0) {
|
||||
printf("Expected \"%s\" but got \"%s\" instead.\n", exp, var);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
print_irc_message(const IRC_Message* ptr)
|
||||
{
|
||||
#ifdef UIRC_FEATURE_IRCV3
|
||||
printf(DELIMITER);
|
||||
|
||||
llist_t* tmp = ptr->tag_list;
|
||||
for (; tmp != NULL; tmp = tmp->next) { print_irc_tag((IRC_Tag*) tmp->content); }
|
||||
#endif /* UIRC_FEATURE_IRCV3 */
|
||||
|
||||
if (ptr->source != NULL) { print_irc_user(ptr->source); }
|
||||
|
||||
if (ptr->command != NULL) printf("mc: %s\n", ptr->command);
|
||||
|
||||
for (short i = 0; i < IRC_MAXARGS && ptr->args[i] != NULL; i++) { printf("marg[%i]: %s\n", i, ptr->args[i]); }
|
||||
|
||||
printf(DELIMITER);
|
||||
}
|
||||
|
||||
#ifdef UIRC_FEATURE_IRCV3
|
||||
void
|
||||
print_irc_tag(const IRC_Tag* tag)
|
||||
{
|
||||
printf(DELIMITER "tn: %s\n"
|
||||
"tv: %s\n"
|
||||
"tc: %i\n" DELIMITER,
|
||||
PRINTVARORNULL(tag->key),
|
||||
PRINTVARORNULL(tag->value),
|
||||
tag->clientbound);
|
||||
}
|
||||
#endif /* UIRC_FEATURE_IRCV3 */
|
||||
|
||||
void
|
||||
print_irc_user(const IRC_User* user)
|
||||
{
|
||||
printf(DELIMITER "un: %s\n"
|
||||
"uu: %s\n"
|
||||
"ur: %s\n"
|
||||
"uh: %s\n" DELIMITER,
|
||||
PRINTVARORNULL(user->nick),
|
||||
PRINTVARORNULL(user->user),
|
||||
PRINTVARORNULL(user->real),
|
||||
PRINTVARORNULL(user->host));
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||
* Copyright (c) 2019, 2020 Alex-David Denes
|
||||
*
|
||||
* uIRC is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* uIRC 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../types.h" // IRC_*
|
||||
|
||||
#include <stdio.h> // printf()
|
||||
#include <stdlib.h> // exit()
|
||||
#include <string.h> // strcmp()
|
||||
|
||||
#ifndef UIRC_GUARD_PRIVATE_COMMONTESTS
|
||||
#define UIRC_GUARD_PRIVATE_COMMONTESTS
|
||||
|
||||
#define ERRIFNULL(VAR, ...) \
|
||||
if (VAR == NULL) printf(__VA_ARGS__)
|
||||
|
||||
void expect(const char* var, const char* exp);
|
||||
|
||||
void print_irc_message(const IRC_Message* ptr);
|
||||
#ifdef UIRC_FEATURE_IRCV3
|
||||
void print_irc_tag(const IRC_Tag* tag);
|
||||
#endif /* UIRC_FEATURE_IRCV3 */
|
||||
void print_irc_user(const IRC_User* user);
|
||||
|
||||
#endif /* UIRC_GUARD_PRIVATE_COMMONTESTS */
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||
* Copyright (c) 2019, 2020 Alex-David Denes
|
||||
*
|
||||
* uIRC is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* uIRC 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../assemblers/assemblers.h" // Assm_mesg()
|
||||
#include "../../tokenizers/tokenizers.h" // Tok_mesg()
|
||||
#include "../../types.h" // IRC_User
|
||||
#include "../common.h" // expect()
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <stdlib.h> // EXIT_SUCCESS
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
const char* str[] = { ":buddy@hostnet.com PRIVMSG #general :login hunter12",
|
||||
"NOTICE * :nice cock bro",
|
||||
"@day=13;willtolive=0 PRIVMSG you :helo",
|
||||
":mom!mother@localhost NOTICE #netadmin :johnny, your pizza is done" };
|
||||
|
||||
for (unsigned long i = 0; i < sizeof(str) / sizeof(*str); i++) {
|
||||
IRC_Message* m = NULL;
|
||||
if ((m = uirc_tokenizer_message(str[i])) == NULL) {
|
||||
printf("Failed to convert string to IRC_Message struct.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ssize_t ret;
|
||||
char buf[513];
|
||||
if ((ret = uirc_assembler_message(buf, m, sizeof(buf) / sizeof(char))) <= 0) {
|
||||
printf("Failed to convert IRC_Message struct to a string. (%li)\n", ret);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
size_t s1 = strlen(str[i]), s2 = strlen(buf);
|
||||
if (s1 != s2) {
|
||||
printf("String lenght doesn't match after parsing and assembly. Expected %li but got %li\n", s1, s2);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
expect(buf, str[i]);
|
||||
print_irc_message(m);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||
* Copyright (c) 2019, 2020 Alex-David Denes
|
||||
*
|
||||
* uIRC is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* uIRC 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../tokenizers/tokenizers.h" // Tok_user()
|
||||
#include "../../types.h" // IRC_User
|
||||
#include "../common.h" // expect()
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <stdlib.h> // EXIT_SUCCESS
|
||||
|
||||
#define COMMAND "NOTICE"
|
||||
#define ARG1 "urmomgay"
|
||||
#define TRAILING "what's up retard"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
IRC_Message* m = uirc_tokenizer_message(COMMAND " " ARG1 " :" TRAILING);
|
||||
ERRIFNULL(m, "Message wasn't tokenized successfully.\n");
|
||||
expect(m->command, COMMAND);
|
||||
expect(m->args[0], ARG1);
|
||||
expect(m->args[1], TRAILING);
|
||||
if (!m->trailing) {
|
||||
printf("Message wasn't trailing when it should've been.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
print_irc_message(m);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||
* Copyright (c) 2019, 2020 Alex-David Denes
|
||||
*
|
||||
* uIRC is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* uIRC 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../tokenizers/tokenizers.h" // uirc_tokenizer_*()
|
||||
#include "../common.h" // expect()
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <corelibs/llist.h> // llist_t
|
||||
#include <stdlib.h> // EXIT_SUCCESS
|
||||
|
||||
#define key1 "msgid"
|
||||
#define val1 "30"
|
||||
#define key2 "time"
|
||||
#define key3 "x"
|
||||
#define val3 "spx"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
IRC_Tag* cur = NULL;
|
||||
llist_t* tags = uirc_tokenizer_tag_list("+" key1 "=" val1 ";" key2 ";" key3 "=" val3);
|
||||
ERRIFNULL(tags, "Tags weren't tokenized successfully.\n");
|
||||
|
||||
cur = tags->content;
|
||||
expect(cur->key, key1);
|
||||
expect(cur->value, val1);
|
||||
if (!cur->clientbound) {
|
||||
printf("Tag #1 wasn't clientbound.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
print_irc_tag(cur);
|
||||
|
||||
cur = (tags = tags->next)->content;
|
||||
expect(cur->key, key2);
|
||||
if (cur->clientbound) {
|
||||
printf("Tag #2 was clientbound.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
print_irc_tag(cur);
|
||||
|
||||
cur = (tags = tags->next)->content;
|
||||
expect(cur->key, key3);
|
||||
expect(cur->value, val3);
|
||||
print_irc_tag(cur);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||
* Copyright (c) 2019, 2020 Alex-David Denes
|
||||
*
|
||||
* uIRC is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* uIRC 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../tokenizers/tokenizers.h" // Tok_user()
|
||||
#include "../../types.h" // IRC_User
|
||||
#include "../common.h" // expect()
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <stdlib.h> // EXIT_SUCCESS
|
||||
|
||||
#define NICK "minion"
|
||||
#define USER "banana"
|
||||
#define HOST "freebanana.com"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
IRC_User* user = uirc_tokenizer_user(NICK "!" USER "@" HOST);
|
||||
ERRIFNULL(user, "User wasn't successfully tokenized.\n");
|
||||
expect(user->nick, NICK);
|
||||
expect(user->user, USER);
|
||||
expect(user->host, HOST);
|
||||
print_irc_user(user);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -16,9 +16,9 @@
|
|||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../memory/memory.h" // uirc_memory_*()
|
||||
#include "../types.h" // IRC_Message
|
||||
#include "tokenizers.h" // uirc_tokenizer_*()
|
||||
#include "memory.h" // uirc_memory_*()
|
||||
#include "tokenizers.h" // uirc_tokenizer_*()
|
||||
#include "types.h" // IRC_Message
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <corelibs/stringext.h> // malloc_string() strtok_mr()
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../memory/memory.h" // Free_IRC_Tag()
|
||||
#include "../types.h" // IRC_Tag
|
||||
#include "tokenizers.h" // uirc_tokenizer_tags()
|
||||
#include "memory.h" // Free_IRC_Tag()
|
||||
#include "tokenizers.h" // uirc_tokenizer_tags()
|
||||
#include "types.h" // IRC_Tag
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <corelibs/llist.h> // allocate_linked_list_elem() connect_linked_list_elem() remove_linked_list_elem()
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../memory/memory.h" // uirc_memory_*()
|
||||
#include "../types.h" // IRC_Message
|
||||
#include "tokenizers.h" // uirc_tokenizer_*()
|
||||
#include "memory.h" // uirc_memory_*()
|
||||
#include "tokenizers.h" // uirc_tokenizer_*()
|
||||
#include "types.h" // IRC_Message
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <corelibs/stringext.h> // malloc_string()
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
#include "validators.h"
|
||||
|
||||
#include "../errors.h" // ERR_UIRC_*
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <stdio.h> // NULL
|
||||
#include <string.h> // strchr()
|
||||
|
|
Reference in New Issue