/[cvs]/eggdrop1.8/src/tclegg.h
ViewVC logotype

Annotation of /eggdrop1.8/src/tclegg.h

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


Revision 1.2 - (hide annotations) (download) (as text)
Wed Oct 27 20:47:26 2010 UTC (9 years, 5 months ago) by pseudo
Branch: MAIN
CVS Tags: HEAD
Branch point for: gettext
Changes since 1.1: +5 -3 lines
File MIME type: text/x-csrc
Added optional count argument to Tcl timer and utimer to allow them run more than once.

1 simple 1.1 /*
2     * tclegg.h
3     * stuff used by tcl.c and tclhash.c
4     *
5 pseudo 1.2 * $Id: tclegg.h,v 1.1.1.1 2010/07/26 21:11:06 simple Exp $
6 simple 1.1 */
7     /*
8     * Copyright (C) 1997 Robey Pointer
9     * Copyright (C) 1999 - 2010 Eggheads Development Team
10     *
11     * This program is free software; you can redistribute it and/or
12     * modify it under the terms of the GNU General Public License
13     * as published by the Free Software Foundation; either version 2
14     * of the License, or (at your option) any later version.
15     *
16     * This program is distributed in the hope that it will be useful,
17     * but WITHOUT ANY WARRANTY; without even the implied warranty of
18     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19     * GNU General Public License for more details.
20     *
21     * You should have received a copy of the GNU General Public License
22     * along with this program; if not, write to the Free Software
23     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24     */
25    
26     #ifndef _EGG_TCLEGG_H
27     #define _EGG_TCLEGG_H
28    
29     #include "lush.h"
30    
31     #ifndef MAKING_MODS
32     # include "proto.h"
33     #endif
34    
35    
36     /*
37     * Wow, this is old...CMD_LEAVE goes back to before version 0.9.
38     * This is for partyline and filesys 'quit'.
39     */
40     #define CMD_LEAVE (Function)(-1)
41    
42    
43     /* Match types for check_tcl_bind(). */
44     #define MATCH_PARTIAL 0
45     #define MATCH_EXACT 1
46     #define MATCH_MASK 2
47     #define MATCH_CASE 3
48     #define MATCH_MODE 4
49     #define MATCH_CRON 5
50    
51     /*
52     * Bitwise 'or' these:
53     */
54    
55     /* Check flags; make sure the user has the flags required. */
56     #define BIND_USE_ATTR 0x010
57    
58     /* Bind is stackable; more than one bind can have the same name. */
59     #define BIND_STACKABLE 0x020
60    
61     /* Additional flag checking; check for +d, +k, etc.
62     * Currently used for dcc, fil, msg, and pub bind types.
63     * Note that this just causes the flag checking to use flagrec_ok()
64     * instead of flagrec_eq().
65     */
66     /* FIXME: Should this really be used for the dcc and fil types since
67     * they are only available to the partyline/filesys (+p/+x)?
68     * Eggdrop's revenge code does not add default flags when
69     * adding a user record for +d or +k flags.
70     */
71     /* FIXME: This type actually seems to be obsolete. This was originally
72     * used to check built-in types in Eggdrop version 1.0.
73     */
74     #define BIND_HAS_BUILTINS 0x040
75    
76     /* Want return; we want to know if the proc returns 1.
77     * Side effect: immediate return; don't do any further
78     * processing of stacked binds.
79     */
80     #define BIND_WANTRET 0x080
81    
82     /* Alternate args; replace args with the return result from the Tcl proc. */
83     #define BIND_ALTER_ARGS 0x100
84    
85     /* Stacked return; we want to know if any proc returns 1,
86     * and also want to process all stacked binds.
87     */
88     #define BIND_STACKRET 0x200
89    
90    
91     /* Return values. */
92     #define BIND_NOMATCH 0
93     #define BIND_AMBIGUOUS 1
94     #define BIND_MATCHED 2 /* But the proc couldn't be found */
95     #define BIND_EXECUTED 3
96     #define BIND_EXEC_LOG 4 /* Proc returned 1 -> wants to be logged */
97     #define BIND_QUIT 5 /* CMD_LEAVE 'quit' from partyline or filesys */
98    
99     /* Extra commands are stored in Tcl hash tables (one hash table for each type
100     * of command: msg, dcc, etc).
101     */
102     typedef struct timer_str {
103     struct timer_str *next;
104 pseudo 1.2 unsigned int mins; /* Time remaining */
105     unsigned int count; /* Number of repeats */
106     unsigned int interval; /* Time to elapse */
107 simple 1.1 char *cmd; /* Command linked to */
108     unsigned long id; /* Used to remove timers */
109     } tcl_timer_t;
110    
111    
112     /* Used for Tcl stub functions */
113     #define STDVAR (cd, irp, argc, argv) \
114     ClientData cd; \
115     Tcl_Interp *irp; \
116     int argc; \
117     char *argv[];
118    
119     #define BADARGS(nl, nh, example) do { \
120     if ((argc < (nl)) || ((argc > (nh)) && ((nh) != -1))) { \
121     Tcl_AppendResult(irp, "wrong # args: should be \"", \
122     argv[0], (example), "\"", NULL); \
123     return TCL_ERROR; \
124     } \
125     } while (0)
126    
127     #define CHECKVALIDITY(a) do { \
128     if (!check_validity(argv[0], (a))) { \
129     Tcl_AppendResult(irp, "bad builtin command call!", \
130     NULL); \
131     return TCL_ERROR; \
132     } \
133     } while (0)
134    
135 pseudo 1.2 unsigned long add_timer(tcl_timer_t **, int, int, char *, unsigned long);
136 simple 1.1 int remove_timer(tcl_timer_t **, unsigned long);
137     void list_timers(Tcl_Interp *, tcl_timer_t *);
138     void wipe_timers(Tcl_Interp *, tcl_timer_t **);
139     void do_check_timers(tcl_timer_t **);
140    
141     typedef struct _tcl_strings {
142     char *name;
143     char *buf;
144     int length;
145     int flags;
146     } tcl_strings;
147    
148     typedef struct _tcl_int {
149     char *name;
150     int *val;
151     int readonly;
152     } tcl_ints;
153    
154     typedef struct _tcl_coups {
155     char *name;
156     int *lptr;
157     int *rptr;
158     } tcl_coups;
159    
160     typedef struct _tcl_cmds {
161     char *name;
162     IntFunc func;
163     } tcl_cmds;
164    
165     typedef struct _cd_tcl_cmd {
166     char *name;
167     IntFunc callback;
168     void *cdata;
169     } cd_tcl_cmd;
170    
171     void add_tcl_commands(tcl_cmds *);
172     void add_cd_tcl_cmds(cd_tcl_cmd *);
173     void rem_tcl_commands(tcl_cmds *);
174     void rem_cd_tcl_cmds(cd_tcl_cmd *);
175     void add_tcl_strings(tcl_strings *);
176     void rem_tcl_strings(tcl_strings *);
177     void add_tcl_coups(tcl_coups *);
178     void rem_tcl_coups(tcl_coups *);
179     void add_tcl_ints(tcl_ints *);
180     void rem_tcl_ints(tcl_ints *);
181     const char *tcl_resultstring();
182     int tcl_resultint();
183     int tcl_resultempty();
184     int tcl_threaded();
185     int fork_before_tcl();
186    
187     /* From Tcl's tclUnixInit.c */
188     /* The following table is used to map from Unix locale strings to
189     * encoding files.
190     */
191     typedef struct LocaleTable {
192     const char *lang;
193     const char *encoding;
194     } LocaleTable;
195    
196     static const LocaleTable localeTable[] = {
197     {"ja_JP.SJIS", "shiftjis"},
198     {"ja_JP.EUC", "euc-jp"},
199     {"ja_JP.JIS", "iso2022-jp"},
200     {"ja_JP.mscode", "shiftjis"},
201     {"ja_JP.ujis", "euc-jp"},
202     {"ja_JP", "euc-jp"},
203     {"Ja_JP", "shiftjis"},
204     {"Jp_JP", "shiftjis"},
205     {"japan", "euc-jp"},
206     #ifdef hpux
207     {"japanese", "shiftjis"},
208     {"ja", "shiftjis"},
209     #else
210     {"japanese", "euc-jp"},
211     {"ja", "euc-jp"},
212     #endif
213     {"japanese.sjis", "shiftjis"},
214     {"japanese.euc", "euc-jp"},
215     {"japanese-sjis", "shiftjis"},
216     {"japanese-ujis", "euc-jp"},
217    
218     {"ko", "euc-kr"},
219     {"ko_KR", "euc-kr"},
220     {"ko_KR.EUC", "euc-kr"},
221     {"ko_KR.euc", "euc-kr"},
222     {"ko_KR.eucKR", "euc-kr"},
223     {"korean", "euc-kr"},
224    
225     {"ru", "iso8859-5"},
226     {"ru_RU", "iso8859-5"},
227     {"ru_SU", "iso8859-5"},
228    
229     {"zh", "cp936"},
230    
231     {NULL, NULL}
232     };
233    
234     #endif /* _EGG_TCLEGG_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23