23
23
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
27
#include "modules.h"
29
28
#include "tandem.h"
30
29
#include "md5/md5.h"
30
#ifdef TIME_WITH_SYS_TIME
31
# include <sys/time.h>
34
# ifdef HAVE_SYS_TIME_H
35
# include <sys/time.h>
32
42
#include <sys/utsname.h>
35
extern p_tcl_bind_list bind_table_list;
36
extern tcl_timer_t *timer, *utimer;
37
extern struct dcc_t *dcc;
38
extern char origbotname[], botnetnick[], quit_msg[];
39
extern struct userrec *userlist;
41
extern module_entry *module_list;
45
extern p_tcl_bind_list bind_table_list;
46
extern tcl_timer_t *timer, *utimer;
47
extern struct dcc_t *dcc;
48
extern char origbotname[], botnetnick[], quit_msg[];
49
extern struct userrec *userlist;
51
extern module_entry *module_list;
42
52
extern int max_logs;
43
53
extern log_t *logs;
44
54
extern Tcl_Interp *interp;
68
78
BADARGS(1, 4, " ?logModes channel logFile?");
70
81
/* They just want a list of the logfiles and modes */
71
82
for (i = 0; i < max_logs; i++)
72
83
if (logs[i].filename != NULL) {
73
strcpy(s, masktype(logs[i].mask));
75
strcat(s, logs[i].chname);
77
strcat(s, logs[i].filename);
78
Tcl_AppendElement(interp, s);
84
strcpy(s, masktype(logs[i].mask));
86
strcat(s, logs[i].chname);
88
strcat(s, logs[i].filename);
89
Tcl_AppendElement(interp, s);
82
94
BADARGS(4, 4, " ?logModes channel logFile?");
83
96
for (i = 0; i < max_logs; i++)
84
97
if ((logs[i].filename != NULL) && (!strcmp(logs[i].filename, argv[3]))) {
85
98
logs[i].flags &= ~LF_EXPIRING;
159
175
char logtext[501];
161
177
BADARGS(4, 4, " level channel text");
162
179
lev = logmodes(argv[1]);
164
181
Tcl_AppendResult(irp, "No valid log-level given", NULL);
165
182
return TCL_ERROR;
167
184
strncpyz(logtext, argv[3], sizeof logtext);
168
186
putlog(lev, argv[2], "%s", logtext);
172
190
static int tcl_binds STDVAR
174
tcl_bind_list_t *tl, *tl_kind;
177
char *list[5], *g, flg[100], hits[11];
193
char *g, flg[100], hits[11];
194
EGG_CONST char *list[5];
195
tcl_bind_list_t *tl, *tl_kind;
180
199
BADARGS(1, 2, " ?type/mask?");
182
202
tl_kind = find_bind_table(argv[1]);
191
211
for (tm = tl->first; tm; tm = tm->next) {
192
212
if (tm->flags & TBM_DELETED)
194
214
for (tc = tm->first; tc; tc = tc->next) {
195
if (tc->attributes & TC_DELETED)
215
if (tc->attributes & TC_DELETED)
198
!wild_match(argv[1], tl->name) &&
199
!wild_match(argv[1], tm->mask) &&
200
!wild_match(argv[1], tc->func_name))
218
!wild_match_per(argv[1], tl->name) &&
219
!wild_match_per(argv[1], tm->mask) &&
220
!wild_match_per(argv[1], tc->func_name))
202
build_flags(flg, &(tc->flags), NULL);
222
build_flags(flg, &(tc->flags), NULL);
203
223
egg_snprintf(hits, sizeof hits, "%i", (int) tc->hits);
204
224
list[0] = tl->name;
581
632
static int tcl_md5 STDVAR
634
#endif /* USE_TCL_OBJ */
585
636
char digest_string[33], *string;
586
637
unsigned char digest[16];
589
#if (TCL_MAJOR_VERSION >= 8)
591
642
Tcl_WrongNumArgs(irp, 1, objv, "string");
592
643
return TCL_ERROR;
595
#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 1)
645
# ifdef USE_TCL_BYTE_ARRAYS
646
string = (unsigned char *)Tcl_GetByteArrayFromObj(objv[1], &len);
596
648
string = Tcl_GetStringFromObj(objv[1], &len);
598
string = Tcl_GetByteArrayFromObj(objv[1], &len);
649
# endif /* USE_TCL_BYTE_ARRAYS */
650
#else /* USE_TCL_OBJ */
602
651
BADARGS(2, 2, " string");
603
653
string = argv[1];
604
654
len = strlen(argv[1]);
655
#endif /* USE_TCL_OBJ */
607
657
MD5_Init(&md5context);
608
MD5_Update(&md5context, (unsigned char *)string, len);
658
MD5_Update(&md5context, (unsigned char *) string, len);
609
659
MD5_Final(digest, &md5context);
611
sprintf(digest_string + (i*2), "%.2x", digest[i]);
660
for (i = 0; i < 16; i++)
661
sprintf(digest_string + (i * 2), "%.2x", digest[i]);
612
662
Tcl_AppendResult(irp, digest_string, NULL);
616
tcl_cmds tclmisc_objcmds[] =
618
#if (TCL_MAJOR_VERSION >= 8)
666
tcl_cmds tclmisc_objcmds[] = {
669
#endif /* USE_TCL_OBJ */
624
tcl_cmds tclmisc_cmds[] =
673
tcl_cmds tclmisc_cmds[] = {
626
674
{"logfile", tcl_logfile},
627
{"putlog", tcl_putlog},
628
{"putcmdlog", tcl_putcmdlog},
629
{"putxferlog", tcl_putxferlog},
630
{"putloglev", tcl_putloglev},
631
{"timer", tcl_timer},
632
{"utimer", tcl_utimer},
633
{"killtimer", tcl_killtimer},
634
{"killutimer", tcl_killutimer},
635
{"timers", tcl_timers},
636
{"utimers", tcl_utimers},
637
{"unixtime", tcl_unixtime},
638
{"strftime", tcl_strftime},
639
{"ctime", tcl_ctime},
642
{"sendnote", tcl_sendnote},
643
{"dumpfile", tcl_dumpfile},
644
{"dccdumpfile", tcl_dccdumpfile},
645
{"backup", tcl_backup},
648
{"unames", tcl_unames},
649
{"unloadmodule", tcl_unloadmodule},
650
{"loadmodule", tcl_loadmodule},
651
{"checkmodule", tcl_loadmodule},
652
{"modules", tcl_modules},
653
{"loadhelp", tcl_loadhelp},
654
{"unloadhelp", tcl_unloadhelp},
655
{"reloadhelp", tcl_reloadhelp},
656
{"duration", tcl_duration},
657
#if (TCL_MAJOR_VERSION < 8)
660
{"binds", tcl_binds},
661
{"callevent", tcl_callevent},
675
{"putlog", tcl_putlog},
676
{"putcmdlog", tcl_putcmdlog},
677
{"putxferlog", tcl_putxferlog},
678
{"putloglev", tcl_putloglev},
679
{"timer", tcl_timer},
680
{"utimer", tcl_utimer},
681
{"killtimer", tcl_killtimer},
682
{"killutimer", tcl_killutimer},
683
{"timers", tcl_timers},
684
{"utimers", tcl_utimers},
685
{"unixtime", tcl_unixtime},
686
{"strftime", tcl_strftime},
687
{"ctime", tcl_ctime},
690
{"sendnote", tcl_sendnote},
691
{"dumpfile", tcl_dumpfile},
692
{"dccdumpfile", tcl_dccdumpfile},
693
{"backup", tcl_backup},
696
{"unames", tcl_unames},
697
{"unloadmodule", tcl_unloadmodule},
698
{"loadmodule", tcl_loadmodule},
699
{"checkmodule", tcl_loadmodule},
700
{"modules", tcl_modules},
701
{"loadhelp", tcl_loadhelp},
702
{"unloadhelp", tcl_unloadhelp},
703
{"reloadhelp", tcl_reloadhelp},
704
{"duration", tcl_duration},
707
#endif /* USE_TCL_OBJ */
708
{"binds", tcl_binds},
709
{"callevent", tcl_callevent},