diff --git a/extensions/hurt.c b/extensions/hurt.c index f976aa7a7..c3eb971a3 100644 --- a/extensions/hurt.c +++ b/extensions/hurt.c @@ -18,6 +18,7 @@ #include "s_newconf.h" #include "hash.h" #include "messages.h" +#include "s_assert.h" /* {{{ Structures */ #define HURT_CUTOFF (10) /* protocol messages. */ diff --git a/extensions/m_mkpasswd.c b/extensions/m_mkpasswd.c index 43c6d799e..e0cdfe981 100644 --- a/extensions/m_mkpasswd.c +++ b/extensions/m_mkpasswd.c @@ -11,6 +11,7 @@ #include "s_conf.h" #include "modules.h" #include "messages.h" +#include "send.h" #include diff --git a/extensions/m_okick.c b/extensions/m_okick.c index 34f426bb7..50a2b7c9f 100644 --- a/extensions/m_okick.c +++ b/extensions/m_okick.c @@ -38,6 +38,7 @@ #include "s_conf.h" #include "s_serv.h" #include "messages.h" +#include "logger.h" static int mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); diff --git a/extensions/m_omode.c b/extensions/m_omode.c index a1495f696..418ed2148 100644 --- a/extensions/m_omode.c +++ b/extensions/m_omode.c @@ -42,6 +42,7 @@ #include "modules.h" #include "packet.h" #include "messages.h" +#include "logger.h" static int mo_omode(struct Client *, struct Client *, int, const char **); diff --git a/include/ircd_defs.h b/include/ircd_defs.h index 071c92f0f..a3f73b527 100644 --- a/include/ircd_defs.h +++ b/include/ircd_defs.h @@ -59,37 +59,6 @@ #define IRC_DEPRECATED #endif -#include "logger.h" -#include "send.h" - -#ifdef SOFT_ASSERT -#ifdef __GNUC__ -#define s_assert(expr) do \ - if(!(expr)) { \ - ilog(L_MAIN, \ - "file: %s line: %d (%s): Assertion failed: (%s)", \ - __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \ - sendto_realops_snomask(SNO_GENERAL, L_ALL, \ - "file: %s line: %d (%s): Assertion failed: (%s)", \ - __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \ - } \ - while(0) -#else -#define s_assert(expr) do \ - if(!(expr)) { \ - ilog(L_MAIN, \ - "file: %s line: %d: Assertion failed: (%s)", \ - __FILE__, __LINE__, #expr); \ - sendto_realops_snomask(SNO_GENERAL, L_ALL, \ - "file: %s line: %d: Assertion failed: (%s)" \ - __FILE__, __LINE__, #expr); \ - } \ - while(0) -#endif -#else -#define s_assert(expr) assert(expr) -#endif - #if !defined(CONFIG_RATBOX_LEVEL_1) # error Incorrect config.h for this revision of ircd. #endif diff --git a/include/s_assert.h b/include/s_assert.h new file mode 100644 index 000000000..60ea28cd4 --- /dev/null +++ b/include/s_assert.h @@ -0,0 +1,64 @@ +/* + * charybdis: An advanced IRCd. + * s_assert.h: Definition of the soft assert (s_assert) macro. + * + * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center + * Copyright (C) 1996-2002 Hybrid Development Team + * Copyright (C) 2002-2004 ircd-ratbox development team + * Copyright (C) 2005-2013 Charybdis development team + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#ifndef INCLUDED_s_assert_h +#define INCLUDED_s_assert_h + +#include "config.h" + +#ifdef SOFT_ASSERT + +#include "logger.h" +#include "send.h" +#include "snomask.h" + +#ifdef __GNUC__ +#define s_assert(expr) do \ + if(!(expr)) { \ + ilog(L_MAIN, \ + "file: %s line: %d (%s): Assertion failed: (%s)", \ + __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \ + sendto_realops_snomask(SNO_GENERAL, L_ALL, \ + "file: %s line: %d (%s): Assertion failed: (%s)", \ + __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \ + } \ + while(0) +#else +#define s_assert(expr) do \ + if(!(expr)) { \ + ilog(L_MAIN, \ + "file: %s line: %d: Assertion failed: (%s)", \ + __FILE__, __LINE__, #expr); \ + sendto_realops_snomask(SNO_GENERAL, L_ALL, \ + "file: %s line: %d: Assertion failed: (%s)" \ + __FILE__, __LINE__, #expr); \ + } \ + while(0) +#endif +#else +#define s_assert(expr) assert(expr) +#endif + +#endif /* INCLUDED_s_assert_h */ diff --git a/include/tgchange.h b/include/tgchange.h index b2cc684ca..7e9bd052c 100644 --- a/include/tgchange.h +++ b/include/tgchange.h @@ -25,6 +25,8 @@ #define INCLUDED_tgchange_h #include "ircd_defs.h" +#include "client.h" +#include "channel.h" /* finds a channel where source_p has op or voice and target_p is a member */ struct Channel *find_allowing_channel(struct Client *source_p, struct Client *target_p); diff --git a/modules/core/m_ban.c b/modules/core/m_ban.c index ebc5152c8..7a2a59bd2 100644 --- a/modules/core/m_ban.c +++ b/modules/core/m_ban.c @@ -44,6 +44,7 @@ #include "operhash.h" #include "reject.h" #include "hostmask.h" +#include "logger.h" static int m_ban(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); static int ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); diff --git a/modules/core/m_join.c b/modules/core/m_join.c index ead5e38c5..e8db2d7c3 100644 --- a/modules/core/m_join.c +++ b/modules/core/m_join.c @@ -42,6 +42,7 @@ #include "packet.h" #include "chmode.h" #include "ratelimit.h" +#include "s_assert.h" static int m_join(struct Client *, struct Client *, int, const char **); static int ms_join(struct Client *, struct Client *, int, const char **); diff --git a/modules/core/m_nick.c b/modules/core/m_nick.c index 6d26fbf54..1cff2842c 100644 --- a/modules/core/m_nick.c +++ b/modules/core/m_nick.c @@ -47,6 +47,7 @@ #include "scache.h" #include "s_newconf.h" #include "monitor.h" +#include "s_assert.h" /* Give all UID nicks the same TS. This ensures nick TS is always the same on * all servers for each nick-user pair, also if a user with a UID nick changes diff --git a/modules/m_cap.c b/modules/m_cap.c index 7abfa9fe6..5e46ed536 100644 --- a/modules/m_cap.c +++ b/modules/m_cap.c @@ -41,6 +41,7 @@ #include "modules.h" #include "s_serv.h" #include "s_user.h" +#include "send.h" typedef int (*bqcmp)(const void *, const void *); diff --git a/modules/m_etrace.c b/modules/m_etrace.c index 9441a0ee4..2c40c5e8c 100644 --- a/modules/m_etrace.c +++ b/modules/m_etrace.c @@ -49,6 +49,7 @@ #include "msg.h" #include "parse.h" #include "modules.h" +#include "logger.h" static int mo_etrace(struct Client *, struct Client *, int, const char **); static int me_etrace(struct Client *, struct Client *, int, const char **); diff --git a/modules/m_links.c b/modules/m_links.c index bc28ad8bc..92fd2d988 100644 --- a/modules/m_links.c +++ b/modules/m_links.c @@ -37,6 +37,7 @@ #include "modules.h" #include "hook.h" #include "scache.h" +#include "s_assert.h" static int m_links(struct Client *, struct Client *, int, const char **); static int mo_links(struct Client *, struct Client *, int, const char **); diff --git a/modules/m_list.c b/modules/m_list.c index 2737282fb..4947246d0 100644 --- a/modules/m_list.c +++ b/modules/m_list.c @@ -49,6 +49,8 @@ #include "parse.h" #include "modules.h" #include "inline/stringops.h" +#include "s_assert.h" +#include "logger.h" static rb_dlink_list safelisting_clients = { NULL, NULL, 0 }; diff --git a/modules/m_monitor.c b/modules/m_monitor.c index a6ce57551..f230fa92b 100644 --- a/modules/m_monitor.c +++ b/modules/m_monitor.c @@ -38,6 +38,7 @@ #include "monitor.h" #include "numeric.h" #include "s_conf.h" +#include "send.h" static int m_monitor(struct Client *, struct Client *, int, const char **); diff --git a/modules/m_operspy.c b/modules/m_operspy.c index 520a25de6..0ea5a7f17 100644 --- a/modules/m_operspy.c +++ b/modules/m_operspy.c @@ -42,6 +42,7 @@ #include "msg.h" #include "parse.h" #include "modules.h" +#include "logger.h" static int ms_operspy(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); diff --git a/modules/m_scan.c b/modules/m_scan.c index ccc1d024f..79ed616c5 100644 --- a/modules/m_scan.c +++ b/modules/m_scan.c @@ -49,6 +49,7 @@ #include "msg.h" #include "parse.h" #include "modules.h" +#include "logger.h" static int mo_scan(struct Client *, struct Client *, int, const char **); static int scan_umodes(struct Client *, struct Client *, int, const char **); diff --git a/modules/m_starttls.c b/modules/m_starttls.c index 6159cac52..e9bf63188 100644 --- a/modules/m_starttls.c +++ b/modules/m_starttls.c @@ -29,6 +29,8 @@ #include "msg.h" #include "modules.h" #include "sslproc.h" +#include "s_assert.h" +#include "logger.h" static int mr_starttls(struct Client *, struct Client *, int, const char **); diff --git a/modules/m_topic.c b/modules/m_topic.c index 9effb2abf..5818c400c 100644 --- a/modules/m_topic.c +++ b/modules/m_topic.c @@ -40,6 +40,7 @@ #include "modules.h" #include "packet.h" #include "tgchange.h" +#include "logger.h" static int m_topic(struct Client *, struct Client *, int, const char **); static int ms_topic(struct Client *, struct Client *, int, const char **); diff --git a/modules/m_user.c b/modules/m_user.c index f46ec8b42..f258007d8 100644 --- a/modules/m_user.c +++ b/modules/m_user.c @@ -36,6 +36,7 @@ #include "parse.h" #include "modules.h" #include "blacklist.h" +#include "s_assert.h" static int mr_user(struct Client *, struct Client *, int, const char **); diff --git a/modules/m_whois.c b/modules/m_whois.c index 65b169b0f..b02aa1d5b 100644 --- a/modules/m_whois.c +++ b/modules/m_whois.c @@ -45,6 +45,7 @@ #include "s_newconf.h" #include "ipv4_from_ipv6.h" #include "ratelimit.h" +#include "s_assert.h" static void do_whois(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); static void single_whois(struct Client *source_p, struct Client *target_p, int operspy); diff --git a/src/blacklist.c b/src/blacklist.c index 8f4f09a66..ef8a1d1ca 100644 --- a/src/blacklist.c +++ b/src/blacklist.c @@ -40,6 +40,7 @@ #include "s_conf.h" #include "s_user.h" #include "blacklist.h" +#include "send.h" rb_dlink_list blacklist_list = { NULL, NULL, 0 }; diff --git a/src/cache.c b/src/cache.c index 9941b3301..01eefbc4c 100644 --- a/src/cache.c +++ b/src/cache.c @@ -41,6 +41,7 @@ #include "cache.h" #include "irc_dictionary.h" #include "numeric.h" +#include "send.h" struct cachefile *user_motd = NULL; struct cachefile *oper_motd = NULL; diff --git a/src/capability.c b/src/capability.c index 7ffb3d87d..e924e7a70 100644 --- a/src/capability.c +++ b/src/capability.c @@ -21,6 +21,7 @@ #include "stdinc.h" #include "capability.h" #include "irc_dictionary.h" +#include "s_assert.h" static rb_dlink_list capability_indexes = { NULL, NULL, 0 }; diff --git a/src/channel.c b/src/channel.c index e3595d014..824ab0add 100644 --- a/src/channel.c +++ b/src/channel.c @@ -42,6 +42,7 @@ #include "s_newconf.h" #include "logger.h" #include "ipv4_from_ipv6.h" +#include "s_assert.h" struct config_channel_entry ConfigChannel; rb_dlink_list global_channel_list; diff --git a/src/chmode.c b/src/chmode.c index 1191fe9d5..9dd562be1 100644 --- a/src/chmode.c +++ b/src/chmode.c @@ -42,6 +42,7 @@ #include "s_newconf.h" #include "logger.h" #include "chmode.h" +#include "s_assert.h" /* bitmasks for error returns, so we send once per call */ #define SM_ERR_NOTS 0x00000001 /* No TS on channel */ diff --git a/src/client.c b/src/client.c index 0612dedde..7fbfc4e50 100644 --- a/src/client.c +++ b/src/client.c @@ -55,6 +55,7 @@ #include "scache.h" #include "irc_dictionary.h" #include "sslproc.h" +#include "s_assert.h" #define DEBUG_EXITED_CLIENTS diff --git a/src/hash.c b/src/hash.c index 5386856b7..6ee494f26 100644 --- a/src/hash.c +++ b/src/hash.c @@ -38,6 +38,7 @@ #include "msg.h" #include "cache.h" #include "s_newconf.h" +#include "s_assert.h" #define hash_cli_fd(x) (x % CLI_FD_MAX) diff --git a/src/irc_dictionary.c b/src/irc_dictionary.c index 89a0a7bb7..151a874cf 100644 --- a/src/irc_dictionary.c +++ b/src/irc_dictionary.c @@ -27,6 +27,8 @@ #include "client.h" #include "setup.h" #include "irc_dictionary.h" +#include "s_assert.h" +#include "logger.h" static rb_bh *elem_heap = NULL; diff --git a/src/listener.c b/src/listener.c index 3e4965c38..e71921cd2 100644 --- a/src/listener.c +++ b/src/listener.c @@ -42,6 +42,8 @@ #include "hostmask.h" #include "sslproc.h" #include "hash.h" +#include "s_assert.h" +#include "logger.h" #ifndef INADDR_NONE #define INADDR_NONE ((unsigned int) 0xffffffff) diff --git a/src/match.c b/src/match.c index 5c07c34a1..a9d3a6a2e 100644 --- a/src/match.c +++ b/src/match.c @@ -24,6 +24,7 @@ #include "client.h" #include "ircd.h" #include "match.h" +#include "s_assert.h" /* * Compare if a given string (name) matches the given diff --git a/src/monitor.c b/src/monitor.c index 280ef5946..36cd401b9 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -36,6 +36,7 @@ #include "monitor.h" #include "hash.h" #include "numeric.h" +#include "send.h" struct monitor *monitorTable[MONITOR_HASH_SIZE]; static rb_bh *monitor_heap; diff --git a/src/packet.c b/src/packet.c index 73f08c18a..156449b41 100644 --- a/src/packet.c +++ b/src/packet.c @@ -34,6 +34,7 @@ #include "match.h" #include "hook.h" #include "send.h" +#include "s_assert.h" static char readBuf[READBUF_SIZE]; static void client_dopacket(struct Client *client_p, char *buffer, size_t length); diff --git a/src/parse.c b/src/parse.c index 5ff29f052..44dfd64e4 100644 --- a/src/parse.c +++ b/src/parse.c @@ -41,6 +41,7 @@ #include "s_conf.h" #include "s_serv.h" #include "packet.h" +#include "s_assert.h" static struct Dictionary *cmd_dict = NULL; struct Dictionary *alias_dict = NULL; diff --git a/src/privilege.c b/src/privilege.c index 6b2c8b703..c082cbcae 100644 --- a/src/privilege.c +++ b/src/privilege.c @@ -25,6 +25,9 @@ #include "s_conf.h" #include "privilege.h" #include "numeric.h" +#include "s_assert.h" +#include "logger.h" +#include "send.h" static rb_dlink_list privilegeset_list = {}; diff --git a/src/ratelimit.c b/src/ratelimit.c index ce9efc0bc..7ef7c0106 100644 --- a/src/ratelimit.c +++ b/src/ratelimit.c @@ -25,6 +25,7 @@ #include "s_conf.h" #include "s_stats.h" #include "ratelimit.h" +#include "s_assert.h" /* * ratelimit_client(struct Client *client_p, int penalty) diff --git a/src/res.c b/src/res.c index e84e112c9..3093b0f2b 100644 --- a/src/res.c +++ b/src/res.c @@ -40,6 +40,9 @@ #include "match.h" #include "numeric.h" #include "client.h" /* SNO_* */ +#include "s_assert.h" +#include "logger.h" +#include "send.h" #if (CHAR_BIT != 8) #error this code needs to be able to address individual octets diff --git a/src/reslib.c b/src/reslib.c index f62c139a3..a4bdcd668 100644 --- a/src/reslib.c +++ b/src/reslib.c @@ -83,6 +83,7 @@ #include "res.h" #include "reslib.h" #include "match.h" +#include "logger.h" #define NS_TYPE_ELT 0x40 /* EDNS0 extended label type */ #define DNS_LABELTYPE_BITSTRING 0x41 diff --git a/src/s_auth.c b/src/s_auth.c index 0ff5e1918..a7a401a9f 100644 --- a/src/s_auth.c +++ b/src/s_auth.c @@ -49,6 +49,7 @@ #include "send.h" #include "hook.h" #include "blacklist.h" +#include "s_assert.h" struct AuthRequest { diff --git a/src/s_conf.c b/src/s_conf.c index ee3271179..57c32fc44 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -53,6 +53,7 @@ #include "operhash.h" #include "chmode.h" #include "hook.h" +#include "s_assert.h" struct config_server_hide ConfigServerHide; diff --git a/src/s_newconf.c b/src/s_newconf.c index f7590b219..bcf5b84f0 100644 --- a/src/s_newconf.c +++ b/src/s_newconf.c @@ -44,6 +44,8 @@ #include "newconf.h" #include "hash.h" #include "irc_dictionary.h" +#include "s_assert.h" +#include "logger.h" rb_dlink_list shared_conf_list; rb_dlink_list cluster_conf_list; diff --git a/src/s_serv.c b/src/s_serv.c index 7cb1715d8..1efc7eb05 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -55,6 +55,7 @@ #include "reject.h" #include "sslproc.h" #include "capability.h" +#include "s_assert.h" #ifndef INADDR_NONE #define INADDR_NONE ((unsigned int) 0xffffffff) diff --git a/src/s_user.c b/src/s_user.c index 929731729..48b30d512 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -54,6 +54,7 @@ #include "blacklist.h" #include "substitution.h" #include "chmode.h" +#include "s_assert.h" static void report_and_set_user_flags(struct Client *, struct ConfItem *); void user_welcome(struct Client *source_p); diff --git a/src/scache.c b/src/scache.c index ff8c9fac5..1cda0033a 100644 --- a/src/scache.c +++ b/src/scache.c @@ -33,6 +33,7 @@ #include "send.h" #include "scache.h" #include "s_conf.h" +#include "s_assert.h" /* diff --git a/src/substitution.c b/src/substitution.c index 708dce23c..bb935510f 100644 --- a/src/substitution.c +++ b/src/substitution.c @@ -38,6 +38,7 @@ #include "snomask.h" #include "match.h" #include "substitution.h" +#include "s_assert.h" /* * Simple mappings for $foo -> 'bar'. diff --git a/src/supported.c b/src/supported.c index 8133d548c..fef441cff 100644 --- a/src/supported.c +++ b/src/supported.c @@ -81,6 +81,7 @@ #include "s_user.h" #include "supported.h" #include "chmode.h" +#include "send.h" rb_dlink_list isupportlist; diff --git a/src/tgchange.c b/src/tgchange.c index 547eb5fb6..72cad10bf 100644 --- a/src/tgchange.c +++ b/src/tgchange.c @@ -30,6 +30,7 @@ #include "hash.h" #include "s_newconf.h" #include "s_serv.h" +#include "send.h" static int add_hashed_target(struct Client *source_p, uint32_t hashv); diff --git a/src/whowas.c b/src/whowas.c index 41dc9950e..aafe91b48 100644 --- a/src/whowas.c +++ b/src/whowas.c @@ -39,6 +39,7 @@ #include "send.h" #include "s_conf.h" #include "scache.h" +#include "s_assert.h" /* internally defined function */ static void add_whowas_to_clist(struct Whowas **, struct Whowas *);