ekg2  GIT master
commands.h
Idź do dokumentacji tego pliku.
1 /* $Id$ */
2 
3 /*
4  * (C) Copyright 2001-2002 Wojtek Kaniewski <wojtekka@irc.pl>
5  * Dawid Jarosz <dawjar@poczta.onet.pl>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License Version 2 as
9  * published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 
21 #ifndef __EKG_COMMANDS_H
22 #define __EKG_COMMANDS_H
23 
24 #include "dynstuff.h"
25 #include "plugins.h"
26 #include "themes.h"
27 #include "sessions.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #define printq(x...) do { if (!quiet) { print(x); } } while(0)
34 
35 #define COMMAND(x) int x(const char *name, const char **params, session_t *session, const char *target, int quiet)
36 
37 typedef enum {
38 /* INFORMATIONAL FLAGS */
39  COMMAND_ISALIAS = 0x01, /* command is binded by alias management */
40  COMMAND_ISSCRIPT = 0x02, /* command is binded by script management */
41  COMMAND_WITH_RESOURCE = 0x04, /* [XXX] command uses resource, and resource should be passed */
42  COMMAND_PASS_UNCHANGED = 0x08, /* WYSIWYG, pass unchanged line, as first argument */
43 /* .... */
44 
45 /* CONDITIONAL FLAGS */
46  COMMAND_ENABLEREQPARAMS = 0x10, /* '!' in params means that arg must exist in params[..] (?) */
47  COMMAND_PARAMASTARGET = 0x20, /* when params[0] != NULL, than target = params[0] and then params list moves up
48  (params++ ; params[0] == params[1] and so on */
49  SESSION_MUSTBECONNECTED = 0x40, /* session must be connected to execute that command */
50  SESSION_MUSTBELONG = 0x80, /* command must come from the same plugin as session (?) */
51  SESSION_MUSTHAS = 0x100, /* if session == NULL, we try session_current, if still NULL. we return -1...
52  mh, i really don't know if this flag is obsolete... but we do simillar thing
53  in many places in code, so implemented. */
54  SESSION_MUSTHASPRIVATE = 0x200, /* session must exist and has private struct */
55  COMMAND_TARGET_VALID_UID = 0x400 /* before executing handler, check if target (or params[0] if COMMAND_PARAMASTARGET
56  set) is valid uid for current session, or we've got smb with this nickname
57  on userlist... (read: we check if get_uid(session, target) return smth,
58  if not we print message) */
60 
62 
63 typedef struct command {
64 /* public: */
65  const char *name;
67 
68 /* private: */
69  char **params;
70  command_func_t *function;
72  char **possibilities;
73 } command_t;
74 
75 #ifndef EKG2_WIN32_NOFUNCTION
76 extern GSList *commands;
77 
79 int command_remove(plugin_t *plugin, const char *name);
80 command_t *command_find (const char *name);
81 void command_init();
82 void commands_remove(command_t *c);
83 void commands_destroy();
84 int command_exec(const char *target, session_t *session, const char *line, int quiet);
85 int command_exec_params(const char *target, session_t *session, int quiet, const char *command, ...);
86 int command_exec_format(const char *target, session_t *session, int quiet, const char *format, ...);
87 
93 COMMAND(cmd_bind); /* bindings.c */
94 COMMAND(session_command); /* sessions.c */
95 COMMAND(cmd_on); /* events.c */
96 COMMAND(cmd_metacontact); /* metacontacts.c */
97 COMMAND(cmd_script); /* script.c */
98 #endif
99 /*
100  * jakaś malutka lista tych, do których były wysyłane wiadomości.
101  */
102 #define SEND_NICKS_MAX 100
103 
104 extern char *send_nicks[SEND_NICKS_MAX];
106 
107 #ifndef EKG2_WIN32_NOFUNCTION
108 void tabnick_add(const char *nick);
109 void tabnick_remove(const char *nick);
110 
111 
112 int match_arg(const char *arg, char shortopt, const char *longopt, int longoptlen);
113 
114 /* wyniki ostatniego szukania */
115 extern char *last_search_first_name;
116 extern char *last_search_last_name;
117 extern char *last_search_nickname;
118 extern char *last_search_uid;
119 #endif
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* __EKG_COMMANDS_H */
126 
127 /*
128  * Local Variables:
129  * mode: c
130  * c-file-style: "k&r"
131  * c-basic-offset: 8
132  * indent-tabs-mode: t
133  * End:
134  */
int session_command(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: sessions.c:1038
void commands_remove(command_t *c)
Definition: commands.c:100
int match_arg(const char *arg, char shortopt, const char *longopt, int longoptlen)
Definition: commands.c:114
char * send_nicks[100]
Definition: commands.c:77
command_flags_t flags
Definition: commands.h:71
void tabnick_remove(const char *nick)
Definition: commands.c:163
char * last_search_uid
Definition: stuff.c:141
int send_nicks_index
Definition: commands.c:78
Definition: sessions.h:127
char ** params
Definition: commands.h:69
struct command command_t
Definition: commands.h:63
Definition: commands.h:41
Definition: commands.h:39
Definition: ekg_hash_benchmark.c:47
int cmd_add(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: commands.c:234
plugin_t * plugin
Definition: commands.h:66
int cmd_alias_exec(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: commands.c:2795
int command_exec(const char *target, session_t *session, const char *line, int quiet)
Definition: commands.c:2431
char ** possibilities
Definition: commands.h:72
int cmd_metacontact(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: metacontacts.c:62
GSList * commands
Definition: commands.c:81
Definition: plugins.h:76
#define COMMAND(x)
Definition: commands.h:35
#define SEND_NICKS_MAX
Definition: commands.h:102
void command_init()
Definition: commands.c:3648
Definition: commands.h:49
Definition: commands.h:47
#define line
Definition: bindings.c:50
Definition: commands.h:46
Definition: commands.h:40
int send_nicks_count
Definition: commands.c:78
char * last_search_first_name
Definition: stuff.c:138
int command_func_t(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: commands.h:61
Definition: commands.h:55
Definition: commands.h:51
Definition: commands.h:54
int cmd_dcc(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: commands.c:3312
Definition: commands.h:50
const char * name
Definition: commands.h:65
char * last_search_last_name
Definition: stuff.c:139
int cmd_on(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: events.c:63
int cmd_script(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: scripts.c:891
void tabnick_add(const char *nick)
Definition: commands.c:136
Definition: commands.h:42
int command_exec_format(const char *target, session_t *session, int quiet, const char *format,...)
Definition: commands.c:2778
char * last_search_nickname
Definition: stuff.c:140
int cmd_bind(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: bindings.c:113
int cmd_exec(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: commands.c:613
int cmd_list(const char *name, const char **params, session_t *session, const char *target, int quiet)
Definition: commands.c:1303
int command_remove(plugin_t *plugin, const char *name)
Definition: commands.c:3598
command_flags_t
Definition: commands.h:37
command_t * command_add(plugin_t *plugin, const char *name, char *params, command_func_t function, command_flags_t flags, char *possibilities)
Definition: commands.c:3570
int command_exec_params(const char *target, session_t *session, int quiet, const char *command,...)
Definition: commands.c:2719
void commands_destroy()
Definition: commands.c:105
command_t * command_find(const char *name)