2004-02-02 21:01:33 +00:00
|
|
|
|
/* NeoStats - IRC Statistical Services
|
2008-02-24 02:45:41 +00:00
|
|
|
|
** Copyright (c) 1999-2008 Adam Rutter, Justin Hammond, Mark Hetherington
|
2004-02-02 21:01:33 +00:00
|
|
|
|
** http://www.neostats.net/
|
|
|
|
|
**
|
2008-02-24 02:45:41 +00:00
|
|
|
|
** Portions Copyright (c) 2000-2008 ^Enigma^
|
2004-02-02 21:01:33 +00:00
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
|
|
**
|
|
|
|
|
** NeoStats CVS Identification
|
|
|
|
|
** $Id$
|
|
|
|
|
*/
|
|
|
|
|
|
2005-11-23 23:30:34 +00:00
|
|
|
|
#ifndef _NEOSTATS_H_
|
|
|
|
|
#define _NEOSTATS_H_
|
2004-02-02 21:01:33 +00:00
|
|
|
|
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef WIN32
|
2007-01-08 23:28:53 +00:00
|
|
|
|
/* Disable some warnings on MSVC 2005 */
|
|
|
|
|
#define _CRT_SECURE_NO_DEPRECATE 1
|
|
|
|
|
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#include "configwin32.h"
|
2005-10-17 21:06:59 +00:00
|
|
|
|
#include <winsock2.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#else /* WIN32 */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#include "config.h"
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* WIN32 */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
|
2004-09-02 13:29:31 +00:00
|
|
|
|
#ifdef HAVE_STDDEF_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <stddef.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_STDDEF_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_STDIO_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <stdio.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_STDIO_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <sys/types.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_SYS_TYPES_H */
|
2004-08-24 18:54:28 +00:00
|
|
|
|
#ifdef HAVE_ERRNO_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <errno.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_ERRNO_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
2004-06-26 17:26:32 +00:00
|
|
|
|
#include <sys/socket.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_SYS_SOCKET_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_NETDB_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <netdb.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_NETDB_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <netinet/in.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_NETINET_IN_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <unistd.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_UNISTD_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
2004-06-26 17:26:32 +00:00
|
|
|
|
#include <sys/time.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_SYS_TIME_H */
|
2004-08-24 18:54:28 +00:00
|
|
|
|
#ifdef HAVE_SYS_RESOURCE_H
|
2004-06-26 17:26:32 +00:00
|
|
|
|
#include <sys/resource.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_SYS_RESOURCE_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_TIME_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <time.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_TIME_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_STRING_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <string.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_STRING_H */
|
2004-08-24 18:54:28 +00:00
|
|
|
|
#ifdef HAVE_STDARG_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <stdarg.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_STDARG_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_STDLIB_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <stdlib.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_STDLIB_H */
|
2004-08-24 18:54:28 +00:00
|
|
|
|
#ifdef HAVE_CTYPE_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <ctype.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_CTYPE_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <sys/stat.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_SYS_STAT_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_SETJMP_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <setjmp.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_SETJMP_H */
|
2004-08-13 19:10:03 +00:00
|
|
|
|
#ifdef HAVE_ASSERT_H
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include <assert.h>
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* HAVE_ASSERT_H */
|
2005-03-18 12:29:37 +00:00
|
|
|
|
#ifdef HAVE_ARPA_INET_H
|
|
|
|
|
#include <arpa/inet.h>
|
2005-04-13 23:05:21 +00:00
|
|
|
|
#endif /* HAVE_ARPA_INET_H */
|
2005-03-18 12:29:37 +00:00
|
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
|
|
|
|
#include <sys/ioctl.h>
|
2005-04-13 23:05:21 +00:00
|
|
|
|
#endif /* HAVE_SYS_IOCTL_H */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-04-07 12:49:50 +00:00
|
|
|
|
#ifdef WIN32
|
|
|
|
|
typedef SOCKET OS_SOCKET;
|
|
|
|
|
#else /* WIN32 */
|
|
|
|
|
typedef int OS_SOCKET;
|
2005-04-13 23:05:21 +00:00
|
|
|
|
#ifndef SOCKET_ERROR
|
|
|
|
|
#define SOCKET_ERROR -1
|
|
|
|
|
#endif /* SOCKET_ERROR */
|
|
|
|
|
#ifndef INVALID_SOCKET
|
|
|
|
|
#define INVALID_SOCKET -1
|
|
|
|
|
#endif /* INVALID_SOCKET */
|
2005-04-07 12:49:50 +00:00
|
|
|
|
#endif /* WIN32 */
|
2005-03-25 23:12:26 +00:00
|
|
|
|
|
2005-02-01 23:05:43 +00:00
|
|
|
|
/* These macros handle DLL imports and exports for win32 module support */
|
2004-06-26 17:26:32 +00:00
|
|
|
|
#ifdef WIN32
|
2004-07-05 19:35:58 +00:00
|
|
|
|
#ifdef NEOSTATSCORE
|
|
|
|
|
#define EXPORTFUNC __declspec(dllexport)
|
|
|
|
|
#define EXPORTVAR __declspec(dllexport)
|
|
|
|
|
#define MODULEFUNC
|
|
|
|
|
#define MODULEVAR
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#else /* NEOSTATSCORE */
|
2004-07-05 19:35:58 +00:00
|
|
|
|
#define EXPORTVAR __declspec(dllimport)
|
|
|
|
|
#define EXPORTFUNC __declspec(dllimport)
|
|
|
|
|
#define MODULEFUNC __declspec(dllexport)
|
|
|
|
|
#define MODULEVAR __declspec(dllexport)
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* NEOSTATSCORE */
|
|
|
|
|
#else /* WIN32 */
|
2004-07-05 19:35:58 +00:00
|
|
|
|
#define MODULEFUNC
|
|
|
|
|
#define MODULEVAR
|
|
|
|
|
#define EXPORTVAR
|
|
|
|
|
#define EXPORTFUNC
|
2004-08-03 20:45:34 +00:00
|
|
|
|
#include "version.h"
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* WIN32 */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-05-22 21:58:26 +00:00
|
|
|
|
#ifdef WIN32
|
|
|
|
|
#define MODULECONFIG "modconfigwin32.h"
|
|
|
|
|
#else /* WIN32 */
|
|
|
|
|
#define MODULECONFIG "modconfig.h"
|
|
|
|
|
#endif /* WIN32 */
|
|
|
|
|
|
|
|
|
|
|
2005-02-01 23:05:43 +00:00
|
|
|
|
/* No language support under win32 */
|
|
|
|
|
#ifndef WIN32
|
2004-09-29 10:31:35 +00:00
|
|
|
|
/* when db stuff is working, change this back */
|
|
|
|
|
/* #ifdef HAVE_DB_H */
|
|
|
|
|
#if 0
|
|
|
|
|
#define USEGETTEXT
|
2005-02-01 23:05:43 +00:00
|
|
|
|
#else /* HAVE_DB_H */
|
2004-08-10 15:01:59 +00:00
|
|
|
|
/* so our defines for _(x) are not active */
|
|
|
|
|
#undef USEGETTEXT
|
2005-02-01 23:05:43 +00:00
|
|
|
|
#endif /* HAVE_DB_H */
|
|
|
|
|
#endif /* WIN32 */
|
2004-08-10 15:01:59 +00:00
|
|
|
|
|
2004-09-29 10:31:35 +00:00
|
|
|
|
#ifdef USEGETTEXT
|
2004-10-20 19:58:48 +00:00
|
|
|
|
char *LANGgettext( const char *string, int mylang );
|
2004-08-10 15:01:59 +00:00
|
|
|
|
/* our own defines for language support */
|
|
|
|
|
/* this one is for standard language support */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define _( x ) LANGgettext( ( x ), me.lang )
|
2004-08-10 15:01:59 +00:00
|
|
|
|
/* this one is for custom langs based on chan/user struct */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define __( x, y ) LANGgettext( ( x ), ( y )->lang )
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#else /* USEGETTEXT */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define _( x ) ( x )
|
|
|
|
|
#define __( x, y ) ( x )
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* USEGETTEXT */
|
2004-08-10 15:01:59 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* If we're not using GNU C, elide __attribute__ */
|
|
|
|
|
#ifndef __GNUC__
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define __attribute__( x ) /* NOTHING */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* __GNUC__ */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-02-24 18:16:46 +00:00
|
|
|
|
/* va_copy handling*/
|
|
|
|
|
#ifndef HAVE_VA_COPY
|
|
|
|
|
#if HAVE___VA_COPY
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define va_copy( dest, src ) __va_copy( ( dest ), ( src ) )
|
2005-02-24 18:16:46 +00:00
|
|
|
|
#else /* HAVE___VA_COPY */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define va_copy( dest, src ) memcpy( &( dest ), &( src ), sizeof( dest ) )
|
2005-02-24 18:16:46 +00:00
|
|
|
|
#endif /* HAVE___VA_COPY */
|
|
|
|
|
#endif /* HAVE_VA_COPY */
|
|
|
|
|
|
2004-06-08 07:14:40 +00:00
|
|
|
|
#include "pcre.h"
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#include "adns.h"
|
|
|
|
|
#include "list.h"
|
|
|
|
|
#include "hash.h"
|
|
|
|
|
#include "support.h"
|
|
|
|
|
#include "events.h"
|
2004-08-24 22:01:04 +00:00
|
|
|
|
#include "numeric.h"
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define ARRAYLEN( a ) ( sizeof( a ) / sizeof( *( a ) ) )
|
2004-06-14 20:55:41 +00:00
|
|
|
|
|
2005-04-07 12:49:50 +00:00
|
|
|
|
#define PROTOCOL_NOQUIT 0x00000001 /* NOQUIT */
|
|
|
|
|
#define PROTOCOL_TOKEN 0x00000002 /* TOKEN */
|
|
|
|
|
#define PROTOCOL_SJOIN 0x00000004 /* SJOIN */
|
|
|
|
|
#define PROTOCOL_NICKv2 0x00000008 /* NICKv2 */
|
|
|
|
|
#define PROTOCOL_SJOIN2 0x00000010 /* SJOIN2 */
|
|
|
|
|
#define PROTOCOL_UMODE2 0x00000020 /* UMODE2 */
|
|
|
|
|
#define PROTOCOL_NS 0x00000040 /* NS */
|
|
|
|
|
#define PROTOCOL_ZIP 0x00000080 /* ZIP - not actually supported by NeoStats */
|
|
|
|
|
#define PROTOCOL_VL 0x00000100 /* VL */
|
|
|
|
|
#define PROTOCOL_SJ3 0x00000200 /* SJ3 */
|
|
|
|
|
#define PROTOCOL_VHP 0x00000400 /* Send hostnames in NICKv2 even if not sethosted */
|
2004-05-20 21:17:00 +00:00
|
|
|
|
#define PROTOCOL_SJB64 0x00000800 /* */
|
|
|
|
|
#define PROTOCOL_CLIENT 0x00001000 /* CLIENT */
|
|
|
|
|
#define PROTOCOL_B64SERVER 0x00002000 /* Server names use Base 64 */
|
|
|
|
|
#define PROTOCOL_B64NICK 0x00004000 /* Nick names use Base 64 */
|
2004-07-16 22:36:54 +00:00
|
|
|
|
#define PROTOCOL_UNKLN 0x00008000 /* Have UNKLINE support */
|
2004-07-09 13:53:24 +00:00
|
|
|
|
#define PROTOCOL_NICKIP 0x00010000 /* NICK passes IP address */
|
2004-08-26 21:44:44 +00:00
|
|
|
|
#define PROTOCOL_KICKPART 0x00020000 /* KICK also generates PART */
|
2005-04-28 14:58:02 +00:00
|
|
|
|
#define PROTOCOL_P10 0x00040000 /* Protocol is IRCu P10 based */
|
2007-01-28 08:45:11 +00:00
|
|
|
|
#define PROTOCOL_EOB 0x00080000 /* Protocol supports End Of Burst Info */
|
2004-08-24 22:01:04 +00:00
|
|
|
|
#define PROTOCOL_CLIENTMODE 0x80000000 /* Client mode */
|
2004-07-24 17:55:15 +00:00
|
|
|
|
|
2005-04-07 12:49:50 +00:00
|
|
|
|
#define FEATURE_SWHOIS 0x00000001 /* SWHOIS */
|
|
|
|
|
#define FEATURE_SVSTIME 0x00000002 /* SVSTIME */
|
2004-05-20 21:17:00 +00:00
|
|
|
|
#define FEATURE_SVSHOST 0x00000004 /* SVSHOST */
|
|
|
|
|
#define FEATURE_SVSJOIN 0x00000008 /* SVSJOIN */
|
|
|
|
|
#define FEATURE_SVSMODE 0x00000010 /* SVSMODE */
|
|
|
|
|
#define FEATURE_SVSPART 0x00000020 /* SVSPART */
|
|
|
|
|
#define FEATURE_SVSNICK 0x00000040 /* SVSNICK */
|
|
|
|
|
#define FEATURE_SVSKILL 0x00000080 /* SVSKILL */
|
|
|
|
|
#define FEATURE_UMODECLOAK 0x00000100 /* auto cloak host with umode */
|
2004-07-16 22:36:54 +00:00
|
|
|
|
#define FEATURE_USERSMODES 0x00000200 /* User Smode field */
|
2004-07-22 22:17:34 +00:00
|
|
|
|
#define FEATURE_SMO 0x00000400 /* SMO */
|
2004-05-20 21:17:00 +00:00
|
|
|
|
|
2004-06-09 19:15:44 +00:00
|
|
|
|
/* cumodes are channel modes which affect a user */
|
|
|
|
|
#define CUMODE_CHANOP 0x00000001
|
|
|
|
|
#define CUMODE_VOICE 0x00000002
|
|
|
|
|
#define CUMODE_HALFOP 0x00000004
|
|
|
|
|
#define CUMODE_CHANOWNER 0x00000008
|
|
|
|
|
/* Following are mutually exclusive in current IRCd support so share bits.
|
|
|
|
|
* If this changes, all these must change.
|
|
|
|
|
*/
|
|
|
|
|
#define CUMODE_CHANPROT 0x00000010
|
|
|
|
|
#define CUMODE_CHANADMIN 0x00000010
|
|
|
|
|
|
|
|
|
|
/* Channel modes available on all IRCds */
|
|
|
|
|
#define CMODE_PRIVATE 0x00000020
|
|
|
|
|
#define CMODE_SECRET 0x00000040
|
|
|
|
|
#define CMODE_MODERATED 0x00000080
|
|
|
|
|
#define CMODE_TOPICLIMIT 0x00000100
|
|
|
|
|
#define CMODE_BAN 0x00000200
|
|
|
|
|
#define CMODE_INVITEONLY 0x00000400
|
|
|
|
|
#define CMODE_NOPRIVMSGS 0x00000800
|
|
|
|
|
#define CMODE_KEY 0x00001000
|
|
|
|
|
#define CMODE_LIMIT 0x00002000
|
|
|
|
|
|
|
|
|
|
/* Channel modes available on most IRCds */
|
|
|
|
|
#define CMODE_EXCEPT 0x00004000
|
|
|
|
|
#define CMODE_RGSTR 0x00008000
|
|
|
|
|
#define CMODE_RGSTRONLY 0x00010000
|
|
|
|
|
#define CMODE_LINK 0x00020000
|
|
|
|
|
#define CMODE_NOCOLOR 0x00040000
|
|
|
|
|
#define CMODE_OPERONLY 0x00080000
|
|
|
|
|
#define CMODE_ADMONLY 0x00100000
|
|
|
|
|
#define CMODE_STRIP 0x00200000
|
|
|
|
|
#define CMODE_NOKNOCK 0x00400000
|
|
|
|
|
#define CMODE_NOINVITE 0x00800000
|
|
|
|
|
#define CMODE_FLOODLIMIT 0x01000000
|
|
|
|
|
|
|
|
|
|
/* Other channel modes available on IRCds cannot be easily supported so
|
|
|
|
|
* should be defined locally beginning at 0x02000000
|
|
|
|
|
*/
|
|
|
|
|
|
2004-06-23 21:55:30 +00:00
|
|
|
|
/* Cmode macros */
|
2005-10-11 20:16:01 +00:00
|
|
|
|
#define is_hidden_chan( x ) ( ( x ) && ( ( x )->modes & ( CMODE_PRIVATE | CMODE_SECRET | CMODE_ADMONLY | CMODE_OPERONLY ) ) )
|
|
|
|
|
#define is_pub_chan( x ) ( ( x ) && !( ( x )->modes & ( CMODE_PRIVATE | CMODE_SECRET | CMODE_RGSTRONLY | CMODE_ADMONLY | CMODE_OPERONLY | CMODE_INVITEONLY | CMODE_KEY ) ) )
|
|
|
|
|
#define is_priv_chan( x ) ( ( x ) && ( ( x )->modes & ( CMODE_PRIVATE | CMODE_SECRET | CMODE_RGSTRONLY | CMODE_ADMONLY | CMODE_OPERONLY | CMODE_INVITEONLY | CMODE_KEY ) ) )
|
2004-06-23 21:55:30 +00:00
|
|
|
|
|
|
|
|
|
/* User modes available on all IRCds */
|
|
|
|
|
#define UMODE_INVISIBLE 0x00000001 /* makes user invisible */
|
|
|
|
|
#define UMODE_OPER 0x00000002 /* Operator */
|
|
|
|
|
#define UMODE_WALLOP 0x00000004 /* send wallops to them */
|
|
|
|
|
|
2004-07-05 19:35:58 +00:00
|
|
|
|
/* User modes available on most IRCds */
|
|
|
|
|
#define UMODE_LOCOP 0x00000008 /* Local operator -- SRB */
|
|
|
|
|
#define UMODE_REGNICK 0x00000010 /* umode +r - registered nick */
|
|
|
|
|
#define UMODE_DEAF 0x00000020 /* Dont see chan msgs */
|
|
|
|
|
#define UMODE_HIDE 0x00000040 /* Hide from Nukes */
|
2004-07-22 21:52:33 +00:00
|
|
|
|
#define UMODE_BOT 0x00000080 /* User is a bot */
|
|
|
|
|
|
|
|
|
|
#define UMODE_RBOT UMODE_BOT /* Registered Bot */
|
|
|
|
|
#define UMODE_SBOT UMODE_BOT /* Server Bot */
|
|
|
|
|
|
|
|
|
|
#define UMODE_SADMIN 0x00000100 /* Services Admin */
|
|
|
|
|
#define UMODE_ADMIN 0x00000200 /* Admin */
|
|
|
|
|
#define UMODE_SERVICES 0x00000400 /* services */
|
|
|
|
|
#define UMODE_NETADMIN 0x00000800 /* Network Admin */
|
|
|
|
|
#define UMODE_COADMIN 0x00001000 /* Co Admin */
|
2005-04-07 12:49:50 +00:00
|
|
|
|
#define UMODE_TECHADMIN 0x00002000 /* Technical Administrator */
|
2004-07-22 21:52:33 +00:00
|
|
|
|
#define UMODE_CLIENT 0x00004000 /* Show client information */
|
2005-03-21 22:07:46 +00:00
|
|
|
|
#define UMODE_FCLIENT 0x00008000 /* receive client on far connects.. */
|
2004-07-22 21:52:33 +00:00
|
|
|
|
#define UMODE_KIX 0x00010000 /* protected oper, only ulines can kick */
|
|
|
|
|
#define UMODE_HELPOP 0x00020000 /* Help system operator */
|
|
|
|
|
#define UMODE_RGSTRONLY 0x00040000 /* only registered nicks may PM */
|
2004-07-05 19:35:58 +00:00
|
|
|
|
|
|
|
|
|
/* Other user modes available on IRCds cannot be easily supported so
|
2005-01-24 22:21:33 +00:00
|
|
|
|
* should be defined locally beginning at 0x00080000
|
2004-07-05 19:35:58 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2004-07-22 21:52:33 +00:00
|
|
|
|
/* Smodes */
|
|
|
|
|
#define SMODE_SSL 0x00000001 /* ssl client */
|
|
|
|
|
#define SMODE_COADMIN 0x00000002 /* co admin on a server */
|
|
|
|
|
#define SMODE_ADMIN 0x00000004 /* server admin */
|
|
|
|
|
#define SMODE_COTECHADMIN 0x00000008 /* co-tech admin */
|
|
|
|
|
#define SMODE_TECHADMIN 0x00000010 /* tech administrator */
|
|
|
|
|
#define SMODE_CONETADMIN 0x00000020 /* Co-Network Admin */
|
|
|
|
|
#define SMODE_NETADMIN 0x00000040 /* Network Admin */
|
|
|
|
|
#define SMODE_GUESTADMIN 0x00000080 /* Guest Admin */
|
|
|
|
|
|
2004-07-05 19:35:58 +00:00
|
|
|
|
EXPORTVAR extern unsigned int ircd_supported_umodes;
|
|
|
|
|
EXPORTVAR extern unsigned int ircd_supported_smodes;
|
2004-07-28 19:14:27 +00:00
|
|
|
|
EXPORTVAR extern unsigned int ircd_supported_cmodes;
|
|
|
|
|
EXPORTVAR extern unsigned int ircd_supported_cumodes;
|
2005-02-01 23:05:43 +00:00
|
|
|
|
#define HaveUmodeRegNick() ( ircd_supported_umodes & UMODE_REGNICK )
|
|
|
|
|
#define HaveUmodeDeaf() ( ircd_supported_umodes & UMODE_DEAF )
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-06-23 21:55:30 +00:00
|
|
|
|
/* Umode macros */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define IsOper(x) ( ( x ) && ( ( x->user->Umode & ( UMODE_OPER | UMODE_LOCOP ) ) ) )
|
2005-02-04 20:19:11 +00:00
|
|
|
|
#define IsBot(x) ( ( x ) && ( x->user->Umode & UMODE_BOT ) )
|
2005-05-22 23:06:33 +00:00
|
|
|
|
#define IsServerOperMode( mode ) ( mode & ( UMODE_ADMIN | UMODE_COADMIN | UMODE_OPER | UMODE_LOCOP ) )
|
|
|
|
|
#define IsServerOperSMode( mode ) ( mode & ( UMODE_ADMIN | UMODE_COADMIN | UMODE_OPER | UMODE_LOCOP ) )
|
2004-06-23 21:55:30 +00:00
|
|
|
|
|
2005-11-28 23:03:05 +00:00
|
|
|
|
EXPORTFUNC unsigned int UmodeCharToMask( unsigned char mode );
|
|
|
|
|
EXPORTFUNC const char *GetUmodeDesc( unsigned int mask );
|
|
|
|
|
EXPORTFUNC unsigned int SmodeCharToMask( unsigned char mode );
|
|
|
|
|
EXPORTFUNC const char *GetSmodeDesc( unsigned int mask );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC unsigned int UmodeStringToMask( const char *UmodeString );
|
2005-11-28 23:03:05 +00:00
|
|
|
|
EXPORTFUNC char *UmodeMaskToString( unsigned int mask );
|
|
|
|
|
EXPORTFUNC unsigned char UmodeMaskToChar( unsigned int mask );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC unsigned int SmodeStringToMask( const char *UmodeString );
|
2005-11-28 23:03:05 +00:00
|
|
|
|
EXPORTFUNC char *SmodeMaskToString( unsigned int mask );
|
|
|
|
|
EXPORTFUNC unsigned char SmodeMaskToChar( unsigned int mask );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC unsigned int CmodeStringToMask( const char *UmodeString );
|
2005-11-28 23:03:05 +00:00
|
|
|
|
EXPORTFUNC char *CmodeMaskToString( unsigned int mask );
|
|
|
|
|
EXPORTFUNC char *CmodeMaskToPrefixString( unsigned int mask );
|
|
|
|
|
EXPORTFUNC unsigned int CmodeCharToMask( unsigned char mode );
|
|
|
|
|
EXPORTFUNC unsigned char CmodeMaskToChar( unsigned int mask );
|
|
|
|
|
EXPORTFUNC unsigned int CmodeCharToFlags( unsigned char mode );
|
|
|
|
|
EXPORTFUNC unsigned int CmodePrefixToMask( unsigned char prefix );
|
|
|
|
|
EXPORTFUNC unsigned char CmodePrefixToChar( unsigned char prefix );
|
|
|
|
|
EXPORTFUNC unsigned char CmodeMaskToPrefix( unsigned int mask );
|
|
|
|
|
EXPORTFUNC unsigned char CmodeCharToPrefix( unsigned char mode );
|
2004-07-28 22:54:06 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#ifdef NEOSTATS_REVISION
|
2007-01-09 06:35:58 +00:00
|
|
|
|
#define NEOSTATS_VERSION NEO_VERSION " (" NEOSTATS_REVISION ") " NS_HOST
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#else /* NEOSTATS_REVISION */
|
2007-01-09 06:35:58 +00:00
|
|
|
|
#define NEOSTATS_VERSION NEO_VERSION " " NS_HOST
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* NEOSTATS_REVISION */
|
2004-03-25 22:48:44 +00:00
|
|
|
|
#define CORE_MODULE_VERSION NEOSTATS_VERSION
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
#define TS5
|
|
|
|
|
|
|
|
|
|
#ifdef TS5
|
2004-05-16 21:01:19 +00:00
|
|
|
|
#define TS_CURRENT 5 /* current TS protocol version */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#else /* TS5 */
|
2004-05-16 21:01:19 +00:00
|
|
|
|
#define TS_CURRENT 3 /* current TS protocol version */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* TS5 */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#define TS5_ONLY
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
#ifdef TS5_ONLY
|
|
|
|
|
#define TS_MIN 5
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#else /* TS5_ONLY */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#define TS_MIN 3 /* minimum supported TS protocol version */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* TS5_ONLY */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-05-25 19:02:28 +00:00
|
|
|
|
#define TS_ONE_MINUTE ( 60 )
|
|
|
|
|
#define TS_ONE_HOUR ( TS_ONE_MINUTE * 60 ) /* 3600 */
|
|
|
|
|
#define TS_ONE_DAY ( TS_ONE_HOUR * 24 ) /* 86400 */
|
|
|
|
|
#define TS_ONE_WEEK ( TS_ONE_DAY * 7 ) /* 604800 */
|
|
|
|
|
|
2004-03-26 20:55:05 +00:00
|
|
|
|
#define MOD_PATH "modules"
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-05-20 21:17:00 +00:00
|
|
|
|
#define BASE64SERVERSIZE 2
|
|
|
|
|
#define BASE64NICKSIZE 5
|
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#define BUFSIZE 512
|
2004-07-05 19:35:58 +00:00
|
|
|
|
|
2005-03-18 12:29:37 +00:00
|
|
|
|
/* this is like a recvq setting. Going over this, we are getting flooded */
|
|
|
|
|
#define LINEBUFSIZE 2048
|
|
|
|
|
|
|
|
|
|
/* this is the max data we read from a sock at once */
|
|
|
|
|
#define READBUFSIZE 4096
|
|
|
|
|
|
2004-07-05 19:35:58 +00:00
|
|
|
|
#define MAXHOST (128 + 1)
|
|
|
|
|
#define MAXPASS (32 + 1)
|
|
|
|
|
#define MAXNICK (32 + 1)
|
|
|
|
|
#define MAXUSER (15 + 1)
|
|
|
|
|
#define MAXREALNAME (50 + 1)
|
|
|
|
|
#define MAXCHANLEN (50 + 1)
|
|
|
|
|
#define MAXTOPICLEN (307 + 1)
|
2004-07-07 12:12:26 +00:00
|
|
|
|
#define CLOAKKEYLEN (40 + 1)
|
2004-07-05 19:35:58 +00:00
|
|
|
|
|
2005-10-12 03:46:19 +00:00
|
|
|
|
/* the max number of calls we will print out in a backtrace */
|
2008-01-07 16:35:38 +00:00
|
|
|
|
#define MAXBACKTRACESIZE 30
|
2005-10-12 03:46:19 +00:00
|
|
|
|
|
2005-05-22 21:10:22 +00:00
|
|
|
|
#define HOSTIPLEN ( 15 + 1 ) /* Size of IP address in dotted quad */
|
2005-03-17 21:42:33 +00:00
|
|
|
|
/* Size of nick!user@host mask */
|
|
|
|
|
#define USERHOSTLEN (MAXNICK + MAXHOST + MAXUSER + 5)
|
2004-07-23 21:38:05 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#define MODESIZE 53
|
|
|
|
|
#define PARAMSIZE MAXNICK+MAXUSER+MAXHOST+10
|
2005-09-19 20:53:42 +00:00
|
|
|
|
#define MAXINFO MAXREALNAME
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#define B64SIZE 16
|
|
|
|
|
|
2005-07-19 20:39:47 +00:00
|
|
|
|
#define KEYLEN (32 + 1)
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-07-05 19:35:58 +00:00
|
|
|
|
/* MAXCHANLENLIST
|
2004-03-16 23:14:25 +00:00
|
|
|
|
* the max length a string can be that holds channel lists
|
|
|
|
|
*/
|
2005-07-19 20:39:47 +00:00
|
|
|
|
#define MAXCHANLENLIST 1024
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
/* MAXPATH
|
|
|
|
|
* used to determine buffer sizes for file system operations
|
|
|
|
|
*/
|
|
|
|
|
#ifndef MAXPATH
|
|
|
|
|
#define MAXPATH 1024
|
|
|
|
|
#endif /* MAXPATH */
|
|
|
|
|
|
|
|
|
|
/* TIMEBUFSIZE
|
|
|
|
|
* used to determine buffer sizes for time formatting buffers
|
|
|
|
|
*/
|
|
|
|
|
#define TIMEBUFSIZE 80
|
|
|
|
|
|
|
|
|
|
/* STR_TIME_T_SIZE
|
|
|
|
|
* size of a time_t converted to a string.
|
|
|
|
|
*/
|
|
|
|
|
#define STR_TIME_T_SIZE 24
|
|
|
|
|
|
|
|
|
|
/* MAX_MOD_NAME
|
|
|
|
|
ModuleInfo will allow any length since it is merely a char *
|
|
|
|
|
functions displaying ModuleInfo contents will display the full string.
|
|
|
|
|
NeoStats core will truncate to this length for use internally.
|
|
|
|
|
*/
|
|
|
|
|
#define MAX_MOD_NAME 32
|
|
|
|
|
|
2005-01-24 22:30:26 +00:00
|
|
|
|
/* Buffer size for reason string */
|
|
|
|
|
#define MAXREASON 128
|
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* Buffer size for version string */
|
2004-05-16 21:01:19 +00:00
|
|
|
|
#define VERSIONSIZE 128
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Maximum number of modules that can be loaded */
|
2005-07-15 01:42:16 +00:00
|
|
|
|
#define NUM_MODULES 40
|
2004-08-24 18:54:28 +00:00
|
|
|
|
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define IsNeoStatsSynched() me.synched
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* Unified return values and error system */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* NeoStats general success failure return type */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#define NS_SUCCESS 1
|
|
|
|
|
#define NS_FAILURE -1
|
|
|
|
|
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* NeoStats boolean return type */
|
2004-07-23 11:06:34 +00:00
|
|
|
|
#define NS_TRUE 1
|
|
|
|
|
#define NS_FALSE 0
|
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* Specific errors beyond SUCCESS/FAILURE so that functions can handle errors
|
|
|
|
|
* Treat as unsigned with top bit set to give us a clear distinction from
|
|
|
|
|
* other values and use a typedef ENUM so that we can indicate return type */
|
|
|
|
|
typedef enum NS_ERR {
|
|
|
|
|
NS_ERR_NICK_IN_USE = 0x8000001,
|
|
|
|
|
NS_ERR_OUT_OF_MEMORY = 0x8000002,
|
2004-03-19 22:43:43 +00:00
|
|
|
|
NS_ERR_VERSION = 0x8000003,
|
|
|
|
|
NS_ERR_SYNTAX_ERROR = 0x8000004,
|
2004-04-09 22:17:19 +00:00
|
|
|
|
NS_ERR_NEED_MORE_PARAMS = 0x8000005,
|
|
|
|
|
NS_ERR_NO_PERMISSION = 0x8000006,
|
|
|
|
|
NS_ERR_UNKNOWN_COMMAND = 0x8000007,
|
|
|
|
|
NS_ERR_UNKNOWN_OPTION = 0x8000008,
|
2004-05-14 17:43:49 +00:00
|
|
|
|
NS_ERR_PARAM_OUT_OF_RANGE= 0x8000009,
|
2004-03-16 23:14:25 +00:00
|
|
|
|
}NS_ERR ;
|
|
|
|
|
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* General flags for for clients (users and servers) and channels */
|
|
|
|
|
#define NS_FLAG_EXCLUDED 0x00000001 /* matches a exclusion */
|
|
|
|
|
|
|
|
|
|
/* Flags for clients (users and servers) */
|
|
|
|
|
#define CLIENT_FLAG_EXCLUDED NS_FLAG_EXCLUDED /* client is excluded */
|
|
|
|
|
#define CLIENT_FLAG_ME 0x00000002 /* client is a NeoStats one */
|
|
|
|
|
#define CLIENT_FLAG_SYNCHED 0x00000004 /* client is synched */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define CLIENT_FLAG_SETHOST 0x00000008 /* client is sethosted */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#define CLIENT_FLAG_DCC 0x00000010 /* client is connected via DCC */
|
2004-11-28 23:05:17 +00:00
|
|
|
|
#define CLIENT_FLAG_ZOMBIE 0x00000020 /* client is zombie */
|
2005-12-06 20:42:10 +00:00
|
|
|
|
#define CLIENT_FLAG_GOTVERSION 0x00000040 /* got version reply */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#define NS_FLAGS_NETJOIN 0x00000080 /* client is on a net join */
|
|
|
|
|
|
|
|
|
|
#define CHANNEL_FLAG_EXCLUDED NS_FLAG_EXCLUDED /* channel is excluded */
|
|
|
|
|
#define CHANNEL_FLAG_ME 0x00000002 /* channel is services channel */
|
|
|
|
|
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define IsServicesChannel( x ) ( ( x )->flags & CHANNEL_FLAG_ME )
|
2004-10-20 19:58:48 +00:00
|
|
|
|
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define IsNetSplit( x ) ( ( x )->flags & NS_FLAGS_NETJOIN )
|
2007-01-28 08:45:11 +00:00
|
|
|
|
#define ClearNetSplit( x ) ( ( x )->flags &= ~NS_FLAGS_NETJOIN )
|
2004-10-20 19:58:48 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* NeoStats levels */
|
2005-07-19 20:39:47 +00:00
|
|
|
|
#define NS_ULEVEL_ROOT 200
|
|
|
|
|
#define NS_ULEVEL_ADMIN 185
|
|
|
|
|
#define NS_ULEVEL_OPER 50
|
|
|
|
|
#define NS_ULEVEL_LOCOPER 40
|
|
|
|
|
#define NS_ULEVEL_REG 10
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
/* transfer stuff */
|
|
|
|
|
typedef enum NS_TRANSFER {
|
2005-07-19 20:39:47 +00:00
|
|
|
|
NS_FILE = 0,
|
|
|
|
|
NS_MEMORY,
|
2004-03-16 23:14:25 +00:00
|
|
|
|
} NS_TRANSFER;
|
|
|
|
|
|
|
|
|
|
#define SEGV_LOCATION_BUFSIZE 255
|
2005-07-19 20:39:47 +00:00
|
|
|
|
#define SET_SEGV_LOCATION() ircsnprintf( segv_location, SEGV_LOCATION_BUFSIZE, "%s %d %s", __FILE__, __LINE__, __PRETTY_FUNCTION__ );
|
|
|
|
|
#define SET_SEGV_LOCATION_EXTRA( debug_text ) ircsnprintf( segv_location, SEGV_LOCATION_BUFSIZE, "%s %d %s %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, (debug_text) );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#define CLEAR_SEGV_LOCATION() segv_location[0]='\0';
|
|
|
|
|
|
2004-07-27 23:05:50 +00:00
|
|
|
|
EXPORTVAR extern char segv_location[SEGV_LOCATION_BUFSIZE];
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
/* this is the dns structure */
|
2005-10-10 18:05:39 +00:00
|
|
|
|
extern adns_state nsads;
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
/* version info */
|
2004-07-17 17:01:53 +00:00
|
|
|
|
EXPORTVAR extern const char version_date[];
|
|
|
|
|
EXPORTVAR extern const char version_time[];
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-02-08 19:12:21 +00:00
|
|
|
|
/* Forward references for cyclic structs */
|
2005-10-14 20:08:35 +00:00
|
|
|
|
typedef struct Module Module;
|
|
|
|
|
typedef struct Bot Bot;
|
2004-07-22 14:54:21 +00:00
|
|
|
|
|
2005-03-18 12:29:37 +00:00
|
|
|
|
/* to avoid warnings for Sock */
|
|
|
|
|
struct Sock;
|
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/** @brief Server structure
|
2004-10-20 19:58:48 +00:00
|
|
|
|
* Client extension structure for server specifics
|
2004-03-16 23:14:25 +00:00
|
|
|
|
*/
|
|
|
|
|
typedef struct Server {
|
2004-09-07 20:17:36 +00:00
|
|
|
|
unsigned int users;
|
|
|
|
|
unsigned int awaycount;
|
2004-03-16 23:14:25 +00:00
|
|
|
|
int hops;
|
|
|
|
|
int numeric;
|
2005-07-16 21:33:50 +00:00
|
|
|
|
time_t ping;
|
2004-07-17 17:01:53 +00:00
|
|
|
|
time_t uptime;
|
|
|
|
|
} Server;
|
|
|
|
|
|
|
|
|
|
/** @brief User structure
|
2004-10-20 19:58:48 +00:00
|
|
|
|
* Client extension structure for user specifics
|
2004-07-17 17:01:53 +00:00
|
|
|
|
*/
|
|
|
|
|
typedef struct User {
|
|
|
|
|
char hostname[MAXHOST];
|
|
|
|
|
char username[MAXUSER];
|
|
|
|
|
char vhost[MAXHOST];
|
|
|
|
|
char awaymsg[MAXHOST];
|
|
|
|
|
char swhois[MAXHOST];
|
2005-03-17 21:42:33 +00:00
|
|
|
|
char userhostmask[USERHOSTLEN];
|
|
|
|
|
char uservhostmask[USERHOSTLEN];
|
2005-07-16 21:33:50 +00:00
|
|
|
|
unsigned int flood;
|
2004-07-17 17:01:53 +00:00
|
|
|
|
int is_away;
|
|
|
|
|
time_t tslastmsg;
|
|
|
|
|
time_t tslastnick;
|
|
|
|
|
time_t tslastaway;
|
|
|
|
|
time_t servicestamp;
|
|
|
|
|
char modes[MODESIZE];
|
|
|
|
|
unsigned int Umode;
|
|
|
|
|
char smodes[MODESIZE];
|
|
|
|
|
unsigned int Smode;
|
|
|
|
|
int ulevel;
|
|
|
|
|
list_t *chans;
|
2004-08-31 22:01:22 +00:00
|
|
|
|
Bot *bot;
|
2004-07-17 17:01:53 +00:00
|
|
|
|
} User;
|
|
|
|
|
|
|
|
|
|
/** @brief Client structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
2004-08-24 18:54:28 +00:00
|
|
|
|
typedef struct Client {
|
2004-07-17 17:01:53 +00:00
|
|
|
|
User *user;
|
|
|
|
|
Server *server;
|
|
|
|
|
char name[MAXNICK];
|
|
|
|
|
char name64[B64SIZE];
|
2004-08-03 19:50:54 +00:00
|
|
|
|
char uplinkname[MAXHOST];
|
2004-09-07 20:17:36 +00:00
|
|
|
|
struct Client *uplink;
|
2004-07-17 17:01:53 +00:00
|
|
|
|
char info[MAXREALNAME];
|
2004-03-17 21:49:46 +00:00
|
|
|
|
char version[MAXHOST];
|
2004-07-17 17:01:53 +00:00
|
|
|
|
unsigned int flags;
|
|
|
|
|
time_t tsconnect;
|
2004-07-23 21:38:05 +00:00
|
|
|
|
struct in_addr ip;
|
|
|
|
|
char hostip[HOSTIPLEN];
|
2004-08-10 15:01:59 +00:00
|
|
|
|
int lang;
|
2004-09-02 20:50:09 +00:00
|
|
|
|
void *modptr[NUM_MODULES];
|
|
|
|
|
void *modvalue[NUM_MODULES];
|
2005-07-16 21:33:50 +00:00
|
|
|
|
OS_SOCKET fd;
|
2004-10-02 12:02:42 +00:00
|
|
|
|
int port;
|
2005-03-18 12:29:37 +00:00
|
|
|
|
struct Sock *sock;
|
2004-08-24 18:54:28 +00:00
|
|
|
|
} Client;
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-03-18 12:29:37 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/** @brief me structure
|
|
|
|
|
* structure containing information about the neostats core
|
|
|
|
|
*/
|
2004-07-05 19:35:58 +00:00
|
|
|
|
typedef struct tme {
|
2004-03-16 23:14:25 +00:00
|
|
|
|
char name[MAXHOST];
|
2004-09-22 20:25:28 +00:00
|
|
|
|
int numeric;
|
2004-07-05 19:35:58 +00:00
|
|
|
|
char protocol[MAXHOST];
|
2004-09-30 19:26:28 +00:00
|
|
|
|
char rootnick[MAXNICK];
|
2004-09-22 20:25:28 +00:00
|
|
|
|
char dbm[MAXHOST];
|
2004-03-16 23:14:25 +00:00
|
|
|
|
char uplink[MAXHOST];
|
|
|
|
|
char infoline[MAXHOST];
|
|
|
|
|
char netname[MAXPASS];
|
|
|
|
|
char local[MAXHOST];
|
2005-03-16 21:55:15 +00:00
|
|
|
|
char servicehost[MAXHOST];
|
2004-08-03 19:50:54 +00:00
|
|
|
|
int port;
|
2004-08-10 15:01:59 +00:00
|
|
|
|
int lang;
|
2004-09-07 20:17:36 +00:00
|
|
|
|
time_t ts_boot;
|
|
|
|
|
unsigned int usercount;
|
|
|
|
|
unsigned int awaycount;
|
|
|
|
|
unsigned int channelcount;
|
|
|
|
|
unsigned int servercount;
|
2004-03-16 23:14:25 +00:00
|
|
|
|
unsigned int maxsocks;
|
|
|
|
|
unsigned int cursocks;
|
|
|
|
|
unsigned int want_nickip:1;
|
2004-08-24 18:54:28 +00:00
|
|
|
|
char servicescmode[MODESIZE];
|
2004-07-16 22:36:54 +00:00
|
|
|
|
unsigned int servicescmodemask;
|
2004-08-24 18:54:28 +00:00
|
|
|
|
char servicesumode[MODESIZE];
|
2004-07-16 22:36:54 +00:00
|
|
|
|
unsigned int servicesumodemask;
|
2004-07-05 19:35:58 +00:00
|
|
|
|
char serviceschan[MAXCHANLEN];
|
2004-07-10 22:39:50 +00:00
|
|
|
|
unsigned int synched:1;
|
2004-07-17 17:01:53 +00:00
|
|
|
|
Client *s;
|
2005-03-18 12:29:37 +00:00
|
|
|
|
struct Sock *servsock;
|
2004-03-16 23:14:25 +00:00
|
|
|
|
int requests;
|
|
|
|
|
long SendM;
|
|
|
|
|
long SendBytes;
|
|
|
|
|
long RcveM;
|
|
|
|
|
long RcveBytes;
|
|
|
|
|
time_t lastmsg;
|
|
|
|
|
time_t now;
|
|
|
|
|
char strnow[STR_TIME_T_SIZE];
|
|
|
|
|
char version[VERSIONSIZE];
|
2004-07-29 18:34:35 +00:00
|
|
|
|
int dobind;
|
|
|
|
|
struct sockaddr_in lsa;
|
2005-06-11 06:09:46 +00:00
|
|
|
|
struct sockaddr_in srvip;
|
2004-10-27 20:21:46 +00:00
|
|
|
|
time_t tslastping;
|
2005-07-16 21:33:50 +00:00
|
|
|
|
time_t ulag;
|
2005-08-12 12:36:23 +00:00
|
|
|
|
unsigned int versionscan;
|
2004-07-05 19:35:58 +00:00
|
|
|
|
} tme;
|
|
|
|
|
|
2004-07-27 23:05:50 +00:00
|
|
|
|
EXPORTVAR extern tme me;
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-08-22 20:38:47 +00:00
|
|
|
|
#define NSGetChannelCount() me.channelcount
|
|
|
|
|
#define NSGetServerCount() me.servercount
|
|
|
|
|
#define NSGetUserCount() me.usercount
|
|
|
|
|
#define NSGetAwayCount() me.awaycount
|
2005-08-12 12:36:23 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/** @brief Bans structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
typedef struct Ban {
|
2004-05-09 21:31:02 +00:00
|
|
|
|
char type[8];
|
2004-03-16 23:14:25 +00:00
|
|
|
|
char user[MAXUSER];
|
|
|
|
|
char host[MAXHOST];
|
|
|
|
|
char mask[MAXHOST];
|
|
|
|
|
char reason[BUFSIZE];
|
|
|
|
|
char setby[MAXHOST];
|
|
|
|
|
time_t tsset;
|
|
|
|
|
time_t tsexpires;
|
|
|
|
|
} Ban;
|
|
|
|
|
|
|
|
|
|
|
2005-12-06 19:05:15 +00:00
|
|
|
|
/** @brief ModeParams structure
|
2004-07-28 22:54:06 +00:00
|
|
|
|
*
|
|
|
|
|
*/
|
2005-12-06 19:05:15 +00:00
|
|
|
|
typedef struct ModeParams {
|
2004-07-28 22:54:06 +00:00
|
|
|
|
unsigned int mask;
|
|
|
|
|
char param[PARAMSIZE];
|
2005-12-06 19:05:15 +00:00
|
|
|
|
} ModeParams;
|
2004-07-28 22:54:06 +00:00
|
|
|
|
|
2004-09-24 22:15:13 +00:00
|
|
|
|
/** @brief ChannelMember structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
typedef struct ChannelMember {
|
|
|
|
|
Client *u;
|
|
|
|
|
time_t tsjoin;
|
2005-10-13 22:00:05 +00:00
|
|
|
|
unsigned int modes;
|
2004-09-24 22:15:13 +00:00
|
|
|
|
} ChannelMember;
|
|
|
|
|
|
2004-03-17 21:49:46 +00:00
|
|
|
|
/** @brief Channel structure
|
2004-03-16 23:14:25 +00:00
|
|
|
|
*
|
|
|
|
|
*/
|
2004-03-17 21:49:46 +00:00
|
|
|
|
typedef struct Channel {
|
2004-07-05 19:35:58 +00:00
|
|
|
|
char name[MAXCHANLEN];
|
2004-03-16 23:14:25 +00:00
|
|
|
|
char name64[B64SIZE];
|
2004-08-12 21:43:01 +00:00
|
|
|
|
unsigned int users;
|
|
|
|
|
unsigned int neousers;
|
2004-08-24 18:54:28 +00:00
|
|
|
|
unsigned int persistentusers;
|
2004-08-10 15:01:59 +00:00
|
|
|
|
int lang;
|
2004-07-07 09:57:46 +00:00
|
|
|
|
unsigned int modes;
|
2004-09-09 22:40:46 +00:00
|
|
|
|
list_t *members;
|
2004-03-16 23:14:25 +00:00
|
|
|
|
char topic[BUFSIZE];
|
|
|
|
|
char topicowner[MAXHOST]; /* because a "server" can be a topic owner */
|
|
|
|
|
time_t topictime;
|
2005-04-07 12:49:50 +00:00
|
|
|
|
int limit;
|
|
|
|
|
char key[KEYLEN];
|
2005-12-06 19:05:15 +00:00
|
|
|
|
list_t *modeparams;
|
2004-03-17 21:49:46 +00:00
|
|
|
|
time_t creationtime;
|
2004-07-07 09:57:46 +00:00
|
|
|
|
unsigned int flags;
|
2004-09-02 20:50:09 +00:00
|
|
|
|
void *modptr[NUM_MODULES];
|
|
|
|
|
void *modvalue[NUM_MODULES];
|
2004-03-17 21:49:46 +00:00
|
|
|
|
} Channel;
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-10-14 20:08:35 +00:00
|
|
|
|
typedef struct bot_cmd bot_cmd;
|
2005-05-17 22:54:18 +00:00
|
|
|
|
|
2004-04-09 22:17:19 +00:00
|
|
|
|
typedef struct CmdParams {
|
2005-02-06 17:47:06 +00:00
|
|
|
|
Client *source; /* pointer to client triggering command */
|
|
|
|
|
Client *target; /* pointer to client command acts on */
|
|
|
|
|
Bot *bot; /* pointer to associated bot where appropriate */
|
|
|
|
|
char *param; /* command parameter */
|
|
|
|
|
char *cmd; /* command */
|
2005-05-17 22:54:18 +00:00
|
|
|
|
bot_cmd *cmd_ptr; /* pointer to associated command structure */
|
2005-04-28 14:58:02 +00:00
|
|
|
|
Channel *channel; /* pointer to channel struct where appropriate */
|
2005-04-07 12:49:50 +00:00
|
|
|
|
char **av; /* command parameter list */
|
|
|
|
|
int ac; /* count of command parameter list */
|
2008-02-21 08:01:27 +00:00
|
|
|
|
int eventid; /* the event that triggered this */
|
2004-04-09 22:17:19 +00:00
|
|
|
|
} CmdParams;
|
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* Comand list handling */
|
|
|
|
|
|
|
|
|
|
/** @brief bot_cmd_handler type
|
|
|
|
|
* defines handler function definition
|
|
|
|
|
*/
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* SET_REASON is passed to SET command callback funtions
|
|
|
|
|
* so the callback knows why it triggered
|
|
|
|
|
*/
|
2004-07-28 19:14:27 +00:00
|
|
|
|
typedef enum SET_REASON {
|
|
|
|
|
SET_LOAD = 0,
|
|
|
|
|
SET_LIST,
|
|
|
|
|
SET_CHANGE,
|
2005-02-15 23:44:20 +00:00
|
|
|
|
SET_VALIDATE,
|
2004-07-28 19:14:27 +00:00
|
|
|
|
} SET_REASON;
|
|
|
|
|
|
2005-10-13 22:00:05 +00:00
|
|
|
|
typedef int (*bot_cmd_handler) ( const CmdParams* cmdparams );
|
|
|
|
|
typedef int (*bot_set_handler) ( const CmdParams* cmdparams, SET_REASON reason );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-10-26 21:01:28 +00:00
|
|
|
|
/* Command will only respond to privmsg. !command in channel is ignored.
|
|
|
|
|
* Use of this flag is discouraged.
|
|
|
|
|
*/
|
|
|
|
|
#define CMD_FLAG_PRIVMSGONLY 0x00000001
|
|
|
|
|
/* Command will only respond to !command in channel. privmsg is ignored.
|
|
|
|
|
* Use of this flag is discouraged.
|
|
|
|
|
*/
|
|
|
|
|
#define CMD_FLAG_CHANONLY 0x00000002
|
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/** @brief bot_cmd structure
|
|
|
|
|
* defines command lists for bots
|
|
|
|
|
*/
|
2005-10-17 19:19:54 +00:00
|
|
|
|
struct bot_cmd
|
|
|
|
|
{
|
2004-03-16 23:14:25 +00:00
|
|
|
|
const char *cmd; /* command string */
|
|
|
|
|
bot_cmd_handler handler; /* handler */
|
|
|
|
|
int minparams; /* min num params */
|
2004-07-10 22:39:50 +00:00
|
|
|
|
int ulevel; /* min user level */
|
2004-08-31 22:01:22 +00:00
|
|
|
|
const char **helptext; /* pointer to help text */
|
2004-10-26 21:01:28 +00:00
|
|
|
|
int flags; /* command flags */
|
2005-05-17 22:54:18 +00:00
|
|
|
|
void *moddata; /* pointer for module use */
|
2005-02-08 19:12:21 +00:00
|
|
|
|
Module *modptr; /* NeoStats internal use only */
|
2005-10-17 19:19:54 +00:00
|
|
|
|
};
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-08-17 20:55:58 +00:00
|
|
|
|
#define NS_CMD_END() { NULL, NULL, 0, 0, NULL, 0, NULL, NULL }
|
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/** @brief flags for bots
|
|
|
|
|
* flags to influence how bots are managed
|
|
|
|
|
* e.g. restrict to opers
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Restrict module bot to only respond to oper requests
|
|
|
|
|
* when ONLY_OPERS is set in the config file
|
|
|
|
|
* E.g. StatServ
|
|
|
|
|
*/
|
|
|
|
|
#define BOT_FLAG_ONLY_OPERS 0x00000001
|
|
|
|
|
/* Restrict module bot to only respond to oper requests
|
|
|
|
|
* regardless of ONLY_OPERS setting in the config file
|
|
|
|
|
* E.g. Connectserv
|
|
|
|
|
*/
|
|
|
|
|
#define BOT_FLAG_RESTRICT_OPERS 0x00000002
|
|
|
|
|
/* Stop bot listening to channel chatter when they do not need to
|
|
|
|
|
* E.g. Connectserv
|
|
|
|
|
*/
|
|
|
|
|
#define BOT_FLAG_DEAF 0x00000004
|
2007-08-10 21:02:07 +00:00
|
|
|
|
/* Mark bot as a root bot that will manage commands and settings
|
|
|
|
|
* for the module. Limited to one per module.
|
2004-04-09 22:17:19 +00:00
|
|
|
|
* E.g. Connectserv
|
|
|
|
|
*/
|
2007-08-10 21:02:07 +00:00
|
|
|
|
#define BOT_FLAG_ROOT 0x00000008
|
|
|
|
|
/* Temp while flag is deprecated across modules */
|
|
|
|
|
#define BOT_FLAG_SERVICEBOT BOT_FLAG_ROOT
|
2004-08-24 18:54:28 +00:00
|
|
|
|
/* Mark bot as persistent even when no users are left in a channel
|
|
|
|
|
* If not set, and there are no bots with this flag set, when all
|
|
|
|
|
* users leave a channel, the bot will automatically leave aswell.
|
|
|
|
|
* You should watch the NEWCHAN event to join channels when they
|
|
|
|
|
* are created.
|
|
|
|
|
*/
|
|
|
|
|
#define BOT_FLAG_PERSIST 0x00000010
|
2005-09-05 21:21:52 +00:00
|
|
|
|
/* Bot becomes CTCP master for version requests and replies
|
|
|
|
|
* E.g. SecureServ issuing CTCP VERSION rather than NeoStats
|
|
|
|
|
*/
|
2007-08-10 21:02:07 +00:00
|
|
|
|
#define BOT_FLAG_CTCPVERSIONMASTER 0x00000020
|
2007-08-02 12:26:45 +00:00
|
|
|
|
|
2004-07-10 22:39:50 +00:00
|
|
|
|
/* This defines a "NULL" string for the purpose of BotInfo structures that
|
|
|
|
|
* want to inherit the main host used by NeoStats and still make the info
|
|
|
|
|
* readable
|
|
|
|
|
*/
|
|
|
|
|
#define BOT_COMMON_HOST ""
|
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* SET Comand handling */
|
|
|
|
|
|
|
|
|
|
typedef enum SET_TYPE {
|
2005-10-10 21:08:32 +00:00
|
|
|
|
SET_TYPE_NONE = -1, /* ON or OFF */
|
2004-04-09 22:17:19 +00:00
|
|
|
|
SET_TYPE_BOOLEAN = 0, /* ON or OFF */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
SET_TYPE_INT, /* valid integer */
|
|
|
|
|
SET_TYPE_STRING, /* single string */
|
|
|
|
|
SET_TYPE_MSG, /* multiple strings to be treated as a message and stored in one field */
|
|
|
|
|
SET_TYPE_NICK, /* valid nick */
|
|
|
|
|
SET_TYPE_USER, /* valid user */
|
|
|
|
|
SET_TYPE_HOST, /* valid host name */
|
|
|
|
|
SET_TYPE_REALNAME, /* valid realname */
|
|
|
|
|
SET_TYPE_CHANNEL, /* valid channel */
|
|
|
|
|
SET_TYPE_IPV4, /* valid IPv4 dotted quad */
|
|
|
|
|
SET_TYPE_CUSTOM, /* handled by module */
|
|
|
|
|
}SET_TYPE;
|
|
|
|
|
|
|
|
|
|
/** @brief bot_setting structure
|
|
|
|
|
* defines SET list for bots
|
|
|
|
|
*/
|
|
|
|
|
typedef struct bot_setting {
|
|
|
|
|
char *option; /* option string */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
void *varptr; /* pointer to var */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
SET_TYPE type; /* type of var */
|
2004-07-10 22:39:50 +00:00
|
|
|
|
int min; /* min value */
|
|
|
|
|
int max; /* max value */
|
|
|
|
|
int ulevel; /* min user level */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
const char *desc; /* description of setting for messages e.g. seconds, days*/
|
2004-08-31 22:01:22 +00:00
|
|
|
|
const char **helptext; /* pointer to help text */
|
2004-07-28 19:14:27 +00:00
|
|
|
|
bot_set_handler handler; /* handler for custom/post-set processing */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
void *defaultval;/* default value for setting */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
}bot_setting;
|
|
|
|
|
|
2005-10-10 21:08:32 +00:00
|
|
|
|
#define NS_SETTING_END() { NULL, NULL, SET_TYPE_NONE, 0, 0, 0, NULL, NULL, NULL, NULL }
|
2004-03-18 22:17:23 +00:00
|
|
|
|
|
|
|
|
|
/** @brief Message function types
|
|
|
|
|
*
|
|
|
|
|
*/
|
2005-12-07 23:56:01 +00:00
|
|
|
|
typedef int (*timer_handler) ( void * );
|
2004-03-18 22:17:23 +00:00
|
|
|
|
|
2005-02-01 23:05:43 +00:00
|
|
|
|
/* Event system flags */
|
|
|
|
|
#define EVENT_FLAG_DISABLED 0x00000001 /* Event is disabled */
|
|
|
|
|
#define EVENT_FLAG_IGNORE_SYNCH 0x00000002 /* Event triggers even if not synched */
|
|
|
|
|
#define EVENT_FLAG_USE_EXCLUDE 0x00000004 /* Event observes global exclusions */
|
|
|
|
|
#define EVENT_FLAG_EXCLUDE_ME 0x00000008 /* Event excludes neostats bots and servers */
|
|
|
|
|
#define EVENT_FLAG_EXCLUDE_MODME 0x00000010 /* Event excludes module bots */
|
2005-09-12 13:07:54 +00:00
|
|
|
|
#define EVENT_FLAG_PERLCALL 0x00000020 /* Event is for a perl Module/Extension */
|
2004-07-25 00:17:49 +00:00
|
|
|
|
|
2005-07-18 15:01:27 +00:00
|
|
|
|
#ifdef USE_PERL
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/** @brief Forward declaration of perl events
|
2005-07-08 12:56:49 +00:00
|
|
|
|
*/
|
|
|
|
|
struct PerlEvent;
|
2005-09-13 20:36:05 +00:00
|
|
|
|
#endif /* USE_PERL */
|
2005-07-08 12:56:49 +00:00
|
|
|
|
|
2005-02-01 23:05:43 +00:00
|
|
|
|
/** @brief Event function types
|
|
|
|
|
*
|
|
|
|
|
*/
|
2005-10-13 22:00:05 +00:00
|
|
|
|
typedef int (*event_handler) ( const CmdParams *cmdparams );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
|
|
|
|
|
/** @brief ModuleEvent functions structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
2004-03-22 23:30:22 +00:00
|
|
|
|
|
|
|
|
|
typedef struct ModuleEvent {
|
2004-04-09 22:17:19 +00:00
|
|
|
|
Event event;
|
2005-02-13 23:28:27 +00:00
|
|
|
|
event_handler handler;
|
2004-07-25 00:17:49 +00:00
|
|
|
|
unsigned int flags;
|
2005-07-08 12:56:49 +00:00
|
|
|
|
#ifdef USE_PERL
|
|
|
|
|
struct PerlEvent *pe;
|
2005-07-08 22:57:59 +00:00
|
|
|
|
#endif /* USE_PERL */
|
2004-03-22 23:30:22 +00:00
|
|
|
|
}ModuleEvent;
|
|
|
|
|
|
2005-10-17 21:06:59 +00:00
|
|
|
|
#define NS_EVENT_END() { EVENT_NULL, NULL, 0 }
|
2005-09-19 20:11:48 +00:00
|
|
|
|
|
2004-03-25 22:48:44 +00:00
|
|
|
|
typedef int ModuleProtocol;
|
2004-05-20 21:17:00 +00:00
|
|
|
|
typedef int ModuleFeatures;
|
2004-09-29 22:15:39 +00:00
|
|
|
|
typedef int ModuleFlags;
|
2004-03-25 22:48:44 +00:00
|
|
|
|
|
2004-09-29 22:15:39 +00:00
|
|
|
|
#define MODULE_FLAG_NONE 0x00000000
|
|
|
|
|
#define MODULE_FLAG_AUTH 0x00000001
|
|
|
|
|
#define MODULE_FLAG_LOCAL_EXCLUDES 0x00000002
|
2005-09-02 20:21:10 +00:00
|
|
|
|
#define MODULE_FLAG_CTCP_VERSION 0x00000004
|
2004-07-27 12:44:20 +00:00
|
|
|
|
|
2005-08-30 22:21:36 +00:00
|
|
|
|
typedef enum MOD_TYPE {
|
|
|
|
|
/* standard C Modules */
|
|
|
|
|
MOD_TYPE_STANDARD = 1,
|
|
|
|
|
/* Perl Modules */
|
|
|
|
|
MOD_TYPE_PERL
|
|
|
|
|
} MOD_TYPE;
|
|
|
|
|
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** @brief Module Info structure
|
2004-03-25 22:48:44 +00:00
|
|
|
|
* This describes the module to the NeoStats core and provides information
|
|
|
|
|
* to end users when modules are queried.
|
|
|
|
|
* The presence of this structure is required but some fields are optional.
|
2004-03-22 23:30:22 +00:00
|
|
|
|
*/
|
|
|
|
|
typedef struct ModuleInfo {
|
2004-03-25 22:48:44 +00:00
|
|
|
|
/* REQUIRED:
|
|
|
|
|
* name of module e.g. StatServ */
|
|
|
|
|
const char *name;
|
|
|
|
|
/* REQUIRED:
|
|
|
|
|
* one line brief description of module */
|
|
|
|
|
const char *description;
|
|
|
|
|
/* OPTIONAL:
|
|
|
|
|
* pointer to a NULL terminated list with copyright information
|
|
|
|
|
* NeoStats will automatically provide a CREDITS command to output this
|
|
|
|
|
* use NULL for none */
|
|
|
|
|
const char **copyright;
|
|
|
|
|
/* OPTIONAL:
|
|
|
|
|
* pointer to a NULL terminated list with extended description
|
|
|
|
|
* NeoStats will automatically provide an ABOUT command to output this
|
|
|
|
|
* use NULL for none */
|
|
|
|
|
const char **about_text;
|
|
|
|
|
/* REQUIRED:
|
|
|
|
|
* version of neostats used to build module
|
|
|
|
|
* must be NEOSTATS_VERSION */
|
|
|
|
|
const char *neostats_version;
|
|
|
|
|
/* REQUIRED:
|
|
|
|
|
* string containing version of module */
|
|
|
|
|
const char *version;
|
|
|
|
|
/* REQUIRED: string containing build date of module
|
|
|
|
|
* should be __DATE__ */
|
|
|
|
|
const char *build_date;
|
|
|
|
|
/* REQUIRED: string containing build time of module
|
|
|
|
|
* should be __TIME__ */
|
|
|
|
|
const char *build_time;
|
|
|
|
|
/* OPTIONAL:
|
|
|
|
|
* Module control flags,
|
|
|
|
|
* use 0 if not needed */
|
|
|
|
|
const ModuleFlags flags;
|
|
|
|
|
/* OPTIONAL:
|
2004-05-20 21:17:00 +00:00
|
|
|
|
* Protocol flags for required protocol specfic features e.g. NICKIP
|
2004-03-25 22:48:44 +00:00
|
|
|
|
* use 0 if not needed */
|
|
|
|
|
const ModuleProtocol protocol;
|
2004-05-20 21:17:00 +00:00
|
|
|
|
/* OPTIONAL:
|
|
|
|
|
* Protocol flags for required protocol specfic features e.g. SETHOST
|
|
|
|
|
* use 0 if not needed */
|
|
|
|
|
const ModuleFeatures features;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
}ModuleInfo;
|
|
|
|
|
|
2005-08-22 18:16:13 +00:00
|
|
|
|
typedef int (*mod_auth) ( const Client *u );
|
2004-03-22 23:30:22 +00:00
|
|
|
|
|
2005-08-30 22:21:36 +00:00
|
|
|
|
/* Module type macros */
|
|
|
|
|
#define IS_STANDARD_MOD( mod ) ( ( mod )->type == MOD_TYPE_STANDARD )
|
|
|
|
|
#ifdef USE_PERL
|
|
|
|
|
#define IS_PERL_MOD( mod ) ( ( mod )->type == MOD_TYPE_PERL )
|
|
|
|
|
#else /* USE_PERL */
|
|
|
|
|
#define IS_PERL_MOD( mod ) ( 0 )
|
|
|
|
|
#endif /* USE_PERL */
|
|
|
|
|
|
2005-07-07 13:04:12 +00:00
|
|
|
|
#ifdef USE_PERL
|
|
|
|
|
|
|
|
|
|
/* forward decleration (in perlmod.h) for perl module info
|
|
|
|
|
* we don't include any perl includes here because it screws up
|
|
|
|
|
* some of the existing system defines (like readdir) */
|
|
|
|
|
struct PerlModInfo;
|
|
|
|
|
|
|
|
|
|
/* to save some chars while typing */
|
|
|
|
|
#define PMI PerlInterpreter
|
|
|
|
|
|
2005-07-08 22:57:59 +00:00
|
|
|
|
#endif /* USE_PERL */
|
2005-07-07 13:04:12 +00:00
|
|
|
|
|
2005-08-22 21:31:24 +00:00
|
|
|
|
#define MODULE_STATUS_SYNCHED 0x00000001
|
|
|
|
|
#define MODULE_STATUS_INSYNCH 0x00000002
|
|
|
|
|
#define MODULE_STATUS_ERROR 0x00000004
|
2007-08-10 21:02:07 +00:00
|
|
|
|
#define MODULE_STATUS_ROOTBOT 0x00000008
|
2005-08-22 21:31:24 +00:00
|
|
|
|
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** @brief Module structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
2005-10-17 19:19:54 +00:00
|
|
|
|
struct Module {
|
2005-08-30 22:21:36 +00:00
|
|
|
|
/** type of module */
|
|
|
|
|
MOD_TYPE type;
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/** Pointer to info structure */
|
2004-03-22 23:30:22 +00:00
|
|
|
|
ModuleInfo *info;
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/** Pointer to event list */
|
2004-07-27 23:05:50 +00:00
|
|
|
|
ModuleEvent **event_list;
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/** Optional module supplied auth callback for modules to authorise
|
|
|
|
|
* module commands not handled by core auth modules (e.g. SecureServ helpers) */
|
2005-04-11 21:35:40 +00:00
|
|
|
|
mod_auth authcb;
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/** Auth callback for auth modules */
|
2004-07-27 12:44:20 +00:00
|
|
|
|
mod_auth userauth;
|
2005-09-19 21:18:17 +00:00
|
|
|
|
/** Exclude list */
|
|
|
|
|
list_t *exclude_list;
|
|
|
|
|
/** Exclude command list */
|
2005-09-29 21:57:02 +00:00
|
|
|
|
bot_cmd *exclude_cmd_list;
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/** Dynamic library handle */
|
2005-04-11 21:35:40 +00:00
|
|
|
|
void *handle;
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/** index */
|
2004-03-25 22:48:44 +00:00
|
|
|
|
unsigned int modnum;
|
2005-08-22 21:31:24 +00:00
|
|
|
|
/** status flag for synch, error, etc */
|
|
|
|
|
unsigned int status;
|
2005-08-24 20:23:01 +00:00
|
|
|
|
/** moddata flags */
|
|
|
|
|
unsigned int userdatacnt;
|
|
|
|
|
unsigned int serverdatacnt;
|
|
|
|
|
unsigned int channeldatacnt;
|
2005-07-07 13:04:12 +00:00
|
|
|
|
#ifdef USE_PERL
|
|
|
|
|
struct PerlModInfo *pm;
|
2005-07-08 22:57:59 +00:00
|
|
|
|
#endif /* USE_PERL */
|
2005-10-17 19:19:54 +00:00
|
|
|
|
};
|
2004-03-22 23:30:22 +00:00
|
|
|
|
|
2005-08-22 21:31:24 +00:00
|
|
|
|
/* Set module status */
|
|
|
|
|
#define SetModuleSynched( m ) ( ( m )->status |= MODULE_STATUS_SYNCHED )
|
|
|
|
|
#define SetModuleInSynch( m ) ( ( m )->status |= MODULE_STATUS_INSYNCH )
|
|
|
|
|
#define SetModuleError( m ) ( ( m )->status |= MODULE_STATUS_ERROR )
|
2007-08-10 21:02:07 +00:00
|
|
|
|
#define SetModuleRootBot( m ) ( ( m )->status |= MODULE_STATUS_ROOTBOT )
|
2005-08-22 21:31:24 +00:00
|
|
|
|
/* Test module status */
|
|
|
|
|
#define IsModuleSynched( m ) ( ( m )->status & MODULE_STATUS_SYNCHED )
|
|
|
|
|
#define IsModuleInSynch( m ) ( ( m )->status & MODULE_STATUS_INSYNCH )
|
|
|
|
|
#define IsModuleError( m ) ( ( m )->status & MODULE_STATUS_ERROR )
|
2007-08-10 21:02:07 +00:00
|
|
|
|
#define IsModuleRootBot( m ) ( ( m )->status & MODULE_STATUS_ROOTBOT )
|
2005-08-22 21:31:24 +00:00
|
|
|
|
|
|
|
|
|
#define ModuleSynched() ( GET_CUR_MODULE()->status & MODULE_STATUS_SYNCHED )
|
|
|
|
|
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* Simple stack to manage run level replacing segv_module used in
|
|
|
|
|
* previous versions. This makes it easier to determine where we are
|
|
|
|
|
* running and avoids the need for modules to manage this or the core to
|
2004-04-18 22:28:02 +00:00
|
|
|
|
* have to set/reset when a module calls a core function which triggers
|
2004-08-31 22:01:22 +00:00
|
|
|
|
* other modules to run (e.g. AddBot)
|
2004-04-18 22:28:02 +00:00
|
|
|
|
*/
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* Run level stack */
|
|
|
|
|
EXPORTVAR extern Module *RunModule[10];
|
|
|
|
|
/* Run level stack index */
|
|
|
|
|
EXPORTVAR extern int RunLevel;
|
|
|
|
|
/* Macros to manage run level stack */
|
|
|
|
|
/* Set current run level */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define SET_RUN_LEVEL( moduleptr ) { if( RunLevel < 10 ) { RunLevel++; RunModule[RunLevel] = moduleptr; } }
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* Reset run level */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define RESET_RUN_LEVEL() { if( RunLevel > 0 ) { RunLevel--; } }
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* Get current run level module pointer */
|
2004-04-18 22:28:02 +00:00
|
|
|
|
#define GET_CUR_MODULE() RunModule[RunLevel]
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* Get current run level module index */
|
2005-08-24 20:23:01 +00:00
|
|
|
|
#define GET_CUR_MODULE_INDEX() RunModule[RunLevel]->modnum
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* Get current run level module name */
|
2004-04-18 22:28:02 +00:00
|
|
|
|
#define GET_CUR_MODNAME() RunModule[RunLevel]->info->name
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* Get current run level module version */
|
2005-02-17 22:39:50 +00:00
|
|
|
|
#define GET_CUR_MODVERSION() RunModule[RunLevel]->info->version
|
2004-04-18 22:28:02 +00:00
|
|
|
|
|
2005-03-18 12:29:37 +00:00
|
|
|
|
/** @brief Socket function types
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* socket interface type */
|
2005-03-25 23:12:26 +00:00
|
|
|
|
typedef enum SOCK_TYPE {
|
|
|
|
|
/* */
|
|
|
|
|
SOCK_STANDARD = 1,
|
|
|
|
|
/* */
|
|
|
|
|
SOCK_BUFFERED,
|
|
|
|
|
/* */
|
|
|
|
|
SOCK_LINEMODE,
|
|
|
|
|
/* */
|
|
|
|
|
SOCK_LISTEN,
|
|
|
|
|
/* */
|
|
|
|
|
SOCK_NATIVE,
|
|
|
|
|
}SOCK_TYPE;
|
2005-03-18 12:29:37 +00:00
|
|
|
|
|
|
|
|
|
typedef int (*sockcb)(int, void *data);
|
2005-10-20 21:21:35 +00:00
|
|
|
|
typedef int (*sockfunccb)(void *, void *, int);
|
2005-03-18 12:29:37 +00:00
|
|
|
|
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** @brief Module socket list structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
typedef struct Sock {
|
|
|
|
|
/** Owner module ptr */
|
2004-08-31 22:01:22 +00:00
|
|
|
|
Module *moduleptr;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** Socket number */
|
2005-03-25 23:12:26 +00:00
|
|
|
|
OS_SOCKET sock_no;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** Socket name */
|
|
|
|
|
char name[MAX_MOD_NAME];
|
|
|
|
|
/** socket interface (poll or standard) type */
|
|
|
|
|
int socktype;
|
|
|
|
|
/** data */
|
|
|
|
|
void *data;
|
|
|
|
|
/* if socktype = SOCK_STANDARD, function calls */
|
|
|
|
|
/** Socket read function */
|
|
|
|
|
/** rmsgs */
|
|
|
|
|
long rmsgs;
|
|
|
|
|
/** rbytes */
|
|
|
|
|
long rbytes;
|
2005-03-18 12:29:37 +00:00
|
|
|
|
/** smsgs */
|
|
|
|
|
long smsgs;
|
|
|
|
|
/** sbytes */
|
|
|
|
|
long sbytes;
|
|
|
|
|
union {
|
|
|
|
|
struct bufferevent *buffered;
|
|
|
|
|
struct event *event;
|
|
|
|
|
} event;
|
|
|
|
|
union {
|
|
|
|
|
struct linemode {
|
|
|
|
|
char *readbuf;
|
|
|
|
|
size_t readbufsize;
|
|
|
|
|
sockfunccb funccb;
|
|
|
|
|
sockcb errcb;
|
|
|
|
|
size_t recvq;
|
|
|
|
|
} linemode;
|
|
|
|
|
struct listenmode {
|
|
|
|
|
int port;
|
|
|
|
|
sockcb funccb;
|
|
|
|
|
} listenmode;
|
|
|
|
|
struct standmode {
|
|
|
|
|
sockfunccb readfunc;
|
|
|
|
|
sockcb writefunc;
|
|
|
|
|
} standmode;
|
|
|
|
|
} sfunc;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
} Sock;
|
|
|
|
|
|
2004-07-26 20:29:43 +00:00
|
|
|
|
typedef enum TIMER_TYPE {
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* Called at the specified interval */
|
2004-07-26 20:29:43 +00:00
|
|
|
|
TIMER_TYPE_INTERVAL,
|
2005-10-14 20:08:35 +00:00
|
|
|
|
/* Called at the beginning of the day (midnight) */
|
|
|
|
|
TIMER_TYPE_DAILY,
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* Called at the beginning of the week */
|
2004-09-28 19:38:04 +00:00
|
|
|
|
TIMER_TYPE_WEEKLY,
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* Called at the beginning of the month */
|
2004-09-28 19:38:04 +00:00
|
|
|
|
TIMER_TYPE_MONTHLY,
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* One shot countdown which is removed after trigger */
|
2004-08-11 20:16:06 +00:00
|
|
|
|
TIMER_TYPE_COUNTDOWN,
|
2004-07-26 20:29:43 +00:00
|
|
|
|
} TIMER_TYPE;
|
|
|
|
|
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** @brief Module Timer structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
typedef struct Timer {
|
|
|
|
|
/** Owner module ptr */
|
2004-08-31 22:01:22 +00:00
|
|
|
|
Module *moduleptr;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** Timer type */
|
2004-07-26 20:29:43 +00:00
|
|
|
|
TIMER_TYPE type;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** Timer name */
|
|
|
|
|
char name[MAX_MOD_NAME];
|
|
|
|
|
/** Timer interval */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
time_t interval;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** Time last run */
|
|
|
|
|
time_t lastrun;
|
2005-02-13 23:28:27 +00:00
|
|
|
|
/** Timer handler */
|
|
|
|
|
timer_handler handler;
|
2005-08-09 06:51:21 +00:00
|
|
|
|
/** Pointer to user suplied context */
|
|
|
|
|
void *userptr;
|
2008-01-15 17:40:14 +00:00
|
|
|
|
/** Next Run at time */
|
|
|
|
|
time_t nextrun;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
} Timer;
|
|
|
|
|
|
|
|
|
|
/** @brief BotInfo structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
2004-03-25 22:48:44 +00:00
|
|
|
|
typedef struct BotInfo {
|
|
|
|
|
/* REQUIRED: nick */
|
2004-03-22 23:30:22 +00:00
|
|
|
|
char nick[MAXNICK];
|
2005-02-01 23:05:43 +00:00
|
|
|
|
/* OPTIONAL: altnick, use "" if not needed */
|
2004-03-25 22:48:44 +00:00
|
|
|
|
char altnick[MAXNICK];
|
|
|
|
|
/* REQUIRED: user */
|
2004-03-22 23:30:22 +00:00
|
|
|
|
char user[MAXUSER];
|
2004-03-25 22:48:44 +00:00
|
|
|
|
/* REQUIRED: host */
|
2004-03-22 23:30:22 +00:00
|
|
|
|
char host[MAXHOST];
|
2004-03-25 22:48:44 +00:00
|
|
|
|
/* REQUIRED: realname */
|
2004-03-22 23:30:22 +00:00
|
|
|
|
char realname[MAXREALNAME];
|
2004-07-10 22:39:50 +00:00
|
|
|
|
/* OPTIONAL: flags */
|
|
|
|
|
unsigned int flags;
|
|
|
|
|
/* OPTIONAL: bot command list pointer */
|
|
|
|
|
bot_cmd *bot_cmd_list;
|
|
|
|
|
/* OPTIONAL: bot command setting pointer */
|
|
|
|
|
bot_setting *bot_setting_list;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
} BotInfo;
|
|
|
|
|
|
|
|
|
|
/** @brief Bot structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2005-10-17 19:19:54 +00:00
|
|
|
|
struct Bot
|
|
|
|
|
{
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** Owner module ptr */
|
2004-08-31 22:01:22 +00:00
|
|
|
|
Module *moduleptr;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/** Nick */
|
2004-07-17 17:01:53 +00:00
|
|
|
|
char name[MAXNICK];
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/* bot flags */
|
|
|
|
|
unsigned int flags;
|
|
|
|
|
/* hash for command list */
|
|
|
|
|
hash_t *botcmds;
|
|
|
|
|
/* hash for settings */
|
2004-07-10 22:39:50 +00:00
|
|
|
|
hash_t *botsettings;
|
|
|
|
|
/* hash for bot_info settings */
|
|
|
|
|
bot_setting *bot_info_settings;
|
2004-03-22 23:30:22 +00:00
|
|
|
|
/* min ulevel for settings */
|
2004-07-10 22:39:50 +00:00
|
|
|
|
int set_ulevel;
|
2004-05-14 17:43:49 +00:00
|
|
|
|
/* Link back to user struct associated with this bot*/
|
2004-08-31 22:01:22 +00:00
|
|
|
|
Client *u;
|
2005-07-19 09:32:20 +00:00
|
|
|
|
/* link back to BotInfo struct so if we have a module that needs to free it, it can be referenced */
|
|
|
|
|
BotInfo *botinfo;
|
2005-05-17 22:54:18 +00:00
|
|
|
|
/* pointer for module use */
|
|
|
|
|
void *moddata;
|
2005-10-17 19:19:54 +00:00
|
|
|
|
};
|
2004-04-09 22:17:19 +00:00
|
|
|
|
|
2005-12-04 11:38:25 +00:00
|
|
|
|
/* current state */
|
2005-09-29 07:58:21 +00:00
|
|
|
|
typedef enum MQS_STATE {
|
|
|
|
|
MQS_DISCONNECTED,
|
|
|
|
|
MQS_CONNECTING,
|
|
|
|
|
MQS_SENTAUTH,
|
|
|
|
|
MQS_OK,
|
|
|
|
|
} MQS_STATE;
|
|
|
|
|
|
2005-12-04 11:38:25 +00:00
|
|
|
|
/* connection strategy */
|
|
|
|
|
typedef enum MQS_CONNECT {
|
2005-12-11 06:33:31 +00:00
|
|
|
|
MQ_CONNECT_ERROR,
|
2005-12-04 11:38:25 +00:00
|
|
|
|
MQ_CONNECT_NO,
|
|
|
|
|
MQ_CONNECT_DEMAND,
|
2005-12-11 06:33:31 +00:00
|
|
|
|
MQ_CONNECT_YES,
|
2005-12-04 11:38:25 +00:00
|
|
|
|
} MQS_CONNECT;
|
|
|
|
|
|
|
|
|
|
|
2005-09-29 07:58:21 +00:00
|
|
|
|
/* this is the NeoNet details */
|
|
|
|
|
typedef struct updateserver {
|
|
|
|
|
MQS_STATE state;
|
|
|
|
|
OS_SOCKET sock;
|
2005-12-04 11:38:25 +00:00
|
|
|
|
MQS_CONNECT connect;
|
2005-09-29 07:58:21 +00:00
|
|
|
|
char username[MAXUSER];
|
|
|
|
|
char password [MAXUSER];
|
|
|
|
|
char hostname[MAXHOST];
|
|
|
|
|
int port;
|
2005-10-05 11:31:14 +00:00
|
|
|
|
Sock *Sockinfo;
|
2005-12-04 11:38:25 +00:00
|
|
|
|
/* max of 8 groups so far */
|
|
|
|
|
char groups[8][MAXUSER];
|
|
|
|
|
int nogroups;
|
2005-09-29 07:58:21 +00:00
|
|
|
|
}updateserver;
|
|
|
|
|
|
|
|
|
|
extern updateserver mqs;
|
|
|
|
|
|
|
|
|
|
/* MQ Server update sending functions */
|
|
|
|
|
typedef enum MQ_MSG_TYPE {
|
|
|
|
|
UPDATE_SSREPORT=1,
|
|
|
|
|
UPDATE_OPSBREPORT,
|
|
|
|
|
} MQ_MSG_TYPE;
|
|
|
|
|
|
|
|
|
|
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* load configuration associated with this bot_setting list */
|
2007-01-14 20:37:40 +00:00
|
|
|
|
EXPORTFUNC void ModuleConfig( bot_setting *bot_settings );
|
2004-03-22 23:30:22 +00:00
|
|
|
|
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* Add a new timer callback to NeoStats */
|
2005-08-09 06:51:21 +00:00
|
|
|
|
EXPORTFUNC int AddTimer( TIMER_TYPE type, timer_handler handler, const char *name, int interval, void *userptr );
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* Delete a timer callback from NeoStats */
|
2004-10-27 20:21:46 +00:00
|
|
|
|
EXPORTFUNC int DelTimer( const char *timer_name );
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* Change timer callback interval counter */
|
2004-10-27 20:21:46 +00:00
|
|
|
|
EXPORTFUNC int SetTimerInterval( const char *timer_name, int interval );
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* Find timer from name */
|
2004-10-27 20:21:46 +00:00
|
|
|
|
EXPORTFUNC Timer *FindTimer( const char *timer_name );
|
2004-03-22 23:30:22 +00:00
|
|
|
|
|
2005-03-25 23:12:26 +00:00
|
|
|
|
EXPORTFUNC Sock *AddSock( SOCK_TYPE type, const char *sock_name, int socknum, sockfunccb readfunc, sockcb writefunc, short what, void *data, struct timeval *tv);
|
|
|
|
|
EXPORTFUNC int UpdateSock( Sock *sock, short what, short reset, struct timeval *tv );
|
|
|
|
|
EXPORTFUNC int DelSock( Sock *sock );
|
|
|
|
|
EXPORTFUNC Sock *FindSock( const char *sock_name );
|
|
|
|
|
EXPORTFUNC OS_SOCKET sock_connect( int socktype, struct in_addr ip, int port );
|
|
|
|
|
EXPORTFUNC Sock *add_listen_sock( const char *sock_name, const int port, int type, sockcb acceptcb, void *data );
|
|
|
|
|
EXPORTFUNC Sock *add_linemode_socket( const char *sock_name, OS_SOCKET socknum, sockfunccb readcb, sockcb errcb, void *arg );
|
2005-11-23 23:30:34 +00:00
|
|
|
|
EXPORTFUNC int send_to_sock( Sock *sock, const char *buf, size_t buflen );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* Add a new bot to NeoStats */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC Bot *AddBot( BotInfo *botinfo );
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* Find bot from name */
|
2004-10-27 20:21:46 +00:00
|
|
|
|
EXPORTFUNC Bot *FindBot( const char *bot_name );
|
2004-07-29 18:34:35 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* main.c */
|
2005-11-23 23:30:34 +00:00
|
|
|
|
EXPORTFUNC void fatal_error( char *file, int line, const char *func, char *error_text ) __attribute__( ( noreturn ) );
|
|
|
|
|
#define FATAL_ERROR( error_text ) fatal_error(__FILE__, __LINE__, __PRETTY_FUNCTION__, ( error_text ) );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-08-24 18:54:28 +00:00
|
|
|
|
/* nsmemory.c */
|
2005-10-11 21:53:48 +00:00
|
|
|
|
EXPORTFUNC void *ns_malloc( size_t size );
|
|
|
|
|
EXPORTFUNC void *ns_calloc( size_t size );
|
|
|
|
|
EXPORTFUNC void *ns_realloc( void *ptr, size_t size );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC void _ns_free( void **ptr );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define ns_free( ptr ) _ns_free( ( void **) &( ptr ) );
|
2004-08-24 18:54:28 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* misc.c */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
EXPORTFUNC unsigned hrand( const unsigned upperbound, const unsigned lowerbound );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC void strip( char *line );
|
|
|
|
|
EXPORTFUNC char *sstrdup( const char *s );
|
2005-11-14 22:33:08 +00:00
|
|
|
|
EXPORTFUNC char *ns_strlwr( char *s );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC void AddStringToList( char ***List, char S[], int *C );
|
|
|
|
|
EXPORTFUNC void strip_mirc_codes( char *text );
|
2005-09-09 13:07:54 +00:00
|
|
|
|
EXPORTFUNC void clean_string(char *text, size_t len);
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC char *sctime( time_t t );
|
|
|
|
|
EXPORTFUNC char *sftime( time_t t );
|
|
|
|
|
EXPORTFUNC char *make_safe_filename( char *name );
|
2005-10-12 20:45:22 +00:00
|
|
|
|
EXPORTFUNC char *joinbuf( char **av, int ac, int from );
|
2005-10-12 20:34:09 +00:00
|
|
|
|
EXPORTFUNC unsigned int split_buf( char *buf, char ***argv );
|
2008-01-13 21:46:18 +00:00
|
|
|
|
EXPORTFUNC unsigned int ircsplitbuf( char *buf, char ***argv, int colon_special );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-09-30 19:59:46 +00:00
|
|
|
|
/* For use by modules to report command information channel which
|
|
|
|
|
* takes account of neostats reporting options
|
|
|
|
|
*/
|
2004-10-27 20:21:46 +00:00
|
|
|
|
EXPORTFUNC void CommandReport( const Bot *botptr, const char *fmt, ... );
|
2004-09-30 19:59:46 +00:00
|
|
|
|
|
2004-07-22 23:00:20 +00:00
|
|
|
|
/* IRC interface for modules
|
|
|
|
|
* Modules use these functions to perform actions on IRC
|
|
|
|
|
* They use a similar naming convention to the same actions as IRC commands
|
|
|
|
|
* issued by users from an IRC client.
|
|
|
|
|
*/
|
|
|
|
|
|
2004-07-16 22:36:54 +00:00
|
|
|
|
/* Messaging functions to send messages to users and channels
|
|
|
|
|
*/
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int irc_prefmsg( const Bot *botptr, const Client *target, const char *fmt, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_prefmsg_list( const Bot *botptr, const Client *target, const char **text );
|
|
|
|
|
EXPORTFUNC int irc_privmsg( const Bot *botptr, const Client *target, const char *fmt, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_privmsg_list( const Bot *botptr, const Client *target, const char **text );
|
|
|
|
|
EXPORTFUNC int irc_notice( const Bot *botptr, const Client *target, const char *fmt, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_chanprivmsg( const Bot *botptr, const char *chan, const char *fmt, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_channotice( const Bot *botptr, const char *chan, const char *fmt, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
2004-07-22 23:00:20 +00:00
|
|
|
|
|
2005-05-01 20:17:59 +00:00
|
|
|
|
EXPORTFUNC int irc_dccmsgall( const char *fmt, ...) __attribute__((format(printf,1,2))); /* 1=format 2=params */
|
|
|
|
|
|
|
|
|
|
|
2004-07-22 23:00:20 +00:00
|
|
|
|
/* Specialised messaging functions for global messages, services channel
|
|
|
|
|
* alerts and numeric responses
|
|
|
|
|
*/
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int irc_chanalert( const Bot *botptr, const char *fmt, ...) __attribute__((format(printf,2,3))); /* 2=format 3=params */
|
|
|
|
|
EXPORTFUNC int irc_globops( const Bot *botptr, const char *fmt, ...) __attribute__((format(printf,2,3))); /* 2=format 3=params */
|
|
|
|
|
EXPORTFUNC int irc_wallops( const Bot *botptr, const char *fmt, ...) __attribute__((format(printf,2,3))); /* 2=format 3=params */
|
|
|
|
|
EXPORTFUNC int irc_numeric( const int numeric, const char *target, const char *data, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
2005-08-09 04:24:03 +00:00
|
|
|
|
EXPORTFUNC int irc_smo( const char *source, const char *umodetarget, const char *msg );
|
2004-07-16 22:36:54 +00:00
|
|
|
|
|
|
|
|
|
/* General irc actions for join/part channels etc
|
|
|
|
|
*/
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int irc_nickchange( const Bot *botptr, const char *newnick );
|
|
|
|
|
EXPORTFUNC int irc_quit( const Bot *botptr, const char *quitmsg );
|
|
|
|
|
EXPORTFUNC int irc_join( const Bot *botptr, const char *chan, const char *chanmodes );
|
|
|
|
|
EXPORTFUNC int irc_part( const Bot *botptr, const char *chan, const char *quitmsg );
|
|
|
|
|
EXPORTFUNC int irc_kick( const Bot *botptr, const char *chan, const char *target, const char *reason );
|
|
|
|
|
EXPORTFUNC int irc_invite( const Bot *botptr, const Client *target, const char *chan );
|
2005-04-30 22:09:25 +00:00
|
|
|
|
EXPORTFUNC int irc_topic( const Bot *botptr, const Channel *channel, const char *topic );
|
|
|
|
|
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int irc_cloakhost( const Bot *botptr );
|
|
|
|
|
EXPORTFUNC int irc_setname( const Bot *botptr, const char *realname );
|
2004-07-16 22:36:54 +00:00
|
|
|
|
|
|
|
|
|
/* Mode functions
|
|
|
|
|
*/
|
2005-10-20 22:20:08 +00:00
|
|
|
|
EXPORTFUNC int irc_umode( const Bot *botptr, const char *target, unsigned int mode );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int irc_cmode( const Bot *botptr, const char *chan, const char *mode, const char *args );
|
|
|
|
|
EXPORTFUNC int irc_chanusermode( const Bot *botptr, const char *chan, const char *mode, const char *target );
|
2004-07-16 22:36:54 +00:00
|
|
|
|
|
|
|
|
|
/* Oper functions
|
|
|
|
|
* Require an opered bot to operate
|
|
|
|
|
*/
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int irc_kill( const Bot *botptr, const char *target, const char *reason, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_akill( const Bot *botptr, const char *host, const char *ident, const unsigned long length, const char *reason, ...) __attribute__((format(printf,5,6))); /* 5=format 6=params */
|
|
|
|
|
EXPORTFUNC int irc_rakill( const Bot *botptr, const char *host, const char *ident );
|
2005-03-15 00:15:10 +00:00
|
|
|
|
EXPORTFUNC int irc_sqline( const Bot *botptr, const char *mask, const char *reason, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_unsqline( const Bot *botptr, const char *mask );
|
|
|
|
|
EXPORTFUNC int irc_sgline( const Bot *botptr, const char *mask, const char *reason, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_unsgline( const Bot *botptr, const char *mask );
|
2005-05-10 20:53:24 +00:00
|
|
|
|
EXPORTFUNC int irc_gline( const Bot *botptr, const char *mask, const char *reason, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_remgline( const Bot *botptr, const char *mask );
|
2005-03-15 00:15:10 +00:00
|
|
|
|
EXPORTFUNC int irc_zline( const Bot *botptr, const char *mask, const char *reason, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_unzline( const Bot *botptr, const char *mask );
|
2005-05-10 20:53:24 +00:00
|
|
|
|
EXPORTFUNC int irc_kline( const Bot *botptr, const char *mask, const char *reason, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_unkline( const Bot *botptr, const char *mask );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int irc_swhois( const char *target, const char *swhois );
|
|
|
|
|
EXPORTFUNC int irc_sethost( const Bot *botptr, const char *host );
|
|
|
|
|
EXPORTFUNC int irc_setident( const Bot *botptr, const char *ident );
|
2004-07-16 22:36:54 +00:00
|
|
|
|
|
2005-04-07 23:35:49 +00:00
|
|
|
|
/* Other */
|
2005-04-23 22:46:40 +00:00
|
|
|
|
EXPORTFUNC int irc_stats( const char *source, const char type, const char *target );
|
2005-04-07 23:35:49 +00:00
|
|
|
|
|
2004-10-20 19:58:48 +00:00
|
|
|
|
int irc_ping( const char *source, const char *reply, const char *to );
|
2007-11-16 12:56:16 +00:00
|
|
|
|
int irc_pong( const char *reply, const char *data );
|
2004-07-16 22:36:54 +00:00
|
|
|
|
|
|
|
|
|
/* SVS functions
|
|
|
|
|
* these operate from the server rather than a bot
|
|
|
|
|
*/
|
2005-07-16 21:33:50 +00:00
|
|
|
|
EXPORTFUNC int irc_svsnick( const Bot *botptr, const Client *target, const char *newnick );
|
|
|
|
|
EXPORTFUNC int irc_svsjoin( const Bot *botptr, const Client *target, const char *chan );
|
|
|
|
|
EXPORTFUNC int irc_svspart( const Bot *botptr, const Client *target, const char *chan );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int irc_svshost( const Bot *botptr, Client *target, const char *vhost );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
EXPORTFUNC int irc_svsmode( const Bot *botptr, const Client *target, const char *modes );
|
|
|
|
|
EXPORTFUNC int irc_svskill( const Bot *botptr, const Client *target, const char *reason, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
|
|
|
|
|
EXPORTFUNC int irc_svstime( const Bot *botptr, const Client *target, const time_t ts );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-07-25 00:17:49 +00:00
|
|
|
|
/* CTCP functions to correctly format CTCP requests and replies
|
|
|
|
|
*/
|
2005-07-16 21:33:50 +00:00
|
|
|
|
EXPORTFUNC int irc_ctcp_version_req( const Bot *botptr, const Client *target );
|
|
|
|
|
EXPORTFUNC int irc_ctcp_version_rpl( const Bot *botptr, const Client *target, const char *version );
|
|
|
|
|
EXPORTFUNC int irc_ctcp_ping_req( const Bot *botptr, const Client *target );
|
2004-07-25 00:17:49 +00:00
|
|
|
|
|
2005-07-16 21:33:50 +00:00
|
|
|
|
EXPORTFUNC int irc_ctcp_finger_req( const Bot *botptr, const Client *target );
|
2004-07-25 00:17:49 +00:00
|
|
|
|
|
2005-07-16 21:33:50 +00:00
|
|
|
|
EXPORTFUNC int irc_ctcp_action_req( const Bot *botptr, const Client *target, const char *action );
|
2005-08-31 22:17:47 +00:00
|
|
|
|
EXPORTFUNC int irc_ctcp_action_req_channel( const Bot *botptr, const Channel *channel, const char *action );
|
2004-07-25 00:17:49 +00:00
|
|
|
|
|
2005-12-07 23:56:01 +00:00
|
|
|
|
EXPORTFUNC int irc_ctcp_time_req( const Bot *botptr, const Client *target );
|
2005-04-28 21:55:48 +00:00
|
|
|
|
|
2005-08-31 22:17:47 +00:00
|
|
|
|
EXPORTFUNC int irc_ctcp_unhandled_req( const Bot *botptr, const Client *target, const char *ctcp_command );
|
|
|
|
|
EXPORTFUNC int irc_ctcp_unhandled_rpl( const Bot *botptr, const Client *target, const char *ctcp_command, const char *ctcp_parameters );
|
|
|
|
|
|
|
|
|
|
|
2005-05-30 01:19:11 +00:00
|
|
|
|
/* bots.c */
|
2005-10-10 21:08:32 +00:00
|
|
|
|
EXPORTFUNC int GenerateBotNick( char *nickbuf, size_t stublen, int alphacount, int numcount);
|
2005-05-30 01:19:11 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* users.c */
|
2004-10-27 20:21:46 +00:00
|
|
|
|
EXPORTFUNC Client *FindUser( const char *nick );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int UserLevel( Client *u );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
/* server.c */
|
2004-10-27 20:21:46 +00:00
|
|
|
|
EXPORTFUNC Client *FindServer( const char *name );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-10-17 21:06:59 +00:00
|
|
|
|
EXPORTFUNC Client *FindClient( const char *name );
|
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* chans.c */
|
2004-10-27 20:21:46 +00:00
|
|
|
|
EXPORTFUNC Channel *FindChannel( const char *chan );
|
2005-08-20 22:53:26 +00:00
|
|
|
|
EXPORTFUNC int test_cmode( const Channel *c, unsigned int mode );
|
2005-05-01 20:17:59 +00:00
|
|
|
|
EXPORTFUNC int IsChannelMember( const Channel *c, const Client *u );
|
2005-10-13 22:00:05 +00:00
|
|
|
|
EXPORTFUNC int test_cumode( const Channel *c, const Client *u, unsigned int mode );
|
2005-02-28 23:28:52 +00:00
|
|
|
|
EXPORTFUNC Channel *GetRandomChannel( void );
|
2005-10-11 20:16:01 +00:00
|
|
|
|
EXPORTFUNC Client *GetRandomChannelMember( const Channel *c, int uge );
|
2005-02-28 23:32:44 +00:00
|
|
|
|
EXPORTFUNC char *GetRandomChannelKey( int length );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define IsChanOp( chan, nick ) test_cumode( chan, nick, CUMODE_CHANOP )
|
|
|
|
|
#define IsChanHalfOp( chan, nick ) test_cumode( chan, nick, CUMODE_HALFOP )
|
|
|
|
|
#define IsChanVoice( chan, nick ) test_cumode( chan, nick, CUMODE_VOICE )
|
|
|
|
|
#define IsChanOwner( chan, nick ) test_cumode( chan, nick, CUMODE_CHANOWNER )
|
|
|
|
|
#define IsChanProt( chan, nick ) test_cumode( chan, nick, CUMODE_CHANPROT )
|
|
|
|
|
#define IsChanAdmin( chan, nick ) test_cumode( chan, nick, CUMODE_CHANADMIN )
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-09-06 11:49:14 +00:00
|
|
|
|
EXPORTVAR extern unsigned char UmodeChRegNick;
|
2004-07-10 22:39:50 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* dns.c */
|
2005-12-07 23:56:01 +00:00
|
|
|
|
EXPORTFUNC int dns_lookup( char *str, adns_rrtype type, void (*callback) ( void *data, adns_answer *a), void *data );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
/* services.c */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int add_services_cmd_list( bot_cmd *bot_cmd_list );
|
2005-10-13 22:00:05 +00:00
|
|
|
|
EXPORTFUNC void del_services_cmd_list( const bot_cmd *bot_cmd_list );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int add_services_set_list( bot_setting *bot_setting_list );
|
2005-10-13 22:00:05 +00:00
|
|
|
|
EXPORTFUNC void del_services_set_list( const bot_setting *bot_setting_list );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int add_bot_cmd_list( Bot *bot_ptr, bot_cmd *bot_cmd_list );
|
2005-10-13 22:00:05 +00:00
|
|
|
|
EXPORTFUNC void del_bot_cmd_list( const Bot *bot_ptr, const bot_cmd *bot_cmd_list );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int add_bot_setting_list( Bot *bot_ptr, bot_setting *bot_setting_list );
|
2005-10-13 22:00:05 +00:00
|
|
|
|
EXPORTFUNC void del_bot_setting_list( const Bot *bot_ptr, const bot_setting *bot_setting_list );
|
2004-09-22 20:25:28 +00:00
|
|
|
|
|
2005-08-18 21:01:25 +00:00
|
|
|
|
EXPORTFUNC Client *FindValidUser( const Bot *botptr, const Client *u, const char *target_nick );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
/* transfer.c stuff */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
typedef void (transfer_callback) ( void *data, int returncode, char *body, int bodysize );
|
|
|
|
|
EXPORTFUNC int new_transfer( char *url, char *params, NS_TRANSFER savetofileormemory, char *filename, void *data, transfer_callback *callback );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* Is the client excluded */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define IsExcluded( x ) ( ( x ) && ( ( x )->flags & NS_FLAG_EXCLUDED ) )
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* Is the client a NeoStats one? */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define IsMe( x ) ( ( x ) && ( ( x )->flags & CLIENT_FLAG_ME ) )
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-10-20 19:58:48 +00:00
|
|
|
|
/* Is the client synched? */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define IsSynched( x ) ( ( x ) && ( ( x )->flags & CLIENT_FLAG_SYNCHED ) )
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
/* Mark server as synched */
|
2007-01-28 08:45:11 +00:00
|
|
|
|
#define SetServerSynched( x ) ( ( ( x )->flags |= CLIENT_FLAG_SYNCHED ) )
|
|
|
|
|
|
|
|
|
|
/* Mark Server as Unsynced */
|
2007-02-08 13:09:08 +00:00
|
|
|
|
#define SetSynching(x) ( ( ( x )->flags &= ~CLIENT_FLAG_SYNCHED ) )
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-09-01 18:08:58 +00:00
|
|
|
|
/* Has NeoStats issued a SETHOST for this user? */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define IsUserSetHosted( x ) ( ( x ) && ( ( x )->flags & CLIENT_FLAG_SETHOST ) )
|
2004-09-01 18:08:58 +00:00
|
|
|
|
|
2005-02-05 00:12:03 +00:00
|
|
|
|
/* Is the client marked away? */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
#define IsAway( x ) ( ( x ) && ( x->user->is_away ) )
|
2005-02-05 00:12:03 +00:00
|
|
|
|
|
2007-01-21 07:13:32 +00:00
|
|
|
|
EXPORTFUNC int ValidateString (const char *string);
|
2005-08-17 20:40:17 +00:00
|
|
|
|
EXPORTFUNC int ValidateNick( const char *nick );
|
2005-08-22 18:16:13 +00:00
|
|
|
|
EXPORTFUNC int ValidateNickWild( const char *nick );
|
2005-08-17 20:40:17 +00:00
|
|
|
|
EXPORTFUNC int ValidateUser( const char *username );
|
2005-08-22 18:16:13 +00:00
|
|
|
|
EXPORTFUNC int ValidateUserWild( const char *username );
|
2005-08-17 20:40:17 +00:00
|
|
|
|
EXPORTFUNC int ValidateHost( const char *hostname );
|
2005-08-22 18:16:13 +00:00
|
|
|
|
EXPORTFUNC int ValidateHostWild( const char *hostname );
|
|
|
|
|
EXPORTFUNC int ValidateUserHost( const char *userhost );
|
|
|
|
|
EXPORTFUNC int ValidateUserHostWild( const char *userhost );
|
2005-08-17 20:40:17 +00:00
|
|
|
|
EXPORTFUNC int ValidateURL( const char *url );
|
|
|
|
|
EXPORTFUNC int ValidateChannel( const char *channel_name );
|
2005-08-22 18:16:13 +00:00
|
|
|
|
EXPORTFUNC int ValidateChannelWild( const char *channel_name );
|
2005-08-17 20:40:17 +00:00
|
|
|
|
EXPORTFUNC int ValidateChannelKey( const char *key );
|
2005-09-19 20:11:48 +00:00
|
|
|
|
EXPORTFUNC int IsJustWildcard( const char *mask, int ishostmask );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2005-11-24 21:44:35 +00:00
|
|
|
|
/* DBA */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#define CONFIG_TABLE_NAME "config"
|
2004-09-22 20:25:28 +00:00
|
|
|
|
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* Row fetch handler type */
|
2005-03-17 19:51:29 +00:00
|
|
|
|
typedef int (*DBRowHandler) ( void *data, int size );
|
2004-09-22 20:25:28 +00:00
|
|
|
|
|
2006-01-14 08:11:30 +00:00
|
|
|
|
/* Row fetch handler type version 2 (returns key as well) */
|
|
|
|
|
typedef int (*DBRowHandler2) ( char *key, void *data, int size );
|
|
|
|
|
|
2004-09-22 20:25:28 +00:00
|
|
|
|
/* DB API */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int DBAOpenDatabase( void );
|
|
|
|
|
EXPORTFUNC int DBACloseDatabase( void );
|
2005-08-17 23:57:40 +00:00
|
|
|
|
EXPORTFUNC int DBAOpenTable( const char *table );
|
|
|
|
|
EXPORTFUNC int DBACloseTable( const char *table );
|
2005-08-19 22:59:11 +00:00
|
|
|
|
EXPORTFUNC int DBAStore( const char *table, const char *key, void *data, int size );
|
|
|
|
|
EXPORTFUNC int DBAFetch( const char *table, const char *key, void *data, int size );
|
|
|
|
|
EXPORTFUNC int DBADelete( const char *table, const char * key );
|
2005-08-18 21:01:25 +00:00
|
|
|
|
EXPORTFUNC int DBAFetchRows( const char *table, DBRowHandler handler );
|
2006-07-16 09:55:30 +00:00
|
|
|
|
EXPORTFUNC int DBAFetchRows2( const char *table, DBRowHandler2 handler );
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* DB API Macros to wrap common types */
|
2005-09-29 21:11:06 +00:00
|
|
|
|
#define DBAStoreBool( table, key, data ) DBAStore( table, key, ( void * )data, sizeof ( int ) )
|
|
|
|
|
#define DBAStoreInt( table, key, data ) DBAStore( table, key, ( void * )data, sizeof ( int ) )
|
|
|
|
|
#define DBAStoreStr( table, key, data, size ) DBAStore( table, key, ( void * )data, size)
|
|
|
|
|
#define DBAFetchBool( table, key, data ) DBAFetch( table, key, ( void * )data, sizeof ( int ) )
|
|
|
|
|
#define DBAFetchInt( table, key, data ) DBAFetch( table, key, ( void * )data, sizeof ( int ) )
|
|
|
|
|
#define DBAFetchStr( table, key, data, size ) DBAFetch( table, key, ( void * )data, size)
|
2005-02-06 17:47:06 +00:00
|
|
|
|
/* DB API Macros to wrap common config types */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#define DBAStoreConfigBool( key, data ) DBAStoreBool(CONFIG_TABLE_NAME, key, data)
|
|
|
|
|
#define DBAStoreConfigInt( key, data ) DBAStoreInt(CONFIG_TABLE_NAME, key, data)
|
|
|
|
|
#define DBAStoreConfigStr( key, data, size ) DBAStoreStr(CONFIG_TABLE_NAME, key, data, size)
|
|
|
|
|
#define DBAFetchConfigBool( key, data ) DBAFetchBool(CONFIG_TABLE_NAME, key, data)
|
|
|
|
|
#define DBAFetchConfigInt( key, data ) DBAFetchInt(CONFIG_TABLE_NAME, key, data)
|
|
|
|
|
#define DBAFetchConfigStr( key, data , size) DBAFetchStr(CONFIG_TABLE_NAME, key, data, size)
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
/* log.c API export */
|
|
|
|
|
/* define the log levels */
|
|
|
|
|
|
2005-11-15 20:06:09 +00:00
|
|
|
|
typedef enum NS_LOG_LEVEL {
|
2004-03-16 23:14:25 +00:00
|
|
|
|
LOG_CRITICAL=1, /* critical crash type notices */
|
|
|
|
|
LOG_ERROR, /* something is majorly wrong */
|
|
|
|
|
LOG_WARNING, /* Hey, you should know about this type messages */
|
|
|
|
|
LOG_NOTICE, /* did you know messages */
|
|
|
|
|
LOG_NORMAL, /* our normal logging level? */
|
|
|
|
|
LOG_INFO, /* lots of info about what we are doing */
|
2005-10-12 20:45:22 +00:00
|
|
|
|
LOG_LEVELMAX = LOG_INFO,
|
2005-11-15 20:06:09 +00:00
|
|
|
|
} NS_LOG_LEVEL;
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
2004-04-09 22:17:19 +00:00
|
|
|
|
/* define debug levels */
|
|
|
|
|
|
2005-11-15 20:06:09 +00:00
|
|
|
|
typedef enum NS_DEBUG_LEVEL {
|
2005-12-07 23:56:01 +00:00
|
|
|
|
DEBUGRX = 1,
|
2004-07-23 16:08:30 +00:00
|
|
|
|
DEBUGTX,
|
2004-10-20 19:58:48 +00:00
|
|
|
|
DEBUG1,
|
|
|
|
|
DEBUG2,
|
|
|
|
|
DEBUG3,
|
|
|
|
|
DEBUG4,
|
2004-04-09 22:17:19 +00:00
|
|
|
|
DEBUG5,
|
|
|
|
|
DEBUG6,
|
|
|
|
|
DEBUG7,
|
|
|
|
|
DEBUG8,
|
|
|
|
|
DEBUG9,
|
2004-04-18 22:28:02 +00:00
|
|
|
|
DEBUG10,
|
2005-10-12 20:45:22 +00:00
|
|
|
|
DEBUGMAX = DEBUG10,
|
2005-11-15 20:06:09 +00:00
|
|
|
|
} NS_DEBUG_LEVEL;
|
2004-04-09 22:17:19 +00:00
|
|
|
|
|
2004-03-16 23:14:25 +00:00
|
|
|
|
/* this is for the neostats assert replacement. */
|
|
|
|
|
/* Version 2.4 and later of GCC define a magical variable _PRETTY_FUNCTION__'
|
|
|
|
|
which contains the name of the function currently being defined.
|
|
|
|
|
This is broken in G++ before version 2.6.
|
|
|
|
|
C9x has a similar variable called __func__, but prefer the GCC one since
|
|
|
|
|
it demangles C++ function names. */
|
|
|
|
|
|
|
|
|
|
#define __NASSERT_FUNCTION __PRETTY_FUNCTION__
|
|
|
|
|
/* Not all compilers provide __STRING so define it here if it is unknown */
|
|
|
|
|
#ifndef __STRING
|
|
|
|
|
#define __STRING(x) #x
|
|
|
|
|
#endif /* __STRING */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __ASSERT_VOID_CAST
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#define __ASSERT_VOID_CAST ( void)
|
|
|
|
|
#endif /* __ASSERT_VOID_CAST */
|
|
|
|
|
extern void nassert_fail( const char *expr, const char *file, const int line, const char *infunk );
|
2004-03-16 23:14:25 +00:00
|
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
#define nassert(expr) \
|
|
|
|
|
(__ASSERT_VOID_CAST ((expr) ? 0 : \
|
2005-10-11 21:53:48 +00:00
|
|
|
|
(nassert_fail((__STRING((expr))), __FILE__, __LINE__, __NASSERT_FUNCTION), 0)))
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#else /* NDEBUG */
|
2004-03-16 23:14:25 +00:00
|
|
|
|
#define nassert(expr) (__ASSERT_VOID_CAST (0))
|
2004-10-20 19:58:48 +00:00
|
|
|
|
#endif /* NDEBUG */
|
2008-01-15 10:28:08 +00:00
|
|
|
|
EXPORTFUNC void CaptureBackTrace (const char *file, const int line, const char *func);
|
2005-11-15 20:06:09 +00:00
|
|
|
|
EXPORTFUNC void nlog( NS_LOG_LEVEL level, const char *fmt, ...) __attribute__((format(printf,2,3))); /* 2=format 3=params */
|
|
|
|
|
EXPORTFUNC void dlog( NS_DEBUG_LEVEL level, const char *fmt, ...) __attribute__((format(printf,2,3))); /* 2=format 3=params */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* List walk handler type */
|
2005-02-05 00:12:03 +00:00
|
|
|
|
typedef int (*ChannelListHandler) ( Channel *c, void *v );
|
2005-10-07 20:04:13 +00:00
|
|
|
|
EXPORTFUNC int ProcessChannelList( const ChannelListHandler handler, void *v );
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* List walk handler type */
|
2005-08-22 20:38:47 +00:00
|
|
|
|
typedef int (*ChannelMemberListHandler) ( Channel *c, ChannelMember *m, void *v );
|
2005-10-07 20:04:13 +00:00
|
|
|
|
EXPORTFUNC int ProcessChannelMembers( Channel *c, const ChannelMemberListHandler handler, void *v );
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* List walk handler type */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
typedef int (*UserListHandler) ( Client *u, void *v );
|
2005-10-07 20:04:13 +00:00
|
|
|
|
EXPORTFUNC int ProcessUserList( const UserListHandler handler, void *v );
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* List walk handler type */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
typedef int (*ServerListHandler) ( Client *s, void *v );
|
2005-10-07 20:04:13 +00:00
|
|
|
|
EXPORTFUNC int ProcessServerList( const ServerListHandler handler, void *v );
|
2005-08-22 18:16:13 +00:00
|
|
|
|
/* List walk handler type */
|
2005-08-24 21:43:09 +00:00
|
|
|
|
typedef void( *ServerMapHandler )( const Client *s, int isroot, int depth, void *v );
|
2005-10-07 20:04:13 +00:00
|
|
|
|
EXPORTFUNC void ProcessServerMap( const ServerMapHandler handler, int useexclusions, void *v );
|
2005-08-24 21:43:09 +00:00
|
|
|
|
/* List walk handler type */
|
2005-08-20 22:53:26 +00:00
|
|
|
|
typedef int (*ModuleListHandler) ( Module *module_ptr, void *v );
|
2005-10-07 20:04:13 +00:00
|
|
|
|
EXPORTFUNC int ProcessModuleList( const ModuleListHandler handler, void *v );
|
2005-08-22 20:52:02 +00:00
|
|
|
|
/* List walk handler type */
|
|
|
|
|
typedef int (*BanListHandler) ( Ban *ban, void *v );
|
2005-10-07 20:04:13 +00:00
|
|
|
|
EXPORTFUNC int ProcessBanList( const BanListHandler handler, void *v );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
|
|
|
|
|
EXPORTFUNC int HaveFeature( int mask );
|
|
|
|
|
|
2005-04-11 21:35:40 +00:00
|
|
|
|
EXPORTFUNC void AddEvent( ModuleEvent *eventptr );
|
|
|
|
|
EXPORTFUNC void AddEventList( ModuleEvent *eventlistptr );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC void DeleteEvent( Event event );
|
2005-10-28 22:14:21 +00:00
|
|
|
|
EXPORTFUNC void DeleteEventList( const ModuleEvent *eventlistptr );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC void SetAllEventFlags( unsigned int flag, unsigned int enable );
|
|
|
|
|
EXPORTFUNC void SetEventFlags( Event event, unsigned int flag, unsigned int enable );
|
|
|
|
|
EXPORTFUNC void EnableEvent( Event event );
|
|
|
|
|
EXPORTFUNC void DisableEvent( Event event );
|
2004-07-26 20:29:43 +00:00
|
|
|
|
|
2004-08-24 18:54:28 +00:00
|
|
|
|
/* String functions */
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* vs[n]printf replacements */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int ircvsprintf( char *buf, const char *fmt, va_list args );
|
|
|
|
|
EXPORTFUNC int ircvsnprintf( char *buf, size_t size, const char *fmt, va_list args );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* s[n]printf replacements */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int ircsprintf( char *buf, const char *fmt, ...) __attribute__((format(printf,2,3)) ); /* 2=format 3=params */
|
|
|
|
|
EXPORTFUNC int ircsnprintf( char *buf, size_t size, const char *fmt, ...) __attribute__((format(printf,3,4)) ); /* 3=format 4=params */
|
2004-08-24 18:54:28 +00:00
|
|
|
|
/* str[n]casecmp replacements */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC int ircstrcasecmp( const char *s1, const char *s2 );
|
|
|
|
|
EXPORTFUNC int ircstrncasecmp( const char *s1, const char *s2, size_t size );
|
2004-08-24 18:54:28 +00:00
|
|
|
|
|
2005-02-06 17:47:06 +00:00
|
|
|
|
EXPORTFUNC int match( const char *mask, const char *name );
|
2004-08-24 18:54:28 +00:00
|
|
|
|
|
2004-08-03 19:50:54 +00:00
|
|
|
|
/*
|
|
|
|
|
* Portability wrapper functions
|
|
|
|
|
*/
|
2005-04-07 12:49:50 +00:00
|
|
|
|
|
|
|
|
|
/* File system functions */
|
|
|
|
|
EXPORTFUNC int os_mkdir( const char *filename, mode_t mode );
|
2005-10-15 22:30:54 +00:00
|
|
|
|
EXPORTFUNC int os_create_dir( const char *dirname );
|
2005-04-07 12:49:50 +00:00
|
|
|
|
EXPORTFUNC FILE *os_fopen( const char *filename, const char *filemode );
|
|
|
|
|
EXPORTFUNC int os_fclose( FILE *handle );
|
|
|
|
|
EXPORTFUNC int os_fseek( FILE *handle, long offset, int origin );
|
|
|
|
|
EXPORTFUNC long os_ftell( FILE *handle );
|
2005-10-28 22:14:21 +00:00
|
|
|
|
EXPORTFUNC int os_fprintf( FILE *handle, const char *fmt, ...) __attribute__((format(printf,2,3)) ); /* 2=format 3=params */
|
2005-03-15 00:15:10 +00:00
|
|
|
|
EXPORTFUNC int os_fputs( const char *string, FILE *handle );
|
2005-10-28 22:14:21 +00:00
|
|
|
|
EXPORTFUNC size_t os_fread( void *buffer, size_t size, size_t count, FILE *handle );
|
2005-04-07 12:49:50 +00:00
|
|
|
|
EXPORTFUNC char *os_fgets( char *string, int n, FILE *handle );
|
2005-10-28 22:14:21 +00:00
|
|
|
|
EXPORTFUNC size_t os_fwrite( const void *buffer, size_t size, size_t count, FILE *handle );
|
2005-04-07 12:49:50 +00:00
|
|
|
|
EXPORTFUNC int os_fflush( FILE *handle );
|
|
|
|
|
EXPORTFUNC int os_rename( const char *oldname, const char *newname );
|
|
|
|
|
EXPORTFUNC int os_stat( const char *path, struct stat *buffer );
|
|
|
|
|
EXPORTFUNC int os_access( const char *path, int mode );
|
|
|
|
|
EXPORTFUNC int os_write( int fd, const void *buffer, unsigned int count );
|
|
|
|
|
EXPORTFUNC int os_close( int fd );
|
|
|
|
|
EXPORTFUNC int os_mkstemp( char *ftemplate );
|
|
|
|
|
EXPORTFUNC int os_write_temp_file( char *ftemplate, const void *buffer, unsigned int count );
|
|
|
|
|
EXPORTFUNC int os_file_get_size( const char *filename );
|
2005-11-23 23:30:34 +00:00
|
|
|
|
EXPORTFUNC int os_chmod( const char *filename, int pmode );
|
2005-09-06 11:49:14 +00:00
|
|
|
|
EXPORTVAR extern int os_file_errno;
|
2005-04-14 21:12:52 +00:00
|
|
|
|
|
|
|
|
|
EXPORTFUNC char *os_strerror( void );
|
2005-04-07 12:49:50 +00:00
|
|
|
|
EXPORTFUNC size_t os_strftime( char *strDest, size_t maxsize, const char *format, const struct tm *timeptr );
|
|
|
|
|
EXPORTFUNC struct tm* os_localtime( const time_t *timer );
|
|
|
|
|
/* Socket functions */
|
|
|
|
|
EXPORTFUNC int os_sock_close( OS_SOCKET sock );
|
|
|
|
|
EXPORTFUNC int os_sock_write( OS_SOCKET s, const char *buf, int len );
|
2005-08-18 21:01:25 +00:00
|
|
|
|
EXPORTFUNC int os_sock_sendto( OS_SOCKET s, const char *buf, int len, int flags, const struct sockaddr* to, int tolen );
|
2005-04-07 12:49:50 +00:00
|
|
|
|
EXPORTFUNC int os_sock_read( OS_SOCKET s, char *buf, int len );
|
2005-12-07 23:07:16 +00:00
|
|
|
|
EXPORTFUNC int os_sock_recvfrom( OS_SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen );
|
2005-04-07 12:49:50 +00:00
|
|
|
|
EXPORTFUNC int os_sock_set_nonblocking( OS_SOCKET s );
|
2005-04-05 22:35:00 +00:00
|
|
|
|
EXPORTFUNC int os_sock_connect( OS_SOCKET s, const struct sockaddr* name, int namelen );
|
2005-04-13 23:05:21 +00:00
|
|
|
|
EXPORTFUNC OS_SOCKET os_sock_socket( int socket_family, int socket_type, int protocol );
|
|
|
|
|
EXPORTFUNC int os_sock_bind( OS_SOCKET s, const struct sockaddr* name, int namelen );
|
2005-04-07 12:49:50 +00:00
|
|
|
|
EXPORTFUNC int os_sock_listen( OS_SOCKET s, int backlog );
|
2005-08-18 21:01:25 +00:00
|
|
|
|
EXPORTFUNC int os_sock_setsockopt( OS_SOCKET s, int level, int optname, const char *optval, int optlen );
|
|
|
|
|
EXPORTFUNC int os_sock_ioctl( OS_SOCKET s, int cmd, void *argp );
|
2005-09-06 11:49:14 +00:00
|
|
|
|
EXPORTVAR extern int os_sock_errno;
|
2005-04-07 20:39:44 +00:00
|
|
|
|
EXPORTFUNC char *os_sock_getlasterrorstring( void );
|
2005-10-17 21:06:59 +00:00
|
|
|
|
EXPORTFUNC char *os_sock_strerror( int sockerrno );
|
2005-10-10 21:24:03 +00:00
|
|
|
|
EXPORTFUNC int os_sock_select( int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout );
|
2005-04-07 12:49:50 +00:00
|
|
|
|
|
|
|
|
|
/* Memory functions */
|
|
|
|
|
EXPORTFUNC void *os_memset( void *dest, int c, size_t count );
|
|
|
|
|
EXPORTFUNC void *os_memcpy( void *dest, const void *src, size_t count );
|
|
|
|
|
EXPORTFUNC void *os_malloc( size_t size );
|
|
|
|
|
EXPORTFUNC void os_free( void *ptr );
|
2004-08-03 19:50:54 +00:00
|
|
|
|
|
2005-05-30 01:19:11 +00:00
|
|
|
|
#ifdef WIN32
|
|
|
|
|
#define OS_SOCK_EMSGSIZE WSAEMSGSIZE
|
|
|
|
|
#define OS_SOCK_EAGAIN WSAEPROCLIM
|
|
|
|
|
#define OS_SOCK_ENOBUFS WSAENOBUFS
|
|
|
|
|
#define OS_SOCK_EWOULDBLOCK WSAEWOULDBLOCK
|
|
|
|
|
#define OS_SOCK_EINPROGRESS WSAEINPROGRESS
|
|
|
|
|
#define OS_SOCK_EINTR WSAEINTR
|
2005-07-08 22:57:59 +00:00
|
|
|
|
#else /* WIN32 */
|
2005-05-30 01:19:11 +00:00
|
|
|
|
#define OS_SOCK_EMSGSIZE EMSGSIZE
|
|
|
|
|
#define OS_SOCK_EAGAIN EAGAIN
|
|
|
|
|
#define OS_SOCK_ENOBUFS ENOBUFS
|
|
|
|
|
#define OS_SOCK_EWOULDBLOCK EWOULDBLOCK
|
|
|
|
|
#define OS_SOCK_EINPROGRESS EINPROGRESS
|
|
|
|
|
#define OS_SOCK_EINTR EINTR
|
2005-07-08 22:57:59 +00:00
|
|
|
|
#endif /* WIN32 */
|
2005-04-07 21:11:05 +00:00
|
|
|
|
|
2004-03-17 23:40:38 +00:00
|
|
|
|
/*
|
2005-07-16 21:33:50 +00:00
|
|
|
|
* Module interface
|
2004-03-17 23:40:38 +00:00
|
|
|
|
*/
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module basic interface */
|
2004-07-27 23:05:50 +00:00
|
|
|
|
MODULEVAR extern ModuleInfo module_info;
|
2005-02-18 22:18:02 +00:00
|
|
|
|
MODULEFUNC int ModInit( void );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
MODULEFUNC int ModSynch( void );
|
2005-02-18 22:18:02 +00:00
|
|
|
|
MODULEFUNC int ModFini( void );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module event interface */
|
2004-07-27 23:05:50 +00:00
|
|
|
|
MODULEVAR extern ModuleEvent module_events[];
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module auth interface */
|
2005-08-18 21:01:25 +00:00
|
|
|
|
MODULEFUNC int ModAuthUser( const Client *u );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module exclude interface */
|
2005-08-18 21:01:25 +00:00
|
|
|
|
EXPORTFUNC int ModIsServerExcluded( const Client *s );
|
|
|
|
|
EXPORTFUNC int ModIsUserExcluded( const Client *u );
|
|
|
|
|
EXPORTFUNC int ModIsChannelExcluded( const Channel *c );
|
2004-09-02 20:50:09 +00:00
|
|
|
|
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module data pointer interface */
|
|
|
|
|
/* Module data pointer interface channel */
|
2005-10-12 18:01:04 +00:00
|
|
|
|
EXPORTFUNC void *AllocChannelModPtr( Channel *c, size_t size );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC void FreeChannelModPtr( Channel *c );
|
2005-08-19 20:38:11 +00:00
|
|
|
|
EXPORTFUNC void *GetChannelModPtr( const Channel *c );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module data pointer interface user */
|
2005-10-12 18:01:04 +00:00
|
|
|
|
EXPORTFUNC void *AllocUserModPtr( Client *u, size_t size );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC void FreeUserModPtr( Client *u );
|
2005-08-19 20:38:11 +00:00
|
|
|
|
EXPORTFUNC void *GetUserModPtr( const Client *u );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module data pointer interface server */
|
2005-10-12 18:01:04 +00:00
|
|
|
|
EXPORTFUNC void *AllocServerModPtr( Client *s, size_t size );
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC void FreeServerModPtr( Client *s );
|
2005-08-19 20:38:11 +00:00
|
|
|
|
EXPORTFUNC void *GetServerModPtr( const Client *s );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module data pointer interface bot */
|
2005-10-12 18:01:04 +00:00
|
|
|
|
EXPORTFUNC void *AllocBotModPtr( Bot *pBot, size_t size );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
EXPORTFUNC void FreeBotModPtr( Bot *pBot );
|
2005-12-07 23:56:01 +00:00
|
|
|
|
EXPORTFUNC void *GetBotModPtr( const Bot *pBot );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module data value interface */
|
|
|
|
|
/* Module data value interface channel */
|
2005-04-28 14:58:02 +00:00
|
|
|
|
EXPORTFUNC void ClearChannelModValue( Channel *c );
|
|
|
|
|
EXPORTFUNC void SetChannelModValue( Channel *c, void *data );
|
2005-08-19 20:38:11 +00:00
|
|
|
|
EXPORTFUNC void *GetChannelModValue( const Channel *c );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module data value interface user */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC void ClearUserModValue( Client *u );
|
|
|
|
|
EXPORTFUNC void SetUserModValue( Client *u, void *data );
|
2005-08-19 20:38:11 +00:00
|
|
|
|
EXPORTFUNC void *GetUserModValue( const Client *u );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module data value interface server */
|
2004-10-20 19:58:48 +00:00
|
|
|
|
EXPORTFUNC void ClearServerModValue( Client *s );
|
|
|
|
|
EXPORTFUNC void SetServerModValue( Client *s, void *data );
|
2005-08-19 20:38:11 +00:00
|
|
|
|
EXPORTFUNC void *GetServerModValue( const Client *s );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
/* Module data value interface bot */
|
|
|
|
|
EXPORTFUNC void ClearBotModValue( Bot *pBot );
|
|
|
|
|
EXPORTFUNC void SetBotModValue( Bot *pBot, void *data );
|
2005-08-19 20:38:11 +00:00
|
|
|
|
EXPORTFUNC void *GetBotModValue( const Bot *pBot );
|
2005-07-16 21:33:50 +00:00
|
|
|
|
|
2005-06-11 06:09:46 +00:00
|
|
|
|
|
2005-11-19 10:23:07 +00:00
|
|
|
|
#ifdef BUILDINGMOD
|
|
|
|
|
/* these defines collide with modules that include neostats.h */
|
|
|
|
|
#undef PACKAGE
|
|
|
|
|
#undef VERSION
|
2005-12-11 05:27:54 +00:00
|
|
|
|
#undef DEBUG
|
2005-11-19 10:23:07 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2005-11-23 23:30:34 +00:00
|
|
|
|
#endif /* _NEOSTATS_H_ */
|