#include "signals.h"
+typedef struct {
+ SIGNAL_FUNC func;
+ void *user_data;
+} COMMAND_CALLBACK_REC;
+
typedef struct {
char *name;
char *options;
- GSList *signals;
+ int protocol; /* chat protocol required for this command */
+ GSList *callbacks;
} COMMAND_MODULE_REC;
typedef struct {
CMDERR_ERRNO, /* get the error from errno */
CMDERR_NOT_ENOUGH_PARAMS, /* not enough parameters given */
- CMDERR_NOT_CONNECTED, /* not connected to IRC server */
+ CMDERR_NOT_CONNECTED, /* not connected to server */
CMDERR_NOT_JOINED, /* not joined to any channels in this window */
CMDERR_CHAN_NOT_FOUND, /* channel not found */
CMDERR_CHAN_NOT_SYNCED, /* channel not fully synchronized yet */
- CMDERR_NOT_GOOD_IDEA /* not good idea to do, -yes overrides this */
+ CMDERR_ILLEGAL_PROTO, /* requires different chat protocol than the active server */
+ CMDERR_NOT_GOOD_IDEA, /* not good idea to do, -yes overrides this */
+ CMDERR_INVALID_TIME, /* invalid time specification */
+ CMDERR_INVALID_CHARSET, /* invalid charset specification */
+ CMDERR_EVAL_MAX_RECURSE, /* eval hit recursion limit */
+ CMDERR_PROGRAM_NOT_FOUND /* program not found */
};
/* Return the full command for `alias' */
extern char *current_command; /* the command we're right now. */
/* Bind command to specified function. */
-void command_bind_to(const char *module, int pos, const char *cmd,
- const char *category, SIGNAL_FUNC func);
-#define command_bind(a, b, c) command_bind_to(MODULE_NAME, 1, a, b, c)
-#define command_bind_first(a, b, c) command_bind_to(MODULE_NAME, 0, a, b, c)
-#define command_bind_last(a, b, c) command_bind_to(MODULE_NAME, 2, a, b, c)
+void command_bind_full(const char *module, int priority, const char *cmd,
+ int protocol, const char *category, SIGNAL_FUNC func,
+ void *user_data);
+#define command_bind(a, b, c) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, a, -1, b, c, NULL)
+#define command_bind_first(a, b, c) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, a, -1, b, c, NULL)
+#define command_bind_last(a, b, c) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, a, -1, b, c, NULL)
+
+#define command_bind_data(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, a, -1, b, c, d)
+#define command_bind_data_first(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, a, -1, b, c, d)
+#define command_bind_data_last(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, a, -1, b, c, d)
+
+#define command_bind_proto(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, a, b, c, d, NULL)
+#define command_bind_proto_first(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, a, b, c, d, NULL)
+#define command_bind_proto_last(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, a, b, c, d, NULL)
-void command_unbind(const char *cmd, SIGNAL_FUNC func);
+void command_unbind_full(const char *cmd, SIGNAL_FUNC func, void *user_data);
+#define command_unbind(cmd, func) command_unbind_full(cmd, func, NULL)
/* Run subcommand, `cmd' contains the base command, first word in `data'
contains the subcommand */
#define PARAM_FLAG_UNKNOWN_OPTIONS 0x00008000
/* optional channel in first argument */
#define PARAM_FLAG_OPTCHAN 0x00010000
+/* optional channel in first argument, but don't treat "*" as current channel */
+#define PARAM_FLAG_OPTCHAN_NAME (0x00020000|PARAM_FLAG_OPTCHAN)
char *cmd_get_param(char **data);
+char *cmd_get_quoted_param(char **data);
/* get parameters from command - you should point free_me somewhere and
cmd_params_free() it after you don't use any of the parameters anymore.