From 7cea4c784d63c4444f10e06d793a29e0d8cb8d18 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 12 Jul 2016 22:22:05 -0700 Subject: [PATCH] ircd: Merge the defaults/ircd_defs stuff for now. ircd/rb: Move some lowish level macros down to rb. --- include/ircd/defaults.h | 162 +++++++++++++++++++++++++-------------- include/ircd/ircd_defs.h | 120 ----------------------------- include/ircd/logger.h | 2 +- include/ircd/s_conf.h | 1 - include/ircd/send.h | 1 - include/ircd/stdinc.h | 60 +-------------- include/ircd/tgchange.h | 2 +- include/rb/system.h | 42 ++++++++++ ircd/authproc.c | 1 - ircd/ircd_lexer.l | 2 - ircd/s_serv.c | 1 - modules/m_whowas.c | 1 - 12 files changed, 151 insertions(+), 244 deletions(-) delete mode 100644 include/ircd/ircd_defs.h diff --git a/include/ircd/defaults.h b/include/ircd/defaults.h index d31c78919..ff95af06b 100644 --- a/include/ircd/defaults.h +++ b/include/ircd/defaults.h @@ -22,39 +22,14 @@ * USA */ -#ifndef INCLUDED_defaults_h -#define INCLUDED_defaults_h +#ifndef _IRCD_SYSTEM_H +#define _IRCD_SYSTEM_H /* /!\ DANGER WILL ROBINSON! DANGER! /!\ * * Do not mess with these values unless you know what you are doing! */ -#include "stdinc.h" - -/* Below are the elements for default paths. */ -typedef enum { - IRCD_PATH_PREFIX, - IRCD_PATH_MODULES, - IRCD_PATH_AUTOLOAD_MODULES, - IRCD_PATH_ETC, - IRCD_PATH_LOG, - IRCD_PATH_USERHELP, - IRCD_PATH_OPERHELP, - IRCD_PATH_IRCD_EXEC, - IRCD_PATH_IRCD_CONF, - IRCD_PATH_IRCD_MOTD, - IRCD_PATH_IRCD_LOG, - IRCD_PATH_IRCD_PID, - IRCD_PATH_IRCD_OMOTD, - IRCD_PATH_BANDB, - IRCD_PATH_BIN, - IRCD_PATH_LIBEXEC, - IRCD_PATH_COUNT -} ircd_path_t; - -extern const char *ircd_paths[IRCD_PATH_COUNT]; - /* The below are used as defaults if not found in the configuration file (or on ircd warm-up). * Don't change these - edit the conf file instead. */ @@ -87,35 +62,51 @@ extern const char *ircd_paths[IRCD_PATH_COUNT]; #define MIN_SPAM_NUM 5 #define MIN_SPAM_TIME 60 -/* - * Directory paths and filenames for UNIX systems. - * IRCD_PREFIX is set using ./configure --prefix, see INSTALL. - * Do not change these without corresponding changes in the build system. - * - * IRCD_PREFIX = prefix for all directories, - * DPATH = root directory of installation, - * BINPATH = directory for binary files, - * ETCPATH = directory for configuration files, - * LOGPATH = directory for logfiles, - * MODPATH = directory for modules, - * AUTOMODPATH = directory for autoloaded modules - */ -#define DPATH IRCD_PREFIX -#define BINPATH IRCD_PREFIX "/bin" -#define MODPATH MODULE_DIR -#define AUTOMODPATH MODULE_DIR "/autoload" -#define ETCPATH ETC_DIR -#define LOGPATH LOG_DIR -#define UHPATH HELP_DIR "/users" -#define HPATH HELP_DIR "/opers" -#define SPATH BINPATH "/" PROGRAM_PREFIX "/" BRANDING_NAME /* ircd executable */ -#define CPATH ETCPATH "/ircd.conf" /* ircd.conf file */ -#define MPATH ETCPATH "/ircd.motd" /* MOTD file */ -#define LPATH LOGPATH "/ircd.log" /* ircd logfile */ -#define PPATH PKGRUNDIR "/ircd.pid" /* pid file */ -#define OPATH ETCPATH "/opers.motd" /* oper MOTD file */ -#define DBPATH PKGLOCALSTATEDIR "/ban.db" /* bandb file */ + +#define HOSTLEN 63 /* Length of hostname. Updated to */ + /* comply with RFC1123 */ + +/* Longest hostname we're willing to work with. + * Due to DNSBLs this is more than HOSTLEN. + */ +#define IRCD_RES_HOSTLEN 255 + +#define USERLEN 10 +#define REALLEN 50 +#define CHANNELLEN 200 +#define LOC_CHANNELLEN 50 + +/* reason length of klines, parts, quits etc */ +/* for quit messages, note that a client exit server notice + * :012345678901234567890123456789012345678901234567890123456789123 NOTICE * :*** Notice -- Client exiting: 012345678901234567 (0123456789@012345678901234567890123456789012345678901234567890123456789123) [] [1111:2222:3333:4444:5555:6666:7777:8888] + * takes at most 246 bytes (including CRLF and '\0') and together with the + * quit reason should fit in 512 */ +#define REASONLEN 260 /* kick/part/quit */ +#define BANREASONLEN 390 /* kline/dline */ +#define AWAYLEN TOPICLEN +#define KILLLEN 200 /* with Killed (nick ()) added this should fit in quit */ + +/* 23+1 for \0 */ +#define KEYLEN 24 +#define BUFSIZE 512 /* WARNING: *DONT* CHANGE THIS!!!! */ +#define OPERNICKLEN (NICKLEN*2) /* Length of OPERNICKs. */ + +#define USERHOST_REPLYLEN (NICKLEN+HOSTLEN+USERLEN+5) +#define MAX_DATE_STRING 32 /* maximum string length for a date string */ + +#define HELPLEN 400 + +/* + * message return values + */ +#define CLIENT_EXITED -2 +#define CLIENT_PARSE_ERROR -1 +#define CLIENT_OK 1 + +/* Read buffer size */ +#define READBUF_SIZE 16384 + /* Below are somewhat configurable settings (though it's probably a bad idea * to blindly mess with them). If in any doubt, leave them alone. @@ -153,4 +144,63 @@ extern const char *ircd_paths[IRCD_PATH_COUNT]; # define SOMAXCONN 25 #endif -#endif /* INCLUDED_defaults_h */ + +/* + * Directory paths and filenames for UNIX systems. + * IRCD_PREFIX is set using ./configure --prefix, see INSTALL. + * Do not change these without corresponding changes in the build system. + * + * IRCD_PREFIX = prefix for all directories, + * DPATH = root directory of installation, + * BINPATH = directory for binary files, + * ETCPATH = directory for configuration files, + * LOGPATH = directory for logfiles, + * MODPATH = directory for modules, + * AUTOMODPATH = directory for autoloaded modules + */ + +#define DPATH IRCD_PREFIX +#define BINPATH IRCD_PREFIX "/bin" +#define MODPATH RB_MODULE_DIR +#define MODULE_DIR RB_MODULE_DIR +#define AUTOMODPATH RB_MODULE_DIR "/autoload" +#define ETCPATH RB_ETC_DIR "/charybdis" +#define LOGPATH RB_LOG_DIR +#define UHPATH RB_HELP_DIR "/users" +#define HPATH RB_HELP_DIR "/opers" +#define SPATH RB_BIN_DIR "/" BRANDING_NAME /* ircd executable */ +#define CPATH ETCPATH "/ircd.conf" /* ircd.conf file */ +#define MPATH ETCPATH "/ircd.motd" /* MOTD file */ +#define LPATH LOGPATH "/ircd.log" /* ircd logfile */ +#define PPATH PKGRUNDIR "/ircd.pid" /* pid file */ +#define OPATH ETCPATH "/opers.motd" /* oper MOTD file */ +#define DBPATH PKGLOCALSTATEDIR "/ban.db" /* bandb file */ + + +/* Below are the elements for default paths. */ +typedef enum +{ + IRCD_PATH_PREFIX, + IRCD_PATH_MODULES, + IRCD_PATH_AUTOLOAD_MODULES, + IRCD_PATH_ETC, + IRCD_PATH_LOG, + IRCD_PATH_USERHELP, + IRCD_PATH_OPERHELP, + IRCD_PATH_IRCD_EXEC, + IRCD_PATH_IRCD_CONF, + IRCD_PATH_IRCD_MOTD, + IRCD_PATH_IRCD_LOG, + IRCD_PATH_IRCD_PID, + IRCD_PATH_IRCD_OMOTD, + IRCD_PATH_BANDB, + IRCD_PATH_BIN, + IRCD_PATH_LIBEXEC, + IRCD_PATH_COUNT +} +ircd_path_t; + +extern const char *ircd_paths[IRCD_PATH_COUNT]; + + +#endif // _IRCD_SYSTEM_H diff --git a/include/ircd/ircd_defs.h b/include/ircd/ircd_defs.h deleted file mode 100644 index eb5294081..000000000 --- a/include/ircd/ircd_defs.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * charybdis: An advanced IRCd. - * ircd_defs.h: A header for ircd global definitions. - * - * 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-2006 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 - */ - -/* - * NOTE: NICKLEN and TOPICLEN do not live here anymore. Set it with configure - * Otherwise there are no user servicable part here. - */ - -/* ircd_defs.h - Global size definitions for record entries used - * througout ircd. Please think 3 times before adding anything to this - * file. - */ -#ifndef INCLUDED_ircd_defs_h -#define INCLUDED_ircd_defs_h - -#include "defaults.h" - -/* - * This ensures that __attribute__((deprecated)) is not used in for example - * sun CC, since it's a GNU-specific extension. -nenolod - */ -#ifdef __GNUC__ -#define IRC_DEPRECATED __attribute__((deprecated)) -#else -#define IRC_DEPRECATED -#endif - -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif - -#define HOSTLEN 63 /* Length of hostname. Updated to */ - /* comply with RFC1123 */ - -/* Longest hostname we're willing to work with. - * Due to DNSBLs this is more than HOSTLEN. - */ -#define IRCD_RES_HOSTLEN 255 - -#define USERLEN 10 -#define REALLEN 50 -#define CHANNELLEN 200 -#define LOC_CHANNELLEN 50 - -/* reason length of klines, parts, quits etc */ -/* for quit messages, note that a client exit server notice - * :012345678901234567890123456789012345678901234567890123456789123 NOTICE * :*** Notice -- Client exiting: 012345678901234567 (0123456789@012345678901234567890123456789012345678901234567890123456789123) [] [1111:2222:3333:4444:5555:6666:7777:8888] - * takes at most 246 bytes (including CRLF and '\0') and together with the - * quit reason should fit in 512 */ -#define REASONLEN 260 /* kick/part/quit */ -#define BANREASONLEN 390 /* kline/dline */ -#define AWAYLEN TOPICLEN -#define KILLLEN 200 /* with Killed (nick ()) added this should fit in quit */ - -/* 23+1 for \0 */ -#define KEYLEN 24 -#define BUFSIZE 512 /* WARNING: *DONT* CHANGE THIS!!!! */ -#define OPERNICKLEN (NICKLEN*2) /* Length of OPERNICKs. */ - -#define USERHOST_REPLYLEN (NICKLEN+HOSTLEN+USERLEN+5) -#define MAX_DATE_STRING 32 /* maximum string length for a date string */ - -#define HELPLEN 400 - -/* - * message return values - */ -#define CLIENT_EXITED -2 -#define CLIENT_PARSE_ERROR -1 -#define CLIENT_OK 1 - -#ifdef RB_IPV6 -#ifndef AF_INET6 -#error "AF_INET6 not defined" -#endif - - -#else /* #ifdef RB_IPV6 */ - -#ifndef AF_INET6 -#define AF_INET6 AF_MAX /* Dummy AF_INET6 declaration */ -#endif -#endif /* #ifdef RB_IPV6 */ - -#ifdef RB_IPV6 -#define PATRICIA_BITS 128 -#else -#define PATRICIA_BITS 32 -#endif - -/* Read buffer size */ -#define READBUF_SIZE 16384 - -#endif /* INCLUDED_ircd_defs_h */ diff --git a/include/ircd/logger.h b/include/ircd/logger.h index 6a0f7dc07..f537ecc37 100644 --- a/include/ircd/logger.h +++ b/include/ircd/logger.h @@ -32,7 +32,7 @@ #ifndef INCLUDED_s_log_h #define INCLUDED_s_log_h -#include "ircd_defs.h" +#include "defaults.h" typedef enum ilogfile { diff --git a/include/ircd/s_conf.h b/include/ircd/s_conf.h index ce0f62802..18df76910 100644 --- a/include/ircd/s_conf.h +++ b/include/ircd/s_conf.h @@ -30,7 +30,6 @@ #include #endif -#include "ircd_defs.h" #include "class.h" #include "client.h" diff --git a/include/ircd/send.h b/include/ircd/send.h index a4b9aa74f..7ffd35d28 100644 --- a/include/ircd/send.h +++ b/include/ircd/send.h @@ -26,7 +26,6 @@ #define INCLUDED_send_h #include -#include "ircd_defs.h" struct Client; struct Channel; diff --git a/include/ircd/stdinc.h b/include/ircd/stdinc.h index 1f7b6294d..c06ffbd3b 100644 --- a/include/ircd/stdinc.h +++ b/include/ircd/stdinc.h @@ -22,7 +22,7 @@ */ #include -#include "ircd_defs.h" /* Needed for some reasons here -- dwr */ +#include "defaults.h" /* Needed for some reasons here -- dwr */ /* AIX requires this to be the first thing in the file. */ #ifdef __GNUC__ @@ -47,69 +47,11 @@ char *alloca (); # endif #endif - -#ifdef HAVE_STDLIB_H -#include -#endif -#ifdef STRING_WITH_STRINGS -# include -# include -#else -# ifdef HAVE_STRING_H -# include -# else -# ifdef HAVE_STRINGS_H -# include -# endif -# endif -#endif - - -#ifdef HAVE_STDDEF_H -#include -#endif - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include -#include -#include -#ifdef HAVE_SYS_RESOURCE_H -#include -#endif - - -#include - -#ifdef HAVE_SYS_PARAM_H -#include -#endif - #ifdef HAVE_ERRNO_H -#include #else extern int errno; #endif -#ifdef HAVE_SYS_UIO_H -#include -#endif - #if defined(__INTEL_COMPILER) || defined(__GNUC__) # ifdef __unused # undef __unused diff --git a/include/ircd/tgchange.h b/include/ircd/tgchange.h index 7e9bd052c..0cca04dd3 100644 --- a/include/ircd/tgchange.h +++ b/include/ircd/tgchange.h @@ -24,7 +24,7 @@ #ifndef INCLUDED_tgchange_h #define INCLUDED_tgchange_h -#include "ircd_defs.h" +#include "defaults.h" #include "client.h" #include "channel.h" diff --git a/include/rb/system.h b/include/rb/system.h index c83d6f0ef..ba78fae3b 100644 --- a/include/rb/system.h +++ b/include/rb/system.h @@ -48,6 +48,17 @@ char *alloca(); #ifdef __GNUC__ +/* + * This ensures that __attribute__((deprecated)) is not used in for example + * sun CC, since it's a GNU-specific extension. -nenolod + */ +#ifdef __GNUC__ +#define IRC_DEPRECATED __attribute__((deprecated)) +#else +#define IRC_DEPRECATED +#endif + + #ifdef rb_likely #undef rb_likely #endif @@ -62,6 +73,9 @@ char *alloca(); #define rb_likely(x) __builtin_expect(!!(x), 1) #define rb_unlikely(x) __builtin_expect(!!(x), 0) +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) + #else /* !__GNUC__ */ #define UNUSED(x) x @@ -270,4 +284,32 @@ while(0) #define RB_UIO_MAXIOV 16 #endif +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifdef RB_IPV6 +#ifndef AF_INET6 +#error "AF_INET6 not defined" +#endif + + +#else /* #ifdef RB_IPV6 */ + +#ifndef AF_INET6 +#define AF_INET6 AF_MAX /* Dummy AF_INET6 declaration */ +#endif +#endif /* #ifdef RB_IPV6 */ + +#ifdef RB_IPV6 +#define PATRICIA_BITS 128 +#else +#define PATRICIA_BITS 32 +#endif + + #endif // _RB_SYSTEM_H diff --git a/ircd/authproc.c b/ircd/authproc.c index d06823907..be65c103f 100644 --- a/ircd/authproc.c +++ b/ircd/authproc.c @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/ircd/ircd_lexer.l b/ircd/ircd_lexer.l index b2401a476..682d341aa 100644 --- a/ircd/ircd_lexer.l +++ b/ircd/ircd_lexer.l @@ -32,8 +32,6 @@ #define WE_ARE_MEMORY_C #include -#include -#include #include #include #include diff --git a/ircd/s_serv.c b/ircd/s_serv.c index e84a159b3..132ad581a 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/modules/m_whowas.c b/modules/m_whowas.c index c42788463..ce04e1c49 100644 --- a/modules/m_whowas.c +++ b/modules/m_whowas.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include