diff options
Diffstat (limited to 'src/irc/core/modes.h')
-rw-r--r-- | src/irc/core/modes.h | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/irc/core/modes.h b/src/irc/core/modes.h index 485b176b..d5af8403 100644 --- a/src/irc/core/modes.h +++ b/src/irc/core/modes.h @@ -1,30 +1,43 @@ #ifndef __MODES_H #define __MODES_H +#include "irc-channels.h" + +typedef void mode_func_t(IRC_CHANNEL_REC *, const char *, char, char, + char *, GString *); + +struct modes_type { + mode_func_t *func; + char prefix; +}; + /* modes that have argument always */ -#define HAS_MODE_ARG_ALWAYS(mode) \ - ((mode) == 'b' || (mode) == 'e' || (mode) == 'I' || (mode) == 'q' || \ - (mode) == 'd' || (mode) == 'o' || (mode) == 'h' || (mode) == 'v' || \ - (mode) == 'O' || (mode) == 'k' || (mode) == 'f') +#define HAS_MODE_ARG_ALWAYS(server, mode) \ + (server->modes[(int)(unsigned char) mode].func == modes_type_a || \ + server->modes[(int)(unsigned char) mode].func == modes_type_b || \ + server->modes[(int)(unsigned char) mode].func == modes_type_prefix) /* modes that have argument when being set (+) */ -#define HAS_MODE_ARG_SET(mode) \ - (HAS_MODE_ARG_ALWAYS(mode) || (mode) == 'l') +#define HAS_MODE_ARG_SET(server, mode) \ + (HAS_MODE_ARG_ALWAYS(server, mode) || \ + server->modes[(int)(unsigned char) mode].func == modes_type_c) /* modes that have argument when being unset (-) */ -#define HAS_MODE_ARG_UNSET(mode) \ - HAS_MODE_ARG_ALWAYS(mode) +#define HAS_MODE_ARG_UNSET(server, mode) \ + HAS_MODE_ARG_ALWAYS(server, mode) -#define HAS_MODE_ARG(type, mode) \ - ((type) == '+' ? HAS_MODE_ARG_SET(mode) : HAS_MODE_ARG_UNSET(mode)) +#define HAS_MODE_ARG(server, type, mode) \ + ((type) == '+' ? HAS_MODE_ARG_SET(server,mode) : \ + HAS_MODE_ARG_UNSET(server, mode)) void modes_init(void); void modes_deinit(void); +void modes_server_init(IRC_SERVER_REC *); /* add `mode' to `old' - return newly allocated mode. `channel' specifies if we're parsing channel mode and we should try to join mode arguments too. */ -char *modes_join(const char *old, const char *mode, int channel); +char *modes_join(IRC_SERVER_REC *server, const char *old, const char *mode, int channel); int channel_mode_is_set(IRC_CHANNEL_REC *channel, char mode); @@ -36,4 +49,10 @@ void channel_set_singlemode(IRC_CHANNEL_REC *channel, const char *nicks, void channel_set_mode(IRC_SERVER_REC *server, const char *channel, const char *mode); +mode_func_t modes_type_a; +mode_func_t modes_type_b; +mode_func_t modes_type_c; +mode_func_t modes_type_d; +mode_func_t modes_type_prefix; + #endif |