/* * 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 . */ #include "common.h" #include "../types.h" // IRC_Message #include // printf() #include // exit() #include // 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)); }