/[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.18 - (hide annotations) (download) (as text)
Wed Oct 10 10:44:04 2001 UTC (18 years ago) by tothwolf
Branch: MAIN
Changes since 1.17: +1 -2 lines
File MIME type: text/x-csrc
all expmem functions and support removed
all memory status/debugging code removed
all #ifdef DEBUG_MEM code removed

nmalloc macro/n_malloc function removed, use malloc() now
mod_malloc function removed
my_strdup function removed, use malloc_strcpy macro now
channel_malloc removed, use malloc_memset macro now
n_malloc_null function removed, use malloc_memset macro now
user_malloc macro/_user_malloc function removed, use malloc() now

nrealloc macro/n_realloc function removed, use realloc() now
mod_realloc function removed

nfree macro/n_free function removed, use free() now
mod_free function removed
my_free macro removed, use free_null macro now
Tcl_Free compat macro now uses free() instead of removed n_free function

malloc->strcpy now uses malloc_strcpy macro
free(ptr);ptr=NULL; now uses free_null macro
malloc->bzero now uses malloc_memset macro
get_data_ptr macro/_get_data_ptr function removed, use malloc_memset macro now

compat memcpy removed
compat memset removed
egg_memcpy/my_memcpy misuse/mess changed to memcpy
egg_bzero/bzero macro removed, use memset() now

many uninitialized pointers now default to NULL

match.c is now compiled on it's own instead of being included into tclhash.c
match.c cleanup, removed broken/incomplete ircII compat code
wild_match macro removed, _wild_match function renamed to wild_match
wild_match_per function no longer declared static
added prototypes for wild_match and wild_match_per functions

Major function/macro changes:
  nmalloc -> malloc()
  nrealloc -> realloc()
  nfree -> free()

Bugs found and fixed during audit:
  buffer overflow in adduser()

Bugs fixed when code was removed:
  typo in filedb3.c: EBUG_MEM -> DEBUG_MEM
  extra egg_bzero call from filesys.c

1 guppy 1.8 /*
2 fabian 1.3 * tclhash.h
3 guppy 1.8 *
4 tothwolf 1.18 * $Id: tclhash.h,v 1.17 2001/10/09 12:42:13 tothwolf 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 stdarg 1.15 #define BIND_BREAKABLE 0x100
38 stdarg 1.16
39     /* Flags for return values from bind callbacks */
40     #define BIND_RET_LOG 1
41     #define BIND_RET_BREAK 2
42    
43     /* Callback clientdata for a tcl bind */
44     typedef struct tcl_cmd_cdata_b {
45     Tcl_Interp *irp;
46     char *cmd;
47     char *syntax;
48     } tcl_cmd_cdata;
49 stdarg 1.14
50 stdarg 1.9 /* Will replace tcl_cmd_t */
51 stdarg 1.10 /* This holds the final information for a function listening on a bind
52     table. */
53 stdarg 1.9 typedef struct bind_entry_b {
54     struct bind_entry_b *next;
55     struct flag_record user_flags;
56     char *function_name;
57     Function callback;
58     void *client_data;
59     int hits;
60     int bind_flags;
61     } bind_entry_t;
62    
63 fabian 1.7 typedef struct tcl_cmd_b {
64     struct tcl_cmd_b *next;
65    
66     struct flag_record flags;
67     char *func_name; /* Proc name. */
68     int hits; /* Number of times this proc
69     was triggered. */
70     u_8bit_t attributes; /* Flags for this entry. TC_* */
71 segfault 1.1 } tcl_cmd_t;
72    
73 fabian 1.7
74     #define TBM_DELETED 0x0001 /* This mask was deleted. */
75    
76 stdarg 1.9 /* Will replace tcl_bind_mask_t */
77 stdarg 1.10 /* This is the list of bind masks in a given table.
78     For instance, in the "msg" table you might have "pass", "op",
79     and "invite". */
80 stdarg 1.9 typedef struct bind_chain_b {
81 stdarg 1.11 struct bind_chain_b *next;
82 stdarg 1.9 bind_entry_t *entries;
83     char *mask;
84     int flags;
85     } bind_chain_t;
86    
87 fabian 1.7 typedef struct tcl_bind_mask_b {
88     struct tcl_bind_mask_b *next;
89    
90     tcl_cmd_t *first; /* List of commands registered
91     for this bind. */
92     char *mask;
93     u_8bit_t flags; /* Flags for this entry. TBM_* */
94     } tcl_bind_mask_t;
95    
96    
97     #define HT_STACKABLE 0x0001 /* Triggers in this bind list may be
98     stacked. */
99     #define HT_DELETED 0x0002 /* This bind list was already deleted.
100     Do not use it anymore. */
101 stdarg 1.9
102     /* Will replace tcl_bind_list_b */
103 stdarg 1.10 /* This is the highest-level structure. It's like the "msg" table
104     or the "pubm" table. */
105 stdarg 1.9 typedef struct bind_table_b {
106 stdarg 1.11 struct bind_table_b *next;
107 stdarg 1.9 bind_chain_t *chains;
108     char *name;
109 stdarg 1.13 char *syntax;
110 stdarg 1.14 int nargs;
111     int match_type;
112 stdarg 1.9 int flags;
113     } bind_table_t;
114 fabian 1.7
115     typedef struct tcl_bind_list_b {
116     struct tcl_bind_list_b *next;
117    
118     tcl_bind_mask_t *first; /* Pointer to registered binds
119     for this list. */
120     char name[5]; /* Name of the bind. */
121     u_8bit_t flags; /* Flags for this element. HT_* */
122     Function func; /* Function used as the Tcl
123     calling interface for procs
124     actually representing C
125     functions. */
126     } tcl_bind_list_t, *p_tcl_bind_list;
127 segfault 1.1
128 fabian 1.5
129 segfault 1.1 #ifndef MAKING_MODS
130 fabian 1.5
131 fabian 1.7 inline void garbage_collect_tclhash(void);
132    
133     void init_bind(void);
134 tothwolf 1.17 void init_bind2(void);
135 fabian 1.7 void kill_bind(void);
136 tothwolf 1.17 void kill_bind2(void);
137 fabian 1.7
138     tcl_bind_list_t *add_bind_table(const char *nme, int flg, Function func);
139     void del_bind_table(tcl_bind_list_t *tl_which);
140    
141     tcl_bind_list_t *find_bind_table(const char *nme);
142    
143     int check_tcl_bind(tcl_bind_list_t *, const char *, struct flag_record *, const char *, int);
144     int check_tcl_dcc(const char *, int, const char *);
145     void check_tcl_chjn(const char *, const char *, int, char, int, const char *);
146     void check_tcl_chpt(const char *, const char *, int, int);
147     void check_tcl_bot(const char *, const char *, const char *);
148     void check_tcl_link(const char *, const char *);
149     void check_tcl_disc(const char *);
150     const char *check_tcl_filt(int, const char *);
151     int check_tcl_note(const char *, const char *, const char *);
152     void check_tcl_listen(const char *, int);
153 segfault 1.1 void check_tcl_time(struct tm *);
154     void tell_binds(int, char *);
155 fabian 1.7 void check_tcl_nkch(const char *, const char *);
156     void check_tcl_away(const char *, int, const char *);
157     void check_tcl_chatactbcst(const char *, int, const char *, tcl_bind_list_t *);
158     void check_tcl_event(const char *);
159    
160     #define check_tcl_chat(a, b, c) check_tcl_chatactbcst(a ,b, c, H_chat)
161     #define check_tcl_act(a, b, c) check_tcl_chatactbcst(a, b, c, H_act)
162     #define check_tcl_bcst(a, b, c) check_tcl_chatactbcst(a, b, c, H_bcst)
163     void check_tcl_chonof(char *, int, tcl_bind_list_t *);
164    
165     #define check_tcl_chon(a, b) check_tcl_chonof(a, b, H_chon)
166     #define check_tcl_chof(a, b) check_tcl_chonof(a, b, H_chof)
167     void check_tcl_loadunld(const char *, tcl_bind_list_t *);
168 segfault 1.1
169 fabian 1.7 #define check_tcl_load(a) check_tcl_loadunld(a, H_load)
170     #define check_tcl_unld(a) check_tcl_loadunld(a, H_unld)
171 segfault 1.1
172 fabian 1.7 void rem_builtins(tcl_bind_list_t *, cmd_t *);
173     void add_builtins(tcl_bind_list_t *, cmd_t *);
174 segfault 1.1
175     int check_validity(char *, Function);
176     extern p_tcl_bind_list H_chat, H_act, H_bcst, H_chon, H_chof;
177     extern p_tcl_bind_list H_load, H_unld, H_dcc, H_bot, H_link;
178     extern p_tcl_bind_list H_away, H_nkch, H_filt, H_disc, H_event;
179 stdarg 1.14
180     int check_bind(bind_table_t *table, const char *match, struct flag_record *_flags, ...);
181    
182     bind_table_t *add_bind_table2(const char *name, int nargs, const char *syntax, int match_type, int flags);
183    
184     void del_bind_table2(bind_table_t *table);
185    
186     bind_table_t *find_bind_table2(const char *name);
187    
188     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);
189    
190     int del_bind_entry(bind_table_t *table, const char *flags, const char *mask, const char *function_name);
191    
192     void add_builtins2(bind_table_t *table, cmd_t *cmds);
193    
194     void rem_builtins2(bind_table_t *table, cmd_t *cmds);
195 segfault 1.1
196     #endif
197    
198 fabian 1.5
199 fabian 1.6 #define CHECKVALIDITY(a) do { \
200 fabian 1.5 if (!check_validity(argv[0], (a))) { \
201     Tcl_AppendResult(irp, "bad builtin command call!", \
202     NULL); \
203     return TCL_ERROR; \
204 fabian 1.6 } \
205     } while (0)
206 fabian 1.3
207     #endif /* _EGG_TCLHASH_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23