Merged from silc_1_0_branch.
[silc.git] / apps / irssi / src / silc / core / silc-commands.h
1 #ifndef SILC_COMMANDS_H
2 #define SILC_COMMANDS_H
3
4 #define command_bind_silc(cmd, section, signal) \
5         command_bind_proto(cmd, SILC_PROTOCOL, section, signal)
6 #define command_bind_silc_first(cmd, section, signal) \
7         command_bind_proto_first(cmd, SILC_PROTOCOL, section, signal)
8 #define command_bind_silc_last(cmd, section, signal) \
9         command_bind_proto_last(cmd, SILC_PROTOCOL, section, signal)
10
11 /* Simply returns if server isn't for SILC protocol. Prints ERR_NOT_CONNECTED
12    error if there's no server or server isn't connected yet */
13 #define CMD_SILC_SERVER(server) \
14         G_STMT_START { \
15           if (server != NULL && !IS_SILC_SERVER(server)) \
16             return; \
17           if (server == NULL || !(server)->connected) \
18             cmd_return_error(CMDERR_NOT_CONNECTED); \
19         } G_STMT_END
20
21 /* Returning from command function with error */
22 #define cmd_return_error_value(a,v) \
23         G_STMT_START { \
24           signal_emit("error command", 1, GINT_TO_POINTER(a)); \
25           signal_stop(); \
26           return (v); \
27         } G_STMT_END
28
29 #endif