src/tclegg.h File Reference

#include "lush.h"
#include "proto.h"
Include dependency graph for tclegg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  timer_str
struct  _tcl_strings
struct  _tcl_int
struct  _tcl_coups
struct  _tcl_cmds
struct  _cd_tcl_cmd
struct  LocaleTable

Defines

#define CMD_LEAVE   (Function)(-1)
#define MATCH_PARTIAL   0
#define MATCH_EXACT   1
#define MATCH_MASK   2
#define MATCH_CASE   3
#define MATCH_MODE   4
#define MATCH_CRON   5
#define BIND_USE_ATTR   0x010
#define BIND_STACKABLE   0x020
#define BIND_HAS_BUILTINS   0x040
#define BIND_WANTRET   0x080
#define BIND_ALTER_ARGS   0x100
#define BIND_STACKRET   0x200
#define BIND_NOMATCH   0
#define BIND_AMBIGUOUS   1
#define BIND_MATCHED   2
#define BIND_EXECUTED   3
#define BIND_EXEC_LOG   4
#define BIND_QUIT   5
#define STDVAR
#define BADARGS(nl, nh, example)
#define CHECKVALIDITY(a)

Typedefs

typedef struct timer_str tcl_timer_t
typedef void(* tcleventcallback )(char *, char *, int, const char *, int)
typedef struct _tcl_strings tcl_strings
typedef struct _tcl_int tcl_ints
typedef struct _tcl_coups tcl_coups
typedef struct _tcl_cmds tcl_cmds
typedef struct _cd_tcl_cmd cd_tcl_cmd

Functions

void do_tcl_async (char *, char *, tcleventcallback)
unsigned long add_timer (tcl_timer_t **, int, char *, unsigned long)
int remove_timer (tcl_timer_t **, unsigned long)
void list_timers (Tcl_Interp *, tcl_timer_t *)
void wipe_timers (Tcl_Interp *, tcl_timer_t **)
void do_check_timers (tcl_timer_t **)
 void ((void(*)(tcl_cmds *)) global[14])(tcl_cmds *)
void add_cd_tcl_cmds (cd_tcl_cmd *)
 void ((void(*)(tcl_cmds *)) global[15])(tcl_cmds *)
void rem_cd_tcl_cmds (cd_tcl_cmd *)
 void ((void(*)(tcl_strings *)) global[18])(tcl_strings *)
 void ((void(*)(tcl_strings *)) global[19])(tcl_strings *)
 void ((void(*)(tcl_coups *)) global[209])(tcl_coups *)
 void ((void(*)(tcl_coups *)) global[210])(tcl_coups *)
 void ((void(*)(tcl_ints *)) global[16])(tcl_ints *)
 void ((void(*)(tcl_ints *)) global[17])(tcl_ints *)
void do_tcl_sync (char *, char *, tcleventcallback, int)
const char * tcl_resultstring ()
int tcl_resultint ()
int tcl_resultempty ()
int tcl_threaded ()
int fork_before_tcl ()

Variables

static const LocaleTable localeTable []

Define Documentation

#define BADARGS ( nl,
nh,
example   ) 
#define BIND_ALTER_ARGS   0x100

Definition at line 83 of file tclegg.h.

#define BIND_AMBIGUOUS   1

Definition at line 93 of file tclegg.h.

Referenced by check_tcl_fil().

#define BIND_EXEC_LOG   4
#define BIND_EXECUTED   3

Definition at line 95 of file tclegg.h.

Referenced by check_tcl_msg().

#define BIND_HAS_BUILTINS   0x040

Definition at line 74 of file tclegg.h.

Referenced by check_tcl_fil(), and check_tcl_msg().

#define BIND_MATCHED   2

Definition at line 94 of file tclegg.h.

Referenced by check_tcl_msg().

#define BIND_NOMATCH   0

Definition at line 92 of file tclegg.h.

Referenced by check_tcl_fil(), check_tcl_msgm(), check_tcl_notc(), and check_tcl_wall().

#define BIND_QUIT   5

Definition at line 97 of file tclegg.h.

Referenced by check_tcl_fil().

#define BIND_STACKABLE   0x020
#define BIND_STACKRET   0x200

Definition at line 88 of file tclegg.h.

Referenced by check_tcl_msgm(), check_tcl_notc(), and check_tcl_wall().

#define BIND_USE_ATTR   0x010
#define BIND_WANTRET   0x080
#define CHECKVALIDITY (  ) 
Value:
do {                                    \
        if (!check_validity(argv[0], (a))) {                            \
                Tcl_AppendResult(irp, "bad builtin command call!",      \
                                 NULL);                                 \
                return TCL_ERROR;                                       \
        }                                                               \
} while (0)

Definition at line 146 of file tclegg.h.

#define CMD_LEAVE   (Function)(-1)

Definition at line 40 of file tclegg.h.

#define MATCH_CASE   3

Definition at line 47 of file tclegg.h.

#define MATCH_CRON   5

Definition at line 49 of file tclegg.h.

#define MATCH_EXACT   1

Definition at line 45 of file tclegg.h.

Referenced by check_tcl_msg(), check_tcl_raw(), and check_tcl_raw4().

#define MATCH_MASK   2
#define MATCH_MODE   4

Definition at line 48 of file tclegg.h.

#define MATCH_PARTIAL   0

Definition at line 44 of file tclegg.h.

Referenced by check_tcl_fil().

#define STDVAR
Value:
(cd, irp, argc, argv)                                    \
        ClientData cd;                                                  \
        Tcl_Interp *irp;                                                \
        int argc;                                                       \
        char *argv[];

Definition at line 132 of file tclegg.h.


Typedef Documentation

typedef struct _cd_tcl_cmd cd_tcl_cmd
typedef struct _tcl_cmds tcl_cmds
typedef struct _tcl_coups tcl_coups
typedef struct _tcl_int tcl_ints
typedef struct _tcl_strings tcl_strings
typedef struct timer_str tcl_timer_t
typedef void(* tcleventcallback)(char *, char *, int, const char *, int)

Definition at line 114 of file tclegg.h.


Function Documentation

void add_cd_tcl_cmds ( cd_tcl_cmd  ) 

Definition at line 414 of file tcl.c.

References _cd_tcl_cmd::callback, _cd_tcl_cmd::cdata, interp, _cd_tcl_cmd::name, and NULL.

Referenced by init_bind().

00415 {
00416   while (table->name) {
00417     Tcl_CreateCommand(interp, table->name, table->callback,
00418                       (ClientData) table->cdata, NULL);
00419     table++;
00420   }
00421 }

Here is the caller graph for this function:

unsigned long add_timer ( tcl_timer_t **  ,
int  ,
char *  ,
unsigned  long 
)

Definition at line 561 of file chanprog.c.

References timer_str::mins, nmalloc, return(), and timer_id.

Referenced by tcl_timer(), and tcl_utimer().

00563 {
00564   tcl_timer_t *old = (*stack);
00565 
00566   *stack = nmalloc(sizeof **stack);
00567   (*stack)->next = old;
00568   (*stack)->mins = elapse;
00569   (*stack)->cmd = nmalloc(strlen(cmd) + 1);
00570   strcpy((*stack)->cmd, cmd);
00571   /* If it's just being added back and already had an id,
00572    * don't create a new one.
00573    */
00574   if (prev_id > 0)
00575     (*stack)->id = prev_id;
00576   else
00577     (*stack)->id = timer_id++;
00578   return (*stack)->id;
00579 }

Here is the call graph for this function:

Here is the caller graph for this function:

void do_check_timers ( tcl_timer_t **   ) 

Definition at line 603 of file chanprog.c.

References do_tcl, egg_snprintf, timer_str::mins, timer_str::next, nfree, and NULL.

Referenced by core_minutely(), and core_secondly().

00604 {
00605   tcl_timer_t *mark = *stack, *old = NULL;
00606   char x[16];
00607 
00608   /* New timers could be added by a Tcl script inside a current timer
00609    * so i'll just clear out the timer list completely, and add any
00610    * unexpired timers back on.
00611    */
00612   *stack = NULL;
00613   while (mark) {
00614     if (mark->mins > 0)
00615       mark->mins--;
00616     old = mark;
00617     mark = mark->next;
00618     if (!old->mins) {
00619       egg_snprintf(x, sizeof x, "timer%lu", old->id);
00620       do_tcl(x, old->cmd);
00621       nfree(old->cmd);
00622       nfree(old);
00623     } else {
00624       old->next = *stack;
00625       *stack = old;
00626     }
00627   }
00628 }

Here is the caller graph for this function:

void do_tcl_async ( char *  ,
char *  ,
tcleventcallback   
)

Definition at line 729 of file tcl.c.

References do_tcl_sync().

Referenced by dns_tcl_iporhostres().

00729                                                                           {
00730   do_tcl_sync(context, script, callback, 0);
00731 }

Here is the call graph for this function:

Here is the caller graph for this function:

void do_tcl_sync ( char *  ,
char *  ,
tcleventcallback  ,
int   
)

Referenced by do_tcl_async(), and mainloop().

Here is the caller graph for this function:

int fork_before_tcl (  ) 

Definition at line 1102 of file tcl.c.

References tcl_threaded().

Referenced by bg_do_split(), bg_prepare_split(), and bg_send_quit().

01103 {
01104 #ifndef REPLACE_NOTIFIER
01105   return tcl_threaded();
01106 #endif
01107   return 0;
01108 }

Here is the call graph for this function:

Here is the caller graph for this function:

void list_timers ( Tcl_Interp ,
tcl_timer_t  
)

Definition at line 647 of file chanprog.c.

References argv, timer_str::cmd, EGG_CONST, egg_snprintf, timer_str::id, timer_str::mins, timer_str::next, and Tcl_Free.

Referenced by tcl_timers(), and tcl_utimers().

00648 {
00649   char mins[10], id[16], *x;
00650   EGG_CONST char *argv[3];
00651   tcl_timer_t *mark;
00652 
00653   for (mark = stack; mark; mark = mark->next) {
00654     egg_snprintf(mins, sizeof mins, "%u", mark->mins);
00655     egg_snprintf(id, sizeof id, "timer%lu", mark->id);
00656     argv[0] = mins;
00657     argv[1] = mark->cmd;
00658     argv[2] = id;
00659     x = Tcl_Merge(3, argv);
00660     Tcl_AppendElement(irp, x);
00661     Tcl_Free((char *) x);
00662   }
00663 }

Here is the caller graph for this function:

void rem_cd_tcl_cmds ( cd_tcl_cmd  ) 

Definition at line 432 of file tcl.c.

References interp, and _cd_tcl_cmd::name.

00433 {
00434   while (table->name) {
00435     Tcl_DeleteCommand(interp, table->name);
00436     table++;
00437   }
00438 }

int remove_timer ( tcl_timer_t **  ,
unsigned  long 
)

Definition at line 583 of file chanprog.c.

References timer_str::cmd, and nfree.

Referenced by tcl_killtimer(), and tcl_killutimer().

00584 {
00585   tcl_timer_t *old;
00586   int ok = 0;
00587 
00588   while (*stack) {
00589     if ((*stack)->id == id) {
00590       ok++;
00591       old = *stack;
00592       *stack = ((*stack)->next);
00593       nfree(old->cmd);
00594       nfree(old);
00595     } else
00596       stack = &((*stack)->next);
00597   }
00598   return ok;
00599 }

Here is the caller graph for this function:

int tcl_resultempty (  ) 

Definition at line 463 of file tcl.c.

References tcl_resultstring().

Referenced by add_note(), answer_local_whom(), cmd_chat(), cmd_whom(), remote_tell_who(), and tell_who().

00463                       {
00464   const char *result;
00465   result = tcl_resultstring();
00466   return (result && result[0]) ? 0 : 1;
00467 }

Here is the call graph for this function:

Here is the caller graph for this function:

int tcl_resultint (  ) 

Definition at line 470 of file tcl.c.

References interp, and NULL.

Referenced by call_tcl_func(), cmd_chat(), and cmd_whom().

00471 {
00472   int result;
00473 #ifdef USE_TCL_OBJ
00474   if (Tcl_GetIntFromObj(NULL, Tcl_GetObjResult(interp), &result) != TCL_OK)
00475 #else
00476   if (Tcl_GetInt(NULL, interp->result, &result) != TCL_OK)
00477 #endif
00478     result = 0;
00479   return result;
00480 }

Here is the caller graph for this function:

const char* tcl_resultstring (  ) 

Definition at line 452 of file tcl.c.

References interp.

Referenced by answer_local_whom(), call_tcl_func(), cmd_set(), cmd_tcl(), remote_tell_who(), tcl_resultempty(), tell_verbose_status(), and tell_who().

00453 {
00454   const char *result;
00455 #ifdef USE_TCL_OBJ
00456   result = Tcl_GetStringResult(interp);
00457 #else
00458   result = interp->result;
00459 #endif
00460   return result;
00461 }

Here is the caller graph for this function:

int tcl_threaded (  ) 

Definition at line 1090 of file tcl.c.

Referenced by fork_before_tcl(), and tell_verbose_status().

01091 {
01092 #ifdef HAVE_TCL_GETCURRENTTHREAD
01093   if (Tcl_GetCurrentThread() != (Tcl_ThreadId)0)
01094     return 1;
01095 #endif
01096 
01097   return 0;
01098 }

Here is the caller graph for this function:

void ( (void(*)(tcl_ints *))  global[17]  ) 

Definition at line 1034 of file tcl.c.

References interp, _tcl_int::name, nfree, NULL, strtot, and tcl_eggint().

01035 {
01036   int i, f;
01037   intinfo *ii;
01038 
01039   f = TCL_GLOBAL_ONLY | TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS;
01040   for (i = 0; list[i].name; i++) {
01041     ii = (intinfo *) Tcl_VarTraceInfo(interp, list[i].name, f, tcl_eggint,
01042                                       NULL);
01043     Tcl_UntraceVar(interp, list[i].name, f, tcl_eggint, (ClientData) ii);
01044     if (ii) {
01045       strtot -= sizeof(intinfo);
01046       nfree(ii);
01047     }
01048   }
01049 }

Here is the call graph for this function:

void ( (void(*)(tcl_ints *))  global[16]  ) 

Definition at line 1012 of file tcl.c.

References interp, _tcl_int::name, nmalloc, NULL, protect_readonly, _tcl_int::readonly, intinfo::ro, strtot, tcl_eggint(), _tcl_int::val, and intinfo::var.

01013 {
01014   int i, tmp;
01015   intinfo *ii;
01016 
01017   for (i = 0; list[i].name; i++) {
01018     ii = nmalloc(sizeof *ii);
01019     strtot += sizeof(intinfo);
01020     ii->var = list[i].val;
01021     ii->ro = list[i].readonly;
01022     tmp = protect_readonly;
01023     protect_readonly = 0;
01024     tcl_eggint((ClientData) ii, interp, list[i].name, NULL, TCL_TRACE_WRITES);
01025     protect_readonly = tmp;
01026     tcl_eggint((ClientData) ii, interp, list[i].name, NULL, TCL_TRACE_READS);
01027     Tcl_TraceVar(interp, list[i].name,
01028                  TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
01029                  tcl_eggint, (ClientData) ii);
01030   }
01031 
01032 }

Here is the call graph for this function:

void ( (void(*)(tcl_coups *))  global[210]  ) 

Definition at line 1073 of file tcl.c.

References interp, _tcl_coups::name, nfree, NULL, strtot, and tcl_eggcouplet().

01074 {
01075   int i, f;
01076   coupletinfo *cp;
01077 
01078   f = TCL_GLOBAL_ONLY | TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS;
01079   for (i = 0; list[i].name; i++) {
01080     cp = (coupletinfo *) Tcl_VarTraceInfo(interp, list[i].name, f,
01081                                           tcl_eggcouplet, NULL);
01082     strtot -= sizeof(coupletinfo);
01083     Tcl_UntraceVar(interp, list[i].name, f, tcl_eggcouplet, (ClientData) cp);
01084     nfree(cp);
01085   }
01086 }

Here is the call graph for this function:

void ( (void(*)(tcl_coups *))  global[209]  ) 

Definition at line 1053 of file tcl.c.

References interp, coupletinfo::left, _tcl_coups::lptr, _tcl_coups::name, nmalloc, NULL, coupletinfo::right, _tcl_coups::rptr, strtot, and tcl_eggcouplet().

01054 {
01055   coupletinfo *cp;
01056   int i;
01057 
01058   for (i = 0; list[i].name; i++) {
01059     cp = nmalloc(sizeof *cp);
01060     strtot += sizeof(coupletinfo);
01061     cp->left = list[i].lptr;
01062     cp->right = list[i].rptr;
01063     tcl_eggcouplet((ClientData) cp, interp, list[i].name, NULL,
01064                    TCL_TRACE_WRITES);
01065     tcl_eggcouplet((ClientData) cp, interp, list[i].name, NULL,
01066                    TCL_TRACE_READS);
01067     Tcl_TraceVar(interp, list[i].name,
01068                  TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
01069                  tcl_eggcouplet, (ClientData) cp);
01070   }
01071 }

Here is the call graph for this function:

void ( (void(*)(tcl_strings *))  global[19]  ) 

Definition at line 995 of file tcl.c.

References interp, _tcl_strings::name, nfree, NULL, strtot, and tcl_eggstr().

00996 {
00997   int i, f;
00998   strinfo *st;
00999 
01000   f = TCL_GLOBAL_ONLY | TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS;
01001   for (i = 0; list[i].name; i++) {
01002     st = (strinfo *) Tcl_VarTraceInfo(interp, list[i].name, f, tcl_eggstr,
01003                                       NULL);
01004     Tcl_UntraceVar(interp, list[i].name, f, tcl_eggstr, st);
01005     if (st != NULL) {
01006       strtot -= sizeof(strinfo);
01007       nfree(st);
01008     }
01009   }
01010 }

Here is the call graph for this function:

void ( (void(*)(tcl_strings *))  global[18]  ) 

Definition at line 971 of file tcl.c.

References _tcl_strings::buf, strinfo::flags, _tcl_strings::flags, interp, _tcl_strings::length, strinfo::max, _tcl_strings::name, nmalloc, NULL, protect_readonly, strinfo::str, STR_DIR, STR_PROTECT, strtot, and tcl_eggstr().

00972 {
00973   int i;
00974   strinfo *st;
00975   int tmp;
00976 
00977   for (i = 0; list[i].name; i++) {
00978     st = nmalloc(sizeof *st);
00979     strtot += sizeof(strinfo);
00980     st->max = list[i].length - (list[i].flags & STR_DIR);
00981     if (list[i].flags & STR_PROTECT)
00982       st->max = -st->max;
00983     st->str = list[i].buf;
00984     st->flags = (list[i].flags & STR_DIR);
00985     tmp = protect_readonly;
00986     protect_readonly = 0;
00987     tcl_eggstr((ClientData) st, interp, list[i].name, NULL, TCL_TRACE_WRITES);
00988     protect_readonly = tmp;
00989     tcl_eggstr((ClientData) st, interp, list[i].name, NULL, TCL_TRACE_READS);
00990     Tcl_TraceVar(interp, list[i].name, TCL_TRACE_READS | TCL_TRACE_WRITES |
00991                  TCL_TRACE_UNSETS, tcl_eggstr, (ClientData) st);
00992   }
00993 }

Here is the call graph for this function:

void ( (void(*)(tcl_cmds *))  global[15]  ) 

Definition at line 424 of file tcl.c.

References interp, and _tcl_cmds::name.

00425 {
00426   int i;
00427 
00428   for (i = 0; table[i].name; i++)
00429     Tcl_DeleteCommand(interp, table[i].name);
00430 }

void ( (void(*)(tcl_cmds *))  global[14]  ) 

Definition at line 387 of file tcl.c.

References interp, _tcl_cmds::name, and NULL.

00388 {
00389   int i;
00390 
00391   for (i = 0; table[i].name; i++)
00392     Tcl_CreateCommand(interp, table[i].name, table[i].func, NULL, NULL);
00393 }

void wipe_timers ( Tcl_Interp ,
tcl_timer_t **   
)

Definition at line 632 of file chanprog.c.

References timer_str::next, nfree, and NULL.

Referenced by cmd_restart().

00633 {
00634   tcl_timer_t *mark = *stack, *old;
00635 
00636   while (mark) {
00637     old = mark;
00638     mark = mark->next;
00639     nfree(old->cmd);
00640     nfree(old);
00641   }
00642   *stack = NULL;
00643 }

Here is the caller graph for this function:


Variable Documentation

const LocaleTable localeTable[] [static]

Definition at line 216 of file tclegg.h.

Referenced by init_tcl().


Generated on 7 Sep 2016 for Eggdrop by  doxygen 1.6.1