| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134 |
- /******************************************************************************
- * This file is part of TinTin++ *
- * *
- * Copyright 2004-2020 Igor van den Hoven *
- * *
- * TinTin++ is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 3 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with TinTin++. If not, see https://www.gnu.org/licenses. *
- ******************************************************************************/
- /******************************************************************************
- * T I N T I N + + *
- * *
- * coded by Igor van den Hoven 2004 *
- ******************************************************************************/
- #include "tintin.h"
- DO_COMMAND(do_configure)
- {
- struct listnode *node;
- int index;
- arg = sub_arg_in_braces(ses, arg, arg1, GET_ONE, SUB_VAR|SUB_FUN);
- arg = sub_arg_in_braces(ses, arg, arg2, GET_ALL, SUB_VAR|SUB_FUN);
- if (*arg1 == 0)
- {
- tintin_header(ses, 80, " CONFIGURATIONS ");
- for (index = 0 ; *config_table[index].name != 0 ; index++)
- {
- node = search_node_list(ses->list[LIST_CONFIG], config_table[index].name);
- if (node)
- {
- strcpy(arg2, "");
- config_table[index].config(ses, arg1, arg2, index);
- tintin_printf2(ses, "[%-14s] [%12s] %s",
- node->arg1,
- arg2,
- strcmp(node->arg2, "OFF") ? config_table[index].msg_on : config_table[index].msg_off);
- }
- }
- tintin_header(ses, 80, "");
- }
- else
- {
- // fixing silly config name
- if (is_abbrev(arg1, "MOUSE TRACKING"))
- {
- str_cpy(&arg1, "MOUSE");
- }
- for (index = 0 ; *config_table[index].name != 0 ; index++)
- {
- if (is_abbrev(arg1, config_table[index].name))
- {
- if (*arg2)
- {
- if (config_table[index].config(ses, arg1, arg2, index) != NULL)
- {
- update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg2, "", "");
- node = search_node_list(ses->list[LIST_CONFIG], config_table[index].name);
- if (node)
- {
- show_message(ses, LIST_CONFIG, "#CONFIG {%s} HAS BEEN SET TO {%s}.", config_table[index].name, node->arg2);
- }
- }
- }
- else
- {
- config_table[index].config(ses, arg1, arg2, index);
- show_message(ses, LIST_CONFIG, "#CONFIG {%s} IS SET TO {%s}.", config_table[index].name, arg2);
- }
- return ses;
- }
- }
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG {%s} IS NOT A VALID OPTION.", capitalize(arg1));
- }
- return ses;
- }
- DO_CONFIG(config_autotab)
- {
- if (*arg2)
- {
- if (!is_number(arg2))
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {AUTO TAB} <NUMBER>");
- return NULL;
- }
- if (atoi(arg2) < 1 || atoi(arg2) > 999999)
- {
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG BUFFER: PROVIDE A NUMBER BETWEEN 1 and 999999");
- return NULL;
- }
- ses->scrollback_tab = atoi(arg2);
- }
- sprintf(arg2, "%d", ses->scrollback_tab);
- return ses;
- }
- DO_CONFIG(config_buffersize)
- {
- if (*arg2)
- {
- if (!is_number(arg2))
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {BUFFER SIZE} <NUMBER>");
- return NULL;
- }
- switch (atoi(arg2))
- {
- case 100:
- case 1000:
- case 10000:
- case 100000:
- case 1000000:
- break;
- default:
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG BUFFER: SIZE MUST BE 100, 1000, 10000, 100000, or 1000000.");
- return NULL;
- }
- init_buffer(ses, atoi(arg2));
- }
- sprintf(arg2, "%d", ses->scroll->size);
- return ses;
- }
- DO_CONFIG(config_charset)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "AUTO"))
- {
- if (strcasestr(gtd->system->lang, "UTF-8"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8);
- }
- else if (strcasestr(gtd->system->lang, "BIG-5"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_BIG5);
- }
- else if (strcasestr(gtd->system->term, "XTERM"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8);
- }
- else
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- }
- }
- else if (is_abbrev(arg2, "ASCII"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- }
- else if (is_abbrev(arg2, "BIG-5"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_BIG5);
- }
- else if (is_abbrev(arg2, "GBK-1"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_GBK1);
- }
- else if (is_abbrev(arg2, "UTF-8"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8);
- }
- else if (is_abbrev(arg2, "BIG5TOUTF8") || is_abbrev(arg2, "BIG2UTF"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8|CHARSET_FLAG_BIG5TOUTF8);
- }
- else if (is_abbrev(arg2, "CP1251TOUTF8"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8|CHARSET_FLAG_CP1251TOUTF8);
- }
- else if (is_abbrev(arg2, "FANSI"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8|CHARSET_FLAG_FANSITOUTF8);
- }
- else if (is_abbrev(arg2, "GBK1TOUTF8"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8|CHARSET_FLAG_GBK1TOUTF8);
- }
- else if (is_abbrev(arg2, "ISO1TOUTF8"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8|CHARSET_FLAG_ISO1TOUTF8);
- }
- else if (is_abbrev(arg2, "ISO2TOUTF8"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8|CHARSET_FLAG_ISO2TOUTF8);
- }
- else if (is_abbrev(arg2, "KOI8TOUTF8"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8|CHARSET_FLAG_KOI8TOUTF8);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <AUTO|ASCII|BIG-5|BIG5TOUTF8|CP1251TOUTF8|FANSI|GBK-1|GBK1TOUTF8|ISO1TOUTF8|ISO2TOUTF8|KOI8TOUTF8|UTF-8>", config_table[index].name);
- return NULL;
- }
- }
- switch (HAS_BIT(ses->charset, CHARSET_FLAG_ALL))
- {
- case CHARSET_FLAG_BIG5:
- strcpy(arg2, "BIG-5");
- break;
- case CHARSET_FLAG_GBK1:
- strcpy(arg2, "GBK-1");
- break;
- case CHARSET_FLAG_UTF8:
- strcpy(arg2, "UTF-8");
- break;
- case CHARSET_FLAG_UTF8|CHARSET_FLAG_BIG5TOUTF8:
- strcpy(arg2, "BIG5TOUTF8");
- break;
- case CHARSET_FLAG_UTF8|CHARSET_FLAG_CP1251TOUTF8:
- strcpy(arg2, "CP1251TOUTF8");
- break;
- case CHARSET_FLAG_UTF8|CHARSET_FLAG_FANSITOUTF8:
- strcpy(arg2, "FANSI");
- break;
- case CHARSET_FLAG_UTF8|CHARSET_FLAG_GBK1TOUTF8:
- strcpy(arg2, "GBK1TOUTF8");
- break;
- case CHARSET_FLAG_UTF8|CHARSET_FLAG_KOI8TOUTF8:
- strcpy(arg2, "KOI8TOUTF8");
- break;
- case CHARSET_FLAG_UTF8|CHARSET_FLAG_ISO1TOUTF8:
- strcpy(arg2, "ISO1TOUTF8");
- break;
- case CHARSET_FLAG_UTF8|CHARSET_FLAG_ISO2TOUTF8:
- strcpy(arg2, "ISO2TOUTF8");
- break;
- default:
- strcpy(arg2, "ASCII");
- break;
- }
- return ses;
- }
- DO_CONFIG(config_childlock)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(gtd->flags, TINTIN_FLAG_CHILDLOCK);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(gtd->flags, TINTIN_FLAG_CHILDLOCK);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(gtd->flags, TINTIN_FLAG_CHILDLOCK) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_colormode)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "NONE") || is_abbrev(arg2, "OFF"))
- {
- ses->color = 0;
- }
- else if (is_abbrev(arg2, "ANSI"))
- {
- ses->color = 16;
- }
- else if (is_abbrev(arg2, "256"))
- {
- ses->color = 256;
- }
- else if (is_abbrev(arg2, "TRUE") || is_abbrev(arg2, "ON") || is_abbrev(arg2, "AUTO"))
- {
- ses->color = 4096;
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF|ANSI|256|TRUE>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, ses->color == 0 ? "OFF" : ses->color == 16 ? "ANSI" : ses->color == 256 ? "256" : "TRUE");
- return ses;
- }
- DO_CONFIG(config_colorpatch)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_COLORPATCH);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_COLORPATCH);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_COLORPATCH) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_commandcolor)
- {
- if (*arg2)
- {
- get_color_names(ses, arg2, arg1);
- RESTRING(ses->cmd_color, arg1);
- }
- convert_meta(ses->cmd_color, arg2, SUB_EOL);
- return ses;
- }
- DO_CONFIG(config_commandecho)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_ECHOCOMMAND);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_ECHOCOMMAND);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_ECHOCOMMAND) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_connectretry)
- {
- if (*arg2)
- {
- if (!is_number(arg2))
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {CONNECT RETRY} <NUMBER>");
- return NULL;
- }
- else if (atof(arg2) < 0 || atof(arg2) > 10000)
- {
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG CONNECT RETRY: PROVIDE A NUMBER BETWEEN 0.0 and 10000.0");
- return NULL;
- }
- gts->connect_retry = atoll(arg2) * 1000000LL;
- }
- sprintf(arg2, "%.1Lf", (long double) gts->connect_retry / 1000000);
- return ses;
- }
- DO_CONFIG(config_convertmeta)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_CONVERTMETA);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_CONVERTMETA);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_CONVERTMETA) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_debugtelnet)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->telopts, TELOPT_FLAG_DEBUG) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_historysize)
- {
- if (*arg2)
- {
- if (!is_number(arg2))
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {HISTORY SIZE} <NUMBER>");
- return NULL;
- }
- if (atoi(arg2) < 0 || atoi(arg2) > 9999)
- {
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG HISTORY: PROVIDE A NUMBER BETWEEN 0 and 9999");
- return NULL;
- }
- gtd->history_size = atoi(arg2);
- }
- sprintf(arg2, "%d", gtd->history_size);
- return ses;
- }
- DO_CONFIG(config_inheritance)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(gtd->flags, TINTIN_FLAG_INHERITANCE);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(gtd->flags, TINTIN_FLAG_INHERITANCE);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(gtd->flags, TINTIN_FLAG_INHERITANCE) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_loglevel)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "LOW"))
- {
- SET_BIT(ses->logmode, LOG_FLAG_LOW);
- }
- else if (is_abbrev(arg2, "HIGH"))
- {
- DEL_BIT(ses->logmode, LOG_FLAG_LOW);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <LOW|HIGH>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->logmode, LOG_FLAG_LOW) ? "LOW" : "HIGH");
- return ses;
- }
- DO_CONFIG(config_logmode)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "HTML"))
- {
- SET_BIT(ses->logmode, LOG_FLAG_HTML);
- DEL_BIT(ses->logmode, LOG_FLAG_PLAIN);
- DEL_BIT(ses->logmode, LOG_FLAG_RAW);
- }
- else if (is_abbrev(arg2, "PLAIN"))
- {
- DEL_BIT(ses->logmode, LOG_FLAG_HTML);
- SET_BIT(ses->logmode, LOG_FLAG_PLAIN);
- DEL_BIT(ses->logmode, LOG_FLAG_RAW);
- }
- else if (is_abbrev(arg2, "RAW"))
- {
- DEL_BIT(ses->logmode, LOG_FLAG_HTML);
- DEL_BIT(ses->logmode, LOG_FLAG_PLAIN);
- SET_BIT(ses->logmode, LOG_FLAG_RAW);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG LOG <HTML|PLAIN|RAW>");
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->logmode, LOG_FLAG_HTML) ? "HTML" : HAS_BIT(ses->logmode, LOG_FLAG_PLAIN) ? "PLAIN" : "RAW");
- return ses;
- }
- DO_CONFIG(config_mccp)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_MCCP);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MCCP);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_MCCP) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_mousetracking)
- {
- if (*arg2)
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEINFO);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEPIXELS);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEPIXELS);
- DEL_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- if (is_member(arg2, "INFO"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_MOUSEINFO);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- }
- if (is_member(arg2, "DEBUG"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- }
- if (is_member(arg2, "ON"))
- {
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- }
- if (is_member(arg2, "PIXELS"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_MOUSEPIXELS);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- }
- if (is_abbrev(arg2, "OFF"))
- {
- if (HAS_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEINFO);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEPIXELS);
- DEL_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout(0, 0, "\e[?1000l\e[?1002l\e[?1004l\e[?1006l\e[?1016l");
- }
- }
- else
- {
- if (HAS_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING))
- {
- if (HAS_BIT(ses->config_flags, CONFIG_FLAG_MOUSEPIXELS))
- {
- print_stdout(0, 0, "\e[?1000h\e[?1002h\e[?1004h\e[?1016h");
- }
- else
- {
- print_stdout(0, 0, "\e[?1000h\e[?1002h\e[?1004h\e[?1006h");
- }
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF|DEBUG|INFO|PIXELS>", config_table[index].name);
- return NULL;
- }
- }
- /*
- if (is_abbrev(arg2, "ON"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEINFO);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEPIXELS);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout(0, 0, "\e[?1000h\e[?1002h\e[?1004h\e[?1006h");
- }
- else if (is_abbrev(arg2, "PIXELS"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEINFO);
- SET_BIT(ses->config_flags, CONFIG_FLAG_MOUSEPIXELS);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
-
- print_stdout(0, 0, "\e[?1000h\e[?1002h\e[?1004h\e[?1016h");
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- if (HAS_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEINFO);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEPIXELS);
- DEL_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout(0, 0, "\e[?1000l\e[?1002l\e[?1004l\e[?1006l");
- }
- }
- else if (is_abbrev(arg2, "DEBUG"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEINFO);
- SET_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout(0, 0, "\e[?1000h\e[?1002h\e[?1004h\e[?1006h");
- }
- else if (is_abbrev(arg2, "DEBUG INFO"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG);
- SET_BIT(ses->config_flags, CONFIG_FLAG_MOUSEINFO);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout(0, 0, "\e[?1000h\e[?1002h\e[?1004h\e[?1006h");
- }
- else if (is_abbrev(arg2, "INFO"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG);
- SET_BIT(ses->config_flags, CONFIG_FLAG_MOUSEINFO);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout(0, 0, "\e[?1000h\e[?1002h\e[?1004h\e[?1006h");
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF|DEBUG|INFO|DEBUG INFO>", config_table[index].name);
- return NULL;
- }
- */
- }
- if (HAS_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING))
- {
- if (!HAS_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG|CONFIG_FLAG_MOUSEINFO|CONFIG_FLAG_MOUSEPIXELS))
- {
- strcpy(arg2, "ON");
- }
- else
- {
- strcpy(arg2, "");
- if (HAS_BIT(ses->config_flags, CONFIG_FLAG_MOUSEPIXELS))
- {
- strcpy(arg2, "PIXELS");
- }
- if (HAS_BIT(ses->config_flags, CONFIG_FLAG_MOUSEDEBUG))
- {
- strcat(arg2, *arg2 ? " DEBUG" : "DEBUG");
- }
- if (HAS_BIT(ses->config_flags, CONFIG_FLAG_MOUSEINFO))
- {
- strcat(arg2, *arg2 ? " INFO" : "INFO");
- }
- }
- }
- else
- {
- strcpy(arg2, "OFF");
- }
- return ses;
- }
- DO_CONFIG(config_packetpatch)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "AUTO PROMPT") || is_abbrev(arg2, "AUTO TELNET") || is_abbrev(arg2, "AUTO OFF"))
- {
- ses->packet_patch = 0;
- SET_BIT(ses->config_flags, CONFIG_FLAG_AUTOPATCH);
- }
- else if (!is_number(arg2))
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {PACKET PATCH} <NUMBER>");
- return NULL;
- }
- else if (atof(arg2) < 0 || atof(arg2) > 10)
- {
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG PACKET PATCH: PROVIDE A NUMBER BETWEEN 0.00 and 10.00");
- return NULL;
- }
- else
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_AUTOPATCH);
- ses->packet_patch = (unsigned long long) (tintoi(arg2) * 1000000ULL);
- }
- }
- if (HAS_BIT(ses->config_flags, CONFIG_FLAG_AUTOPATCH))
- {
- if (ses->list[LIST_PROMPT]->list[0])
- {
- strcpy(arg2, "AUTO PROMPT");
- }
- else if (HAS_BIT(ses->config_flags, CONFIG_FLAG_AUTOPROMPT))
- {
- strcpy(arg2, "AUTO TELNET");
- }
- else
- {
- strcpy(arg2, "AUTO OFF");
- }
- }
- else
- {
- sprintf(arg2, "%4.2Lf", (long double) ses->packet_patch / 1000000);
- }
- return ses;
- }
- DO_CONFIG(config_randomseed)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "AUTO"))
- {
- seed_rand(ses, utime());
- }
- else if (is_number(arg2))
- {
- seed_rand(ses, get_number(ses, arg2));
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <AUTO|NUMBER>", config_table[index].name);
- return NULL;
- }
- }
- sprintf(arg2, "%u", (unsigned int) ses->rand);
- return ses;
- }
- DO_CONFIG(config_repeatchar)
- {
- if (*arg2)
- {
- if (!ispunct((int) arg2[0]))
- {
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG REPEAT CHAR: INVALID CHARACTER {%c}", arg2[0]);
- return NULL;
- }
- gtd->repeat_char = arg2[0];
- arg2[1] = 0;
- }
- sprintf(arg2, "%c", gtd->repeat_char);
- return ses;
- }
- DO_CONFIG(config_repeatenter)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_REPEATENTER);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_REPEATENTER);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_REPEATENTER) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_screenreader)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_SCREENREADER);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_SCREENREADER);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_SCREENREADER) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_scrolllock)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_SCROLLLOCK);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_SCROLLLOCK);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_SCROLLLOCK) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_speedwalk)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_SPEEDWALK);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_SPEEDWALK);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_SPEEDWALK) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_tabwidth)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "AUTO"))
- {
- ses->tab_width = 8;
- }
- else if (!is_number(arg2))
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {TAB WIDTH} <NUMBER>");
- return NULL;
- }
- else if (atof(arg2) < 1 || atof(arg2) > 16)
- {
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG TAB WIDTH: PROVIDE A NUMBER BETWEEN 1 and 16");
- return NULL;
- }
- else
- {
- ses->tab_width = (int) tintoi(arg2);
- }
- }
- sprintf(arg2, "%d", ses->tab_width);
- return ses;
- }
-
- DO_CONFIG(config_telnet)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- DEL_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
- SET_BIT(ses->config_flags, CONFIG_FLAG_TELNET);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
- DEL_BIT(ses->config_flags, CONFIG_FLAG_TELNET);
- }
- else if (is_abbrev(arg2, "DEBUG"))
- {
- SET_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
- SET_BIT(ses->config_flags, CONFIG_FLAG_TELNET);
- }
- else if (is_abbrev(arg2, "INFO"))
- {
- SET_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
- SET_BIT(ses->config_flags, CONFIG_FLAG_TELNET);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF|DEBUG|INFO>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->telopts, TELOPT_FLAG_DEBUG) ? "DEBUG" : HAS_BIT(ses->config_flags, CONFIG_FLAG_TELNET) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_tintinchar)
- {
- if (*arg2)
- {
- if (!ispunct((int) arg2[0]))
- {
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG TINTIN CHAR: INVALID CHARACTER {%c}", arg2[0]);
- return NULL;
- }
- gtd->tintin_char = arg2[0];
- }
- sprintf(arg2, "%c", gtd->tintin_char);
- return ses;
- }
- DO_CONFIG(config_verbatim)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_VERBATIM);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_VERBATIM);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_VERBATIM) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_verbatimchar)
- {
- if (*arg2)
- {
- if (!ispunct((int) arg2[0]))
- {
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG VERBATIM CHAR: INVALID CHARACTER {%c}", arg2[0]);
- return NULL;
- }
- gtd->verbatim_char = arg2[0];
- }
- sprintf(arg2, "%c", gtd->verbatim_char);
- return ses;
- }
- DO_CONFIG(config_verbose)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_VERBOSE);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_VERBOSE);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_VERBOSE) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_wordwrap)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->config_flags, CONFIG_FLAG_WORDWRAP);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->config_flags, CONFIG_FLAG_WORDWRAP);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_WORDWRAP) ? "ON" : "OFF");
- return ses;
- }
|