| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061 |
- /******************************************************************************
- * 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)
- {
- char arg1[BUFFER_SIZE], arg2[BUFFER_SIZE];
- 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_ONE, SUB_VAR|SUB_FUN);
- if (*arg1 == 0)
- {
- tintin_header(ses, " 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, "ON") == 0 ? config_table[index].msg_on : config_table[index].msg_off);
- }
- }
- tintin_header(ses, "");
- }
- else
- {
- 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->auto_tab = atoi(arg2);
- }
- sprintf(arg2, "%d", ses->auto_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->lang, "UTF-8"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_UTF8);
- }
- else if (strcasestr(gtd->lang, "BIG-5"))
- {
- DEL_BIT(ses->charset, CHARSET_FLAG_ALL);
- SET_BIT(ses->charset, CHARSET_FLAG_BIG5);
- }
- else if (strcasestr(gtd->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, "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|FANSI|GBK-1|GBK1TOUTF8|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_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->flags, SES_FLAG_COLORPATCH);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_COLORPATCH);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_FLAG_COLORPATCH) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_commandcolor)
- {
- if (*arg2)
- {
- if (!get_color_names(ses, arg2, arg1))
- {
- show_error(ses, LIST_CONFIG, "#CONFIG COMMAND COLOR: INVALID COLOR CODE {%s}", arg2);
- return NULL;
- }
- 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->flags, SES_FLAG_ECHOCOMMAND);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_ECHOCOMMAND);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_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, "%6.1Lf", (long double) gts->connect_retry / 1000000);
- return ses;
- }
- DO_CONFIG(config_convertmeta)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->flags, SES_FLAG_CONVERTMETA);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_CONVERTMETA);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_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->flags, SES_FLAG_MCCP);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_MCCP);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_FLAG_MCCP) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_mousetracking)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- DEL_BIT(ses->flags, SES_FLAG_MOUSEDEBUG);
- DEL_BIT(ses->flags, SES_FLAG_MOUSEINFO);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout("\e[?1000h\e[?1002h\e[?1004h\e[?1006h");
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- if (HAS_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING))
- {
- DEL_BIT(ses->flags, SES_FLAG_MOUSEDEBUG);
- DEL_BIT(ses->flags, SES_FLAG_MOUSEINFO);
- DEL_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout("\e[?1000l\e[?1002l\e[?1004l\e[?1006l");
- }
- }
- else if (is_abbrev(arg2, "DEBUG"))
- {
- DEL_BIT(ses->flags, SES_FLAG_MOUSEINFO);
- SET_BIT(ses->flags, SES_FLAG_MOUSEDEBUG);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout("\e[?1000h\e[?1002h\e[?1004h\e[?1006h");
- }
- else if (is_abbrev(arg2, "DEBUG INFO"))
- {
- SET_BIT(ses->flags, SES_FLAG_MOUSEDEBUG);
- SET_BIT(ses->flags, SES_FLAG_MOUSEINFO);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout("\e[?1000h\e[?1002h\e[?1004h\e[?1006h");
- }
- else if (is_abbrev(arg2, "INFO"))
- {
- DEL_BIT(ses->flags, SES_FLAG_MOUSEDEBUG);
- SET_BIT(ses->flags, SES_FLAG_MOUSEINFO);
- SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
- print_stdout("\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))
- {
- switch (HAS_BIT(ses->flags, SES_FLAG_MOUSEDEBUG|SES_FLAG_MOUSEINFO))
- {
- case 0:
- strcpy(arg2, "ON");
- break;
- case SES_FLAG_MOUSEDEBUG:
- strcpy(arg2, "DEBUG");
- break;
- case SES_FLAG_MOUSEINFO:
- strcpy(arg2, "INFO");
- break;
- default:
- strcpy(arg2, "DEBUG INFO");
- break;
- }
- }
- else
- {
- strcpy(arg2, "OFF");
- }
- return ses;
- }
- DO_CONFIG(config_packetpatch)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "AUTO"))
- {
- ses->packet_patch = 0;
- SET_BIT(ses->flags, SES_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->flags, SES_FLAG_AUTOPATCH);
- ses->packet_patch = (unsigned long long) (tintoi(arg2) * 1000000ULL);
- }
- }
- if (HAS_BIT(ses->flags, SES_FLAG_AUTOPATCH))
- {
- strcpy(arg2, "AUTO");
- }
- else
- {
- sprintf(arg2, "%4.2Lf", (long double) ses->packet_patch / 1000000);
- }
- return ses;
- }
- DO_CONFIG(config_pid)
- {
- if (*arg2)
- {
- if (!is_number(arg2))
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {PID} <NUMBER>");
-
- return NULL;
- }
- else if (atoi(arg2) < 0 || atoi(arg2) > 4194303)
- {
- show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG PID: PROVIDE A NUMBER BETWEEN 3 and 4194304");
- return NULL;
- }
- else
- {
- gtd->detach_pid = atoi(arg2);
- }
- }
- sprintf(arg2, "%d", gtd->detach_pid);
- 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, "%llu", 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->flags, SES_FLAG_REPEATENTER);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_REPEATENTER);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_FLAG_REPEATENTER) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_screenreader)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->flags, SES_FLAG_SCREENREADER);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_SCREENREADER);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_FLAG_SCREENREADER) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_scrolllock)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->flags, SES_FLAG_SCROLLLOCK);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_SCROLLLOCK);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_FLAG_SCROLLLOCK) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_speedwalk)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->flags, SES_FLAG_SPEEDWALK);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_SPEEDWALK);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_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->flags, SES_FLAG_TELNET);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
- DEL_BIT(ses->flags, SES_FLAG_TELNET);
- }
- else if (is_abbrev(arg2, "DEBUG"))
- {
- SET_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
- SET_BIT(ses->flags, SES_FLAG_TELNET);
- }
- else if (is_abbrev(arg2, "INFO"))
- {
- SET_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
- SET_BIT(ses->flags, SES_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->flags, SES_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->flags, SES_FLAG_VERBATIM);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_VERBATIM);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_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->flags, SES_FLAG_VERBOSE);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_VERBOSE);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_FLAG_VERBOSE) ? "ON" : "OFF");
- return ses;
- }
- DO_CONFIG(config_wordwrap)
- {
- if (*arg2)
- {
- if (is_abbrev(arg2, "ON"))
- {
- SET_BIT(ses->flags, SES_FLAG_WORDWRAP);
- }
- else if (is_abbrev(arg2, "OFF"))
- {
- DEL_BIT(ses->flags, SES_FLAG_WORDWRAP);
- }
- else
- {
- show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
- return NULL;
- }
- }
- strcpy(arg2, HAS_BIT(ses->flags, SES_FLAG_WORDWRAP) ? "ON" : "OFF");
- return ses;
- }
|