1 /****************************************************************************** 2 * Internetting Cooperating Programmers 3 * ---------------------------------------------------------------------------- 4 * 5 * ____ PROJECT 6 * | _ \ __ _ _ __ ___ ___ _ __ 7 * | | | |/ _` | '_ \ / __/ _ \ '__| 8 * | |_| | (_| | | | | (_| __/ | 9 * |____/ \__,_|_| |_|\___\___|_| the IRC bot 10 * 11 * All files in this archive are subject to the GNU General Public License. 12 * 13 * $Source: /cvsroot/dancer/dancer/src/dancer.h,v $ 14 * $Revision: 1.1.1.1 $ 15 * $Date: 2000/11/13 02:42:41 $ 16 * $Author: holsta $ 17 * $State: Exp $ 18 * $Locker: $ 19 * 20 * --------------------------------------------------------------------------- 21 *****************************************************************************/ 22 23 #ifndef DANCER_H 24 #define DANCER_H 25 26 #ifdef HAVE_CONFIG_H 27 # include "config.h" 28 #else 29 # error Not properly configured 30 #endif 31 32 #if TIME_WITH_SYS_TIME 33 # include <sys/time.h> 34 # include <time.h> 35 #else 36 # if HAVE_SYS_TIME_H 37 # include <sys/time.h> 38 # else 39 # include <time.h> 40 # endif 41 #endif 42 43 #include <stdio.h> 44 #include <stdlib.h> 45 #include <limits.h> 46 #include <errno.h> 47 #include <sys/types.h> 48 #include <ctype.h> 49 50 #include "language.h" 51 #include "servfunc.h" 52 #include "version.h" 53 54 /* ---------------------------------------------------------------- */ 55 56 /* Max length of nicknames. Some IRC networks (like Dalnet) use 57 wider nicknames. Change here if you run on one of those nets */ 58 #define NICKLEN 9 59 #define NICKLENTXT "9" /*QUOTE(NICKLEN)*/ 60 61 #define USERLEN 10 62 #define USERLENTXT "10" 63 64 /* Background processes should be nice'd. See 'man 1 nice' for further 65 info */ 66 #define NICE 5 67 68 /* Number of seconds between pinging the server. Don't make this too 69 small */ 70 #define PINGDELAY 30 71 72 73 /* ---------------------------------------------------------------- */ 74 /* - - - - - - - - No need to change anything below! - - - - - - - */ 75 76 /* This defines the current version of the bot */ 77 #define VERSIONMSG "Dancer V" VERSION 78 #define CTCPVERSION VERSIONMSG 79 80 /* Default IRC port (not necessary to change as you can specify 81 port number in server list) */ 82 #define IRCPORT 6667 83 84 /* HASHSIZE should be a prime far from 2^n */ 85 #define HASHSIZE 701 86 87 /* Every X second (select timeout). TimeEvents() */ 88 #define TIMER 2 89 90 /* Each TIMER * TIMERCHK second. SloppyEvents() */ 91 #define TIMERCHK 4 92 93 /* Timer stuff */ 94 #define MILLION 1000000L 95 #define RTIMER (TIMER * MILLION) /* select timeout in usecs */ 96 97 /* Buffers */ 98 #define MAXLINE 512 99 #define MINIBUFFER 128 100 #define MINIBUFFERTXT "127" 101 #define MIDBUFFER 256 102 #define MIDBUFFERTXT "255" 103 #define BIGBUFFER 512 104 #define BIGBUFFERTXT "511" 105 #define KILOBUFFER 1024 106 #define KILOBUFFERTXT "1023" 107 108 /* This kind of buffer is ideal for scanned text from an IRC line, that is 109 later presented back on IRC (with some extra blurb around). */ 110 #define SEMIBUFFER 472 111 #define SEMIBUFFERTXT "471" 112 113 /* This buffer should be only used when creating a string where 114 strings of BIGBUFFER size may be part of it */ 115 #define BIGGERBUFFER 768 116 117 #ifdef WANT_VALUES_FROM_THE_IRCD_SOURCE 118 /* 119 dast 961205 120 I stole some information from the ircd2.9.2/include/struct.h file 121 to show some real-life default values for a few buffers: */ 122 123 #define HOSTLEN 63 /* Length of hostname. Updated to */ 124 /* comply with RFC1123 */ 125 126 #define NICKLEN 9 /* Necessary to put 9 here instead of 10 127 ** if s_msg.c/m_nick has been corrected. 128 ** This preserves compatibility with old 129 ** servers --msa 130 */ 131 #define USERLEN 10 132 #define REALLEN 50 133 #define TOPICLEN 80 134 #define CHANNELLEN 50 135 #define PASSWDLEN 20 136 #define KEYLEN 23 137 #define BUFSIZE 512 /* WARNING: *DONT* CHANGE THIS!!!! */ 138 #define MAXRECIPIENTS 20 139 #define MAXBANS 20 140 #define MAXBANLENGTH 1024 141 #define BANLEN (USERLEN + NICKLEN + HOSTLEN + 3) 142 143 #endif /* WANT_VALUES_FROM_THE_IRCD_SOURCE */ 144 145 146 /* Levels */ 147 #define LEVELOWNER levels[LEVEL_OWNER] 148 #define LEVELBOT levels[LEVEL_BOT] 149 #define LEVELEXPERT levels[LEVEL_EXPERT] 150 #define LEVELTRUST levels[LEVEL_TRUST] 151 #define LEVELCHANOP levels[LEVEL_CHANOP] 152 #define LEVELRECOG levels[LEVEL_RECOG] 153 #define LEVELANYBODY levels[LEVEL_ANYBODY] 154 155 #define LEVEL_OWNER 6 156 #define LEVEL_BOT 5 157 #define LEVEL_EXPERT 4 158 #define LEVEL_TRUST 3 159 #define LEVEL_CHANOP 2 160 #define LEVEL_RECOG 1 161 #define LEVEL_ANYBODY 0 162 163 /* Thresholds */ 164 #define LEVELPUB LEVELCHANOP /* Level for public commands */ 165 #define LEVELPUBX LEVELRECOG /* Level for public commands if chanop */ 166 #define FLOODLOWMID LEVELRECOG /* Level that gets warnings */ 167 #define FLOODMIDHIGH LEVELCHANOP /* Level that are allowed to misbehave */ 168 169 /* Number of misbehaves before kicking a user with the right level */ 170 #define WARNLOW 0 /* -> FLOODLOWMID */ 171 #define WARNMID 3 /* FLOODLOWMID -> FLOODMIDHIGH */ 172 173 #define DEFPASSWDTXT "pass" 174 175 #define UNKNOWN GetText(msg_unknown) /*"<UNKNOWN>" */ 176 #define NOREASON GetText(msg_no_reason) /*"<No reason>"*/ 177 178 /* Timings */ 179 #define SECINMIN 60 180 #define SECINHOUR (SECINMIN*60) 181 #define SECINDAY (SECINHOUR*24) 182 #define SECINMONTH (SECINDAY*30) /* ~30 days in a month! ;) */ 183 184 /* Timeout, then the server ain't considered split anymore but all 185 users are counted as true QUITs */ 186 #define SPLITTIMEOUT (30*SECINMIN) 187 188 /* Period after a netsplit where FLOOD is off, to prevent kicking 189 people because of an sudden exchange of data between the servers. 190 (Usually called a netburp) */ 191 #define NETBURPTIME (3*SECINMIN) 192 193 194 /* ---------------------------------------------------------------- */ 195 196 /* My ubiquitous #defines */ 197 #undef NULL 198 #define NULL 0 199 #undef NIL 200 #define NIL ((char)0) 201 #undef FALSE 202 #define FALSE (1 == 0) 203 #undef TRUE 204 #define TRUE (1 == 1) 205 206 typedef int bool; 207 208 #if defined(hpux) || defined(__hpux) 209 typedef unsigned long ulong; 210 #endif 211 212 #define ULONG_BIT (CHAR_BIT * sizeof(ulong)) 213 214 /* ---------------------------------------------------------------- */ 215 216 extern int errno; 217 #ifndef SYS_ERRLIST_DECLARED 218 extern int sys_nerr; 219 extern char *sys_errlist[]; 220 #endif 221 222 /* "Borrowed" from the ircII client source */ 223 #ifndef HAVE_STRERROR 224 # define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e]) 225 #endif 226 227 #ifdef DEBUG 228 void MakeSnapshot(char *, int); /* This should've been in transfer.h */ 229 #define snapshot MakeSnapshot(__FILE__, __LINE__) 230 #else 231 #define snapshot 232 #endif 233 234 #ifndef HAVE_ATOL 235 # ifdef HAVE_STRTOUL 236 # define atol(x) (StrToUnsignedLong(x, (char **)NULL, 10)) 237 # else 238 # define atol(x) (StrToLong(x, (char **)NULL, 10)) 239 # endif 240 #endif 241 242 #ifdef HAVE_STRTOUL 243 # define atoul(x) (StrToUnsignedLong(x, (char **)NULL, 10)) 244 #else 245 # define atoul(x) atol(x) 246 #endif 247 248 #ifndef MIN 249 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 250 #endif 251 #ifndef MAX 252 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 253 #endif 254 255 #define iswhite(c) (isascii(c) && isspace(c)) 256 #define isvalid(c) ((('A' <= (c)) && ('~' >= (c))) || \ 257 (('0' <= (c)) && ('9' >= (c))) || \ 258 ('-' == (c))) 259 260 /* ---------------------------------------------------------------- */ 261 262 void TimeEvents(void); 263 void Hello(itemserv *); 264 void Cleanup(void); 265 266 #endif /* DANCER_H */ 267