#include "main.h"
#include "modules.h"
#include "tandem.h"
#include "md5/md5.h"
#include <time.h>
#include <sys/stat.h>
Go to the source code of this file.
Functions | |
char ((char *) global[123])[] | |
int | expmem_tclmisc () |
static int | tcl_logfile (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_putlog (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_putcmdlog (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_putxferlog (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_putloglev (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_binds (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_timer (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_utimer (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_killtimer (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_killutimer (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_timers (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_utimers (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_duration (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_unixtime (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_ctime (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_strftime (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_myip (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_rand (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_sendnote (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_dumpfile (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_dccdumpfile (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_backup (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_die (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_loadmodule (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_unloadmodule (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_unames (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_modules (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_loadhelp (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_unloadhelp (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_reloadhelp (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_callevent (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_stripcodes (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_md5 (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_matchaddr (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_matchcidr (ClientData cd, Tcl_Interp *irp, int argc, argv) |
static int | tcl_matchstr (ClientData cd, Tcl_Interp *irp, int argc, argv) |
Variables | |
p_tcl_bind_list | bind_table_list |
tcl_timer_t * | timer |
tcl_timer_t * | utimer |
struct dcc_t *struct | global [92] |
module_entry * | module_list |
int | max_logs |
log_t * | logs |
Tcl_Interp *(* | Tcl_Interp )(global[128])) |
tcl_cmds | tclmisc_objcmds [] |
tcl_cmds | tclmisc_cmds [] |
char | ( | (char *) | global[123] | ) |
int expmem_tclmisc | ( | ) |
Definition at line 59 of file tclmisc.c.
References max_logs, and NULL.
Referenced by debug_mem_to_dcc(), and expected_memory().
00060 { 00061 int i, tot = 0; 00062 00063 for (i = 0; i < max_logs; i++) { 00064 if (logs[i].filename != NULL) { 00065 tot += strlen(logs[i].filename) + 1; 00066 tot += strlen(logs[i].chname) + 1; 00067 } 00068 } 00069 00070 return tot; 00071 }
static int tcl_backup | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 514 of file tclmisc.c.
References BADARGS, call_hook, and HOOK_BACKUP.
00515 { 00516 BADARGS(1, 1, ""); 00517 00518 call_hook(HOOK_BACKUP); 00519 return TCL_OK; 00520 }
static int tcl_binds | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 206 of file tclmisc.c.
References argv, tcl_cmd_b::attributes, BADARGS, build_flags, EGG_CONST, egg_snprintf, find_bind_table, tcl_bind_mask_b::first, tcl_bind_list_b::first, tcl_cmd_b::flags, tcl_bind_mask_b::flags, tcl_bind_list_b::flags, tcl_cmd_b::func_name, tcl_cmd_b::hits, HT_DELETED, irp, tcl_bind_mask_b::mask, tcl_bind_list_b::name, tcl_cmd_b::next, tcl_bind_mask_b::next, tcl_bind_list_b::next, NULL, TBM_DELETED, TC_DELETED, Tcl_Free, and wild_match_per.
00207 { 00208 int matching = 0; 00209 char *g, flg[100], hits[11]; 00210 EGG_CONST char *list[5]; 00211 tcl_bind_list_t *tl, *tl_kind; 00212 tcl_bind_mask_t *tm; 00213 tcl_cmd_t *tc; 00214 00215 BADARGS(1, 2, " ?type/mask?"); 00216 00217 if (argv[1]) 00218 tl_kind = find_bind_table(argv[1]); 00219 else 00220 tl_kind = NULL; 00221 if (!tl_kind && argv[1]) 00222 matching = 1; 00223 for (tl = tl_kind ? tl_kind : bind_table_list; tl; 00224 tl = tl_kind ? 0 : tl->next) { 00225 if (tl->flags & HT_DELETED) 00226 continue; 00227 for (tm = tl->first; tm; tm = tm->next) { 00228 if (tm->flags & TBM_DELETED) 00229 continue; 00230 for (tc = tm->first; tc; tc = tc->next) { 00231 if (tc->attributes & TC_DELETED) 00232 continue; 00233 if (matching && 00234 !wild_match_per(argv[1], tl->name) && 00235 !wild_match_per(argv[1], tm->mask) && 00236 !wild_match_per(argv[1], tc->func_name)) 00237 continue; 00238 build_flags(flg, &(tc->flags), NULL); 00239 egg_snprintf(hits, sizeof hits, "%i", (int) tc->hits); 00240 list[0] = tl->name; 00241 list[1] = flg; 00242 list[2] = tm->mask; 00243 list[3] = hits; 00244 list[4] = tc->func_name; 00245 g = Tcl_Merge(5, list); 00246 Tcl_AppendElement(irp, g); 00247 Tcl_Free((char *) g); 00248 } 00249 } 00250 } 00251 return TCL_OK; 00252 }
static int tcl_callevent | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 639 of file tclmisc.c.
References argv, BADARGS, and check_tcl_event.
00640 { 00641 BADARGS(2, 2, " event"); 00642 00643 check_tcl_event(argv[1]); 00644 return TCL_OK; 00645 }
static int tcl_ctime | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
static int tcl_dccdumpfile | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 495 of file tclmisc.c.
References argv, BADARGS, findidx(), FR_ANYWH, FR_CHAN, FR_GLOBAL, get_user_by_handle, get_user_flagrec, HELP_TEXT, irp, NULL, and tellhelp.
00496 { 00497 int idx, i; 00498 struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0 }; 00499 00500 BADARGS(3, 3, " idx filename"); 00501 00502 i = atoi(argv[1]); 00503 idx = findidx(i); 00504 if (idx < 0) { 00505 Tcl_AppendResult(irp, "illegal idx", NULL); 00506 return TCL_ERROR; 00507 } 00508 get_user_flagrec(get_user_by_handle(userlist, dcc[idx].nick), &fr, NULL); 00509 00510 tellhelp(idx, argv[2], &fr, HELP_TEXT); 00511 return TCL_OK; 00512 }
static int tcl_die | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 522 of file tclmisc.c.
References argc, argv, BADARGS, egg_snprintf, kill_bot, quit_msg, and strncpyz.
00523 { 00524 char s[1024]; 00525 00526 BADARGS(1, 2, " ?reason?"); 00527 00528 if (argc == 2) { 00529 egg_snprintf(s, sizeof s, "BOT SHUTDOWN (%s)", argv[1]); 00530 strncpyz(quit_msg, argv[1], 1024); 00531 } else { 00532 strncpyz(s, "BOT SHUTDOWN (No reason)", sizeof s); 00533 quit_msg[0] = 0; 00534 } 00535 kill_bot(s, quit_msg[0] ? quit_msg : "EXIT"); 00536 return TCL_OK; 00537 }
static int tcl_dumpfile | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 482 of file tclmisc.c.
References argv, BADARGS, FR_CHAN, FR_GLOBAL, get_user_by_nick(), get_user_flagrec, HELP_TEXT, NICKLEN, NULL, showhelp, and strncpyz.
00483 { 00484 char nick[NICKLEN]; 00485 struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 }; 00486 00487 BADARGS(3, 3, " nickname filename"); 00488 00489 strncpyz(nick, argv[1], sizeof nick); 00490 get_user_flagrec(get_user_by_nick(nick), &fr, NULL); 00491 showhelp(argv[1], argv[2], &fr, HELP_TEXT); 00492 return TCL_OK; 00493 }
static int tcl_duration | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 336 of file tclmisc.c.
References argv, BADARGS, irp, and NULL.
00337 { 00338 char s[70]; 00339 unsigned long sec, tmp; 00340 00341 BADARGS(2, 2, " seconds"); 00342 00343 if (atol(argv[1]) <= 0) { 00344 Tcl_AppendResult(irp, "0 seconds", NULL); 00345 return TCL_OK; 00346 } 00347 sec = atol(argv[1]); 00348 00349 s[0] = 0; 00350 if (sec >= 31536000) { 00351 tmp = (sec / 31536000); 00352 sprintf(s, "%lu year%s ", tmp, (tmp == 1) ? "" : "s"); 00353 sec -= (tmp * 31536000); 00354 } 00355 if (sec >= 604800) { 00356 tmp = (sec / 604800); 00357 sprintf(&s[strlen(s)], "%lu week%s ", tmp, (tmp == 1) ? "" : "s"); 00358 sec -= (tmp * 604800); 00359 } 00360 if (sec >= 86400) { 00361 tmp = (sec / 86400); 00362 sprintf(&s[strlen(s)], "%lu day%s ", tmp, (tmp == 1) ? "" : "s"); 00363 sec -= (tmp * 86400); 00364 } 00365 if (sec >= 3600) { 00366 tmp = (sec / 3600); 00367 sprintf(&s[strlen(s)], "%lu hour%s ", tmp, (tmp == 1) ? "" : "s"); 00368 sec -= (tmp * 3600); 00369 } 00370 if (sec >= 60) { 00371 tmp = (sec / 60); 00372 sprintf(&s[strlen(s)], "%lu minute%s ", tmp, (tmp == 1) ? "" : "s"); 00373 sec -= (tmp * 60); 00374 } 00375 if (sec > 0) { 00376 tmp = (sec); 00377 sprintf(&s[strlen(s)], "%lu second%s", tmp, (tmp == 1) ? "" : "s"); 00378 } 00379 if (strlen(s) > 0 && s[strlen(s) - 1] == ' ') 00380 s[strlen(s) - 1] = 0; 00381 Tcl_AppendResult(irp, s, NULL); 00382 return TCL_OK; 00383 }
static int tcl_killtimer | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 292 of file tclmisc.c.
References argv, BADARGS, irp, NULL, and remove_timer().
00293 { 00294 BADARGS(2, 2, " timerID"); 00295 00296 if (strncmp(argv[1], "timer", 5)) { 00297 Tcl_AppendResult(irp, "argument is not a timerID", NULL); 00298 return TCL_ERROR; 00299 } 00300 if (remove_timer(&timer, atol(&argv[1][5]))) 00301 return TCL_OK; 00302 Tcl_AppendResult(irp, "invalid timerID", NULL); 00303 return TCL_ERROR; 00304 }
static int tcl_killutimer | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 306 of file tclmisc.c.
References argv, BADARGS, irp, NULL, and remove_timer().
00307 { 00308 BADARGS(2, 2, " timerID"); 00309 00310 if (strncmp(argv[1], "timer", 5)) { 00311 Tcl_AppendResult(irp, "argument is not a timerID", NULL); 00312 return TCL_ERROR; 00313 } 00314 if (remove_timer(&utimer, atol(&argv[1][5]))) 00315 return TCL_OK; 00316 Tcl_AppendResult(irp, "invalid timerID", NULL); 00317 return TCL_ERROR; 00318 }
static int tcl_loadhelp | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 615 of file tclmisc.c.
References add_help_reference, argv, and BADARGS.
00616 { 00617 BADARGS(2, 2, " helpfile-name"); 00618 00619 add_help_reference(argv[1]); 00620 return TCL_OK; 00621 }
static int tcl_loadmodule | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 539 of file tclmisc.c.
References argv, BADARGS, irp, LOG_MISC, MOD_ALREADYLOAD, MOD_CANTLOADMOD, module_load, NULL, and putlog.
00540 { 00541 const char *p; 00542 00543 BADARGS(2, 2, " module-name"); 00544 00545 p = module_load(argv[1]); 00546 if (p && strcmp(p, MOD_ALREADYLOAD) && !strcmp(argv[0], "loadmodule")) 00547 putlog(LOG_MISC, "*", "%s %s: %s", MOD_CANTLOADMOD, argv[1], p); 00548 Tcl_AppendResult(irp, p, NULL); 00549 return TCL_OK; 00550 }
static int tcl_logfile | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 78 of file tclmisc.c.
References argc, argv, BADARGS, CHANMETA, log_t::chname, log_t::f, log_t::filename, log_t::flags, interp, LF_EXPIRING, logmodes, log_t::mask, masktype, max_logs, nfree, nmalloc, and NULL.
00079 { 00080 int i; 00081 char s[151]; 00082 00083 BADARGS(1, 4, " ?logModes channel logFile?"); 00084 00085 if (argc == 1) { 00086 /* They just want a list of the logfiles and modes */ 00087 for (i = 0; i < max_logs; i++) 00088 if (logs[i].filename != NULL) { 00089 snprintf(s, sizeof s, "%s %s %s", masktype(logs[i].mask), 00090 logs[i].chname, logs[i].filename); 00091 Tcl_AppendElement(interp, s); 00092 } 00093 return TCL_OK; 00094 } 00095 00096 BADARGS(4, 4, " ?logModes channel logFile?"); 00097 00098 if (*argv[1] && !*argv[2]) { 00099 Tcl_AppendResult(interp, 00100 "log modes set, but no channel specified", NULL); 00101 return TCL_ERROR; 00102 } 00103 if (*argv[2] && !strchr(CHANMETA, *argv[2]) && strcmp(argv[2], "*")) { 00104 Tcl_AppendResult(interp, "invalid channel prefix", NULL); 00105 return TCL_ERROR; 00106 } 00107 if (*argv[2] && strchr(argv[2], ' ')) { 00108 Tcl_AppendResult(interp, "channel names cannot contain spaces", NULL); 00109 return TCL_ERROR; 00110 } 00111 00112 for (i = 0; i < max_logs; i++) 00113 if ((logs[i].filename != NULL) && (!strcmp(logs[i].filename, argv[3]))) { 00114 logs[i].flags &= ~LF_EXPIRING; 00115 logs[i].mask = logmodes(argv[1]); 00116 nfree(logs[i].chname); 00117 logs[i].chname = NULL; 00118 if (!logs[i].mask) { 00119 /* ending logfile */ 00120 nfree(logs[i].filename); 00121 logs[i].filename = NULL; 00122 if (logs[i].f != NULL) { 00123 fclose(logs[i].f); 00124 logs[i].f = NULL; 00125 } 00126 logs[i].flags = 0; 00127 } else { 00128 logs[i].chname = nmalloc(strlen(argv[2]) + 1); 00129 strcpy(logs[i].chname, argv[2]); 00130 } 00131 Tcl_AppendResult(interp, argv[3], NULL); 00132 return TCL_OK; 00133 } 00134 /* Do not add logfiles without any flags to log ++rtc */ 00135 if (!logmodes(argv[1])) { 00136 Tcl_AppendResult(interp, "can't remove \"", argv[3], 00137 "\" from list: no such logfile", NULL); 00138 return TCL_ERROR; 00139 } 00140 for (i = 0; i < max_logs; i++) 00141 if (logs[i].filename == NULL) { 00142 logs[i].flags = 0; 00143 logs[i].mask = logmodes(argv[1]); 00144 logs[i].filename = nmalloc(strlen(argv[3]) + 1); 00145 strcpy(logs[i].filename, argv[3]); 00146 logs[i].chname = nmalloc(strlen(argv[2]) + 1); 00147 strcpy(logs[i].chname, argv[2]); 00148 Tcl_AppendResult(interp, argv[3], NULL); 00149 return TCL_OK; 00150 } 00151 Tcl_AppendResult(interp, "reached max # of logfiles", NULL); 00152 return TCL_ERROR; 00153 }
static int tcl_matchaddr | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
static int tcl_matchcidr | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 737 of file tclmisc.c.
References argv, BADARGS, cidr_match(), and NULL.
00738 { 00739 BADARGS(4, 4, " block address prefix"); 00740 00741 if (cidr_match(argv[1], argv[2], atoi(argv[3]))) 00742 Tcl_AppendResult(irp, "1", NULL); 00743 else 00744 Tcl_AppendResult(irp, "0", NULL); 00745 return TCL_OK; 00746 }
static int tcl_matchstr | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
static int tcl_md5 | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 692 of file tclmisc.c.
References argv, BADARGS, MD5_Final, MD5_Init, MD5_Update, and NULL.
00693 { 00694 #endif /* USE_TCL_OBJ */ 00695 MD5_CTX md5context; 00696 char digest_string[33], *string; 00697 unsigned char digest[16]; 00698 int i, len; 00699 00700 #ifdef USE_TCL_OBJ 00701 if (objc != 2) { 00702 Tcl_WrongNumArgs(irp, 1, objv, "string"); 00703 return TCL_ERROR; 00704 } 00705 # ifdef USE_TCL_BYTE_ARRAYS 00706 string = (char *)Tcl_GetByteArrayFromObj(objv[1], &len); 00707 # else 00708 string = Tcl_GetStringFromObj(objv[1], &len); 00709 # endif /* USE_TCL_BYTE_ARRAYS */ 00710 #else /* USE_TCL_OBJ */ 00711 BADARGS(2, 2, " string"); 00712 00713 string = argv[1]; 00714 len = strlen(argv[1]); 00715 #endif /* USE_TCL_OBJ */ 00716 00717 MD5_Init(&md5context); 00718 MD5_Update(&md5context, (unsigned char *) string, len); 00719 MD5_Final(digest, &md5context); 00720 for (i = 0; i < 16; i++) 00721 sprintf(digest_string + (i * 2), "%.2x", digest[i]); 00722 Tcl_AppendResult(irp, digest_string, NULL); 00723 return TCL_OK; 00724 }
static int tcl_modules | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 580 of file tclmisc.c.
References BADARGS, dependancy_list, EGG_CONST, egg_snprintf, irp, _module_entry::major, _module_entry::minor, _module_entry::name, _dependancy::next, _module_entry::next, and Tcl_Free.
00581 { 00582 int i; 00583 char *p, s[24], s2[24]; 00584 EGG_CONST char *list[100], *list2[2]; 00585 dependancy *dep; 00586 module_entry *current; 00587 00588 BADARGS(1, 1, ""); 00589 00590 for (current = module_list; current; current = current->next) { 00591 list[0] = current->name; 00592 egg_snprintf(s, sizeof s, "%d.%d", current->major, current->minor); 00593 list[1] = s; 00594 i = 2; 00595 for (dep = dependancy_list; dep && (i < 100); dep = dep->next) { 00596 if (dep->needing == current) { 00597 list2[0] = dep->needed->name; 00598 egg_snprintf(s2, sizeof s2, "%d.%d", dep->major, dep->minor); 00599 list2[1] = s2; 00600 list[i] = Tcl_Merge(2, list2); 00601 i++; 00602 } 00603 } 00604 p = Tcl_Merge(i, list); 00605 Tcl_AppendElement(irp, p); 00606 Tcl_Free((char *) p); 00607 while (i > 2) { 00608 i--; 00609 Tcl_Free((char *) list[i]); 00610 } 00611 } 00612 return TCL_OK; 00613 }
static int tcl_myip | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
static int tcl_putcmdlog | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
static int tcl_putlog | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
static int tcl_putloglev | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 188 of file tclmisc.c.
References argv, BADARGS, irp, logmodes, NULL, putlog, and strncpyz.
00189 { 00190 int lev = 0; 00191 char logtext[501]; 00192 00193 BADARGS(4, 4, " level(s) channel text"); 00194 00195 lev = logmodes(argv[1]); 00196 if (!lev) { 00197 Tcl_AppendResult(irp, "No valid log-level given", NULL); 00198 return TCL_ERROR; 00199 } 00200 strncpyz(logtext, argv[3], sizeof logtext); 00201 00202 putlog(lev, argv[2], "%s", logtext); 00203 return TCL_OK; 00204 }
static int tcl_putxferlog | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
static int tcl_rand | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 442 of file tclmisc.c.
References argv, BADARGS, egg_snprintf, irp, NULL, and randint.
00443 { 00444 long i; 00445 unsigned long x; 00446 char s[11]; 00447 00448 BADARGS(2, 2, " limit"); 00449 00450 i = atol(argv[1]); 00451 00452 if (i <= 0) { 00453 Tcl_AppendResult(irp, "random limit must be greater than zero", NULL); 00454 return TCL_ERROR; 00455 } else if (i > RANDOM_MAX) { 00456 Tcl_AppendResult(irp, "random limit must be less than ", RANDOM_MAX, NULL); 00457 return TCL_ERROR; 00458 } 00459 00460 x = randint(i); 00461 00462 egg_snprintf(s, sizeof s, "%lu", x); 00463 00464 Tcl_AppendResult(irp, s, NULL); 00465 return TCL_OK; 00466 }
static int tcl_reloadhelp | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 631 of file tclmisc.c.
References BADARGS, and reload_help_data().
00632 { 00633 BADARGS(1, 1, ""); 00634 00635 reload_help_data(); 00636 return TCL_OK; 00637 }
static int tcl_sendnote | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 468 of file tclmisc.c.
References add_note, argv, BADARGS, egg_snprintf, from, irp, NOTENAMELEN, NULL, and strncpyz.
00469 { 00470 char s[5], from[NOTENAMELEN + 1], to[NOTENAMELEN + 1], msg[451]; 00471 00472 BADARGS(4, 4, " from to message"); 00473 00474 strncpyz(from, argv[1], sizeof from); 00475 strncpyz(to, argv[2], sizeof to); 00476 strncpyz(msg, argv[3], sizeof msg); 00477 egg_snprintf(s, sizeof s, "%d", add_note(to, from, msg, -1, 0)); 00478 Tcl_AppendResult(irp, s, NULL); 00479 return TCL_OK; 00480 }
static int tcl_strftime | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 410 of file tclmisc.c.
References argc, argv, BADARGS, egg_strftime(), irp, now, NULL, and time_t.
00411 { 00412 char buf[512]; 00413 struct tm *tm1; 00414 time_t t; 00415 00416 BADARGS(2, 3, " format ?time?"); 00417 00418 if (argc == 3) 00419 t = atol(argv[2]); 00420 else 00421 t = now; 00422 tm1 = localtime(&t); 00423 if (egg_strftime(buf, sizeof(buf) - 1, argv[1], tm1)) { 00424 Tcl_AppendResult(irp, buf, NULL); 00425 return TCL_OK; 00426 } 00427 Tcl_AppendResult(irp, " error with strftime", NULL); 00428 return TCL_ERROR; 00429 }
static int tcl_stripcodes | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 647 of file tclmisc.c.
References argv, BADARGS, irp, NULL, STRIP_ANSI, STRIP_BELLS, STRIP_BOLD, STRIP_COLOR, strip_mirc_codes, STRIP_REV, and STRIP_UNDER.
00648 { 00649 int flags = 0; 00650 char *p; 00651 00652 BADARGS(3, 3, " strip-flags string"); 00653 00654 for (p = argv[1]; *p; p++) 00655 switch (*p) { 00656 case 'a': 00657 flags |= STRIP_ANSI; 00658 break; 00659 case 'b': 00660 flags |= STRIP_BOLD; 00661 break; 00662 case 'c': 00663 flags |= STRIP_COLOR; 00664 break; 00665 case 'g': 00666 flags |= STRIP_BELLS; 00667 break; 00668 case 'r': 00669 flags |= STRIP_REV; 00670 break; 00671 case 'u': 00672 flags |= STRIP_UNDER; 00673 break; 00674 default: 00675 Tcl_AppendResult(irp, "Invalid strip-flags: ", argv[1], NULL); 00676 return TCL_ERROR; 00677 } 00678 00679 strip_mirc_codes(flags, argv[2]); 00680 Tcl_AppendResult(irp, argv[2], NULL); 00681 return TCL_OK; 00682 }
static int tcl_timer | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 254 of file tclmisc.c.
References add_timer(), argv, BADARGS, egg_snprintf, irp, and NULL.
00255 { 00256 unsigned long x; 00257 char s[16]; 00258 00259 BADARGS(3, 3, " minutes command"); 00260 00261 if (atoi(argv[1]) < 0) { 00262 Tcl_AppendResult(irp, "time value must be positive", NULL); 00263 return TCL_ERROR; 00264 } 00265 if (argv[2][0] != '#') { 00266 x = add_timer(&timer, atoi(argv[1]), argv[2], 0L); 00267 egg_snprintf(s, sizeof s, "timer%lu", x); 00268 Tcl_AppendResult(irp, s, NULL); 00269 } 00270 return TCL_OK; 00271 }
static int tcl_timers | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 320 of file tclmisc.c.
References BADARGS, irp, and list_timers().
00321 { 00322 BADARGS(1, 1, ""); 00323 00324 list_timers(irp, timer); 00325 return TCL_OK; 00326 }
static int tcl_unames | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 560 of file tclmisc.c.
00561 { 00562 char *unix_n, *vers_n; 00563 #ifdef HAVE_UNAME 00564 struct utsname un; 00565 00566 if (uname(&un) < 0) { 00567 #endif 00568 unix_n = "*unknown*"; 00569 vers_n = ""; 00570 #ifdef HAVE_UNAME 00571 } else { 00572 unix_n = un.sysname; 00573 vers_n = un.release; 00574 } 00575 #endif 00576 Tcl_AppendResult(irp, unix_n, " ", vers_n, NULL); 00577 return TCL_OK; 00578 }
static int tcl_unixtime | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
static int tcl_unloadhelp | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 623 of file tclmisc.c.
References argv, BADARGS, and rem_help_reference.
00624 { 00625 BADARGS(2, 2, " helpfile-name"); 00626 00627 rem_help_reference(argv[1]); 00628 return TCL_OK; 00629 }
static int tcl_unloadmodule | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 552 of file tclmisc.c.
References argv, BADARGS, botnetnick, irp, module_unload, and NULL.
00553 { 00554 BADARGS(2, 2, " module-name"); 00555 00556 Tcl_AppendResult(irp, module_unload(argv[1], botnetnick), NULL); 00557 return TCL_OK; 00558 }
static int tcl_utimer | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 273 of file tclmisc.c.
References add_timer(), argv, BADARGS, egg_snprintf, irp, and NULL.
00274 { 00275 unsigned long x; 00276 char s[16]; 00277 00278 BADARGS(3, 3, " seconds command"); 00279 00280 if (atoi(argv[1]) < 0) { 00281 Tcl_AppendResult(irp, "time value must be positive", NULL); 00282 return TCL_ERROR; 00283 } 00284 if (argv[2][0] != '#') { 00285 x = add_timer(&utimer, atoi(argv[1]), argv[2], 0L); 00286 egg_snprintf(s, sizeof s, "timer%lu", x); 00287 Tcl_AppendResult(irp, s, NULL); 00288 } 00289 return TCL_OK; 00290 }
static int tcl_utimers | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
argv | ||||
) | [static] |
Definition at line 328 of file tclmisc.c.
References BADARGS, irp, and list_timers().
00329 { 00330 BADARGS(1, 1, ""); 00331 00332 list_timers(irp, utimer); 00333 return TCL_OK; 00334 }
Tcl_Interp*(* Tcl_Interp)(global[128])) |
Definition at line 56 of file chanprog.c.
Referenced by answer_local_whom(), and dump_links().
Definition at line 57 of file chanprog.c.