Lookup tables and organizing
- Add predefined strings by IRCv3 standards, RFC2812 and CTCP - Rename most things to singular version - Add lookup functions and converters - Remove assert for non-pointer value - Fix two tests on standard build - Update clang tidy checks
This commit is contained in:
parent
29f47560fe
commit
d55cc68e37
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
Checks: 'bugprone-*,performance-*,portability-*,readability-*,-readability-braces-around-statements,-readability-isolate-declaration,-readability-else-after-return,-readability-braces-around-statements,misc-*,modernize-*,clang-analyzer-core.*,clang-analyzer-security.*,clang-analyzer-unix.*,clang-analyzer-optin.portability.UnixAPI,clang-analyzer-optin.performance.Padding'
|
Checks: 'performance-*,portability-*,readability-*,bugprone-*,concurrency-*,llvm-*,clang-analyzer-core.*,clang-analyzer-nullability.*,clang-analyzer-optin.portability.UnixAPI,clang-analyzer-security.*,clang-analyzer-unix.*,clang-analyzer-valist.*,clang-analyzer-apiModeling.*,cert-*-c,-readability-isolate-declaration,-readability-braces-around-statements,-readability-magic-numbers'
|
||||||
WarningsAsErrors: ''
|
WarningsAsErrors: ''
|
||||||
HeaderFilterRegex: ''
|
HeaderFilterRegex: ''
|
||||||
AnalyzeTemporaryDtors: false
|
AnalyzeTemporaryDtors: false
|
||||||
|
|
|
@ -19,29 +19,31 @@ OPTION(CODE_ANALYZER "Analyze the code statically" OFF)
|
||||||
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
|
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
|
||||||
|
|
||||||
set(UIRC_SOURCE
|
set(UIRC_SOURCE
|
||||||
src/assemblers/message.c
|
src/assembler/message.c
|
||||||
src/assemblers/user.c
|
src/assembler/user.c
|
||||||
|
src/command/command.c
|
||||||
|
src/command/reply.c
|
||||||
src/error/error.c
|
src/error/error.c
|
||||||
src/modes/modes.c
|
|
||||||
src/memory/list.c
|
src/memory/list.c
|
||||||
src/memory/struct.c
|
src/memory/struct.c
|
||||||
src/tokenizers/message.c
|
src/mode/mode.c
|
||||||
src/tokenizers/user.c
|
src/tokenizer/message.c
|
||||||
|
src/tokenizer/user.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(UIRC_HEADERS
|
set(UIRC_HEADERS
|
||||||
include/assemblers.h
|
include/assembler.h
|
||||||
include/commands.h
|
include/command.h
|
||||||
include/ctcp.h
|
include/ctcp.h
|
||||||
include/errors.h
|
include/error.h
|
||||||
include/memory.h
|
include/memory.h
|
||||||
include/misc.h
|
include/misc.h
|
||||||
include/modes.h
|
include/mode.h
|
||||||
include/replies.h
|
include/tag.h
|
||||||
include/tokenizers.h
|
include/tokenizer.h
|
||||||
include/types.h
|
include/type.h
|
||||||
include/uirc.h
|
include/uirc.h
|
||||||
include/validators.h
|
include/validator.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# Libraries used
|
# Libraries used
|
||||||
|
@ -57,8 +59,9 @@ if (BUILD_IRCV3)
|
||||||
add_compile_definitions(UIRC_FEATURE_IRCV3)
|
add_compile_definitions(UIRC_FEATURE_IRCV3)
|
||||||
set(UIRC_SOURCE
|
set(UIRC_SOURCE
|
||||||
${UIRC_SOURCE}
|
${UIRC_SOURCE}
|
||||||
src/assemblers/tag.c
|
src/assembler/tag.c
|
||||||
src/tokenizers/tag.c
|
src/tokenizer/tag.c
|
||||||
|
src/tag/tag.c
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if (BUILD_VALIDATORS)
|
if (BUILD_VALIDATORS)
|
||||||
|
@ -66,11 +69,15 @@ if (BUILD_VALIDATORS)
|
||||||
add_compile_definitions(UIRC_FEATURE_VALIDATORS)
|
add_compile_definitions(UIRC_FEATURE_VALIDATORS)
|
||||||
set(UIRC_SOURCE
|
set(UIRC_SOURCE
|
||||||
${UIRC_SOURCE}
|
${UIRC_SOURCE}
|
||||||
src/validators/validators.c
|
src/validator/validator.c
|
||||||
)
|
)
|
||||||
set(UIRC_HEADERS
|
endif()
|
||||||
${UIRC_HEADERS}
|
if (BUILD_CTCP)
|
||||||
src/validators/validators.h
|
message(STATUS "CTCP support will be built")
|
||||||
|
add_compile_definitions(UIRC_FEATURE_CTCP)
|
||||||
|
set(UIRC_SOURCE
|
||||||
|
${UIRC_SOURCE}
|
||||||
|
src/ctcp/ctcp.c
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_DOCS)
|
if(BUILD_DOCS)
|
||||||
|
@ -93,15 +100,15 @@ if(BUILD_DOCS)
|
||||||
endif()
|
endif()
|
||||||
if (BUILD_TESTS)
|
if (BUILD_TESTS)
|
||||||
message(STATUS "Tests are going to be built.")
|
message(STATUS "Tests are going to be built.")
|
||||||
add_subdirectory(src/tests)
|
add_subdirectory(src/test)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_test(NAME "FullLoop" COMMAND "fullloop")
|
add_test(NAME "FullLoop" COMMAND "fullloop" )
|
||||||
add_test(NAME "EarlyTrail" COMMAND "earlytrail")
|
add_test(NAME "EarlyTrail" COMMAND "earlytrail")
|
||||||
add_test(NAME "OptCRLF" COMMAND "optcrlf")
|
add_test(NAME "OptCRLF" COMMAND "optcrlf" )
|
||||||
add_test(NAME "Allocators" COMMAND "allocs")
|
add_test(NAME "Allocators" COMMAND "allocs" )
|
||||||
add_test(NAME "ManualAssemblers" COMMAND "manassm")
|
add_test(NAME "ManualAssemblers" COMMAND "manassm" )
|
||||||
add_test(NAME "ErrorNumbers" COMMAND "errno")
|
add_test(NAME "ErrorNumbers" COMMAND "errno" )
|
||||||
add_test(NAME "ModeBitmasks" COMMAND "modes")
|
add_test(NAME "Modes" COMMAND "modes" )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(uirc ${UIRC_SOURCE})
|
add_library(uirc ${UIRC_SOURCE})
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
/*! \file */
|
/*! \file */
|
||||||
|
|
||||||
#include "types.h" // IRC_User IRC_Message
|
#include "type.h" // IRC_User IRC_Message
|
||||||
|
|
||||||
#include <corelibs/llist.h> // llist_t
|
#include <corelibs/llist.h> // llist_t
|
||||||
#include <sys/types.h> // ssize_t ssize_t
|
#include <sys/types.h> // ssize_t ssize_t
|
|
@ -0,0 +1,229 @@
|
||||||
|
/*
|
||||||
|
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||||
|
* Copyright (c) 2019-2021 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file */
|
||||||
|
|
||||||
|
#include <stdint.h> // uint_least16_t
|
||||||
|
|
||||||
|
#ifndef UIRC_GUARD_PUBLIC_COMMANDS
|
||||||
|
#define UIRC_GUARD_PUBLIC_COMMANDS
|
||||||
|
|
||||||
|
enum uirc_table_command {
|
||||||
|
IRC_CMD_PASS,
|
||||||
|
IRC_CMD_NICK,
|
||||||
|
IRC_CMD_USER,
|
||||||
|
IRC_CMD_OPER,
|
||||||
|
IRC_CMD_MODE,
|
||||||
|
IRC_CMD_SERVICE,
|
||||||
|
IRC_CMD_QUIT,
|
||||||
|
IRC_CMD_SQUIT,
|
||||||
|
IRC_CMD_JOIN,
|
||||||
|
IRC_CMD_PART,
|
||||||
|
IRC_CMD_TOPIC,
|
||||||
|
IRC_CMD_NAMES,
|
||||||
|
IRC_CMD_LIST,
|
||||||
|
IRC_CMD_INVITE,
|
||||||
|
IRC_CMD_KICK,
|
||||||
|
IRC_CMD_PRIVMSG,
|
||||||
|
IRC_CMD_NOTICE,
|
||||||
|
IRC_CMD_MOTD,
|
||||||
|
IRC_CMD_LUSERS,
|
||||||
|
IRC_CMD_VERSION,
|
||||||
|
IRC_CMD_STATS,
|
||||||
|
IRC_CMD_LINKS,
|
||||||
|
IRC_CMD_TIME,
|
||||||
|
IRC_CMD_CONNECT,
|
||||||
|
IRC_CMD_TRACE,
|
||||||
|
IRC_CMD_ADMIN,
|
||||||
|
IRC_CMD_INFO,
|
||||||
|
IRC_CMD_SERVLIST,
|
||||||
|
IRC_CMD_SQUERY,
|
||||||
|
IRC_CMD_WHO,
|
||||||
|
IRC_CMD_WHOIS,
|
||||||
|
IRC_CMD_WHOWAS,
|
||||||
|
IRC_CMD_KILL,
|
||||||
|
IRC_CMD_PING,
|
||||||
|
IRC_CMD_PONG,
|
||||||
|
IRC_CMD_ERROR,
|
||||||
|
IRC_CMD_AWAY,
|
||||||
|
IRC_CMD_REHASH,
|
||||||
|
IRC_CMD_DIE,
|
||||||
|
IRC_CMD_RESTART,
|
||||||
|
IRC_CMD_SUMMON,
|
||||||
|
IRC_CMD_USERS,
|
||||||
|
IRC_CMD_WALLOPS,
|
||||||
|
IRC_CMD_USERHOST,
|
||||||
|
IRC_CMD_ISON,
|
||||||
|
};
|
||||||
|
const char* IRC_CMD(enum uirc_table_command cmd);
|
||||||
|
|
||||||
|
enum uirc_table_replies {
|
||||||
|
IRC_RPL_WELCOME,
|
||||||
|
IRC_RPL_YOURHOST,
|
||||||
|
IRC_RPL_CREATED,
|
||||||
|
IRC_RPL_MYINFO,
|
||||||
|
IRC_RPL_BOUNCE,
|
||||||
|
|
||||||
|
#ifdef UIRC_FEATURE_IRCV3
|
||||||
|
IRC_RPL_ISUPPORT,
|
||||||
|
#endif /* UIRC_FEATURE_IRCV3 */
|
||||||
|
|
||||||
|
IRC_RPL_TRACELINK,
|
||||||
|
IRC_RPL_TRACECONNECTING,
|
||||||
|
IRC_RPL_TRACEHANDSHAKE,
|
||||||
|
IRC_RPL_TRACEUNKNOWN,
|
||||||
|
IRC_RPL_TRACEOPERATOR,
|
||||||
|
IRC_RPL_TRACEUSER,
|
||||||
|
IRC_RPL_TRACESERVER,
|
||||||
|
IRC_RPL_TRACENEWTYPE,
|
||||||
|
IRC_RPL_STATSLINKINFO,
|
||||||
|
IRC_RPL_STATSCOMMANDS,
|
||||||
|
IRC_RPL_STATSCLINE,
|
||||||
|
IRC_RPL_STATSNLINE,
|
||||||
|
IRC_RPL_STATSILINE,
|
||||||
|
IRC_RPL_STATSKLINE,
|
||||||
|
IRC_RPL_STATSYLINE,
|
||||||
|
IRC_RPL_ENDOFSTATS,
|
||||||
|
IRC_RPL_UMODEIS,
|
||||||
|
IRC_RPL_STATSLLINE,
|
||||||
|
IRC_RPL_STATSUPTIME,
|
||||||
|
IRC_RPL_STATSOLINE,
|
||||||
|
IRC_RPL_STATSHLINE,
|
||||||
|
IRC_RPL_LUSERCLIENT,
|
||||||
|
IRC_RPL_LUSEROP,
|
||||||
|
IRC_RPL_LUSERUNKNOWN,
|
||||||
|
IRC_RPL_LUSERCHANNELS,
|
||||||
|
IRC_RPL_LUSERME,
|
||||||
|
IRC_RPL_ADMINME,
|
||||||
|
IRC_RPL_ADMINLOC1,
|
||||||
|
IRC_RPL_ADMINLOC2,
|
||||||
|
IRC_RPL_ADMINEMAIL,
|
||||||
|
IRC_RPL_TRACELOG,
|
||||||
|
IRC_RPL_NONE,
|
||||||
|
IRC_RPL_AWAY,
|
||||||
|
IRC_RPL_USERHOST,
|
||||||
|
IRC_RPL_ISON,
|
||||||
|
IRC_RPL_UNAWAY,
|
||||||
|
IRC_RPL_NOWAWAY,
|
||||||
|
IRC_RPL_WHOISUSER,
|
||||||
|
IRC_RPL_WHOISSERVER,
|
||||||
|
IRC_RPL_WHOISOPERATOR,
|
||||||
|
IRC_RPL_WHOWASUSER,
|
||||||
|
IRC_RPL_ENDOFWHO,
|
||||||
|
IRC_RPL_WHOISIDLE,
|
||||||
|
IRC_RPL_ENDOFWHOIS,
|
||||||
|
IRC_RPL_WHOISCHANNELS,
|
||||||
|
IRC_RPL_LISTSTART,
|
||||||
|
IRC_RPL_LIST,
|
||||||
|
IRC_RPL_LISTEND,
|
||||||
|
IRC_RPL_CHANNELMODEIS,
|
||||||
|
IRC_RPL_NOTOPIC,
|
||||||
|
IRC_RPL_TOPIC,
|
||||||
|
IRC_RPL_INVITING,
|
||||||
|
IRC_RPL_SUMMONING,
|
||||||
|
IRC_RPL_VERSION,
|
||||||
|
IRC_RPL_WHOREPLY,
|
||||||
|
IRC_RPL_NAMREPLY,
|
||||||
|
IRC_RPL_LINKS,
|
||||||
|
IRC_RPL_ENDOFLINKS,
|
||||||
|
IRC_RPL_ENDOFNAMES,
|
||||||
|
IRC_RPL_BANLIST,
|
||||||
|
IRC_RPL_ENDOFBANLIST,
|
||||||
|
IRC_RPL_ENDOFWHOWAS,
|
||||||
|
IRC_RPL_INFO,
|
||||||
|
IRC_RPL_MOTD,
|
||||||
|
IRC_RPL_ENDOFINFO,
|
||||||
|
IRC_RPL_MOTDSTART,
|
||||||
|
IRC_RPL_ENDOFMOTD,
|
||||||
|
IRC_RPL_YOUREOPER,
|
||||||
|
IRC_RPL_REHASHING,
|
||||||
|
IRC_RPL_TIME,
|
||||||
|
IRC_RPL_USERSSTART,
|
||||||
|
IRC_RPL_USERS,
|
||||||
|
IRC_RPL_ENDOFUSERS,
|
||||||
|
IRC_RPL_NOUSERS,
|
||||||
|
|
||||||
|
IRC_ERR_NOSUCHNICK,
|
||||||
|
IRC_ERR_NOSUCHSERVER,
|
||||||
|
IRC_ERR_NOSUCHCHANNEL,
|
||||||
|
IRC_ERR_CANNOTSENDTOCHAN,
|
||||||
|
IRC_ERR_TOOMANYCHANNELS,
|
||||||
|
IRC_ERR_WASNOSUCHNICK,
|
||||||
|
IRC_ERR_TOOMANYTARGETS,
|
||||||
|
IRC_ERR_NOORIGIN,
|
||||||
|
IRC_ERR_NORECIPIENT,
|
||||||
|
IRC_ERR_NOTEXTTOSEND,
|
||||||
|
IRC_ERR_NOTOPLEVEL,
|
||||||
|
IRC_ERR_WILDTOPLEVEL,
|
||||||
|
IRC_ERR_UNKNOWNCOMMAND,
|
||||||
|
IRC_ERR_NOMOTD,
|
||||||
|
IRC_ERR_NOADMININFO,
|
||||||
|
IRC_ERR_FILEIRC_ERROR,
|
||||||
|
IRC_ERR_NONICKNAMEGIVEN,
|
||||||
|
IRC_ERR_IRC_ERRONEUSNICKNAME,
|
||||||
|
IRC_ERR_NICKNAMEINUSE,
|
||||||
|
IRC_ERR_NICKCOLLISION,
|
||||||
|
IRC_ERR_USERNOTINCHANNEL,
|
||||||
|
IRC_ERR_NOTONCHANNEL,
|
||||||
|
IRC_ERR_USERONCHANNEL,
|
||||||
|
IRC_ERR_NOLOGIN,
|
||||||
|
IRC_ERR_SUMMONDISABLED,
|
||||||
|
IRC_ERR_USERSDISABLED,
|
||||||
|
IRC_ERR_NOTREGISTERED,
|
||||||
|
IRC_ERR_NEEDMOREPARAMS,
|
||||||
|
IRC_ERR_ALREADYREGISTRED,
|
||||||
|
IRC_ERR_NOPERMFORHOST,
|
||||||
|
IRC_ERR_PASSWDMISMATCH,
|
||||||
|
IRC_ERR_YOUREBANNEDCREEP,
|
||||||
|
IRC_ERR_KEYSET,
|
||||||
|
IRC_ERR_CHANNELISFULL,
|
||||||
|
IRC_ERR_UNKNOWNMODE,
|
||||||
|
IRC_ERR_INVITEONLYCHAN,
|
||||||
|
IRC_ERR_BANNEDFROMCHAN,
|
||||||
|
IRC_ERR_BADCHANNELKEY,
|
||||||
|
IRC_ERR_NOPRIVILEGES,
|
||||||
|
IRC_ERR_CHANOPRIVSNEEDED,
|
||||||
|
IRC_ERR_CANTKILLSERVER,
|
||||||
|
IRC_ERR_NOOPERHOST,
|
||||||
|
IRC_ERR_UMODEUNKNOWNFLAG,
|
||||||
|
IRC_ERR_USERSDONTMATCH,
|
||||||
|
|
||||||
|
#ifdef UIRC_FEATURE_IRCV3
|
||||||
|
IRC_RPL_STARTTLS,
|
||||||
|
IRC_ERR_STARTTLS,
|
||||||
|
IRC_RPL_MONONLINE,
|
||||||
|
IRC_RPL_MONOFFLINE,
|
||||||
|
IRC_RPL_MONLIST,
|
||||||
|
IRC_RPL_ENDOFMONLIST,
|
||||||
|
IRC_ERR_MOLISTFULL,
|
||||||
|
IRC_RPL_LOGGEDIN,
|
||||||
|
IRC_RPL_LOGGEDOUT,
|
||||||
|
IRC_ERR_NICKLOCKED,
|
||||||
|
IRC_RPL_SASLSUCCESS,
|
||||||
|
IRC_ERR_SASLFAIL,
|
||||||
|
IRC_ERR_SASLTOOLONG,
|
||||||
|
IRC_ERR_SASLABORTED,
|
||||||
|
IRC_ERR_SASLALREADY,
|
||||||
|
IRC_ERR_SASLMECHS,
|
||||||
|
#endif /* UIRC_FEATURE_IRCV3 */
|
||||||
|
};
|
||||||
|
uint_least16_t IRC_RPL(enum uirc_table_replies rpl);
|
||||||
|
const char* IRC_RPL_STR(enum uirc_table_replies rpl);
|
||||||
|
|
||||||
|
#endif /* UIRC_GUARD_PUBLIC_COMMANDS */
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
|
||||||
* Copyright (c) 2019-2021 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*! \file */
|
|
||||||
|
|
||||||
#ifndef UIRC_GUARD_PUBLIC_COMMANDS
|
|
||||||
#define UIRC_GUARD_PUBLIC_COMMANDS
|
|
||||||
|
|
||||||
#define IRC_CMD_PASS "PASS"
|
|
||||||
#define IRC_CMD_NICK "NICK"
|
|
||||||
#define IRC_CMD_USER "USER"
|
|
||||||
#define IRC_CMD_OPER "OPER"
|
|
||||||
#define IRC_CMD_MODE "MODE"
|
|
||||||
#define IRC_CMD_SERVICE "SERVICE"
|
|
||||||
#define IRC_CMD_QUIT "QUIT"
|
|
||||||
#define IRC_CMD_SQUIT "SQUIT"
|
|
||||||
#define IRC_CMD_JOIN "JOIN"
|
|
||||||
#define IRC_CMD_PART "PART"
|
|
||||||
#define IRC_CMD_MODE "MODE"
|
|
||||||
#define IRC_CMD_TOPIC "TOPIC"
|
|
||||||
#define IRC_CMD_NAMES "NAMES"
|
|
||||||
#define IRC_CMD_LIST "LIST"
|
|
||||||
#define IRC_CMD_INVITE "INVITE"
|
|
||||||
#define IRC_CMD_KICK "KICK"
|
|
||||||
#define IRC_CMD_PRIVMSG "PRIVMSG"
|
|
||||||
#define IRC_CMD_NOTICE "NOTICE"
|
|
||||||
#define IRC_CMD_MOTD "MOTD"
|
|
||||||
#define IRC_CMD_LUSERS "LUSERS"
|
|
||||||
#define IRC_CMD_VERSION "VERSION"
|
|
||||||
#define IRC_CMD_STATS "STATS"
|
|
||||||
#define IRC_CMD_LINKS "LINKS"
|
|
||||||
#define IRC_CMD_TIME "TIME"
|
|
||||||
#define IRC_CMD_CONNECT "CONNECT"
|
|
||||||
#define IRC_CMD_TRACE "TRACE"
|
|
||||||
#define IRC_CMD_ADMIN "ADMIN"
|
|
||||||
#define IRC_CMD_INFO "INFO"
|
|
||||||
#define IRC_CMD_SERVLIST "SERVLIST"
|
|
||||||
#define IRC_CMD_SQUERY "SQUERY"
|
|
||||||
#define IRC_CMD_WHO "WHO"
|
|
||||||
#define IRC_CMD_WHOIS "WHOIS"
|
|
||||||
#define IRC_CMD_WHOWAS "WHOWAS"
|
|
||||||
#define IRC_CMD_KILL "KILL"
|
|
||||||
#define IRC_CMD_PING "PING"
|
|
||||||
#define IRC_CMD_PONG "PONG"
|
|
||||||
#define IRC_CMD_ERROR "ERROR"
|
|
||||||
#define IRC_CMD_AWAY "AWAY"
|
|
||||||
#define IRC_CMD_REHASH "REHASH"
|
|
||||||
#define IRC_CMD_DIE "DIE"
|
|
||||||
#define IRC_CMD_RESTART "RESTART"
|
|
||||||
#define IRC_CMD_SUMMON "SUMMON"
|
|
||||||
#define IRC_CMD_USERS "USERS"
|
|
||||||
#define IRC_CMD_WALLOPS "WALLOPS"
|
|
||||||
#define IRC_CMD_USERHOST "USERHOST"
|
|
||||||
#define IRC_CMD_ISON "ISON"
|
|
||||||
|
|
||||||
#endif /* UIRC_GUARD_PUBLIC_COMMANDS */
|
|
||||||
|
|
146
include/ctcp.h
146
include/ctcp.h
|
@ -18,24 +18,27 @@
|
||||||
|
|
||||||
/*! \file */
|
/*! \file */
|
||||||
|
|
||||||
|
#include <stdint.h> // uint_least8_t
|
||||||
|
|
||||||
#ifndef UIRC_GUARD_PUBLIC_CTCP
|
#ifndef UIRC_GUARD_PUBLIC_CTCP
|
||||||
#define UIRC_GUARD_PUBLIC_CTCP
|
#define UIRC_GUARD_PUBLIC_CTCP
|
||||||
|
|
||||||
#ifdef UIRC_FEATURE_CTCP
|
enum uirc_table_ctcp_formats {
|
||||||
enum formatting {
|
IRC_CTCP_BOLD,
|
||||||
IRC_CTCP_BOLD = 0x02,
|
IRC_CTCP_COLOR,
|
||||||
IRC_CTCP_COLOR = 0x03,
|
IRC_CTCP_COLOR_HEX,
|
||||||
IRC_CTCP_COLOR_HEX = 0x04,
|
IRC_CTCP_RESET,
|
||||||
IRC_CTCP_RESET = 0x0F,
|
IRC_CTCP_MONOSPACE,
|
||||||
IRC_CTCP_MONOSPACE = 0x11,
|
IRC_CTCP_REVERSE,
|
||||||
IRC_CTCP_REVERSE = 0x16,
|
IRC_CTCP_ITALICS,
|
||||||
IRC_CTCP_ITALICS = 0x1D,
|
IRC_CTCP_STRIKETHROUGH,
|
||||||
IRC_CTCP_STRIKETHROUGH = 0x1E,
|
IRC_CTCP_UNDERLINE,
|
||||||
IRC_CTCP_UNDERLINE = 0x1F,
|
|
||||||
};
|
};
|
||||||
enum colors {
|
int_least8_t IRC_CTCP_FORMAT(enum uirc_table_ctcp_formats fmt);
|
||||||
IRC_CTCP_COLORS_WHITE = 0,
|
|
||||||
IRC_CTCP_COLORS_BLACK = 1,
|
enum uirc_table_ctcp_named_colors {
|
||||||
|
IRC_CTCP_COLORS_WHITE,
|
||||||
|
IRC_CTCP_COLORS_BLACK,
|
||||||
IRC_CTCP_COLORS_BLUE,
|
IRC_CTCP_COLORS_BLUE,
|
||||||
IRC_CTCP_COLORS_GREEN,
|
IRC_CTCP_COLORS_GREEN,
|
||||||
IRC_CTCP_COLORS_RED,
|
IRC_CTCP_COLORS_RED,
|
||||||
|
@ -50,117 +53,12 @@ enum colors {
|
||||||
IRC_CTCP_COLORS_PINK,
|
IRC_CTCP_COLORS_PINK,
|
||||||
IRC_CTCP_COLORS_GREY,
|
IRC_CTCP_COLORS_GREY,
|
||||||
IRC_CTCP_COLORS_LIGHT_GREY,
|
IRC_CTCP_COLORS_LIGHT_GREY,
|
||||||
IRC_CTCP_COLORS_DEFAULT = 99,
|
IRC_CTCP_COLORS_DEFAULT,
|
||||||
};
|
};
|
||||||
short UIRC_FORMAT_ANSI[] = {
|
int_least8_t IRC_CTCP_COLORS(enum uirc_table_ctcp_named_colors col);
|
||||||
[IRC_CTCP_COLORS_WHITE] = 97,
|
|
||||||
[IRC_CTCP_COLORS_BLACK] = 30,
|
typedef uint_least8_t rgbcolor[3];
|
||||||
[IRC_CTCP_COLORS_BLUE] = 34,
|
rgbcolor* uirc_ctcp_to_rgb(uint_least8_t color);
|
||||||
[IRC_CTCP_COLORS_GREEN] = 32,
|
|
||||||
[IRC_CTCP_COLORS_RED] = 31,
|
|
||||||
[IRC_CTCP_COLORS_BROWN] = 94,
|
|
||||||
[IRC_CTCP_COLORS_MAGENTA] = 35,
|
|
||||||
[IRC_CTCP_COLORS_ORANGE] = 166,
|
|
||||||
[IRC_CTCP_COLORS_YELLOW] = 33,
|
|
||||||
[IRC_CTCP_COLORS_LIGHT_GREEN] = 92,
|
|
||||||
[IRC_CTCP_COLORS_CYAN] = 36,
|
|
||||||
[IRC_CTCP_COLORS_LIGHT_CYAN] = 96,
|
|
||||||
[IRC_CTCP_COLORS_LIGHT_BLUE] = 94,
|
|
||||||
[IRC_CTCP_COLORS_PINK] = 127,
|
|
||||||
[IRC_CTCP_COLORS_GREY] = 90,
|
|
||||||
[IRC_CTCP_COLORS_LIGHT_GREY] = 37,
|
|
||||||
[IRC_CTCP_COLORS_DEFAULT] = 39,
|
|
||||||
[IRC_CTCP_BOLD] = 1,
|
|
||||||
[IRC_CTCP_RESET] = 0,
|
|
||||||
[IRC_CTCP_REVERSE] = 7,
|
|
||||||
[IRC_CTCP_ITALICS] = 3,
|
|
||||||
[IRC_CTCP_STRIKETHROUGH] = 9,
|
|
||||||
[IRC_CTCP_UNDERLINE] = 4,
|
|
||||||
[16] = 52, /* See https://modern.ircdocs.horse/formatting.html */
|
|
||||||
[17] = 94,
|
|
||||||
[18] = 100,
|
|
||||||
[19] = 58,
|
|
||||||
[20] = 22,
|
|
||||||
[21] = 29,
|
|
||||||
[22] = 23,
|
|
||||||
[23] = 24,
|
|
||||||
[24] = 17,
|
|
||||||
[25] = 54,
|
|
||||||
[26] = 53,
|
|
||||||
[27] = 89,
|
|
||||||
[28] = 88,
|
|
||||||
[29] = 130,
|
|
||||||
[30] = 142,
|
|
||||||
[31] = 64,
|
|
||||||
[32] = 28,
|
|
||||||
[33] = 35,
|
|
||||||
[34] = 30,
|
|
||||||
[35] = 25,
|
|
||||||
[36] = 18,
|
|
||||||
[37] = 91,
|
|
||||||
[38] = 90,
|
|
||||||
[39] = 125,
|
|
||||||
[40] = 124,
|
|
||||||
[41] = 166,
|
|
||||||
[42] = 184,
|
|
||||||
[43] = 106,
|
|
||||||
[44] = 34,
|
|
||||||
[45] = 49,
|
|
||||||
[46] = 37,
|
|
||||||
[47] = 33,
|
|
||||||
[48] = 19,
|
|
||||||
[49] = 129,
|
|
||||||
[50] = 127,
|
|
||||||
[51] = 161,
|
|
||||||
[52] = 196,
|
|
||||||
[53] = 208,
|
|
||||||
[54] = 226,
|
|
||||||
[55] = 154,
|
|
||||||
[56] = 46,
|
|
||||||
[57] = 86,
|
|
||||||
[58] = 51,
|
|
||||||
[59] = 75,
|
|
||||||
[60] = 21,
|
|
||||||
[61] = 171,
|
|
||||||
[62] = 201,
|
|
||||||
[63] = 198,
|
|
||||||
[64] = 203,
|
|
||||||
[65] = 215,
|
|
||||||
[66] = 227,
|
|
||||||
[67] = 191,
|
|
||||||
[68] = 83,
|
|
||||||
[69] = 122,
|
|
||||||
[70] = 87,
|
|
||||||
[71] = 111,
|
|
||||||
[72] = 63,
|
|
||||||
[73] = 177,
|
|
||||||
[74] = 207,
|
|
||||||
[75] = 205,
|
|
||||||
[76] = 217,
|
|
||||||
[77] = 223,
|
|
||||||
[78] = 229,
|
|
||||||
[79] = 193,
|
|
||||||
[80] = 157,
|
|
||||||
[81] = 158,
|
|
||||||
[82] = 159,
|
|
||||||
[83] = 153,
|
|
||||||
[84] = 147,
|
|
||||||
[85] = 183,
|
|
||||||
[86] = 219,
|
|
||||||
[87] = 212,
|
|
||||||
[88] = 16,
|
|
||||||
[89] = 233,
|
|
||||||
[90] = 235,
|
|
||||||
[91] = 237,
|
|
||||||
[92] = 239,
|
|
||||||
[93] = 241,
|
|
||||||
[94] = 244,
|
|
||||||
[95] = 247,
|
|
||||||
[96] = 250,
|
|
||||||
[97] = 254,
|
|
||||||
[98] = 231,
|
|
||||||
};
|
|
||||||
#endif /* UIRC_FEATURE_CTCP */
|
|
||||||
|
|
||||||
#endif /* UIRC_GUARD_PUBLIC_CTCP */
|
#endif /* UIRC_GUARD_PUBLIC_CTCP */
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
|
|
||||||
/*! \file */
|
/*! \file */
|
||||||
|
|
||||||
#include "types.h" // IRC_*
|
#include "mode.h" // IRC_Modes
|
||||||
|
#include "type.h" // IRC_*
|
||||||
|
|
||||||
#include <stddef.h> // ptrdiff_t
|
#include <stddef.h> // ptrdiff_t
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,17 @@
|
||||||
#define UIRC_GUARD_PUBLIC_MODES
|
#define UIRC_GUARD_PUBLIC_MODES
|
||||||
|
|
||||||
typedef bool IRC_Modes[(('z' - 'a')) * 2];
|
typedef bool IRC_Modes[(('z' - 'a')) * 2];
|
||||||
typedef enum {
|
|
||||||
IRC_MODE_WALLOPS = 'w',
|
enum uirc_table_mode {
|
||||||
IRC_MODE_INVISIBLE = 'i',
|
IRC_MODE_WALLOPS,
|
||||||
IRC_MODE_AWAY = 'a',
|
IRC_MODE_INVISIBLE,
|
||||||
IRC_MODE_RESTRICTED = 'r',
|
IRC_MODE_AWAY,
|
||||||
IRC_MODE_OPERATOR = 'o',
|
IRC_MODE_RESTRICTED,
|
||||||
IRC_MODE_LOCALOPERATOR = 'O',
|
IRC_MODE_OPERATOR,
|
||||||
IRC_MODE_SERVERNOTICES = 's',
|
IRC_MODE_LOCALOPERATOR,
|
||||||
} IRC_Mode;
|
IRC_MODE_SERVERNOTICES,
|
||||||
|
};
|
||||||
|
char IRC_MODE(enum uirc_table_mode mode);
|
||||||
|
|
||||||
bool uirc_mode_toggle(char m, IRC_Modes ms);
|
bool uirc_mode_toggle(char m, IRC_Modes ms);
|
||||||
bool uirc_mode_enable(char m, IRC_Modes ms);
|
bool uirc_mode_enable(char m, IRC_Modes ms);
|
|
@ -1,186 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
|
||||||
* Copyright (c) 2019-2021 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*! \file */
|
|
||||||
|
|
||||||
#ifndef UIRC_GUARD_PUBLIC_REPLIES
|
|
||||||
#define UIRC_GUARD_PUBLIC_REPLIES
|
|
||||||
|
|
||||||
enum replies {
|
|
||||||
IRC_RPL_WELCOME = 1,
|
|
||||||
IRC_RPL_YOURHOST = 2,
|
|
||||||
IRC_RPL_CREATED = 3,
|
|
||||||
IRC_RPL_MYINFO = 4,
|
|
||||||
IRC_RPL_BOUNCE = 5,
|
|
||||||
|
|
||||||
#ifdef UIRC_FEATURE_IRCV3
|
|
||||||
/* TO IRCv3 WG:
|
|
||||||
* Please, stop complicating implementations
|
|
||||||
* Get people in the WG that actually care about the protocol and understand why and how standards are written
|
|
||||||
*
|
|
||||||
* TO LIBRARY USERS:
|
|
||||||
* Read the above and go speak with them, or just don't use IRCv3 :)
|
|
||||||
*/
|
|
||||||
IRC_RPL_ISUPPORT = 5,
|
|
||||||
#endif /* UIRC_FEATURE_IRCV3 */
|
|
||||||
|
|
||||||
IRC_RPL_TRACELINK = 200,
|
|
||||||
IRC_RPL_TRACECONNECTING = 201,
|
|
||||||
IRC_RPL_TRACEHANDSHAKE = 202,
|
|
||||||
IRC_RPL_TRACEUNKNOWN = 203,
|
|
||||||
IRC_RPL_TRACEOPERATOR = 204,
|
|
||||||
IRC_RPL_TRACEUSER = 205,
|
|
||||||
IRC_RPL_TRACESERVER = 206,
|
|
||||||
IRC_RPL_TRACENEWTYPE = 208,
|
|
||||||
IRC_RPL_STATSLINKINFO = 211,
|
|
||||||
IRC_RPL_STATSCOMMANDS = 212,
|
|
||||||
IRC_RPL_STATSCLINE = 213,
|
|
||||||
IRC_RPL_STATSNLINE = 214,
|
|
||||||
IRC_RPL_STATSILINE = 215,
|
|
||||||
IRC_RPL_STATSKLINE = 216,
|
|
||||||
IRC_RPL_STATSYLINE = 218,
|
|
||||||
IRC_RPL_ENDOFSTATS = 219,
|
|
||||||
IRC_RPL_UMODEIS = 221,
|
|
||||||
IRC_RPL_STATSLLINE = 241,
|
|
||||||
IRC_RPL_STATSUPTIME = 242,
|
|
||||||
IRC_RPL_STATSOLINE = 243,
|
|
||||||
IRC_RPL_STATSHLINE = 244,
|
|
||||||
IRC_RPL_LUSERCLIENT = 251,
|
|
||||||
IRC_RPL_LUSEROP = 252,
|
|
||||||
IRC_RPL_LUSERUNKNOWN = 253,
|
|
||||||
IRC_RPL_LUSERCHANNELS = 254,
|
|
||||||
IRC_RPL_LUSERME = 255,
|
|
||||||
IRC_RPL_ADMINME = 256,
|
|
||||||
IRC_RPL_ADMINLOC1 = 257,
|
|
||||||
IRC_RPL_ADMINLOC2 = 258,
|
|
||||||
IRC_RPL_ADMINEMAIL = 259,
|
|
||||||
IRC_RPL_TRACELOG = 261,
|
|
||||||
IRC_RPL_NONE = 300,
|
|
||||||
IRC_RPL_AWAY = 301,
|
|
||||||
IRC_RPL_USERHOST = 302,
|
|
||||||
IRC_RPL_ISON = 303,
|
|
||||||
IRC_RPL_UNAWAY = 305,
|
|
||||||
IRC_RPL_NOWAWAY = 306,
|
|
||||||
IRC_RPL_WHOISUSER = 311,
|
|
||||||
IRC_RPL_WHOISSERVER = 312,
|
|
||||||
IRC_RPL_WHOISOPERATOR = 313,
|
|
||||||
IRC_RPL_WHOWASUSER = 314,
|
|
||||||
IRC_RPL_ENDOFWHO = 315,
|
|
||||||
IRC_RPL_WHOISIDLE = 317,
|
|
||||||
IRC_RPL_ENDOFWHOIS = 318,
|
|
||||||
IRC_RPL_WHOISCHANNELS = 319,
|
|
||||||
IRC_RPL_LISTSTART = 321,
|
|
||||||
IRC_RPL_LIST = 322,
|
|
||||||
IRC_RPL_LISTEND = 323,
|
|
||||||
IRC_RPL_CHANNELMODEIS = 324,
|
|
||||||
IRC_RPL_NOTOPIC = 331,
|
|
||||||
IRC_RPL_TOPIC = 332,
|
|
||||||
IRC_RPL_INVITING = 341,
|
|
||||||
IRC_RPL_SUMMONING = 342,
|
|
||||||
IRC_RPL_VERSION = 351,
|
|
||||||
IRC_RPL_WHOREPLY = 352,
|
|
||||||
IRC_RPL_NAMREPLY = 353,
|
|
||||||
IRC_RPL_LINKS = 364,
|
|
||||||
IRC_RPL_ENDOFLINKS = 365,
|
|
||||||
IRC_RPL_ENDOFNAMES = 366,
|
|
||||||
IRC_RPL_BANLIST = 367,
|
|
||||||
IRC_RPL_ENDOFBANLIST = 368,
|
|
||||||
IRC_RPL_ENDOFWHOWAS = 369,
|
|
||||||
IRC_RPL_INFO = 371,
|
|
||||||
IRC_RPL_MOTD = 372,
|
|
||||||
IRC_RPL_ENDOFINFO = 374,
|
|
||||||
IRC_RPL_MOTDSTART = 375,
|
|
||||||
IRC_RPL_ENDOFMOTD = 376,
|
|
||||||
IRC_RPL_YOUREOPER = 381,
|
|
||||||
IRC_RPL_REHASHING = 382,
|
|
||||||
IRC_RPL_TIME = 391,
|
|
||||||
IRC_RPL_USERSSTART = 392,
|
|
||||||
IRC_RPL_USERS = 393,
|
|
||||||
IRC_RPL_ENDOFUSERS = 394,
|
|
||||||
IRC_RPL_NOUSERS = 395,
|
|
||||||
|
|
||||||
IRC_ERR_NOSUCHNICK = 401,
|
|
||||||
IRC_ERR_NOSUCHSERVER = 402,
|
|
||||||
IRC_ERR_NOSUCHCHANNEL = 403,
|
|
||||||
IRC_ERR_CANNOTSENDTOCHAN = 404,
|
|
||||||
IRC_ERR_TOOMANYCHANNELS = 405,
|
|
||||||
IRC_ERR_WASNOSUCHNICK = 406,
|
|
||||||
IRC_ERR_TOOMANYTARGETS = 407,
|
|
||||||
IRC_ERR_NOORIGIN = 409,
|
|
||||||
IRC_ERR_NORECIPIENT = 411,
|
|
||||||
IRC_ERR_NOTEXTTOSEND = 412,
|
|
||||||
IRC_ERR_NOTOPLEVEL = 413,
|
|
||||||
IRC_ERR_WILDTOPLEVEL = 414,
|
|
||||||
IRC_ERR_UNKNOWNCOMMAND = 421,
|
|
||||||
IRC_ERR_NOMOTD = 422,
|
|
||||||
IRC_ERR_NOADMININFO = 423,
|
|
||||||
IRC_ERR_FILEIRC_ERROR = 424,
|
|
||||||
IRC_ERR_NONICKNAMEGIVEN = 431,
|
|
||||||
IRC_ERR_IRC_ERRONEUSNICKNAME = 432,
|
|
||||||
IRC_ERR_NICKNAMEINUSE = 433,
|
|
||||||
IRC_ERR_NICKCOLLISION = 436,
|
|
||||||
IRC_ERR_USERNOTINCHANNEL = 441,
|
|
||||||
IRC_ERR_NOTONCHANNEL = 442,
|
|
||||||
IRC_ERR_USERONCHANNEL = 443,
|
|
||||||
IRC_ERR_NOLOGIN = 444,
|
|
||||||
IRC_ERR_SUMMONDISABLED = 445,
|
|
||||||
IRC_ERR_USERSDISABLED = 446,
|
|
||||||
IRC_ERR_NOTREGISTERED = 451,
|
|
||||||
IRC_ERR_NEEDMOREPARAMS = 461,
|
|
||||||
IRC_ERR_ALREADYREGISTRED = 462,
|
|
||||||
IRC_ERR_NOPERMFORHOST = 463,
|
|
||||||
IRC_ERR_PASSWDMISMATCH = 464,
|
|
||||||
IRC_ERR_YOUREBANNEDCREEP = 465,
|
|
||||||
IRC_ERR_KEYSET = 467,
|
|
||||||
IRC_ERR_CHANNELISFULL = 471,
|
|
||||||
IRC_ERR_UNKNOWNMODE = 472,
|
|
||||||
IRC_ERR_INVITEONLYCHAN = 473,
|
|
||||||
IRC_ERR_BANNEDFROMCHAN = 474,
|
|
||||||
IRC_ERR_BADCHANNELKEY = 475,
|
|
||||||
IRC_ERR_NOPRIVILEGES = 481,
|
|
||||||
IRC_ERR_CHANOPRIVSNEEDED = 482,
|
|
||||||
IRC_ERR_CANTKILLSERVER = 483,
|
|
||||||
IRC_ERR_NOOPERHOST = 491,
|
|
||||||
IRC_ERR_UMODEUNKNOWNFLAG = 501,
|
|
||||||
IRC_ERR_USERSDONTMATCH = 502,
|
|
||||||
|
|
||||||
#ifdef UIRC_FEATURE_IRCV3
|
|
||||||
/* https://ircv3.net/registry */
|
|
||||||
IRC_RPL_STARTTLS = 670,
|
|
||||||
IRC_ERR_STARTTLS = 691,
|
|
||||||
|
|
||||||
IRC_RPL_MONONLINE = 730,
|
|
||||||
IRC_RPL_MONOFFLINE = 731,
|
|
||||||
IRC_RPL_MONLIST = 732,
|
|
||||||
IRC_RPL_ENDOFMONLIST = 733,
|
|
||||||
IRC_ERR_MOLISTFULL = 734,
|
|
||||||
|
|
||||||
IRC_RPL_LOGGEDIN = 900,
|
|
||||||
IRC_RPL_LOGGEDOUT = 901,
|
|
||||||
IRC_ERR_NICKLOCKED = 902,
|
|
||||||
IRC_RPL_SASLSUCCESS = 903,
|
|
||||||
IRC_ERR_SASLFAIL = 904,
|
|
||||||
IRC_ERR_SASLTOOLONG = 905,
|
|
||||||
IRC_ERR_SASLABORTED = 906,
|
|
||||||
IRC_ERR_SASLALREADY = 907,
|
|
||||||
IRC_ERR_SASLMECHS = 908,
|
|
||||||
#endif /* UIRC_FEATURE_IRCV3 */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* UIRC_GUARD_PUBLIC_REPLIES */
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||||
|
* Copyright (c) 2019-2021 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file */
|
||||||
|
|
||||||
|
#ifndef UIRC_GUARD_PUBLIC_TAGS
|
||||||
|
#define UIRC_GUARD_PUBLIC_TAGS
|
||||||
|
|
||||||
|
enum uirc_table_tag {
|
||||||
|
IRC_TAG_ACCOUNT,
|
||||||
|
IRC_TAG_BATCH,
|
||||||
|
IRC_TAG_BOT,
|
||||||
|
IRC_TAG_LABEL,
|
||||||
|
IRC_TAG_MSGID,
|
||||||
|
IRC_TAG_MULTILINE,
|
||||||
|
IRC_TAG_TIME,
|
||||||
|
IRC_TAG_REACT,
|
||||||
|
IRC_TAG_REPLY,
|
||||||
|
IRC_TAG_TYPING,
|
||||||
|
};
|
||||||
|
const char* IRC_TAG(enum uirc_table_tag tag);
|
||||||
|
|
||||||
|
#endif /* UIRC_GUARD_PUBLIC_TAGS */
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
/*! \file */
|
/*! \file */
|
||||||
|
|
||||||
#include "types.h" // IRC_User
|
#include "type.h" // IRC_User
|
||||||
|
|
||||||
#include <corelibs/llist.h> // llist_t
|
#include <corelibs/llist.h> // llist_t
|
||||||
#include <stdbool.h> // bool
|
#include <stdbool.h> // bool
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
/*! \file */
|
/*! \file */
|
||||||
|
|
||||||
#include "modes.h"
|
#include "mode.h"
|
||||||
|
|
||||||
#include <corelibs/llist.h> // llist_t
|
#include <corelibs/llist.h> // llist_t
|
||||||
#include <inttypes.h> // uintmax_t
|
#include <inttypes.h> // uintmax_t
|
|
@ -16,14 +16,20 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assemblers.h"
|
#include "assembler.h"
|
||||||
#include "commands.h"
|
#include "command.h"
|
||||||
#include "ctcp.h"
|
#include "error.h"
|
||||||
#include "errors.h"
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "modes.h"
|
#include "mode.h"
|
||||||
#include "replies.h"
|
#include "tokenizer.h"
|
||||||
#include "tokenizers.h"
|
#include "type.h"
|
||||||
#include "types.h"
|
#include "validator.h"
|
||||||
#include "validators.h"
|
|
||||||
|
#ifdef UIRC_FEATURE_IRCV3
|
||||||
|
#include "tag.h"
|
||||||
|
#endif /* UIRC_FEATURE_IRCV3 */
|
||||||
|
|
||||||
|
#ifdef UIRC_FEATURE_CTCP
|
||||||
|
#include "ctcp.h"
|
||||||
|
#endif /* UIRC_FEATURE_CTCP */
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
/*! \file */
|
/*! \file */
|
||||||
|
|
||||||
#include "types.h" // IRC_Message
|
#include "type.h" // IRC_Message
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assemblers.h" // uirc_assembler_*
|
#include "assembler.h" // uirc_assembler_*
|
||||||
#include "errors.h" // uirc_errno
|
#include "error.h" // uirc_errno
|
||||||
#include "types.h" // IRC_Message IRC_Tag IRC_User
|
#include "type.h" // IRC_Message IRC_Tag IRC_User
|
||||||
|
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
#include <stdio.h> // NULL, snprintf()
|
#include <stdio.h> // NULL, snprintf()
|
|
@ -16,9 +16,9 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assemblers.h" // uirc_assembler_tag_*
|
#include "assembler.h" // uirc_assembler_tag_*
|
||||||
#include "errors.h" // uirc_errno
|
#include "error.h" // uirc_errno
|
||||||
#include "types.h" // IRC_Tag
|
#include "type.h" // IRC_Tag
|
||||||
|
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
#include <corelibs/llist.h> // llist_t
|
#include <corelibs/llist.h> // llist_t
|
|
@ -16,9 +16,9 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assemblers.h" // Assm_user()
|
#include "assembler.h" // Assm_user()
|
||||||
#include "errors.h" // uirc_errno
|
#include "error.h" // uirc_errno
|
||||||
#include "types.h" // IRC_User
|
#include "type.h" // IRC_User
|
||||||
|
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
#include <stdbool.h> // bool
|
#include <stdbool.h> // bool
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||||
|
* Copyright (c) 2019-2021 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 "command.h"
|
||||||
|
|
||||||
|
static const char* const cmd_table[] = {
|
||||||
|
[IRC_CMD_PASS] = "PASS", [IRC_CMD_NICK] = "NICK", [IRC_CMD_USER] = "USER", [IRC_CMD_OPER] = "OPER",
|
||||||
|
[IRC_CMD_MODE] = "MODE", [IRC_CMD_SERVICE] = "SERVICE", [IRC_CMD_QUIT] = "QUIT", [IRC_CMD_SQUIT] = "SQUIT",
|
||||||
|
[IRC_CMD_JOIN] = "JOIN", [IRC_CMD_PART] = "PART", [IRC_CMD_TOPIC] = "TOPIC", [IRC_CMD_NAMES] = "NAMES",
|
||||||
|
[IRC_CMD_LIST] = "LIST", [IRC_CMD_INVITE] = "INVITE", [IRC_CMD_KICK] = "KICK", [IRC_CMD_PRIVMSG] = "PRIVMSG",
|
||||||
|
[IRC_CMD_NOTICE] = "NOTICE", [IRC_CMD_MOTD] = "MOTD", [IRC_CMD_LUSERS] = "LUSERS", [IRC_CMD_VERSION] = "VERSION",
|
||||||
|
[IRC_CMD_STATS] = "STATS", [IRC_CMD_LINKS] = "LINKS", [IRC_CMD_TIME] = "TIME", [IRC_CMD_CONNECT] = "CONNECT",
|
||||||
|
[IRC_CMD_TRACE] = "TRACE", [IRC_CMD_ADMIN] = "ADMIN", [IRC_CMD_INFO] = "INFO", [IRC_CMD_SERVLIST] = "SERVLIST",
|
||||||
|
[IRC_CMD_SQUERY] = "SQUERY", [IRC_CMD_WHO] = "WHO", [IRC_CMD_WHOIS] = "WHOIS", [IRC_CMD_WHOWAS] = "WHOWAS",
|
||||||
|
[IRC_CMD_KILL] = "KILL", [IRC_CMD_PING] = "PING", [IRC_CMD_PONG] = "PONG", [IRC_CMD_ERROR] = "ERROR",
|
||||||
|
[IRC_CMD_AWAY] = "AWAY", [IRC_CMD_REHASH] = "REHASH", [IRC_CMD_DIE] = "DIE", [IRC_CMD_RESTART] = "RESTART",
|
||||||
|
[IRC_CMD_SUMMON] = "SUMMON", [IRC_CMD_USERS] = "USERS", [IRC_CMD_WALLOPS] = "WALLOPS", [IRC_CMD_USERHOST] = "USERHOST",
|
||||||
|
[IRC_CMD_ISON] = "ISON",
|
||||||
|
};
|
||||||
|
|
||||||
|
const char*
|
||||||
|
IRC_CMD(enum uirc_table_command cmd)
|
||||||
|
{
|
||||||
|
return cmd_table[cmd];
|
||||||
|
}
|
|
@ -0,0 +1,197 @@
|
||||||
|
/*
|
||||||
|
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||||
|
* Copyright (c) 2019-2021 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 "command.h"
|
||||||
|
|
||||||
|
#include <stdint.h> // uint_least16_t
|
||||||
|
#include <stdio.h> // snprintf()
|
||||||
|
|
||||||
|
static const uint_least16_t reply_table[] = {
|
||||||
|
[IRC_RPL_WELCOME] = 1,
|
||||||
|
[IRC_RPL_YOURHOST] = 2,
|
||||||
|
[IRC_RPL_CREATED] = 3,
|
||||||
|
[IRC_RPL_MYINFO] = 4,
|
||||||
|
[IRC_RPL_BOUNCE] = 5,
|
||||||
|
|
||||||
|
#ifdef UIRC_FEATURE_IRCV3
|
||||||
|
/* TO IRCv3 WG:
|
||||||
|
* Please, stop complicating implementations
|
||||||
|
* Get people in the WG that actually care about the protocol and understand why and how standards are written
|
||||||
|
*
|
||||||
|
* TO LIBRARY USERS:
|
||||||
|
* Read the above and go speak with them, or just don't use IRCv3 :)
|
||||||
|
*/
|
||||||
|
[IRC_RPL_ISUPPORT] = 5,
|
||||||
|
#endif /* UIRC_FEATURE_IRCV3 */
|
||||||
|
|
||||||
|
[IRC_RPL_TRACELINK] = 200,
|
||||||
|
[IRC_RPL_TRACECONNECTING] = 201,
|
||||||
|
[IRC_RPL_TRACEHANDSHAKE] = 202,
|
||||||
|
[IRC_RPL_TRACEUNKNOWN] = 203,
|
||||||
|
[IRC_RPL_TRACEOPERATOR] = 204,
|
||||||
|
[IRC_RPL_TRACEUSER] = 205,
|
||||||
|
[IRC_RPL_TRACESERVER] = 206,
|
||||||
|
[IRC_RPL_TRACENEWTYPE] = 208,
|
||||||
|
[IRC_RPL_STATSLINKINFO] = 211,
|
||||||
|
[IRC_RPL_STATSCOMMANDS] = 212,
|
||||||
|
[IRC_RPL_STATSCLINE] = 213,
|
||||||
|
[IRC_RPL_STATSNLINE] = 214,
|
||||||
|
[IRC_RPL_STATSILINE] = 215,
|
||||||
|
[IRC_RPL_STATSKLINE] = 216,
|
||||||
|
[IRC_RPL_STATSYLINE] = 218,
|
||||||
|
[IRC_RPL_ENDOFSTATS] = 219,
|
||||||
|
[IRC_RPL_UMODEIS] = 221,
|
||||||
|
[IRC_RPL_STATSLLINE] = 241,
|
||||||
|
[IRC_RPL_STATSUPTIME] = 242,
|
||||||
|
[IRC_RPL_STATSOLINE] = 243,
|
||||||
|
[IRC_RPL_STATSHLINE] = 244,
|
||||||
|
[IRC_RPL_LUSERCLIENT] = 251,
|
||||||
|
[IRC_RPL_LUSEROP] = 252,
|
||||||
|
[IRC_RPL_LUSERUNKNOWN] = 253,
|
||||||
|
[IRC_RPL_LUSERCHANNELS] = 254,
|
||||||
|
[IRC_RPL_LUSERME] = 255,
|
||||||
|
[IRC_RPL_ADMINME] = 256,
|
||||||
|
[IRC_RPL_ADMINLOC1] = 257,
|
||||||
|
[IRC_RPL_ADMINLOC2] = 258,
|
||||||
|
[IRC_RPL_ADMINEMAIL] = 259,
|
||||||
|
[IRC_RPL_TRACELOG] = 261,
|
||||||
|
[IRC_RPL_NONE] = 300,
|
||||||
|
[IRC_RPL_AWAY] = 301,
|
||||||
|
[IRC_RPL_USERHOST] = 302,
|
||||||
|
[IRC_RPL_ISON] = 303,
|
||||||
|
[IRC_RPL_UNAWAY] = 305,
|
||||||
|
[IRC_RPL_NOWAWAY] = 306,
|
||||||
|
[IRC_RPL_WHOISUSER] = 311,
|
||||||
|
[IRC_RPL_WHOISSERVER] = 312,
|
||||||
|
[IRC_RPL_WHOISOPERATOR] = 313,
|
||||||
|
[IRC_RPL_WHOWASUSER] = 314,
|
||||||
|
[IRC_RPL_ENDOFWHO] = 315,
|
||||||
|
[IRC_RPL_WHOISIDLE] = 317,
|
||||||
|
[IRC_RPL_ENDOFWHOIS] = 318,
|
||||||
|
[IRC_RPL_WHOISCHANNELS] = 319,
|
||||||
|
[IRC_RPL_LISTSTART] = 321,
|
||||||
|
[IRC_RPL_LIST] = 322,
|
||||||
|
[IRC_RPL_LISTEND] = 323,
|
||||||
|
[IRC_RPL_CHANNELMODEIS] = 324,
|
||||||
|
[IRC_RPL_NOTOPIC] = 331,
|
||||||
|
[IRC_RPL_TOPIC] = 332,
|
||||||
|
[IRC_RPL_INVITING] = 341,
|
||||||
|
[IRC_RPL_SUMMONING] = 342,
|
||||||
|
[IRC_RPL_VERSION] = 351,
|
||||||
|
[IRC_RPL_WHOREPLY] = 352,
|
||||||
|
[IRC_RPL_NAMREPLY] = 353,
|
||||||
|
[IRC_RPL_LINKS] = 364,
|
||||||
|
[IRC_RPL_ENDOFLINKS] = 365,
|
||||||
|
[IRC_RPL_ENDOFNAMES] = 366,
|
||||||
|
[IRC_RPL_BANLIST] = 367,
|
||||||
|
[IRC_RPL_ENDOFBANLIST] = 368,
|
||||||
|
[IRC_RPL_ENDOFWHOWAS] = 369,
|
||||||
|
[IRC_RPL_INFO] = 371,
|
||||||
|
[IRC_RPL_MOTD] = 372,
|
||||||
|
[IRC_RPL_ENDOFINFO] = 374,
|
||||||
|
[IRC_RPL_MOTDSTART] = 375,
|
||||||
|
[IRC_RPL_ENDOFMOTD] = 376,
|
||||||
|
[IRC_RPL_YOUREOPER] = 381,
|
||||||
|
[IRC_RPL_REHASHING] = 382,
|
||||||
|
[IRC_RPL_TIME] = 391,
|
||||||
|
[IRC_RPL_USERSSTART] = 392,
|
||||||
|
[IRC_RPL_USERS] = 393,
|
||||||
|
[IRC_RPL_ENDOFUSERS] = 394,
|
||||||
|
[IRC_RPL_NOUSERS] = 395,
|
||||||
|
|
||||||
|
[IRC_ERR_NOSUCHNICK] = 401,
|
||||||
|
[IRC_ERR_NOSUCHSERVER] = 402,
|
||||||
|
[IRC_ERR_NOSUCHCHANNEL] = 403,
|
||||||
|
[IRC_ERR_CANNOTSENDTOCHAN] = 404,
|
||||||
|
[IRC_ERR_TOOMANYCHANNELS] = 405,
|
||||||
|
[IRC_ERR_WASNOSUCHNICK] = 406,
|
||||||
|
[IRC_ERR_TOOMANYTARGETS] = 407,
|
||||||
|
[IRC_ERR_NOORIGIN] = 409,
|
||||||
|
[IRC_ERR_NORECIPIENT] = 411,
|
||||||
|
[IRC_ERR_NOTEXTTOSEND] = 412,
|
||||||
|
[IRC_ERR_NOTOPLEVEL] = 413,
|
||||||
|
[IRC_ERR_WILDTOPLEVEL] = 414,
|
||||||
|
[IRC_ERR_UNKNOWNCOMMAND] = 421,
|
||||||
|
[IRC_ERR_NOMOTD] = 422,
|
||||||
|
[IRC_ERR_NOADMININFO] = 423,
|
||||||
|
[IRC_ERR_FILEIRC_ERROR] = 424,
|
||||||
|
[IRC_ERR_NONICKNAMEGIVEN] = 431,
|
||||||
|
[IRC_ERR_IRC_ERRONEUSNICKNAME] = 432,
|
||||||
|
[IRC_ERR_NICKNAMEINUSE] = 433,
|
||||||
|
[IRC_ERR_NICKCOLLISION] = 436,
|
||||||
|
[IRC_ERR_USERNOTINCHANNEL] = 441,
|
||||||
|
[IRC_ERR_NOTONCHANNEL] = 442,
|
||||||
|
[IRC_ERR_USERONCHANNEL] = 443,
|
||||||
|
[IRC_ERR_NOLOGIN] = 444,
|
||||||
|
[IRC_ERR_SUMMONDISABLED] = 445,
|
||||||
|
[IRC_ERR_USERSDISABLED] = 446,
|
||||||
|
[IRC_ERR_NOTREGISTERED] = 451,
|
||||||
|
[IRC_ERR_NEEDMOREPARAMS] = 461,
|
||||||
|
[IRC_ERR_ALREADYREGISTRED] = 462,
|
||||||
|
[IRC_ERR_NOPERMFORHOST] = 463,
|
||||||
|
[IRC_ERR_PASSWDMISMATCH] = 464,
|
||||||
|
[IRC_ERR_YOUREBANNEDCREEP] = 465,
|
||||||
|
[IRC_ERR_KEYSET] = 467,
|
||||||
|
[IRC_ERR_CHANNELISFULL] = 471,
|
||||||
|
[IRC_ERR_UNKNOWNMODE] = 472,
|
||||||
|
[IRC_ERR_INVITEONLYCHAN] = 473,
|
||||||
|
[IRC_ERR_BANNEDFROMCHAN] = 474,
|
||||||
|
[IRC_ERR_BADCHANNELKEY] = 475,
|
||||||
|
[IRC_ERR_NOPRIVILEGES] = 481,
|
||||||
|
[IRC_ERR_CHANOPRIVSNEEDED] = 482,
|
||||||
|
[IRC_ERR_CANTKILLSERVER] = 483,
|
||||||
|
[IRC_ERR_NOOPERHOST] = 491,
|
||||||
|
[IRC_ERR_UMODEUNKNOWNFLAG] = 501,
|
||||||
|
[IRC_ERR_USERSDONTMATCH] = 502,
|
||||||
|
|
||||||
|
#ifdef UIRC_FEATURE_IRCV3
|
||||||
|
/* https://ircv3.net/registry */
|
||||||
|
[IRC_RPL_STARTTLS] = 670,
|
||||||
|
[IRC_ERR_STARTTLS] = 691,
|
||||||
|
|
||||||
|
[IRC_RPL_MONONLINE] = 730,
|
||||||
|
[IRC_RPL_MONOFFLINE] = 731,
|
||||||
|
[IRC_RPL_MONLIST] = 732,
|
||||||
|
[IRC_RPL_ENDOFMONLIST] = 733,
|
||||||
|
[IRC_ERR_MOLISTFULL] = 734,
|
||||||
|
|
||||||
|
[IRC_RPL_LOGGEDIN] = 900,
|
||||||
|
[IRC_RPL_LOGGEDOUT] = 901,
|
||||||
|
[IRC_ERR_NICKLOCKED] = 902,
|
||||||
|
[IRC_RPL_SASLSUCCESS] = 903,
|
||||||
|
[IRC_ERR_SASLFAIL] = 904,
|
||||||
|
[IRC_ERR_SASLTOOLONG] = 905,
|
||||||
|
[IRC_ERR_SASLABORTED] = 906,
|
||||||
|
[IRC_ERR_SASLALREADY] = 907,
|
||||||
|
[IRC_ERR_SASLMECHS] = 908,
|
||||||
|
#endif /* UIRC_FEATURE_IRCV3 */
|
||||||
|
};
|
||||||
|
|
||||||
|
uint_least16_t
|
||||||
|
IRC_RPL(enum uirc_table_replies rpl)
|
||||||
|
{
|
||||||
|
return reply_table[rpl];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
IRC_RPL_STR(enum uirc_table_replies rpl)
|
||||||
|
{
|
||||||
|
static char cmd[4];
|
||||||
|
snprintf(cmd, 3, "%i", reply_table[rpl]);
|
||||||
|
return cmd;
|
||||||
|
}
|
|
@ -0,0 +1,270 @@
|
||||||
|
/*
|
||||||
|
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||||
|
* Copyright (c) 2019-2021 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 "ctcp.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// Tables
|
||||||
|
static int_least8_t ctcp_formats[] = {
|
||||||
|
[IRC_CTCP_BOLD] = 0x02, [IRC_CTCP_COLOR] = 0x03, [IRC_CTCP_COLOR_HEX] = 0x04,
|
||||||
|
[IRC_CTCP_RESET] = 0x0F, [IRC_CTCP_MONOSPACE] = 0x11, [IRC_CTCP_REVERSE] = 0x16,
|
||||||
|
[IRC_CTCP_ITALICS] = 0x1D, [IRC_CTCP_STRIKETHROUGH] = 0x1E, [IRC_CTCP_UNDERLINE] = 0x1F,
|
||||||
|
};
|
||||||
|
static int_least8_t ctcp_named_colors[] = {
|
||||||
|
[IRC_CTCP_COLORS_WHITE] = 0, [IRC_CTCP_COLORS_BLACK] = 1, [IRC_CTCP_COLORS_BLUE] = 2, [IRC_CTCP_COLORS_GREEN] = 3,
|
||||||
|
[IRC_CTCP_COLORS_RED] = 4, [IRC_CTCP_COLORS_BROWN] = 5, [IRC_CTCP_COLORS_MAGENTA] = 6, [IRC_CTCP_COLORS_ORANGE] = 7,
|
||||||
|
[IRC_CTCP_COLORS_YELLOW] = 8, [IRC_CTCP_COLORS_LIGHT_GREEN] = 9, [IRC_CTCP_COLORS_CYAN] = 10, [IRC_CTCP_COLORS_LIGHT_CYAN] = 11,
|
||||||
|
[IRC_CTCP_COLORS_LIGHT_BLUE] = 12, [IRC_CTCP_COLORS_PINK] = 13, [IRC_CTCP_COLORS_GREY] = 14, [IRC_CTCP_COLORS_LIGHT_GREY] = 15,
|
||||||
|
[IRC_CTCP_COLORS_DEFAULT] = 99,
|
||||||
|
};
|
||||||
|
|
||||||
|
// CTCP to ANSI format mappings
|
||||||
|
static short ansi_formats[] = {
|
||||||
|
[IRC_CTCP_BOLD] = 1, [IRC_CTCP_RESET] = 0, [IRC_CTCP_REVERSE] = 7,
|
||||||
|
[IRC_CTCP_ITALICS] = 3, [IRC_CTCP_STRIKETHROUGH] = 9, [IRC_CTCP_UNDERLINE] = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
// CTCP to ANSI color mappings
|
||||||
|
static short ansi_colors[] = {
|
||||||
|
[IRC_CTCP_COLORS_WHITE] = 97,
|
||||||
|
[IRC_CTCP_COLORS_BLACK] = 30,
|
||||||
|
[IRC_CTCP_COLORS_BLUE] = 34,
|
||||||
|
[IRC_CTCP_COLORS_GREEN] = 32,
|
||||||
|
[IRC_CTCP_COLORS_RED] = 31,
|
||||||
|
[IRC_CTCP_COLORS_BROWN] = 94,
|
||||||
|
[IRC_CTCP_COLORS_MAGENTA] = 35,
|
||||||
|
[IRC_CTCP_COLORS_ORANGE] = 166,
|
||||||
|
[IRC_CTCP_COLORS_YELLOW] = 33,
|
||||||
|
[IRC_CTCP_COLORS_LIGHT_GREEN] = 92,
|
||||||
|
[IRC_CTCP_COLORS_CYAN] = 36,
|
||||||
|
[IRC_CTCP_COLORS_LIGHT_CYAN] = 96,
|
||||||
|
[IRC_CTCP_COLORS_LIGHT_BLUE] = 94,
|
||||||
|
[IRC_CTCP_COLORS_PINK] = 127,
|
||||||
|
[IRC_CTCP_COLORS_GREY] = 90,
|
||||||
|
[IRC_CTCP_COLORS_LIGHT_GREY] = 37,
|
||||||
|
[IRC_CTCP_COLORS_DEFAULT] = 39,
|
||||||
|
[16] = 52, /* See https://modern.ircdocs.horse/formatting.html */
|
||||||
|
[17] = 94,
|
||||||
|
[18] = 100,
|
||||||
|
[19] = 58,
|
||||||
|
[20] = 22,
|
||||||
|
[21] = 29,
|
||||||
|
[22] = 23,
|
||||||
|
[23] = 24,
|
||||||
|
[24] = 17,
|
||||||
|
[25] = 54,
|
||||||
|
[26] = 53,
|
||||||
|
[27] = 89,
|
||||||
|
[28] = 88,
|
||||||
|
[29] = 130,
|
||||||
|
[30] = 142,
|
||||||
|
[31] = 64,
|
||||||
|
[32] = 28,
|
||||||
|
[33] = 35,
|
||||||
|
[34] = 30,
|
||||||
|
[35] = 25,
|
||||||
|
[36] = 18,
|
||||||
|
[37] = 91,
|
||||||
|
[38] = 90,
|
||||||
|
[39] = 125,
|
||||||
|
[40] = 124,
|
||||||
|
[41] = 166,
|
||||||
|
[42] = 184,
|
||||||
|
[43] = 106,
|
||||||
|
[44] = 34,
|
||||||
|
[45] = 49,
|
||||||
|
[46] = 37,
|
||||||
|
[47] = 33,
|
||||||
|
[48] = 19,
|
||||||
|
[49] = 129,
|
||||||
|
[50] = 127,
|
||||||
|
[51] = 161,
|
||||||
|
[52] = 196,
|
||||||
|
[53] = 208,
|
||||||
|
[54] = 226,
|
||||||
|
[55] = 154,
|
||||||
|
[56] = 46,
|
||||||
|
[57] = 86,
|
||||||
|
[58] = 51,
|
||||||
|
[59] = 75,
|
||||||
|
[60] = 21,
|
||||||
|
[61] = 171,
|
||||||
|
[62] = 201,
|
||||||
|
[63] = 198,
|
||||||
|
[64] = 203,
|
||||||
|
[65] = 215,
|
||||||
|
[66] = 227,
|
||||||
|
[67] = 191,
|
||||||
|
[68] = 83,
|
||||||
|
[69] = 122,
|
||||||
|
[70] = 87,
|
||||||
|
[71] = 111,
|
||||||
|
[72] = 63,
|
||||||
|
[73] = 177,
|
||||||
|
[74] = 207,
|
||||||
|
[75] = 205,
|
||||||
|
[76] = 217,
|
||||||
|
[77] = 223,
|
||||||
|
[78] = 229,
|
||||||
|
[79] = 193,
|
||||||
|
[80] = 157,
|
||||||
|
[81] = 158,
|
||||||
|
[82] = 159,
|
||||||
|
[83] = 153,
|
||||||
|
[84] = 147,
|
||||||
|
[85] = 183,
|
||||||
|
[86] = 219,
|
||||||
|
[87] = 212,
|
||||||
|
[88] = 16,
|
||||||
|
[89] = 233,
|
||||||
|
[90] = 235,
|
||||||
|
[91] = 237,
|
||||||
|
[92] = 239,
|
||||||
|
[93] = 241,
|
||||||
|
[94] = 244,
|
||||||
|
[95] = 247,
|
||||||
|
[96] = 250,
|
||||||
|
[97] = 254,
|
||||||
|
[98] = 231,
|
||||||
|
};
|
||||||
|
|
||||||
|
// CTCP to RGB color mappings
|
||||||
|
static rgbcolor rgb_maps[] = {
|
||||||
|
[IRC_CTCP_COLORS_WHITE] = { 0xFF, 0xFF, 0xFF },
|
||||||
|
[IRC_CTCP_COLORS_BLACK] = { 0x00, 0x00, 0x00 },
|
||||||
|
[IRC_CTCP_COLORS_BLUE] = { 0x00, 0x00, 0x7F },
|
||||||
|
[IRC_CTCP_COLORS_GREEN] = { 0x00, 0x93, 0x00 },
|
||||||
|
[IRC_CTCP_COLORS_RED] = { 0xFF, 0x00, 0x00 },
|
||||||
|
[IRC_CTCP_COLORS_BROWN] = { 0x7F, 0x00, 0x00 },
|
||||||
|
[IRC_CTCP_COLORS_MAGENTA] = { 0x9C, 0x00, 0x9C },
|
||||||
|
[IRC_CTCP_COLORS_ORANGE] = { 0xFC, 0x7F, 0x00 },
|
||||||
|
[IRC_CTCP_COLORS_YELLOW] = { 0xFF, 0xFF, 0x00 },
|
||||||
|
[IRC_CTCP_COLORS_LIGHT_GREEN] = { 0x00, 0xFC, 0x00 },
|
||||||
|
[IRC_CTCP_COLORS_CYAN] = { 0x00, 0x93, 0x93 },
|
||||||
|
[IRC_CTCP_COLORS_LIGHT_CYAN] = { 0x00, 0xFF, 0xFF },
|
||||||
|
[IRC_CTCP_COLORS_LIGHT_BLUE] = { 0x00, 0x00, 0xFC },
|
||||||
|
[IRC_CTCP_COLORS_PINK] = { 0xFF, 0x00, 0xFF },
|
||||||
|
[IRC_CTCP_COLORS_GREY] = { 0x7F, 0x7F, 0x7F },
|
||||||
|
[IRC_CTCP_COLORS_LIGHT_GREY] = { 0xD2, 0xD2, 0xD2 },
|
||||||
|
[IRC_CTCP_COLORS_DEFAULT] = { 0xFF, 0xFF, 0xFF },
|
||||||
|
[16] = { 0x47, 0x00, 0x00 }, /* See https://modern.ircdocs.horse/formatting.html */
|
||||||
|
[17] = { 0x47, 0x21, 0x00 },
|
||||||
|
[18] = { 0x47, 0x47, 0x00 },
|
||||||
|
[19] = { 0x32, 0x47, 0x00 },
|
||||||
|
[20] = { 0x00, 0x47, 0x00 },
|
||||||
|
[21] = { 0x00, 0x47, 0x2c },
|
||||||
|
[22] = { 0x00, 0x47, 0x47 },
|
||||||
|
[23] = { 0x00, 0x27, 0x47 },
|
||||||
|
[24] = { 0x00, 0x00, 0x47 },
|
||||||
|
[25] = { 0x2e, 0x00, 0x47 },
|
||||||
|
[26] = { 0x47, 0x00, 0x47 },
|
||||||
|
[27] = { 0x47, 0x00, 0x2a },
|
||||||
|
[28] = { 0x74, 0x00, 0x00 },
|
||||||
|
[29] = { 0x74, 0x3a, 0x00 },
|
||||||
|
[30] = { 0x74, 0x74, 0x00 },
|
||||||
|
[31] = { 0x51, 0x74, 0x00 },
|
||||||
|
[32] = { 0x00, 0x74, 0x00 },
|
||||||
|
[33] = { 0x00, 0x74, 0x49 },
|
||||||
|
[34] = { 0x00, 0x74, 0x74 },
|
||||||
|
[35] = { 0x00, 0x40, 0x74 },
|
||||||
|
[36] = { 0x00, 0x00, 0x74 },
|
||||||
|
[37] = { 0x4b, 0x00, 0x74 },
|
||||||
|
[38] = { 0x74, 0x00, 0x74 },
|
||||||
|
[39] = { 0x74, 0x00, 0x45 },
|
||||||
|
[40] = { 0xb5, 0x00, 0x00 },
|
||||||
|
[41] = { 0xb5, 0x63, 0x00 },
|
||||||
|
[42] = { 0xb5, 0xb5, 0x00 },
|
||||||
|
[43] = { 0x7d, 0xb5, 0x00 },
|
||||||
|
[44] = { 0x00, 0xb5, 0x00 },
|
||||||
|
[45] = { 0x00, 0xb5, 0x71 },
|
||||||
|
[46] = { 0x00, 0xb5, 0xb5 },
|
||||||
|
[47] = { 0x00, 0x63, 0xb5 },
|
||||||
|
[48] = { 0x00, 0x00, 0xb5 },
|
||||||
|
[49] = { 0x75, 0x00, 0xb5 },
|
||||||
|
[50] = { 0xb5, 0x00, 0xb5 },
|
||||||
|
[51] = { 0xb5, 0x00, 0x6b },
|
||||||
|
[52] = { 0xff, 0x00, 0x00 },
|
||||||
|
[53] = { 0xff, 0x8c, 0x00 },
|
||||||
|
[54] = { 0xff, 0xff, 0x00 },
|
||||||
|
[55] = { 0xb2, 0xff, 0x00 },
|
||||||
|
[56] = { 0x00, 0xff, 0x00 },
|
||||||
|
[57] = { 0x00, 0xff, 0xa0 },
|
||||||
|
[58] = { 0x00, 0xff, 0xff },
|
||||||
|
[59] = { 0x00, 0x8c, 0xff },
|
||||||
|
[60] = { 0x00, 0x00, 0xff },
|
||||||
|
[61] = { 0xa5, 0x00, 0xff },
|
||||||
|
[62] = { 0xff, 0x00, 0xff },
|
||||||
|
[63] = { 0xff, 0x00, 0x98 },
|
||||||
|
[64] = { 0xff, 0x59, 0x59 },
|
||||||
|
[65] = { 0xff, 0xb4, 0x59 },
|
||||||
|
[66] = { 0xff, 0xff, 0x71 },
|
||||||
|
[67] = { 0xcf, 0xff, 0x60 },
|
||||||
|
[68] = { 0x6f, 0xff, 0x6f },
|
||||||
|
[69] = { 0x65, 0xff, 0xc9 },
|
||||||
|
[70] = { 0x6d, 0xff, 0xff },
|
||||||
|
[71] = { 0x59, 0xb4, 0xff },
|
||||||
|
[72] = { 0x59, 0x59, 0xff },
|
||||||
|
[73] = { 0xc4, 0x59, 0xff },
|
||||||
|
[74] = { 0xff, 0x66, 0xff },
|
||||||
|
[75] = { 0xff, 0x59, 0xbc },
|
||||||
|
[76] = { 0xff, 0x9c, 0x9c },
|
||||||
|
[77] = { 0xff, 0xd3, 0x9c },
|
||||||
|
[78] = { 0xff, 0xff, 0x9c },
|
||||||
|
[79] = { 0xe2, 0xff, 0x9c },
|
||||||
|
[80] = { 0x9c, 0xff, 0x9c },
|
||||||
|
[81] = { 0x9c, 0xff, 0xdb },
|
||||||
|
[82] = { 0x9c, 0xff, 0xff },
|
||||||
|
[83] = { 0x9c, 0xd3, 0xff },
|
||||||
|
[84] = { 0x9c, 0x9c, 0xff },
|
||||||
|
[85] = { 0xdc, 0x9c, 0xff },
|
||||||
|
[86] = { 0xff, 0x9c, 0xff },
|
||||||
|
[87] = { 0xff, 0x94, 0xd3 },
|
||||||
|
[88] = { 0x00, 0x00, 0x00 },
|
||||||
|
[89] = { 0x13, 0x13, 0x13 },
|
||||||
|
[90] = { 0x28, 0x28, 0x28 },
|
||||||
|
[91] = { 0x36, 0x36, 0x36 },
|
||||||
|
[92] = { 0x4d, 0x4d, 0x4d },
|
||||||
|
[93] = { 0x65, 0x65, 0x65 },
|
||||||
|
[94] = { 0x81, 0x81, 0x81 },
|
||||||
|
[95] = { 0x9f, 0x9f, 0x9f },
|
||||||
|
[96] = { 0xbc, 0xbc, 0xbc },
|
||||||
|
[97] = { 0xe2, 0xe2, 0xe2 },
|
||||||
|
[98] = { 0xff, 0xff, 0xff },
|
||||||
|
};
|
||||||
|
|
||||||
|
rgbcolor*
|
||||||
|
uirc_ctcp_to_rgb(uint_least8_t color)
|
||||||
|
{
|
||||||
|
if (color < sizeof(rgb_maps) / sizeof(rgbcolor)) return &rgb_maps[color];
|
||||||
|
return &rgb_maps[IRC_CTCP_RESET];
|
||||||
|
}
|
||||||
|
|
||||||
|
int_least8_t
|
||||||
|
IRC_CTCP_FORMAT(enum uirc_table_ctcp_formats fmt)
|
||||||
|
{
|
||||||
|
return ctcp_formats[fmt];
|
||||||
|
}
|
||||||
|
|
||||||
|
int_least8_t
|
||||||
|
IRC_CTCP_COLORS(enum uirc_table_ctcp_named_colors col)
|
||||||
|
{
|
||||||
|
return ctcp_named_colors[col];
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Write converters for ANSI
|
|
@ -16,7 +16,7 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "errors.h"
|
#include "error.h"
|
||||||
|
|
||||||
uirc_errno_t uirc_errno = UIRC_ERR_NERROR;
|
uirc_errno_t uirc_errno = UIRC_ERR_NERROR;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "types.h" // IRC_*
|
|
||||||
|
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
#include <corelibs/llist.h> // llist_t
|
#include <corelibs/llist.h> // llist_t
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "errors.h" // uirc_errno
|
#include "error.h" // uirc_errno
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "modes.h" // uirc_modes_*
|
#include "mode.h" // uirc_modes_*
|
||||||
#include "types.h" // IRC_*
|
#include "type.h" // IRC_*
|
||||||
|
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
#include <corelibs/stringext.h> // stringext_strmalloc()
|
#include <corelibs/stringext.h> // stringext_strmalloc()
|
||||||
|
|
|
@ -16,21 +16,32 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "modes.h"
|
#include "mode.h"
|
||||||
|
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
#include <ctype.h> // isalpha()
|
#include <ctype.h> // isalpha()
|
||||||
#include <inttypes.h> // int_least8_t
|
#include <inttypes.h> // int_least8_t
|
||||||
#include <stddef.h> //ptrdiff_t
|
#include <stdbool.h> // bool
|
||||||
|
#include <stddef.h> // ptrdiff_t
|
||||||
|
|
||||||
#if ('b' - 'a' != 1 || 'B' - 'A' != 1 || 'z' - 'a' != 25)
|
#if ('b' - 'a' != 1 || 'B' - 'A' != 1 || 'z' - 'a' != 25)
|
||||||
#error "System is not US-ASCII." // This is crucial for the conversions below
|
#error "System is not US-ASCII." // This is crucial for the conversions below
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const char mode_maps[] = {
|
||||||
|
[IRC_MODE_WALLOPS] = 'w', [IRC_MODE_INVISIBLE] = 'i', [IRC_MODE_AWAY] = 'a', [IRC_MODE_RESTRICTED] = 'r',
|
||||||
|
[IRC_MODE_OPERATOR] = 'o', [IRC_MODE_LOCALOPERATOR] = 'O', [IRC_MODE_SERVERNOTICES] = 's',
|
||||||
|
};
|
||||||
|
|
||||||
|
char
|
||||||
|
IRC_MODE(enum uirc_table_mode mode)
|
||||||
|
{
|
||||||
|
return mode_maps[mode];
|
||||||
|
}
|
||||||
|
|
||||||
static int_least8_t
|
static int_least8_t
|
||||||
uirc_mode_index(char mode)
|
uirc_mode_index(char mode)
|
||||||
{
|
{
|
||||||
assert(mode != NULL);
|
|
||||||
int_least8_t index = 0;
|
int_least8_t index = 0;
|
||||||
if (islower(mode)) {
|
if (islower(mode)) {
|
||||||
index += mode - 'a';
|
index += mode - 'a';
|
||||||
|
@ -94,3 +105,4 @@ uirc_mode_bmconv(IRC_Modes ms)
|
||||||
bitmask[i--] = (uirc_mode_fetch(IRC_MODE_INVISIBLE, ms)) ? '1' : '0';
|
bitmask[i--] = (uirc_mode_fetch(IRC_MODE_INVISIBLE, ms)) ? '1' : '0';
|
||||||
return bitmask;
|
return bitmask;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||||||
|
* Copyright (c) 2019-2021 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 "tag.h"
|
||||||
|
|
||||||
|
static const char* const irc_tag[] = {
|
||||||
|
[IRC_TAG_ACCOUNT] = "account", [IRC_TAG_BATCH] = "batch", [IRC_TAG_BOT] = "bot",
|
||||||
|
[IRC_TAG_LABEL] = "label", [IRC_TAG_MSGID] = "msgid", [IRC_TAG_MULTILINE] = "multiline-concat",
|
||||||
|
[IRC_TAG_TIME] = "time", [IRC_TAG_REACT] = "react", [IRC_TAG_REPLY] = "reply",
|
||||||
|
[IRC_TAG_TYPING] = "typing",
|
||||||
|
};
|
||||||
|
|
||||||
|
const char*
|
||||||
|
IRC_TAG(enum uirc_table_tag tag)
|
||||||
|
{
|
||||||
|
return irc_tag[tag];
|
||||||
|
}
|
|
@ -29,7 +29,10 @@ main(void)
|
||||||
{
|
{
|
||||||
const char* str[] = { ":buddy@hostnet.com PRIVMSG #general :login hunter12\r\n",
|
const char* str[] = { ":buddy@hostnet.com PRIVMSG #general :login hunter12\r\n",
|
||||||
"NOTICE * :nice cock bro\r\n",
|
"NOTICE * :nice cock bro\r\n",
|
||||||
"@day=13;willtolive=0 PRIVMSG you :helo\r\n",
|
#ifdef UIRC_FEATURE_IRCV3
|
||||||
|
"@day=13;willtolive=0 "
|
||||||
|
#endif /* UIRC_FEATURE_IRCV3 */
|
||||||
|
"PRIVMSG you :helo\r\n",
|
||||||
":mom!mother@localhost NOTICE #netadmin :johnny, your pizza is done\r\n",
|
":mom!mother@localhost NOTICE #netadmin :johnny, your pizza is done\r\n",
|
||||||
"NOTICE after 14 arguments the trailing starts early so there's no need for a colon hmm interesting really\r\n" };
|
"NOTICE after 14 arguments the trailing starts early so there's no need for a colon hmm interesting really\r\n" };
|
||||||
|
|
|
@ -31,6 +31,7 @@ int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
IRC_Message* m = uirc_struct_assm_message("NONE", false, 0);
|
IRC_Message* m = uirc_struct_assm_message("NONE", false, 0);
|
||||||
|
#ifdef UIRC_FEATURE_IRCV3
|
||||||
m->tag_list = uirc_list_append(NULL, uirc_struct_assm_tag(false, TAGKEY, TAGVAL));
|
m->tag_list = uirc_list_append(NULL, uirc_struct_assm_tag(false, TAGKEY, TAGVAL));
|
||||||
uirc_list_append(m->tag_list, uirc_struct_assm_tag(false, TAGKEY2, NULL));
|
uirc_list_append(m->tag_list, uirc_struct_assm_tag(false, TAGKEY2, NULL));
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ main(void)
|
||||||
fprintf(stderr, "List allocator didn't allocate things right\n");
|
fprintf(stderr, "List allocator didn't allocate things right\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
#endif /* UIRC_FEATURE_IRCV3 */
|
||||||
|
|
||||||
print_irc_message(m);
|
print_irc_message(m);
|
||||||
uirc_struct_free(m, IRC_STRUCT_MESSAGE);
|
uirc_struct_free(m, IRC_STRUCT_MESSAGE);
|
|
@ -16,7 +16,7 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "modes.h" // uirc_mode_*() IRC_Modes
|
#include "uirc.h" // uirc_mode_*() IRC_Modes
|
||||||
|
|
||||||
#include <stdio.h> // fprintf() stderr
|
#include <stdio.h> // fprintf() stderr
|
||||||
#include <stdlib.h> // EXIT_*
|
#include <stdlib.h> // EXIT_*
|
||||||
|
@ -25,7 +25,7 @@ int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
IRC_Modes modes, cpymodes;
|
IRC_Modes modes, cpymodes;
|
||||||
if (!uirc_mode_enable('a', modes) || !modes[0]) {
|
if (!uirc_mode_enable(IRC_MODE(IRC_MODE_OPERATOR), modes) || !modes[14]) {
|
||||||
fprintf(stderr, "Mode enable didn't work or mode was invalid\n");
|
fprintf(stderr, "Mode enable didn't work or mode was invalid\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -34,15 +34,15 @@ main(void)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
uirc_mode_copy(cpymodes, modes);
|
uirc_mode_copy(cpymodes, modes);
|
||||||
if (!cpymodes[0] || !cpymodes[25]) {
|
if (!cpymodes[14] || !cpymodes[25]) {
|
||||||
fprintf(stderr, "Mode copy didn't work\n");
|
fprintf(stderr, "Mode copy didn't work\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (!uirc_mode_toggle('a', modes) || modes[0]) {
|
if (!uirc_mode_toggle(IRC_MODE(IRC_MODE_OPERATOR), modes) || modes[14]) {
|
||||||
fprintf(stderr, "Mode toggle didn't work or mode was invalid\n");
|
fprintf(stderr, "Mode toggle didn't work or mode was invalid\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (!uirc_mode_disable('a', cpymodes) || cpymodes[0]) {
|
if (!uirc_mode_disable(IRC_MODE(IRC_MODE_OPERATOR), cpymodes) || cpymodes[14]) {
|
||||||
fprintf(stderr, "Mode disable didn't work or mode was invalid\n");
|
fprintf(stderr, "Mode disable didn't work or mode was invalid\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -50,5 +50,9 @@ main(void)
|
||||||
fprintf(stderr, "Mode was toggled off incorrectly\n");
|
fprintf(stderr, "Mode was toggled off incorrectly\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (!uirc_mode_disable('A', cpymodes) || cpymodes[25]) {
|
||||||
|
fprintf(stderr, "Mode disable didn't work or mode was invalid\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
|
@ -16,10 +16,10 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "errors.h" // uirc_errno
|
#include "error.h" // uirc_errno
|
||||||
#include "memory.h" // uirc_memory_*()
|
#include "memory.h" // uirc_memory_*()
|
||||||
#include "tokenizers.h" // uirc_tokenizer_*()
|
#include "tokenizer.h" // uirc_tokenizer_*()
|
||||||
#include "types.h" // IRC_Message
|
#include "type.h" // IRC_Message
|
||||||
|
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
#include <corelibs/stringext.h> // stringext_strmalloc() stringext_strtok_mr()
|
#include <corelibs/stringext.h> // stringext_strmalloc() stringext_strtok_mr()
|
||||||
|
@ -110,7 +110,7 @@ uirc_tokenizer_message(const char* str)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
const char* tmp = NULL;
|
const char* tmp = NULL;
|
||||||
if ((tmp = stringext_strtok_mr(&p, " ")) == NULL) {
|
if ((tmp = stringext_strtok_mr(&p, " ")) == NULL) {
|
||||||
uirc_errno = UIRC_ERR_INVFMT;
|
uirc_errno = UIRC_ERR_INVFMT;
|
||||||
|
@ -121,7 +121,6 @@ uirc_tokenizer_message(const char* str)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
skip_spaces(&p);
|
skip_spaces(&p);
|
||||||
}
|
|
||||||
if (i < IRC_MAXARGS) m->args[i] = NULL;
|
if (i < IRC_MAXARGS) m->args[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "errors.h" // uirc_errno
|
#include "error.h" // uirc_errno
|
||||||
#include "memory.h" // Free_IRC_Tag()
|
#include "memory.h" // Free_IRC_Tag()
|
||||||
#include "tokenizers.h" // uirc_tokenizer_tags()
|
#include "tokenizer.h" // uirc_tokenizer_tags()
|
||||||
#include "types.h" // IRC_Tag
|
#include "type.h" // IRC_Tag
|
||||||
|
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
#include <corelibs/llist.h> // llist_elem_alloc() llist_elem_conn() llist_elem_rm()
|
#include <corelibs/llist.h> // llist_elem_alloc() llist_elem_conn() llist_elem_rm()
|
|
@ -16,10 +16,10 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "errors.h" // uirc_errno
|
#include "error.h" // uirc_errno
|
||||||
#include "memory.h" // uirc_memory_*()
|
#include "memory.h" // uirc_memory_*()
|
||||||
#include "tokenizers.h" // uirc_tokenizer_*()
|
#include "tokenizer.h" // uirc_tokenizer_*()
|
||||||
#include "types.h" // IRC_Message
|
#include "type.h" // IRC_Message
|
||||||
|
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
#include <corelibs/stringext.h> // stringext_strmalloc()
|
#include <corelibs/stringext.h> // stringext_strmalloc()
|
|
@ -16,7 +16,7 @@
|
||||||
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "validators.h"
|
#include "validator.h"
|
||||||
|
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
#include <stdio.h> // NULL
|
#include <stdio.h> // NULL
|
Reference in New Issue