config.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. /******************************************************************************
  2. * This file is part of TinTin++ *
  3. * *
  4. * Copyright 2004-2019 Igor van den Hoven *
  5. * *
  6. * TinTin++ is free software; you can redistribute it and/or modify *
  7. * it under the terms of the GNU General Public License as published by *
  8. * the Free Software Foundation; either version 3 of the License, or *
  9. * (at your option) any later version. *
  10. * *
  11. * This program is distributed in the hope that it will be useful, *
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  14. * GNU General Public License for more details. *
  15. * *
  16. * *
  17. * You should have received a copy of the GNU General Public License *
  18. * along with TinTin++. If not, see https://www.gnu.org/licenses. *
  19. ******************************************************************************/
  20. /******************************************************************************
  21. * file: config.c - funtions related tintin++ configuration *
  22. * (T)he K(I)cki(N) (T)ickin D(I)kumud Clie(N)t *
  23. * coded by Igor van den Hoven 2004 *
  24. ******************************************************************************/
  25. #include "tintin.h"
  26. DO_COMMAND(do_configure)
  27. {
  28. char arg1[BUFFER_SIZE], arg2[BUFFER_SIZE];
  29. struct listnode *node;
  30. int index;
  31. arg = get_arg_in_braces(ses, arg, arg1, GET_ONE);
  32. arg = sub_arg_in_braces(ses, arg, arg2, GET_ONE, SUB_VAR|SUB_FUN);
  33. if (*arg1 == 0)
  34. {
  35. tintin_header(ses, " CONFIGURATIONS ");
  36. for (index = 0 ; *config_table[index].name != 0 ; index++)
  37. {
  38. node = search_node_list(ses->list[LIST_CONFIG], config_table[index].name);
  39. if (node)
  40. {
  41. tintin_printf2(ses, "[%-14s] [%8s] %s",
  42. node->arg1,
  43. node->arg2,
  44. strcmp(node->arg2, "ON") == 0 ? config_table[index].msg_on : config_table[index].msg_off);
  45. }
  46. }
  47. tintin_header(ses, "");
  48. }
  49. else
  50. {
  51. for (index = 0 ; *config_table[index].name != 0 ; index++)
  52. {
  53. if (is_abbrev(arg1, config_table[index].name))
  54. {
  55. if (config_table[index].config(ses, arg2, index) != NULL)
  56. {
  57. node = search_node_list(ses->list[LIST_CONFIG], config_table[index].name);
  58. if (node)
  59. {
  60. show_message(ses, LIST_CONFIG, "#CONFIG {%s} HAS BEEN SET TO {%s}.", config_table[index].name, node->arg2);
  61. }
  62. }
  63. return ses;
  64. }
  65. }
  66. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG {%s} IS NOT A VALID OPTION.", capitalize(arg1));
  67. }
  68. return ses;
  69. }
  70. DO_CONFIG(config_speedwalk)
  71. {
  72. if (!strcasecmp(arg, "ON"))
  73. {
  74. SET_BIT(ses->flags, SES_FLAG_SPEEDWALK);
  75. }
  76. else if (!strcasecmp(arg, "OFF"))
  77. {
  78. DEL_BIT(ses->flags, SES_FLAG_SPEEDWALK);
  79. }
  80. else
  81. {
  82. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  83. return NULL;
  84. }
  85. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  86. return ses;
  87. }
  88. DO_CONFIG(config_verbatim)
  89. {
  90. if (!strcasecmp(arg, "ON"))
  91. {
  92. SET_BIT(ses->flags, SES_FLAG_VERBATIM);
  93. }
  94. else if (!strcasecmp(arg, "OFF"))
  95. {
  96. DEL_BIT(ses->flags, SES_FLAG_VERBATIM);
  97. }
  98. else
  99. {
  100. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  101. return NULL;
  102. }
  103. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  104. return ses;
  105. }
  106. DO_CONFIG(config_repeatenter)
  107. {
  108. if (!strcasecmp(arg, "ON"))
  109. {
  110. SET_BIT(ses->flags, SES_FLAG_REPEATENTER);
  111. }
  112. else if (!strcasecmp(arg, "OFF"))
  113. {
  114. DEL_BIT(ses->flags, SES_FLAG_REPEATENTER);
  115. }
  116. else
  117. {
  118. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  119. return NULL;
  120. }
  121. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  122. return ses;
  123. }
  124. DO_CONFIG(config_commandcolor)
  125. {
  126. char buf[BUFFER_SIZE];
  127. substitute(ses, arg, buf, SUB_COL);
  128. RESTRING(ses->cmd_color, buf);
  129. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  130. return ses;
  131. }
  132. DO_CONFIG(config_commandecho)
  133. {
  134. if (!strcasecmp(arg, "ON"))
  135. {
  136. SET_BIT(ses->flags, SES_FLAG_ECHOCOMMAND);
  137. }
  138. else if (!strcasecmp(arg, "OFF"))
  139. {
  140. DEL_BIT(ses->flags, SES_FLAG_ECHOCOMMAND);
  141. }
  142. else
  143. {
  144. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  145. return NULL;
  146. }
  147. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  148. return ses;
  149. }
  150. DO_CONFIG(config_verbose)
  151. {
  152. if (!strcasecmp(arg, "ON"))
  153. {
  154. SET_BIT(ses->flags, SES_FLAG_VERBOSE);
  155. }
  156. else if (!strcasecmp(arg, "OFF"))
  157. {
  158. DEL_BIT(ses->flags, SES_FLAG_VERBOSE);
  159. }
  160. else
  161. {
  162. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  163. return NULL;
  164. }
  165. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  166. return ses;
  167. }
  168. DO_CONFIG(config_wordwrap)
  169. {
  170. if (!strcasecmp(arg, "ON"))
  171. {
  172. SET_BIT(ses->flags, SES_FLAG_WORDWRAP);
  173. }
  174. else if (!strcasecmp(arg, "OFF"))
  175. {
  176. DEL_BIT(ses->flags, SES_FLAG_WORDWRAP);
  177. }
  178. else
  179. {
  180. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  181. return NULL;
  182. }
  183. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  184. SET_BIT(gtd->flags, TINTIN_FLAG_RESETBUFFER);
  185. return ses;
  186. }
  187. DO_CONFIG(config_log)
  188. {
  189. if (!strcasecmp(arg, "HTML"))
  190. {
  191. DEL_BIT(ses->flags, SES_FLAG_LOGPLAIN);
  192. SET_BIT(ses->flags, SES_FLAG_LOGHTML);
  193. }
  194. else if (!strcasecmp(arg, "PLAIN"))
  195. {
  196. SET_BIT(ses->flags, SES_FLAG_LOGPLAIN);
  197. DEL_BIT(ses->flags, SES_FLAG_LOGHTML);
  198. }
  199. else if (!strcasecmp(arg, "RAW"))
  200. {
  201. DEL_BIT(ses->flags, SES_FLAG_LOGPLAIN);
  202. DEL_BIT(ses->flags, SES_FLAG_LOGHTML);
  203. }
  204. else
  205. {
  206. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG LOG <HTML|PLAIN|RAW>");
  207. return NULL;
  208. }
  209. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  210. return ses;
  211. }
  212. DO_CONFIG(config_buffersize)
  213. {
  214. if (!is_number(arg))
  215. {
  216. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {BUFFER SIZE} <NUMBER>");
  217. return NULL;
  218. }
  219. if (atoi(arg) < 100 || atoi(arg) > 999999)
  220. {
  221. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG BUFFER: PROVIDE A NUMBER BETWEEN 100 and 999999");
  222. return NULL;
  223. }
  224. init_buffer(ses, atoi(arg));
  225. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  226. return ses;
  227. }
  228. DO_CONFIG(config_scrolllock)
  229. {
  230. if (!strcasecmp(arg, "ON"))
  231. {
  232. SET_BIT(ses->flags, SES_FLAG_SCROLLLOCK);
  233. }
  234. else if (!strcasecmp(arg, "OFF"))
  235. {
  236. DEL_BIT(ses->flags, SES_FLAG_SCROLLLOCK);
  237. }
  238. else
  239. {
  240. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  241. return NULL;
  242. }
  243. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  244. return ses;
  245. }
  246. DO_CONFIG(config_connectretry)
  247. {
  248. if (!is_number(arg))
  249. {
  250. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {CONNECT RETRY} <NUMBER>");
  251. return NULL;
  252. }
  253. gts->connect_retry = atoll(arg) * 1000000LL;
  254. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  255. return ses;
  256. }
  257. DO_CONFIG(config_packetpatch)
  258. {
  259. if (is_abbrev("AUTO", arg))
  260. {
  261. gts->check_output = 0;
  262. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, "AUTO", "", "");
  263. SET_BIT(ses->flags, SES_FLAG_AUTOPATCH);
  264. return ses;
  265. }
  266. if (!is_number(arg))
  267. {
  268. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {PACKET PATCH} <NUMBER>");
  269. return NULL;
  270. }
  271. if (atof(arg) < 0 || atof(arg) > 10)
  272. {
  273. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG PACKET PATCH: PROVIDE A NUMBER BETWEEN 0.00 and 10.00");
  274. return NULL;
  275. }
  276. DEL_BIT(ses->flags, SES_FLAG_AUTOPATCH);
  277. gts->check_output = (unsigned long long) (tintoi(arg) * 1000000ULL);
  278. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  279. return ses;
  280. }
  281. DO_CONFIG(config_historysize)
  282. {
  283. if (!is_number(arg))
  284. {
  285. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {HISTORY SIZE} <NUMBER>");
  286. }
  287. if (atoi(arg) < 0 || atoi(arg) > 9999)
  288. {
  289. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG HISTORY: PROVIDE A NUMBER BETWEEN 0 and 9999");
  290. return NULL;
  291. }
  292. gtd->history_size = atoi(arg);
  293. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  294. return ses;
  295. }
  296. DO_CONFIG(config_tintinchar)
  297. {
  298. gtd->tintin_char = arg[0];
  299. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  300. return ses;
  301. }
  302. DO_CONFIG(config_verbatimchar)
  303. {
  304. gtd->verbatim_char = arg[0];
  305. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  306. return ses;
  307. }
  308. DO_CONFIG(config_repeatchar)
  309. {
  310. gtd->repeat_char = arg[0];
  311. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  312. return ses;
  313. }
  314. DO_CONFIG(config_debugtelnet)
  315. {
  316. if (!strcasecmp(arg, "ON"))
  317. {
  318. SET_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
  319. }
  320. else if (!strcasecmp(arg, "OFF"))
  321. {
  322. DEL_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
  323. }
  324. else
  325. {
  326. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  327. return NULL;
  328. }
  329. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  330. return ses;
  331. }
  332. DO_CONFIG(config_convertmeta)
  333. {
  334. if (!strcasecmp(arg, "ON"))
  335. {
  336. SET_BIT(ses->flags, SES_FLAG_CONVERTMETA);
  337. }
  338. else if (!strcasecmp(arg, "OFF"))
  339. {
  340. DEL_BIT(ses->flags, SES_FLAG_CONVERTMETA);
  341. }
  342. else
  343. {
  344. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  345. return NULL;
  346. }
  347. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  348. return ses;
  349. }
  350. DO_CONFIG(config_loglevel)
  351. {
  352. if (!strcasecmp(arg, "LOW"))
  353. {
  354. SET_BIT(ses->flags, SES_FLAG_LOGLEVEL);
  355. }
  356. else if (!strcasecmp(arg, "HIGH"))
  357. {
  358. DEL_BIT(ses->flags, SES_FLAG_LOGLEVEL);
  359. }
  360. else
  361. {
  362. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <LOW|HIGH>", config_table[index].name);
  363. return NULL;
  364. }
  365. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  366. return ses;
  367. }
  368. DO_CONFIG(config_colorpatch)
  369. {
  370. if (!strcasecmp(arg, "ON"))
  371. {
  372. SET_BIT(ses->flags, SES_FLAG_COLORPATCH);
  373. }
  374. else if (!strcasecmp(arg, "OFF"))
  375. {
  376. DEL_BIT(ses->flags, SES_FLAG_COLORPATCH);
  377. }
  378. else
  379. {
  380. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  381. return NULL;
  382. }
  383. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  384. return ses;
  385. }
  386. DO_CONFIG(config_mccp)
  387. {
  388. if (!strcasecmp(arg, "ON"))
  389. {
  390. SET_BIT(ses->flags, SES_FLAG_MCCP);
  391. }
  392. else if (!strcasecmp(arg, "OFF"))
  393. {
  394. DEL_BIT(ses->flags, SES_FLAG_MCCP);
  395. }
  396. else
  397. {
  398. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  399. return NULL;
  400. }
  401. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  402. return ses;
  403. }
  404. DO_CONFIG(config_autotab)
  405. {
  406. if (!is_number(arg))
  407. {
  408. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {AUTO TAB} <NUMBER>");
  409. return NULL;
  410. }
  411. if (atoi(arg) < 1 || atoi(arg) > 999999)
  412. {
  413. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG BUFFER: PROVIDE A NUMBER BETWEEN 1 and 999999");
  414. return NULL;
  415. }
  416. ses->auto_tab = atoi(arg);
  417. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  418. return ses;
  419. }
  420. DO_CONFIG(config_charset)
  421. {
  422. if (!strcasecmp(arg, "AUTO"))
  423. {
  424. if (strcasestr(gtd->lang, "UTF-8"))
  425. {
  426. strcpy(arg, "UTF-8");
  427. }
  428. else if (strcasestr(gtd->lang, "BIG-5"))
  429. {
  430. strcpy(arg, "BIG-5");
  431. }
  432. else
  433. {
  434. strcpy(arg, "ASCII");
  435. }
  436. }
  437. if (!strcasecmp(arg, "BIG5"))
  438. {
  439. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  440. SET_BIT(ses->flags, SES_FLAG_BIG5);
  441. }
  442. else if (!strcasecmp(arg, "BIG-5"))
  443. {
  444. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  445. SET_BIT(ses->flags, SES_FLAG_BIG5);
  446. }
  447. else if (!strcasecmp(arg, "UTF-8"))
  448. {
  449. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  450. SET_BIT(ses->flags, SES_FLAG_UTF8);
  451. }
  452. else if (!strcasecmp(arg, "ASCII"))
  453. {
  454. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  455. }
  456. else if (!strcasecmp(arg, "BIG2UTF"))
  457. {
  458. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  459. SET_BIT(ses->flags, SES_FLAG_UTF8|SES_FLAG_BIG5TOUTF8);
  460. }
  461. else if (!strcasecmp(arg, "FANSI"))
  462. {
  463. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  464. SET_BIT(ses->flags, SES_FLAG_UTF8|SES_FLAG_FANSITOUTF8);
  465. }
  466. else if (!strcasecmp(arg, "KOI2UTF"))
  467. {
  468. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  469. SET_BIT(ses->flags, SES_FLAG_UTF8|SES_FLAG_KOI8TOUTF8);
  470. }
  471. else
  472. {
  473. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <AUTO|ASCII|BIG-5|FANSI|UTF-8|BIG2UTF|KOI2UTF>", config_table[index].name);
  474. return NULL;
  475. }
  476. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  477. return ses;
  478. }
  479. DO_CONFIG(config_colormode)
  480. {
  481. if (!strcasecmp(arg, "AUTO"))
  482. {
  483. if (strcasestr(gtd->term, "truecolor"))
  484. {
  485. strcpy(arg, "TRUE");
  486. }
  487. else if (!strcasecmp(gtd->term, "xterm") || strcasestr(gtd->term, "256color"))
  488. {
  489. strcpy(arg, "256");
  490. }
  491. else
  492. {
  493. strcpy(arg, "ANSI");
  494. }
  495. }
  496. if (!strcasecmp(arg, "NONE"))
  497. {
  498. strcpy(arg, "NONE");
  499. DEL_BIT(ses->flags, SES_FLAG_ANSICOLOR|SES_FLAG_256COLOR|SES_FLAG_TRUECOLOR);
  500. }
  501. else if (!strcasecmp(arg, "ANSI"))
  502. {
  503. strcpy(arg, "ANSI");
  504. SET_BIT(ses->flags, SES_FLAG_ANSICOLOR);
  505. DEL_BIT(ses->flags, SES_FLAG_256COLOR|SES_FLAG_TRUECOLOR);
  506. }
  507. else if (!strcasecmp(arg, "256"))
  508. {
  509. SET_BIT(ses->flags, SES_FLAG_ANSICOLOR|SES_FLAG_256COLOR);
  510. DEL_BIT(ses->flags, SES_FLAG_TRUECOLOR);
  511. }
  512. else if (!strcasecmp(arg, "TRUE"))
  513. {
  514. strcpy(arg, "TRUE");
  515. SET_BIT(ses->flags, SES_FLAG_ANSICOLOR|SES_FLAG_256COLOR|SES_FLAG_TRUECOLOR);
  516. }
  517. else
  518. {
  519. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <AUTO|NONE|ANSI|256|TRUE>", config_table[index].name);
  520. return NULL;
  521. }
  522. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  523. return ses;
  524. }
  525. DO_CONFIG(config_screenreader)
  526. {
  527. if (!strcasecmp(arg, "ON"))
  528. {
  529. SET_BIT(ses->flags, SES_FLAG_SCREENREADER);
  530. }
  531. else if (!strcasecmp(arg, "OFF"))
  532. {
  533. DEL_BIT(ses->flags, SES_FLAG_SCREENREADER);
  534. }
  535. else
  536. {
  537. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  538. return NULL;
  539. }
  540. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  541. return ses;
  542. }
  543. DO_CONFIG(config_inheritance)
  544. {
  545. if (!strcasecmp(arg, "ON"))
  546. {
  547. SET_BIT(gtd->flags, TINTIN_FLAG_INHERITANCE);
  548. }
  549. else if (!strcasecmp(arg, "OFF"))
  550. {
  551. DEL_BIT(gtd->flags, TINTIN_FLAG_INHERITANCE);
  552. }
  553. else
  554. {
  555. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  556. return NULL;
  557. }
  558. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  559. return ses;
  560. }
  561. DO_CONFIG(config_randomseed)
  562. {
  563. if (!strcasecmp(arg, "AUTO"))
  564. {
  565. strcpy(arg, "AUTO");
  566. seed_rand(ses, utime());
  567. }
  568. else if (is_number(arg))
  569. {
  570. seed_rand(ses, get_number(ses, arg));
  571. }
  572. else
  573. {
  574. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <AUTO|NUMBER>", config_table[index].name);
  575. return NULL;
  576. }
  577. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  578. return ses;
  579. }
  580. DO_CONFIG(config_mousetracking)
  581. {
  582. if (!strcasecmp(arg, "ON"))
  583. {
  584. SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
  585. printf("\e[?1000h\e[?1002h\e[?1004h\e[?1006h");
  586. }
  587. else if (!strcasecmp(arg, "OFF"))
  588. {
  589. DEL_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
  590. printf("\e[?1000l\e[?1002l\e[?1004l\e[?1006l");
  591. }
  592. else
  593. {
  594. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  595. return NULL;
  596. }
  597. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  598. return ses;
  599. }
  600. DO_CONFIG(config_childlock)
  601. {
  602. if (!strcasecmp(arg, "ON"))
  603. {
  604. SET_BIT(gtd->flags, TINTIN_FLAG_CHILDLOCK);
  605. }
  606. else if (!strcasecmp(arg, "OFF"))
  607. {
  608. DEL_BIT(gtd->flags, TINTIN_FLAG_CHILDLOCK);
  609. }
  610. else
  611. {
  612. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  613. return NULL;
  614. }
  615. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  616. return ses;
  617. }