/[cvs]/eggdrop1.9/src/tclhash.h
ViewVC logotype

Annotation of /eggdrop1.9/src/tclhash.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.14 - (hide annotations) (download) (as text)
Fri Sep 28 03:15:34 2001 UTC (18 years ago) by stdarg
Branch: MAIN
Changes since 1.13: +23 -1 lines
File MIME type: text/x-csrc

This is a big patch!
Created several new bind tables (raw, msg, msgm, pub, pubm) to see how it
would work. Seems to work well so far, although there could be bugs.
Added most of the new important bind table functions to the global table.

1 guppy 1.8 /*
2 fabian 1.3 * tclhash.h
3 guppy 1.8 *
4 stdarg 1.14 * $Id: tclhash.h,v 1.13 2001/09/20 19:50:19 stdarg Exp $
5 fabian 1.3 */
6 guppy 1.8 /*
7     * Copyright (C) 1997 Robey Pointer
8     * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
9     *
10 fabian 1.3 * This program is free software; you can redistribute it and/or
11     * modify it under the terms of the GNU General Public License
12     * as published by the Free Software Foundation; either version 2
13     * of the License, or (at your option) any later version.
14 guppy 1.8 *
15 fabian 1.3 * This program is distributed in the hope that it will be useful,
16     * but WITHOUT ANY WARRANTY; without even the implied warranty of
17     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18     * GNU General Public License for more details.
19 guppy 1.8 *
20 fabian 1.3 * You should have received a copy of the GNU General Public License
21     * along with this program; if not, write to the Free Software
22     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23     */
24    
25     #ifndef _EGG_TCLHASH_H
26     #define _EGG_TCLHASH_H
27 segfault 1.1
28    
29 fabian 1.7 #define TC_DELETED 0x0001 /* This command/trigger was deleted. */
30 stdarg 1.12
31 stdarg 1.14 /* Flags for bind entries */
32 stdarg 1.12 /* Does the callback want their client_data inserted as the first argument? */
33     #define BIND_WANTS_CD 1
34 fabian 1.7
35 stdarg 1.14 /* Flags for bind tables */
36     #define BIND_STRICT_ATTR 0x80
37    
38 stdarg 1.9 /* Will replace tcl_cmd_t */
39 stdarg 1.10 /* This holds the final information for a function listening on a bind
40     table. */
41 stdarg 1.9 typedef struct bind_entry_b {
42     struct bind_entry_b *next;
43     struct flag_record user_flags;
44     char *function_name;
45     Function callback;
46     void *client_data;
47     int hits;
48     int bind_flags;
49     } bind_entry_t;
50    
51 fabian 1.7 typedef struct tcl_cmd_b {
52     struct tcl_cmd_b *next;
53    
54     struct flag_record flags;
55     char *func_name; /* Proc name. */
56     int hits; /* Number of times this proc
57     was triggered. */
58     u_8bit_t attributes; /* Flags for this entry. TC_* */
59 segfault 1.1 } tcl_cmd_t;
60    
61 fabian 1.7
62     #define TBM_DELETED 0x0001 /* This mask was deleted. */
63    
64 stdarg 1.9 /* Will replace tcl_bind_mask_t */
65 stdarg 1.10 /* This is the list of bind masks in a given table.
66     For instance, in the "msg" table you might have "pass", "op",
67     and "invite". */
68 stdarg 1.9 typedef struct bind_chain_b {
69 stdarg 1.11 struct bind_chain_b *next;
70 stdarg 1.9 bind_entry_t *entries;
71     char *mask;
72     int flags;
73     } bind_chain_t;
74    
75 fabian 1.7 typedef struct tcl_bind_mask_b {
76     struct tcl_bind_mask_b *next;
77    
78     tcl_cmd_t *first; /* List of commands registered
79     for this bind. */
80     char *mask;
81     u_8bit_t flags; /* Flags for this entry. TBM_* */
82     } tcl_bind_mask_t;
83    
84    
85     #define HT_STACKABLE 0x0001 /* Triggers in this bind list may be
86     stacked. */
87     #define HT_DELETED 0x0002 /* This bind list was already deleted.
88     Do not use it anymore. */
89 stdarg 1.9
90     /* Will replace tcl_bind_list_b */
91 stdarg 1.10 /* This is the highest-level structure. It's like the "msg" table
92     or the "pubm" table. */
93 stdarg 1.9 typedef struct bind_table_b {
94 stdarg 1.11 struct bind_table_b *next;
95 stdarg 1.9 bind_chain_t *chains;
96     char *name;
97 stdarg 1.13 char *syntax;
98 stdarg 1.14 int nargs;
99     int match_type;
100 stdarg 1.9 int flags;
101     } bind_table_t;
102 fabian 1.7
103     typedef struct tcl_bind_list_b {
104     struct tcl_bind_list_b *next;
105    
106     tcl_bind_mask_t *first; /* Pointer to registered binds
107     for this list. */
108     char name[5]; /* Name of the bind. */
109     u_8bit_t flags; /* Flags for this element. HT_* */
110     Function func; /* Function used as the Tcl
111     calling interface for procs
112     actually representing C
113     functions. */
114     } tcl_bind_list_t, *p_tcl_bind_list;
115 segfault 1.1
116 fabian 1.5
117 segfault 1.1 #ifndef MAKING_MODS
118 fabian 1.5
119 fabian 1.7 inline void garbage_collect_tclhash(void);
120    
121     void init_bind(void);
122     void kill_bind(void);
123     int expmem_tclhash(void);
124    
125     tcl_bind_list_t *add_bind_table(const char *nme, int flg, Function func);
126     void del_bind_table(tcl_bind_list_t *tl_which);
127    
128     tcl_bind_list_t *find_bind_table(const char *nme);
129    
130     int check_tcl_bind(tcl_bind_list_t *, const char *, struct flag_record *, const char *, int);
131     int check_tcl_dcc(const char *, int, const char *);
132     void check_tcl_chjn(const char *, const char *, int, char, int, const char *);
133     void check_tcl_chpt(const char *, const char *, int, int);
134     void check_tcl_bot(const char *, const char *, const char *);
135     void check_tcl_link(const char *, const char *);
136     void check_tcl_disc(const char *);
137     const char *check_tcl_filt(int, const char *);
138     int check_tcl_note(const char *, const char *, const char *);
139     void check_tcl_listen(const char *, int);
140 segfault 1.1 void check_tcl_time(struct tm *);
141     void tell_binds(int, char *);
142 fabian 1.7 void check_tcl_nkch(const char *, const char *);
143     void check_tcl_away(const char *, int, const char *);
144     void check_tcl_chatactbcst(const char *, int, const char *, tcl_bind_list_t *);
145     void check_tcl_event(const char *);
146    
147     #define check_tcl_chat(a, b, c) check_tcl_chatactbcst(a ,b, c, H_chat)
148     #define check_tcl_act(a, b, c) check_tcl_chatactbcst(a, b, c, H_act)
149     #define check_tcl_bcst(a, b, c) check_tcl_chatactbcst(a, b, c, H_bcst)
150     void check_tcl_chonof(char *, int, tcl_bind_list_t *);
151    
152     #define check_tcl_chon(a, b) check_tcl_chonof(a, b, H_chon)
153     #define check_tcl_chof(a, b) check_tcl_chonof(a, b, H_chof)
154     void check_tcl_loadunld(const char *, tcl_bind_list_t *);
155 segfault 1.1
156 fabian 1.7 #define check_tcl_load(a) check_tcl_loadunld(a, H_load)
157     #define check_tcl_unld(a) check_tcl_loadunld(a, H_unld)
158 segfault 1.1
159 fabian 1.7 void rem_builtins(tcl_bind_list_t *, cmd_t *);
160     void add_builtins(tcl_bind_list_t *, cmd_t *);
161 segfault 1.1
162     int check_validity(char *, Function);
163     extern p_tcl_bind_list H_chat, H_act, H_bcst, H_chon, H_chof;
164     extern p_tcl_bind_list H_load, H_unld, H_dcc, H_bot, H_link;
165     extern p_tcl_bind_list H_away, H_nkch, H_filt, H_disc, H_event;
166 stdarg 1.14
167     int check_bind(bind_table_t *table, const char *match, struct flag_record *_flags, ...);
168    
169     bind_table_t *add_bind_table2(const char *name, int nargs, const char *syntax, int match_type, int flags);
170    
171     void del_bind_table2(bind_table_t *table);
172    
173     bind_table_t *find_bind_table2(const char *name);
174    
175     int add_bind_entry(bind_table_t *table, const char *flags, const char *mask, const char *function_name, int bind_flags, Function callback, void *client_data);
176    
177     int del_bind_entry(bind_table_t *table, const char *flags, const char *mask, const char *function_name);
178    
179     void add_builtins2(bind_table_t *table, cmd_t *cmds);
180    
181     void rem_builtins2(bind_table_t *table, cmd_t *cmds);
182 segfault 1.1
183     #endif
184    
185 fabian 1.5
186 fabian 1.6 #define CHECKVALIDITY(a) do { \
187 fabian 1.5 if (!check_validity(argv[0], (a))) { \
188     Tcl_AppendResult(irp, "bad builtin command call!", \
189     NULL); \
190     return TCL_ERROR; \
191 fabian 1.6 } \
192     } while (0)
193 fabian 1.3
194     #endif /* _EGG_TCLHASH_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23