/[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.8 - (show annotations) (download) (as text)
Mon Aug 2 20:12:49 1999 UTC (20 years, 1 month ago) by segfault
Branch: MAIN
Changes since 1.7: +13 -8 lines
File MIME type: text/x-chdr
drummer's globchanset patch

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23