src/tcl.c File Reference

#include <stdlib.h>
#include <locale.h>
#include "main.h"
Include dependency graph for tcl.c:

Go to the source code of this file.

Data Structures

struct  strinfo
struct  intinfo
struct  coupletinfo

Functions

 char ((char *)(global[115]))[]
int int int int(*) int (global[102]))
int int int int(*)(*) int (global[104]))
int int int int(*)(*)(*) int (global[105]))
int int int int(*)(*)(*) int(*) int (global[106]))
int(*) int (global[244]))=0
int(*) int (global[226]))=0
int(*) int (global[225]))=0
int(*) int (global[227]))=0
int(*) int (global[258]))
int(*) int (global[284]))
int(*) int (global[283]))
Tcl_InterpTcl_CreateInterp ()
int expmem_tcl ()
static void botnet_change (char *new)
int init_misc ()
static char * tcl_eggcouplet (ClientData cdata, Tcl_Interp *irp, char *name1, char *name2, int flags)
static char * tcl_eggint (ClientData cdata, Tcl_Interp *irp, char *name1, char *name2, int flags)
static char * tcl_eggstr (ClientData cdata, Tcl_Interp *irp, char *name1, char *name2, int flags)
 void ((void(*)(tcl_cmds *)) global[14])(tcl_cmds *table)
void add_cd_tcl_cmds (cd_tcl_cmd *table)
 void ((void(*)(tcl_cmds *)) global[15])(tcl_cmds *table)
void rem_cd_tcl_cmds (cd_tcl_cmd *table)
const char * tcl_resultstring ()
int tcl_resultempty ()
int tcl_resultint ()
static void init_traces ()
void bgtclcallback (char *context, char *script, int code, const char *result, int dofree)
 void ((void(*)(char *, char *)) global[148])(char *context
int tclthreadmainloop ()
struct threaddatathreaddata ()
void do_tcl_async (char *context, char *script, tcleventcallback callback)
int init_threaddata (int mainthread)
void init_tcl (int argc, char **argv)
void kill_tcl ()
 int ((int(*)(const char *)) global[149])(char *fname)
 void ((void(*)(tcl_strings *)) global[18])(tcl_strings *list)
 void ((void(*)(tcl_strings *)) global[19])(tcl_strings *list)
 void ((void(*)(tcl_ints *)) global[16])(tcl_ints *list)
 void ((void(*)(tcl_ints *)) global[17])(tcl_ints *list)
 void ((void(*)(tcl_coups *)) global[209])(tcl_coups *list)
 void ((void(*)(tcl_coups *)) global[210])(tcl_coups *list)
int tcl_threaded ()
int fork_before_tcl ()

Variables

time_t(* int )(global[205])) = 1
char * global [116][]
char motdfile []
char char char firewall []
char char char char char char myip []
char char char char char char moddir []
char char char char char char char owner []
char char char char char char char network []
char char char char char char
char char 
bannerfile []
char char char char char char
char char 
egg_version []
char char char char char char
char char char 
configfile []
char char char char char char
char char char 
logfile_suffix []
char char char char char char
char char char 
log_ts []
char char char char char char
char char char 
textdir []
char char char char char char
char char char 
pid_file []
int flood_telnet_thr
int flood_telnet_time
int shtime
int int int keep_all_logs
int int int allow_new_telnets
int int int stealth_telnets
int int int use_telnet_banner
int int int int conmask
int int int int switch_logfiles_at
int int int int connect_timeout
int int int int firewallport
int int int int notify_users_at
int int int int flood_thr
int int int int tands
int int int int(*)(*)(*) die_on_sighup
int int int int(*)(*)(*) die_on_sigterm
int int int int(*)(*)(*) max_logs
int int int int(*)(*)(*) max_logsize
int int int int(*)(*)(*) int(*) identtimeout
int int int int(*)(*)(*) int(*) dcc_sanitycheck
int int int int(*)(*)(*) int(*) dupwait_timeout
int int int int(*)(*)(*) int(*) egg_numver
int int int int(*)(*)(*) int(*) share_unlinks
int int int int(*)(*)(*) int(*) protect_telnet
int int int int(*)(*)(*) int(*) sort_users
int int int int(*)(*)(*) int(*) strict_host
int int int int(*)(*)(*) int(*) resolve_timeout
int int int int(*)(*)(*) int(*) default_uflags
int int int int(*)(*)(*) int(*) int cidr_support
tcl_timer_ttimer
tcl_timer_tutimer
Tcl_Interp *(* Tcl_Interp )(global[128]))
char whois_fields [1025] = ""
int dcc_flood_thr = 3
int remote_boots = 2
int allow_dk_cmds = 1
int max_socks = 100
int quick_logs = 0
int par_telnet_flood = 1
int quiet_save = 0
int strtot = 0
int handlen = 9 */
int utftot = 0
int clientdata_stuff = 0
int strict_servernames = 0
int enable_simul = 1
int use_console_r = 0
int debug_output = 0
static tcl_strings def_tcl_strings []
static tcl_ints def_tcl_ints []
static tcl_coups def_tcl_coups []
 tcldcc_cmds []
 tclmisc_cmds []
 tclmisc_objcmds []
 tcldns_cmds []

Function Documentation

void add_cd_tcl_cmds ( cd_tcl_cmd table  ) 

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:

void bgtclcallback ( char *  context,
char *  script,
int  code,
const char *  result,
int  dofree 
)

Definition at line 582 of file tcl.c.

References LOG_MISC, nfree, NULL, and putlog.

00583                                                    {
00584 #ifdef USE_TCL_ENCODING
00585   Tcl_DString dstr;
00586 #endif
00587 
00588   if (code == TCL_ERROR) {
00589 #ifdef USE_TCL_ENCODING
00590     /* properly convert string to system encoding. */
00591     Tcl_DStringInit(&dstr);
00592     Tcl_UtfToExternalDString(NULL, result, -1, &dstr);
00593     result = Tcl_DStringValue(&dstr);
00594 #endif
00595     putlog(LOG_MISC, "*", "Tcl error in script for '%s':", context);
00596     putlog(LOG_MISC, "*", "%s", result);
00597 #ifdef USE_TCL_ENCODING
00598   Tcl_DStringFree(&dstr);
00599 #endif
00600   }
00601   if (dofree) {
00602     nfree(context);
00603     nfree(script);
00604   }
00605 }

static void botnet_change ( char *  new  )  [static]

Definition at line 106 of file tcl.c.

References botnetnick, egg_strcasecmp, LOG_MISC, putlog, and tands.

Referenced by tcl_eggstr().

00107 {
00108   if (egg_strcasecmp(botnetnick, new)) {
00109     /* Trying to change bot's nickname */
00110     if (tands > 0) {
00111       putlog(LOG_MISC, "*", "* Tried to change my botnet nick, but I'm still "
00112              "linked to a botnet.");
00113       putlog(LOG_MISC, "*", "* (Unlink and try again.)");
00114       return;
00115     } else {
00116       if (botnetnick[0])
00117         putlog(LOG_MISC, "*", "* IDENTITY CHANGE: %s -> %s", botnetnick, new);
00118       strcpy(botnetnick, new);
00119     }
00120   }
00121 }

Here is the caller graph for this function:

char ( (char *)(global[115])   ) 
void do_tcl_async ( char *  context,
char *  script,
tcleventcallback  callback 
)

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:

int expmem_tcl (  ) 

Definition at line 101 of file tcl.c.

References clientdata_stuff, strtot, and utftot.

Referenced by debug_mem_to_dcc(), and expected_memory().

00102 {
00103   return strtot + utftot + clientdata_stuff;
00104 }

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:

int init_misc (  ) 

Definition at line 98 of file misc.c.

References log_t::chname, log_t::f, log_t::filename, log_t::flags, log_t::mask, max_logs, nmalloc, nrealloc, NULL, log_t::repeats, and log_t::szlast.

00099 {
00100   static int last = 0;
00101 
00102   if (max_logs < 1)
00103     max_logs = 1;
00104   if (logs)
00105     logs = nrealloc(logs, max_logs * sizeof(log_t));
00106   else
00107     logs = nmalloc(max_logs * sizeof(log_t));
00108   for (; last < max_logs; last++) {
00109     logs[last].filename = logs[last].chname = NULL;
00110     logs[last].mask = 0;
00111     logs[last].f = NULL;
00112     /* Added by cybah  */
00113     logs[last].szlast[0] = 0;
00114     logs[last].repeats = 0;
00115     /* Added by rtc  */
00116     logs[last].flags = 0;
00117   }
00118 }

void init_tcl ( int  argc,
char **  argv 
)

Definition at line 757 of file tcl.c.

References add_tcl_commands, egg_bzero, egg_version, LocaleTable::encoding, init_bind(), init_traces(), interp, LocaleTable::lang, localeTable, NULL, and Tcl_CreateInterp().

Referenced by main(), and mainloop().

00758 {
00759 #ifdef REPLACE_NOTIFIER
00760   Tcl_NotifierProcs notifierprocs;
00761 #endif /* REPLACE_NOTIFIER */
00762 
00763 #ifdef USE_TCL_ENCODING
00764   const char *encoding;
00765   int i;
00766   char *langEnv;
00767 #endif /* USE_TCL_ENCODING */
00768 #ifdef USE_TCL_PACKAGE
00769   int j;
00770   char pver[1024] = "";
00771 #endif /* USE_TCL_PACKAGE */
00772 
00773 #ifdef REPLACE_NOTIFIER
00774   egg_bzero(&notifierprocs, sizeof(notifierprocs));
00775   notifierprocs.initNotifierProc = tickle_InitNotifier;
00776   notifierprocs.createFileHandlerProc = tickle_CreateFileHandler;
00777   notifierprocs.deleteFileHandlerProc = tickle_DeleteFileHandler;
00778   notifierprocs.setTimerProc = tickle_SetTimer;
00779   notifierprocs.waitForEventProc = tickle_WaitForEvent;
00780   notifierprocs.finalizeNotifierProc = tickle_FinalizeNotifier;
00781 
00782   Tcl_SetNotifier(&notifierprocs);
00783 #endif /* REPLACE_NOTIFIER */
00784 
00785 /* This must be done *BEFORE* Tcl_SetSystemEncoding(),
00786  * or Tcl_SetSystemEncoding() will cause a segfault.
00787  */
00788 #ifdef USE_TCL_FINDEXEC
00789   /* This is used for 'info nameofexecutable'.
00790    * The filename in argv[0] must exist in a directory listed in
00791    * the environment variable PATH for it to register anything.
00792    */
00793   Tcl_FindExecutable(argv[0]);
00794 #endif /* USE_TCL_FINDEXEC */
00795 
00796   /* Initialize the interpreter */
00797   interp = Tcl_CreateInterp();
00798 
00799 #ifdef DEBUG_MEM
00800   /* Initialize Tcl's memory debugging if we want it */
00801   Tcl_InitMemory(interp);
00802 #endif
00803 
00804   /* Set Tcl variable tcl_interactive to 0 */
00805   Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
00806 
00807   /* Setup script library facility */
00808   Tcl_Init(interp);
00809   Tcl_SetServiceMode(TCL_SERVICE_ALL);
00810 
00811 /* Code based on Tcl's TclpSetInitialEncodings() */
00812 #ifdef USE_TCL_ENCODING
00813   /* Determine the current encoding from the LC_* or LANG environment
00814    * variables.
00815    */
00816   langEnv = getenv("LC_ALL");
00817   if (langEnv == NULL || langEnv[0] == '\0') {
00818     langEnv = getenv("LC_CTYPE");
00819   }
00820   if (langEnv == NULL || langEnv[0] == '\0') {
00821     langEnv = getenv("LANG");
00822   }
00823   if (langEnv == NULL || langEnv[0] == '\0') {
00824     langEnv = NULL;
00825   }
00826 
00827   encoding = NULL;
00828   if (langEnv != NULL) {
00829     for (i = 0; localeTable[i].lang != NULL; i++)
00830       if (strcmp(localeTable[i].lang, langEnv) == 0) {
00831         encoding = localeTable[i].encoding;
00832         break;
00833       }
00834 
00835     /* There was no mapping in the locale table.  If there is an
00836      * encoding subfield, we can try to guess from that.
00837      */
00838     if (encoding == NULL) {
00839       char *p;
00840 
00841       for (p = langEnv; *p != '\0'; p++) {
00842         if (*p == '.') {
00843           p++;
00844           break;
00845         }
00846       }
00847       if (*p != '\0') {
00848         Tcl_DString ds;
00849 
00850         Tcl_DStringInit(&ds);
00851         Tcl_DStringAppend(&ds, p, -1);
00852 
00853         encoding = Tcl_DStringValue(&ds);
00854         Tcl_UtfToLower(Tcl_DStringValue(&ds));
00855         if (Tcl_SetSystemEncoding(NULL, encoding) == TCL_OK) {
00856           Tcl_DStringFree(&ds);
00857           goto resetPath;
00858         }
00859         Tcl_DStringFree(&ds);
00860         encoding = NULL;
00861       }
00862     }
00863   }
00864 
00865   if (encoding == NULL) {
00866     //encoding = "iso8859-1";
00867     encoding = "utf-8";
00868   }
00869 
00870   Tcl_SetSystemEncoding(NULL, encoding);
00871 
00872 resetPath:
00873 
00874   /* Initialize the C library's locale subsystem. */
00875   setlocale(LC_CTYPE, "");
00876 
00877   /* In case the initial locale is not "C", ensure that the numeric
00878    * processing is done in "C" locale regardless. */
00879   setlocale(LC_NUMERIC, "C");
00880 
00881   /* Keep the iso8859-1 encoding preloaded.  The IO package uses it for
00882    * gets on a binary channel. */
00883   Tcl_GetEncoding(NULL, "iso8859-1");
00884 #endif /* USE_TCL_ENCODING */
00885 
00886 #ifdef USE_TCL_PACKAGE
00887   /* Add eggdrop to Tcl's package list */
00888   for (j = 0; j <= strlen(egg_version); j++) {
00889     if ((egg_version[j] == ' ') || (egg_version[j] == '+'))
00890       break;
00891     pver[strlen(pver)] = egg_version[j];
00892   }
00893   Tcl_PkgProvide(interp, "eggdrop", pver);
00894 #endif /* USE_TCL_PACKAGE */
00895 
00896   /* Initialize binds and traces */
00897   init_bind();
00898   init_traces();
00899 
00900   /* Add new commands */
00901   add_tcl_commands(tcluser_cmds);
00902   add_tcl_commands(tcldcc_cmds);
00903   add_tcl_commands(tclmisc_cmds);
00904 #ifdef USE_TCL_OBJ
00905   add_tcl_objcommands(tclmisc_objcmds);
00906 #endif
00907   add_tcl_commands(tcldns_cmds);
00908 }

Here is the call graph for this function:

Here is the caller graph for this function:

int init_threaddata ( int  mainthread  ) 

Definition at line 735 of file tcl.c.

References threaddata::blocktime, increase_socks_max, threaddata::mainloopfunc, threaddata::mainthread, threaddata::MAXSOCKS, NULL, tclthreadmainloop(), and threaddata().

Referenced by main().

00736 {
00737   struct threaddata *td = threaddata();
00738 /* Nested evaluation (vwait/update) of the event loop only
00739  * processes Tcl events (after/fileevent) for now. Using
00740  * eggdrops mainloop() requires caution regarding reentrance.
00741  * (check_tcl_* -> Tcl_Eval() -> mainloop() -> check_tcl_* etc.)
00742  */
00743 /* td->mainloopfunc = mainthread ? mainloop : tclthreadmainloop; */
00744   td->mainloopfunc = tclthreadmainloop;
00745   td->socklist = NULL;
00746   td->mainthread = mainthread;
00747   td->blocktime.tv_sec = 1;
00748   td->blocktime.tv_usec = 0;
00749   td->MAXSOCKS = 0;
00750   increase_socks_max();
00751   return 0;
00752 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_traces (  )  [static]

Definition at line 572 of file tcl.c.

References add_tcl_coups, add_tcl_ints, and add_tcl_strings.

Referenced by init_tcl().

Here is the caller graph for this function:

int ( (int(*)(const char *))  global[149]  ) 

Definition at line 934 of file tcl.c.

References EGG_CONST, file_readable, interp, LOG_MISC, NULL, and putlog.

00935 {
00936   int code;
00937   EGG_CONST char *result;
00938 #ifdef USE_TCL_ENCODING
00939   Tcl_DString dstr;
00940 #endif
00941 
00942   if (!file_readable(fname))
00943     return 0;
00944 
00945   code = Tcl_EvalFile(interp, fname);
00946   result = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY);
00947 
00948 #ifdef USE_TCL_ENCODING
00949   /* properly convert string to system encoding. */
00950   Tcl_DStringInit(&dstr);
00951   Tcl_UtfToExternalDString(NULL, result, -1, &dstr);
00952   result = Tcl_DStringValue(&dstr);
00953 #endif
00954 
00955   if (code != TCL_OK) {
00956     putlog(LOG_MISC, "*", "Tcl error in file '%s':", fname);
00957     putlog(LOG_MISC, "*", "%s", result);
00958     code = 0; /* JJM: refactored to remove premature return */
00959   } else {
00960     /* Refresh internal variables */
00961     code = 1;
00962   }
00963 
00964 #ifdef USE_TCL_ENCODING
00965   Tcl_DStringFree(&dstr);
00966 #endif
00967 
00968   return code;
00969 }

int(*) int ( global  [283]  ) 
int(*) int ( global  [284]  ) 
int(*) int ( global  [258]  ) 
int(*) int ( global  [227]  )  [pure virtual]
int(*) int ( global  [225]  )  [pure virtual]
int(*) int ( global  [226]  )  [pure virtual]
int(*) int ( global  [244]  )  [pure virtual]
int int int int(*)(*)(*) int(*) int ( global  [106]  ) 
Type Constraints
int int int int(*)(*)(*) int ( global  [105]  ) 
int int int int(*)(*) int ( global  [104]  ) 
int int int int(*) int ( global  [102]  ) 
Type Constraints
void kill_tcl (  ) 

Definition at line 910 of file tcl.c.

References interp, kill_bind(), nfree, rem_tcl_coups, rem_tcl_ints, and rem_tcl_strings.

Referenced by mainloop().

00911 {
00912 #ifdef REPLACE_NOTIFIER
00913   tclevent_t *ne, *e = tclevents;
00914 
00915   while (e) {
00916     ne = e->next;
00917     e->callback(e->context, e->script, -1, "", 1);
00918     nfree(e);
00919     e = ne;
00920   }
00921 #endif
00922   rem_tcl_coups(def_tcl_coups);
00923   rem_tcl_strings(def_tcl_strings);
00924   rem_tcl_ints(def_tcl_ints);
00925   kill_bind();
00926   Tcl_DeleteInterp(interp);
00927 }

Here is the call graph for this function:

Here is the caller graph for this function:

void rem_cd_tcl_cmds ( cd_tcl_cmd table  ) 

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 }

Tcl_Interp* Tcl_CreateInterp (  ) 

Referenced by init_tcl().

Here is the caller graph for this function:

static char* tcl_eggcouplet ( ClientData  cdata,
Tcl_Interp irp,
char *  name1,
char *  name2,
int  flags 
) [static]

Definition at line 141 of file tcl.c.

References egg_snprintf, interp, coupletinfo::left, NULL, and coupletinfo::right.

Referenced by void().

00144 {
00145   char *s, s1[41];
00146   coupletinfo *cp = (coupletinfo *) cdata;
00147 
00148   if (flags & (TCL_TRACE_READS | TCL_TRACE_UNSETS)) {
00149     egg_snprintf(s1, sizeof s1, "%d:%d", *(cp->left), *(cp->right));
00150     Tcl_SetVar2(interp, name1, name2, s1, TCL_GLOBAL_ONLY);
00151     if (flags & TCL_TRACE_UNSETS)
00152       Tcl_TraceVar(interp, name1,
00153                    TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
00154                    tcl_eggcouplet, cdata);
00155   } else {                        /* writes */
00156     s = (char *) Tcl_GetVar2(interp, name1, name2, 0);
00157     if (s != NULL) {
00158       int nr1, nr2;
00159 
00160       nr1 = nr2 = 0;
00161 
00162       if (strlen(s) > 40)
00163         s[40] = 0;
00164 
00165       sscanf(s, "%d%*c%d", &nr1, &nr2);
00166       *(cp->left) = nr1;
00167       *(cp->right) = nr2;
00168     }
00169   }
00170   return NULL;
00171 }

Here is the caller graph for this function:

static char* tcl_eggint ( ClientData  cdata,
Tcl_Interp irp,
char *  name1,
char *  name2,
int  flags 
) [static]

Definition at line 175 of file tcl.c.

References break_down_flags, build_flags, conmask, default_flags, default_uflags, egg_snprintf, FR_GLOBAL, flag_record::global, init_misc(), interp, LOG_CMDS, LOG_MISC, LOG_MODES, logmodes, masktype, max_logs, max_socks, NULL, oatoi, protect_readonly, intinfo::ro, sanity_check, threaddata(), flag_record::udef_global, userfile_perm, and intinfo::var.

Referenced by void().

00178 {
00179   char *s, s1[40];
00180   long l;
00181   intinfo *ii = (intinfo *) cdata;
00182 
00183   if (flags & (TCL_TRACE_READS | TCL_TRACE_UNSETS)) {
00184     /* Special cases */
00185     if ((int *) ii->var == &conmask)
00186       strcpy(s1, masktype(conmask));
00187     else if ((int *) ii->var == &default_flags) {
00188       struct flag_record fr = { FR_GLOBAL, 0, 0, 0, 0, 0 };
00189       fr.global = default_flags;
00190 
00191       fr.udef_global = default_uflags;
00192       build_flags(s1, &fr, 0);
00193     } else if ((int *) ii->var == &userfile_perm) {
00194       egg_snprintf(s1, sizeof s1, "0%o", userfile_perm);
00195     } else
00196       egg_snprintf(s1, sizeof s1, "%d", *(int *) ii->var);
00197     Tcl_SetVar2(interp, name1, name2, s1, TCL_GLOBAL_ONLY);
00198     if (flags & TCL_TRACE_UNSETS)
00199       Tcl_TraceVar(interp, name1,
00200                    TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
00201                    tcl_eggint, cdata);
00202     return NULL;
00203   } else {                        /* Writes */
00204     s = (char *) Tcl_GetVar2(interp, name1, name2, TCL_GLOBAL_ONLY);
00205     if (s != NULL) {
00206       if ((int *) ii->var == &conmask) {
00207         if (s[0])
00208           conmask = logmodes(s);
00209         else
00210           conmask = LOG_MODES | LOG_MISC | LOG_CMDS;
00211       } else if ((int *) ii->var == &default_flags) {
00212         struct flag_record fr = { FR_GLOBAL, 0, 0, 0, 0, 0 };
00213 
00214         break_down_flags(s, &fr, 0);
00215         default_flags = sanity_check(fr.global);        /* drummer */
00216 
00217         default_uflags = fr.udef_global;
00218       } else if ((int *) ii->var == &userfile_perm) {
00219         int p = oatoi(s);
00220 
00221         if (p <= 0)
00222           return "invalid userfile permissions";
00223         userfile_perm = p;
00224       } else if ((ii->ro == 2) || ((ii->ro == 1) && protect_readonly))
00225         return "read-only variable";
00226       else {
00227         if (Tcl_ExprLong(interp, s, &l) == TCL_ERROR)
00228           return "variable must have integer value";
00229         if ((int *) ii->var == &max_socks) {
00230           if (l < threaddata()->MAXSOCKS)
00231             return "you can't DECREASE max-socks below current usage";
00232           max_socks = l;
00233         } else if ((int *) ii->var == &max_logs) {
00234           if (l < max_logs)
00235             return "you can't DECREASE max-logs";
00236           max_logs = l;
00237           init_misc();
00238         } else
00239           *(ii->var) = (int) l;
00240       }
00241     }
00242     return NULL;
00243   }
00244 }

Here is the call graph for this function:

Here is the caller graph for this function:

static char* tcl_eggstr ( ClientData  cdata,
Tcl_Interp irp,
char *  name1,
char *  name2,
int  flags 
) [static]

Definition at line 248 of file tcl.c.

References botnet_change(), botnetnick, egg_memcpy(), egg_snprintf, firewall, firewallport, strinfo::flags, free, interp, logfile_suffix, logsuffix_change(), malloc, strinfo::max, NULL, protect_readonly, splitc, and strinfo::str.

Referenced by void().

00251 {
00252   char *s;
00253   strinfo *st = (strinfo *) cdata;
00254 
00255   if (flags & (TCL_TRACE_READS | TCL_TRACE_UNSETS)) {
00256     if ((st->str == firewall) && (firewall[0])) {
00257       char s1[127];
00258 
00259       egg_snprintf(s1, sizeof s1, "%s:%d", firewall, firewallport);
00260       Tcl_SetVar2(interp, name1, name2, s1, TCL_GLOBAL_ONLY);
00261     } else
00262       Tcl_SetVar2(interp, name1, name2, st->str, TCL_GLOBAL_ONLY);
00263     if (flags & TCL_TRACE_UNSETS) {
00264       Tcl_TraceVar(interp, name1, TCL_TRACE_READS | TCL_TRACE_WRITES |
00265                    TCL_TRACE_UNSETS, tcl_eggstr, cdata);
00266       if ((st->max <= 0) && (protect_readonly || (st->max == 0)))
00267         return "read-only variable";    /* it won't return the error... */
00268     }
00269     return NULL;
00270   } else {                        /* writes */
00271     if ((st->max <= 0) && (protect_readonly || (st->max == 0))) {
00272       Tcl_SetVar2(interp, name1, name2, st->str, TCL_GLOBAL_ONLY);
00273       return "read-only variable";
00274     }
00275 #ifdef USE_TCL_BYTE_ARRAYS
00276 #  undef malloc
00277 #  undef free
00278     {
00279       Tcl_Obj *obj;
00280       unsigned char *bytes;
00281       int len;
00282 
00283       obj = Tcl_GetVar2Ex(interp, name1, name2, 0);
00284       if (!obj)
00285         return NULL;
00286       len = 0;
00287       bytes = Tcl_GetByteArrayFromObj(obj, &len);
00288       if (!bytes)
00289         return NULL;
00290       s = malloc(len + 1);
00291       egg_memcpy(s, bytes, len);
00292       s[len] = 0;
00293     }
00294 #else
00295     s = (char *) Tcl_GetVar2(interp, name1, name2, 0);
00296 #endif /* USE_TCL_BYTE_ARRAYS */
00297     if (s != NULL) {
00298       if (strlen(s) > abs(st->max))
00299         s[abs(st->max)] = 0;
00300       if (st->str == botnetnick)
00301         botnet_change(s);
00302       else if (st->str == logfile_suffix)
00303         logsuffix_change(s);
00304       else if (st->str == firewall) {
00305         splitc(firewall, s, ':');
00306         if (!firewall[0])
00307           strcpy(firewall, s);
00308         else
00309           firewallport = atoi(s);
00310       } else
00311         strcpy(st->str, s);
00312       if ((st->flags) && (s[0])) {
00313         if (st->str[strlen(st->str) - 1] != '/')
00314           strcat(st->str, "/");
00315       }
00316 #ifdef USE_TCL_BYTE_ARRAYS
00317       free(s);
00318 #endif /* USE_TCL_BYTE_ARRAYS */
00319     }
00320     return NULL;
00321   }
00322 }

Here is the call graph for this function:

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:

int tclthreadmainloop (  ) 

Definition at line 720 of file tcl.c.

Referenced by init_threaddata().

00720 { return 0; }

Here is the caller graph for this function:

struct threaddata* threaddata (  )  [read]

Definition at line 722 of file tcl.c.

Referenced by expmem_dccutil(), expmem_net(), increase_socks_max(), init_threaddata(), tcl_eggint(), and tell_verbose_status().

00723 {
00724   static struct threaddata tsd;
00725   return &tsd;
00726 }

Here is the caller 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_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_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(*)(char *, char *))  global[148]  ) 
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 }


Variable Documentation

int allow_dk_cmds = 1

Definition at line 77 of file tcl.c.

Referenced by flagrec_ok().

int int int allow_new_telnets

Definition at line 52 of file dcc.c.

Referenced by dcc_telnet_got_ident(), and dcc_telnet_id().

char char char char char char char char bannerfile[]

Definition at line 48 of file tcl.c.

int int int int(*)(*)(*) int(*) int cidr_support

Definition at line 62 of file tcl.c.

Definition at line 88 of file tcl.c.

Referenced by expmem_tcl().

char char char char char char char char char configfile[]

Definition at line 48 of file tcl.c.

Referenced by chanprog(), do_arg(), and tell_verbose_status().

int int int int conmask

Definition at line 66 of file misc.c.

int int int int connect_timeout

Definition at line 44 of file dccutil.c.

int dcc_flood_thr = 3

Definition at line 72 of file tcl.c.

Referenced by detect_dcc_flood().

int int int int(*)(*)(*) int(*) dcc_sanitycheck

Definition at line 60 of file tcl.c.

int debug_output = 0

Definition at line 92 of file tcl.c.

Initial value:
 {
  {"telnet-flood",       &flood_telnet_thr,  &flood_telnet_time},
  {"reserved-portrange", & (*(int *)(global[104])) , & (*(int *)(global[105])) },
  { 0 ,                  0 ,                              0 }
}

Definition at line 563 of file tcl.c.

tcl_ints def_tcl_ints[] [static]

Definition at line 511 of file tcl.c.

Initial value:
 {
  {"botnet-nick",      ((char *)global[123]) ,      9    */ ,                 0},
  {"userfile",         ((char *)global[118]) ,       120,            2 },
  {"motd",            motdfile,       120,            2 },
  {"admin",            ((char *)(global[117])) ,          120,                     0},
  {"help-path",        ((char *)global[121]) ,        120,  1  |  2 },
  {"temp-path",        ((char *)(global[112])) ,        120,  1  |  2 },
  {"text-path",       textdir,        120,  1  |  2 },

  {"mod-path",        moddir,         120,  1  |  2 },

  {"notify-newusers",  ((char *)global[120]) ,     120,                     0},
  {"owner",           owner,          120,            2 },
  {"my-ip",           myip,           120,                     0},
  {"my-hostname",      ((char *)(global[114])) ,       120,                     0},
  {"network",         network,        40,                      0},
  {"whois-fields",    whois_fields,   1024,                    0},
  {"nat-ip",           ((char *)(global[113])) ,          120,                     0},
  {"username",         ((char *)(global[116])) ,        10,                      0},
  {"version",         egg_version,    0,                       0},
  {"firewall",        firewall,       120,                     0},
  {"config",          configfile,     0,                       0},
  {"telnet-banner",   bannerfile,     120,            2 },
  {"logfile-suffix",  logfile_suffix, 20,                      0},
  {"timestamp-format",log_ts,         32,                      0},
  {"pidfile",         pid_file,       120,            2 },
  { 0 ,               0 ,           0,                       0}
}

Definition at line 482 of file tcl.c.

int int int int(*)(*)(*) int(*) default_uflags

Definition at line 60 of file tcl.c.

int int int int(*)(*)(*) die_on_sighup

Definition at line 58 of file tcl.c.

int int int int(*)(*)(*) die_on_sigterm

Definition at line 58 of file tcl.c.

int int int int(*)(*)(*) int(*) dupwait_timeout

Definition at line 60 of file tcl.c.

int int int int(*)(*)(*) int(*) egg_numver

Definition at line 60 of file tcl.c.

Referenced by greet_new_bot(), init_modules(), main(), patch(), and tell_bottree().

char char char char char char char char egg_version[]

Definition at line 48 of file tcl.c.

int enable_simul = 1

Definition at line 91 of file tcl.c.

char char char firewall[]

Definition at line 48 of file tcl.c.

Referenced by tcl_eggstr(), and tell_settings().

int int int int firewallport

Definition at line 64 of file net.c.

Definition at line 62 of file dcc.c.

Referenced by detect_telnet_flood().

Definition at line 64 of file dcc.c.

Referenced by detect_telnet_flood().

int int int int flood_thr
struct dcc_t* struct global[92] [read]

Definition at line 48 of file tcl.c.

int handlen = 9 */

Definition at line 86 of file tcl.c.

int int int int(*)(*)(*) int(*) identtimeout

Definition at line 60 of file tcl.c.

int(* int)(global[283])) ( global  [205]  )  = 1 [read]

Definition at line 39 of file modules.h.

int int int keep_all_logs

Definition at line 116 of file main.c.

Referenced by check_logsize(), core_secondly(), and putlog().

char char char char char char char char char log_ts[]

Definition at line 48 of file tcl.c.

char char char char char char char char char logfile_suffix[]

Definition at line 48 of file tcl.c.

int int int int(*)(*)(*) max_logs
int int int int(*)(*)(*) max_logsize

Definition at line 58 of file tcl.c.

int max_socks = 100

Definition at line 81 of file tcl.c.

Referenced by increase_socks_max(), tcl_eggint(), and tell_verbose_status().

char char char char char char moddir[]

Definition at line 48 of file tcl.c.

Referenced by tell_settings().

char motdfile[]

Definition at line 48 of file tcl.c.

Referenced by bot_motd(), show_motd(), and tell_settings().

char char char char char char myip[]

Definition at line 48 of file tcl.c.

char char char char char char char network[]

Definition at line 48 of file tcl.c.

Referenced by bot_infoq(), cmd_botinfo(), greet_new_bot(), and help_subst().

int int int int notify_users_at

Definition at line 126 of file main.c.

Referenced by core_secondly().

char char char char char char char owner[]

Definition at line 48 of file tcl.c.

Referenced by isowner(), reaffirm_owners(), and tell_settings().

Definition at line 83 of file tcl.c.

Referenced by detect_telnet_flood().

char char char char char char char char char pid_file[]

Definition at line 48 of file tcl.c.

Referenced by bg_do_detach(), bg_prepare_split(), bg_send_pidfile(), fatal(), and main().

int int int int(*)(*)(*) int(*) protect_telnet

Definition at line 60 of file tcl.c.

int quick_logs = 0

Definition at line 82 of file tcl.c.

Referenced by core_minutely(), core_secondly(), and flushlogs().

int quiet_save = 0

Definition at line 84 of file tcl.c.

Referenced by backup_chanfile(), backup_userfile(), channels_start(), core_secondly(), and write_channels().

int remote_boots = 2

Definition at line 76 of file tcl.c.

int int int int(*)(*)(*) int(*) resolve_timeout

Definition at line 60 of file tcl.c.

Referenced by block_dns_hostbyip(), and block_dns_ipbyhost().

int int int int(*)(*)(*) int(*) share_unlinks

Definition at line 60 of file tcl.c.

int shtime

Definition at line 60 of file misc.c.

Referenced by putlog().

int int int int(*)(*)(*) int(*) sort_users

Definition at line 60 of file tcl.c.

int int int stealth_telnets

Definition at line 54 of file dcc.c.

Referenced by dcc_telnet_got_ident().

int int int int(*)(*)(*) int(*) strict_host

Definition at line 60 of file tcl.c.

Definition at line 91 of file tcl.c.

int strtot = 0

Definition at line 85 of file tcl.c.

Referenced by expmem_tcl(), and void().

int int int int switch_logfiles_at

Definition at line 118 of file main.c.

Referenced by core_secondly().

int int int int tands

Definition at line 43 of file botnet.c.

Tcl_Interp*(* Tcl_Interp)(global[128]))

Definition at line 629 of file tcl.c.

Definition at line 629 of file tcl.c.

Definition at line 629 of file tcl.c.

Definition at line 629 of file tcl.c.

char char char char char char char char char textdir[]

Definition at line 48 of file tcl.c.

Definition at line 56 of file chanprog.c.

int use_console_r = 0

Definition at line 91 of file tcl.c.

int int int use_telnet_banner

Definition at line 55 of file dcc.c.

Referenced by dcc_telnet_got_ident().

int utftot = 0

Definition at line 87 of file tcl.c.

Referenced by expmem_tcl().

Definition at line 57 of file chanprog.c.

char whois_fields[1025] = ""

Definition at line 70 of file tcl.c.


Generated on 7 Sep 2016 for Eggdrop by  doxygen 1.6.1