tcldcc.c 31 KB

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