/[cvs]/eggdrop1.4/src/tcl.c
ViewVC logotype

Contents of /eggdrop1.4/src/tcl.c

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


Revision 1.13 - (show annotations) (download) (as text)
Mon Sep 27 20:33:55 1999 UTC (20 years ago) by guppy
Branch: MAIN
Changes since 1.12: +1 -1 lines
File MIME type: text/x-chdr
*** empty log message ***

1 /*
2 * tcl.c -- handles:
3 * the code for every command eggdrop adds to Tcl
4 * Tcl initialization
5 * getting and setting Tcl/eggdrop variables
6 *
7 * dprintf'ized, 4feb1996
8 */
9 /*
10 * This file is part of the eggdrop source code
11 * copyright (c) 1997 Robey Pointer
12 * and is distributed according to the GNU general public license.
13 * For full details, read the top of 'main.c' or the file called
14 * COPYING that was distributed with this code.
15 */
16
17 #include "main.h"
18
19 /* used for read/write to internal strings */
20 typedef struct {
21 char *str; /* pointer to actual string in eggdrop */
22 int max; /* max length (negative: read-only var when protect is on) */
23 /* (0: read-only ALWAYS) */
24 int flags; /* 1 = directory */
25 } strinfo;
26
27 typedef struct {
28 int *var;
29 int ro;
30 } intinfo;
31
32 int protect_readonly = 0; /* turn on/off readonly protection */
33 char whois_fields[121] = ""; /* fields to display in a .whois */
34 Tcl_Interp *interp; /* eggdrop always uses the same interpreter */
35
36 extern int backgrd, flood_telnet_thr, flood_telnet_time;
37 extern int shtime, share_greet, require_p, keep_all_logs;
38 extern int allow_new_telnets, stealth_telnets, use_telnet_banner;
39 extern int default_flags, conmask, switch_logfiles_at, connect_timeout;
40 extern int firewallport, reserved_port, notify_users_at;
41 extern int flood_thr, ignore_time;
42 extern char origbotname[], botuser[], motdfile[], admin[], userfile[],
43 firewall[], helpdir[], notify_new[], hostname[], myip[], moddir[],
44 tempdir[], owner[], network[], botnetnick[], bannerfile[];
45 extern int die_on_sighup, die_on_sigterm, max_logs, max_logsize, enable_simul;
46 extern int dcc_total, debug_output, identtimeout, protect_telnet;
47 extern int egg_numver, share_unlinks, dcc_sanitycheck, sort_users;
48 extern struct dcc_t *dcc;
49 extern char egg_version[];
50 extern tcl_timer_t *timer, *utimer;
51 extern time_t online_since;
52 extern log_t *logs;
53 extern int tands;
54 extern int resolve_timeout;
55 extern char natip[];
56 extern int default_uflags; /* drummer */
57
58 /* confvar patch by aaronwl */
59 extern char configfile[];
60 int dcc_flood_thr = 3;
61 int debug_tcl = 0;
62 int use_silence = 0;
63 int use_invites = 0; /* Jason/drummer */
64 int use_exempts = 0; /* Jason/drummer */
65 int force_expire = 0; /* Rufus */
66 int remote_boots = 2;
67 int allow_dk_cmds = 1;
68 int must_be_owner = 1;
69 int max_dcc = 20; /* needs at least 4 or 5 just to get started
70 * 20 should be enough */
71 int min_dcc_port = 1024; /* dcc-portrange, min port - dw/guppy */
72 int max_dcc_port = 65535; /* dcc-portrange, max port - dw/guppy */
73 int quick_logs = 0; /* quick write logs?
74 * flush em every min instead of every 5 */
75 int par_telnet_flood = 1; /* trigger telnet flood for +f ppl? - dw */
76 int quiet_save = 0; /* quiet-save patch by Lucas */
77
78 /* prototypes for tcl */
79 Tcl_Interp *Tcl_CreateInterp();
80 int strtot = 0;
81
82 int expmem_tcl()
83 {
84 int i, tot = 0;
85
86 context;
87 for (i = 0; i < max_logs; i++)
88 if (logs[i].filename != NULL) {
89 tot += strlen(logs[i].filename) + 1;
90 tot += strlen(logs[i].chname) + 1;
91 }
92 return tot + strtot;
93 }
94
95 /***********************************************************************/
96
97 /* logfile [<modes> <channel> <filename>] */
98 static int tcl_logfile STDVAR
99 {
100 int i;
101 char s[151];
102
103 BADARGS(1, 4, " ?logModes channel logFile?");
104 if (argc == 1) {
105 /* they just want a list of the logfiles and modes */
106 for (i = 0; i < max_logs; i++)
107 if (logs[i].filename != NULL) {
108 strcpy(s, masktype(logs[i].mask));
109 strcat(s, " ");
110 strcat(s, logs[i].chname);
111 strcat(s, " ");
112 strcat(s, logs[i].filename);
113 Tcl_AppendElement(interp, s);
114 }
115 return TCL_OK;
116 }
117 BADARGS(4, 4, " ?logModes channel logFile?");
118 for (i = 0; i < max_logs; i++)
119 if ((logs[i].filename != NULL) && (!strcmp(logs[i].filename, argv[3]))) {
120 logs[i].flags &= ~LF_EXPIRING;
121 logs[i].mask = logmodes(argv[1]);
122 nfree(logs[i].chname);
123 logs[i].chname = NULL;
124 if (!logs[i].mask) {
125 /* ending logfile */
126 nfree(logs[i].filename);
127 logs[i].filename = NULL;
128 if (logs[i].f != NULL) {
129 fclose(logs[i].f);
130 logs[i].f = NULL;
131 }
132 logs[i].flags = 0;
133 } else {
134 logs[i].chname = (char *) nmalloc(strlen(argv[2]) + 1);
135 strcpy(logs[i].chname, argv[2]);
136 }
137 Tcl_AppendResult(interp, argv[3], NULL);
138 return TCL_OK;
139 }
140 /* do not add logfiles without any flags to log ++rtc */
141 if (!logmodes (argv [1])) {
142 Tcl_AppendResult (interp, "can't remove \"", argv[3],
143 "\" from list: no such logfile", NULL);
144 return TCL_ERROR;
145 }
146 for (i = 0; i < max_logs; i++)
147 if (logs[i].filename == NULL) {
148 logs[i].flags = 0;
149 logs[i].mask = logmodes(argv[1]);
150 logs[i].filename = (char *) nmalloc(strlen(argv[3]) + 1);
151 strcpy(logs[i].filename, argv[3]);
152 logs[i].chname = (char *) nmalloc(strlen(argv[2]) + 1);
153 strcpy(logs[i].chname, argv[2]);
154 Tcl_AppendResult(interp, argv[3], NULL);
155 return TCL_OK;
156 }
157 Tcl_AppendResult(interp, "reached max # of logfiles", NULL);
158 return TCL_ERROR;
159 }
160
161 int findidx(int z)
162 {
163 int j;
164
165 for (j = 0; j < dcc_total; j++)
166 if ((dcc[j].sock == z) && (dcc[j].type->flags & DCT_VALIDIDX))
167 return j;
168 return -1;
169 }
170
171 static void botnet_change(char *new)
172 {
173 if (strcasecmp(botnetnick, new) != 0) {
174 /* trying to change bot's nickname */
175 if (tands > 0) {
176 putlog(LOG_MISC, "*", "* Tried to change my botnet nick, but I'm still linked to a botnet.");
177 putlog(LOG_MISC, "*", "* (Unlink and try again.)");
178 return;
179 } else {
180 if (botnetnick[0])
181 putlog(LOG_MISC, "*", "* IDENTITY CHANGE: %s -> %s", botnetnick, new);
182 strcpy(botnetnick, new);
183 }
184 }
185 }
186
187 /**********************************************************************/
188
189 int init_dcc_max(), init_misc();
190
191 /* used for read/write to integer couplets */
192 typedef struct {
193 int *left; /* left side of couplet */
194 int *right; /* right side */
195 } coupletinfo;
196
197 /* read/write integer couplets (int1:int2) */
198 static char *tcl_eggcouplet(ClientData cdata, Tcl_Interp * irp, char *name1,
199 char *name2, int flags)
200 {
201 char *s, s1[41];
202 coupletinfo *cp = (coupletinfo *) cdata;
203
204 if (flags & (TCL_TRACE_READS | TCL_TRACE_UNSETS)) {
205 sprintf(s1, "%d:%d", *(cp->left), *(cp->right));
206 Tcl_SetVar2(interp, name1, name2, s1, TCL_GLOBAL_ONLY);
207 if (flags & TCL_TRACE_UNSETS)
208 Tcl_TraceVar(interp, name1,
209 TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
210 tcl_eggcouplet, cdata);
211 } else { /* writes */
212 s = Tcl_GetVar2(interp, name1, name2, TCL_GLOBAL_ONLY);
213 if (s != NULL) {
214 int nr1, nr2;
215
216 if (strlen(s) > 40)
217 s[40] = 0;
218 sscanf(s, "%d%*c%d", &nr1, &nr2);
219 *(cp->left) = nr1;
220 *(cp->right) = nr2;
221 }
222 }
223 return NULL;
224 }
225
226 /* read/write normal integer */
227 static char *tcl_eggint(ClientData cdata, Tcl_Interp * irp, char *name1,
228 char *name2, int flags)
229 {
230 char *s, s1[40];
231 long l;
232 intinfo *ii = (intinfo *) cdata;
233
234 if (flags & (TCL_TRACE_READS | TCL_TRACE_UNSETS)) {
235 /* special cases */
236 if ((int *) ii->var == &conmask)
237 strcpy(s1, masktype(conmask));
238 else if ((int *) ii->var == &default_flags) {
239 struct flag_record fr =
240 {FR_GLOBAL, 0, 0, 0, 0, 0};
241 fr.global = default_flags;
242 fr.udef_global = default_uflags;
243 build_flags(s1, &fr, 0);
244 } else
245 sprintf(s1, "%d", *(int *) ii->var);
246 Tcl_SetVar2(interp, name1, name2, s1, TCL_GLOBAL_ONLY);
247 if (flags & TCL_TRACE_UNSETS)
248 Tcl_TraceVar(interp, name1,
249 TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
250 tcl_eggint, cdata);
251 return NULL;
252 } else { /* writes */
253 s = Tcl_GetVar2(interp, name1, name2, TCL_GLOBAL_ONLY);
254 if (s != NULL) {
255 if ((int *) ii->var == &conmask) {
256 if (s[0])
257 conmask = logmodes(s);
258 else
259 conmask = LOG_MODES | LOG_MISC | LOG_CMDS;
260 } else if ((int *) ii->var == &default_flags) {
261 struct flag_record fr =
262 {FR_GLOBAL, 0, 0, 0, 0, 0};
263
264 break_down_flags(s, &fr, 0);
265 default_flags = sanity_check(fr.global); /* drummer */
266 default_uflags = fr.udef_global;
267 } else if ((ii->ro == 2) || ((ii->ro == 1) && protect_readonly)) {
268 return "read-only variable";
269 } else {
270 if (Tcl_ExprLong(interp, s, &l) == TCL_ERROR)
271 return interp->result;
272 if ((int *) ii->var == &max_dcc) {
273 if (l < max_dcc)
274 return "you can't DECREASE max-dcc";
275 max_dcc = l;
276 init_dcc_max();
277 } else if ((int *) ii->var == &max_logs) {
278 if (l < max_logs)
279 return "you can't DECREASE max-logs";
280 max_logs = l;
281 init_misc();
282 } else
283 *(ii->var) = (int) l;
284 }
285 }
286 return NULL;
287 }
288 }
289
290 /* read/write normal string variable */
291 static char *tcl_eggstr(ClientData cdata, Tcl_Interp * irp, char *name1,
292 char *name2, int flags)
293 {
294 char *s;
295 strinfo *st = (strinfo *) cdata;
296
297 if (flags & (TCL_TRACE_READS | TCL_TRACE_UNSETS)) {
298 if ((st->str == firewall) && (firewall[0])) {
299 char s1[161];
300
301 sprintf(s1, "%s:%d", firewall, firewallport);
302 Tcl_SetVar2(interp, name1, name2, s1, TCL_GLOBAL_ONLY);
303 } else
304 Tcl_SetVar2(interp, name1, name2, st->str, TCL_GLOBAL_ONLY);
305 if (flags & TCL_TRACE_UNSETS) {
306 Tcl_TraceVar(interp, name1, TCL_TRACE_READS | TCL_TRACE_WRITES |
307 TCL_TRACE_UNSETS, tcl_eggstr, cdata);
308 if ((st->max <= 0) && (protect_readonly || (st->max == 0)))
309 return "read-only variable"; /* it won't return the error... */
310 }
311 return NULL;
312 } else { /* writes */
313 if ((st->max <= 0) && (protect_readonly || (st->max == 0))) {
314 Tcl_SetVar2(interp, name1, name2, st->str, TCL_GLOBAL_ONLY);
315 return "read-only variable";
316 }
317 s = Tcl_GetVar2(interp, name1, name2, TCL_GLOBAL_ONLY);
318 if (s != NULL) {
319 if (strlen(s) > abs(st->max))
320 s[abs(st->max)] = 0;
321 if (st->str == botnetnick)
322 botnet_change(s);
323 else if (st->str == firewall) {
324 splitc(firewall, s, ':');
325 if (!firewall[0])
326 strcpy(firewall, s);
327 else
328 firewallport = atoi(s);
329 } else
330 strcpy(st->str, s);
331 if ((st->flags) && (s[0])) {
332 if (st->str[strlen(st->str) - 1] != '/')
333 strcat(st->str, "/");
334 }
335 }
336 return NULL;
337 }
338 }
339
340 /* add/remove tcl commands */
341 void add_tcl_commands(tcl_cmds * tab)
342 {
343 int i;
344
345 for (i = 0; tab[i].name; i++)
346 Tcl_CreateCommand(interp, tab[i].name, tab[i].func, NULL, NULL);
347 }
348
349 void rem_tcl_commands(tcl_cmds * tab)
350 {
351 int i;
352
353 for (i = 0; tab[i].name; i++)
354 Tcl_DeleteCommand(interp, tab[i].name);
355 }
356
357 static tcl_strings def_tcl_strings[] =
358 {
359 {"botnet-nick", botnetnick, HANDLEN, 0},
360 {"userfile", userfile, 120, STR_PROTECT},
361 {"motd", motdfile, 120, STR_PROTECT},
362 {"admin", admin, 120, 0},
363 {"help-path", helpdir, 120, STR_DIR | STR_PROTECT},
364 {"temp-path", tempdir, 120, STR_DIR | STR_PROTECT},
365 #ifndef STATIC
366 {"mod-path", moddir, 120, STR_DIR | STR_PROTECT},
367 #endif
368 {"notify-newusers", notify_new, 120, 0},
369 {"owner", owner, 120, STR_PROTECT},
370 {"my-hostname", hostname, 120, 0},
371 {"my-ip", myip, 120, 0},
372 {"network", network, 40, 0},
373 {"whois-fields", whois_fields, 120, 0},
374 {"nat-ip", natip, 120, 0},
375 {"username", botuser, 10, 0},
376 {"version", egg_version, 0, 0},
377 {"firewall", firewall, 120, 0},
378 /* confvar patch by aaronwl */
379 {"config", configfile, 0, 0},
380 {"telnet-banner", bannerfile, 120, STR_PROTECT},
381 {0, 0, 0, 0}
382 };
383
384 /* ints */
385
386 static tcl_ints def_tcl_ints[] =
387 {
388 {"ignore-time", &ignore_time, 0},
389 {"dcc-flood-thr", &dcc_flood_thr, 0},
390 {"hourly-updates", &notify_users_at, 0},
391 {"switch-logfiles-at", &switch_logfiles_at, 0},
392 {"connect-timeout", &connect_timeout, 0},
393 {"reserved-port", &reserved_port, 0},
394 /* booleans (really just ints) */
395 {"require-p", &require_p, 0},
396 {"keep-all-logs", &keep_all_logs, 0},
397 {"open-telnets", &allow_new_telnets, 0},
398 {"stealth-telnets", &stealth_telnets, 0},
399 {"use-telnet-banner", &use_telnet_banner, 0},
400 {"uptime", (int *) &online_since, 2},
401 {"console", &conmask, 0},
402 {"default-flags", &default_flags, 0},
403 /* moved from eggdrop.h */
404 {"numversion", &egg_numver, 2},
405 {"debug-tcl", &debug_tcl, 1},
406 {"die-on-sighup", &die_on_sighup, 1},
407 {"die-on-sigterm", &die_on_sigterm, 1},
408 {"remote-boots", &remote_boots, 1},
409 {"max-dcc", &max_dcc, 0},
410 {"max-logs", &max_logs, 0},
411 {"max-logsize", &max_logsize, 0},
412 {"quick-logs", &quick_logs, 0},
413 {"enable-simul", &enable_simul, 1},
414 {"debug-output", &debug_output, 1},
415 {"protect-telnet", &protect_telnet, 0},
416 {"dcc-sanitycheck", &dcc_sanitycheck, 0},
417 {"sort-users", &sort_users, 0},
418 {"ident-timeout", &identtimeout, 0},
419 {"share-unlinks", &share_unlinks, 0},
420 {"log-time", &shtime, 0},
421 {"allow-dk-cmds", &allow_dk_cmds, 0},
422 {"resolve-timeout", &resolve_timeout, 0},
423 {"must-be-owner", &must_be_owner, 1},
424 {"use-silence", &use_silence, 0}, /* arthur2 */
425 {"paranoid-telnet-flood", &par_telnet_flood, 0},
426 {"use-exempts", &use_exempts, 0}, /* Jason/drummer */
427 {"use-invites", &use_invites, 0}, /* Jason/drummer */
428 {"quiet-save", &quiet_save, 0}, /* Lucas */
429 {"force-expire", &force_expire, 0}, /* Rufus */
430 {0, 0, 0} /* arthur2 */
431 };
432
433 static tcl_coups def_tcl_coups[] =
434 {
435 {"telnet-flood", &flood_telnet_thr, &flood_telnet_time},
436 {"dcc-portrange", &min_dcc_port, &max_dcc_port}, /* dw */
437 {0, 0, 0}
438 };
439
440 /* set up Tcl variables that will hook into eggdrop internal vars via */
441 /* trace callbacks */
442 static void init_traces()
443 {
444 add_tcl_coups(def_tcl_coups);
445 add_tcl_strings(def_tcl_strings);
446 add_tcl_ints(def_tcl_ints);
447 }
448
449 void kill_tcl()
450 {
451 context;
452 rem_tcl_coups(def_tcl_coups);
453 rem_tcl_strings(def_tcl_strings);
454 rem_tcl_ints(def_tcl_ints);
455 kill_bind();
456 Tcl_DeleteInterp(interp);
457 }
458
459 extern tcl_cmds tcluser_cmds[], tcldcc_cmds[], tclmisc_cmds[];
460
461 /* not going through Tcl's crazy main() system (what on earth was he
462 * smoking?!) so we gotta initialize the Tcl interpreter */
463 void init_tcl()
464 {
465 char pver[1024];
466
467 /* initialize the interpreter */
468 context;
469 interp = Tcl_CreateInterp();
470 Tcl_Init(interp);
471 init_bind();
472 init_traces();
473 /* add new commands */
474 /* isnt this much neater :) */
475 add_tcl_commands(tcluser_cmds);
476 add_tcl_commands(tcldcc_cmds);
477 add_tcl_commands(tclmisc_cmds);
478
479 #define Q(A,B) Tcl_CreateCommand(interp,A,B,NULL,NULL)
480 Q("logfile", tcl_logfile);
481 sscanf(egg_version, "%s", pver);
482 Tcl_PkgProvide(interp, "eggdrop", pver);
483 }
484
485 /**********************************************************************/
486
487 void do_tcl(char *whatzit, char *script)
488 {
489 int code;
490 FILE *f = 0;
491
492 if (debug_tcl) {
493 f = fopen("DEBUG.TCL", "a");
494 if (f != NULL)
495 fprintf(f, "eval: %s\n", script);
496 }
497 set_tcl_vars();
498 context;
499 code = Tcl_Eval(interp, script);
500 if (debug_tcl && (f != NULL)) {
501 fprintf(f, "done eval, result=%d\n", code);
502 fclose(f);
503 }
504 if (code != TCL_OK) {
505 putlog(LOG_MISC, "*", "Tcl error in script for '%s':", whatzit);
506 putlog(LOG_MISC, "*", "%s", interp->result);
507 }
508 }
509
510 /* read and interpret the configfile given */
511 /* return 1 if everything was okay */
512 int readtclprog(char *fname)
513 {
514 int code;
515 FILE *f;
516
517 set_tcl_vars();
518 f = fopen(fname, "r");
519 if (f == NULL)
520 return 0;
521 fclose(f);
522 if (debug_tcl) {
523 f = fopen("DEBUG.TCL", "a");
524 if (f != NULL) {
525 fprintf(f, "Sourcing file %s ...\n", fname);
526 fclose(f);
527 }
528 }
529 code = Tcl_EvalFile(interp, fname);
530 if (code != TCL_OK) {
531 putlog(LOG_MISC, "*", "Tcl error in file '%s':", fname);
532 putlog(LOG_MISC, "*", "%s",
533 Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY));
534 /* try to go on anyway (shrug) */
535 /* no dont it's to risky now */
536 return 0;
537 }
538 /* refresh internal variables */
539 return 1;
540 }
541
542 void add_tcl_strings(tcl_strings * list)
543 {
544 int i;
545 strinfo *st;
546
547 for (i = 0; list[i].name; i++) {
548 if (list[i].length > 0) {
549 char *p = Tcl_GetVar(interp, list[i].name, TCL_GLOBAL_ONLY);
550
551 if (p != NULL) {
552 strncpy(list[i].buf, p, list[i].length);
553 list[i].buf[list[i].length] = 0;
554 if (list[i].flags & STR_DIR) {
555 int x = strlen(list[i].buf);
556
557 if ((x > 0) && (x < (list[i].length - 1)) &&
558 (list[i].buf[x - 1] != '/')) {
559 list[i].buf[x++] = '/';
560 list[i].buf[x] = 0;
561 }
562 }
563 }
564 }
565 st = (strinfo *) nmalloc(sizeof(strinfo));
566 strtot += sizeof(strinfo);
567 st->max = list[i].length - (list[i].flags & STR_DIR);
568 if (list[i].flags & STR_PROTECT)
569 st->max = -st->max;
570 st->str = list[i].buf;
571 st->flags = (list[i].flags & STR_DIR);
572 Tcl_TraceVar(interp, list[i].name, TCL_TRACE_READS | TCL_TRACE_WRITES |
573 TCL_TRACE_UNSETS, tcl_eggstr, (ClientData) st);
574 }
575 }
576
577 void rem_tcl_strings(tcl_strings * list)
578 {
579 int i;
580 strinfo *st;
581
582 for (i = 0; list[i].name; i++) {
583 st = (strinfo *) Tcl_VarTraceInfo(interp, list[i].name,
584 TCL_TRACE_READS |
585 TCL_TRACE_WRITES |
586 TCL_TRACE_UNSETS,
587 tcl_eggstr, NULL);
588 Tcl_UntraceVar(interp, list[i].name,
589 TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
590 tcl_eggstr, st);
591 if (st != NULL) {
592 strtot -= sizeof(strinfo);
593 nfree(st);
594 }
595 }
596 }
597
598 void add_tcl_ints(tcl_ints * list)
599 {
600 int i;
601 intinfo *ii;
602
603 for (i = 0; list[i].name; i++) {
604 char *p = Tcl_GetVar(interp, list[i].name, TCL_GLOBAL_ONLY);
605
606 if (p != NULL)
607 *(list[i].val) = atoi(p);
608 ii = nmalloc(sizeof(intinfo));
609 strtot += sizeof(intinfo);
610 ii->var = list[i].val;
611 ii->ro = list[i].readonly;
612 Tcl_TraceVar(interp, list[i].name,
613 TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
614 tcl_eggint, (ClientData) ii);
615 }
616
617 }
618
619 void rem_tcl_ints(tcl_ints * list)
620 {
621 int i;
622 intinfo *ii;
623
624 for (i = 0; list[i].name; i++) {
625 ii = (intinfo *) Tcl_VarTraceInfo(interp, list[i].name,
626 TCL_TRACE_READS |
627 TCL_TRACE_WRITES |
628 TCL_TRACE_UNSETS,
629 tcl_eggint, NULL);
630 Tcl_UntraceVar(interp, list[i].name,
631 TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
632 tcl_eggint, (ClientData) ii);
633 if (ii) {
634 strtot -= sizeof(intinfo);
635 nfree(ii);
636 }
637 }
638 }
639
640 /* allocate couplet space for tracing couplets */
641 void add_tcl_coups(tcl_coups * list)
642 {
643 coupletinfo *cp;
644 int i;
645
646 for (i = 0; list[i].name; i++) {
647 cp = (coupletinfo *) nmalloc(sizeof(coupletinfo));
648 strtot += sizeof(coupletinfo);
649 cp->left = list[i].lptr;
650 cp->right = list[i].rptr;
651 Tcl_TraceVar(interp, list[i].name,
652 TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
653 tcl_eggcouplet, (ClientData) cp);
654 }
655 }
656
657 void rem_tcl_coups(tcl_coups * list)
658 {
659 coupletinfo *cp;
660 int i;
661
662 for (i = 0; list[i].name; i++) {
663 cp = (coupletinfo *) Tcl_VarTraceInfo(interp, list[i].name,
664 TCL_TRACE_READS |
665 TCL_TRACE_WRITES |
666 TCL_TRACE_UNSETS,
667 tcl_eggcouplet, NULL);
668 strtot -= sizeof(coupletinfo);
669 Tcl_UntraceVar(interp, list[i].name,
670 TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
671 tcl_eggcouplet, (ClientData) cp);
672 nfree(cp);
673 }
674 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23