summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2009-02-09 21:01:05 +0000
committerrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2009-02-09 21:01:05 +0000
commitd7d01bdc5c667a1fafd95241282b58e03b4caa5b (patch)
treef1482d8734da609923c6d8af6bc8fcb0fc187534 /include
parentd49b3a25fda5f597491e73640dd1e76babc240eb (diff)
Squashed commit: merge next (1.9.1) back to trunk.
SVN users, NOTE: THIS WILL NOT BUILD, NOR SHOULD YOU RUN IT YET. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1953 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'include')
-rw-r--r--include/extern.h49
-rw-r--r--include/modules.h162
-rw-r--r--include/services.h43
-rw-r--r--include/users.h50
4 files changed, 183 insertions, 121 deletions
diff --git a/include/extern.h b/include/extern.h
index a12c3448a..a455a4a0b 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -137,10 +137,10 @@ E Entry *entry_create(char *mask);
E Entry *entry_add(EList *list, const char *mask);
E void entry_delete(EList *list, Entry *e);
E EList *list_create();
-E int entry_match(Entry *e, char *nick, char *user, char *host, uint32 ip);
-E int entry_match_mask(Entry *e, char *mask, uint32 ip);
-E Entry *elist_match(EList *list, char *nick, char *user, char *host, uint32 ip);
-E Entry *elist_match_mask(EList *list, char *mask, uint32 ip);
+E int entry_match(Entry *e, const char *nick, const char *user, const char *host, uint32 ip);
+E int entry_match_mask(Entry *e, const char *mask, uint32 ip);
+E Entry *elist_match(EList *list, const char *nick, const char *user, const char *host, uint32 ip);
+E Entry *elist_match_mask(EList *list, const char *mask, uint32 ip);
E Entry *elist_match_user(EList *list, User *u);
E Entry *elist_find_mask(EList *list, const char *mask);
E long get_memuse(EList *list);
@@ -942,7 +942,6 @@ E User *do_nick(const char *source, const char *nick, const char *username, cons
const char *server, const char *realname, time_t ts, uint32 svid, uint32 ip, const char *vhost, const char *uid);
E void do_umode(const char *source, int ac, const char **av);
-E void do_umode2(const char *source, int ac, const char **av);
E void do_quit(const char *source, int ac, const char **av);
E void do_kill(const char *source, const char *reason);
@@ -950,54 +949,16 @@ E int is_oper(User * user);
E int is_protected(User * user);
E int is_excepted(ChannelInfo * ci, User * user);
-E int is_excepted_mask(ChannelInfo * ci, char *mask);
+E int is_excepted_mask(ChannelInfo * ci, const char *mask);
E int match_usermask(const char *mask, User * user);
-E int match_userip(const char *mask, User * user, char *host);
E void split_usermask(const char *mask, char **nick, char **user,
char **host);
E char *create_mask(User * u);
-#ifdef USE_MYSQL
-/**** mysql.c ****/
-E MYSQL *mysql;
-E MYSQL_RES *mysql_res;
-E MYSQL_FIELD *mysql_fields;
-E MYSQL_ROW mysql_row;
-
-E int db_mysql_init();
-E int db_mysql_open();
-E int db_mysql_close();
-E int db_mysql_query(char *sql);
-E char *db_mysql_quote(char *sql);
-E char *db_mysql_quote_buffer(char *sql, int size);
-E int db_mysql_try(const char *fmt, ...);
-E int db_mysql_save_ns_core(NickCore * nc);
-E int db_mysql_save_ns_alias(NickAlias * na);
-E int db_mysql_save_ns_req(NickRequest * nr);
-E int db_mysql_save_cs_info(ChannelInfo * ci);
-E int db_mysql_save_os_db(unsigned int maxucnt, unsigned int maxutime,
- SList * ak, SList * sgl, SList * sql,
- SList * szl);
-E int db_mysql_save_news(NewsItem * ni);
-E int db_mysql_save_exceptions(Exception * e);
-E int db_mysql_save_hs_core(HostCore * hc);
-E int db_mysql_save_bs_core(BotInfo * bi);
-E int db_mysql_load_bs_dbase();
-E int db_mysql_load_hs_dbase();
-E int db_mysql_load_ns_dbase();
-E int db_mysql_load_ns_req_dbase();
-E int db_mysql_load_cs_dbase();
-E int db_mysql_load_os_dbase();
-E int db_mysql_load_exceptions();
-E int db_mysql_load_news();
-E unsigned int mysql_rand();
-#endif
/******************************************************************************/
-E char *common_get_vident(User *u);
-E char *common_get_vhost(User *u);
E const char* base64enc(long i);
E long base64dec(char *b64);
E long base64dects(const char *ts);
diff --git a/include/modules.h b/include/modules.h
index 5c4eaa67c..eb0b8c4a6 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -20,30 +20,24 @@
/* Cross OS compatibility macros */
#ifdef _WIN32
-typedef HMODULE ano_module_t;
-
-#define ano_modopen(file) LoadLibrary(file)
-/* ano_moderr in modules.c */
-#define ano_modsym(file, symbol) (HMODULE)GetProcAddress(file, symbol)
-#define ano_modclose(file) FreeLibrary(file) ? 0 : 1
-#define ano_modclearerr() SetLastError(0)
-#define MODULE_EXT ".so"
-
+ typedef HMODULE ano_module_t;
+
+ #define dlopen(file, unused) LoadLibrary(file)
+ MDE const char *dlerror();
+ #define dlsym(file, symbol) (HMODULE)GetProcAddress(file, symbol)
+ #define dlclose(file) FreeLibrary(file) ? 0 : 1
+ #define ano_modclearerr() SetLastError(0)
+ #define MODULE_EXT ".so"
#else
-typedef void * ano_module_t;
-
-#define ano_modopen(file) dlopen(file, RTLD_LAZY)
-#define ano_moderr() dlerror()
-#define ano_modsym(file, symbol) dlsym(file, symbol)
-#define ano_modclose(file) dlclose(file)
-/* We call dlerror() here because it clears the module error after being
- * called. This previously read 'errno = 0', but that didn't work on
- * all POSIX-compliant architectures. This way the error is guaranteed
- * to be cleared, POSIX-wise. -GD
- */
-#define ano_modclearerr() dlerror()
-#define MODULE_EXT ".so"
+ typedef void * ano_module_t;
+ /* We call dlerror() here because it clears the module error after being
+ * called. This previously read 'errno = 0', but that didn't work on
+ * all POSIX-compliant architectures. This way the error is guaranteed
+ * to be cleared, POSIX-wise. -GD
+ */
+ #define ano_modclearerr() dlerror()
+ #define MODULE_EXT ".so"
#endif
@@ -51,8 +45,13 @@ typedef void * ano_module_t;
#define CMD_HASH(x) (((x)[0]&31)<<5 | ((x)[1]&31)) /* Will gen a hash from a string :) */
#define MAX_CMD_HASH 1024
-#define MOD_STOP 1
-#define MOD_CONT 0
+/** The return value from commands.
+ */
+enum CommandReturn
+{
+ MOD_CONT,
+ MOD_STOP
+};
#define HOSTSERV HS_cmdTable /* using HOSTSERV etc. looks nicer than HS_cmdTable for modules */
#define BOTSERV BS_cmdTable
@@ -122,7 +121,6 @@ typedef enum { MOD_OP_LOAD, MOD_OP_UNLOAD } ModuleOperation;
/*************************************************************************/
/* Structure for information about a *Serv command. */
-typedef struct Command_ Command;
struct CommandHash;
typedef struct ModuleLang_ ModuleLang;
typedef struct ModuleHash_ ModuleHash;
@@ -148,6 +146,86 @@ struct ModuleLang_ {
char **argv;
};
+/** Every services command is a class, inheriting from Command.
+ */
+class Command
+{
+ public:
+ size_t MaxParams;
+ size_t MinParams;
+ std::string name;
+
+ /** Create a new command.
+ * @param min_params The minimum number of parameters the parser will require to execute this command
+ * @param max_params The maximum number of parameters the parser will create, after max_params, all will be combined into the last argument.
+ * NOTE: If max_params is not set (default), there is no limit to the max number of params.
+ */
+ Command(const std::string &sname, size_t min_params, size_t max_params = 0) : MaxParams(max_params), MinParams(min_params), name(sname)
+ {
+ this->has_priv = NULL;
+ this->help_param1 = NULL;
+ this->help_param2 = NULL;
+ this->help_param3 = NULL;
+ this->help_param4 = NULL;
+ this->core = 0;
+ this->next = NULL;
+ this->mod_name = NULL;
+ this->service = NULL;
+ this->all_help = NULL;
+ this->regular_help = NULL;
+ this->oper_help = NULL;
+ this->admin_help = NULL;
+ this->root_help = NULL;
+ }
+
+ ~Command()
+ {
+ this->has_priv = NULL;
+ if (this->mod_name) {
+ delete [] this->mod_name;
+ }
+ if (this->service) {
+ delete [] this->service;
+ }
+ this->next = NULL;
+ }
+
+ /** Execute this command.
+ * @param u The user executing the command.
+ */
+ virtual CommandReturn Execute(User *u, std::vector<std::string> &) { return MOD_CONT; }
+
+ /** Requested when the user is requesting help on this command. Help on this command should be sent to the user.
+ * @param u The user requesting help
+ * @param subcommand The subcommand the user is requesting help on, or an empty string. (e.g. /ns help set foo bar lol gives a subcommand of "FOO BAR LOL")
+ * @return true if help was provided to the user, false otherwise.
+ */
+ virtual bool OnHelp(User *u, const std::string &subcommand) { return false; }
+
+ /** Requested when the user provides bad syntax to this command (not enough params, etc).
+ * @param u The user executing the command.
+ */
+ virtual void OnBadSyntax(User *u) { }
+
+ int (*has_priv)(User *u); /* Returns 1 if user may use command, else 0 */
+
+ char *help_param1;
+ char *help_param2;
+ char *help_param3;
+ char *help_param4;
+
+ /* Module related stuff */
+ int core; /* Can this command be deleted? */
+ char *mod_name; /* Name of the module who owns us, NULL for core's */
+ char *service; /* Service we provide this command for */
+ int (*all_help)(User *u);
+ int (*regular_help)(User *u);
+ int (*oper_help)(User *u);
+ int (*admin_help)(User *u);
+ int (*root_help)(User *u);
+
+ Command *next; /* Next command responsible for the same command */
+};
/** Every module in Anope is actually a class.
*/
class CoreExport Module
@@ -398,38 +476,6 @@ struct ModuleHash_ {
ModuleHash *next;
};
-struct Command_ {
- char *name;
- int (*routine)(User *u);
- int (*has_priv)(User *u); /* Returns 1 if user may use command, else 0 */
-
- /* Regrettably, these are hard-coded to correspond to current privilege
- * levels (v4.0). Suggestions for better ways to do this are
- * appreciated.
- */
- int helpmsg_all; /* Displayed to all users; -1 = no message */
- int helpmsg_reg; /* Displayed to regular users only */
- int helpmsg_oper; /* Displayed to Services operators only */
- int helpmsg_admin; /* Displayed to Services admins only */
- int helpmsg_root; /* Displayed to Services root only */
- char *help_param1;
- char *help_param2;
- char *help_param3;
- char *help_param4;
-
- /* Module related stuff */
- int core; /* Can this command be deleted? */
- char *mod_name; /* Name of the module who owns us, NULL for core's */
- char *service; /* Service we provide this command for */
- int (*all_help)(User *u);
- int (*regular_help)(User *u);
- int (*oper_help)(User *u);
- int (*admin_help)(User *u);
- int (*root_help)(User *u);
-
- Command *next; /* Next command responsible for the same command */
-};
-
struct CommandHash {
char *name; /* Name of the command */
Command *c; /* Actual command */
@@ -494,8 +540,6 @@ extern MDE char *mod_current_buffer;
/*************************************************************************/
/*************************************************************************/
/* Command Managment Functions */
-MDE Command *createCommand(const char *name,int (*func)(User *u),int (*has_priv)(User *u),int help_all, int help_reg, int help_oper, int help_admin,int help_root);
-MDE int destroyCommand(Command *c); /* destroy a command */
Command *findCommand(CommandHash *cmdTable[], const char *name); /* Find a command */
/*************************************************************************/
diff --git a/include/services.h b/include/services.h
index 46e21728b..76a2878fa 100644
--- a/include/services.h
+++ b/include/services.h
@@ -542,7 +542,6 @@ struct ircdcapab_ {
uint32 vhost;
uint32 ssj3;
uint32 nick2;
- uint32 umode2;
uint32 vl;
uint32 tlkext;
uint32 dodkey;
@@ -1173,7 +1172,7 @@ typedef struct ircd_modes_ {
#define CUS_HALFOP 0x0004 /* Halfop (+h) */
#define CUS_OWNER 0x0008 /* Owner/Founder (+q) */
#define CUS_PROTECT 0x0010 /* Protected users (+a) */
-#define CUS_DEOPPED 0x0080 /* User has been specifically deopped */
+/* #define CUS_DEOPPED 0x0080 */ /* Removed due to IRCd checking it */
#define MUT_DEOP 0
#define MUT_OP 1
@@ -1218,12 +1217,11 @@ struct capabinfo_ {
#define CAPAB_TOKEN 0x00400000
#define CAPAB_SSJ3 0x00800000
#define CAPAB_NICK2 0x01000000
-#define CAPAB_UMODE2 0x02000000
-#define CAPAB_VL 0x04000000
-#define CAPAB_TLKEXT 0x08000000
-#define CAPAB_CHANMODE 0x10000000
-#define CAPAB_SJB64 0x20000000
-#define CAPAB_NICKCHARS 0x40000000
+#define CAPAB_VL 0x02000000
+#define CAPAB_TLKEXT 0x04000000
+#define CAPAB_CHANMODE 0x08000000
+#define CAPAB_SJB64 0x10000000
+#define CAPAB_NICKCHARS 0x20000000
/*************************************************************************/
@@ -1311,14 +1309,24 @@ private:
virtual void SendTopic(BotInfo *, const char *, const char *, const char *, time_t) = 0;
virtual void SendVhostDel(User *) { }
virtual void SendAkill(const char *, const char *, const char *, time_t, time_t, const char *) = 0;
- virtual void SendSVSKill(const char *source, const char *user, const char *fmt, ...)
+ virtual bool CanSVSKill(const char *source, const char *user, const char *buf)
+ {
+ return true;
+ }
+ virtual bool SendSVSKill(const char *source, const char *user, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZE] = "";
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
va_end(args);
- SendSVSKillInternal(source, user, buf);
+
+ if (CanSVSKill(source, user, buf))
+ {
+ SendSVSKillInternal(source, user, buf);
+ }
+
+ return false;
}
virtual void SendSVSMode(User *, int, const char **) = 0;
virtual void SendMode(BotInfo *bi, const char *dest, const char *fmt, ...)
@@ -1331,14 +1339,25 @@ private:
SendModeInternal(bi, dest, buf);
}
virtual void SendClientIntroduction(const char *, const char *, const char *, const char *, const char *, const char *uid) = 0;
- virtual void SendKick(BotInfo *bi, const char *chan, const char *user, const char *fmt, ...)
+ virtual bool CanKick(BotInfo *bi, const char *chan, const char *user, const char *buf)
+ {
+ return true;
+ }
+ virtual bool SendKick(BotInfo *bi, const char *chan, const char *user, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZE] = "";
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
va_end(args);
- SendKickInternal(bi, chan, user, buf);
+
+ if (CanKick(bi, chan, user, buf))
+ {
+ SendKickInternal(bi, chan, user, buf);
+ return true;
+ }
+
+ return false;
}
virtual void SendNoticeChanops(BotInfo *bi, const char *dest, const char *fmt, ...)
{
diff --git a/include/users.h b/include/users.h
index 9c0c85824..a8ab1b9e8 100644
--- a/include/users.h
+++ b/include/users.h
@@ -22,17 +22,19 @@ struct u_chaninfolist {
/* Online user and channel data. */
class CoreExport User : public Extensible
{
- public: // XXX: exposing a tiny bit too much
+ private:
+ std::string vident;
+ std::string ident;
+ std::string uid;
+public: // XXX: exposing a tiny bit too much
User *next, *prev;
char nick[NICKMAX];
- char *username; /* ident */
char *host; /* User's real hostname */
char *hostip; /* User's IP number */
char *vhost; /* User's virtual hostname */
std::string chost; /* User's cloaked hostname */
- char *vident; /* User's virtual ident */
char *realname; /* Realname */
Server *server; /* Server user is connected to */
char *nickTrack; /* Nick Tracking */
@@ -40,7 +42,6 @@ class CoreExport User : public Extensible
time_t my_signon; /* When did _we_ see the user? */
time_t svid; /* Services ID */
uint32 mode; /* See below */
- char *uid; /* Univeral ID */
NickAlias *na;
@@ -62,14 +63,16 @@ class CoreExport User : public Extensible
/** Create a new user object, initialising necessary fields and
* adds it to the hash
*
- * @parameter nick The nickname of the user account.
+ * @param nick The nickname of the user.
+ * @param uid The unique identifier of the user.
*/
- User(const std::string &nick);
+ User(const std::string &nick, const std::string &uid);
/** Destroy a user.
*/
~User();
+
/** Update the nickname of a user record accordingly, should be
* called from ircd protocol.
*/
@@ -77,13 +80,48 @@ class CoreExport User : public Extensible
/** Update the displayed (vhost) of a user record.
* This is used (if set) instead of real host.
+ * @param host The new displayed host to give the user.
*/
void SetDisplayedHost(const std::string &host);
+ /** Get the displayed vhost of a user record.
+ * @return The displayed vhost of the user, where ircd-supported, or the user's real host.
+ */
+ const std::string GetDisplayedHost() const;
+
+
+ /** Retrieves the UID of the user, where applicable, if set.
+ * This is not used on some IRCds, but is for a lot e.g. P10, TS6 protocols.
+ * @return The UID of the user.
+ */
+ const std::string &GetUID() const;
+
+
/** Update the displayed ident (username) of a user record.
+ * @param ident The new ident to give this user.
+ */
+ void SetVIdent(const std::string &ident);
+
+ /** Get the displayed ident (username) of this user.
+ * @return The displayed ident of this user.
+ */
+ const std::string &GetVIdent() const;
+
+ /** Update the real ident (username) of a user record.
+ * @param ident The new ident to give this user.
+ * NOTE: Where possible, you should use the Get/SetVIdent() equivilants.
*/
void SetIdent(const std::string &ident);
+ /** Get the real ident (username) of this user.
+ * @return The displayed ident of this user.
+ * NOTE: Where possible, you should use the Get/SetVIdent() equivilants.
+ */
+ const std::string &GetIdent() const;
+
+
+
+
/** Updates the realname of the user record.
*/
void SetRealname(const std::string &realname);