tcldcc.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256
  1. /*
  2. * tcldcc.c -- handles:
  3. * Tcl stubs for the dcc commands
  4. *
  5. */
  6. #include "main.h"
  7. #include "tandem.h"
  8. #include "modules.h"
  9. #include "blowfish_conf.h"
  10. #include <sys/stat.h>
  11. extern Tcl_Interp *interp;
  12. extern tcl_timer_t *timer,
  13. *utimer;
  14. extern struct dcc_t *dcc;
  15. extern int dcc_total, backgrd, parties,
  16. do_restart, remote_boots, max_dcc, hub, leaf;
  17. extern char botnetnick[], netpass[], *binname;
  18. extern party_t *party;
  19. extern tand_t *tandbot;
  20. extern time_t now;
  21. /* Traffic stuff. */
  22. extern unsigned long otraffic_irc, otraffic_irc_today, itraffic_irc, itraffic_irc_today, otraffic_bn, otraffic_bn_today, itraffic_bn, itraffic_bn_today, otraffic_dcc, otraffic_dcc_today, itraffic_dcc, itraffic_dcc_today, otraffic_trans, otraffic_trans_today, itraffic_trans, itraffic_trans_today, otraffic_unknown, otraffic_unknown_today, itraffic_unknown, itraffic_unknown_today;
  23. int enable_simul = 0;
  24. static struct portmap *root = NULL;
  25. int expmem_tcldcc(void)
  26. {
  27. int tot = 0;
  28. struct portmap *pmap;
  29. for (pmap = root; pmap; pmap = pmap->next)
  30. tot += sizeof(struct portmap);
  31. return tot;
  32. }
  33. /***********************************************************************/
  34. static int tcl_putdcc STDVAR
  35. {
  36. int i, j;
  37. BADARGS(3, 3, " idx text");
  38. i = atoi(argv[1]);
  39. j = findidx(i);
  40. if (j < 0) {
  41. Tcl_AppendResult(irp, "invalid idx", NULL);
  42. return TCL_ERROR;
  43. }
  44. dumplots(-i, "", argv[2]);
  45. return TCL_OK;
  46. }
  47. /* Allows tcl scripts to send out raw data. Can be used for fast server
  48. * write (idx=0)
  49. *
  50. * usage:
  51. * putdccraw <idx> <size> <rawdata>
  52. * example:
  53. * putdccraw 6 13 "eggdrop rulz\n"
  54. *
  55. * (added by drummer@sophia.jpte.hu)
  56. */
  57. static int tcl_putdccraw STDVAR
  58. {
  59. int i, j = 0, z;
  60. BADARGS(4, 4, " idx size text");
  61. z = atoi(argv[1]);
  62. for (i = 0; i < dcc_total; i++) {
  63. if (!z && !strcmp(dcc[i].nick, "(server)")) {
  64. j = dcc[i].sock;
  65. break;
  66. } else if (dcc[i].sock == z) {
  67. j = dcc[i].sock;
  68. break;
  69. }
  70. }
  71. if (i == dcc_total) {
  72. Tcl_AppendResult(irp, "invalid idx", NULL);
  73. return TCL_ERROR;
  74. }
  75. tputs(j, argv[3], atoi(argv[2]));
  76. return TCL_OK;
  77. }
  78. static int tcl_dccsimul STDVAR
  79. {
  80. BADARGS(3, 3, " idx command");
  81. if (enable_simul) {
  82. int idx = findidx(atoi(argv[1]));
  83. if (idx >= 0 && (dcc[idx].type->flags & DCT_SIMUL)) {
  84. int l = strlen(argv[2]);
  85. if (l > 510) {
  86. l = 510;
  87. argv[2][510] = 0; /* Restrict length of cmd */
  88. }
  89. if (dcc[idx].type && dcc[idx].type->activity) {
  90. dcc[idx].type->activity(idx, argv[2], l);
  91. return TCL_OK;
  92. }
  93. } else
  94. Tcl_AppendResult(irp, "invalid idx", NULL);
  95. } else
  96. Tcl_AppendResult(irp, "simul disabled", NULL);
  97. return TCL_ERROR;
  98. }
  99. static int tcl_dccbroadcast STDVAR
  100. {
  101. char msg[sgrab-110];
  102. BADARGS(2, 2, " message");
  103. strncpyz(msg, argv[1], sizeof msg);
  104. chatout("*** %s\n", msg);
  105. botnet_send_chat(-1, botnetnick, msg);
  106. return TCL_OK;
  107. }
  108. static int tcl_hand2idx STDVAR
  109. {
  110. int i;
  111. char s[11];
  112. BADARGS(2, 2, " nickname");
  113. for (i = 0; i < dcc_total; i++)
  114. if ((dcc[i].type->flags & DCT_SIMUL) &&
  115. !egg_strcasecmp(argv[1], dcc[i].nick)) {
  116. egg_snprintf(s, sizeof s, "%ld", dcc[i].sock);
  117. Tcl_AppendResult(irp, s, NULL);
  118. return TCL_OK;
  119. }
  120. Tcl_AppendResult(irp, "-1", NULL);
  121. return TCL_OK;
  122. }
  123. static int tcl_getchan STDVAR
  124. {
  125. char s[7];
  126. int idx;
  127. BADARGS(2, 2, " idx");
  128. idx = findidx(atoi(argv[1]));
  129. if (idx < 0 ||
  130. (dcc[idx].type != &DCC_CHAT && dcc[idx].type != &DCC_SCRIPT)) {
  131. Tcl_AppendResult(irp, "invalid idx", NULL);
  132. return TCL_ERROR;
  133. }
  134. if (dcc[idx].type == &DCC_SCRIPT)
  135. egg_snprintf(s, sizeof s, "%d", dcc[idx].u.script->u.chat->channel);
  136. else
  137. egg_snprintf(s, sizeof s, "%d", dcc[idx].u.chat->channel);
  138. Tcl_AppendResult(irp, s, NULL);
  139. return TCL_OK;
  140. }
  141. static int tcl_setchan STDVAR
  142. {
  143. int idx, chan;
  144. module_entry *me;
  145. BADARGS(3, 3, " idx channel");
  146. idx = findidx(atoi(argv[1]));
  147. if (idx < 0 ||
  148. (dcc[idx].type != &DCC_CHAT && dcc[idx].type != &DCC_SCRIPT)) {
  149. Tcl_AppendResult(irp, "invalid idx", NULL);
  150. return TCL_ERROR;
  151. }
  152. if (argv[2][0] < '0' || argv[2][0] > '9') {
  153. if (!strcmp(argv[2], "-1") || !egg_strcasecmp(argv[2], "off"))
  154. chan = (-1);
  155. else {
  156. Tcl_SetVar(irp, "chan", argv[2], 0);
  157. if (Tcl_VarEval(irp, "assoc ", "$chan", NULL) != TCL_OK ||
  158. !interp->result[0]) {
  159. Tcl_AppendResult(irp, "channel name is invalid", NULL);
  160. return TCL_ERROR;
  161. }
  162. chan = atoi(interp->result);
  163. }
  164. } else
  165. chan = atoi(argv[2]);
  166. if ((chan < -1) || (chan > 199999)) {
  167. Tcl_AppendResult(irp, "channel out of range; must be -1 thru 199999",
  168. NULL);
  169. return TCL_ERROR;
  170. }
  171. if (dcc[idx].type == &DCC_SCRIPT)
  172. dcc[idx].u.script->u.chat->channel = chan;
  173. else {
  174. int oldchan = dcc[idx].u.chat->channel;
  175. if (dcc[idx].u.chat->channel >= 0) {
  176. if ((chan >= GLOBAL_CHANS) && (oldchan < GLOBAL_CHANS))
  177. botnet_send_part_idx(idx, "*script*");
  178. check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
  179. dcc[idx].u.chat->channel);
  180. }
  181. dcc[idx].u.chat->channel = chan;
  182. if (chan < GLOBAL_CHANS)
  183. botnet_send_join_idx(idx, oldchan);
  184. check_tcl_chjn(botnetnick, dcc[idx].nick, chan, geticon(idx),
  185. dcc[idx].sock, dcc[idx].host);
  186. }
  187. /* Console autosave. */
  188. if ((me = module_find("console", 0, 0))) {
  189. Function *func = me->funcs;
  190. (func[CONSOLE_DOSTORE]) (idx);
  191. }
  192. return TCL_OK;
  193. }
  194. static int tcl_dccputchan STDVAR
  195. {
  196. int chan;
  197. char msg[sgrab-110];
  198. BADARGS(3, 3, " channel message");
  199. chan = atoi(argv[1]);
  200. if ((chan < 0) || (chan > 199999)) {
  201. Tcl_AppendResult(irp, "channel out of range; must be 0 thru 199999",
  202. NULL);
  203. return TCL_ERROR;
  204. }
  205. strncpyz(msg, argv[2], sizeof msg);
  206. chanout_but(-1, chan, "*** %s\n", argv[2]);
  207. botnet_send_chan(-1, botnetnick, NULL, chan, argv[2]);
  208. check_tcl_bcst(botnetnick, chan, argv[2]);
  209. return TCL_OK;
  210. }
  211. static int tcl_console STDVAR
  212. {
  213. int i, j, pls, arg;
  214. module_entry *me;
  215. BADARGS(2, 4, " idx ?channel? ?console-modes?");
  216. i = findidx(atoi(argv[1]));
  217. if (i < 0 || dcc[i].type != &DCC_CHAT) {
  218. Tcl_AppendResult(irp, "invalid idx", NULL);
  219. return TCL_ERROR;
  220. }
  221. pls = 1;
  222. for (arg = 2; arg < argc; arg++) {
  223. if (argv[arg][0] && ((strchr(CHANMETA, argv[arg][0]) != NULL) ||
  224. (argv[arg][0] == '*'))) {
  225. if ((argv[arg][0] != '*') && (!findchan_by_dname(argv[arg]))) {
  226. /* If we dont find the channel, and it starts with a +... assume it
  227. * should be the console flags to set.
  228. */
  229. if (argv[arg][0]=='+')
  230. goto do_console_flags;
  231. Tcl_AppendResult(irp, "invalid channel", NULL);
  232. return TCL_ERROR;
  233. }
  234. strncpyz(dcc[i].u.chat->con_chan, argv[arg], 81);
  235. } else {
  236. if ((argv[arg][0] != '+') && (argv[arg][0] != '-'))
  237. dcc[i].u.chat->con_flags = 0;
  238. do_console_flags:
  239. for (j = 0; j < strlen(argv[arg]); j++) {
  240. if (argv[arg][j] == '+')
  241. pls = 1;
  242. else if (argv[arg][j] == '-')
  243. pls = (-1);
  244. else {
  245. char s[2];
  246. s[0] = argv[arg][j];
  247. s[1] = 0;
  248. if (pls == 1)
  249. dcc[i].u.chat->con_flags |= logmodes(s);
  250. else
  251. dcc[i].u.chat->con_flags &= ~logmodes(s);
  252. }
  253. }
  254. }
  255. }
  256. Tcl_AppendElement(irp, dcc[i].u.chat->con_chan);
  257. Tcl_AppendElement(irp, masktype(dcc[i].u.chat->con_flags));
  258. /* Console autosave. */
  259. if (argc > 2 && (me = module_find("console", 0, 0))) {
  260. Function *func = me->funcs;
  261. (func[CONSOLE_DOSTORE]) (i);
  262. }
  263. return TCL_OK;
  264. }
  265. static int tcl_strip STDVAR
  266. {
  267. int i, j, pls, arg;
  268. module_entry *me;
  269. BADARGS(2, 4, " idx ?strip-flags?");
  270. i = findidx(atoi(argv[1]));
  271. if (i < 0 || dcc[i].type != &DCC_CHAT) {
  272. Tcl_AppendResult(irp, "invalid idx", NULL);
  273. return TCL_ERROR;
  274. }
  275. pls = 1;
  276. for (arg = 2; arg < argc; arg++) {
  277. if ((argv[arg][0] != '+') && (argv[arg][0] != '-'))
  278. dcc[i].u.chat->strip_flags = 0;
  279. for (j = 0; j < strlen(argv[arg]); j++) {
  280. if (argv[arg][j] == '+')
  281. pls = 1;
  282. else if (argv[arg][j] == '-')
  283. pls = (-1);
  284. else {
  285. char s[2];
  286. s[0] = argv[arg][j];
  287. s[1] = 0;
  288. if (pls == 1)
  289. dcc[i].u.chat->strip_flags |= stripmodes(s);
  290. else
  291. dcc[i].u.chat->strip_flags &= ~stripmodes(s);
  292. }
  293. }
  294. }
  295. Tcl_AppendElement(irp, stripmasktype(dcc[i].u.chat->strip_flags));
  296. /* Console autosave. */
  297. if (argc > 2 && (me = module_find("console", 0, 0))) {
  298. Function *func = me->funcs;
  299. (func[CONSOLE_DOSTORE]) (i);
  300. }
  301. return TCL_OK;
  302. }
  303. static int tcl_echo STDVAR
  304. {
  305. int i;
  306. module_entry *me;
  307. BADARGS(2, 3, " idx ?status?");
  308. i = findidx(atoi(argv[1]));
  309. if (i < 0 || dcc[i].type != &DCC_CHAT) {
  310. Tcl_AppendResult(irp, "invalid idx", NULL);
  311. return TCL_ERROR;
  312. }
  313. if (argc == 3) {
  314. if (atoi(argv[2]))
  315. dcc[i].status |= STAT_ECHO;
  316. else
  317. dcc[i].status &= ~STAT_ECHO;
  318. }
  319. if (dcc[i].status & STAT_ECHO)
  320. Tcl_AppendResult(irp, "1", NULL);
  321. else
  322. Tcl_AppendResult(irp, "0", NULL);
  323. /* Console autosave. */
  324. if (argc > 2 && (me = module_find("console", 0, 0))) {
  325. Function *func = me->funcs;
  326. (func[CONSOLE_DOSTORE]) (i);
  327. }
  328. return TCL_OK;
  329. }
  330. static int tcl_page STDVAR
  331. {
  332. int i;
  333. char x[20];
  334. module_entry *me;
  335. BADARGS(2, 3, " idx ?status?");
  336. i = findidx(atoi(argv[1]));
  337. if (i < 0 || dcc[i].type != &DCC_CHAT) {
  338. Tcl_AppendResult(irp, "invalid idx", NULL);
  339. return TCL_ERROR;
  340. }
  341. if (argc == 3) {
  342. int l = atoi(argv[2]);
  343. if (!l)
  344. dcc[i].status &= ~STAT_PAGE;
  345. else {
  346. dcc[i].status |= STAT_PAGE;
  347. dcc[i].u.chat->max_line = l;
  348. }
  349. }
  350. if (dcc[i].status & STAT_PAGE) {
  351. egg_snprintf(x, sizeof x, "%d", dcc[i].u.chat->max_line);
  352. Tcl_AppendResult(irp, x, NULL);
  353. } else
  354. Tcl_AppendResult(irp, "0", NULL);
  355. /* Console autosave. */
  356. if ((argc > 2) && (me = module_find("console", 0, 0))) {
  357. Function *func = me->funcs;
  358. (func[CONSOLE_DOSTORE]) (i);
  359. }
  360. return TCL_OK;
  361. }
  362. static int tcl_control STDVAR
  363. {
  364. int idx;
  365. void *hold;
  366. BADARGS(3, 3, " idx command");
  367. idx = findidx(atoi(argv[1]));
  368. if (idx < 0) {
  369. Tcl_AppendResult(irp, "invalid idx", NULL);
  370. return TCL_ERROR;
  371. }
  372. if (dcc[idx].type->flags & DCT_CHAT) {
  373. if (dcc[idx].u.chat->channel >= 0) {
  374. chanout_but(idx, dcc[idx].u.chat->channel, "*** %s has gone.\n",
  375. dcc[idx].nick);
  376. check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
  377. dcc[idx].u.chat->channel);
  378. botnet_send_part_idx(idx, "gone");
  379. }
  380. check_tcl_chof(dcc[idx].nick, dcc[idx].sock);
  381. }
  382. hold = dcc[idx].u.other;
  383. dcc[idx].u.script = get_data_ptr(sizeof(struct script_info));
  384. dcc[idx].u.script->u.other = hold;
  385. dcc[idx].u.script->type = dcc[idx].type;
  386. dcc[idx].type = &DCC_SCRIPT;
  387. /* Do not buffer data anymore. All received and stored data is passed
  388. over to the dcc functions from now on. */
  389. sockoptions(dcc[idx].sock, EGG_OPTION_UNSET, SOCK_BUFFER);
  390. strncpyz(dcc[idx].u.script->command, argv[2], 120);
  391. return TCL_OK;
  392. }
  393. static int tcl_valididx STDVAR
  394. {
  395. int idx;
  396. BADARGS(2, 2, " idx");
  397. idx = findidx(atoi(argv[1]));
  398. if (idx < 0 || !(dcc[idx].type->flags & DCT_VALIDIDX))
  399. Tcl_AppendResult(irp, "0", NULL);
  400. else
  401. Tcl_AppendResult(irp, "1", NULL);
  402. return TCL_OK;
  403. }
  404. static int tcl_killdcc STDVAR
  405. {
  406. int idx;
  407. BADARGS(2, 3, " idx ?reason?");
  408. idx = findidx(atoi(argv[1]));
  409. if (idx < 0) {
  410. Tcl_AppendResult(irp, "invalid idx", NULL);
  411. return TCL_ERROR;
  412. }
  413. /* Don't kill terminal socket */
  414. if ((dcc[idx].sock == STDOUT) && !backgrd)
  415. return TCL_OK;
  416. /* Make sure 'whom' info is updated for other bots */
  417. if (dcc[idx].type->flags & DCT_CHAT) {
  418. chanout_but(idx, dcc[idx].u.chat->channel, "*** %s has left the %s%s%s\n",
  419. dcc[idx].nick, dcc[idx].u.chat ? "channel" : "partyline",
  420. argc == 3 ? ": " : "", argc == 3 ? argv[2] : "");
  421. botnet_send_part_idx(idx, argc == 3 ? argv[2] : "");
  422. if ((dcc[idx].u.chat->channel >= 0) &&
  423. (dcc[idx].u.chat->channel < GLOBAL_CHANS))
  424. check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
  425. dcc[idx].u.chat->channel);
  426. check_tcl_chof(dcc[idx].nick, dcc[idx].sock);
  427. /* Notice is sent to the party line, the script can add a reason. */
  428. }
  429. killsock(dcc[idx].sock);
  430. lostdcc(idx);
  431. return TCL_OK;
  432. }
  433. static int tcl_putbot STDVAR
  434. {
  435. int i;
  436. char msg[sgrab-110];
  437. BADARGS(3, 3, " botnick message");
  438. i = nextbot(argv[1]);
  439. if (i < 0) {
  440. Tcl_AppendResult(irp, "bot is not in the botnet", NULL);
  441. return TCL_ERROR;
  442. }
  443. strncpyz(msg, argv[2], sizeof msg);
  444. botnet_send_zapf(i, botnetnick, argv[1], msg);
  445. return TCL_OK;
  446. }
  447. static int tcl_putallbots STDVAR
  448. {
  449. char msg[sgrab-110];
  450. BADARGS(2, 2, " message");
  451. strncpyz(msg, argv[1], sizeof msg);
  452. botnet_send_zapf_broad(-1, botnetnick, NULL, msg);
  453. return TCL_OK;
  454. }
  455. static int tcl_idx2hand STDVAR
  456. {
  457. int idx;
  458. BADARGS(2, 2, " idx");
  459. idx = findidx(atoi(argv[1]));
  460. if (idx < 0) {
  461. Tcl_AppendResult(irp, "invalid idx", NULL);
  462. return TCL_ERROR;
  463. }
  464. Tcl_AppendResult(irp, dcc[idx].nick, NULL);
  465. return TCL_OK;
  466. }
  467. static int tcl_islinked STDVAR
  468. {
  469. int i;
  470. BADARGS(2, 2, " bot");
  471. i = nextbot(argv[1]);
  472. if (i < 0)
  473. Tcl_AppendResult(irp, "0", NULL);
  474. else
  475. Tcl_AppendResult(irp, "1", NULL);
  476. return TCL_OK;
  477. }
  478. static int tcl_randstring STDVAR
  479. {
  480. int length = atoi(argv[1]);
  481. char s[length+1];
  482. BADARGS(2, 2, " length");
  483. if (length) {
  484. make_rand_str(s,length);
  485. Tcl_AppendResult(irp, s, NULL);
  486. } else
  487. Tcl_AppendResult(irp, "", NULL);
  488. return TCL_OK;
  489. }
  490. //This function is simply for the tcl to check if the right binary is being used.
  491. static int tcl_hcheck STDVAR
  492. {
  493. Tcl_AppendResult(irp, "1", NULL);
  494. return TCL_OK;
  495. }
  496. static int tcl_binname STDVAR
  497. {
  498. Tcl_AppendResult(irp, binname, NULL);
  499. return TCL_OK;
  500. }
  501. static int tcl_configend STDVAR
  502. {
  503. Tcl_AppendResult(irp, "1", NULL);
  504. return TCL_OK;
  505. }
  506. static int tcl_esource STDVAR
  507. {
  508. int code, nc, skip = 0, incom = 0, lines = 0, line = 0;
  509. FILE *f;
  510. char *buf, *tptr, templine[2048];
  511. char *temps = NULL, temps2[2048];
  512. char *horeting, check[2048];
  513. struct stat st;
  514. BADARGS(2, 2, " file");
  515. /* Check whether file is readable. */
  516. if ((f = fopen(argv[1], "r")) == NULL)
  517. return 0;
  518. fclose(f);
  519. if (stat(argv[1], &st)) {
  520. fatal("broken file", 0);
  521. }
  522. buf = nmalloc(st.st_size * 2.5);
  523. *buf = 0;
  524. f = fopen(argv[1], "r");
  525. if (!f)
  526. fatal("broken file", 0);
  527. while(fgets(templine, sizeof(templine), f)) {
  528. nc = 0;
  529. if(strchr(templine, '\n')) {
  530. tptr = templine;
  531. while( (tptr = strchr(tptr, '\n')) ) {
  532. nc++;
  533. *tptr++ = 0;
  534. }
  535. }
  536. horeting = decryptit(templine);
  537. temps = (char *) decrypt_string(netpass, horeting);
  538. temps2[0] = '\0';
  539. strcpy(temps2,temps);
  540. nfree(temps);
  541. strcpy(check,temps2);
  542. line++;
  543. if (!strncmp(check,"-ifhub",6) || !strncmp(check,"-ifleaf",7) || !strncmp(check,"-endif",6) || (!strncmp(check,"-else",5) && (skip == 1 || skip == 2)) || !strncmp(check,"/*",2) || !strncmp(check,"*/",2) || !strcmp(check+(strlen(check)-2),"*/") || !strncmp(check,"//",2)) {
  544. /* skip == 1 means hub code is being processed, 2 is leaf code */
  545. if (!strncmp(check,"-",1) && !incom) { //check for changing defines, but not if in comment.
  546. if (!strncmp(check,"-ifhub",6))
  547. skip = 1;
  548. else if (!strncmp(check,"-ifleaf",7))
  549. skip = 2;
  550. else if (!strncmp(check,"-endif",6)) { //end the ifdef
  551. if (skip)
  552. skip = 0;
  553. else {
  554. putlog(LOG_MISC, "*", "Error on line %i -endif with no ifdef!", line);
  555. return 0;
  556. }
  557. }
  558. else if (!strncmp(check,"-else",5)) { //change the ifdef from hub->leaf or leaf->hub
  559. if (skip == 1)
  560. skip = 2;
  561. else if (skip == 2)
  562. skip = 1;
  563. else {
  564. putlog(LOG_MISC, "*", "Error on line %i -else with no ifdef!", line);
  565. return 0;
  566. }
  567. }
  568. }
  569. else { //then it must be a comment!
  570. if (!strncmp(check,"/*",2))
  571. if (!incom)
  572. incom = 1;
  573. else {
  574. putlog(LOG_MISC, "*", "Error on line %i New /* inside a /*", line);
  575. return 0;
  576. }
  577. else if (!strcmp(check+(strlen(check)-2),"*/") || !strncmp(check,"*/",2)) {
  578. if (incom)
  579. incom = 0;
  580. else {
  581. putlog(LOG_MISC, "*", "Error on line %i */ without a /*", line);
  582. return 0;
  583. }
  584. }
  585. //we dont need to check for // because its a 1 line skip, the actual read is an ELSE.
  586. }
  587. check[0] = '\0';
  588. }
  589. else {
  590. if ((((hub && (skip == 1)) || (leaf && (skip == 2))) || (!skip)) && !incom) {
  591. lines++;
  592. strcat(buf, temps2);
  593. while (nc > 0) {
  594. strcat(buf, "\n");
  595. nc--;
  596. }
  597. }
  598. }
  599. }
  600. // putlog(LOG_MISC, "@", "Loading %i lines from tcl", lines);
  601. code = Tcl_Eval(interp, buf);
  602. memset(buf, 0, st.st_size*2.5);
  603. nfree(buf);
  604. return code;
  605. }
  606. static int tcl_bots STDVAR
  607. {
  608. tand_t *bot;
  609. BADARGS(1, 1, "");
  610. for (bot = tandbot; bot; bot = bot->next)
  611. Tcl_AppendElement(irp, bot->bot);
  612. return TCL_OK;
  613. }
  614. static int tcl_botlist STDVAR
  615. {
  616. tand_t *bot;
  617. char *p;
  618. char sh[2], string[20];
  619. #if (((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)) || (TCL_MAJOR_VERSION > 8))
  620. CONST char *list[4];
  621. #else
  622. char *list[4];
  623. #endif
  624. BADARGS(1, 1, "");
  625. sh[1] = 0;
  626. list[3] = sh;
  627. list[2] = string;
  628. for (bot = tandbot; bot; bot = bot->next) {
  629. list[0] = bot->bot;
  630. list[1] = (bot->uplink == (tand_t *) 1) ? botnetnick : bot->uplink->bot;
  631. strncpyz(string, int_to_base10(bot->ver), sizeof string);
  632. sh[0] = bot->share;
  633. p = Tcl_Merge(4, list);
  634. Tcl_AppendElement(irp, p);
  635. Tcl_Free((char *) p);
  636. }
  637. return TCL_OK;
  638. }
  639. /* list of { idx nick host type {other} timestamp}
  640. */
  641. static int tcl_dcclist STDVAR
  642. {
  643. int i;
  644. char idxstr[10];
  645. char timestamp[11];
  646. char *p;
  647. char other[160];
  648. #if (((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)) || (TCL_MAJOR_VERSION > 8))
  649. CONST char *list[6];
  650. #else
  651. char *list[6];
  652. #endif
  653. BADARGS(1, 2, " ?type?");
  654. for (i = 0; i < dcc_total; i++) {
  655. if (argc == 1 ||
  656. ((argc == 2) && (dcc[i].type && !egg_strcasecmp(dcc[i].type->name, argv[1])))) {
  657. egg_snprintf(idxstr, sizeof idxstr, "%ld", dcc[i].sock);
  658. egg_snprintf(timestamp, sizeof timestamp, "%ld", dcc[i].timeval);
  659. if (dcc[i].type && dcc[i].type->display)
  660. dcc[i].type->display(i, other);
  661. else {
  662. egg_snprintf(other, sizeof other, "?:%lX !! ERROR !!",
  663. (long) dcc[i].type);
  664. break;
  665. }
  666. list[0] = idxstr;
  667. list[1] = dcc[i].nick;
  668. list[2] = dcc[i].host;
  669. list[3] = dcc[i].type ? dcc[i].type->name : "*UNKNOWN*";
  670. list[4] = other;
  671. list[5] = timestamp;
  672. p = Tcl_Merge(6, list);
  673. Tcl_AppendElement(irp, p);
  674. Tcl_Free((char *) p);
  675. }
  676. }
  677. return TCL_OK;
  678. }
  679. /* list of { nick bot host flag idletime awaymsg [channel]}
  680. */
  681. static int tcl_whom STDVAR
  682. {
  683. char c[2], idle[11], work[20], *p;
  684. int chan, i;
  685. #if (((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)) || (TCL_MAJOR_VERSION > 8))
  686. CONST char *list[7];
  687. #else
  688. char *list[7];
  689. #endif
  690. BADARGS(2, 2, " chan");
  691. if (argv[1][0] == '*')
  692. chan = -1;
  693. else {
  694. if ((argv[1][0] < '0') || (argv[1][0] > '9')) {
  695. Tcl_SetVar(interp, "chan", argv[1], 0);
  696. if ((Tcl_VarEval(interp, "assoc ", "$chan", NULL) != TCL_OK) ||
  697. !interp->result[0]) {
  698. Tcl_AppendResult(irp, "channel name is invalid", NULL);
  699. return TCL_ERROR;
  700. }
  701. chan = atoi(interp->result);
  702. } else
  703. chan = atoi(argv[1]);
  704. if ((chan < 0) || (chan > 199999)) {
  705. Tcl_AppendResult(irp, "channel out of range; must be 0 thru 199999",
  706. NULL);
  707. return TCL_ERROR;
  708. }
  709. }
  710. for (i = 0; i < dcc_total; i++)
  711. if (dcc[i].type == &DCC_CHAT) {
  712. if (dcc[i].u.chat->channel == chan || chan == -1) {
  713. c[0] = geticon(i);
  714. c[1] = 0;
  715. egg_snprintf(idle, sizeof idle, "%lu", (now - dcc[i].timeval) / 60);
  716. list[0] = dcc[i].nick;
  717. list[1] = botnetnick;
  718. list[2] = dcc[i].host;
  719. list[3] = c;
  720. list[4] = idle;
  721. list[5] = dcc[i].u.chat->away ? dcc[i].u.chat->away : "";
  722. if (chan == -1) {
  723. egg_snprintf(work, sizeof work, "%d", dcc[i].u.chat->channel);
  724. list[6] = work;
  725. }
  726. p = Tcl_Merge((chan == -1) ? 7 : 6, list);
  727. Tcl_AppendElement(irp, p);
  728. Tcl_Free((char *) p);
  729. }
  730. }
  731. for (i = 0; i < parties; i++) {
  732. if (party[i].chan == chan || chan == -1) {
  733. c[0] = party[i].flag;
  734. c[1] = 0;
  735. if (party[i].timer == 0L)
  736. strcpy(idle, "0");
  737. else
  738. egg_snprintf(idle, sizeof idle, "%lu", (now - party[i].timer) / 60);
  739. list[0] = party[i].nick;
  740. list[1] = party[i].bot;
  741. list[2] = party[i].from ? party[i].from : "";
  742. list[3] = c;
  743. list[4] = idle;
  744. list[5] = party[i].status & PLSTAT_AWAY ? party[i].away : "";
  745. if (chan == -1) {
  746. egg_snprintf(work, sizeof work, "%d", party[i].chan);
  747. list[6] = work;
  748. }
  749. p = Tcl_Merge((chan == -1) ? 7 : 6, list);
  750. Tcl_AppendElement(irp, p);
  751. Tcl_Free((char *) p);
  752. }
  753. }
  754. return TCL_OK;
  755. }
  756. static int tcl_dccused STDVAR
  757. {
  758. char s[20];
  759. BADARGS(1, 1, "");
  760. egg_snprintf(s, sizeof s, "%d", dcc_total);
  761. Tcl_AppendResult(irp, s, NULL);
  762. return TCL_OK;
  763. }
  764. static int tcl_getdccidle STDVAR
  765. {
  766. int x, idx;
  767. char s[21];
  768. BADARGS(2, 2, " idx");
  769. idx = findidx(atoi(argv[1]));
  770. if (idx < 0) {
  771. Tcl_AppendResult(irp, "invalid idx", NULL);
  772. return TCL_ERROR;
  773. }
  774. x = (now - dcc[idx].timeval);
  775. egg_snprintf(s, sizeof s, "%d", x);
  776. Tcl_AppendElement(irp, s);
  777. return TCL_OK;
  778. }
  779. static int tcl_getdccaway STDVAR
  780. {
  781. int idx;
  782. BADARGS(2, 2, " idx");
  783. idx = findidx(atol(argv[1]));
  784. if (idx < 0 || dcc[idx].type != &DCC_CHAT) {
  785. Tcl_AppendResult(irp, "invalid idx", NULL);
  786. return TCL_ERROR;
  787. }
  788. if (dcc[idx].u.chat->away == NULL)
  789. return TCL_OK;
  790. Tcl_AppendResult(irp, dcc[idx].u.chat->away, NULL);
  791. return TCL_OK;
  792. }
  793. static int tcl_setdccaway STDVAR
  794. {
  795. int idx;
  796. BADARGS(3, 3, " idx message");
  797. idx = findidx(atol(argv[1]));
  798. if (idx < 0 || dcc[idx].type != &DCC_CHAT) {
  799. Tcl_AppendResult(irp, "invalid idx", NULL);
  800. return TCL_ERROR;
  801. }
  802. if (!argv[2][0]) {
  803. /* un-away */
  804. if (dcc[idx].u.chat->away != NULL)
  805. not_away(idx);
  806. return TCL_OK;
  807. }
  808. /* away */
  809. set_away(idx, argv[2]);
  810. return TCL_OK;
  811. }
  812. static int tcl_link STDVAR
  813. {
  814. int x, i;
  815. char bot[HANDLEN + 1], bot2[HANDLEN + 1];
  816. BADARGS(2, 3, " ?via-bot? bot");
  817. strncpyz(bot, argv[1], sizeof bot);
  818. if (argc == 3) {
  819. x = 1;
  820. strncpyz(bot2, argv[2], sizeof bot2);
  821. i = nextbot(bot);
  822. if (i < 0)
  823. x = 0;
  824. else
  825. botnet_send_link(i, botnetnick, bot, bot2);
  826. } else
  827. x = botlink("", -2, bot);
  828. egg_snprintf(bot, sizeof bot, "%d", x);
  829. Tcl_AppendResult(irp, bot, NULL);
  830. return TCL_OK;
  831. }
  832. static int tcl_unlink STDVAR
  833. {
  834. int i, x;
  835. char bot[HANDLEN + 1];
  836. BADARGS(2, 3, " bot ?comment?");
  837. strncpyz(bot, argv[1], sizeof bot);
  838. i = nextbot(bot);
  839. if (i < 0)
  840. x = 0;
  841. else {
  842. x = 1;
  843. if (!egg_strcasecmp(bot, dcc[i].nick))
  844. x = botunlink(-2, bot, argv[2]);
  845. else
  846. botnet_send_unlink(i, botnetnick, lastbot(bot), bot, argv[2]);
  847. }
  848. egg_snprintf(bot, sizeof bot, "%d", x);
  849. Tcl_AppendResult(irp, bot, NULL);
  850. return TCL_OK;
  851. }
  852. static int tcl_connect STDVAR
  853. {
  854. int i, z, sock;
  855. char s[81];
  856. BADARGS(3, 3, " hostname port");
  857. if (dcc_total == max_dcc) {
  858. Tcl_AppendResult(irp, "out of dcc table space", NULL);
  859. return TCL_ERROR;
  860. }
  861. sock = getsock(0,getprotocol(argv[1]));
  862. if (sock < 0) {
  863. Tcl_AppendResult(irp, MISC_NOFREESOCK, NULL);
  864. return TCL_ERROR;
  865. }
  866. z = open_telnet_raw(sock, argv[1], atoi(argv[2]));
  867. if (z < 0) {
  868. killsock(sock);
  869. if (z == (-2))
  870. strncpyz(s, "DNS lookup failed", sizeof s);
  871. else
  872. neterror(s);
  873. Tcl_AppendResult(irp, s, NULL);
  874. return TCL_ERROR;
  875. }
  876. /* Well well well... it worked! */
  877. i = new_dcc(&DCC_SOCKET, 0);
  878. dcc[i].sock = sock;
  879. dcc[i].port = atoi(argv[2]);
  880. strcpy(dcc[i].nick, "*");
  881. strncpyz(dcc[i].host, argv[1], UHOSTMAX);
  882. egg_snprintf(s, sizeof s, "%d", sock);
  883. Tcl_AppendResult(irp, s, NULL);
  884. return TCL_OK;
  885. }
  886. /* Create a new listening port (or destroy one)
  887. *
  888. * listen <port> bots/all/users [mask]
  889. * listen <port> script <proc> [flag]
  890. * listen <port> off
  891. */
  892. static int tcl_listen STDVAR
  893. {
  894. int i, j, idx = (-1), port, realport;
  895. char s[11];
  896. struct portmap *pmap = NULL, *pold = NULL;
  897. BADARGS(3, 5, " port type ?mask?/?proc ?flag??");
  898. port = realport = atoi(argv[1]);
  899. for (pmap = root; pmap; pold = pmap, pmap = pmap->next)
  900. if (pmap->realport == port) {
  901. port = pmap->mappedto;
  902. break;
  903. }
  904. for (i = 0; i < dcc_total; i++)
  905. if ((dcc[i].type == &DCC_TELNET) && (dcc[i].port == port))
  906. idx = i;
  907. if (!egg_strcasecmp(argv[2], "off")) {
  908. if (pmap) {
  909. if (pold)
  910. pold->next = pmap->next;
  911. else
  912. root = pmap->next;
  913. nfree(pmap);
  914. }
  915. /* Remove */
  916. if (idx < 0) {
  917. Tcl_AppendResult(irp, "no such listen port is open", NULL);
  918. return TCL_ERROR;
  919. }
  920. killsock(dcc[idx].sock);
  921. lostdcc(idx);
  922. return TCL_OK;
  923. }
  924. if (idx < 0) {
  925. /* Make new one */
  926. if (dcc_total >= max_dcc) {
  927. Tcl_AppendResult(irp, "no more DCC slots available", NULL);
  928. return TCL_ERROR;
  929. }
  930. /* Try to grab port */
  931. j = port + 20;
  932. i = (-1);
  933. while (port < j && i < 0) {
  934. i = open_listen(&port);
  935. if (i == -1)
  936. port++;
  937. else if (i == -2)
  938. break;
  939. }
  940. if (i == -1) {
  941. Tcl_AppendResult(irp, "Couldn't grab nearby port", NULL);
  942. return TCL_ERROR;
  943. } else if (i == -2) {
  944. Tcl_AppendResult(irp, "Couldn't assign the requested IP. Please make sure 'my-ip' is set properly.", NULL);
  945. return TCL_ERROR;
  946. }
  947. idx = new_dcc(&DCC_TELNET, 0);
  948. dcc[idx].addr = iptolong(getmyip(0));
  949. dcc[idx].port = port;
  950. dcc[idx].sock = i;
  951. dcc[idx].timeval = now;
  952. }
  953. /* script? */
  954. if (!strcmp(argv[2], "script")) {
  955. strcpy(dcc[idx].nick, "(script)");
  956. if (argc < 4) {
  957. Tcl_AppendResult(irp, "must give proc name for script listen", NULL);
  958. killsock(dcc[idx].sock);
  959. lostdcc(idx);
  960. return TCL_ERROR;
  961. }
  962. if (argc == 5) {
  963. if (strcmp(argv[4], "pub")) {
  964. Tcl_AppendResult(irp, "unknown flag: ", argv[4], ". allowed flags: pub",
  965. NULL);
  966. killsock(dcc[idx].sock);
  967. lostdcc(idx);
  968. return TCL_ERROR;
  969. }
  970. dcc[idx].status = LSTN_PUBLIC;
  971. }
  972. strncpyz(dcc[idx].host, argv[3], UHOSTMAX);
  973. egg_snprintf(s, sizeof s, "%d", port);
  974. Tcl_AppendResult(irp, s, NULL);
  975. return TCL_OK;
  976. }
  977. /* bots/users/all */
  978. if (!strcmp(argv[2], "bots"))
  979. strcpy(dcc[idx].nick, "(bots)");
  980. else if (!strcmp(argv[2], "users"))
  981. strcpy(dcc[idx].nick, "(users)");
  982. else if (!strcmp(argv[2], "all"))
  983. strcpy(dcc[idx].nick, "(telnet)");
  984. if (!dcc[idx].nick[0]) {
  985. Tcl_AppendResult(irp, "illegal listen type: must be one of ",
  986. "bots, users, all, off, script", NULL);
  987. killsock(dcc[idx].sock);
  988. dcc_total--;
  989. return TCL_ERROR;
  990. }
  991. if (argc == 4) {
  992. strncpyz(dcc[idx].host, argv[3], UHOSTMAX);
  993. } else
  994. strcpy(dcc[idx].host, "*");
  995. egg_snprintf(s, sizeof s, "%d", port);
  996. Tcl_AppendResult(irp, s, NULL);
  997. if (!pmap) {
  998. pmap = nmalloc(sizeof(struct portmap));
  999. pmap->next = root;
  1000. root = pmap;
  1001. }
  1002. pmap->realport = realport;
  1003. pmap->mappedto = port;
  1004. putlog(LOG_MISC, "*", "Listening at telnet port %d (%s)", port, argv[2]);
  1005. return TCL_OK;
  1006. }
  1007. static int tcl_boot STDVAR
  1008. {
  1009. char who[NOTENAMELEN + 1];
  1010. int i, ok = 0;
  1011. BADARGS(2, 3, " user@bot ?reason?");
  1012. strncpyz(who, argv[1], sizeof who);
  1013. if (strchr(who, '@') != NULL) {
  1014. char whonick[HANDLEN + 1];
  1015. splitc(whonick, who, '@');
  1016. whonick[HANDLEN] = 0;
  1017. if (!egg_strcasecmp(who, botnetnick))
  1018. strncpyz(who, whonick, sizeof who);
  1019. else if (remote_boots > 0) {
  1020. i = nextbot(who);
  1021. if (i < 0)
  1022. return TCL_OK;
  1023. botnet_send_reject(i, botnetnick, NULL, whonick, who, argv[2] ? argv[2] : "");
  1024. } else {
  1025. return TCL_OK;
  1026. }
  1027. }
  1028. for (i = 0; i < dcc_total; i++)
  1029. if (!ok && (dcc[i].type->flags & DCT_CANBOOT) &&
  1030. !egg_strcasecmp(dcc[i].nick, who)) {
  1031. do_boot(i, botnetnick, argv[2] ? argv[2] : "");
  1032. ok = 1;
  1033. }
  1034. return TCL_OK;
  1035. }
  1036. static int tcl_rehash STDVAR
  1037. {
  1038. BADARGS(1, 1, " ");
  1039. #ifdef HUB
  1040. write_userfile(-1);
  1041. #endif
  1042. putlog(LOG_MISC, "*", USERF_REHASHING);
  1043. do_restart = -2;
  1044. return TCL_OK;
  1045. }
  1046. static int tcl_restart STDVAR
  1047. {
  1048. BADARGS(1, 1, " ");
  1049. if (!backgrd) {
  1050. Tcl_AppendResult(interp, "You can't restart a -n bot", NULL);
  1051. return TCL_ERROR;
  1052. }
  1053. #ifdef HUB
  1054. write_userfile(-1);
  1055. #endif
  1056. putlog(LOG_MISC, "*", MISC_RESTARTING);
  1057. wipe_timers(interp, &utimer);
  1058. wipe_timers(interp, &timer);
  1059. do_restart = -1;
  1060. return TCL_OK;
  1061. }
  1062. static int tcl_traffic STDVAR
  1063. {
  1064. char buf[1024];
  1065. unsigned long out_total_today, out_total;
  1066. unsigned long in_total_today, in_total;
  1067. /* IRC traffic */
  1068. sprintf(buf, "irc %ld %ld %ld %ld", itraffic_irc_today, itraffic_irc +
  1069. itraffic_irc_today, otraffic_irc_today, otraffic_irc + otraffic_irc_today);
  1070. Tcl_AppendElement(irp, buf);
  1071. /* Botnet traffic */
  1072. sprintf(buf, "botnet %ld %ld %ld %ld", itraffic_bn_today, itraffic_bn +
  1073. itraffic_bn_today, otraffic_bn_today, otraffic_bn + otraffic_bn_today);
  1074. Tcl_AppendElement(irp, buf);
  1075. /* Partyline */
  1076. sprintf(buf, "partyline %ld %ld %ld %ld", itraffic_dcc_today, itraffic_dcc +
  1077. itraffic_dcc_today, otraffic_dcc_today, otraffic_dcc + otraffic_dcc_today);
  1078. Tcl_AppendElement(irp, buf);
  1079. /* Transfer */
  1080. sprintf(buf, "transfer %ld %ld %ld %ld", itraffic_trans_today, itraffic_trans +
  1081. itraffic_trans_today, otraffic_trans_today, otraffic_trans + otraffic_trans_today);
  1082. Tcl_AppendElement(irp, buf);
  1083. /* Misc traffic */
  1084. sprintf(buf, "misc %ld %ld %ld %ld", itraffic_unknown_today, itraffic_unknown +
  1085. itraffic_unknown_today, otraffic_unknown_today, otraffic_unknown +
  1086. otraffic_unknown_today);
  1087. Tcl_AppendElement(irp, buf);
  1088. /* Totals */
  1089. in_total_today = itraffic_irc_today + itraffic_bn_today + itraffic_dcc_today +
  1090. itraffic_trans_today + itraffic_unknown_today,
  1091. in_total = in_total_today + itraffic_irc + itraffic_bn + itraffic_dcc +
  1092. itraffic_trans + itraffic_unknown;
  1093. out_total_today = otraffic_irc_today + otraffic_bn_today + otraffic_dcc_today +
  1094. itraffic_trans_today + otraffic_unknown_today,
  1095. out_total = out_total_today + otraffic_irc + otraffic_bn + otraffic_dcc +
  1096. otraffic_trans + otraffic_unknown;
  1097. sprintf(buf, "total %ld %ld %ld %ld", in_total_today, in_total, out_total_today, out_total);
  1098. Tcl_AppendElement(irp, buf);
  1099. return(TCL_OK);
  1100. }
  1101. tcl_cmds tcldcc_cmds[] =
  1102. {
  1103. {"binname", tcl_binname},
  1104. {"putdcc", tcl_putdcc},
  1105. {"putdccraw", tcl_putdccraw},
  1106. {"putidx", tcl_putdcc},
  1107. {"dccsimul", tcl_dccsimul},
  1108. {"dccbroadcast", tcl_dccbroadcast},
  1109. {"hand2idx", tcl_hand2idx},
  1110. {"getchan", tcl_getchan},
  1111. {"setchan", tcl_setchan},
  1112. {"dccputchan", tcl_dccputchan},
  1113. {"console", tcl_console},
  1114. {"strip", tcl_strip},
  1115. {"echo", tcl_echo},
  1116. {"page", tcl_page},
  1117. {"control", tcl_control},
  1118. {"valididx", tcl_valididx},
  1119. {"killdcc", tcl_killdcc},
  1120. {"putbot", tcl_putbot},
  1121. {"putallbots", tcl_putallbots},
  1122. {"idx2hand", tcl_idx2hand},
  1123. {"bots", tcl_bots},
  1124. {"botlist", tcl_botlist},
  1125. {"dcclist", tcl_dcclist},
  1126. {"whom", tcl_whom},
  1127. {"dccused", tcl_dccused},
  1128. {"getdccidle", tcl_getdccidle},
  1129. {"getdccaway", tcl_getdccaway},
  1130. {"setdccaway", tcl_setdccaway},
  1131. {"islinked", tcl_islinked},
  1132. {"hcheck", tcl_hcheck},
  1133. {"randstring", tcl_randstring},
  1134. {"source", tcl_esource},
  1135. {"config_end", tcl_configend},
  1136. {"link", tcl_link},
  1137. {"unlink", tcl_unlink},
  1138. {"connect", tcl_connect},
  1139. {"listen", tcl_listen},
  1140. {"boot", tcl_boot},
  1141. {"rehash", tcl_rehash},
  1142. {"restart", tcl_restart},
  1143. {"traffic", tcl_traffic},
  1144. {NULL, NULL}
  1145. };