| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947 |
- /******************************************************************************
- * 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"
- // color subs
- char *c256to16_fg[256] =
- {
- "\e[22;30m", "\e[22;31m", "\e[22;32m", "\e[22;33m", "\e[22;34m", "\e[22;35m", "\e[22;36m", "\e[22;37m",
- "\e[1;30m", "\e[1;31m", "\e[1;32m", "\e[1;33m", "\e[1;34m", "\e[1;35m", "\e[1;36m", "\e[1;37m",
- "\e[22;30m", "\e[22;34m", "\e[22;34m", "\e[22;34m", "\e[1;34m", "\e[1;34m",
- "\e[22;32m", "\e[22;36m", "\e[22;36m", "\e[22;34m", "\e[1;34m", "\e[1;34m",
- "\e[22;32m", "\e[22;36m", "\e[22;36m", "\e[22;36m", "\e[1;34m", "\e[1;34m",
- "\e[22;32m", "\e[22;32m", "\e[22;36m", "\e[22;36m", "\e[22;36m", "\e[1;36m",
- "\e[1;32m", "\e[1;32m", "\e[1;32m", "\e[22;36m", "\e[1;36m", "\e[1;36m",
- "\e[1;32m", "\e[1;32m", "\e[1;32m", "\e[1;36m", "\e[1;36m", "\e[1;36m",
- "\e[22;31m", "\e[22;35m", "\e[22;35m", "\e[22;34m", "\e[1;34m", "\e[1;34m",
- "\e[22;33m", "\e[1;30m", "\e[22;34m", "\e[22;34m", "\e[1;34m", "\e[1;34m",
- "\e[22;33m", "\e[22;32m", "\e[22;36m", "\e[22;36m", "\e[1;34m", "\e[1;34m",
- "\e[22;32m", "\e[22;32m", "\e[22;36m", "\e[22;36m", "\e[22;36m", "\e[1;36m",
- "\e[1;32m", "\e[1;32m", "\e[1;32m", "\e[22;36m", "\e[1;36m", "\e[1;36m",
- "\e[1;32m", "\e[1;32m", "\e[1;32m", "\e[1;36m", "\e[1;36m", "\e[1;36m",
- "\e[22;31m", "\e[22;35m", "\e[22;35m", "\e[22;35m", "\e[1;34m", "\e[1;34m",
- "\e[22;33m", "\e[22;31m", "\e[22;35m", "\e[22;35m", "\e[1;34m", "\e[1;34m",
- "\e[22;33m", "\e[22;33m", "\e[22;37m", "\e[22;34m", "\e[1;34m", "\e[1;34m",
- "\e[22;33m", "\e[22;33m", "\e[22;32m", "\e[22;36m", "\e[22;36m", "\e[1;34m",
- "\e[1;32m", "\e[1;32m", "\e[1;32m", "\e[22;36m", "\e[1;36m", "\e[1;36m",
- "\e[1;32m", "\e[1;32m", "\e[1;32m", "\e[1;32m", "\e[1;36m", "\e[1;36m",
- "\e[22;31m", "\e[22;31m", "\e[22;35m", "\e[22;35m", "\e[22;35m", "\e[1;35m",
- "\e[22;31m", "\e[22;31m", "\e[22;35m", "\e[22;35m", "\e[22;35m", "\e[1;35m",
- "\e[22;33m", "\e[22;33m", "\e[22;31m", "\e[22;35m", "\e[22;35m", "\e[1;34m",
- "\e[22;33m", "\e[22;33m", "\e[22;33m", "\e[22;37m", "\e[1;34m", "\e[1;34m",
- "\e[22;33m", "\e[22;33m", "\e[22;33m", "\e[1;32m", "\e[1;36m", "\e[1;36m",
- "\e[1;33m", "\e[1;33m", "\e[1;32m", "\e[1;32m", "\e[1;36m", "\e[1;36m",
- "\e[1;31m", "\e[1;31m", "\e[1;31m", "\e[22;35m", "\e[1;35m", "\e[1;35m",
- "\e[1;31m", "\e[1;31m", "\e[1;31m", "\e[22;35m", "\e[1;35m", "\e[1;35m",
- "\e[1;31m", "\e[1;31m", "\e[1;31m", "\e[22;35m", "\e[1;35m", "\e[1;35m",
- "\e[22;33m", "\e[22;33m", "\e[22;33m", "\e[1;31m", "\e[1;35m", "\e[1;35m",
- "\e[1;33m", "\e[1;33m", "\e[1;33m", "\e[1;33m", "\e[1;37m", "\e[1;37m",
- "\e[1;33m", "\e[1;33m", "\e[1;33m", "\e[1;33m", "\e[1;37m", "\e[1;37m",
- "\e[1;31m", "\e[1;31m", "\e[1;31m", "\e[1;35m", "\e[1;35m", "\e[1;35m",
- "\e[1;31m", "\e[1;31m", "\e[1;31m", "\e[1;35m", "\e[1;35m", "\e[1;35m",
- "\e[1;31m", "\e[1;31m", "\e[1;31m", "\e[1;31m", "\e[1;35m", "\e[1;35m",
- "\e[1;33m", "\e[1;33m", "\e[1;31m", "\e[1;31m", "\e[1;35m", "\e[1;35m",
- "\e[1;33m", "\e[1;33m", "\e[1;33m", "\e[1;33m", "\e[1;37m", "\e[1;37m",
- "\e[1;33m", "\e[1;33m", "\e[1;33m", "\e[1;33m", "\e[1;37m", "\e[1;37m",
- "\e[1;30m", "\e[1;30m", "\e[1;30m", "\e[1;30m", "\e[1;30m", "\e[1;30m",
- "\e[1;30m", "\e[1;30m", "\e[1;30m", "\e[1;30m", "\e[1;30m", "\e[1;30m",
- "\e[22;37m", "\e[22;37m", "\e[22;37m", "\e[22;37m", "\e[22;37m", "\e[22;37m",
- "\e[1;37m", "\e[1;37m", "\e[1;37m", "\e[1;37m", "\e[1;37m", "\e[1;37m"
- };
- char *c256to16_bg[256] =
- {
- "\e[22;40m", "\e[22;41m", "\e[22;42m", "\e[22;43m", "\e[22;44m", "\e[22;45m", "\e[22;46m", "\e[22;47m",
- "\e[1;40m", "\e[1;41m", "\e[1;42m", "\e[1;43m", "\e[1;44m", "\e[1;45m", "\e[1;46m", "\e[1;47m",
- "\e[22;40m", "\e[22;44m", "\e[22;44m", "\e[22;44m", "\e[1;44m", "\e[1;44m",
- "\e[22;42m", "\e[22;46m", "\e[22;46m", "\e[22;44m", "\e[1;44m", "\e[1;44m",
- "\e[22;42m", "\e[22;46m", "\e[22;46m", "\e[22;46m", "\e[1;44m", "\e[1;44m",
- "\e[22;42m", "\e[22;42m", "\e[22;46m", "\e[22;46m", "\e[22;46m", "\e[1;46m",
- "\e[1;42m", "\e[1;42m", "\e[1;42m", "\e[22;46m", "\e[1;46m", "\e[1;46m",
- "\e[1;42m", "\e[1;42m", "\e[1;42m", "\e[1;46m", "\e[1;46m", "\e[1;46m",
- "\e[22;41m", "\e[22;45m", "\e[22;45m", "\e[22;44m", "\e[1;44m", "\e[1;44m",
- "\e[22;43m", "\e[1;40m", "\e[22;44m", "\e[22;44m", "\e[1;44m", "\e[1;44m",
- "\e[22;43m", "\e[22;42m", "\e[22;46m", "\e[22;46m", "\e[1;44m", "\e[1;44m",
- "\e[22;42m", "\e[22;42m", "\e[22;46m", "\e[22;46m", "\e[22;46m", "\e[1;46m",
- "\e[1;42m", "\e[1;42m", "\e[1;42m", "\e[22;46m", "\e[1;46m", "\e[1;46m",
- "\e[1;42m", "\e[1;42m", "\e[1;42m", "\e[1;46m", "\e[1;46m", "\e[1;46m",
- "\e[22;41m", "\e[22;45m", "\e[22;45m", "\e[22;45m", "\e[1;44m", "\e[1;44m",
- "\e[22;43m", "\e[22;41m", "\e[22;45m", "\e[22;45m", "\e[1;44m", "\e[1;44m",
- "\e[22;43m", "\e[22;43m", "\e[22;47m", "\e[22;44m", "\e[1;44m", "\e[1;44m",
- "\e[22;43m", "\e[22;43m", "\e[22;42m", "\e[22;46m", "\e[22;46m", "\e[1;44m",
- "\e[1;42m", "\e[1;42m", "\e[1;42m", "\e[22;46m", "\e[1;46m", "\e[1;46m",
- "\e[1;42m", "\e[1;42m", "\e[1;42m", "\e[1;42m", "\e[1;46m", "\e[1;46m",
- "\e[22;41m", "\e[22;41m", "\e[22;45m", "\e[22;45m", "\e[22;45m", "\e[1;45m",
- "\e[22;41m", "\e[22;41m", "\e[22;45m", "\e[22;45m", "\e[22;45m", "\e[1;45m",
- "\e[22;43m", "\e[22;43m", "\e[22;41m", "\e[22;45m", "\e[22;45m", "\e[1;44m",
- "\e[22;43m", "\e[22;43m", "\e[22;43m", "\e[22;47m", "\e[1;44m", "\e[1;44m",
- "\e[22;43m", "\e[22;43m", "\e[22;43m", "\e[1;42m", "\e[1;46m", "\e[1;46m",
- "\e[1;43m", "\e[1;43m", "\e[1;42m", "\e[1;42m", "\e[1;46m", "\e[1;46m",
- "\e[1;41m", "\e[1;41m", "\e[1;41m", "\e[22;45m", "\e[1;45m", "\e[1;45m",
- "\e[1;41m", "\e[1;41m", "\e[1;41m", "\e[22;45m", "\e[1;45m", "\e[1;45m",
- "\e[1;41m", "\e[1;41m", "\e[1;41m", "\e[22;45m", "\e[1;45m", "\e[1;45m",
- "\e[22;43m", "\e[22;43m", "\e[22;43m", "\e[1;41m", "\e[1;45m", "\e[1;45m",
- "\e[1;43m", "\e[1;43m", "\e[1;43m", "\e[1;43m", "\e[1;47m", "\e[1;47m",
- "\e[1;43m", "\e[1;43m", "\e[1;43m", "\e[1;43m", "\e[1;47m", "\e[1;47m",
- "\e[1;41m", "\e[1;41m", "\e[1;41m", "\e[1;45m", "\e[1;45m", "\e[1;45m",
- "\e[1;41m", "\e[1;41m", "\e[1;41m", "\e[1;45m", "\e[1;45m", "\e[1;45m",
- "\e[1;41m", "\e[1;41m", "\e[1;41m", "\e[1;41m", "\e[1;45m", "\e[1;45m",
- "\e[1;43m", "\e[1;43m", "\e[1;41m", "\e[1;41m", "\e[1;45m", "\e[1;45m",
- "\e[1;43m", "\e[1;43m", "\e[1;43m", "\e[1;43m", "\e[1;47m", "\e[1;47m",
- "\e[1;43m", "\e[1;43m", "\e[1;43m", "\e[1;43m", "\e[1;47m", "\e[1;47m",
- "\e[1;40m", "\e[1;40m", "\e[1;40m", "\e[1;40m", "\e[1;40m", "\e[1;40m",
- "\e[1;40m", "\e[1;40m", "\e[1;40m", "\e[1;40m", "\e[1;40m", "\e[1;40m",
- "\e[22;47m", "\e[22;47m", "\e[22;47m", "\e[22;47m", "\e[22;47m", "\e[22;47m",
- "\e[1;47m", "\e[1;47m", "\e[1;47m", "\e[1;47m", "\e[1;47m", "\e[1;47m"
- };
- // input A to F
- int c256_val(char chr)
- {
- static unsigned char c256_val[256] =
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- return (int) c256_val[(unsigned char) chr];
- }
- // input 00 to FF
- int c4096_val(char chr1, char chr2)
- {
- static unsigned char c4096_val[256] =
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
- 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- return (int) c4096_val[(unsigned char) chr1] * 16 + c4096_val[(unsigned char) chr2];
- }
- // input 00 to FF
- int c4096_to_256_val(char chr1, char chr2)
- {
- static unsigned char c4096_to_256[256] =
- {
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- };
- return (int) c4096_to_256[c4096_val(chr1, chr2)];
- }
- char int_to_hex[16] =
- {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
- };
- char int_to_256[6] =
- {
- 'A', 'B', 'C', 'D', 'E', 'F'
- };
- void c4096_rnd(struct session *ses, char *str)
- {
- sprintf(str, "%c%c%c", int_to_hex[generate_rand(ses) % 16], int_to_hex[generate_rand(ses) % 16], int_to_hex[generate_rand(ses) % 16]);
- }
- int is_c32(char chr)
- {
- static unsigned char c32_lookup[256] =
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '?',
- 0, 'A', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 'Z', 0, 0, 0, 0, 0,
- 0, 'a', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 'z', 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- return (int) c32_lookup[(unsigned char) chr];
- }
- char *c32_fg_dark[26] =
- {
- "<f06b>", "<f00b>", "<f0bb>", "", "<f000>", "", "<f0b0>", "", "", "<f0b6>", "", "<f6b0>", "<fb0b>",
- "", "<fb60>", "<fb06>", "", "<fb00>", "<f888>", "<f860>", "", "<f60b>", "<fbbb>", "", "<fbb0>", ""
- };
- char *c32_fg_bold[26] =
- {
- "<f08f>", "<f00f>", "<f0ff>", "", "<f666>", "", "<f0f0>", "", "", "<f0f8>", "", "<f8f0>", "<ff0f>",
- "", "<ff80>", "<ff08>", "", "<ff00>", "<fddd>", "<fdb0>", "", "<f80f>", "<ffff>", "", "<fff0>", ""
- };
- int is_variable(struct session *ses, char *str)
- {
- struct listroot *root;
- char temp[BUFFER_SIZE], *ptt;
- int i = 1;
- while (str[i] == str[0])
- {
- i++;
- }
- if (str[i] == DEFAULT_OPEN)
- {
- return TRUE;
- }
- if (str[i] != '_' && isalpha((int) str[i]) == 0)
- {
- return FALSE;
- }
- ptt = temp;
- while (isalnum((int) str[i]) || str[i] == '_')
- {
- *ptt++ = str[i];
- i++;
- }
- *ptt = 0;
- root = local_list(ses);
- if (search_node_list(root, temp) == NULL)
- {
- root = ses->list[LIST_VARIABLE];
- if (search_node_list(root, temp) == NULL)
- {
- return FALSE;
- }
- }
- return TRUE;
- }
- int is_function(struct session *ses, char *str)
- {
- char temp[BUFFER_SIZE], *ptt;
- int i = 1;
- while (str[i] == str[0])
- {
- i++;
- }
- if (str[i] != '_' && isalpha((int) str[i]) == 0)
- {
- return FALSE;
- }
- ptt = temp;
- while (isalnum((int) str[i]) || str[i] == '_')
- {
- *ptt++ = str[i];
- i++;
- }
- *ptt = 0;
- if (str[i] != DEFAULT_OPEN)
- {
- return FALSE;
- }
- if (search_node_list(ses->list[LIST_FUNCTION], temp) == NULL)
- {
- if (find_session(temp) == NULL)
- {
- return FALSE;
- }
- }
- return TRUE;
- }
- int is_color_code(char *pti)
- {
- if (pti[0] == '<')
- {
- if (pti[1] == 0 || pti[2] == 0 || pti[3] == 0 || pti[4] == 0)
- {
- return 0;
- }
- if (pti[4] == '>')
- {
- if (isdigit(pti[1]) && isdigit(pti[2]) && isdigit(pti[3]))
- {
- return 5;
- }
- if (pti[1] >= 'a' && pti[1] <= 'f' && pti[2] >= 'a' && pti[2] <= 'f' && pti[3] >= 'a' && pti[3] <= 'f')
- {
- return 5;
- }
- if (pti[1] >= 'A' && pti[1] <= 'F' && pti[2] >= 'A' && pti[2] <= 'F' && pti[3] >= 'A' && pti[3] <= 'F')
- {
- return 5;
- }
- if (pti[1] == 'g' || pti[1] == 'G')
- {
- if (isdigit((int) pti[2]) && isdigit((int) pti[3]))
- {
- return 5;
- }
- return 0;
- }
- return 0;
- }
- if (pti[5] == 0)
- {
- return 0;
- }
- if (toupper((int) pti[1]) == 'F')
- {
- if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && pti[5] == '>')
- {
- return 6;
- }
- else if (pti[2] == '?' && pti[3] == '?' && pti[4] == '?' && pti[5] == '>')
- {
- return 6;
- }
- else if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && isxdigit(pti[5]) && isxdigit(pti[6]) && isxdigit(pti[7]) && pti[8] == '>')
- {
- return 9;
- }
- return 0;
- }
- if (toupper(pti[1]) == 'B')
- {
- if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && pti[5] == '>')
- {
- return 6;
- }
- if (toupper(pti[1]) == 'B' && pti[2] == '?' && pti[3] == '?' && pti[4] == '?' && pti[5] == '>')
- {
- return 6;
- }
- if (toupper(pti[1]) == 'B' && isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && isxdigit(pti[5]) && isxdigit(pti[6]) && isxdigit(pti[7]) && pti[8] == '>')
- {
- return 9;
- }
- return 0;
- }
- }
- return 0;
- }
- char *fuzzy_char(struct session *ses, char val1, char val2, int mode)
- {
- static char out[10][3];
- static int cnt;
- int tmp;
- cnt = (cnt + 1) % 10;
- switch (mode)
- {
- case 8:
- tmp = c256_val(val2) - 1 + generate_rand(ses) % 3;
- tmp = URANGE(0, tmp, 5);
- if (isupper(val2))
- {
- sprintf(out[cnt], "%c", toupper(int_to_256[tmp]));
- }
- else
- {
- sprintf(out[cnt], "%c", tolower(int_to_256[tmp]));
- }
- break;
- case 12:
- tmp = c4096_val(0, val2);
- tmp = tmp - 2 + generate_rand(ses) % 4;
- tmp = URANGE(0, tmp, 15);
- sprintf(out[cnt], "%c", int_to_hex[tmp]);
- break;
- case 24:
- tmp = c4096_val(val1, val2);
- tmp = (tmp - 12 + generate_rand(ses) % 24);
- tmp = URANGE(0, tmp, 255);
- sprintf(out[cnt], "%c%c", int_to_hex[tmp / 16], int_to_hex[tmp % 16]);
- break;
- default:
- tintin_printf2(ses, "dim_char: invalid mode");
- break;
- }
- return out[cnt];
- }
- char *fuzzy_color_code(struct session *ses, char *in)
- {
- static char *pto, out[10][100];
- static int cnt;
- char *pti, buf[100];
- int tmp;
- if (*in == 0 || strlen(in) > 50)
- {
- return "";
- }
- strcpy(buf, in);
- pti = buf;
- cnt = (cnt + 1) % 10;
- pto = out[cnt];
- while (*pti)
- {
- if (pti[0] == '<')
- {
- if (pti[1] == 0 || pti[2] == 0 || pti[3] == 0 || pti[4] == 0)
- {
- return out[cnt];
- }
- if (pti[4] == '>')
- {
- if (isdigit(pti[1]) && isdigit(pti[2]) && isdigit(pti[3]))
- {
- pto += sprintf(pto, "<%c%c%c>", pti[1], pti[2], pti[3]);
- }
- else if (pti[1] >= 'a' && pti[1] <= 'f' && pti[2] >= 'a' && pti[2] <= 'f' && pti[3] >= 'a' && pti[3] <= 'f')
- {
- pto += sprintf(pto, "<%s%s%s>", fuzzy_char(ses, 0, pti[1], 8), fuzzy_char(ses, 0, pti[2], 8), fuzzy_char(ses, 0, pti[3], 8));
- }
- else if (pti[1] >= 'A' && pti[1] <= 'F' && pti[2] >= 'A' && pti[2] <= 'F' && pti[3] >= 'A' && pti[3] <= 'F')
- {
- pto += sprintf(pto, "<%s%s%s>", fuzzy_char(ses, 0, pti[1], 8), fuzzy_char(ses, 0, pti[2], 8), fuzzy_char(ses, 0, pti[3], 8));
- }
- else if ((pti[1] == 'g' || pti[1] == 'G') && isdigit((int) pti[2]) && isdigit((int) pti[3]))
- {
- tmp = (pti[2] - '0') * 10 + (pti[3] - '0') - 3 + generate_rand(ses) % 7;
- pto += sprintf(pto, "<%c%02d>", pti[1], URANGE(0, tmp, 23));
- }
- else
- {
- return out[cnt];
- }
- pti += 5;
- }
- else if (toupper((int) pti[1]) == 'F')
- {
- if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && pti[5] == '>')
- {
- pto += sprintf(pto, "<F%s%s%s>", fuzzy_char(ses, 0, pti[2], 12), fuzzy_char(ses, 0, pti[3], 12), fuzzy_char(ses, 0, pti[4], 12));
- pti += 6;
- }
- else if (pti[2] == '?' && pti[3] == '?' && pti[4] == '?' && pti[5] == '>')
- {
- c4096_rnd(ses, &pti[2]);
- pto += sprintf(pto, "<F%c%c%c>", pti[2], pti[3], pti[4]);
- pti += 6;
- }
- else if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && isxdigit(pti[5]) && isxdigit(pti[6]) && isxdigit(pti[7]) && pti[8] == '>')
- {
- pto += sprintf(pto, "<F%s%s%s>", fuzzy_char(ses, pti[3], pti[4], 24), fuzzy_char(ses, pti[4], pti[5], 24), fuzzy_char(ses, pti[7], pti[7], 24));
- pti += 9;
- }
- else
- {
- return out[cnt];
- }
- }
- else if (toupper(pti[1]) == 'B')
- {
- if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && pti[5] == '>')
- {
- pto += sprintf(pto, "<B%s%s%s>", fuzzy_char(ses, 0, pti[2], 12), fuzzy_char(ses, 0, pti[3], 12), fuzzy_char(ses, 0, pti[4], 12));
- pti += 6;
- }
- else if (pti[2] == '?' && pti[3] == '?' && pti[4] == '?' && pti[5] == '>')
- {
- c4096_rnd(ses, &pti[2]);
- pto += sprintf(pto, "<B%c%c%c>", pti[2], pti[3], pti[4]);
- pti += 6;
- }
- else if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && isxdigit(pti[5]) && isxdigit(pti[6]) && isxdigit(pti[7]) && pti[8] == '>')
- {
- pto += sprintf(pto, "<B%s%s%s>", fuzzy_char(ses, pti[2], pti[3], 24), fuzzy_char(ses, pti[4], pti[5], 24), fuzzy_char(ses, pti[6], pti[7], 24));
- pti += 9;
- }
- else
- {
- return out[cnt];
- }
- }
- else
- {
- return out[cnt];
- }
- }
- else
- {
- return out[cnt];
- }
- }
- return out[cnt];
- }
- char *dim_char(struct session *ses, char val1, char val2, int mod, int mode)
- {
- static char out[10][3];
- static int cnt;
- int tmp;
- cnt = (cnt + 1) % 10;
- switch (mode)
- {
- case 8:
- tmp = c256_val(val2) - mod;
- tmp = URANGE(0, tmp, 5);
- if (isupper(val2))
- {
- sprintf(out[cnt], "%c", toupper(int_to_256[tmp]));
- }
- else
- {
- sprintf(out[cnt], "%c", tolower(int_to_256[tmp]));
- }
- break;
- case 12:
- tmp = c4096_val(0, val2);
- tmp = tmp - mod - generate_rand(ses) % 3;
- tmp = URANGE(0, tmp, 15);
- sprintf(out[cnt], "%c", int_to_hex[tmp]);
- break;
- case 24:
- tmp = c4096_val(val1, val2);
- tmp = tmp - mod - generate_rand(ses) % 2;
- tmp = URANGE(0, tmp, 255);
- sprintf(out[cnt], "%c%c", int_to_hex[tmp / 16], int_to_hex[tmp % 16]);
- break;
- default:
- tintin_printf2(ses, "dim_char: invalid mode");
- break;
- }
- return out[cnt];
- }
- char *dim_color_code(struct session *ses, char *in, int mod)
- {
- static char *pto, out[10][60], buf[60];
- char *pti;
- static int cnt;
- int tmp;
- if (*in == 0 || strlen(in) > 40)
- {
- return "";
- }
- strcpy(buf, in);
- pti = buf;
- cnt = (cnt + 1) % 10;
- pto = out[cnt];
- if (mod < 0)
- {
- strcpy(pto, buf);
- return out[cnt];
- }
- *pto = 0;
- while (*pti)
- {
- if (pti[0] == '<')
- {
- if (pti[1] == 0 || pti[2] == 0 || pti[3] == 0 || pti[4] == 0)
- {
- return out[cnt];
- }
- if (pti[4] == '>')
- {
- if (isdigit(pti[1]) && isdigit(pti[2]) && isdigit(pti[3]))
- {
- pto += sprintf(pto, "<%c%c%c>", pti[1], pti[2], pti[3]);
- }
- else if (pti[1] >= 'a' && pti[1] <= 'f' && pti[2] >= 'a' && pti[2] <= 'f' && pti[3] >= 'a' && pti[3] <= 'f')
- {
- pto += sprintf(pto, "<%s%s%s>", dim_char(ses, 0, pti[1], mod, 8), dim_char(ses, 0, pti[2], mod, 8), dim_char(ses, 0, pti[3], mod, 8));
- }
- else if (pti[1] >= 'A' && pti[1] <= 'F' && pti[2] >= 'A' && pti[2] <= 'F' && pti[3] >= 'A' && pti[3] <= 'F')
- {
- pto += sprintf(pto, "<%s%s%s>", dim_char(ses, 0, pti[1], mod, 8), dim_char(ses, 0, pti[2], mod, 8), dim_char(ses, 0, pti[3], mod, 8));
- }
- else if ((pti[1] == 'g' || pti[1] == 'G') && isdigit((int) pti[2]) && isdigit((int) pti[3]))
- {
- tmp = (pti[2] - '0') * 10 + (pti[3] - '0') - mod;
- pto += sprintf(pto, "<%c%02d>", pti[1], URANGE(0, tmp, 23));
- }
- else
- {
- return out[cnt];
- }
- pti += 5;
- }
- else if (toupper((int) pti[1]) == 'F')
- {
- if (pti[2] == '?' && pti[3] == '?' && pti[4] == '?' && pti[5] == '>')
- {
- c4096_rnd(ses, &pti[2]);
- }
- if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && pti[5] == '>')
- {
- pto += sprintf(pto, "<F%s%s%s>", dim_char(ses, 0, pti[2], mod, 12), dim_char(ses, 0, pti[3], mod, 12), dim_char(ses, 0, pti[4], mod, 12));
- pti += 6;
- }
- else if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && isxdigit(pti[5]) && isxdigit(pti[6]) && isxdigit(pti[7]) && pti[8] == '>')
- {
- pto += sprintf(pto, "<F%s%s%s>", dim_char(ses, pti[2], pti[3], mod, 24), dim_char(ses, pti[4], pti[5], mod, 24), dim_char(ses, mod, pti[6], pti[7], 24));
- pti += 9;
- }
- else
- {
- return out[cnt];
- }
- }
- else if (toupper(pti[1]) == 'B')
- {
- if (pti[2] == '?' && pti[3] == '?' && pti[4] == '?' && pti[5] == '>')
- {
- c4096_rnd(ses, &pti[2]);
- }
- if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && pti[5] == '>')
- {
- pto += sprintf(pto, "<B%s%s%s>", dim_char(ses, 0, pti[2], mod, 12), dim_char(ses, 0, pti[3], mod, 12), dim_char(ses, 0, pti[4], mod, 12));
- pti += 6;
- }
- else if (toupper(pti[1]) == 'B' && isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && isxdigit(pti[5]) && isxdigit(pti[6]) && isxdigit(pti[7]) && pti[8] == '>')
- {
- pto += sprintf(pto, "<B%s%s%s>", dim_char(ses, pti[2], pti[3], mod, 24), dim_char(ses, pti[4], pti[5], mod, 24), dim_char(ses, pti[6], pti[7], mod, 24));
- pti += 9;
- }
- else
- {
- return out[cnt];
- }
- }
- else
- {
- return out[cnt];
- }
- }
- }
- return out[cnt];
- }
- char lit_char(struct session *ses, char max, char val, int mod, int mode)
- {
- int tmp;
- switch (mode)
- {
- case 8:
- tmp = val + mod;
- return UMIN(max, tmp);
- case 12:
- tmp = c4096_val(0, val);
- tmp = URANGE(0, tmp + mod, 15);
- return int_to_hex[tmp];
- }
- return val;
- }
- char *lit_color_code(struct session *ses, char *pti, int mod)
- {
- static char fuzzy[10][20];
- static int cnt;
- int tmp;
- cnt = (cnt + 1) % 10;
- if (pti[0] == '<')
- {
- if (pti[1] == 0 || pti[2] == 0 || pti[3] == 0 || pti[4] == 0)
- {
- return "";
- }
- if (pti[4] == '>')
- {
- if (isdigit(pti[1]) && isdigit(pti[2]) && isdigit(pti[3]))
- {
- sprintf(fuzzy[cnt], "<%c%c%c>%.9s", pti[1], pti[2], pti[3], &pti[5]);
- return fuzzy[cnt];
- }
- if (pti[1] >= 'a' && pti[1] <= 'f' && pti[2] >= 'a' && pti[2] <= 'f' && pti[3] >= 'a' && pti[3] <= 'f')
- {
- sprintf(fuzzy[cnt], "<%c%c%c>%.9s", lit_char(ses, 'f', pti[1], mod, 8), lit_char(ses, 'f', pti[2], mod, 8), lit_char(ses, 'f', pti[3], mod, 8), &pti[5]);
- return fuzzy[cnt];
- }
- if (pti[1] >= 'A' && pti[1] <= 'F' && pti[2] >= 'A' && pti[2] <= 'F' && pti[3] >= 'A' && pti[3] <= 'F')
- {
- sprintf(fuzzy[cnt], "<%c%c%c>%.9s", lit_char(ses, 'F', pti[1], mod, 8), lit_char(ses, 'F', pti[2], mod, 8), lit_char(ses, 'F', pti[3], mod, 8), &pti[5]);
- return fuzzy[cnt];
- }
- }
- {
- if (pti[1] == 'g' || pti[1] == 'G')
- {
- if (isdigit((int) pti[2]) && isdigit((int) pti[3]))
- {
- tmp = (pti[2] - '0') * 10 + (pti[3] - '0');
- tmp -= mod;
- sprintf(fuzzy[cnt], "<%c%02d>%.9s", pti[1], URANGE(0, tmp, 23), &pti[5]);
- return fuzzy[cnt];
- }
- return "";
- }
- }
- if (pti[5] == 0)
- {
- return "";
- }
- if (toupper((int) pti[1]) == 'F')
- {
- if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && pti[5] == '>')
- {
- sprintf(fuzzy[cnt], "<F%c%c%c>%.9s", lit_char(ses, 'F', pti[2], mod, 12), lit_char(ses, 'F', pti[3], mod, 12), lit_char(ses, 'F', pti[4], mod, 12), &pti[6]);
- return fuzzy[cnt];
- }
- else if (pti[2] == '?' && pti[3] == '?' && pti[4] == '?' && pti[5] == '>')
- {
- sprintf(fuzzy[cnt], "<F??%c>%.9s", '?', &pti[6]);
- c4096_rnd(ses, &fuzzy[cnt][2]);
- return dim_color_code(ses, fuzzy[cnt], mod);
- }
- else if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && isxdigit(pti[5]) && isxdigit(pti[6]) && isxdigit(pti[7]) && pti[8] == '>')
- {
- sprintf(fuzzy[cnt], "<F%c%c%c>%.9s", lit_char(ses, 'F', pti[2], mod, 12), lit_char(ses, 'F', pti[4], mod, 12), lit_char(ses, mod, pti[6], 'F', 12), &pti[9]);
- return fuzzy[cnt];
- }
- return "";
- }
- if (toupper(pti[1]) == 'B')
- {
- if (isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && pti[5] == '>')
- {
- sprintf(fuzzy[cnt], "<B%c%c%c>%.9s", lit_char(ses, 'F', pti[2], mod, 12), lit_char(ses, 'F', pti[3], mod, 12), lit_char(ses, 'F', pti[4], mod, 12), &pti[6]);
- return fuzzy[cnt];
- }
- if (toupper(pti[1]) == 'B' && pti[2] == '?' && pti[3] == '?' && pti[4] == '?' && pti[5] == '>')
- {
- sprintf(fuzzy[cnt], "<B??%c>%.9s", '?', &pti[6]);
- c4096_rnd(ses, &fuzzy[cnt][2]);
- return dim_color_code(ses, fuzzy[cnt], mod);
- }
- if (toupper(pti[1]) == 'B' && isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && isxdigit(pti[5]) && isxdigit(pti[6]) && isxdigit(pti[7]) && pti[8] == '>')
- {
- sprintf(fuzzy[cnt], "<B%c%c%c>%.9s", lit_char(ses, 'F', pti[2], mod, 12), lit_char(ses, 'F', pti[4], mod, 12), lit_char(ses, mod, pti[6], 'F', 12), &pti[9]);
- return fuzzy[cnt];
- }
- return "";
- }
- }
- return "";
- }
- int substitute(struct session *ses, char *string, char *result, int flags)
- {
- struct listnode *node;
- struct listroot *root;
- struct session *sesptr;
- char temp[BUFFER_SIZE], buf[BUFFER_SIZE], buffer[BUFFER_SIZE], *pti, *pto, *ptt, *str;
- char *pte, old[10] = { 0 };
- int i, skip, cnt, escape = FALSE, flags_neol = flags;
- push_call("substitute(%p,%p,%p,%d)",ses,string,result,flags);
- pti = string;
- pto = (string == result) ? buffer : result;
- DEL_BIT(flags_neol, SUB_EOL|SUB_LNF);
- while (TRUE)
- {
- if (HAS_BIT(ses->charset, CHARSET_FLAG_EUC) && is_euc_head(ses, pti))
- {
- *pto++ = *pti++;
- *pto++ = *pti++;
- continue;
- }
- switch (*pti)
- {
- case '\0':
- if (HAS_BIT(flags, SUB_EOL))
- {
- if (HAS_BIT(ses->flags, SES_FLAG_RUN))
- {
- *pto++ = '\r';
- }
- else
- {
- *pto++ = '\r';
- *pto++ = '\n';
- }
- }
- if (HAS_BIT(flags, SUB_LNF))
- {
- *pto++ = '\n';
- }
- *pto = 0;
- if (string == result)
- {
- strcpy(result, buffer);
- pop_call();
- return pto - buffer;
- }
- else
- {
- pop_call();
- return pto - result;
- }
- break;
- case '@':
- if (HAS_BIT(flags, SUB_FUN) && !HAS_BIT(ses->list[LIST_FUNCTION]->flags, LIST_FLAG_IGNORE))
- {
- i = 1;
- escape = FALSE;
- sesptr = NULL;
- while (pti[i] == '@')
- {
- escape = TRUE;
- i++;
- }
- for (ptt = temp ; isalnum((int) pti[i]) || pti[i] == '_' ; i++)
- {
- *ptt++ = pti[i];
- }
- *ptt = 0;
- if (pti[i] != DEFAULT_OPEN)
- {
- while (*pti == '@')
- {
- *pto++ = *pti++;
- }
- continue;
- }
- node = search_node_list(ses->list[LIST_FUNCTION], temp);
- if (node == NULL)
- {
- sesptr = find_session(temp);
- }
- if (sesptr == NULL && node == NULL)
- {
- while (*pti == '@')
- {
- *pto++ = *pti++;
- }
- continue;
- }
- if (escape)
- {
- pti++;
- while (*pti == '@')
- {
- *pto++ = *pti++;
- }
- continue;
- }
- pti = get_arg_in_braces(ses, &pti[i], temp, GET_ONE);
- if (sesptr)
- {
- substitute(sesptr, temp, pto, flags_neol);
- pto += strlen(pto);
- continue;
- }
- else
- {
- substitute(ses, temp, buf, flags_neol);
- }
- show_debug(ses, LIST_FUNCTION, "#DEBUG FUNCTION {%s}", node->arg1);
- RESTRING(gtd->vars[0], buf);
- pte = buf;
- for (i = 1 ; i < 100 ; i++)
- {
- pte = get_arg_in_braces(ses, pte, temp, GET_ALL);
- RESTRING(gtd->vars[i], temp);
- if (*pte == 0)
- {
- while (++i < 100)
- {
- if (*gtd->vars[i])
- {
- RESTRING(gtd->vars[i], "");
- }
- }
- break;
- }
- if (*pte == COMMAND_SEPARATOR)
- {
- pte++;
- }
- }
- substitute(ses, node->arg2, buf, SUB_ARG);
- if (HAS_BIT(node->flags, NODE_FLAG_ONESHOT))
- {
- delete_node_list(ses, LIST_FUNCTION, node);
- }
- script_driver(ses, LIST_FUNCTION, buf);
- substitute(ses, "$result", pto, flags_neol|SUB_VAR);
- pto += strlen(pto);
- }
- else
- {
- if (HAS_BIT(flags, SUB_SEC) && !HAS_BIT(flags, SUB_ARG) && is_function(ses, pti))
- {
- *pto++ = '\\';
- }
- *pto++ = *pti++;
- }
- break;
- case '*':
- if (HAS_BIT(flags, SUB_VAR) && !HAS_BIT(ses->list[LIST_VARIABLE]->flags, LIST_FLAG_IGNORE) && pti[1])
- {
- int brace = FALSE;
- i = 1;
- escape = FALSE;
- while (pti[i] == '*')
- {
- escape = TRUE;
- i++;
- }
- if (pti[i] == DEFAULT_OPEN)
- {
- brace = TRUE;
- ptt = get_arg_in_braces(ses, &pti[i], buf, GET_ALL);
- i += strlen(buf) + 2;
- substitute(ses, buf, temp, flags_neol);
- }
- else
- {
- ptt = temp;
- while (isalnum((int) pti[i]) || pti[i] == '_')
- {
- *ptt++ = pti[i];
- i++;
- }
- *ptt = 0;
- }
- if (*temp)
- {
- root = local_list(ses);
- if ((node = search_node_list(root, temp)) == NULL)
- {
- root = ses->list[LIST_VARIABLE];
- node = search_node_list(root, temp);
- }
- }
- else
- {
- root = ses->list[LIST_VARIABLE];
- node = NULL;
- }
- if (brace == FALSE && node == NULL)
- {
- while (*pti == '*')
- {
- *pto++ = *pti++;
- }
- continue;
- }
- if (escape)
- {
- pti++;
- while (*pti == '*')
- {
- *pto++ = *pti++;
- }
- continue;
- }
- if (brace == FALSE)
- {
- pti = get_arg_at_brackets(ses, &pti[i], temp + strlen(temp));
- }
- else
- {
- pti = ptt;
- }
- substitute(ses, temp, buf, flags_neol);
- str = str_dup("");
- get_nest_node_key(root, buf, &str, brace);
- substitute(ses, str, pto, flags_neol - SUB_VAR);
- pto += strlen(pto);
- str_free(str);
- }
- else
- {
- if (HAS_BIT(flags, SUB_SEC) && !HAS_BIT(flags, SUB_ARG) && is_variable(ses, pti))
- {
- *pto++ = '\\';
- }
- *pto++ = *pti++;
- }
- break;
- case '$':
- if (HAS_BIT(flags, SUB_VAR) && !HAS_BIT(ses->list[LIST_VARIABLE]->flags, LIST_FLAG_IGNORE) && pti[1])
- {
- int brace = FALSE;
- i = 1;
- escape = FALSE;
- while (pti[i] == '$')
- {
- escape = TRUE;
- i++;
- }
- if (pti[i] == DEFAULT_OPEN)
- {
- brace = TRUE;
- ptt = get_arg_in_braces(ses, &pti[i], buf, GET_ALL);
- i += strlen(buf) + 2;
- substitute(ses, buf, temp, flags_neol);
- }
- else
- {
- ptt = temp;
- while (isalnum((int) pti[i]) || pti[i] == '_')
- {
- *ptt++ = pti[i];
- i++;
- }
- *ptt = 0;
- }
- if (*temp)
- {
- root = search_nest_base_ses(ses, temp);
- if (root)
- {
- node = search_node_list(root, temp);
- }
- else
- {
- root = ses->list[LIST_VARIABLE];
- node = NULL;
- }
- }
- else
- {
- root = ses->list[LIST_VARIABLE];
- node = NULL;
- }
- if (brace == FALSE && node == NULL)
- {
- while (*pti == '$')
- {
- *pto++ = *pti++;
- }
- continue;
- }
- if (escape)
- {
- pti++;
- while (*pti == '$')
- {
- *pto++ = *pti++;
- }
- continue;
- }
- if (brace == FALSE)
- {
- pti = get_arg_at_brackets(ses, &pti[i], temp + strlen(temp));
- }
- else
- {
- pti = ptt;
- }
- substitute(ses, temp, buf, flags_neol);
- str = str_dup("");
- get_nest_node_val(root, buf, &str, brace);
- substitute(ses, str, pto, flags_neol - SUB_VAR);
- pto += strlen(pto);
- str_free(str);
- }
- else
- {
- if (HAS_BIT(flags, SUB_SEC) && !HAS_BIT(flags, SUB_ARG) && is_variable(ses, pti))
- {
- *pto++ = '\\';
- }
- *pto++ = *pti++;
- }
- break;
- case '&':
- if (HAS_BIT(flags, SUB_CMD) && (isdigit((int) pti[1]) || pti[1] == '&'))
- {
- if (pti[1] == '&')
- {
- while (pti[1] == '&')
- {
- *pto++ = *pti++;
- }
- if (isdigit((int) pti[1]))
- {
- pti++;
- }
- else
- {
- *pto++ = *pti++;
- }
- }
- else
- {
- i = isdigit((int) pti[2]) ? (pti[1] - '0') * 10 + pti[2] - '0' : pti[1] - '0';
- for (cnt = 0 ; gtd->cmds[i][cnt] ; cnt++)
- {
- *pto++ = gtd->cmds[i][cnt];
- }
- pti += isdigit((int) pti[2]) ? 3 : 2;
- }
- }
- else if (HAS_BIT(flags, SUB_VAR) && !HAS_BIT(ses->list[LIST_VARIABLE]->flags, LIST_FLAG_IGNORE))
- {
- int brace = FALSE;
- i = 1;
- escape = FALSE;
- while (pti[i] == '&')
- {
- escape = TRUE;
- i++;
- }
- if (pti[i] == DEFAULT_OPEN)
- {
- brace = TRUE;
- ptt = get_arg_in_braces(ses, &pti[i], buf, GET_ALL);
- i += strlen(buf) + 2;
- substitute(ses, buf, temp, flags_neol);
- }
- else
- {
- ptt = temp;
- while (isalnum((int) pti[i]) || pti[i] == '_')
- {
- *ptt++ = pti[i];
- i++;
- }
- *ptt = 0;
- }
- if (*temp)
- {
- root = local_list(ses);
- if ((node = search_node_list(root, temp)) == NULL)
- {
- root = ses->list[LIST_VARIABLE];
- node = search_node_list(root, temp);
- }
- }
- else
- {
- root = ses->list[LIST_VARIABLE];
- node = NULL;
- }
- if (brace == FALSE && node == NULL)
- {
- while (*pti == '&')
- {
- *pto++ = *pti++;
- }
- continue;
- }
- if (escape)
- {
- pti++;
- while (*pti == '&')
- {
- *pto++ = *pti++;
- }
- continue;
- }
- if (brace == FALSE)
- {
- pti = get_arg_at_brackets(ses, &pti[i], temp + strlen(temp));
- }
- else
- {
- pti = ptt;
- }
- substitute(ses, temp, buf, flags_neol);
- str = str_dup("");
- get_nest_index(root, buf, &str, brace);
- substitute(ses, str, pto, flags_neol - SUB_VAR);
- pto += strlen(pto);
- str_free(str);
- }
- else
- {
- if (HAS_BIT(flags, SUB_SEC) && !HAS_BIT(flags, SUB_ARG) && is_variable(ses, pti))
- {
- *pto++ = '\\';
- }
- *pto++ = *pti++;
- }
- break;
- case '%':
- if (HAS_BIT(flags, SUB_ARG) && (isdigit((int) pti[1]) || pti[1] == '%'))
- {
- if (pti[1] == '%')
- {
- while (pti[1] == '%')
- {
- *pto++ = *pti++;
- }
- pti++;
- }
- else
- {
- i = isdigit((int) pti[2]) ? (pti[1] - '0') * 10 + pti[2] - '0' : pti[1] - '0';
- ptt = gtd->vars[i];
- while (*ptt)
- {
- if (HAS_BIT(ses->charset, CHARSET_FLAG_EUC) && is_euc_head(ses, ptt))
- {
- *pto++ = *ptt++;
- *pto++ = *ptt++;
- continue;
- }
- if (HAS_BIT(flags, SUB_SEC))
- {
- switch (*ptt)
- {
- case '\\':
- *pto++ = '\\';
- *pto++ = '\\';
- break;
- case '{':
- *pto++ = '\\';
- *pto++ = 'x';
- *pto++ = '7';
- *pto++ = 'B';
- break;
- case '}':
- *pto++ = '\\';
- *pto++ = 'x';
- *pto++ = '7';
- *pto++ = 'D';
- break;
- case '$':
- case '&':
- case '*':
- if (is_variable(ses, ptt))
- {
- *pto++ = '\\';
- *pto++ = *ptt;
- }
- else
- {
- *pto++ = *ptt;
- }
- break;
- case '@':
- if (is_function(ses, ptt))
- {
- *pto++ = '\\';
- *pto++ = *ptt;
- }
- else
- {
- *pto++ = *ptt;
- }
- break;
- case COMMAND_SEPARATOR:
- *pto++ = '\\';
- *pto++ = COMMAND_SEPARATOR;
- break;
- default:
- *pto++ = *ptt;
- break;
- }
- ptt++;
- }
- else
- {
- *pto++ = *ptt++;
- }
- }
- pti += isdigit((int) pti[2]) ? 3 : 2;
- }
- }
- else if (pti[1] == '*') // avoid %*variable triggers
- {
- *pto++ = *pti++;
- *pto++ = *pti++;
- }
- else
- {
- *pto++ = *pti++;
- }
- break;
- case '<':
- if (HAS_BIT(flags, SUB_COL))
- {
- if (HAS_BIT(flags, SUB_CMP) && old[0] && !strncmp(old, pti, strlen(old)))
- {
- pti += strlen(old);
- }
- else if (isdigit(pti[1]) && isdigit(pti[2]) && isdigit(pti[3]) && pti[4] == '>')
- {
- if (pti[1] != '8' || pti[2] != '8' || pti[3] != '8')
- {
- *pto++ = ASCII_ESC;
- *pto++ = '[';
- switch (pti[1])
- {
- case '2':
- *pto++ = '2';
- *pto++ = '2';
- *pto++ = ';';
- break;
- case '8':
- break;
- default:
- *pto++ = pti[1];
- *pto++ = ';';
- }
- switch (pti[2])
- {
- case '8':
- break;
- default:
- *pto++ = '3';
- *pto++ = pti[2];
- *pto++ = ';';
- break;
- }
- switch (pti[3])
- {
- case '8':
- break;
- default:
- *pto++ = '4';
- *pto++ = pti[3];
- *pto++ = ';';
- break;
- }
- pto--;
- *pto++ = 'm';
- }
- pti += sprintf(old, "<%c%c%c>", pti[1], pti[2], pti[3]);
- }
- else if (pti[1] >= 'a' && pti[1] <= 'f' && pti[2] >= 'a' && pti[2] <= 'f' && pti[3] >= 'a' && pti[3] <= 'f' && pti[4] == '>')
- {
- cnt = 16 + (pti[1] - 'a') * 36 + (pti[2] - 'a') * 6 + (pti[3] - 'a');
- if (ses->color >= 256)
- {
- pto += sprintf(pto, "\e[38;5;%dm", cnt);
- }
- else if (ses->color == 16)
- {
- pto += sprintf(pto, "%s", c256to16_fg[cnt]);
- }
- pti += sprintf(old, "<%c%c%c>", pti[1], pti[2], pti[3]);
- }
- else if (pti[1] >= 'A' && pti[1] <= 'F' && pti[2] >= 'A' && pti[2] <= 'F' && pti[3] >= 'A' && pti[3] <= 'F' && pti[4] == '>')
- {
- cnt = 16 + (pti[1] - 'A') * 36 + (pti[2] - 'A') * 6 + (pti[3] - 'A');
- if (ses->color >= 256)
- {
- pto += sprintf(pto, "\e[48;5;%dm", cnt);
- }
- else if (ses->color == 16)
- {
- pto += sprintf(pto, "%s", c256to16_bg[cnt]);
- }
- pti += sprintf(old, "<%c%c%c>", pti[1], pti[2], pti[3]);
- }
- else if (pti[1] == 'g' && isdigit((int) pti[2]) && isdigit((int) pti[3]) && pti[4] == '>')
- {
- cnt = 232 + (pti[2] - '0') * 10 + (pti[3] - '0');
- if (ses->color >= 256)
- {
- pto += sprintf(pto, "\e[38;5;%dm", cnt);
- }
- else if (ses->color == 16)
- {
- pto += sprintf(pto, "%s", c256to16_fg[cnt]);
- }
- pti += sprintf(old, "<g%c%c>", pti[2], pti[3]);
- }
- else if (pti[1] == 'G' && isdigit((int) pti[2]) && isdigit((int) pti[3]) && pti[4] == '>')
- {
- cnt = 232 + (pti[2] - '0') * 10 + (pti[3] - '0');
- if (ses->color >= 256)
- {
- pto += sprintf(pto, "\e[48;5;%dm", cnt);
- }
- else if (ses->color == 16)
- {
- pto += sprintf(pto, "%s", c256to16_bg[cnt]);
- }
- pti += sprintf(old, "<G%c%c>", pti[2], pti[3]);
- }
- else if (toupper((int) pti[1]) == 'F' && isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && pti[5] == '>')
- {
- if (ses->color == 4096)
- {
- pto += sprintf(pto, "\e[38;2;%d;%d;%dm", c4096_val(pti[2], pti[2]), c4096_val(pti[3], pti[3]), c4096_val(pti[4], pti[4]));
- }
- else if (ses->color == 256)
- {
- pto += sprintf(pto, "\033[38;5;%dm", 16 + c4096_to_256_val(pti[2], pti[2]) * 36 + c4096_to_256_val(pti[3], pti[3]) * 6 + c4096_to_256_val(pti[4], pti[4]));
- }
- else if (ses->color == 16)
- {
- pto += sprintf(pto, "%s", c256to16_fg[16 + c4096_to_256_val(pti[2], pti[2]) * 36 + c4096_to_256_val(pti[3], pti[3]) * 6 + c4096_to_256_val(pti[4], pti[4])]);
- }
- pti += sprintf(old, "<F%c%c%c>", pti[2], pti[3], pti[4]);
- }
- else if (toupper(pti[1]) == 'F' && pti[2] == '?' && pti[3] == '?' && pti[4] == '?' && pti[5] == '>')
- {
- c4096_rnd(ses, &pti[2]);
- if (ses->color == 4096)
- {
- pto += sprintf(pto, "\e[38;2;%d;%d;%dm", c4096_val(pti[2], pti[2]), c4096_val(pti[3], pti[3]), c4096_val(pti[4], pti[4]));
- }
- else if (ses->color == 256)
- {
- pto += sprintf(pto, "\033[38;5;%dm", 16 + c4096_to_256_val(pti[2], pti[2]) * 36 + c4096_to_256_val(pti[3], pti[3]) * 6 + c4096_to_256_val(pti[4], pti[4]));
- }
- else if (ses->color == 16)
- {
- pto += sprintf(pto, "%s", c256to16_fg[16 + c4096_to_256_val(pti[2], pti[2]) * 36 + c4096_to_256_val(pti[3], pti[3]) * 6 + c4096_to_256_val(pti[4], pti[4])]);
- }
- pti += sprintf(old, "<F%c%c%c>", pti[2], pti[3], pti[4]);
- }
- else if (toupper((int) pti[1]) == 'F' && isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && isxdigit(pti[5]) && isxdigit(pti[6]) && isxdigit(pti[7]) && pti[8] == '>')
- {
- if (ses->color == 4096)
- {
- pto += sprintf(pto, "\e[38;2;%d;%d;%dm", c4096_val(pti[2], pti[3]), c4096_val(pti[4], pti[5]), c4096_val(pti[6], pti[7]));
- }
- else if (ses->color == 256)
- {
- pto += sprintf(pto, "\033[38;5;%dm", 16 + c4096_to_256_val(pti[2], pti[3]) * 36 + c4096_to_256_val(pti[4], pti[5]) * 6 + c4096_to_256_val(pti[6], pti[7]));
- }
- else if (ses->color == 16)
- {
- pto += sprintf(pto, "%s", c256to16_fg[16 + c4096_to_256_val(pti[2], pti[3]) * 36 + c4096_to_256_val(pti[4], pti[5]) * 6 + c4096_to_256_val(pti[6], pti[7])]);
- }
- pti += sprintf(old, "<F%c%c%c%c%c%c>", pti[2], pti[3], pti[4], pti[5], pti[6], pti[7]);
- }
- else if (toupper(pti[1]) == 'B' && isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && pti[5] == '>')
- {
- if (ses->color == 4096)
- {
- pto += sprintf(pto, "\e[48;2;%d;%d;%dm", c4096_val(pti[2], pti[2]), c4096_val(pti[3], pti[3]), c4096_val(pti[4], pti[4]));
- }
- else if (ses->color == 256)
- {
- pto += sprintf(pto, "\033[48;5;%dm", 16 + c4096_to_256_val(pti[2], pti[2]) * 36 + c4096_to_256_val(pti[3], pti[3]) * 6 + c4096_to_256_val(pti[4], pti[4]));
- }
- else if (ses->color == 16)
- {
- pto += sprintf(pto, "%s", c256to16_bg[16 + c4096_to_256_val(pti[2], pti[2]) * 36 + c4096_to_256_val(pti[3], pti[3]) * 6 + c4096_to_256_val(pti[4], pti[4])]);
- }
- pti += sprintf(old, "<B%c%c%c>", pti[2], pti[3], pti[4]);
- }
- else if (toupper(pti[1]) == 'B' && pti[2] == '?' && pti[3] == '?' && pti[4] == '?' && pti[5] == '>')
- {
- c4096_rnd(ses, &pti[2]);
- if (ses->color == 4096)
- {
- pto += sprintf(pto, "\e[48;2;%d;%d;%dm", c4096_val(pti[2], pti[2]), c4096_val(pti[3], pti[3]), c4096_val(pti[4], pti[4]));
- }
- else if (ses->color == 256)
- {
- pto += sprintf(pto, "\033[48;5;%dm", 16 + c4096_to_256_val(pti[2], pti[2]) * 36 + c4096_to_256_val(pti[3], pti[3]) * 6 + c4096_to_256_val(pti[4], pti[4]));
- }
- else if (ses->color == 16)
- {
- pto += sprintf(pto, "%s", c256to16_bg[16 + c4096_to_256_val(pti[2], pti[2]) * 36 + c4096_to_256_val(pti[3], pti[3]) * 6 + c4096_to_256_val(pti[4], pti[4])]);
- }
- pti += sprintf(old, "<F%c%c%c>", pti[2], pti[3], pti[4]);
- }
- else if (toupper(pti[1]) == 'B' && isxdigit(pti[2]) && isxdigit(pti[3]) && isxdigit(pti[4]) && isxdigit(pti[5]) && isxdigit(pti[6]) && isxdigit(pti[7]) && pti[8] == '>')
- {
- if (ses->color == 4096)
- {
- pto += sprintf(pto, "\e[48;2;%d;%d;%dm", c4096_val(pti[2], pti[3]), c4096_val(pti[4], pti[5]), c4096_val(pti[6], pti[7]));
- }
- else if (ses->color == 256)
- {
- pto += sprintf(pto, "\033[48;5;%dm", 16 + c4096_to_256_val(pti[2], pti[3]) * 36 + c4096_to_256_val(pti[4], pti[5]) * 6 + c4096_to_256_val(pti[6], pti[7]));
- }
- else if (ses->color == 16)
- {
- pto += sprintf(pto, "%s", c256to16_bg[16 + c4096_to_256_val(pti[2], pti[3]) * 36 + c4096_to_256_val(pti[4], pti[5]) * 6 + c4096_to_256_val(pti[6], pti[7])]);
- }
- pti += sprintf(old, "<B%c%c%c%c%c%c>", pti[2], pti[3], pti[4], pti[5], pti[6], pti[7]);
- }
- else
- {
- *pto++ = *pti++;
- }
- }
- else
- {
- *pto++ = *pti++;
- }
- break;
- case '\\':
- if (HAS_BIT(flags, SUB_ESC))
- {
- pti++;
- switch (*pti)
- {
- case 'a':
- *pto++ = '\a';
- break;
- case 'b':
- *pto++ = '\b';
- break;
- case 'c':
- if (pti[1])
- {
- pti++;
- *pto++ = *pti % 32;
- }
- break;
- case 'e':
- *pto++ = '\e';
- break;
- case 'f':
- *pto++ = '\f';
- break;
- case 'n':
- *pto++ = '\n';
- break;
- case 'r':
- *pto++ = '\r';
- break;
- case 't':
- *pto++ = '\t';
- break;
- case 'x':
- if (pti[1] && pti[2])
- {
- if (pti[1] == '0' && pti[2] == '0' && pti[3] == 0)
- {
- pti += 2;
- DEL_BIT(flags, SUB_EOL);
- DEL_BIT(flags, SUB_LNF);
- }
- else
- {
- pti++;
- *pto++ = hex_number_8bit(pti);
- pti++;
- }
- }
- break;
- case 'u':
- if (pti[1] && pti[2] && pti[3] && pti[4])
- {
- pto += unicode_16_bit(&pti[1], pto);
- pti += 4;
- }
- break;
- case 'U':
- if (pti[1] && pti[2] && pti[3] && pti[4] && pti[5] && pti[6])
- {
- pto += unicode_21_bit(&pti[1], pto);
- pti += 6;
- }
- break;
- case 'v':
- *pto++ = '\v';
- break;
- case '0':
- if (pti[1] == 0)
- {
- DEL_BIT(flags, SUB_EOL);
- DEL_BIT(flags, SUB_LNF);
- }
- else if (pti[1] && pti[2])
- {
- pti++;
- *pto++ = oct_number(pti);
- pti++;
- }
- break;
- case '\0':
- DEL_BIT(flags, SUB_EOL);
- DEL_BIT(flags, SUB_LNF);
- continue;
- default:
- *pto++ = *pti;
- break;
- }
- pti++;
- }
- else if (HAS_BIT(flags, SUB_SEC) && !HAS_BIT(flags, SUB_ARG))
- {
- *pto++ = '\\';
- *pto++ = *pti++;
- }
- else if (HAS_BIT(flags, SUB_LIT))
- {
- *pto++ = *pti++;
- }
- else
- {
- *pto++ = *pti++;
- if (*pti)
- {
- *pto++ = *pti++;
- }
- }
- break;
- case ASCII_ESC:
- if (HAS_BIT(flags, SUB_COL) && ses->color == 0)
- {
- skip = find_color_code(pti);
- if (skip)
- {
- pti += skip;
- }
- else
- {
- *pto++ = *pti++;
- }
- }
- else
- {
- *pto++ = *pti++;
- }
- break;
- default:
- if (HAS_BIT(flags, SUB_SEC) && !HAS_BIT(flags, SUB_ARG))
- {
- switch (*pti)
- {
- case '{':
- *pto++ = '\\';
- *pto++ = 'x';
- *pto++ = '7';
- *pto++ = 'B';
- break;
- case '}':
- *pto++ = '\\';
- *pto++ = 'x';
- *pto++ = '7';
- *pto++ = 'D';
- break;
- case COMMAND_SEPARATOR:
- *pto++ = '\\';
- *pto++ = COMMAND_SEPARATOR;
- break;
- default:
- *pto++ = *pti;
- break;
- }
- pti++;
- }
- else
- {
- *pto++ = *pti++;
- }
- break;
- }
- }
- pop_call();
- return 0;
- }
|