ekg2
|
00001 /* $Id$ */ 00002 00003 /* 00004 * (C) Copyright 2001-2002 Wojtek Kaniewski <wojtekka@irc.pl> 00005 * Dawid Jarosz <dawjar@poczta.onet.pl> 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License Version 2 as 00009 * published by the Free Software Foundation. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 #ifndef __EKG_COMMANDS_H 00022 #define __EKG_COMMANDS_H 00023 00024 #include "dynstuff.h" 00025 #include "plugins.h" 00026 #include "themes.h" 00027 #include "sessions.h" 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 #define printq(x...) do { if (!quiet) { print(x); } } while(0) 00034 00035 #define COMMAND(x) int x(const char *name, const char **params, session_t *session, const char *target, int quiet) 00036 00037 typedef enum { 00038 /* INFORMATIONAL FLAGS */ 00039 COMMAND_ISALIAS = 0x01, /* command is binded by alias management */ 00040 COMMAND_ISSCRIPT = 0x02, /* command is binded by script management */ 00041 COMMAND_WITH_RESOURCE = 0x04, /* [XXX] command uses resource, and resource should be passed */ 00042 COMMAND_PASS_UNCHANGED = 0x08, /* WYSIWYG, pass unchanged line, as first argument */ 00043 /* .... */ 00044 00045 /* CONDITIONAL FLAGS */ 00046 COMMAND_ENABLEREQPARAMS = 0x10, /* '!' in params means that arg must exist in params[..] (?) */ 00047 COMMAND_PARAMASTARGET = 0x20, /* when params[0] != NULL, than target = params[0] and then params list moves up 00048 (params++ ; params[0] == params[1] and so on */ 00049 SESSION_MUSTBECONNECTED = 0x40, /* session must be connected to execute that command */ 00050 SESSION_MUSTBELONG = 0x80, /* command must come from the same plugin as session (?) */ 00051 SESSION_MUSTHAS = 0x100, /* if session == NULL, we try session_current, if still NULL. we return -1... 00052 mh, i really don't know if this flag is obsolete... but we do simillar thing 00053 in many places in code, so implemented. */ 00054 SESSION_MUSTHASPRIVATE = 0x200, /* session must exist and has private struct */ 00055 COMMAND_TARGET_VALID_UID = 0x400 /* before executing handler, check if target (or params[0] if COMMAND_PARAMASTARGET 00056 set) is valid uid for current session, or we've got smb with this nickname 00057 on userlist... (read: we check if get_uid(session, target) return smth, 00058 if not we print message) */ 00059 } command_flags_t; 00060 00061 typedef COMMAND(command_func_t); 00062 00063 typedef struct command { 00064 struct command *next; 00065 00066 /* public: */ 00067 const char *name; 00068 plugin_t *plugin; 00069 00070 /* private: */ 00071 char **params; 00072 command_func_t *function; 00073 command_flags_t flags; 00074 char **possibilities; 00075 } command_t; 00076 00077 #ifndef EKG2_WIN32_NOFUNCTION 00078 extern command_t *commands; 00079 00080 command_t *command_add(plugin_t *plugin, const char *name, char *params, command_func_t function, command_flags_t flags, char *possibilities); 00081 int command_remove(plugin_t *plugin, const char *name); 00082 command_t *command_find (const char *name); 00083 void command_init(); 00084 void commands_remove(command_t *c); 00085 command_t *commands_removei(command_t *c); 00086 void commands_destroy(); 00087 int command_exec(const char *target, session_t *session, const char *line, int quiet); 00088 int command_exec_params(const char *target, session_t *session, int quiet, const char *command, ...); 00089 int command_exec_format(const char *target, session_t *session, int quiet, const char *format, ...); 00090 00091 COMMAND(cmd_add); 00092 COMMAND(cmd_alias_exec); 00093 COMMAND(cmd_exec); 00094 COMMAND(cmd_list); 00095 COMMAND(cmd_dcc); 00096 COMMAND(cmd_bind); /* bindings.c */ 00097 COMMAND(session_command); /* sessions.c */ 00098 COMMAND(cmd_on); /* events.c */ 00099 COMMAND(cmd_metacontact); /* metacontacts.c */ 00100 COMMAND(cmd_streams); /* audio.c */ 00101 COMMAND(cmd_script); /* script.c */ 00102 #endif 00103 /* 00104 * jakaś malutka lista tych, do których były wysyłane wiadomości. 00105 */ 00106 #define SEND_NICKS_MAX 100 00107 00108 extern char *send_nicks[SEND_NICKS_MAX]; 00109 extern int send_nicks_count, send_nicks_index; 00110 00111 #ifndef EKG2_WIN32_NOFUNCTION 00112 void tabnick_add(const char *nick); 00113 void tabnick_remove(const char *nick); 00114 00115 00116 int match_arg(const char *arg, char shortopt, const char *longopt, int longoptlen); 00117 00118 /* wyniki ostatniego szukania */ 00119 extern char *last_search_first_name; 00120 extern char *last_search_last_name; 00121 extern char *last_search_nickname; 00122 extern char *last_search_uid; 00123 #endif 00124 00125 #ifdef __cplusplus 00126 } 00127 #endif 00128 00129 #endif /* __EKG_COMMANDS_H */ 00130 00131 /* 00132 * Local Variables: 00133 * mode: c 00134 * c-file-style: "k&r" 00135 * c-basic-offset: 8 00136 * indent-tabs-mode: t 00137 * End: 00138 */