ckuus7.c 511 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422
  1. #include "ckcsym.h"
  2. /* C K U U S 7 -- "User Interface" for C-Kermit, part 7 */
  3. /*
  4. Authors:
  5. Frank da Cruz <fdc@columbia.edu>,
  6. The Kermit Project, New York City
  7. Jeffrey E Altman <jaltman@secure-endpoints.com>
  8. Secure Endpoints Inc., New York City
  9. Copyright (C) 1985, 2017,
  10. Trustees of Columbia University in the City of New York.
  11. All rights reserved. See the C-Kermit COPYING.TXT file or the
  12. copyright text in the ckcmai.c module for disclaimer and permissions.
  13. */
  14. /*
  15. This file created from parts of ckuus3.c, which became too big for
  16. Mark Williams Coherent compiler to handle.
  17. */
  18. /*
  19. Definitions here supersede those from system include files.
  20. */
  21. #include "ckcdeb.h" /* Debugging & compiler things */
  22. #include "ckcasc.h" /* ASCII character symbols */
  23. #include "ckcker.h" /* Kermit application definitions */
  24. #include "ckcxla.h" /* Character set translation */
  25. #include "ckcnet.h" /* Network symbols */
  26. #include "ckuusr.h" /* User interface symbols */
  27. #include "ckucmd.h"
  28. #include "ckclib.h"
  29. #ifdef VMS
  30. #ifndef TCPSOCKET
  31. #include <errno.h>
  32. #endif /* TCPSOCKET */
  33. #endif /* VMS */
  34. #ifdef OS2
  35. #ifndef NT
  36. #define INCL_NOPM
  37. #define INCL_VIO /* Needed for ckocon.h */
  38. #define INCL_DOSMODULEMGR
  39. #include <os2.h>
  40. #undef COMMENT
  41. #else /* NT */
  42. #define APIRET ULONG
  43. #include <windows.h>
  44. #include <tapi.h>
  45. #include "cknwin.h"
  46. #include "ckntap.h"
  47. #endif /* NT */
  48. #include "ckowin.h"
  49. #include "ckocon.h"
  50. #include "ckodir.h"
  51. #ifdef OS2MOUSE
  52. #include "ckokey.h"
  53. #endif /* OS2MOUSE */
  54. #ifdef KUI
  55. #include "ikui.h"
  56. #endif /* KUI */
  57. #ifdef putchar
  58. #undef putchar
  59. #endif /* putchar */
  60. #define putchar(x) conoc(x)
  61. extern int mskkeys;
  62. extern int mskrename;
  63. #endif /* OS2 */
  64. #ifdef CK_AUTHENTICATION
  65. #include "ckuath.h"
  66. #endif /* CK_AUTHENTICATION */
  67. #ifdef CK_SSL
  68. #include "ck_ssl.h"
  69. #endif /* CK_SSL */
  70. #ifdef SSHBUILTIN
  71. #include "ckossh.h"
  72. #endif /* SSHBUILTIN */
  73. #ifdef STRATUS /* Stratus Computer, Inc. VOS */
  74. #ifdef putchar
  75. #undef putchar
  76. #endif /* putchar */
  77. #define putchar(x) conoc(x)
  78. #ifdef getchar
  79. #undef getchar
  80. #endif /* getchar */
  81. #define getchar(x) coninc(0)
  82. #endif /* STRATUS */
  83. char * slmsg = NULL;
  84. static int x, y = 0, z;
  85. static char *s;
  86. extern CHAR feol;
  87. extern int g_matchdot, hints, xcmdsrc, rcdactive;
  88. extern char * k_info_dir;
  89. #ifdef CK_LOGIN
  90. #ifdef CK_PAM
  91. int gotemptypasswd = 0; /* distinguish empty passwd from none given */
  92. #endif /* CK_PAM */
  93. #endif /* CK_LOGIN */
  94. #ifndef NOSPL
  95. extern int nmac;
  96. extern struct mtab *mactab;
  97. #endif /* NOSPL */
  98. #ifndef NOXFER
  99. #ifdef CK_SPEED
  100. extern short ctlp[]; /* Control-char prefixing table */
  101. #endif /* CK_SPEED */
  102. #ifdef PIPESEND
  103. extern char * sndfilter, * g_sfilter;
  104. extern char * rcvfilter, * g_rfilter;
  105. #endif /* PIPESEND */
  106. extern char * snd_move;
  107. extern char * snd_rename;
  108. extern char * g_snd_move;
  109. extern char * g_snd_rename;
  110. extern char * rcv_move;
  111. extern char * rcv_rename;
  112. extern char * g_rcv_move;
  113. extern char * g_rcv_rename;
  114. #ifdef PATTERNS
  115. extern char *binpatterns[], *txtpatterns[];
  116. extern int patterns;
  117. #endif /* PATTERNS */
  118. extern char * remdest;
  119. #ifdef CK_TMPDIR
  120. char * dldir = NULL;
  121. #endif /* CK_TMPDIR */
  122. extern struct ck_p ptab[];
  123. extern int protocol, remfile, rempipe, remappd, reliable, xreliable, fmask,
  124. fncnv, frecl, maxrps, wslotr, bigsbsiz, bigrbsiz, urpsiz, rpsiz, spsiz,
  125. bctr, npad, timef, timint, spsizr, spsizf, maxsps, spmax, nfils, displa,
  126. atcapr, pkttim, rtimo, fncact, mypadn, fdispla, f_save, pktpaus, setreliable,
  127. fnrpath, fnspath, atenci, atenco, atdati, atdato, atleni, atleno, atblki,
  128. atblko, attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;
  129. extern int stathack;
  130. extern int atfrmi, atfrmo;
  131. #ifdef STRATUS
  132. extern int atcrei, atcreo, atacti, atacto;
  133. #endif /* STRATUS */
  134. #ifdef CK_PERMS
  135. extern int atlpri, atlpro, atgpri, atgpro;
  136. #endif /* CK_PERMS */
  137. extern CHAR
  138. sstate, eol, seol, stchr, mystch, mypadc, padch, ctlq, myctlq;
  139. #ifdef IKSD
  140. extern int inserver;
  141. #ifdef IKSDCONF
  142. extern int iksdcf;
  143. #endif /* IKSDCONF */
  144. #endif /* IKSD */
  145. extern char *cmarg, *cmarg2;
  146. #ifndef NOFRILLS
  147. extern char optbuf[]; /* Buffer for MAIL or PRINT options */
  148. extern int rprintf; /* REMOTE PRINT flag */
  149. #endif /* NOFRILLS */
  150. #endif /* NOXFER */
  151. #ifdef CK_TRIGGER
  152. extern char * tt_trigger[];
  153. #endif /* CK_TRIGGER */
  154. extern int tcs_transp;
  155. #ifdef PCTERM
  156. extern int tt_pcterm;
  157. #endif /* PCTERM */
  158. #ifdef NT
  159. extern int tt_vtnt;
  160. #endif /* NT */
  161. #ifdef SSHBUILTIN
  162. int sl_ssh_xfw = 0;
  163. int sl_ssh_xfw_saved = 0;
  164. int sl_ssh_ver = 0;
  165. int sl_ssh_ver_saved = 0;
  166. #endif /* SSHBUILTIN */
  167. #ifdef CK_AUTHENTICATION
  168. extern int auth_type_user[];
  169. int sl_auth_type_user[AUTHTYPLSTSZ] = {AUTHTYPE_NULL, AUTHTYPE_NULL};
  170. int sl_auth_saved = 0;
  171. int sl_topt_a_su = 0;
  172. int sl_topt_a_s_saved = 0;
  173. int sl_topt_a_cm = 0;
  174. int sl_topt_a_c_saved = 0;
  175. #endif /* CK_AUTHENTICATION */
  176. #ifdef CK_ENCRYPTION
  177. extern int cx_type;
  178. int sl_cx_type = 0;
  179. int sl_cx_saved = 0;
  180. int sl_topt_e_su = 0;
  181. int sl_topt_e_sm = 0;
  182. int sl_topt_e_s_saved = 0;
  183. int sl_topt_e_cu = 0;
  184. int sl_topt_e_cm = 0;
  185. int sl_topt_e_c_saved = 0;
  186. #endif /* CK_ENCRYPTION */
  187. extern char uidbuf[];
  188. static int uidflag = 0;
  189. char sl_uidbuf[UIDBUFLEN] = { NUL, NUL };
  190. int sl_uid_saved = 0;
  191. #ifdef TNCODE
  192. int sl_tn_wait = 0;
  193. int sl_tn_saved = 0;
  194. #endif /* TNCODE */
  195. #ifdef TNCODE
  196. extern int tn_wait_flg;
  197. #endif /* TNCODE */
  198. VOID
  199. slrestor() {
  200. #ifdef CK_AUTHENTICATION
  201. int x;
  202. if (sl_auth_saved) {
  203. for (x = 0; x < AUTHTYPLSTSZ; x++)
  204. auth_type_user[x] = sl_auth_type_user[x];
  205. sl_auth_saved = 0;
  206. }
  207. if (sl_topt_a_s_saved) {
  208. TELOPT_DEF_S_U_MODE(TELOPT_AUTHENTICATION) = sl_topt_a_su;
  209. sl_topt_a_s_saved = 0;
  210. }
  211. if (sl_topt_a_c_saved) {
  212. TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = sl_topt_a_cm;
  213. sl_topt_a_c_saved = 0;
  214. }
  215. #endif /* CK_AUTHENTICATION */
  216. #ifdef CK_ENCRYPTION
  217. if (sl_cx_saved) {
  218. cx_type = sl_cx_type;
  219. sl_cx_saved = 0;
  220. }
  221. if (sl_topt_e_s_saved) {
  222. TELOPT_DEF_S_U_MODE(TELOPT_ENCRYPTION) = sl_topt_e_su;
  223. TELOPT_DEF_S_ME_MODE(TELOPT_ENCRYPTION) = sl_topt_e_sm;
  224. sl_topt_e_s_saved = 0;
  225. }
  226. if (sl_topt_e_c_saved) {
  227. TELOPT_DEF_C_U_MODE(TELOPT_ENCRYPTION) = sl_topt_e_cu;
  228. TELOPT_DEF_C_ME_MODE(TELOPT_ENCRYPTION) = sl_topt_e_cm;
  229. sl_topt_e_c_saved = 0;
  230. }
  231. #endif /* CK_ENCRYPTION */
  232. if (sl_uid_saved) {
  233. ckstrncpy(uidbuf,sl_uidbuf,UIDBUFLEN);
  234. sl_uid_saved = 0;
  235. }
  236. #ifdef TNCODE
  237. if (sl_tn_saved) {
  238. tn_wait_flg = sl_tn_wait;
  239. sl_tn_saved = 0;
  240. }
  241. #endif /* TNCODE */
  242. #ifdef SSHBUILTIN
  243. if (sl_ssh_xfw_saved) {
  244. ssh_xfw = sl_ssh_xfw;
  245. sl_ssh_xfw_saved = 0;
  246. }
  247. if (sl_ssh_ver_saved) {
  248. ssh_ver = sl_ssh_ver;
  249. sl_ssh_ver_saved = 0;
  250. }
  251. #endif /* SSHBUILTIN */
  252. }
  253. int oldplex = -1; /* Duplex holder around network */
  254. #ifndef NOICP
  255. #ifdef LOCUS
  256. extern int locus, autolocus;
  257. #endif /* LOCUS */
  258. #ifndef NODIAL
  259. extern int dialsta;
  260. #endif /* NODIAL */
  261. /* Note: gcc -Wall wants braces around each keyword table entry. */
  262. static struct keytab psltab[] = { /* SET LINE/PORT command options */
  263. { "/connect", SL_CNX, 0 },
  264. #ifdef OS2ORVMS
  265. { "/noshare", SL_NSH, 0 },
  266. #endif /* OS2ORVMS */
  267. { "/server", SL_SRV, 0 },
  268. #ifdef OS2ORVMS
  269. { "/share", SL_SHR, 0 },
  270. #endif /* OS2ORVMS */
  271. { "", 0, 0 }
  272. };
  273. static int npsltab = sizeof(psltab)/sizeof(struct keytab) - 1;
  274. #ifdef NETCONN
  275. static struct keytab shtab[] = { /* SET HOST command options */
  276. #ifdef NETCMD
  277. /* (COMMAND is also a network type) */
  278. { "/command", SL_CMD, CM_INV },
  279. #endif /* NETCMD */
  280. { "/connect", SL_CNX, 0 },
  281. { "/network-type", SL_NET, CM_ARG },
  282. { "/nowait", SL_NOWAIT, 0 },
  283. #ifndef NOSPL
  284. #ifdef CK_AUTHENTICATION
  285. { "/password", SL_PSW, CM_ARG },
  286. #endif /* CK_AUTHENTICATION */
  287. #endif /* NOSPL */
  288. #ifdef NETCMD
  289. { "/pipe", SL_CMD, 0 },
  290. #endif /* NETCMD */
  291. #ifdef NETPTY
  292. { "/pty", SL_PTY, 0 },
  293. #endif /* NETPTY */
  294. { "/server", SL_SRV, 0 },
  295. { "/timeout", SL_TMO, CM_ARG },
  296. { "/userid", SL_UID, CM_ARG },
  297. { "/wait", SL_WAIT, 0 },
  298. { "", 0, 0 }
  299. };
  300. static int nshtab = sizeof(shtab)/sizeof(struct keytab) - 1;
  301. static struct keytab shteltab[] = { /* TELNET command options */
  302. #ifdef CK_AUTHENTICATION
  303. { "/auth", SL_AUTH, CM_ARG },
  304. #endif /* CK_AUTHENTICATION */
  305. #ifdef CK_ENCRYPTION
  306. { "/encrypt", SL_ENC, CM_ARG },
  307. #endif /* CK_ENCRYPTION */
  308. { "/nowait", SL_NOWAIT, 0 },
  309. #ifndef NOSPL
  310. #ifdef CK_AUTHENTICATION
  311. { "/password", SL_PSW, CM_ARG },
  312. #endif /* CK_AUTHENTICATION */
  313. #endif /* NOSPL */
  314. { "/timeout", SL_TMO, CM_ARG },
  315. { "/userid", SL_UID, CM_ARG },
  316. { "/wait", SL_WAIT, 0 },
  317. { "", 0 ,0 }
  318. };
  319. static int nshteltab = sizeof(shteltab)/sizeof(struct keytab) - 1;
  320. #ifdef RLOGCODE
  321. static struct keytab shrlgtab[] = { /* SET HOST RLOGIN command options */
  322. #ifdef CK_KERBEROS
  323. #ifdef CK_ENCRYPTION
  324. { "/encrypt", SL_ENC, 0 },
  325. #endif /* CK_ENCRYPTION */
  326. { "/k4", SL_KRB4, CM_INV },
  327. { "/k5", SL_KRB5, CM_INV },
  328. { "/kerberos4", SL_KRB4, 0 },
  329. { "/kerberos5", SL_KRB5, 0 },
  330. { "/kerberos_iv", SL_KRB4, CM_INV },
  331. { "/kerberos_v", SL_KRB5, CM_INV },
  332. { "/krb4", SL_KRB4, CM_INV },
  333. { "/krb5", SL_KRB5, CM_INV },
  334. #endif /* CK_KERBEROS */
  335. { "", 0 ,0 }
  336. };
  337. static int nshrlgtab = sizeof(shrlgtab)/sizeof(struct keytab)-1;
  338. #endif /* RLOGCODE */
  339. extern struct keytab netcmd[];
  340. extern int nnets;
  341. #ifndef NODIAL
  342. extern int dirline;
  343. extern int nnetdir; /* Network services directory */
  344. extern char *netdir[];
  345. _PROTOTYP( VOID ndreset, (void) );
  346. char *nh_p[MAXDNUMS + 1]; /* Network directory entry pointers */
  347. char *nh_p2[MAXDNUMS + 1]; /* Network directory entry nettype */
  348. char *nh_px[4][MAXDNUMS + 1]; /* Network-specific stuff... */
  349. #endif /* NODIAL */
  350. int nhcount = 0;
  351. int ndinited = 0;
  352. char * n_name = NULL; /* Network name pointer */
  353. #endif /* NETCONN */
  354. _PROTOTYP(int remtxt, (char **) );
  355. _PROTOTYP(VOID rmsg, (void) );
  356. _PROTOTYP(static int remcfm, (void) );
  357. extern int nopush;
  358. int mdmsav = -1; /* Save modem type around network */
  359. extern int isguest; /* Global flag for anonymous login */
  360. extern xx_strp xxstring;
  361. extern int success, binary, b_save, ckwarn, msgflg, quiet, cmask, pflag, local,
  362. nettype, escape, mdmtyp, duplex, dfloc, network, cdtimo, autoflow, tnlm,
  363. sosi, tlevel, lf_opts, backgrd, flow, debses, parity, ttnproto, ckxech,
  364. x_ifnum, cmflgs, haveline, cxtype, cxflow[], maclvl;
  365. #ifdef DCMDBUF
  366. extern struct cmdptr *cmdstk; /* The command stack itself */
  367. #else
  368. extern struct cmdptr cmdstk[]; /* The command stack itself */
  369. #endif /* DCMDBUF */
  370. extern FILE * tfile[];
  371. extern char * macp[];
  372. extern char psave[]; /* For saving & restoring prompt */
  373. extern int sprmlen, rprmlen;
  374. #ifdef OS2
  375. static struct keytab strmkeytab[] = {
  376. { "clear", 0, 0 },
  377. { "default", 1, 0 }
  378. };
  379. static int nstrmkeytab = sizeof(strmkeytab)/sizeof(struct keytab);
  380. static struct keytab strmswitab[] = {
  381. { "/literal", 0, 0 }
  382. };
  383. static int nstrmswitab = sizeof(strmswitab)/sizeof(struct keytab);
  384. static struct keytab normrev[] = {
  385. { "dark-display", 0, 0 },
  386. { "light-display", 1, 0 },
  387. { "normal", 0, 0 },
  388. { "reverse", 1, 0 }
  389. };
  390. static struct keytab prnmtab[] = {
  391. { "auto", 1, 0 },
  392. { "copy", 2, 0 },
  393. { "off", 0, 0 },
  394. { "on", 1, CM_INV }, /* Compatibility with XPRINT version */
  395. { "user", 3, 0 },
  396. { "transparent", 3, CM_INV } /* not really transparent */
  397. };
  398. static int nprnmtab = sizeof(prnmtab)/sizeof(struct keytab);
  399. extern int tt_diff_upd;
  400. #ifdef NT
  401. #define stricmp _stricmp
  402. extern int tt_attr_bug;
  403. #endif /* NT */
  404. extern int tt_rows[], tt_cols[];
  405. extern int tt_cols_usr;
  406. extern int tt_szchng[VNUM];
  407. int tt_modechg = TVC_ENA;
  408. extern int tt_url_hilite, tt_url_hilite_attr;
  409. extern struct _vtG G[4];
  410. extern int priority;
  411. extern bool send_c1;
  412. int send_c1_usr = FALSE;
  413. extern int sgrcolors;
  414. extern int marginbell, marginbellcol;
  415. extern int autoscroll, wy_autopage;
  416. extern int tt_sac;
  417. extern int dec_nrc, dec_lang, dec_kbd;
  418. #else /* OS2 */
  419. extern int tt_rows, tt_cols;
  420. #endif /* OS2 */
  421. extern int tt_escape;
  422. extern long speed;
  423. extern char *dftty;
  424. extern char *tp, *lp; /* Temporary buffer & pointers */
  425. extern char ttname[];
  426. #ifdef CK_TAPI
  427. int tttapi = 0; /* is Line TAPI? */
  428. struct keytab * tapilinetab = NULL;
  429. struct keytab * _tapilinetab = NULL;
  430. int ntapiline = 0;
  431. #endif /* CK_TAPI */
  432. #ifdef NETCONN /* Network items */
  433. #ifdef ANYX25
  434. extern int revcall, closgr, cudata, nx25;
  435. extern char udata[];
  436. extern struct keytab x25tab[];
  437. #ifndef IBMX25
  438. extern int npadx3;
  439. extern CHAR padparms[];
  440. extern struct keytab padx3tab[];
  441. #endif /* IBMX25 */
  442. #endif /* ANYX25 */
  443. #ifdef OS2
  444. extern bool ttshare;
  445. #ifndef NT
  446. extern bool ttslip,ttppp;
  447. #endif /* NT */
  448. #endif /* OS2 */
  449. #ifdef NPIPE
  450. extern char pipename[];
  451. #endif /* NPIPE */
  452. #ifdef TCPSOCKET
  453. static struct keytab tcprawtab[] = { /* SET HOST options */
  454. { "/default", NP_DEFAULT, CM_INV },
  455. #ifdef CK_AUTHENTICATION
  456. #ifdef CK_KERBEROS
  457. #ifdef RLOGCODE
  458. { "/ek4login", NP_EK4LOGIN, 0 },
  459. { "/ek5login", NP_EK5LOGIN, 0 },
  460. { "/k4login", NP_K4LOGIN, 0 },
  461. { "/k5login", NP_K5LOGIN, 0 },
  462. #endif /* RLOGCODE */
  463. #ifdef KRB5_U2U
  464. { "/k5user2user", NP_K5U2U, 0 },
  465. #endif /* KRB5_U2U */
  466. #endif /* CK_KERBEROS */
  467. #endif /* CK_AUTHENTICATION */
  468. { "/no-telnet-init", NP_NONE, 0 },
  469. { "/none", NP_NONE, CM_INV },
  470. { "/raw-socket", NP_TCPRAW, 0 },
  471. #ifdef RLOGCODE
  472. { "/rlogin", NP_RLOGIN, 0 },
  473. #endif /* RLOGCODE */
  474. #ifdef CK_SSL
  475. { "/ssl", NP_SSL, 0 },
  476. { "/ssl-raw", NP_SSL_RAW, 0 },
  477. { "/ssl-telnet", NP_SSL_TELNET, 0 },
  478. #endif /* CK_SSL */
  479. { "/telnet", NP_TELNET, 0 },
  480. #ifdef CK_SSL
  481. { "/tls", NP_TLS, 0 },
  482. { "/tls-raw", NP_TLS_RAW, 0 },
  483. { "/tls-telnet", NP_TLS_TELNET, 0 },
  484. #endif /* CK_SSL */
  485. { "", 0, 0 }
  486. };
  487. static int ntcpraw = (sizeof(tcprawtab) / sizeof(struct keytab)) - 1;
  488. #ifdef RLOGCODE
  489. _PROTOTYP( int rlog_naws, (void) );
  490. #endif /* RLOGCODE */
  491. #endif /* TCPSOCKET */
  492. #ifdef SUPERLAT
  493. extern char slat_pwd[18];
  494. #endif /* SUPERLAT */
  495. #endif /* NETCONN */
  496. #ifdef COMMENT
  497. #ifndef NOSETKEY
  498. extern KEY *keymap;
  499. #ifndef OS2
  500. #define mapkey(x) keymap[x]
  501. #endif /* OS2 */
  502. extern MACRO *macrotab;
  503. #ifndef NOKVERBS
  504. extern struct keytab kverbs[];
  505. extern int nkverbs;
  506. #endif /* NOKVERBS */
  507. #endif /* NOSETKEY */
  508. #else
  509. #ifndef NOSETKEY
  510. extern KEY *keymap;
  511. extern MACRO *macrotab;
  512. #ifndef NOKVERBS
  513. extern struct keytab kverbs[];
  514. extern int nkverbs;
  515. #endif /* NOKVERBS */
  516. #endif /* NOSETKEY */
  517. #endif /* COMMENT */
  518. #ifdef OS2 /* AUTODOWNLOAD parameters */
  519. extern int adl_kmode, adl_zmode; /* Match Packet to signal download */
  520. extern char * adl_kstr; /* KERMIT Download String */
  521. extern char * adl_zstr; /* ZMODEM Download String */
  522. extern int adl_kc0, adl_zc0; /* Process ADL C0s in emulation */
  523. #endif /* OS2 */
  524. /* Keyword tables ... */
  525. extern struct keytab onoff[], rltab[];
  526. extern int nrlt;
  527. #ifndef NOCSETS
  528. static struct keytab fdfltab[] = {
  529. { "7bit-character-set", 7, 0 },
  530. { "8bit-character-set", 8, 0 }
  531. };
  532. static int nfdflt = (sizeof(fdfltab) / sizeof(struct keytab));
  533. #endif /* NOCSETS */
  534. /* SET FILE parameters */
  535. static struct keytab filtab[] = {
  536. #ifndef NOXFER
  537. #ifdef PATTERNS
  538. { "binary-patterns", XYFIBP, 0 },
  539. #endif /* PATTERNS */
  540. { "bytesize", XYFILS, 0 },
  541. #ifndef NOCSETS
  542. { "character-set", XYFILC, 0 },
  543. #endif /* NOCSETS */
  544. { "collision", XYFILX, 0 },
  545. { "default", XYF_DFLT, 0 },
  546. { "destination", XYFILY, 0 },
  547. { "display", XYFILD, CM_INV },
  548. #ifdef CK_TMPDIR
  549. { "download-directory", XYFILG, 0 },
  550. #endif /* CK_TMPDIR */
  551. #endif /* NOXFER */
  552. { "end-of-line", XYFILA, 0 },
  553. { "eol", XYFILA, CM_INV },
  554. #ifdef CK_CTRLZ
  555. { "eof", XYFILV, 0 },
  556. #endif /* CK_CTRLZ */
  557. #ifndef NOXFER
  558. { "fastlookups", 9997, CM_INV },
  559. { "incomplete", XYFILI, 0 },
  560. #ifndef datageneral
  561. { "inspection", XYF_INSP, CM_INV },
  562. #endif /* datageneral */
  563. #ifdef CK_LABELED
  564. { "label", XYFILL, 0 },
  565. #endif /* CK_LABELED */
  566. #ifdef UNIX
  567. #ifdef DYNAMIC
  568. { "listsize", XYF_LSIZ, 0 },
  569. #endif /* DYNAMIC */
  570. #endif /* UNIX */
  571. { "names", XYFILN, 0 },
  572. #ifdef UNIX
  573. { "output", XYFILH, 0 },
  574. #endif /* UNIX */
  575. #ifdef PATTERNS
  576. { "patterns", XYFIPA, 0 },
  577. #endif /* PATTERNS */
  578. #ifdef COMMENT /* Not implemented (but see CHMOD) */
  579. { "permissions", XYF_PRM, CM_INV },
  580. { "protection", XYF_PRM, 0 },
  581. #endif /* COMMENt */
  582. #ifdef VMS
  583. { "record-length", XYFILR, 0 },
  584. #endif /* VMS */
  585. #ifndef datageneral
  586. { "scan", XYF_INSP, 0 },
  587. #endif /* datageneral */
  588. #ifdef UNIX
  589. #ifdef DYNAMIC
  590. { "stringspace", XYF_SSPA, 0 },
  591. #endif /* DYNAMIC */
  592. #endif /* UNIX */
  593. #ifdef PATTERNS
  594. { "t", XYFILT, CM_INV|CM_ABR },
  595. { "text-patterns", XYFITP, 0 },
  596. #endif /* PATTERNS */
  597. #endif /* NOXFER */
  598. { "type", XYFILT, 0 },
  599. #ifdef UNICODE
  600. { "ucs", XYFILU, 0 },
  601. #endif /* UNICODE */
  602. #ifndef NOXFER
  603. { "warning", XYFILW, CM_INV }
  604. #endif /* NOXFER */
  605. };
  606. static int nfilp = (sizeof(filtab) / sizeof(struct keytab));
  607. struct keytab pathtab[] = {
  608. { "absolute", PATH_ABS, 0 },
  609. { "none", PATH_OFF, CM_INV },
  610. { "off", PATH_OFF, 0 },
  611. { "on", PATH_ABS, CM_INV },
  612. { "relative", PATH_REL, 0 }
  613. };
  614. int npathtab = (sizeof(pathtab) / sizeof(struct keytab));
  615. struct keytab rpathtab[] = {
  616. { "absolute", PATH_ABS, 0 },
  617. { "auto", PATH_AUTO, 0 },
  618. { "none", PATH_OFF, CM_INV },
  619. { "off", PATH_OFF, 0 },
  620. { "on", PATH_ABS, CM_INV },
  621. { "relative", PATH_REL, 0 }
  622. };
  623. int nrpathtab = (sizeof(rpathtab) / sizeof(struct keytab));
  624. #ifdef CK_CTRLZ
  625. struct keytab eoftab[] = { /* EOF detection method */
  626. { "ctrl-z", 1, 0 },
  627. { "length", 0, 0 },
  628. { "noctrl-z", 0, CM_INV }
  629. };
  630. #endif /* CK_CTRLZ */
  631. struct keytab fttab[] = { /* File types for SET FILE TYPE */
  632. { "ascii", XYFT_T, CM_INV },
  633. #ifdef VMS
  634. { "b", XYFT_B, CM_INV|CM_ABR },
  635. #endif /* VMS */
  636. { "binary", XYFT_B, 0 },
  637. #ifdef VMS
  638. { "block", XYFT_I, CM_INV },
  639. { "image", XYFT_I, 0 },
  640. #endif /* VMS */
  641. #ifdef CK_LABELED
  642. { "labeled", XYFT_L, 0 },
  643. #endif /* CK_LABELED */
  644. #ifdef MAC
  645. { "macbinary", XYFT_M, 0 },
  646. #endif /* MAC */
  647. { "text", XYFT_T, 0 }
  648. };
  649. int nfttyp = (sizeof(fttab) / sizeof(struct keytab));
  650. static struct keytab rfttab[] = { /* File types for REMOTE SET FILE */
  651. { "ascii", XYFT_T, CM_INV },
  652. { "binary", XYFT_B, 0 },
  653. #ifdef VMS
  654. { "labeled", XYFT_L, 0 },
  655. #else
  656. #ifdef OS2
  657. { "labeled", XYFT_L, 0 },
  658. #endif /* OS2 */
  659. #endif /* VMS */
  660. { "text", XYFT_T, 0 }
  661. };
  662. static int nrfttyp = (sizeof(rfttab) / sizeof(struct keytab));
  663. #ifdef OS2ORUNIX
  664. #define ZOF_BLK 0
  665. #define ZOF_NBLK 1
  666. #define ZOF_BUF 2
  667. #define ZOF_NBUF 3
  668. static struct keytab zoftab[] = {
  669. { "blocking", ZOF_BLK, 0 },
  670. { "buffered", ZOF_BUF, 0 },
  671. { "nonblocking", ZOF_NBLK, 0 },
  672. { "unbuffered", ZOF_NBUF, 0 }
  673. };
  674. static int nzoftab = (sizeof(zoftab) / sizeof(struct keytab));
  675. #endif /* OS2ORUNIX */
  676. extern int query; /* Global flag for QUERY active */
  677. #ifndef NOSPL
  678. #ifndef NOXFER
  679. static struct keytab vartyp[] = { /* Variable types for REMOTE QUERY */
  680. { "global", (int) 'G', CM_INV },
  681. { "kermit", (int) 'K', 0 },
  682. { "system", (int) 'S', 0 },
  683. { "user", (int) 'G', 0 }
  684. };
  685. static int nvartyp = (sizeof(vartyp) / sizeof(struct keytab));
  686. #endif /* NOXFER */
  687. #endif /* NOSPL */
  688. #ifdef CK_TIMERS
  689. static struct keytab timotab[] = { /* Timer types */
  690. { "dynamic", 1, 0 },
  691. { "fixed", 0, 0 }
  692. };
  693. #endif /* CK_TIMERS */
  694. #ifdef DCMDBUF
  695. extern char *atxbuf, *atmbuf; /* Atom buffer */
  696. extern char *cmdbuf; /* Command buffer */
  697. extern char *line, *tmpbuf; /* Character buffers for anything */
  698. extern int *intime; /* INPUT TIMEOUT */
  699. #else /* Not DCMDBUF ... */
  700. extern char atxbuf[], atmbuf[]; /* Atom buffer */
  701. extern char cmdbuf[]; /* Command buffer */
  702. extern char line[], tmpbuf[]; /* Character buffer for anything */
  703. extern int intime[];
  704. #endif /* DCMDBUF */
  705. #ifndef NOCSETS
  706. extern struct keytab fcstab[]; /* For SET FILE CHARACTER-SET */
  707. extern struct csinfo fcsinfo[]; /* File character set info. */
  708. extern struct keytab ttcstab[];
  709. extern int nfilc, fcharset, tcharset, ntermc, tcsr, tcsl, dcset7, dcset8;
  710. #ifdef CKOUNI
  711. extern int tt_utf8;
  712. #endif /* CKOUNI */
  713. #ifdef OS2
  714. _PROTOTYP( int os2setcp, (int) );
  715. _PROTOTYP( int os2getcp, (void) );
  716. _PROTOTYP( void os2debugoff, (void) );
  717. #endif /* OS2 */
  718. #endif /* NOCSETS */
  719. extern int cmdlvl; /* Overall command level */
  720. #ifndef NOSPL
  721. #ifdef DCMDBUF
  722. extern int *inpcas; /* INPUT CASE setting on cmd stack */
  723. #else
  724. extern int inpcas[];
  725. #endif /* DCMDBUF */
  726. #endif /* NOSPL */
  727. #ifdef CK_CURSES
  728. #ifndef VMS
  729. _PROTOTYP(int tgetent,(char *, char *));
  730. #else
  731. #ifdef __DECC
  732. _PROTOTYP(int tgetent,(char *, char *));
  733. #endif /* __DECC */
  734. #endif /* VMS */
  735. #endif /* CK_CURSES */
  736. #ifndef NOXMIT
  737. #define XMITF 0 /* SET TRANSMIT values */
  738. #define XMITL 1 /* (Local to this module) */
  739. #define XMITP 2
  740. #define XMITE 3
  741. #define XMITX 4
  742. #define XMITS 5
  743. #define XMITW 6
  744. #define XMITT 7
  745. #define XMBUFL 50
  746. extern int xmitf, xmitl, xmitp, xmitx, xmits, xmitw, xmitt;
  747. char xmitbuf[XMBUFL+1] = { NUL }; /* TRANSMIT eof string */
  748. struct keytab xmitab[] = { /* SET TRANSMIT */
  749. { "echo", XMITX, 0 },
  750. { "eof", XMITE, 0 },
  751. { "fill", XMITF, 0 },
  752. { "linefeed", XMITL, 0 },
  753. { "locking-shift", XMITS, 0 },
  754. { "pause", XMITW, 0 },
  755. { "prompt", XMITP, 0 },
  756. { "timeout", XMITT, 0 }
  757. };
  758. int nxmit = (sizeof(xmitab) / sizeof(struct keytab));
  759. #endif /* NOXMIT */
  760. /* For SET FILE COLLISION */
  761. /* Some of the following may be possible for some C-Kermit implementations */
  762. /* but not others. Those that are not possible for your implementation */
  763. /* should be ifdef'd out. */
  764. struct keytab colxtab[] = { /* SET FILE COLLISION options */
  765. #ifndef MAC
  766. { "append", XYFX_A, 0 }, /* append to old file */
  767. #endif /* MAC */
  768. #ifdef COMMENT
  769. { "ask", XYFX_Q, 0 }, /* ask what to do (not implemented) */
  770. #endif
  771. { "backup", XYFX_B, 0 }, /* rename old file */
  772. #ifndef MAC
  773. /* This crashes Mac Kermit. */
  774. { "discard", XYFX_D, CM_INV }, /* don't accept new file */
  775. { "no-supersede", XYFX_D, CM_INV }, /* ditto (MSK compatibility) */
  776. #endif /* MAC */
  777. { "overwrite", XYFX_X, 0 }, /* overwrite the old file */
  778. { "reject", XYFX_D, 0 }, /* (better word than discard) */
  779. { "rename", XYFX_R, 0 }, /* rename the incoming file */
  780. #ifndef MAC /* This crashes Mac Kermit. */
  781. { "update", XYFX_U, 0 }, /* replace if newer */
  782. #endif /* MAC */
  783. { "", 0, 0 }
  784. };
  785. int ncolx = (sizeof(colxtab) / sizeof(struct keytab)) - 1;
  786. static struct keytab rfiltab[] = { /* for REMOTE SET FILE */
  787. #ifndef NOCSETS
  788. { "character-set", XYFILC, 0 },
  789. #endif /* NOCSETS */
  790. { "collision", XYFILX, 0 },
  791. { "incomplete", XYFILI, 0 },
  792. { "names", XYFILN, 0 },
  793. { "record-length", XYFILR, 0 },
  794. { "type", XYFILT, 0 }
  795. };
  796. int nrfilp = (sizeof(rfiltab) / sizeof(struct keytab));
  797. struct keytab eoltab[] = { /* File eof delimiters */
  798. { "cr", XYFA_C, 0 },
  799. { "crlf", XYFA_2, 0 },
  800. { "lf", XYFA_L, 0 }
  801. };
  802. static int neoltab = (sizeof(eoltab) / sizeof(struct keytab));
  803. struct keytab fntab[] = { /* File naming */
  804. { "converted", XYFN_C, 0 },
  805. { "literal", XYFN_L, 0 },
  806. { "standard", XYFN_C, CM_INV }
  807. };
  808. int nfntab = (sizeof(fntab) / sizeof(struct keytab));
  809. #ifndef NOLOCAL
  810. /* Terminal parameters table */
  811. static struct keytab trmtab[] = {
  812. #ifdef OS2
  813. { "answerback", XYTANS, 0 },
  814. #endif /* OS2 */
  815. #ifdef CK_APC
  816. { "apc", XYTAPC, 0 },
  817. #endif /* CK_APC */
  818. #ifdef OS2
  819. { "arrow-keys", XYTARR, 0 },
  820. #endif /* OS2 */
  821. #ifdef NT
  822. { "at", XYTATTR, CM_INV|CM_ABR },
  823. { "att", XYTATTR, CM_INV|CM_ABR },
  824. { "attr", XYTATTR, CM_INV|CM_ABR },
  825. { "attr-bug", XYTATTBUG, CM_INV },
  826. #endif /* NT */
  827. #ifdef OS2
  828. { "attribute", XYTATTR, 0 },
  829. #endif /* OS2 */
  830. #ifdef CK_APC
  831. #ifdef CK_AUTODL
  832. { "autodownload", XYTAUTODL, 0, },
  833. #endif /* CK_AUTODL */
  834. #endif /* CK_APC */
  835. #ifdef OS2
  836. { "autopage", XYTAPAGE, 0 },
  837. { "autoscroll", XYTASCRL, 0 },
  838. { "bell", XYTBEL, CM_INV },
  839. #endif /* OS2 */
  840. { "bytesize", XYTBYT, 0 },
  841. #ifndef NOCSETS
  842. { "character-set", XYTCS, 0 },
  843. #endif /* NOCSETS */
  844. #ifdef OS2
  845. { "code-page", XYTCPG, 0 },
  846. { "color", XYTCOL, 0 },
  847. { "controls", XYTCTRL, 0 },
  848. #endif /* OS2 */
  849. { "cr-display", XYTCRD, 0 },
  850. #ifdef OS2
  851. { "cursor", XYTCUR, 0 },
  852. #endif /* OS2 */
  853. { "debug", XYTDEB, 0 },
  854. #ifdef OS2
  855. { "dg-unix-mode", XYTUNX, 0 },
  856. #endif /* OS2 */
  857. { "echo", XYTEC, 0 },
  858. { "escape-character", XYTESC, 0 },
  859. #ifdef OS2
  860. #ifdef PCFONTS
  861. { "font", XYTFON, 0 },
  862. #else
  863. #ifdef KUI
  864. { "font", XYTFON, 0 },
  865. #endif /* KUI */
  866. #endif /* PCFONTS */
  867. #endif /* OS2 */
  868. { "height", XYTHIG, 0 },
  869. #ifdef CKTIDLE
  870. { "idle-action", XYTIACT, 0 },
  871. { "idle-limit", XYTITMO, CM_INV },
  872. { "idle-send", XYTIDLE, CM_INV },
  873. { "idle-timeout", XYTITMO, 0 },
  874. #endif /* CKTIDLE */
  875. #ifdef OS2
  876. #ifndef NOCSETS
  877. { "kbd-follows-gl/gr", XYTKBDGL, 0 },
  878. #endif /* NOCSETS */
  879. { "key", XYTKEY, 0 },
  880. { "keyboard-mode", XYTKBMOD, 0 },
  881. { "keypad-mode", XYTKPD, 0 },
  882. #endif /* OS2 */
  883. { "lf-display", XYTLFD, 0 },
  884. #ifndef NOCSETS
  885. #ifdef OS2
  886. #ifndef KUI
  887. { "line-spacing", XYTLSP, CM_INV },
  888. { "local-character-set", XYTLCS, 0 },
  889. #else
  890. { "line-spacing", XYTLSP, 0 },
  891. { "local-character-set", XYTLCS, CM_INV },
  892. #endif /* KUI */
  893. #else
  894. { "local-character-set", XYTLCS, CM_INV },
  895. #endif /* OS2 */
  896. #endif /* NOCSETS */
  897. { "locking-shift", XYTSO, 0 },
  898. #ifdef OS2
  899. { "margin-bell", XYTMBEL, 0 },
  900. #endif /* OS2 */
  901. #ifdef OS2MOUSE
  902. { "mouse", XYTMOU, CM_INV },
  903. #endif /* OS2MOUSE */
  904. { "newline-mode", XYTNL, 0 },
  905. #ifdef OS2
  906. { "output-pacing", XYTPAC, 0 },
  907. #ifdef PCTERM
  908. { "pcterm", XYTPCTERM, 0 },
  909. #endif /* PCTERM */
  910. #endif /* OS2 */
  911. #ifdef OS2ORUNIX
  912. { "print", XYTPRN, 0 },
  913. #endif /* OS2ORUNIX */
  914. #ifndef NOCSETS
  915. #ifdef OS2
  916. { "remote-character-set", XYTRCS, 0 },
  917. #else
  918. { "remote-character-set", XYTRCS, CM_INV },
  919. #endif /* OS2 */
  920. #endif /* NOCSETS */
  921. #ifdef OS2
  922. { "roll-mode", XYTROL, 0 },
  923. { "s", XYTUPD, CM_ABR|CM_INV },
  924. { "sc", XYTUPD, CM_ABR|CM_INV },
  925. { "scr", XYTUPD, CM_ABR|CM_INV },
  926. { "scree", XYTUPD, CM_ABR|CM_INV },
  927. { "screen", XYTUPD, CM_ABR|CM_INV },
  928. { "screen-", XYTUPD, CM_ABR|CM_INV },
  929. { "screen-mode", XYTSCNM, 0 },
  930. { "screen-optimize", XYTOPTI, 0 },
  931. { "screen-update", XYTUPD, 0 },
  932. { "scrollback", XYSCRS, 0 },
  933. { "send-data", XYTSEND, 0 },
  934. { "send-end-of-block", XYTSEOB, 0 },
  935. { "sgr-colors", XYTSGRC, 0 },
  936. { "sni-ch.code", XYTSNICC, 0 },
  937. { "sni-firmware-versions", XYTSNIFV, 0 },
  938. { "sni-language", XYTVTLNG, 0 },
  939. { "sni-pagemode", XYTSNIPM, CM_INV },
  940. { "sni-scrollmode", XYTSNISM, CM_INV },
  941. { "spacing-attribute-character", XYTSAC, CM_INV },
  942. { "statusline", XYTSTAT, 0 },
  943. { "tra", XYTCTS, CM_INV|CM_ABR },
  944. { "transmit-timeout", XYTCTS, 0 },
  945. #endif /* OS2 */
  946. #ifdef OS2ORUNIX
  947. { "transparent-print", XYTPRN, CM_INV },
  948. #endif /* OS2ORUNIX */
  949. #ifdef CK_TRIGGER
  950. { "trigger", XYTRIGGER,0 },
  951. #endif /* CK_TRIGGER */
  952. #ifdef OS2
  953. { "type", XYTTYP, 0 },
  954. #else
  955. { "type", XYTTYP, CM_INV },
  956. #endif /* OS2 */
  957. #ifndef NOCSETS
  958. #ifdef UNICODE
  959. #ifdef CKOUNI
  960. { "unicode", XYTUNI, CM_INV },
  961. #endif /* CKOUNI */
  962. #endif /* UNICODE */
  963. #endif /* NOCSETS */
  964. #ifdef OS2
  965. { "unix-mode", XYTUNX, CM_INV },
  966. { "url-highlight", XYTURLHI, 0 },
  967. #ifdef NT
  968. { "video-change", XYTVCH, 0 },
  969. #endif /* NT */
  970. { "vt-language", XYTVTLNG, 0 },
  971. { "vt-nrc-mode", XYTVTNRC, 0 },
  972. #endif /* OS2 */
  973. { "width", XYTWID, 0 },
  974. #ifdef OS2
  975. { "wrap", XYTWRP, 0 },
  976. #endif /* OS2 */
  977. { "", 0, 0 }
  978. };
  979. int ntrm = (sizeof(trmtab) / sizeof(struct keytab)) - 1;
  980. #ifdef OS2
  981. struct keytab termctrl[] = { /* SET TERM CONTROLS */
  982. { "7", 7, 0 },
  983. { "8", 8, 0 }
  984. };
  985. int ntermctrl = (sizeof(termctrl) / sizeof(struct keytab));
  986. struct keytab curontab[] = { /* SET TERM CURSOR */
  987. #ifdef KUI
  988. { "noblink", 2, 0 },
  989. #else
  990. { "noblink", 2, CM_INV },
  991. #endif /* KUI */
  992. { "off", 0, 0 },
  993. { "on", 1, 0 }
  994. };
  995. int ncuron = (sizeof(curontab) / sizeof(struct keytab));
  996. struct keytab rolltab[] = { /* Set TERM Roll Options */
  997. { "insert", TTR_INSERT, 0 },
  998. { "keystrokes",TTR_KEYS, 0 },
  999. { "off", TTR_OVER, CM_INV },
  1000. { "on", TTR_INSERT, CM_INV },
  1001. { "overwrite", TTR_OVER, 0 }
  1002. };
  1003. int nroll = (sizeof(rolltab) / sizeof(struct keytab));
  1004. struct keytab rollkeytab[] = { /* Set TERM ROLL KEYSTROKES */
  1005. { "ignore", TTRK_IGN, 0 },
  1006. { "restore-and-send", TTRK_RST, 0 },
  1007. { "send", TTRK_SND, 0 }
  1008. };
  1009. int nrollkey = (sizeof(rollkeytab) / sizeof(struct keytab));
  1010. #define TT_GR_ALL 4
  1011. #define TT_GR_G0 0
  1012. #define TT_GR_G1 1
  1013. #define TT_GR_G2 2
  1014. #define TT_GR_G3 3
  1015. #define TT_GR_KBD 4
  1016. struct keytab graphsettab[] = { /* DEC VT Graphic Sets */
  1017. { "all", TT_GR_ALL, 0 },
  1018. { "g0", TT_GR_G0, 0 },
  1019. { "g1", TT_GR_G1, 0 },
  1020. { "g2", TT_GR_G2, 0 },
  1021. { "g3", TT_GR_G3, 0 },
  1022. { "keyboard", TT_GR_KBD, 0 }
  1023. };
  1024. int ngraphset = (sizeof(graphsettab) / sizeof(struct keytab));
  1025. #endif /* OS2 */
  1026. struct keytab adltab[] = { /* Autodownload Options */
  1027. { "ask", TAD_ASK, 0 },
  1028. { "error", TAD_ERR, 0 },
  1029. #ifdef OS2
  1030. { "kermit", TAD_K, 0 },
  1031. #endif /* OS2 */
  1032. { "off", TAD_OFF, 0 },
  1033. { "on", TAD_ON, 0 },
  1034. #ifdef OS2
  1035. { "zmodem", TAD_Z, 0 },
  1036. #endif /* OS2 */
  1037. { "", 0, 0 }
  1038. };
  1039. int nadltab = (sizeof(adltab) / sizeof(struct keytab)) - 1;
  1040. struct keytab adlerrtab[] = { /* Autodownload Error Options */
  1041. { "continue", 0, 0 },
  1042. { "go", 0, CM_INV },
  1043. { "stop", 1, 0 }
  1044. };
  1045. int nadlerrtab = (sizeof(adlerrtab) / sizeof(struct keytab));
  1046. #ifdef OS2
  1047. struct keytab adlxtab[] = { /* Autodownload Options */
  1048. { "c0-conflicts", TAD_X_C0, 0 },
  1049. { "detection-method", TAD_X_DETECT, 0 },
  1050. { "string", TAD_X_STR, 0 }
  1051. };
  1052. int nadlxtab = (sizeof(adlxtab) / sizeof(struct keytab));
  1053. struct keytab adldtab[] = { /* Auto-dl Detection Methods */
  1054. { "packet", ADL_PACK, 0 },
  1055. { "string", ADL_STR, 0 }
  1056. };
  1057. int nadldtab = (sizeof(adldtab) / sizeof(struct keytab));
  1058. struct keytab adlc0tab[] = { /* Auto-dl Detection Methods */
  1059. { "ignored-by-emulator", 0, 0 },
  1060. { "processed-by-emulator", 1, 0 }
  1061. };
  1062. int nadlc0tab = (sizeof(adlc0tab) / sizeof(struct keytab));
  1063. #ifndef NOCSETS
  1064. struct keytab vtlangtab[] = {
  1065. { "belgian", VTL_BELGIAN , 0 },
  1066. { "british", VTL_BRITISH , 0 },
  1067. { "canadian", VTL_CANADIAN, 0 },
  1068. { "czech", VTL_CZECH , 0 },
  1069. { "danish", VTL_DANISH , 0 },
  1070. { "dutch", VTL_DUTCH , 0 },
  1071. { "finnish", VTL_FINNISH , 0 },
  1072. { "french", VTL_FRENCH , 0 },
  1073. { "french-canadian",VTL_FR_CAN , 0 },
  1074. { "german", VTL_GERMAN , 0 },
  1075. { "greek", VTL_GREEK , 0 },
  1076. { "hebrew", VTL_HEBREW , 0 },
  1077. { "hungarian", VTL_HUNGARIA, 0 },
  1078. { "italian", VTL_ITALIAN , 0 },
  1079. { "latin-american", VTL_LATIN_AM, 0 },
  1080. { "north-american", VTL_NORTH_AM, 0 },
  1081. { "norwegian", VTL_NORWEGIA, 0 },
  1082. { "polish", VTL_POLISH , 0 },
  1083. { "portugese", VTL_PORTUGES, 0 },
  1084. { "romanian", VTL_ROMANIAN, 0 },
  1085. { "russian", VTL_RUSSIAN , 0 },
  1086. { "scs", VTL_SCS , CM_INV },
  1087. { "slovak", VTL_SLOVAK , 0 },
  1088. { "spanish", VTL_SPANISH , 0 },
  1089. { "swedish", VTL_SWEDISH , 0 },
  1090. { "swiss-french", VTL_SW_FR , 0 },
  1091. { "swiss-german", VTL_SW_GR , 0 },
  1092. { "turkish-f", VTL_TURK_F , CM_INV },
  1093. { "turkish-q", VTL_TURK_Q , CM_INV }
  1094. };
  1095. int nvtlangtab = (sizeof(vtlangtab) / sizeof(struct keytab));
  1096. #endif /* NOCSETS */
  1097. #endif /* OS2 */
  1098. struct keytab crdtab[] = { /* Carriage-return display */
  1099. { "crlf", 1, 0 },
  1100. { "normal", 0, 0 }
  1101. };
  1102. extern int tt_crd; /* Carriage-return display variable */
  1103. extern int tt_lfd; /* Linefeed display variable */
  1104. #ifdef CK_APC
  1105. extern int apcstatus, apcactive;
  1106. static struct keytab apctab[] = { /* Terminal APC parameters */
  1107. { "no-input", APC_ON|APC_NOINP,0 },
  1108. { "off", APC_OFF, 0 },
  1109. { "on", APC_ON, 0 },
  1110. { "unchecked", APC_ON|APC_UNCH, 0 },
  1111. { "unchecked-no-input", APC_ON|APC_NOINP|APC_UNCH, 0 }
  1112. };
  1113. int napctab = (sizeof(apctab) / sizeof(struct keytab));
  1114. #endif /* CK_APC */
  1115. #endif /* NOLOCAL */
  1116. extern int autodl, adl_err, adl_ask;
  1117. struct keytab beltab[] = { /* Terminal bell mode */
  1118. #ifdef OS2
  1119. { "audible", XYB_AUD, 0 },
  1120. { "none", XYB_NONE, 0 },
  1121. #else
  1122. { "audible", XYB_AUD, CM_INV },
  1123. { "none", XYB_NONE, CM_INV },
  1124. #endif /* OS2 */
  1125. #ifdef OS2
  1126. { "off", XYB_NONE, CM_INV },
  1127. { "on", XYB_AUD, CM_INV },
  1128. #else
  1129. { "off", XYB_NONE, 0 },
  1130. { "on", XYB_AUD, 0 },
  1131. #endif /* OS2 */
  1132. #ifdef OS2
  1133. { "visible", XYB_VIS, 0 },
  1134. #endif /* OS2 */
  1135. { "", 0, 0 }
  1136. };
  1137. int nbeltab = sizeof(beltab)/sizeof(struct keytab) - 1;
  1138. int tt_unicode = 1; /* Use Unicode if possible */
  1139. #ifdef CKTIDLE
  1140. int tt_idlesnd_tmo = 0; /* Idle Send Timeout, disabled */
  1141. char * tt_idlesnd_str = NULL; /* Idle Send String, none */
  1142. char * tt_idlestr = NULL;
  1143. extern int tt_idleact, tt_idlelimit;
  1144. #endif /* CKTIDLE */
  1145. #ifdef OS2
  1146. #ifndef NOLOCAL
  1147. /*
  1148. OS/2 serial communication devices.
  1149. */
  1150. struct keytab os2devtab[] = {
  1151. { "1", 1, CM_INV }, /* Invisible synonyms, like */
  1152. { "2", 2, CM_INV }, /* "set port 1" */
  1153. { "3", 3, CM_INV },
  1154. { "4", 4, CM_INV },
  1155. { "5", 5, CM_INV },
  1156. { "6", 6, CM_INV },
  1157. { "7", 7, CM_INV },
  1158. { "8", 8, CM_INV },
  1159. { "com1", 1, 0 }, /* Real device names */
  1160. { "com2", 2, 0 },
  1161. { "com3", 3, 0 },
  1162. { "com4", 4, 0 },
  1163. { "com5", 5, 0 },
  1164. { "com6", 6, 0 },
  1165. { "com7", 7, 0 },
  1166. { "com8", 8, 0 },
  1167. #ifdef OS2ONLY
  1168. { "slipcom1", 1, 0 }, /* For use with SLIP driver */
  1169. { "slipcom2", 2, 0 }, /* shared access */
  1170. { "slipcom3", 3, 0 },
  1171. { "slipcom4", 4, 0 },
  1172. { "slipcom5", 5, 0 },
  1173. { "slipcom6", 6, 0 },
  1174. { "slipcom7", 7, 0 },
  1175. { "slipcom8", 8, 0 },
  1176. { "pppcom1", 1, 0 }, /* For use with PPP driver */
  1177. { "pppcom2", 2, 0 }, /* shared access */
  1178. { "pppcom3", 3, 0 },
  1179. { "pppcom4", 4, 0 },
  1180. { "pppcom5", 5, 0 },
  1181. { "pppcom6", 6, 0 },
  1182. { "pppcom7", 7, 0 },
  1183. { "pppcom8", 8, 0 }
  1184. #endif /* OS2ONLY */
  1185. };
  1186. int nos2dev = (sizeof(os2devtab) / sizeof(struct keytab)) - 1;
  1187. #ifdef OS2ONLY
  1188. struct keytab os2ppptab[] = {
  1189. { "0", 0, CM_INV },
  1190. { "1", 1, CM_INV }, /* Invisible synonyms, like */
  1191. { "2", 2, CM_INV }, /* "set port 1" */
  1192. { "3", 3, CM_INV },
  1193. { "4", 4, CM_INV },
  1194. { "5", 5, CM_INV },
  1195. { "6", 6, CM_INV },
  1196. { "7", 7, CM_INV },
  1197. { "8", 8, CM_INV },
  1198. { "9", 9, CM_INV },
  1199. { "ppp0", 0, 0 },
  1200. { "ppp1", 1, 0 }, /* For use with PPP driver */
  1201. { "ppp2", 2, 0 }, /* shared access */
  1202. { "ppp3", 3, 0 },
  1203. { "ppp4", 4, 0 },
  1204. { "ppp5", 5, 0 },
  1205. { "ppp6", 6, 0 },
  1206. { "ppp7", 7, 0 },
  1207. { "ppp8", 8, 0 },
  1208. { "ppp9", 9, 0 }
  1209. };
  1210. int nos2ppp = (sizeof(os2ppptab) / sizeof(struct keytab));
  1211. #endif /* OS2ONLY */
  1212. /*
  1213. Terminal parameters that can be set by SET commands.
  1214. Used by the ck?con.c terminal emulator code.
  1215. For now, only used for #ifdef OS2. Should add these for Macintosh.
  1216. */
  1217. int tt_arrow = TTK_NORM; /* Arrow key mode: normal (cursor) */
  1218. int tt_keypad = TTK_NORM; /* Keypad mode: normal (numeric) */
  1219. int tt_shift_keypad = 0; /* Keypad Shift mode: Off */
  1220. int tt_wrap = 1; /* Terminal wrap, 1 = On */
  1221. int tt_type = TT_VT220; /* Terminal type, initially VT220 */
  1222. int tt_type_mode = TT_VT220; /* Terminal type set by host command */
  1223. int tt_cursor = 0; /* Terminal cursor, 0 = Underline */
  1224. int tt_cursor_usr = 0; /* Users Terminal cursor type */
  1225. int tt_cursorena_usr = 1; /* Users Terminal cursor enabled */
  1226. int tt_cursor_blink = 1; /* Terminal Cursor Blink */
  1227. int tt_answer = 0; /* Terminal answerback (disabled) */
  1228. int tt_scrsize[VNUM] = {512,512,512,1}; /* Terminal scrollback buffer size */
  1229. int tt_roll[VNUM] = {1,1,1,1}; /* Terminal roll (on) */
  1230. int tt_rkeys[VNUM] = {1,1,1,1}; /* Terminal roll keys (send) */
  1231. int tt_pacing = 0; /* Terminal output-pacing (none) */
  1232. int tt_ctstmo = 15; /* Terminal transmit-timeout */
  1233. int tt_codepage = -1; /* Terminal code-page */
  1234. int tt_update = 100; /* Terminal screen-update interval */
  1235. int tt_updmode = TTU_FAST; /* Terminal screen-update mode FAST */
  1236. extern int updmode;
  1237. #ifndef KUI
  1238. int tt_status[VNUM] = {1,1,0,0}; /* Terminal status line displayed */
  1239. int tt_status_usr[VNUM] = {1,1,0,0};
  1240. #else /* KUI */
  1241. extern CKFLOAT floatval;
  1242. CKFLOAT tt_linespacing[VNUM] = {1.0,1.0,1.0,1.0};
  1243. #ifdef K95G
  1244. int tt_status[VNUM] = {1,1,0,0}; /* Terminal status line displayed */
  1245. int tt_status_usr[VNUM] = {1,1,0,0};
  1246. #else /* K95G */
  1247. int tt_status[VNUM] = {0,0,0,0}; /* Terminal status line displayed */
  1248. int tt_status_usr[VNUM] = {0,0,0,0};
  1249. #endif /* K95G */
  1250. #endif /* KUI */
  1251. int tt_senddata = 0; /* Let host read terminal data */
  1252. extern int wy_blockend; /* Terminal Send Data EOB type */
  1253. int tt_hidattr = 1; /* Attributes are hidden */
  1254. extern unsigned char colornormal, colorselect,
  1255. colorunderline, colorstatus, colorhelp, colorborder,
  1256. colorgraphic, colordebug, colorreverse, coloritalic;
  1257. extern int trueblink, trueunderline, truereverse, trueitalic, truedim;
  1258. extern int bgi, fgi;
  1259. extern int scrninitialized[];
  1260. struct keytab audibletab[] = { /* Terminal Bell Audible mode */
  1261. { "beep", XYB_BEEP, 0 }, /* Values ORd with bell mode */
  1262. { "system-sounds", XYB_SYS, 0 }
  1263. };
  1264. int naudibletab = sizeof(audibletab)/sizeof(struct keytab);
  1265. struct keytab akmtab[] = { /* Arrow key mode */
  1266. { "application", TTK_APPL, 0 },
  1267. { "cursor", TTK_NORM, 0 }
  1268. };
  1269. struct keytab kpmtab[] = { /* Keypad mode */
  1270. { "application", TTK_APPL, 0 },
  1271. { "numeric", TTK_NORM, 0 }
  1272. };
  1273. struct keytab ttcolmodetab[] = {
  1274. { "current-color", 0, 0 },
  1275. { "default-color", 1, 0 }
  1276. };
  1277. int ncolmode = sizeof(ttcolmodetab)/sizeof(struct keytab);
  1278. #define TTCOLNOR 0
  1279. #define TTCOLREV 1
  1280. #define TTCOLUND 2
  1281. #define TTCOLSTA 3
  1282. #define TTCOLHLP 4
  1283. #define TTCOLBOR 5
  1284. #define TTCOLSEL 6
  1285. #define TTCOLDEB 7
  1286. #define TTCOLGRP 8
  1287. #define TTCOLITA 9
  1288. #define TTCOLRES 10
  1289. #define TTCOLERA 11
  1290. struct keytab ttycoltab[] = { /* Terminal Screen coloring */
  1291. { "border", TTCOLBOR, 0 }, /* Screen border color */
  1292. { "debug-terminal", TTCOLDEB, 0 }, /* Debug color */
  1293. { "erase", TTCOLERA, 0 }, /* Erase mode */
  1294. { "graphic", TTCOLGRP, 0 }, /* Graphic Color */
  1295. { "help-text", TTCOLHLP, 0 }, /* Help screens */
  1296. { "italic", TTCOLITA, 0 }, /* Italic Color */
  1297. { "normal", TTCOLNOR, CM_INV }, /* Normal screen text */
  1298. { "reset-on-esc[0m", TTCOLRES, 0 }, /* Reset on ESC [ 0 m */
  1299. { "reverse-video", TTCOLREV, 0 }, /* Reverse video */
  1300. { "status-line", TTCOLSTA, 0 }, /* Status line */
  1301. { "selection", TTCOLSEL, 0 }, /* Selection color */
  1302. { "terminal-screen", TTCOLNOR, 0 }, /* Better name than "normal" */
  1303. { "underlined-text", TTCOLUND, 0 } /* Underlined text */
  1304. };
  1305. int ncolors = (sizeof(ttycoltab) / sizeof(struct keytab));
  1306. #define TTATTNOR 0
  1307. #define TTATTBLI 1
  1308. #define TTATTREV 2
  1309. #define TTATTUND 3
  1310. #define TTATTPRO 4
  1311. #define TTATTBLD 5
  1312. #define TTATTDIM 6
  1313. #define TTATTINV 7
  1314. #define TTATTITA 8
  1315. #define TTATTDONE 9
  1316. struct keytab ttyattrtab[] = {
  1317. { "blink", TTATTBLI, 0 },
  1318. { "dim", TTATTDIM, 0 },
  1319. { "italic", TTATTITA, 0 },
  1320. { "protected", TTATTPRO, 0 },
  1321. { "reverse", TTATTREV, 0 },
  1322. { "underline", TTATTUND, 0 }
  1323. };
  1324. int nattrib = (sizeof(ttyattrtab) / sizeof(struct keytab));
  1325. struct keytab ttyprotab[] = {
  1326. { "blink", TTATTBLI, 0 },
  1327. { "bold", TTATTBLD, 0 },
  1328. { "dim", TTATTDIM, 0 },
  1329. { "done", TTATTDONE, CM_INV },
  1330. { "invisible", TTATTINV, 0 },
  1331. { "italic", TTATTITA, 0 },
  1332. { "normal", TTATTNOR, 0 },
  1333. { "reverse", TTATTREV, 0 },
  1334. { "underlined", TTATTUND, 0 }
  1335. };
  1336. int nprotect = (sizeof(ttyprotab) / sizeof(struct keytab));
  1337. struct keytab ttyseobtab[] = {
  1338. { "crlf_etx", 1, 0 },
  1339. { "us_cr", 0, 0 }
  1340. };
  1341. struct keytab ttyclrtab[] = { /* Colors */
  1342. { "black", 0, 0 },
  1343. { "blue", 1, 0 },
  1344. { "brown", 6, 0 },
  1345. { "cyan", 3, 0 },
  1346. { "darkgray", 8, CM_INV },
  1347. { "dgray", 8, 0 },
  1348. { "green", 2, 0 },
  1349. { "lblue", 9, CM_INV },
  1350. { "lcyan", 11, CM_INV },
  1351. { "lgray", 7, CM_INV },
  1352. { "lgreen", 10, CM_INV },
  1353. { "lightblue", 9, 0 },
  1354. { "lightcyan", 11, 0 },
  1355. { "lightgray", 7, 0 },
  1356. { "lightgreen", 10, 0 },
  1357. { "lightmagenta", 13, 0 },
  1358. { "lightred", 12, 0 },
  1359. { "lmagenta", 13, CM_INV },
  1360. { "lred", 12, CM_INV },
  1361. { "magenta", 5, 0 },
  1362. { "red", 4, 0 },
  1363. { "white", 15, 0 },
  1364. { "yellow", 14, 0 }
  1365. };
  1366. int nclrs = (sizeof (ttyclrtab) / sizeof (struct keytab));
  1367. struct keytab ttycurtab[] = {
  1368. { "full", TTC_BLOCK, 0 },
  1369. { "half", TTC_HALF, 0 },
  1370. { "underline", TTC_ULINE, 0 }
  1371. };
  1372. int ncursors = 3;
  1373. struct keytab ttyptab[] = {
  1374. { "aaa", TT_AAA, CM_INV }, /* AnnArbor */
  1375. { "adm3a", TT_ADM3A, 0 }, /* LSI ADM-3A */
  1376. { "adm5", TT_ADM5, 0 }, /* LSI ADM-5 */
  1377. { "aixterm", TT_AIXTERM, 0 }, /* IBM AIXterm */
  1378. { "annarbor", TT_AAA, 0 }, /* AnnArbor */
  1379. { "ansi-bbs", TT_ANSI, 0 }, /* ANSI.SYS (BBS) */
  1380. { "at386", TT_AT386, 0 }, /* Unixware ANSI */
  1381. { "avatar/0+",TT_ANSI, 0 }, /* AVATAR/0+ */
  1382. { "ba80", TT_BA80, 0 }, /* Nixdorf BA80 */
  1383. { "be", TT_BEOS, CM_INV|CM_ABR },
  1384. { "beos-ansi",TT_BEOS, CM_INV }, /* BeOS ANSI */
  1385. { "beterm", TT_BEOS, 0 }, /* BeOS Terminal (as of PR2 ) */
  1386. { "d200", TT_DG200, CM_INV|CM_ABR }, /* Data General DASHER 200 */
  1387. { "d210", TT_DG210, CM_INV|CM_ABR }, /* Data General DASHER 210 */
  1388. { "d217", TT_DG217, CM_INV|CM_ABR }, /* Data General DASHER 217 */
  1389. { "dg200", TT_DG200, 0 }, /* Data General DASHER 200 */
  1390. { "dg210", TT_DG210, 0 }, /* Data General DASHER 210 */
  1391. { "dg217", TT_DG217, 0 }, /* Data General DASHER 217 */
  1392. { "h1500", TT_HZL1500, CM_INV }, /* Hazeltine 1500 */
  1393. { "h19", TT_H19, CM_INV }, /* Heath-19 */
  1394. { "heath19", TT_H19, 0 }, /* Heath-19 */
  1395. { "hft", TT_HFT, 0 }, /* IBM High Function Terminal */
  1396. { "hp2621a", TT_HP2621, 0 }, /* HP 2621A */
  1397. { "hpterm", TT_HPTERM, 0 }, /* HP TERM */
  1398. { "hz1500", TT_HZL1500, 0 }, /* Hazeltine 1500 */
  1399. { "ibm3151", TT_IBM31, 0 }, /* IBM 3101-xx,3161 */
  1400. { "linux", TT_LINUX, 0 }, /* Linux */
  1401. { "qansi", TT_QANSI, 0 }, /* QNX ANSI */
  1402. { "qnx", TT_QNX, 0 }, /* QNX Console */
  1403. { "scoansi", TT_SCOANSI, 0 }, /* SCO ANSI */
  1404. { "sni-97801",TT_97801, 0 }, /* SNI 97801 */
  1405. { "sun", TT_SUN, 0 }, /* SUN Console */
  1406. /*
  1407. The idea of NONE is to let the console driver handle the escape sequences,
  1408. which, in theory at least, would give not only ANSI emulation, but also any
  1409. other kind of emulation that might be provided by alternative console
  1410. drivers, if any existed.
  1411. For this to work, ckocon.c would need to be modified to make higher-level
  1412. calls, like VioWrtTTY(), DosWrite(), or (simply) write(), rather than
  1413. VioWrt*Cell() and similar, and it would also have to give up its rollback
  1414. feature, and its status line and help screens would also have to be
  1415. forgotten or else done in an ANSI way.
  1416. As matters stand, we already have perfectly good ANSI emulation built in,
  1417. and there are no alternative console drivers available, so there is no point
  1418. in having a terminal type of NONE, so it is commented out. However, should
  1419. you uncomment it, it will work like a "glass tty" -- no escape sequence
  1420. interpretation at all; somewhat similar to debug mode, except without the
  1421. debugging (no highlighting of control chars or escape sequences); help
  1422. screens, status line, and rollback will still work.
  1423. */
  1424. #ifdef OS2PM
  1425. #ifdef COMMENT
  1426. { "tek4014", TT_TEK40, 0 },
  1427. #endif /* COMMENT */
  1428. #endif /* OS2PM */
  1429. { "tty", TT_NONE, 0 },
  1430. { "tvi910+", TT_TVI910, 0 },
  1431. { "tvi925", TT_TVI925, 0 },
  1432. { "tvi950", TT_TVI950, 0 },
  1433. { "vc404", TT_VC4404, 0 },
  1434. { "vc4404", TT_VC4404, CM_INV },
  1435. { "vip7809", TT_VIP7809,0 },
  1436. { "vt100", TT_VT100, 0 },
  1437. { "vt102", TT_VT102, 0 },
  1438. { "vt220", TT_VT220, 0 },
  1439. { "vt220pc", TT_VT220PC,0 },
  1440. { "vt320", TT_VT320, 0 },
  1441. { "vt320pc", TT_VT320PC,0 },
  1442. { "vt52", TT_VT52, 0 },
  1443. #ifdef NT
  1444. { "vtnt", TT_VTNT, 0 },
  1445. #else /* NT */
  1446. { "vtnt", TT_VTNT, CM_INV },
  1447. #endif /* NT */
  1448. { "wy160", TT_WY160, 0 },
  1449. { "wy30", TT_WY30, 0 },
  1450. { "wy370", TT_WY370, 0 },
  1451. { "wy50", TT_WY50, 0 },
  1452. { "wy60", TT_WY60, 0 },
  1453. { "wyse30", TT_WY30, CM_INV },
  1454. { "wyse370", TT_WY370, CM_INV },
  1455. { "wyse50", TT_WY50, CM_INV },
  1456. { "wyse60", TT_WY60, CM_INV }
  1457. };
  1458. int nttyp = (sizeof(ttyptab) / sizeof(struct keytab));
  1459. struct keytab ttkeytab[] = {
  1460. { "aaa", TT_AAA, CM_INV }, /* AnnArbor */
  1461. { "adm3a", TT_ADM3A, 0 }, /* LSI ADM-3A */
  1462. { "adm5", TT_ADM5, 0 }, /* LSI ADM-5 */
  1463. { "aixterm", TT_AIXTERM, 0 }, /* IBM AIXterm */
  1464. { "annarbor", TT_AAA, 0 }, /* AnnArbor */
  1465. { "ansi-bbs", TT_ANSI, 0 }, /* ANSI.SYS (BBS) */
  1466. { "at386", TT_AT386, 0 }, /* Unixware ANSI */
  1467. { "avatar/0+", TT_ANSI, 0 }, /* AVATAR/0+ */
  1468. { "ba80", TT_BA80, 0 }, /* Nixdorf BA80 */
  1469. { "be", TT_BEOS, CM_INV|CM_ABR },
  1470. { "beos-ansi", TT_BEOS, CM_INV }, /* BeOS ANSI */
  1471. { "beterm", TT_BEOS, 0 }, /* BeOS Terminal (DR2) */
  1472. { "d200", TT_DG200, CM_INV|CM_ABR }, /* DG DASHER 200 */
  1473. { "d210", TT_DG210, CM_INV|CM_ABR }, /* DG DASHER 210 */
  1474. { "d217", TT_DG217, CM_INV|CM_ABR }, /* DG DASHER 217 */
  1475. { "dg200", TT_DG200, 0 }, /* DG DASHER 200 */
  1476. { "dg210", TT_DG210, 0 }, /* DG DASHER 210 */
  1477. { "dg217", TT_DG217, 0 }, /* DG DASHER 217 */
  1478. { "emacs", TT_KBM_EMACS, 0 }, /* Emacs mode */
  1479. { "h19", TT_H19, CM_INV }, /* Heath-19 */
  1480. { "heath19", TT_H19, 0 }, /* Heath-19 */
  1481. { "hebrew", TT_KBM_HEBREW, 0 }, /* Hebrew mode */
  1482. { "hft", TT_HFT, 0 }, /* IBM High Function Term */
  1483. { "hp2621a", TT_HP2621, 0 }, /* HP 2621A */
  1484. { "hpterm", TT_HPTERM, 0 }, /* HP TERM */
  1485. { "hz1500", TT_HZL1500, 0 }, /* Hazeltine 1500 */
  1486. { "ibm3151", TT_IBM31, 0 }, /* IBM 3101-xx,3161 */
  1487. { "linux", TT_LINUX, 0 }, /* Linux */
  1488. { "qansi", TT_QANSI, 0 }, /* QNX ANSI */
  1489. { "qnx", TT_QNX, 0 }, /* QNX */
  1490. { "russian", TT_KBM_RUSSIAN,0 }, /* Russian mode */
  1491. { "scoansi", TT_SCOANSI, 0 }, /* SCO ANSI */
  1492. { "sni-97801", TT_97801, 0 }, /* SNI 97801 */
  1493. { "sun", TT_SUN, 0 }, /* SUN Console */
  1494. #ifdef OS2PM
  1495. #ifdef COMMENT
  1496. { "tek4014", TT_TEK40, 0 },
  1497. #endif /* COMMENT */
  1498. #endif /* OS2PM */
  1499. { "tty", TT_NONE, 0 },
  1500. { "tvi910+", TT_TVI910, 0 },
  1501. { "tvi925", TT_TVI925, 0 },
  1502. { "tvi950", TT_TVI950, 0 },
  1503. { "vc404", TT_VC4404, 0 },
  1504. { "vc4404", TT_VC4404, CM_INV },
  1505. { "vip7809", TT_VIP7809, 0 },
  1506. { "vt100", TT_VT100, 0 },
  1507. { "vt102", TT_VT102, 0 },
  1508. { "vt220", TT_VT220, 0 },
  1509. { "vt220pc", TT_VT220PC, 0 },
  1510. { "vt320", TT_VT320, 0 },
  1511. { "vt320pc", TT_VT320PC, 0 },
  1512. { "vt52", TT_VT52, 0 },
  1513. { "vtnt", TT_VTNT, CM_INV },
  1514. { "wp", TT_KBM_WP, 0 }, /* Word Perfect mode */
  1515. { "wy160", TT_WY160, 0 },
  1516. { "wy30", TT_WY30, 0 },
  1517. { "wy370", TT_WY370, 0 },
  1518. { "wy50", TT_WY50, 0 },
  1519. { "wy60", TT_WY60, 0 },
  1520. { "wyse30", TT_WY30, CM_INV },
  1521. { "wyse370", TT_WY370, CM_INV },
  1522. { "wyse50", TT_WY50, CM_INV },
  1523. { "wyse60", TT_WY60, CM_INV }
  1524. };
  1525. int nttkey = (sizeof(ttkeytab) / sizeof(struct keytab));
  1526. #ifndef NOSETKEY
  1527. struct keytab kbmodtab[] = {
  1528. { "emacs", KBM_EM, 0 },
  1529. { "english", KBM_EN, CM_INV },
  1530. { "hebrew", KBM_HE, 0 },
  1531. { "normal", KBM_EN, 0 },
  1532. { "none", KBM_EN, CM_INV },
  1533. { "russian", KBM_RU, 0 },
  1534. { "wp", KBM_WP, 0 }
  1535. };
  1536. int nkbmodtab = (sizeof(kbmodtab) / sizeof(struct keytab));
  1537. #endif /* NOSETKEY */
  1538. #endif /* NOLOCAL */
  1539. int tt_inpacing = 0; /* input-pacing (none) */
  1540. struct keytab prtytab[] = { /* OS/2 Priority Levels */
  1541. { "foreground-server", XYP_SRV, 0 },
  1542. { "idle", XYP_IDLE, CM_INV },
  1543. { "regular", XYP_REG, 0 },
  1544. { "time-critical", XYP_RTP, 0 }
  1545. };
  1546. int nprty = (sizeof(prtytab) / sizeof(struct keytab));
  1547. #endif /* OS2 */
  1548. #ifdef NT
  1549. struct keytab win95tab[] = { /* Win95 work-arounds */
  1550. { "8.3-filenames", XYW8_3, 0 },
  1551. { "alt-gr", XYWAGR, 0 },
  1552. { "horizontal-scan-line-substitutions", XYWHSL, 0 },
  1553. { "keyboard-translation", XYWKEY, 0 },
  1554. { "lucida-substitutions", XYWLUC, 0 },
  1555. { "overlapped-io", XYWOIO, 0 },
  1556. { "popups", XYWPOPUP, 0 },
  1557. { "select-bug", XYWSELECT, 0 }
  1558. };
  1559. int nwin95 = (sizeof(win95tab) / sizeof(struct keytab));
  1560. #endif /* NT */
  1561. #ifdef OS2MOUSE
  1562. extern int wideresult;
  1563. int tt_mouse = 1; /* Terminal mouse on/off */
  1564. struct keytab mousetab[] = { /* Mouse items */
  1565. { "activate", XYM_ON, 0 },
  1566. { "button", XYM_BUTTON, 0 },
  1567. { "clear", XYM_CLEAR, 0 },
  1568. { "debug", XYM_DEBUG, 0 }
  1569. };
  1570. int nmtab = (sizeof(mousetab)/sizeof(struct keytab));
  1571. struct keytab mousebuttontab[] = { /* event button */
  1572. { "1", XYM_B1, 0 },
  1573. { "2", XYM_B2, 0 },
  1574. { "3", XYM_B3, 0 },
  1575. { "one", XYM_B1, CM_INV },
  1576. { "three", XYM_B3, CM_INV },
  1577. { "two", XYM_B2, CM_INV }
  1578. };
  1579. int nmbtab = (sizeof(mousebuttontab) / sizeof(struct keytab));
  1580. struct keytab mousemodtab[] = { /* event button key modifier */
  1581. { "alt", XYM_ALT, 0 },
  1582. { "alt-shift", XYM_SHIFT|XYM_ALT, 0 },
  1583. { "ctrl", XYM_CTRL, 0 },
  1584. { "ctrl-alt", XYM_CTRL|XYM_ALT, 0 },
  1585. { "ctrl-alt-shift", XYM_CTRL|XYM_SHIFT|XYM_ALT, 0 },
  1586. { "ctrl-shift", XYM_CTRL|XYM_SHIFT, 0 },
  1587. { "none", 0, 0 },
  1588. { "shift", XYM_SHIFT, 0 }
  1589. };
  1590. int nmmtab = (sizeof(mousemodtab) / sizeof(struct keytab));
  1591. struct keytab mclicktab[] = { /* event button click modifier */
  1592. { "click", XYM_C1, 0 },
  1593. { "drag", XYM_DRAG, 0 },
  1594. { "double-click", XYM_C2, 0 }
  1595. };
  1596. int nmctab = (sizeof(mclicktab) / sizeof(struct keytab));
  1597. #ifndef NOKVERBS
  1598. extern int nkverbs;
  1599. extern struct keytab kverbs[];
  1600. #endif /* NOKVERBS */
  1601. #endif /* OS2MOUSE */
  1602. /* #ifdef VMS */
  1603. struct keytab fbtab[] = { /* Binary record types for VMS */
  1604. { "fixed", XYFT_B, 0 }, /* Fixed is normal for binary */
  1605. { "undefined", XYFT_U, 0 } /* Undefined if they ask for it */
  1606. };
  1607. int nfbtyp = (sizeof(fbtab) / sizeof(struct keytab));
  1608. /* #endif */
  1609. #ifdef VMS
  1610. struct keytab lbltab[] = { /* Labeled File info */
  1611. { "acl", LBL_ACL, 0 },
  1612. { "backup-date", LBL_BCK, 0 },
  1613. { "name", LBL_NAM, 0 },
  1614. { "owner", LBL_OWN, 0 },
  1615. { "path", LBL_PTH, 0 }
  1616. };
  1617. int nlblp = (sizeof(lbltab) / sizeof(struct keytab));
  1618. #else
  1619. #ifdef OS2
  1620. struct keytab lbltab[] = { /* Labeled File info */
  1621. { "archive", LBL_ARC, 0 },
  1622. { "extended", LBL_EXT, 0 },
  1623. { "hidden", LBL_HID, 0 },
  1624. { "read-only", LBL_RO, 0 },
  1625. { "system", LBL_SYS, 0 }
  1626. };
  1627. int nlblp = (sizeof(lbltab) / sizeof(struct keytab));
  1628. #endif /* OS2 */
  1629. #endif /* VMS */
  1630. #ifdef CK_CURSES
  1631. #ifdef CK_PCT_BAR
  1632. static struct keytab fdftab[] = { /* SET FILE DISPLAY FULL options */
  1633. { "thermometer", 1, 0, },
  1634. { "no-thermometer", 0, 0 }
  1635. };
  1636. extern int thermometer;
  1637. #endif /* CK_PCT_BAR */
  1638. #endif /* CK_CURSES */
  1639. static struct keytab fdtab[] = { /* SET FILE DISPLAY options */
  1640. #ifdef MAC /* Macintosh */
  1641. { "fullscreen", XYFD_R, 0 }, /* Full-screen but not curses */
  1642. { "none", XYFD_N, 0 },
  1643. { "off", XYFD_N, CM_INV },
  1644. { "on", XYFD_R, CM_INV },
  1645. { "quiet", XYFD_N, CM_INV },
  1646. #else /* Not Mac */
  1647. { "brief", XYFD_B, 0 }, /* Brief */
  1648. { "crt", XYFD_S, 0 }, /* CRT display */
  1649. #ifdef CK_CURSES
  1650. #ifdef COMMENT
  1651. { "curses", XYFD_C, CM_INV }, /* Full-screen, curses */
  1652. #endif /* COMMENT */
  1653. { "fullscreen", XYFD_C, 0 }, /* Full-screen, whatever the method */
  1654. #endif /* CK_CURSES */
  1655. #ifdef KUI
  1656. { "gui", XYFD_G, 0 }, /* GUI */
  1657. #endif /* KUI */
  1658. { "none", XYFD_N, 0 }, /* No display */
  1659. { "off", XYFD_N, CM_INV }, /* Ditto */
  1660. { "on", XYFD_R, CM_INV }, /* On = Serial */
  1661. { "quiet", XYFD_N, CM_INV }, /* No display */
  1662. { "serial", XYFD_R, 0 }, /* Serial */
  1663. #endif /* MAC */
  1664. { "", 0, 0 }
  1665. };
  1666. int nfdtab = (sizeof(fdtab) / sizeof(struct keytab)) - 1;
  1667. struct keytab rsrtab[] = { /* For REMOTE SET RECEIVE */
  1668. { "packet-length", XYLEN, 0 },
  1669. { "timeout", XYTIMO, 0 }
  1670. };
  1671. int nrsrtab = (sizeof(rsrtab) / sizeof(struct keytab));
  1672. /* Send/Receive Parameters */
  1673. struct keytab srtab[] = {
  1674. { "backup", XYBUP, 0 },
  1675. #ifndef NOCSETS
  1676. { "character-set-selection", XYCSET, 0 },
  1677. #endif /* NOCSETS */
  1678. { "control-prefix", XYQCTL, 0 },
  1679. #ifdef CKXXCHAR
  1680. { "double-character", XYDBL, 0 },
  1681. #endif /* CKXXCHAR */
  1682. { "end-of-packet", XYEOL, 0 },
  1683. #ifdef PIPESEND
  1684. { "filter", XYFLTR, 0 },
  1685. #endif /* PIPESEND */
  1686. #ifdef CKXXCHAR
  1687. { "ignore-character", XYIGN, 0 },
  1688. #endif /* CKXXCHAR */
  1689. { "i-packets", 993, 0 },
  1690. { "move-to", XYMOVE, 0 },
  1691. { "negotiation-string-max-length", XYINIL, CM_INV },
  1692. { "packet-length", XYLEN, 0 },
  1693. { "pad-character", XYPADC, 0 },
  1694. { "padding", XYNPAD, 0 },
  1695. { "pathnames", XYFPATH, 0 },
  1696. { "pause", XYPAUS, 0 },
  1697. #ifdef CK_PERMS
  1698. { "permissions", 994, 0}, /* 206 */
  1699. #endif /* CK_PERMS */
  1700. { "quote", XYQCTL, CM_INV }, /* = CONTROL-PREFIX */
  1701. { "rename-to", XYRENAME, 0 },
  1702. { "start-of-packet", XYMARK, 0 },
  1703. { "timeout", XYTIMO, 0 },
  1704. #ifdef VMS
  1705. { "version-numbers", 887, 0 }, /* VMS version numbers */
  1706. #endif /* VMS */
  1707. { "", 0, 0 }
  1708. };
  1709. int nsrtab = (sizeof(srtab) / sizeof(struct keytab)) - 1;
  1710. #ifdef UNICODE
  1711. #define UCS_BOM 1
  1712. #define UCS_BYT 2
  1713. static struct keytab ucstab[] = {
  1714. { "bom", UCS_BOM, 0 },
  1715. { "byte-order", UCS_BYT, 0 },
  1716. { "", 0, 0 }
  1717. };
  1718. int nucstab = (sizeof(ucstab) / sizeof(struct keytab)) - 1;
  1719. static struct keytab botab[] = {
  1720. { "big-endian", 0, 0 },
  1721. { "little-endian", 1, 0 }
  1722. };
  1723. static int nbotab = 2;
  1724. #endif /* UNICODE */
  1725. /* REMOTE SET */
  1726. struct keytab rmstab[] = {
  1727. { "attributes", XYATTR, 0 },
  1728. { "block-check", XYCHKT, 0 },
  1729. { "file", XYFILE, 0 },
  1730. { "incomplete", XYIFD, CM_INV }, /* = REMOTE SET FILE INCOMPLETE */
  1731. { "match", XYMATCH,0 },
  1732. { "receive", XYRECV, 0 },
  1733. { "retry", XYRETR, 0 },
  1734. { "server", XYSERV, 0 },
  1735. { "transfer", XYXFER, 0 },
  1736. { "window", XYWIND, 0 },
  1737. { "xfer", XYXFER, CM_INV }
  1738. };
  1739. int nrms = (sizeof(rmstab) / sizeof(struct keytab));
  1740. struct keytab attrtab[] = {
  1741. #ifdef STRATUS
  1742. { "account", AT_ACCT, 0 },
  1743. #endif /* STRATUS */
  1744. { "all", AT_XALL, 0 },
  1745. #ifdef COMMENT
  1746. { "blocksize", AT_BLKS, 0 }, /* (not used) */
  1747. #endif /* COMMENT */
  1748. #ifndef NOCSETS
  1749. { "character-set", AT_ENCO, 0 },
  1750. #endif /* NOCSETS */
  1751. #ifdef STRATUS
  1752. { "creator", AT_CREA, 0 },
  1753. #endif /* STRATUS */
  1754. { "date", AT_DATE, 0 },
  1755. { "disposition", AT_DISP, 0 },
  1756. { "encoding", AT_ENCO, CM_INV },
  1757. { "format", AT_RECF, CM_INV },
  1758. { "length", AT_LENK, 0 },
  1759. { "off", AT_ALLN, 0 },
  1760. { "on", AT_ALLY, 0 },
  1761. #ifdef COMMENT
  1762. { "os-specific", AT_SYSP, 0 }, /* (not used by UNIX or VMS) */
  1763. #endif /* COMMENT */
  1764. #ifdef CK_PERMS
  1765. { "protection", AT_LPRO, 0 },
  1766. { "permissions", AT_LPRO, CM_INV },
  1767. #endif /* CK_PERMS */
  1768. { "record-format", AT_RECF, 0 },
  1769. { "system-id", AT_SYSI, 0 },
  1770. { "type", AT_FTYP, 0 }
  1771. };
  1772. int natr = (sizeof(attrtab) / sizeof(struct keytab)); /* how many attributes */
  1773. #ifdef CKTIDLE
  1774. struct keytab idlacts[] = {
  1775. { "exit", IDLE_EXIT, 0 },
  1776. { "hangup", IDLE_HANG, 0 },
  1777. { "output", IDLE_OUT, 0 },
  1778. { "return", IDLE_RET, 0 },
  1779. #ifdef TNCODE
  1780. { "telnet-nop", IDLE_TNOP, 0 },
  1781. { "telnet-ayt", IDLE_TAYT, 0 },
  1782. #endif /* TNCODE */
  1783. { "", 0, 0 }
  1784. };
  1785. int nidlacts = (sizeof(idlacts) / sizeof(struct keytab)) - 1;
  1786. #endif /* CKTIDLE */
  1787. #ifndef NOSPL
  1788. extern int indef, inecho, insilence, inbufsize, inautodl, inintr;
  1789. #ifdef CKFLOAT
  1790. extern CKFLOAT inscale;
  1791. #endif /* CKFLOAT */
  1792. extern char * inpbuf, * inpbp;
  1793. #ifdef OS2
  1794. extern int interm;
  1795. #endif /* OS2 */
  1796. struct keytab inptab[] = { /* SET INPUT parameters */
  1797. #ifdef CK_AUTODL
  1798. { "autodownload", IN_ADL, 0 },
  1799. #endif /* CK_AUTODL */
  1800. { "buffer-length", IN_BUF, 0 },
  1801. { "cancellation", IN_CAN, 0 },
  1802. { "case", IN_CAS, 0 },
  1803. { "default-timeout", IN_DEF, CM_INV }, /* There is no default timeout */
  1804. { "echo", IN_ECH, 0 },
  1805. #ifdef OS2
  1806. { "pacing", IN_PAC, CM_INV },
  1807. #endif /* OS2 */
  1808. { "scale-factor", IN_SCA, 0 },
  1809. { "silence", IN_SIL, 0 },
  1810. #ifdef OS2
  1811. { "terminal", IN_TRM, 0 },
  1812. #endif /* OS2 */
  1813. { "timeout-action", IN_TIM, 0 }
  1814. };
  1815. int ninp = (sizeof(inptab) / sizeof(struct keytab));
  1816. struct keytab intimt[] = { /* SET INPUT TIMEOUT parameters */
  1817. { "proceed", 0, 0 }, /* 0 = proceed */
  1818. { "quit", 1, 0 } /* 1 = quit */
  1819. };
  1820. struct keytab incast[] = { /* SET INPUT CASE parameters */
  1821. { "ignore", 0, 0 }, /* 0 = ignore */
  1822. { "observe", 1, 0 } /* 1 = observe */
  1823. };
  1824. #endif /* NOSPL */
  1825. struct keytab nabltab[] = { /* For any command that needs */
  1826. { "disabled", 0, 0 },
  1827. { "enabled", 1, 0 },
  1828. { "off", 0, CM_INV }, /* these keywords... */
  1829. { "on", 1, CM_INV }
  1830. };
  1831. int nnabltab = sizeof(nabltab) / sizeof(struct keytab);
  1832. #ifdef OS2
  1833. struct keytab tvctab[] = { /* SET TERM VIDEO-CHANGE */
  1834. { "disabled", TVC_DIS, 0 },
  1835. { "enabled", TVC_ENA, 0 },
  1836. #ifdef NT
  1837. { "win95-safe", TVC_W95, 0 },
  1838. #endif /* NT */
  1839. { "", 0, 0 }
  1840. };
  1841. int ntvctab = (sizeof(tvctab) / sizeof(struct keytab)) - 1;
  1842. struct keytab msktab[] = { /* SET MS-DOS KERMIT compatibilities */
  1843. #ifdef COMMENT
  1844. { "color", MSK_COLOR, 0 },
  1845. #endif /* COMMENT */
  1846. { "file-renaming", MSK_REN, 0 },
  1847. { "keycodes", MSK_KEYS, 0 }
  1848. };
  1849. int nmsk = (sizeof(msktab) / sizeof(struct keytab));
  1850. struct keytab scrnupd[] = { /* SET TERMINAL SCREEN-UPDATE */
  1851. { "fast", TTU_FAST, 0 },
  1852. { "smooth", TTU_SMOOTH, 0 }
  1853. };
  1854. int nscrnupd = (sizeof(scrnupd) / sizeof(struct keytab));
  1855. #ifdef PCFONTS
  1856. /* This definition of the term_font[] table is only for */
  1857. /* the OS/2 Full Screen Session and is not used on Windows */
  1858. struct keytab term_font[] = { /* SET TERMINAL FONT */
  1859. #ifdef COMMENT
  1860. { "cp111", TTF_111, 0 },
  1861. { "cp112", TTF_112, 0 },
  1862. { "cp113", TTF_113, 0 },
  1863. #endif /* COMMENT */
  1864. { "cp437", TTF_437, 0 },
  1865. { "cp850", TTF_850, 0 },
  1866. #ifdef COMMENT
  1867. { "cp851", TTF_851, 0 },
  1868. #endif /* COMMENT */
  1869. { "cp852", TTF_852, 0 },
  1870. #ifdef COMMENT
  1871. { "cp853", TTF_853, 0 },
  1872. { "cp860", TTF_860, 0 },
  1873. { "cp861", TTF_861, 0 },
  1874. #endif /* COMMENT */
  1875. { "cp862", TTF_862, 0 },
  1876. #ifdef COMMENT
  1877. { "cp863", TTF_863, 0 },
  1878. { "cp864", TTF_864, 0 },
  1879. { "cp865", TTF_865, 0 },
  1880. #endif /* COMMENT */
  1881. { "cp866", TTF_866, 0 },
  1882. #ifdef COMMENT
  1883. { "cp880", TTF_880, 0 },
  1884. { "cp881", TTF_881, 0 },
  1885. { "cp882", TTF_882, 0 },
  1886. { "cp883", TTF_883, 0 },
  1887. { "cp884", TTF_884, 0 },
  1888. { "cp885", TTF_885, 0 },
  1889. #endif /* COMMENT */
  1890. { "default",TTF_ROM,0 }
  1891. };
  1892. int ntermfont = (sizeof(term_font) / sizeof(struct keytab));
  1893. int tt_font = TTF_ROM; /* Terminal screen font */
  1894. #else /* PCFONTS */
  1895. #ifdef NT
  1896. #ifdef KUI
  1897. struct keytab * term_font = NULL;
  1898. struct keytab * _term_font = NULL;
  1899. char * tt_facename = NULL;
  1900. int ntermfont = 0;
  1901. int tt_font = 0;
  1902. int tt_font_size = 0;
  1903. #endif /* KUI */
  1904. #endif /* NT */
  1905. #endif /* PCFONTS */
  1906. struct keytab anbktab[] = { /* For any command that needs */
  1907. { "message", 2, 0 }, /* these keywords... */
  1908. { "off", 0, 0 },
  1909. { "on", 1, 0 },
  1910. { "unsafe-messag0", 99, CM_INV },
  1911. { "unsafe-message", 3, CM_INV }
  1912. };
  1913. int nansbk = (sizeof(anbktab) / sizeof(struct keytab));
  1914. int win95_popup = 1;
  1915. #ifdef NT
  1916. #ifdef KUI
  1917. int win95lucida = 0;
  1918. int win95hsl = 1;
  1919. #else /* KUI */
  1920. int win95lucida = 1;
  1921. int win95hsl = 1;
  1922. #endif /* KUI */
  1923. #else /* NT */
  1924. int win95lucida = 0;
  1925. int win95hsl = 1;
  1926. #endif /* NT */
  1927. #ifdef NT
  1928. int win95altgr = 0;
  1929. extern int win95selectbug;
  1930. extern int win95_8_3;
  1931. #ifdef COMMENT
  1932. extern CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])(CHAR);
  1933. extern struct keytab tcstab[];
  1934. extern int ntcs;
  1935. #endif /* COMMENT */
  1936. extern int maxow, maxow_usr; owwait; /* Overlapped I/O variables */
  1937. #endif /* NT */
  1938. #endif /* OS2 */
  1939. /* The following routines broken out of doprm() to give compilers a break. */
  1940. /* S E T O N -- Parse on/off (default on), set parameter to result */
  1941. int
  1942. seton(prm) int *prm; {
  1943. int x, y;
  1944. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  1945. if ((x = cmcfm()) < 0) return(x);
  1946. *prm = y;
  1947. return(1);
  1948. }
  1949. /* S E T O N A U T O -- Parse on/off/auto (default auto) & set result */
  1950. struct keytab onoffaut[] = {
  1951. { "auto", SET_AUTO, 0 }, /* 2 */
  1952. { "off", SET_OFF, 0 }, /* 0 */
  1953. { "on", SET_ON, 0 } /* 1 */
  1954. };
  1955. int
  1956. setonaut(prm) int *prm; {
  1957. int x, y;
  1958. if ((y = cmkey(onoffaut,3,"","auto",xxstring)) < 0) return(y);
  1959. if ((x = cmcfm()) < 0) return(x);
  1960. *prm = y;
  1961. return(1);
  1962. }
  1963. /* S E T N U M -- Set parameter to result of cmnum() parse. */
  1964. /*
  1965. Call with pointer to integer variable to be set,
  1966. x = number from cnum parse, y = return code from cmnum,
  1967. max = maximum value to accept, -1 if no maximum.
  1968. Returns -9 on failure, after printing a message, or 1 on success.
  1969. */
  1970. int
  1971. setnum(prm,x,y,max) int x, y, *prm, max; {
  1972. debug(F101,"setnum","",y);
  1973. if (y == -3) {
  1974. printf("\n?Value required\n");
  1975. return(-9);
  1976. }
  1977. if (y == -2) {
  1978. printf("%s?Not a number: %s\n",cmflgs == 1 ? "" : "\n", atxbuf);
  1979. return(-9);
  1980. }
  1981. if (y < 0) return(y);
  1982. if (max > -1 && x > max) {
  1983. printf("?Sorry, %d is the maximum\n",max);
  1984. return(-9);
  1985. }
  1986. if ((y = cmcfm()) < 0) return(y);
  1987. *prm = x;
  1988. return(1);
  1989. }
  1990. /* S E T C C -- Set parameter var to an ASCII control character value. */
  1991. /*
  1992. Parses a number, or a literal control character, or a caret (^) followed
  1993. by an ASCII character whose value is 63-95 or 97-122, then gets confirmation,
  1994. then sets the parameter to the code value of the character given. If there
  1995. are any parse errors, they are returned, otherwise on success 1 is returned.
  1996. */
  1997. int
  1998. setcc(dflt,var) char *dflt; int *var; {
  1999. int x, y;
  2000. unsigned int c;
  2001. char *hlpmsg = "Control character,\n\
  2002. numeric ASCII value,\n\
  2003. or in ^X notation,\n\
  2004. or preceded by a backslash and entered literally";
  2005. /* This is a hack to turn off complaints from expression evaluator. */
  2006. x_ifnum = 1;
  2007. y = cmnum(hlpmsg, dflt, 10, &x, xxstring); /* Parse a number */
  2008. x_ifnum = 0; /* Allow complaints again */
  2009. if (y < 0) { /* Parse failed */
  2010. if (y != -2) /* Reparse needed or somesuch */
  2011. return(y); /* Pass failure back up the chain */
  2012. }
  2013. /* Real control character or literal 8-bit character... */
  2014. for (c = strlen(atmbuf) - 1; c > 0; c--) /* Trim */
  2015. if (atmbuf[c] == SP) atmbuf[c] = NUL;
  2016. if (y < 0) { /* It was not a number */
  2017. if (((c = atmbuf[0])) && !atmbuf[1]) { /* Literal character? */
  2018. c &= 0xff;
  2019. if (((c > 31) && (c < 127)) || (c > 255)) {
  2020. printf("\n?%d: Out of range - must be 0-31 or 127-255\n",c);
  2021. return(-9);
  2022. } else {
  2023. if ((y = cmcfm()) < 0) /* Confirm */
  2024. return(y);
  2025. *var = c; /* Set the variable */
  2026. return(1);
  2027. }
  2028. } else if (atmbuf[0] == '^' && !atmbuf[2]) { /* Or ^X notation? */
  2029. c = atmbuf[1];
  2030. if (islower((char) c)) /* Uppercase lowercase letters */
  2031. c = toupper(c);
  2032. if (c > 62 && c < 96) { /* Check range */
  2033. if ((y = cmcfm()) < 0)
  2034. return(y);
  2035. *var = ctl(c); /* OK */
  2036. return(1);
  2037. } else {
  2038. printf("?Not a control character - %s\n", atmbuf);
  2039. return(-9);
  2040. }
  2041. } else { /* Something illegal was typed */
  2042. printf("?Not valid here - '%s'\n", atmbuf);
  2043. return(-9);
  2044. }
  2045. }
  2046. if (((x > 31) && (x < 127)) || (x > 255)) { /* They typed a number */
  2047. printf("\n?%d: Out of range - must be 0-31 or 127-255\n",x);
  2048. return(-9);
  2049. }
  2050. if ((y = cmcfm()) < 0) /* In range, confirm */
  2051. return(y);
  2052. *var = x; /* Set variable */
  2053. return(1);
  2054. }
  2055. #ifndef NOSPL /* The SORT command... */
  2056. static struct keytab srtswtab[] = { /* SORT command switches */
  2057. { "/case", SRT_CAS, CM_ARG },
  2058. { "/key", SRT_KEY, CM_ARG },
  2059. { "/numeric", SRT_NUM, 0 },
  2060. { "/range", SRT_RNG, CM_ARG },
  2061. { "/reverse", SRT_REV, 0 }
  2062. };
  2063. static int nsrtswtab = sizeof(srtswtab)/sizeof(struct keytab);
  2064. extern char **a_ptr[]; /* Array pointers */
  2065. extern int a_dim[]; /* Array dimensions */
  2066. int
  2067. dosort() { /* Do the SORT command */
  2068. char c, *p = NULL, ** ap, ** xp = NULL;
  2069. struct FDB sw, fl, cm;
  2070. int hi, lo;
  2071. int xn = 0, xr = -1, xk = -1, xc = -1, xs = 0;
  2072. int getval = 0, range[2], confirmed = 0;
  2073. cmfdbi(&sw, /* First FDB - command switches */
  2074. _CMKEY, /* fcode */
  2075. "Array name or switch",
  2076. "", /* default */
  2077. "", /* addtl string data */
  2078. nsrtswtab, /* addtl numeric data 1: tbl size */
  2079. 4, /* addtl numeric data 2: 4 = cmswi */
  2080. NULL, /* Processing function */
  2081. srtswtab, /* Keyword table */
  2082. &fl /* Pointer to next FDB */
  2083. );
  2084. cmfdbi(&fl, /* Anything that doesn't match */
  2085. _CMFLD, /* fcode */
  2086. "Array name", /* hlpmsg */
  2087. "", /* default */
  2088. "", /* addtl string data */
  2089. 0, /* addtl numeric data 1 */
  2090. 0, /* addtl numeric data 2 */
  2091. NULL,
  2092. NULL,
  2093. &cm
  2094. );
  2095. cmfdbi(&cm, /* Or premature confirmation */
  2096. _CMCFM, /* fcode */
  2097. "", /* hlpmsg */
  2098. "", /* default */
  2099. "", /* addtl string data */
  2100. 0, /* addtl numeric data 1 */
  2101. 0, /* addtl numeric data 2 */
  2102. NULL,
  2103. NULL,
  2104. NULL
  2105. );
  2106. range[0] = -1;
  2107. range[1] = -1;
  2108. while (1) { /* Parse 0 or more switches */
  2109. x = cmfdb(&sw);
  2110. if (x < 0)
  2111. return(x);
  2112. if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
  2113. break;
  2114. c = cmgbrk();
  2115. getval = (c == ':' || c == '=');
  2116. if (getval && !(cmresult.kflags & CM_ARG)) {
  2117. printf("?This switch does not take arguments\n");
  2118. return(-9);
  2119. }
  2120. switch (cmresult.nresult) {
  2121. case SRT_REV:
  2122. xr = 1;
  2123. break;
  2124. case SRT_KEY:
  2125. if (getval) {
  2126. if ((y = cmnum("Column for comparison (1-based)",
  2127. "1",10,&x,xxstring)) < 0)
  2128. return(y);
  2129. xk = x - 1;
  2130. } else
  2131. xk = 0;
  2132. break;
  2133. case SRT_CAS:
  2134. if (getval) {
  2135. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0)
  2136. return(y);
  2137. xc = y;
  2138. } else
  2139. xc = 1;
  2140. break;
  2141. case SRT_RNG: /* /RANGE */
  2142. if (getval) {
  2143. char buf[32];
  2144. char buf2[16];
  2145. int i;
  2146. char * p, * q;
  2147. if ((y = cmfld("low:high element","1",&s,NULL)) < 0)
  2148. return(y);
  2149. s = brstrip(s);
  2150. ckstrncpy(buf,s,32);
  2151. p = buf;
  2152. for (i = 0; *p && i < 2; i++) { /* Get low and high */
  2153. q = p; /* Start of this piece */
  2154. while (*p) { /* Find end of this piece */
  2155. if (*p == ':') {
  2156. *p = NUL;
  2157. p++;
  2158. break;
  2159. }
  2160. p++;
  2161. }
  2162. y = 15; /* Evaluate this piece */
  2163. s = buf2;
  2164. zzstring(q,&s,&y);
  2165. s = evalx(buf2);
  2166. if (s) if (*s) ckstrncpy(buf2,s,16);
  2167. if (!rdigits(buf2)) {
  2168. printf("?Not numeric: %s\n",buf2);
  2169. return(-9);
  2170. }
  2171. range[i] = atoi(buf2);
  2172. }
  2173. }
  2174. break;
  2175. case SRT_NUM: /* /NUMERIC */
  2176. xn = 1;
  2177. break;
  2178. default:
  2179. return(-2);
  2180. }
  2181. }
  2182. switch (cmresult.fcode) {
  2183. case _CMCFM:
  2184. confirmed = 1;
  2185. break;
  2186. case _CMFLD:
  2187. ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Safe copy of name */
  2188. s = line;
  2189. break;
  2190. default:
  2191. printf("?Unexpected function code: %d\n",cmresult.fcode);
  2192. return(-9);
  2193. }
  2194. if (confirmed) {
  2195. printf("?Array name required\n");
  2196. return(-9);
  2197. }
  2198. ckmakmsg(tmpbuf,TMPBUFSIZ,
  2199. "Second array to sort according to ",s,NULL,NULL);
  2200. if ((x = cmfld(tmpbuf,"",&p,NULL)) < 0)
  2201. if (x != -3)
  2202. return(x);
  2203. tmpbuf[0] = NUL;
  2204. ckstrncpy(tmpbuf,p,TMPBUFSIZ);
  2205. p = tmpbuf;
  2206. if ((x = cmcfm()) < 0) /* Get confirmation */
  2207. return(x);
  2208. x = arraybounds(s,&lo,&hi); /* Get array index & bounds */
  2209. if (x < 0) { /* Check */
  2210. printf("?Bad array name: %s\n",s);
  2211. return(-9);
  2212. }
  2213. if (lo > -1) range[0] = lo; /* Set range */
  2214. if (hi > -1) range[1] = hi;
  2215. ap = a_ptr[x]; /* Get pointer to array element list */
  2216. if (!ap) { /* Check */
  2217. printf("?Array not declared: %s\n", s);
  2218. return(-9);
  2219. }
  2220. if (range[0] < 0) /* Starting element */
  2221. range[0] = 1;
  2222. if (range[1] < 0) /* Final element */
  2223. range[1] = a_dim[x];
  2224. if (range[1] > a_dim[x]) {
  2225. printf("?range %d:%d exceeds array dimension %d\n",
  2226. range[0],range[1],a_dim[x]
  2227. );
  2228. return(-9);
  2229. }
  2230. ap += range[0];
  2231. xs = range[1] - range[0] + 1; /* Number of elements to sort */
  2232. if (xs < 1) { /* Check */
  2233. printf("?Bad range: %d:%d\n",range[0],range[1]);
  2234. return(-9);
  2235. }
  2236. if (xk < 0) xk = 0; /* Key position */
  2237. if (xr < 0) xr = 0; /* Reverse flag */
  2238. if (xn) /* Numeric flag */
  2239. xc = 2;
  2240. else if (xc < 0) /* Not numeric */
  2241. xc = inpcas[cmdlvl]; /* so alpha case option */
  2242. if (*p) { /* Parallel array given? */
  2243. y = xarray(p); /* Yes, get its index. */
  2244. if (y < 0) {
  2245. printf("?Bad array name: %s\n", p);
  2246. return(-9);
  2247. }
  2248. if (y != x) { /* If the 2 arrays are different */
  2249. xp = a_ptr[y]; /* Pointer to 2nd array element list */
  2250. if (!xp) {
  2251. printf("?Array not declared: %s\n", p);
  2252. return(-9);
  2253. }
  2254. if (a_dim[y] < range[1]) {
  2255. printf("?Array %s smaller than %s\n", p, s);
  2256. return(-9);
  2257. }
  2258. xp += range[0]; /* Set base to same as 1st array */
  2259. }
  2260. }
  2261. sh_sort(ap,xp,xs,xk,xr,xc); /* Sort the array(s) */
  2262. return(success = 1); /* Always succeeds */
  2263. }
  2264. #endif /* NOSPL */
  2265. static struct keytab purgtab[] = { /* PURGE command switches */
  2266. { "/after", PU_AFT, CM_ARG },
  2267. { "/ask", PU_ASK, 0 },
  2268. { "/before", PU_BEF, CM_ARG },
  2269. { "/delete", PU_DELE, CM_INV },
  2270. #ifdef UNIXOROSK
  2271. { "/dotfiles", PU_DOT, 0 },
  2272. #endif /* UNIXOROSK */
  2273. { "/except", PU_EXC, CM_ARG },
  2274. { "/heading", PU_HDG, 0 },
  2275. { "/keep", PU_KEEP, CM_ARG },
  2276. { "/larger-than", PU_LAR, CM_ARG },
  2277. { "/list", PU_LIST, 0 },
  2278. { "/log", PU_LIST, CM_INV },
  2279. { "/noask", PU_NASK, 0 },
  2280. { "/nodelete", PU_NODE, CM_INV },
  2281. #ifdef UNIXOROSK
  2282. { "/nodotfiles", PU_NODOT,0 },
  2283. #endif /* UNIXOROSK */
  2284. { "/noheading", PU_NOH, 0 },
  2285. { "/nol", PU_NOLI, CM_INV|CM_ABR },
  2286. { "/nolist", PU_NOLI, 0 },
  2287. { "/nolog", PU_NOLI, CM_INV },
  2288. #ifdef CK_TTGWSIZ
  2289. { "/nopage", PU_NOPA, 0 },
  2290. #endif /* CK_TTGWSIZ */
  2291. { "/not-after", PU_NAF, CM_ARG },
  2292. { "/not-before", PU_NBF, CM_ARG },
  2293. { "/not-since", PU_NAF, CM_INV|CM_ARG },
  2294. #ifdef CK_TTGWSIZ
  2295. { "/page", PU_PAGE, 0 },
  2296. #endif /* CK_TTGWSIZ */
  2297. { "/quiet", PU_QUIE, CM_INV },
  2298. #ifdef RECURSIVE
  2299. { "/recursive", PU_RECU, 0 },
  2300. #endif /* RECURSIVE */
  2301. { "/since", PU_AFT, CM_ARG|CM_INV },
  2302. { "/simulate", PU_NODE, 0 },
  2303. { "/smaller-than", PU_SMA, CM_ARG },
  2304. { "/verbose", PU_VERB, CM_INV }
  2305. };
  2306. static int npurgtab = sizeof(purgtab)/sizeof(struct keytab);
  2307. int
  2308. bkupnum(s,i) char * s; int *i; {
  2309. int k = 0, pos = 0;
  2310. char * p = NULL, *q;
  2311. *i = pos;
  2312. if (!s) s = "";
  2313. if (!*s)
  2314. return(-1);
  2315. if ((k = strlen(s)) < 5)
  2316. return(-1);
  2317. if (s[k-1] != '~')
  2318. return(-1);
  2319. pos = k - 2;
  2320. q = s + pos;
  2321. while (q >= s && isdigit(*q)) {
  2322. p = q--;
  2323. pos--;
  2324. }
  2325. if (!p)
  2326. return(-1);
  2327. if (q < s+2)
  2328. return(-1);
  2329. if (*q != '~' || *(q-1) != '.')
  2330. return(-1);
  2331. pos--;
  2332. *i = pos;
  2333. debug(F111,"bkupnum",s+pos,pos);
  2334. return(atoi(p));
  2335. }
  2336. #ifdef CKPURGE
  2337. /* Presently only for UNIX because we need direct access to the file array. */
  2338. /* Not needed for VMS anyway, because we don't make backup files there. */
  2339. #define MAXKEEP 32 /* Biggest /KEEP: value */
  2340. static int
  2341. pu_keep = 0, pu_list = 0, pu_dot = 0, pu_ask = 0, pu_hdg = 0;
  2342. #ifdef CK_TTGWSIZ
  2343. static int pu_page = -1;
  2344. #else
  2345. static int pu_page = 0;
  2346. #endif /* CK_TTGWSIZ */
  2347. #ifndef NOSHOW
  2348. VOID
  2349. showpurgopts() { /* SHOW PURGE command options */
  2350. int x = 0;
  2351. extern int optlines;
  2352. prtopt(&optlines,"PURGE");
  2353. if (pu_ask > -1) {
  2354. x++;
  2355. prtopt(&optlines, pu_ask ? "/ASK" : "/NOASK");
  2356. }
  2357. #ifdef UNIXOROSK
  2358. if (pu_dot > -1) {
  2359. x++;
  2360. prtopt(&optlines, pu_dot ? "/DOTFILES" : "/NODOTFILES");
  2361. }
  2362. #endif /* UNIXOROSK */
  2363. if (pu_keep > -1) {
  2364. x++;
  2365. ckmakmsg(tmpbuf,TMPBUFSIZ,"/KEEP:",ckitoa(pu_keep),NULL,NULL);
  2366. prtopt(&optlines,tmpbuf);
  2367. }
  2368. if (pu_list > -1) {
  2369. x++;
  2370. prtopt(&optlines, pu_list ? "/LIST" : "/NOLIST");
  2371. }
  2372. if (pu_hdg > -1) {
  2373. x++;
  2374. prtopt(&optlines, pu_hdg ? "/HEADING" : "/NOHEADING");
  2375. }
  2376. #ifdef CK_TTGWSIZ
  2377. if (pu_page > -1) {
  2378. x++;
  2379. prtopt(&optlines, pu_page ? "/PAGE" : "/NOPAGE");
  2380. }
  2381. #endif /* CK_TTGWSIZ */
  2382. if (!x) prtopt(&optlines,"(no options set)");
  2383. prtopt(&optlines,"");
  2384. }
  2385. #endif /* NOSHOW */
  2386. int
  2387. setpurgopts() { /* Set PURGE command options */
  2388. int c, z, getval = 0;
  2389. int
  2390. x_keep = -1, x_list = -1, x_page = -1,
  2391. x_hdg = -1, x_ask = -1, x_dot = -1;
  2392. while (1) {
  2393. if ((y = cmswi(purgtab,npurgtab,"Switch","",xxstring)) < 0) {
  2394. if (y == -3)
  2395. break;
  2396. else
  2397. return(y);
  2398. }
  2399. c = cmgbrk();
  2400. if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
  2401. printf("?This switch does not take an argument\n");
  2402. return(-9);
  2403. }
  2404. if (!getval && (cmgkwflgs() & CM_ARG)) {
  2405. printf("?This switch requires an argument\n");
  2406. return(-9);
  2407. }
  2408. switch (y) {
  2409. case PU_KEEP:
  2410. z = 1;
  2411. if (c == ':' || c == '=')
  2412. if ((y = cmnum("How many backup files to keep",
  2413. "1",10,&z,xxstring)) < 0)
  2414. return(y);
  2415. if (z < 0 || z > MAXKEEP) {
  2416. printf("?Please specify a number between 0 and %d\n",
  2417. MAXKEEP
  2418. );
  2419. return(-9);
  2420. }
  2421. x_keep = z;
  2422. break;
  2423. case PU_LIST:
  2424. case PU_VERB:
  2425. x_list = 1;
  2426. break;
  2427. case PU_QUIE:
  2428. case PU_NOLI:
  2429. x_list = 0;
  2430. break;
  2431. #ifdef CK_TTGWSIZ
  2432. case PU_PAGE:
  2433. x_page = 1;
  2434. break;
  2435. case PU_NOPA:
  2436. x_page = 0;
  2437. break;
  2438. #endif /* CK_TTGWSIZ */
  2439. case PU_HDG:
  2440. x_hdg = 1;
  2441. break;
  2442. case PU_NOH:
  2443. x_hdg = 0;
  2444. break;
  2445. case PU_ASK:
  2446. x_ask = 1;
  2447. break;
  2448. case PU_NASK:
  2449. x_ask = 0;
  2450. break;
  2451. #ifdef UNIXOROSK
  2452. case PU_DOT:
  2453. x_dot = 1;
  2454. break;
  2455. case PU_NODOT:
  2456. x_dot = 0;
  2457. break;
  2458. #endif /* UNIXOROSK */
  2459. default:
  2460. printf("?This option can not be set\n");
  2461. return(-9);
  2462. }
  2463. }
  2464. if ((x = cmcfm()) < 0) /* Get confirmation */
  2465. return(x);
  2466. if (x_keep > -1) /* Set PURGE defaults. */
  2467. pu_keep = x_keep;
  2468. if (x_list > -1)
  2469. pu_list = x_list;
  2470. #ifdef CK_TTGWSIZ
  2471. if (x_page > -1)
  2472. pu_page = x_page;
  2473. #endif /* CK_TTGWSIZ */
  2474. if (x_hdg > -1)
  2475. pu_hdg = x_hdg;
  2476. if (x_ask > -1)
  2477. pu_ask = x_ask;
  2478. if (x_dot > -1)
  2479. pu_dot = x_dot;
  2480. return(success = 1);
  2481. }
  2482. int
  2483. dopurge() { /* Do the PURGE command */
  2484. extern char ** mtchs;
  2485. extern int xaskmore, cmd_rows, recursive;
  2486. int simulate = 0, asking = 0;
  2487. int listing = 0, paging = -1, lines = 0, deleting = 1, errors = 0;
  2488. struct FDB sw, sf, cm;
  2489. int g, i, j, k, m = 0, n, x, y, z, done = 0, count = 0, flags = 0;
  2490. int tokeep = 0, getval = 0, havename = 0, confirmed = 0;
  2491. int xx[MAXKEEP+1]; /* Array of numbers to keep */
  2492. int min = -1;
  2493. int x_hdg = 0, fs = 0, rc = 0;
  2494. CK_OFF_T minsize = -1L, maxsize = -1L;
  2495. char namebuf[CKMAXPATH+4];
  2496. char basebuf[CKMAXPATH+4];
  2497. char
  2498. * pu_aft = NULL,
  2499. * pu_bef = NULL,
  2500. * pu_naf = NULL,
  2501. * pu_nbf = NULL,
  2502. * pu_exc = NULL;
  2503. char * pxlist[8]; /* Exception list */
  2504. if (pu_keep > -1) /* Set PURGE defaults. */
  2505. tokeep = pu_keep;
  2506. if (pu_list > -1)
  2507. listing = pu_list;
  2508. #ifdef CK_TTGWSIZ
  2509. if (pu_page > -1)
  2510. paging = pu_page;
  2511. #endif /* CK_TTGWSIZ */
  2512. for (i = 0; i <= MAXKEEP; i++) /* Clear this number buffer */
  2513. xx[i] = 0;
  2514. for (i = 0; i < 8; i++) /* Initialize these... */
  2515. pxlist[i] = NULL;
  2516. g_matchdot = matchdot; /* Save these... */
  2517. cmfdbi(&sw, /* 1st FDB - PURGE switches */
  2518. _CMKEY, /* fcode */
  2519. "Filename or switch", /* hlpmsg */
  2520. "", /* default */
  2521. "", /* addtl string data */
  2522. npurgtab, /* addtl numeric data 1: tbl size */
  2523. 4, /* addtl numeric data 2: 4 = cmswi */
  2524. xxstring, /* Processing function */
  2525. purgtab, /* Keyword table */
  2526. &sf /* Pointer to next FDB */
  2527. );
  2528. cmfdbi(&sf, /* 2nd FDB - filespec to purge */
  2529. _CMIFI, /* fcode */
  2530. "",
  2531. "", /* default */
  2532. "", /* addtl string data */
  2533. 0, /* addtl numeric data 1 */
  2534. 0, /* addtl numeric data 2 */
  2535. xxstring,
  2536. NULL,
  2537. &cm
  2538. );
  2539. cmfdbi(&cm, /* Or premature confirmation */
  2540. _CMCFM, /* fcode */
  2541. "", /* hlpmsg */
  2542. "", /* default */
  2543. "", /* addtl string data */
  2544. 0, /* addtl numeric data 1 */
  2545. 0, /* addtl numeric data 2 */
  2546. NULL,
  2547. NULL,
  2548. NULL
  2549. );
  2550. while (!havename && !confirmed) {
  2551. x = cmfdb(&sw); /* Parse something */
  2552. if (x < 0) { /* Error */
  2553. rc = x;
  2554. goto xpurge;
  2555. } else if (cmresult.fcode == _CMKEY) {
  2556. char c;
  2557. c = cmgbrk();
  2558. if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
  2559. printf("?This switch does not take an argument\n");
  2560. rc = -9;
  2561. goto xpurge;
  2562. }
  2563. if (!getval && (cmgkwflgs() & CM_ARG)) {
  2564. printf("?This switch requires an argument\n");
  2565. rc = -9;
  2566. goto xpurge;
  2567. }
  2568. switch (k = cmresult.nresult) {
  2569. case PU_KEEP:
  2570. z = 1;
  2571. if (c == ':' || c == '=') {
  2572. if ((y = cmnum("How many backup files to keep",
  2573. "1",10,&z,xxstring)) < 0) {
  2574. rc = y;
  2575. goto xpurge;
  2576. }
  2577. }
  2578. if (z < 0 || z > MAXKEEP) {
  2579. printf("?Please specify a number between 0 and %d\n",
  2580. MAXKEEP
  2581. );
  2582. rc = -9;
  2583. goto xpurge;
  2584. }
  2585. tokeep = z;
  2586. break;
  2587. case PU_LIST:
  2588. listing = 1;
  2589. break;
  2590. case PU_NOLI:
  2591. listing = 0;
  2592. break;
  2593. #ifdef CK_TTGWSIZ
  2594. case PU_PAGE:
  2595. paging = 1;
  2596. break;
  2597. case PU_NOPA:
  2598. paging = 0;
  2599. break;
  2600. #endif /* CK_TTGWSIZ */
  2601. case PU_DELE:
  2602. deleting = 1;
  2603. break;
  2604. case PU_NODE:
  2605. deleting = 0;
  2606. simulate = 1;
  2607. listing = 1;
  2608. break;
  2609. case PU_ASK:
  2610. asking = 1;
  2611. break;
  2612. case PU_NASK:
  2613. asking = 0;
  2614. break;
  2615. case PU_AFT:
  2616. case PU_BEF:
  2617. case PU_NAF:
  2618. case PU_NBF:
  2619. if ((x = cmdate("File-time","",&s,0,xxstring)) < 0) {
  2620. if (x == -3) {
  2621. printf("?Date-time required\n");
  2622. rc = -9;
  2623. } else
  2624. rc = x;
  2625. goto xpurge;
  2626. }
  2627. fs++;
  2628. switch (k) {
  2629. case PU_AFT: makestr(&pu_aft,s); break;
  2630. case PU_BEF: makestr(&pu_bef,s); break;
  2631. case PU_NAF: makestr(&pu_naf,s); break;
  2632. case PU_NBF: makestr(&pu_nbf,s); break;
  2633. }
  2634. break;
  2635. case PU_SMA:
  2636. case PU_LAR:
  2637. if ((x = cmnum("File size in bytes","0",10,&y,xxstring)) < 0) {
  2638. rc = x;
  2639. goto xpurge;
  2640. }
  2641. fs++;
  2642. switch (cmresult.nresult) {
  2643. case PU_SMA: minsize = y; break;
  2644. case PU_LAR: maxsize = y; break;
  2645. }
  2646. break;
  2647. case PU_DOT:
  2648. matchdot = 1;
  2649. break;
  2650. case PU_NODOT:
  2651. matchdot = 0;
  2652. break;
  2653. case PU_EXC:
  2654. if ((x = cmfld("Pattern","",&s,xxstring)) < 0) {
  2655. if (x == -3) {
  2656. printf("?Pattern required\n");
  2657. rc = -9;
  2658. } else
  2659. rc = x;
  2660. goto xpurge;
  2661. }
  2662. fs++;
  2663. makestr(&pu_exc,s);
  2664. break;
  2665. case PU_HDG:
  2666. x_hdg = 1;
  2667. break;
  2668. #ifdef RECURSIVE
  2669. case PU_RECU: /* /RECURSIVE */
  2670. recursive = 2;
  2671. break;
  2672. #endif /* RECURSIVE */
  2673. default:
  2674. printf("?Not implemented yet - \"%s\"\n",atmbuf);
  2675. rc = -9;
  2676. goto xpurge;
  2677. }
  2678. } else if (cmresult.fcode == _CMIFI) {
  2679. havename = 1;
  2680. } else if (cmresult.fcode == _CMCFM) {
  2681. confirmed = 1;
  2682. } else {
  2683. rc = -2;
  2684. goto xpurge;
  2685. }
  2686. }
  2687. if (havename) {
  2688. #ifdef CKREGEX
  2689. ckmakmsg(line,LINBUFSIZ,cmresult.sresult,".~[1-9]*~",NULL,NULL);
  2690. #else
  2691. ckmakmsg(line,LINBUFSIZ,cmresult.sresult,".~*~",NULL,NULL);
  2692. #endif /* CKREGEX */
  2693. } else {
  2694. #ifdef CKREGEX
  2695. ckstrncpy(line,"*.~[1-9]*~",LINBUFSIZ);
  2696. #else
  2697. ckstrncpy(line,"*.~*~",LINBUFSIZ);
  2698. #endif /* CKREGEX */
  2699. }
  2700. if (!confirmed) {
  2701. if ((x = cmcfm()) < 0) {
  2702. rc = x;
  2703. goto xpurge;
  2704. }
  2705. }
  2706. /* Parse finished - now action */
  2707. #ifdef CK_LOGIN
  2708. if (isguest) {
  2709. printf("?File deletion by guests not permitted.\n");
  2710. rc = -9;
  2711. goto xpurge;
  2712. }
  2713. #endif /* CK_LOGIN */
  2714. #ifdef CK_TTGWSIZ
  2715. if (paging < 0) /* /[NO]PAGE not given */
  2716. paging = xaskmore; /* so use prevailing */
  2717. #endif /* CK_TTGWSIZ */
  2718. lines = 0;
  2719. if (x_hdg > 0) {
  2720. printf("Purging %s, keeping %d...%s\n",
  2721. s,
  2722. tokeep,
  2723. simulate ? " (SIMULATION)" : "");
  2724. lines += 2;
  2725. }
  2726. flags = ZX_FILONLY;
  2727. if (recursive) flags |= ZX_RECURSE;
  2728. n = nzxpand(line,flags); /* Get list of backup files */
  2729. if (tokeep < 1) { /* Deleting all of them... */
  2730. for (i = 0; i < n; i++) {
  2731. if (fs) if (fileselect(mtchs[i],
  2732. pu_aft,pu_bef,pu_naf,pu_nbf,
  2733. minsize,maxsize,0,8,pxlist) < 1) {
  2734. if (listing > 0) {
  2735. printf(" %s (SKIPPED)\n",mtchs[i]);
  2736. #ifdef CK_TTGWSIZ
  2737. if (paging)
  2738. if (++lines > cmd_rows - 3) {
  2739. if (!askmore()) goto xpurge; else lines = 0;
  2740. }
  2741. #endif /* CK_TTGWSIZ */
  2742. }
  2743. continue;
  2744. }
  2745. if (asking) {
  2746. int x;
  2747. ckmakmsg(tmpbuf,TMPBUFSIZ," Delete ",mtchs[i],"?",NULL);
  2748. x = getyesno(tmpbuf,1);
  2749. switch (x) {
  2750. case 0: continue;
  2751. case 1: break;
  2752. case 2: goto xpurge;
  2753. }
  2754. }
  2755. x = deleting ? zdelet(mtchs[i]) : 0;
  2756. if (x > -1) {
  2757. if (listing)
  2758. printf(" %s (%s)\n", mtchs[i],deleting ? "OK" : "SELECTED");
  2759. count++;
  2760. } else {
  2761. errors++;
  2762. if (listing)
  2763. printf(" %s (FAILED)\n", mtchs[i]);
  2764. }
  2765. #ifdef CK_TTGWSIZ
  2766. if (listing && paging)
  2767. if (++lines > cmd_rows - 3) {
  2768. if (!askmore()) goto xpurge; else lines = 0;
  2769. }
  2770. #endif /* CK_TTGWSIZ */
  2771. }
  2772. goto xpurge;
  2773. }
  2774. if (n < tokeep) { /* Not deleting any */
  2775. count = 0;
  2776. if (listing)
  2777. printf(" Matches = %d: Not enough to purge.\n",n);
  2778. goto xpurge;
  2779. }
  2780. /* General case - delete some but not others */
  2781. sh_sort(mtchs,NULL,n,0,0,filecase); /* Alphabetize the list (ESSENTIAL) */
  2782. g = 0; /* Start of current group */
  2783. for (i = 0; i < n; i++) { /* Go thru sorted file list */
  2784. x = znext(namebuf); /* Get next file */
  2785. if (x < 1 || !namebuf[0] || i == n - 1) /* No more? */
  2786. done = 1; /* NOTE: 'done' must be 0 or 1 only */
  2787. if (fs) if (fileselect(namebuf,
  2788. pu_aft,pu_bef,pu_naf,pu_nbf,
  2789. minsize,maxsize,0,8,pxlist) < 1) {
  2790. if (listing > 0) {
  2791. printf(" %s (SKIPPED)\n",namebuf);
  2792. if (++lines > cmd_rows - 3)
  2793. if (!askmore()) goto xpurge; else lines = 0;
  2794. }
  2795. continue;
  2796. }
  2797. if (x > 0)
  2798. if ((m = bkupnum(namebuf,&z)) < 0) /* This file's backup number. */
  2799. continue;
  2800. for (j = 0; j < tokeep; j++) { /* Insert in list. */
  2801. if (m > xx[j]) {
  2802. for (k = tokeep - 1; k > j; k--)
  2803. xx[k] = xx[k-1];
  2804. xx[j] = m;
  2805. break;
  2806. }
  2807. }
  2808. /* New group? */
  2809. if (done || (i > 0 && ckstrcmp(namebuf,basebuf,z,1))) {
  2810. if (i + done - g > tokeep) { /* Do we have enough to purge? */
  2811. min = xx[tokeep-1]; /* Yes, lowest backup number to keep */
  2812. debug(F111,"dopurge group",basebuf,min);
  2813. for (j = g; j < i + done; j++) { /* Go through this group */
  2814. x = bkupnum(mtchs[j],&z); /* Get file backup number */
  2815. if (x > 0 && x < min) { /* Below minimum? */
  2816. x = deleting ? zdelet(mtchs[j]) : 0;
  2817. if (x < 0) errors++;
  2818. if (listing)
  2819. printf(" %s (%s)\n",
  2820. mtchs[j],
  2821. ((x < 0) ? "ERROR" :
  2822. (deleting ? "DELETED" : "SELECTED"))
  2823. );
  2824. count++;
  2825. } else if (listing) /* Not below minimum - keep this one */
  2826. printf(" %s (KEPT)\n",mtchs[j]);
  2827. #ifdef CK_TTGWSIZ
  2828. if (listing && paging)
  2829. if (++lines > cmd_rows - 3) {
  2830. if (!askmore()) goto xpurge; else lines = 0;
  2831. }
  2832. #endif /* CK_TTGWSIZ */
  2833. }
  2834. } else if (listing && paging) { /* Not enough to purge */
  2835. printf(" %s.~*~ (KEPT)\n",basebuf);
  2836. #ifdef CK_TTGWSIZ
  2837. if (++lines > cmd_rows - 3) {
  2838. if (!askmore()) goto xpurge; else lines = 0;
  2839. }
  2840. #endif /* CK_TTGWSIZ */
  2841. }
  2842. for (j = 0; j < tokeep; j++) /* Clear the backup number list */
  2843. xx[j] = 0;
  2844. g = i; /* Reset the group pointer */
  2845. }
  2846. if (done) /* No more files, done. */
  2847. break;
  2848. strncpy(basebuf,namebuf,z); /* Set basename of this file */
  2849. basebuf[z] = NUL;
  2850. }
  2851. xpurge: /* Common exit point */
  2852. if (g_matchdot > -1) {
  2853. matchdot = g_matchdot; /* Restore these... */
  2854. g_matchdot = -1;
  2855. }
  2856. if (rc < 0) return(rc); /* Parse error */
  2857. if (x_hdg)
  2858. printf("Files purged: %d%s\n",
  2859. count,
  2860. deleting ? "" : " (not really)"
  2861. );
  2862. return(success = count > 0 ? 1 : (errors > 0) ? 0 : 1);
  2863. }
  2864. #endif /* CKPURGE */
  2865. #ifndef NOXFER
  2866. #ifndef NOLOCAL
  2867. int
  2868. doxdis(which) int which; { /* 1 = Kermit, 2 = FTP */
  2869. extern int nolocal;
  2870. int x, y = 0, z;
  2871. #ifdef NEWFTP
  2872. extern int ftp_dis;
  2873. #endif /* NEWFTP */
  2874. #ifdef COMMENT
  2875. char *s;
  2876. #endif /* COMMENT */
  2877. if ((x = cmkey(fdtab,nfdtab,"file transfer display style","",
  2878. xxstring)) < 0)
  2879. return(x);
  2880. #ifdef CK_PCT_BAR
  2881. if ((y = cmkey(fdftab,2,"","thermometer",xxstring)) < 0)
  2882. return(y);
  2883. #endif /* CK_PCT_BAR */
  2884. if ((z = cmcfm()) < 0) return(z);
  2885. #ifdef CK_CURSES
  2886. if (x == XYFD_C) { /* FULLSCREEN */
  2887. #ifdef COMMENT
  2888. #ifndef MYCURSES
  2889. extern char * trmbuf; /* Real curses */
  2890. int z;
  2891. #endif /* MYCURSES */
  2892. #endif /* COMMENT */
  2893. if (nolocal) /* Nothing to do in this case */
  2894. return(success = 1);
  2895. #ifdef COMMENT
  2896. #ifndef MYCURSES
  2897. #ifndef VMS
  2898. s = getenv("TERM");
  2899. debug(F110,"doxdis TERM",s,0);
  2900. if (!s) s = "";
  2901. fxdinit(x);
  2902. if (*s && trmbuf) { /* Don't call tgetent */
  2903. z = tgetent(trmbuf,s); /* if trmbuf not allocated */
  2904. debug(F111,"doxdis tgetent",s,z);
  2905. } else {
  2906. z = 0;
  2907. debug(F110,"doxdis tgetent skipped",s,0);
  2908. }
  2909. if (z < 1) {
  2910. printf("Sorry, terminal type unknown: \"%s\"\n",s);
  2911. return(success = 0);
  2912. }
  2913. #endif /* VMS */
  2914. #endif /* MYCURSES */
  2915. #else
  2916. fxdinit(x);
  2917. #endif /* COMMENT */
  2918. #ifdef CK_PCT_BAR
  2919. thermometer = y;
  2920. #endif /* CK_PCT_BAR */
  2921. line[0] = '\0'; /* (What's this for?) */
  2922. }
  2923. #endif /* CK_CURSES */
  2924. if (which == 1) /* It's OK. */
  2925. fdispla = x;
  2926. #ifdef NEWFTP
  2927. else if (which == 2)
  2928. ftp_dis = x;
  2929. #endif /* NEWFTP */
  2930. return(success = 1);
  2931. }
  2932. #endif /* NOLOCAL */
  2933. #endif /* NOXFER */
  2934. int
  2935. setfil(rmsflg) int rmsflg; {
  2936. #ifdef COMMENT
  2937. extern int en_del;
  2938. #endif /* COMMENT */
  2939. #ifndef NOXFER
  2940. if (rmsflg) {
  2941. if ((y = cmkey(rfiltab,nrfilp,"Remote file parameter","",
  2942. xxstring)) < 0) {
  2943. if (y == -3) {
  2944. printf("?Remote file parameter required\n");
  2945. return(-9);
  2946. } else return(y);
  2947. }
  2948. } else {
  2949. #endif /* NOXFER */
  2950. if ((y = cmkey(filtab,nfilp,"File parameter","",xxstring)) < 0)
  2951. return(y);
  2952. #ifndef NOXFER
  2953. }
  2954. #endif /* NOXFER */
  2955. switch (y) {
  2956. #ifdef COMMENT /* Not needed */
  2957. case XYFILB: /* Blocksize */
  2958. if ((y = cmnum("file block size",ckitoa(DBLKSIZ),10,&z,xxstring)) < 0)
  2959. return(y);
  2960. if ((x = cmcfm()) < 0) return(x);
  2961. if (rmsflg) {
  2962. sstate = setgen('S', "311", ckitoa(z), "");
  2963. return((int) sstate);
  2964. } else {
  2965. fblksiz = z;
  2966. return(success = 1);
  2967. }
  2968. #endif /* COMMENT */
  2969. #ifndef NOXFER
  2970. case XYFILS: /* Byte size */
  2971. if ((y = cmnum("file byte size (7 or 8)","8",10,&z,xxstring)) < 0)
  2972. return(y);
  2973. if (z != 7 && z != 8) {
  2974. printf("\n?The choices are 7 and 8\n");
  2975. return(0);
  2976. }
  2977. if ((y = cmcfm()) < 0) return(y);
  2978. if (z == 7) fmask = 0177;
  2979. else if (z == 8) fmask = 0377;
  2980. return(success = 1);
  2981. #ifndef NOCSETS
  2982. case XYFILC: { /* Character set */
  2983. char * csetname = NULL;
  2984. extern int
  2985. r_cset, s_cset, afcset[]; /* SEND CHARACTER-SET AUTO or MANUAL */
  2986. struct FDB kw, fl;
  2987. cmfdbi(&kw, /* First FDB - command switches */
  2988. _CMKEY, /* fcode */
  2989. rmsflg ? "server character-set name" : "", /* help */
  2990. "", /* default */
  2991. "", /* addtl string data */
  2992. nfilc, /* addtl numeric data 1: tbl size */
  2993. 0, /* addtl numeric data 2: 0 = keyword */
  2994. xxstring, /* Processing function */
  2995. fcstab, /* Keyword table */
  2996. rmsflg ? &fl : NULL /* Pointer to next FDB */
  2997. );
  2998. cmfdbi(&fl, /* Anything that doesn't match */
  2999. _CMFLD, /* fcode */
  3000. "", /* hlpmsg */
  3001. "", /* default */
  3002. "", /* addtl string data */
  3003. 0, /* addtl numeric data 1 */
  3004. 0, /* addtl numeric data 2 */
  3005. xxstring,
  3006. NULL,
  3007. NULL
  3008. );
  3009. if ((x = cmfdb(&kw)) < 0)
  3010. return(x);
  3011. if (cmresult.fcode == _CMKEY) {
  3012. x = cmresult.nresult;
  3013. csetname = fcsinfo[x].keyword;
  3014. } else {
  3015. ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  3016. csetname = line;
  3017. }
  3018. if ((z = cmcfm()) < 0) return(z);
  3019. if (rmsflg) {
  3020. sstate = setgen('S', "320", csetname, "");
  3021. return((int) sstate);
  3022. }
  3023. fcharset = x;
  3024. if (s_cset == XMODE_A) /* If SEND CHARACTER-SET is AUTO */
  3025. if (x > -1 && x <= MAXFCSETS)
  3026. if (afcset[x] > -1 && afcset[x] <= MAXTCSETS)
  3027. tcharset = afcset[x]; /* Pick corresponding xfer charset */
  3028. setxlatype(tcharset,fcharset); /* Translation type */
  3029. /* If I say SET FILE CHARACTER-SET blah, I want to be blah! */
  3030. r_cset = XMODE_M; /* Don't switch incoming set! */
  3031. x = fcsinfo[fcharset].size; /* Also set default x-bit charset */
  3032. if (x == 128) /* 7-bit... */
  3033. dcset7 = fcharset;
  3034. else if (x == 256) /* 8-bit... */
  3035. dcset8 = fcharset;
  3036. return(success = 1);
  3037. }
  3038. #endif /* NOCSETS */
  3039. #ifndef NOLOCAL
  3040. case XYFILD: /* Display */
  3041. return(doxdis(1)); /* 1 == kermit */
  3042. #endif /* NOLOCAL */
  3043. #endif /* NOXFER */
  3044. case XYFILA: /* End-of-line */
  3045. #ifdef NLCHAR
  3046. s = "";
  3047. if (NLCHAR == 015)
  3048. s = "cr";
  3049. else if (NLCHAR == 012)
  3050. s = "lf";
  3051. if ((x = cmkey(eoltab, neoltab,
  3052. "local text-file line terminator",s,xxstring)) < 0)
  3053. return(x);
  3054. #else
  3055. if ((x = cmkey(eoltab, neoltab,
  3056. "local text-file line terminator","crlf",xxstring)) < 0)
  3057. return(x);
  3058. #endif /* NLCHAR */
  3059. if ((z = cmcfm()) < 0) return(z);
  3060. feol = (CHAR) x;
  3061. return(success = 1);
  3062. #ifndef NOXFER
  3063. case XYFILN: /* Names */
  3064. if ((x = cmkey(fntab,nfntab,"how to handle filenames","converted",
  3065. xxstring)) < 0)
  3066. return(x);
  3067. if ((z = cmcfm()) < 0) return(z);
  3068. if (rmsflg) {
  3069. sstate = setgen('S', "301", ckitoa(1 - x), "");
  3070. return((int) sstate);
  3071. } else {
  3072. ptab[protocol].fncn = x; /* Set structure */
  3073. fncnv = x; /* Set variable */
  3074. f_save = x; /* And set "permanent" variable */
  3075. return(success = 1);
  3076. }
  3077. case XYFILR: /* Record length */
  3078. if ((y = cmnum("file record length",
  3079. ckitoa(DLRECL),10,&z,xxstring)) < 0)
  3080. return(y);
  3081. if ((x = cmcfm()) < 0) return(x);
  3082. if (rmsflg) {
  3083. sstate = setgen('S', "312", ckitoa(z), "");
  3084. return((int) sstate);
  3085. } else {
  3086. frecl = z;
  3087. return(success = 1);
  3088. }
  3089. #ifdef COMMENT
  3090. case XYFILO: /* Organization */
  3091. if ((x = cmkey(forgtab,nforg,"file organization","sequential",
  3092. xxstring)) < 0)
  3093. return(x);
  3094. if ((y = cmcfm()) < 0) return(y);
  3095. if (rmsflg) {
  3096. sstate = setgen('S', "314", ckitoa(x), "");
  3097. return((int) sstate);
  3098. } else {
  3099. forg = x;
  3100. return(success = 1);
  3101. }
  3102. #endif /* COMMENT */
  3103. #ifdef COMMENT /* Not needed */
  3104. case XYFILF: /* Format */
  3105. if ((x = cmkey(frectab,nfrec,"file record format","stream",
  3106. xxstring)) < 0)
  3107. return(x);
  3108. if ((y = cmcfm()) < 0) return(y);
  3109. if (rmsflg) {
  3110. sstate = setgen('S', "313", ckitoa(x), "");
  3111. return((int) sstate);
  3112. } else {
  3113. frecfm = x;
  3114. return(success = 1);
  3115. }
  3116. #endif /* COMMENT */
  3117. #ifdef COMMENT
  3118. case XYFILP: /* Printer carriage control */
  3119. if ((x = cmkey(fcctab,nfcc,"file carriage control","newline",
  3120. xxstring)) < 0)
  3121. return(x);
  3122. if ((y = cmcfm()) < 0) return(y);
  3123. if (rmsflg) {
  3124. sstate = setgen('S', "315", ckitoa(x), "");
  3125. return((int) sstate);
  3126. } else {
  3127. fcctrl = x;
  3128. return(success = 1);
  3129. }
  3130. #endif /* COMMENT */
  3131. #endif /* NOXFER */
  3132. case XYFILT: /* Type */
  3133. if ((x = cmkey(rmsflg ? rfttab : fttab,
  3134. rmsflg ? nrfttyp : nfttyp,
  3135. "type of file transfer","text",xxstring)) < 0)
  3136. return(x);
  3137. #ifdef VMS
  3138. /* Allow VMS users to choose record format for binary files */
  3139. if ((x == XYFT_B) && (rmsflg == 0)) {
  3140. if ((x = cmkey(fbtab,nfbtyp,"VMS record format","fixed",
  3141. xxstring)) < 0)
  3142. return(x);
  3143. }
  3144. #endif /* VMS */
  3145. if ((y = cmcfm()) < 0) return(y);
  3146. binary = x;
  3147. b_save = x;
  3148. #ifdef MAC
  3149. (void) mac_setfildflg(binary);
  3150. #endif /* MAC */
  3151. #ifndef NOXFER
  3152. if (rmsflg) {
  3153. /* Allow for LABELED in VMS & OS/2 */
  3154. sstate = setgen('S', "300", ckitoa(x), "");
  3155. return((int) sstate);
  3156. } else {
  3157. #endif /* NOXFER */
  3158. return(success = 1);
  3159. #ifndef NOXFER
  3160. }
  3161. #endif /* NOXFER */
  3162. #ifndef NOXFER
  3163. case XYFILX: /* Collision Action */
  3164. if ((x = cmkey(colxtab,ncolx,"Filename collision action","backup",
  3165. xxstring)) < 0)
  3166. return(x);
  3167. if ((y = cmcfm()) < 0) return(y);
  3168. #ifdef CK_LOGIN
  3169. if (isguest) {
  3170. /* Don't let guests change existing files */
  3171. printf("?This command not valid for guests\n");
  3172. return(-9);
  3173. }
  3174. #endif /* CK_LOGIN */
  3175. #ifdef COMMENT
  3176. /* Not appropriate - DISABLE DELETE only refers to server */
  3177. if ((x == XYFX_X || x == XYFX_B || x == XYFX_U || x == XYFX_A) &&
  3178. (!ENABLED(en_del))) {
  3179. printf("?Sorry, file deletion is disabled.\n");
  3180. return(-9);
  3181. }
  3182. #endif /* COMMENT */
  3183. fncact = x;
  3184. ptab[protocol].fnca = x;
  3185. if (rmsflg) {
  3186. sstate = setgen('S', "302", ckitoa(fncact), "");
  3187. return((int) sstate);
  3188. } else {
  3189. if (fncact == XYFX_R) ckwarn = 1; /* FILE WARNING implications */
  3190. if (fncact == XYFX_X) ckwarn = 0; /* ... */
  3191. return(success = 1);
  3192. }
  3193. case XYFILW: /* Warning/Write-Protect */
  3194. if ((x = seton(&ckwarn)) < 0) return(x);
  3195. if (ckwarn)
  3196. fncact = XYFX_R;
  3197. else
  3198. fncact = XYFX_X;
  3199. return(success = 1);
  3200. #ifdef CK_LABELED
  3201. case XYFILL: /* LABELED FILE parameters */
  3202. if ((x = cmkey(lbltab,nlblp,"Labeled file feature","",
  3203. xxstring)) < 0)
  3204. return(x);
  3205. if ((success = seton(&y)) < 0)
  3206. return(success);
  3207. if (y) /* Set or reset the selected bit */
  3208. lf_opts |= x; /* in the options bitmask. */
  3209. else
  3210. lf_opts &= ~x;
  3211. return(success);
  3212. #endif /* CK_LABELED */
  3213. case XYFILI: { /* INCOMPLETE */
  3214. extern struct keytab ifdatab[];
  3215. extern int keep;
  3216. if ((y = cmkey(ifdatab,3,"","auto",xxstring)) < 0) return(y);
  3217. if ((x = cmcfm()) < 0) return(x);
  3218. if (rmsflg) {
  3219. sstate = setgen('S',
  3220. "310",
  3221. y == 0 ? "0" : (y == 1 ? "1" : "2"),
  3222. ""
  3223. );
  3224. return((int) sstate);
  3225. } else {
  3226. keep = y;
  3227. return(success = 1);
  3228. }
  3229. }
  3230. #ifdef CK_TMPDIR
  3231. case XYFILG: { /* Download directory */
  3232. int x;
  3233. char *s;
  3234. #ifdef ZFNQFP
  3235. struct zfnfp * fnp;
  3236. #endif /* ZFNQFP */
  3237. #ifdef MAC
  3238. char temp[34];
  3239. #endif /* MAC */
  3240. #ifdef GEMDOS
  3241. if ((x = cmdir("Name of local directory, or carriage return",
  3242. "",&s,
  3243. NULL)) < 0 ) {
  3244. if (x != -3)
  3245. return(x);
  3246. }
  3247. #else
  3248. #ifdef OS2
  3249. if ((x = cmdir("Name of PC disk and/or directory,\n\
  3250. or press the Enter key to use current directory",
  3251. "",&s,xxstring)) < 0 ) {
  3252. if (x != -3)
  3253. return(x);
  3254. }
  3255. #else
  3256. #ifdef MAC
  3257. x = ckstrncpy(temp,zhome(),32);
  3258. if (x > 0) if (temp[x-1] != ':') { temp[x] = ':'; temp[x+1] = NUL; }
  3259. if ((x = cmtxt("Name of Macintosh volume and/or folder,\n\
  3260. or press the Return key for the desktop on the boot disk",
  3261. temp,&s, xxstring)) < 0 )
  3262. return(x);
  3263. #else
  3264. if ((x = cmdir("Name of local directory, or carriage return",
  3265. "", &s, xxstring)) < 0 ) {
  3266. if (x != -3)
  3267. return(x);
  3268. }
  3269. #endif /* MAC */
  3270. #endif /* OS2 */
  3271. #endif /* GEMDOS */
  3272. debug(F110,"download dir",s,0);
  3273. #ifndef MAC
  3274. if (x == 2) {
  3275. printf("?Wildcards not allowed in directory name\n");
  3276. return(-9);
  3277. }
  3278. #endif /* MAC */
  3279. #ifdef ZFNQFP
  3280. if ((fnp = zfnqfp(s,TMPBUFSIZ - 1,tmpbuf))) {
  3281. if (fnp->fpath)
  3282. if ((int) strlen(fnp->fpath) > 0)
  3283. s = fnp->fpath;
  3284. }
  3285. debug(F110,"download zfnqfp",s,0);
  3286. #endif /* ZFNQFP */
  3287. ckstrncpy(line,s,LINBUFSIZ); /* Make a safe copy */
  3288. #ifndef MAC
  3289. if ((x = cmcfm()) < 0) /* Get confirmation */
  3290. return(x);
  3291. #endif /* MAC */
  3292. #ifdef CK_LOGIN
  3293. if (isguest) {
  3294. /* Don't let guests change existing files */
  3295. printf("?This command not valid for guests\n");
  3296. return(-9);
  3297. }
  3298. #endif /* CK_LOGIN */
  3299. x = strlen(s);
  3300. if (x) {
  3301. #ifdef datageneral /* AOS/VS */
  3302. if (s[x-1] == ':') /* homdir ends in colon, */
  3303. s[x-1] = NUL; /* and "dir" doesn't like that... */
  3304. #else
  3305. #ifdef OS2ORUNIX /* Unix or K-95... */
  3306. if ((x < (LINBUFSIZ - 2)) && /* Add trailing dirsep */
  3307. (s[x-1] != '/')) { /* if none present. */
  3308. s[x] = '/'; /* Note that Windows path has */
  3309. s[x+1] = NUL; /* been canonicalized to forward */
  3310. } /* slashes at this point. */
  3311. #endif /* OS2ORUNIX */
  3312. #endif /* datageneral */
  3313. makestr(&dldir,s);
  3314. } else
  3315. makestr(&dldir,NULL); /* dldir is NULL when not assigned */
  3316. return(success = 1);
  3317. }
  3318. #endif /* CK_TMPDIR */
  3319. case XYFILY:
  3320. return(setdest());
  3321. #endif /* NOXFER */
  3322. #ifdef CK_CTRLZ
  3323. case XYFILV: { /* EOF */
  3324. extern int eofmethod;
  3325. if ((x = cmkey(eoftab,3,"end-of-file detection method","",
  3326. xxstring)) < 0)
  3327. return(x);
  3328. if ((y = cmcfm()) < 0)
  3329. return(y);
  3330. eofmethod = x;
  3331. return(success = 1);
  3332. }
  3333. #endif /* CK_CTRLZ */
  3334. #ifndef NOXFER
  3335. #ifdef UNIX
  3336. case XYFILH: { /* OUTPUT */
  3337. extern int zofbuffer, zobufsize, zofblock;
  3338. #ifdef DYNAMIC
  3339. extern char * zoutbuffer;
  3340. #endif /* DYNAMIC */
  3341. if ((x = cmkey(zoftab,nzoftab,"output file writing method","",
  3342. xxstring)) < 0)
  3343. return(x);
  3344. if (x == ZOF_BUF || x == ZOF_NBUF) {
  3345. if ((y = cmnum("output buffer size","32768",10,&z,xxstring)) < 0)
  3346. return(y);
  3347. if (z < 1) {
  3348. printf("?Bad size - %d\n", z);
  3349. return(-9);
  3350. }
  3351. }
  3352. if ((y = cmcfm()) < 0) return(y);
  3353. switch (x) {
  3354. case ZOF_BUF:
  3355. case ZOF_NBUF:
  3356. zofbuffer = (x == ZOF_BUF);
  3357. zobufsize = z;
  3358. break;
  3359. case ZOF_BLK:
  3360. case ZOF_NBLK:
  3361. zofblock = (x == ZOF_BLK);
  3362. break;
  3363. }
  3364. #ifdef DYNAMIC
  3365. if (zoutbuffer) free(zoutbuffer);
  3366. if (!(zoutbuffer = (char *)malloc(z))) {
  3367. printf("MEMORY ALLOCATION ERROR - FATAL\n");
  3368. doexit(BAD_EXIT,-1);
  3369. } else
  3370. zobufsize = z;
  3371. #else
  3372. if (z <= OBUFSIZE) {
  3373. zobufsize = z;
  3374. } else {
  3375. printf("?Sorry, %d is too big - %d is the maximum\n",z,OBUFSIZE);
  3376. return(-9);
  3377. }
  3378. #endif /* DYNAMIC */
  3379. return(success = 1);
  3380. }
  3381. #endif /* UNIX */
  3382. #ifdef PATTERNS
  3383. case XYFIBP: /* BINARY-PATTERN */
  3384. case XYFITP: { /* TEXT-PATTERN */
  3385. char * tmp[FTPATTERNS];
  3386. int i, n = 0;
  3387. while (n < FTPATTERNS) {
  3388. tmp[n] = NULL;
  3389. if ((x = cmfld("Pattern","",&s,xxstring)) < 0)
  3390. break;
  3391. ckstrncpy(line,s,LINBUFSIZ);
  3392. s = brstrip(line);
  3393. makestr(&(tmp[n++]),s);
  3394. }
  3395. if (x == -3) x = cmcfm();
  3396. for (i = 0; i <= n; i++) {
  3397. if (x > -1) {
  3398. if (y == XYFIBP)
  3399. makestr(&(binpatterns[i]),tmp[i]);
  3400. else
  3401. makestr(&(txtpatterns[i]),tmp[i]);
  3402. }
  3403. free(tmp[i]);
  3404. }
  3405. if (y == XYFIBP) /* Null-terminate the list */
  3406. makestr(&(binpatterns[i]),NULL);
  3407. else
  3408. makestr(&(txtpatterns[i]),NULL);
  3409. return(x);
  3410. }
  3411. case XYFIPA: /* PATTERNS */
  3412. if ((x = setonaut(&patterns)) < 0)
  3413. return(x);
  3414. return(success = 1);
  3415. #endif /* PATTERNS */
  3416. #endif /* NOXFER */
  3417. #ifdef UNICODE
  3418. case XYFILU: { /* UCS */
  3419. extern int ucsorder, ucsbom, byteorder;
  3420. if ((x = cmkey(ucstab,nucstab,"","",xxstring)) < 0)
  3421. return(x);
  3422. switch (x) {
  3423. case UCS_BYT:
  3424. if ((y = cmkey(botab,nbotab,
  3425. "Byte order",
  3426. byteorder ? "little-endian" : "big-endian",
  3427. xxstring
  3428. )
  3429. ) < 0)
  3430. return(y);
  3431. if ((x = cmcfm()) < 0)
  3432. return(x);
  3433. ucsorder = y;
  3434. return(success = 1);
  3435. case UCS_BOM:
  3436. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0)
  3437. return(y);
  3438. if ((x = cmcfm()) < 0)
  3439. return(x);
  3440. ucsbom = y;
  3441. return(success = 1);
  3442. default:
  3443. return(-2);
  3444. }
  3445. }
  3446. #endif /* UNICODE */
  3447. #ifndef datageneral
  3448. case XYF_INSP: { /* SCAN (INSPECTION) */
  3449. extern int filepeek, nscanfile;
  3450. if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
  3451. return(x);
  3452. if (y) {
  3453. if ((y = cmnum("How much to scan",ckitoa(SCANFILEBUF),
  3454. 10,&z,xxstring)) < 0)
  3455. return(y);
  3456. }
  3457. if ((y = cmcfm()) < 0)
  3458. return(y);
  3459. #ifdef VMS
  3460. filepeek = 0;
  3461. nscanfile = 0;
  3462. return(success = 0);
  3463. #else
  3464. filepeek = x;
  3465. nscanfile = z;
  3466. return(success = 1);
  3467. #endif /* VMS */
  3468. }
  3469. #endif /* datageneral */
  3470. case XYF_DFLT:
  3471. y = 0;
  3472. #ifndef NOCSETS
  3473. if ((y = cmkey(fdfltab,nfdflt,"","",xxstring)) < 0)
  3474. return(y);
  3475. if (y == 7 || y == 8) {
  3476. if (y == 7)
  3477. s = fcsinfo[dcset7].keyword;
  3478. else
  3479. s = fcsinfo[dcset8].keyword;
  3480. if ((x = cmkey(fcstab,nfilc,"character-set",s,xxstring)) < 0)
  3481. return(x);
  3482. }
  3483. ckstrncpy(line,fcsinfo[x].keyword,LINBUFSIZ);
  3484. s = line;
  3485. #endif /* NOCSETS */
  3486. if ((z = cmcfm()) < 0)
  3487. return(z);
  3488. switch (y) {
  3489. #ifndef NOCSETS
  3490. case 7:
  3491. if (fcsinfo[x].size != 128) {
  3492. printf("%s - Not a 7-bit set\n",s);
  3493. return(-9);
  3494. }
  3495. dcset7 = x;
  3496. break;
  3497. case 8:
  3498. if (fcsinfo[x].size != 256) {
  3499. printf("%s - Not an 8-bit set\n",s);
  3500. return(-9);
  3501. }
  3502. dcset8 = x;
  3503. break;
  3504. #endif /* NOCSETS */
  3505. default:
  3506. return(-2);
  3507. }
  3508. return(success = 1);
  3509. #ifndef NOXFER
  3510. case 9997: /* FASTLOOKUPS */
  3511. return(success = seton(&stathack));
  3512. #endif /* NOXFER */
  3513. #ifdef UNIX
  3514. #ifdef DYNAMIC
  3515. case XYF_LSIZ: { /* LISTSIZE */
  3516. int zz;
  3517. y = cmnum("Maximum number of filenames","",10,&x,xxstring);
  3518. if ((x = setnum(&zz,x,y,-1)) < 0)
  3519. return(x);
  3520. if (zsetfil(zz,3) < 0) {
  3521. printf("?Memory allocation failure\n");
  3522. return(-9);
  3523. }
  3524. return(success = 1);
  3525. }
  3526. case XYF_SSPA: { /* STRINGSPACE */
  3527. int zz;
  3528. y = cmnum("Number of characters for filename list",
  3529. "",10,&x,xxstring);
  3530. if ((x = setnum(&zz,x,y,-1)) < 0)
  3531. return(x);
  3532. if (zsetfil(zz,1) < 0) {
  3533. printf("?Memory allocation failure\n");
  3534. return(-9);
  3535. }
  3536. return(success = 1);
  3537. }
  3538. #endif /* DYNAMIC */
  3539. #endif /* UNIX */
  3540. default:
  3541. printf("?unexpected file parameter\n");
  3542. return(-2);
  3543. }
  3544. }
  3545. #ifdef UNIX
  3546. #ifndef NOPUTENV
  3547. #ifdef BIGBUFOK
  3548. #define NPUTENVS 4096
  3549. #else
  3550. #define NPUTENVS 128
  3551. #endif /* BIGBUFOK */
  3552. /* environment variables must be static, not automatic */
  3553. static char * putenvs[NPUTENVS]; /* Array of environment var strings */
  3554. static int nputenvs = -1; /* Pointer into array */
  3555. /*
  3556. If anyone ever notices the limitation on the number of PUTENVs, the list
  3557. can be made dynamic, we can recycle entries with the same name, etc.
  3558. */
  3559. int
  3560. doputenv(s1, s2) char * s1; char * s2; {
  3561. char * s, * t = tmpbuf; /* Create or alter environment var */
  3562. if (nputenvs == -1) { /* Table not used yet */
  3563. int i; /* Initialize the pointers */
  3564. for (i = 0; i < NPUTENVS; i++)
  3565. putenvs[i] = NULL;
  3566. nputenvs = 0;
  3567. }
  3568. if (!s1) return(1); /* Nothing to do */
  3569. if (!*s1) return(1); /* ditto */
  3570. if (ckindex("=",s1,0,0,0)) { /* Does the name contain an '='? */
  3571. printf( /* putenv() does not allow this. */
  3572. /* This also catches the 'putenv name=value' case */
  3573. "?PUTENV - Equal sign in variable name - 'help putenv' for info.\n");
  3574. return(-9);
  3575. }
  3576. nputenvs++; /* Point to next free string */
  3577. debug(F111,"doputenv s1",s1,nputenvs);
  3578. debug(F111,"doputenv s2",s2,nputenvs);
  3579. if (nputenvs > NPUTENVS - 1) { /* Notice the end */
  3580. printf("?PUTENV - static buffer space exhausted\n");
  3581. return(-9);
  3582. }
  3583. /* Quotes are not needed but we allow them for familiarity */
  3584. /* but then we strip them, so syntax is same as for Unix shell */
  3585. if (s2) {
  3586. s2 = brstrip(s2);
  3587. } else {
  3588. s2 = (char *)"";
  3589. }
  3590. ckmakmsg(t,TMPBUFSIZ,s1,"=",s2,NULL);
  3591. debug(F111,"doputenv",t,nputenvs);
  3592. (VOID) makestr(&(putenvs[nputenvs]),t); /* Make a safe permananent copy */
  3593. if (!putenvs[nputenvs]) {
  3594. printf("?PUTENV - memory allocation failure\n");
  3595. return(-9);
  3596. }
  3597. if (putenv(putenvs[nputenvs])) {
  3598. printf("?PUTENV - %s\n",ck_errstr());
  3599. return(-9);
  3600. } else return(success = 1);
  3601. }
  3602. #endif /* NOPUTENV */
  3603. #endif /* UNIX */
  3604. int
  3605. settrmtyp() {
  3606. #ifdef OS2
  3607. #ifdef TNCODE
  3608. extern int ttnum; /* Last Telnet Terminal Type sent */
  3609. extern int ttnumend; /* Has end of list been found */
  3610. #endif /* TNCODE */
  3611. if ((x = cmkey(ttyptab,nttyp,"","vt220",xxstring)) < 0)
  3612. return(x);
  3613. if ((y = cmcfm()) < 0)
  3614. return(y);
  3615. settermtype(x,1);
  3616. #ifdef TNCODE
  3617. /* So we send the correct terminal name to the host if it asks for it */
  3618. ttnum = -1; /* Last Telnet Terminal Type sent */
  3619. ttnumend = 0; /* end of list not found */
  3620. #endif /* TNCODE */
  3621. return(success = 1);
  3622. #else /* Not OS2 */
  3623. #ifdef UNIX
  3624. extern int fxd_inited;
  3625. x = cmtxt("Terminal type name, case sensitive","",&s,NULL);
  3626. #ifdef NOPUTENV
  3627. success = 1;
  3628. #else
  3629. success = doputenv("TERM",s); /* Set the TERM variable */
  3630. #ifdef CK_CURSES
  3631. fxd_inited = 0; /* Force reinitialization of curses database */
  3632. (void)doxdis(0); /* Re-initialize file transfer display */
  3633. concb((char)escape); /* Fix command terminal */
  3634. #endif /* CK_CURSES */
  3635. #endif /* NOPUTENV */
  3636. return(success);
  3637. #else
  3638. printf(
  3639. "\n Sorry, this version of C-Kermit does not support the SET TERMINAL TYPE\n");
  3640. printf(
  3641. " command. Type \"help set terminal\" for further information.\n");
  3642. return(success = 0);
  3643. #endif /* UNIX */
  3644. #endif /* OS2 */
  3645. }
  3646. #ifndef NOLOCAL
  3647. #ifdef OS2
  3648. /* MS-DOS KERMIT compatibility modes */
  3649. int
  3650. setmsk() {
  3651. if ((y = cmkey(msktab,nmsk,"MS-DOS Kermit compatibility mode",
  3652. "keycodes",xxstring)) < 0) return(y);
  3653. switch ( y ) {
  3654. #ifdef COMMENT
  3655. case MSK_COLOR:
  3656. return(seton(&mskcolors));
  3657. #endif /* COMMENT */
  3658. case MSK_KEYS:
  3659. return(seton(&mskkeys));
  3660. case MSK_REN:
  3661. return(seton(&mskrename));
  3662. default: /* Shouldn't get here. */
  3663. return(-2);
  3664. }
  3665. }
  3666. #endif /* OS2 */
  3667. #ifdef CKTIDLE
  3668. static char iactbuf[132];
  3669. char *
  3670. getiact() {
  3671. switch (tt_idleact) {
  3672. case IDLE_RET: return("return");
  3673. case IDLE_EXIT: return("exit");
  3674. case IDLE_HANG: return("hangup");
  3675. #ifdef TNCODE
  3676. case IDLE_TNOP: return("Telnet NOP");
  3677. case IDLE_TAYT: return("Telnet AYT");
  3678. #endif /* TNCODE */
  3679. case IDLE_OUT: {
  3680. int c, k, n;
  3681. char * p, * q, * t;
  3682. k = ckstrncpy(iactbuf,"output ",132);
  3683. n = k;
  3684. q = &iactbuf[k];
  3685. p = tt_idlestr;
  3686. if (!p) p = "";
  3687. if (!*p) return("output NUL");
  3688. while ((c = *p++) && n < 131) {
  3689. c &= 0xff;
  3690. if (c == '\\') {
  3691. if (n > 130) break;
  3692. *q++ = '\\';
  3693. *q++ = '\\';
  3694. *q = NUL;
  3695. n += 2;
  3696. } else if ((c > 32 && c < 127) || c > 159) {
  3697. *q++ = c;
  3698. *q = NUL;
  3699. n++;
  3700. } else {
  3701. if (n > (131 - 6))
  3702. break;
  3703. sprintf(q,"\\{%d}",c);
  3704. k = strlen(q);
  3705. q += k;
  3706. n += k;
  3707. *q = NUL;
  3708. }
  3709. }
  3710. *q = NUL;
  3711. #ifdef OS2
  3712. k = tt_cols[VTERM];
  3713. #else
  3714. k = tt_cols;
  3715. #endif /* OS2 */
  3716. if (n > k - 52) {
  3717. n = k - 52;
  3718. iactbuf[n-2] = '.';
  3719. iactbuf[n-1] = '.';
  3720. iactbuf[n] = NUL;
  3721. }
  3722. return(iactbuf);
  3723. }
  3724. default: return("unknown");
  3725. }
  3726. }
  3727. #endif /* CKTIDLE */
  3728. #ifndef NOCSETS
  3729. VOID
  3730. setlclcharset(x) int x; {
  3731. int i;
  3732. tcsl = y; /* Local character set */
  3733. #ifdef OS2
  3734. for (i = 0; i < 4; i++) {
  3735. G[i].init = TRUE;
  3736. x = G[i].designation;
  3737. G[i].c1 = (x != tcsl) && cs_is_std(x);
  3738. x = G[i].def_designation;
  3739. G[i].def_c1 = (x != tcsl) && cs_is_std(x);
  3740. }
  3741. #endif /* OS2 */
  3742. }
  3743. VOID
  3744. setremcharset(x, z) int x, z; {
  3745. int i;
  3746. #ifdef KUI
  3747. KuiSetProperty( KUI_TERM_REMCHARSET, (long) x, (long) z ) ;
  3748. #endif /* KUI */
  3749. #ifdef UNICODE
  3750. if (x == TX_TRANSP)
  3751. #else /* UNICODE */
  3752. if (x == FC_TRANSP)
  3753. #endif /* UNICODE */
  3754. { /* TRANSPARENT? */
  3755. #ifndef OS2
  3756. tcsr = tcsl; /* Make both sets the same */
  3757. #else /* OS2 */
  3758. #ifdef CKOUNI
  3759. tt_utf8 = 0; /* Turn off UTF8 flag */
  3760. tcsr = tcsl = dec_kbd = TX_TRANSP; /* No translation */
  3761. tcs_transp = 1;
  3762. if (!cs_is_nrc(tcsl)) {
  3763. G[0].def_designation = G[0].designation = TX_ASCII;
  3764. G[0].init = TRUE;
  3765. G[0].def_c1 = G[0].c1 = FALSE;
  3766. G[0].size = cs94;
  3767. G[0].national = FALSE;
  3768. }
  3769. for (i = cs_is_nrc(tcsl) ? 0 : 1; i < 4; i++) {
  3770. G[i].def_designation = G[i].designation = tcsl;
  3771. G[i].init = TRUE;
  3772. G[i].def_c1 = G[i].c1 = FALSE;
  3773. switch (cs_size(G[i].designation)) { /* 94, 96, or 128 */
  3774. case 128:
  3775. case 96:
  3776. G[i].size = G[i].def_size = cs96;
  3777. break;
  3778. case 94:
  3779. G[i].size = G[i].def_size = cs94;
  3780. break;
  3781. default:
  3782. G[i].size = G[i].def_size = csmb;
  3783. break;
  3784. }
  3785. G[i].national = cs_is_nrc(x);
  3786. }
  3787. #else /* CKOUNI */
  3788. tcsr = tcsl; /* Make both sets the same */
  3789. for (i = 0; i < 4; i++) {
  3790. G[i].def_designation = G[i].designation = FC_TRANSP;
  3791. G[i].init = FALSE;
  3792. G[i].size = G[i].def_size = cs96;
  3793. G[i].c1 = G[i].def_c1 = FALSE;
  3794. G[i].rtoi = NULL;
  3795. G[i].itol = NULL;
  3796. G[i].ltoi = NULL;
  3797. G[i].itor = NULL;
  3798. G[i].national = FALSE;
  3799. }
  3800. #endif /* CKOUNI */
  3801. #endif /* OS2 */
  3802. return;
  3803. }
  3804. #ifdef OS2
  3805. #ifdef CKOUNI
  3806. else if (x == TX_UTF8) {
  3807. tcs_transp = 0;
  3808. tt_utf8 = 1; /* Turn it on if we are UTF8 */
  3809. return;
  3810. }
  3811. #endif /* CKOUNI */
  3812. else {
  3813. tcs_transp = 0;
  3814. tcsr = x; /* Remote character set */
  3815. #ifdef CKOUNI
  3816. tt_utf8 = 0; /* Turn off UTF8 flag */
  3817. #endif /* CKOUNI */
  3818. if (z == TT_GR_ALL) {
  3819. int i;
  3820. #ifdef UNICODE
  3821. dec_kbd = x;
  3822. #endif /* UNICODE */
  3823. for (i = 0; i < 4; i++) {
  3824. G[i].init = TRUE;
  3825. if ( i == 0 && !cs_is_nrc(x) ) {
  3826. G[0].designation = G[0].def_designation = FC_USASCII;
  3827. G[0].size = G[0].def_size = cs94;
  3828. G[0].national = 1;
  3829. } else {
  3830. G[i].def_designation = G[i].designation = x;
  3831. switch (cs_size(x)) { /* 94, 96, or 128 */
  3832. case 128:
  3833. case 96:
  3834. G[i].size = G[i].def_size = cs96;
  3835. break;
  3836. case 94:
  3837. G[i].size = G[i].def_size = cs94;
  3838. break;
  3839. default:
  3840. G[i].size = G[i].def_size = csmb;
  3841. break;
  3842. }
  3843. G[i].national = cs_is_nrc(x);
  3844. }
  3845. G[i].c1 = G[i].def_c1 = x != tcsl && cs_is_std(x);
  3846. }
  3847. #ifdef UNICODE
  3848. } else if (z == TT_GR_KBD) { /* Keyboard only */
  3849. dec_kbd = x;
  3850. #endif /* UNICODE */
  3851. } else { /* Specific Gn */
  3852. G[z].def_designation = G[z].designation = x;
  3853. G[z].init = TRUE;
  3854. switch (cs_size(x)) { /* 94, 96, or 128 */
  3855. case 128:
  3856. case 96:
  3857. G[z].size = G[z].def_size = cs96;
  3858. break;
  3859. case 94:
  3860. G[z].size = G[z].def_size = cs94;
  3861. break;
  3862. default:
  3863. G[z].size = G[z].def_size = csmb;
  3864. break;
  3865. }
  3866. G[z].c1 = G[z].def_c1 = x != tcsl && cs_is_std(x);
  3867. G[z].national = cs_is_nrc(x);
  3868. }
  3869. }
  3870. #else /* not OS2 */
  3871. tcsr = x; /* Remote character set */
  3872. #endif /* OS2 */
  3873. }
  3874. #endif /* NOCSETS */
  3875. VOID
  3876. setcmask(x) int x; {
  3877. if (x == 7) {
  3878. cmask = 0177;
  3879. } else if (x == 8) {
  3880. cmask = 0377;
  3881. parity = 0;
  3882. }
  3883. #ifdef KUI
  3884. KuiSetProperty(KUI_TERM_CMASK,x,0);
  3885. #endif /* KUI */
  3886. }
  3887. #ifdef CK_AUTODL
  3888. VOID
  3889. setautodl(x,y) int x,y; {
  3890. autodl = x;
  3891. adl_ask = y;
  3892. #ifdef KUI
  3893. KuiSetProperty(KUI_TERM_AUTODOWNLOAD,x?(y?2:1):0,0);
  3894. #endif /* KUI */
  3895. }
  3896. #endif /* CK_AUTODL */
  3897. #ifdef OS2
  3898. VOID
  3899. seturlhl(int x) {
  3900. tt_url_hilite = x;
  3901. #ifdef KUI
  3902. KuiSetProperty(KUI_TERM_URL_HIGHLIGHT,x,0);
  3903. #endif /* KUI */
  3904. }
  3905. VOID
  3906. setaprint(int x) {
  3907. extern int aprint;
  3908. aprint = x;
  3909. #ifdef KUI
  3910. KuiSetProperty(KUI_TERM_PRINTERCOPY,x,0);
  3911. #endif /* KUI */
  3912. }
  3913. #endif /* OS2 */
  3914. int
  3915. settrm() {
  3916. int i = 0;
  3917. #ifdef OS2
  3918. extern int colorreset, user_erasemode;
  3919. #endif /* OS2 */
  3920. if ((y = cmkey(trmtab,ntrm,"", "",xxstring)) < 0) return(y);
  3921. #ifdef MAC
  3922. printf("\n?Sorry, not implemented yet. Please use the Settings menu.\n");
  3923. return(-9);
  3924. #else
  3925. #ifdef IKSD
  3926. if (inserver) {
  3927. if ((y = cmcfm()) < 0) return(y);
  3928. printf("?Sorry, command disabled.\r\n");
  3929. return(success = 0);
  3930. }
  3931. #endif /* IKSD */
  3932. switch (y) {
  3933. case XYTBYT: /* SET TERMINAL BYTESIZE */
  3934. if ((y = cmnum("bytesize for terminal connection","8",10,&x,
  3935. xxstring)) < 0)
  3936. return(y);
  3937. if (x != 7 && x != 8) {
  3938. printf("\n?The choices are 7 and 8\n");
  3939. return(success = 0);
  3940. }
  3941. if ((y = cmcfm()) < 0) return(y);
  3942. setcmask(x);
  3943. #ifdef OS2
  3944. if (IS97801(tt_type_mode))
  3945. SNI_bitmode(x);
  3946. #endif /* OS2 */
  3947. return(success = 1);
  3948. case XYTSO: /* SET TERMINAL LOCKING-SHIFT */
  3949. return(seton(&sosi));
  3950. case XYTNL: /* SET TERMINAL NEWLINE-MODE */
  3951. return(seton(&tnlm));
  3952. #ifdef OS2
  3953. case XYTCOL:
  3954. if ((x = cmkey(ttycoltab,ncolors,"","terminal",xxstring)) < 0)
  3955. return(x);
  3956. else if (x == TTCOLRES) {
  3957. if ((y = cmkey(ttcolmodetab,ncolmode,
  3958. "","default-color",xxstring)) < 0)
  3959. return(y);
  3960. if ((z = cmcfm()) < 0)
  3961. return(z);
  3962. colorreset = y;
  3963. return(success = 1);
  3964. } else if (x == TTCOLERA) {
  3965. if ((y = cmkey(ttcolmodetab,ncolmode,"",
  3966. "current-color",xxstring)) < 0)
  3967. return(y);
  3968. if ((z = cmcfm()) < 0)
  3969. return(z);
  3970. user_erasemode = y;
  3971. return(success=1);
  3972. } else { /* No parse error */
  3973. int fg = 0, bg = 0;
  3974. fg = cmkey(ttyclrtab, nclrs,
  3975. (x == TTCOLBOR ?
  3976. "color for screen border" :
  3977. "foreground color and then background color"),
  3978. "lgray", xxstring);
  3979. if (fg < 0)
  3980. return(fg);
  3981. if (x != TTCOLBOR) {
  3982. if ((bg = cmkey(ttyclrtab,nclrs,
  3983. "background color","blue",xxstring)) < 0)
  3984. return(bg);
  3985. }
  3986. if ((y = cmcfm()) < 0)
  3987. return(y);
  3988. switch (x) {
  3989. case TTCOLNOR:
  3990. colornormal = fg | bg << 4;
  3991. fgi = fg & 0x08;
  3992. bgi = bg & 0x08;
  3993. break;
  3994. case TTCOLREV:
  3995. colorreverse = fg | bg << 4;
  3996. break;
  3997. case TTCOLITA:
  3998. coloritalic = fg | bg << 4;
  3999. break;
  4000. case TTCOLUND:
  4001. colorunderline = fg | bg << 4;
  4002. break;
  4003. case TTCOLGRP:
  4004. colorgraphic = fg | bg << 4;
  4005. break;
  4006. case TTCOLDEB:
  4007. colordebug = fg | bg << 4;
  4008. break;
  4009. case TTCOLSTA:
  4010. colorstatus = fg | bg << 4;
  4011. break;
  4012. case TTCOLHLP:
  4013. colorhelp = fg | bg << 4;
  4014. break;
  4015. case TTCOLBOR:
  4016. colorborder = fg;
  4017. break;
  4018. case TTCOLSEL:
  4019. colorselect = fg | bg << 4;
  4020. break;
  4021. default:
  4022. printf("%s - invalid\n",cmdbuf);
  4023. return(-9);
  4024. break;
  4025. }
  4026. scrninitialized[VTERM] = 0;
  4027. VscrnInit(VTERM);
  4028. }
  4029. return(success = 1);
  4030. case XYTCUR: { /* SET TERMINAL CURSOR */
  4031. extern int cursorena[];
  4032. extern int cursoron[] ; /* Cursor state on/off */
  4033. if ((x = cmkey(ttycurtab,ncursors,"","underline",xxstring)) < 0)
  4034. return(x);
  4035. if ((z = cmkey(curontab,ncuron,"","on",xxstring)) < 0)
  4036. return(z);
  4037. if ((y = cmcfm()) < 0) return(y);
  4038. tt_cursor = tt_cursor_usr = x;
  4039. if ( z == 2 ) {
  4040. cursorena[VTERM] = tt_cursorena_usr = 1;
  4041. tt_cursor_blink = 0;
  4042. } else {
  4043. cursorena[VTERM] = tt_cursorena_usr = z;/* turn cursor on/off */
  4044. tt_cursor_blink = 1;
  4045. }
  4046. cursoron[VTERM] = FALSE; /* Force newcursor to restore the cursor */
  4047. return(success = 1);
  4048. }
  4049. #endif /* OS2 */
  4050. case XYTTYP: /* SET TERMINAL TYPE */
  4051. return(settrmtyp());
  4052. #ifdef OS2
  4053. case XYTARR: /* SET TERMINAL ARROW-KEYS */
  4054. if ((x = cmkey(akmtab,2,"","",xxstring)) < 0) return(x);
  4055. if ((y = cmcfm()) < 0) return(y);
  4056. tt_arrow = x; /* TTK_NORM / TTK_APPL; see ckuusr.h */
  4057. return(success = 1);
  4058. case XYTKPD: /* SET TERMINAL KEYPAD-MODE */
  4059. if ((x = cmkey(kpmtab,2,"","",xxstring)) < 0) return(x);
  4060. if ((y = cmcfm()) < 0) return(y);
  4061. tt_keypad = x; /* TTK_NORM / TTK_APPL; see ckuusr.h */
  4062. return(success = 1);
  4063. case XYTUNX: { /* SET TERM UNIX-MODE (DG) */
  4064. extern int dgunix,dgunix_usr;
  4065. x = seton(&dgunix);
  4066. dgunix_usr = dgunix;
  4067. return(x);
  4068. }
  4069. case XYTKBMOD: { /* SET TERM KEYBOARD MODE */
  4070. extern int tt_kb_mode;
  4071. if ((x = cmkey(kbmodtab,
  4072. nkbmodtab,
  4073. "normal",
  4074. "special keyboard mode for terminal emulation",
  4075. xxstring)
  4076. ) < 0)
  4077. return(x);
  4078. if ((y = cmcfm()) < 0) return(y);
  4079. tt_kb_mode = x;
  4080. return(success = 1);
  4081. }
  4082. case XYTWRP: /* SET TERMINAL WRAP */
  4083. return(seton(&tt_wrap));
  4084. case XYSCRS:
  4085. if ((y = cmnum("CONNECT scrollback buffer size, lines","2000",10,&x,
  4086. xxstring)) < 0)
  4087. return(y);
  4088. /* The max number of lines is the RAM */
  4089. /* we can actually dedicate to a */
  4090. /* scrollback buffer given the maximum */
  4091. /* process memory space of 512MB */
  4092. if (x < 256 || x > 2000000L) {
  4093. printf("\n?The size must be between 256 and 2,000,000.\n");
  4094. return(success = 0);
  4095. }
  4096. if ((y = cmcfm()) < 0) return(y);
  4097. tt_scrsize[VTERM] = x;
  4098. VscrnInit(VTERM);
  4099. return(success = 1);
  4100. #endif /* OS2 */
  4101. #ifndef NOCSETS
  4102. case XYTCS: { /* SET TERMINAL CHARACTER-SET */
  4103. int eol;
  4104. /* set terminal character-set <remote> <local> */
  4105. if ((x = cmkey(
  4106. #ifdef CKOUNI
  4107. txrtab,ntxrtab,
  4108. #else /* CKOUNI */
  4109. ttcstab,ntermc,
  4110. #endif /* CKOUNI */
  4111. "remote terminal character-set","",xxstring)) < 0)
  4112. return(x);
  4113. #ifdef UNICODE
  4114. if (x == TX_TRANSP
  4115. #ifdef CKOUNI
  4116. || x == TX_UTF8
  4117. #endif /* CKOUNI */
  4118. ) {
  4119. if ((y = cmcfm()) < 0) /* Confirm the command */
  4120. return(y);
  4121. #ifdef OS2
  4122. if ( isunicode() && x == TX_TRANSP ) {
  4123. /* If we are in unicode display mode then transparent
  4124. * only affects the output direction. We need to know
  4125. * the actual remote character set in order to perform
  4126. * the tcsr -> ucs2 translation for display.
  4127. */
  4128. x = y = tcsl;
  4129. } else
  4130. #endif /* OS2 */
  4131. y = x;
  4132. }
  4133. #else /* UNICODE */
  4134. if (x == FC_TRANSP) {
  4135. if ((y = cmcfm()) < 0) /* Confirm the command */
  4136. return(y);
  4137. y = x;
  4138. }
  4139. #endif /* UNICODE */
  4140. /* Not transparent or UTF8, so get local set to translate it into */
  4141. s = "";
  4142. #ifdef OS2
  4143. y = os2getcp(); /* Default is current code page */
  4144. switch (y) {
  4145. case 437: s = "cp437"; break;
  4146. case 850: s = "cp850"; break;
  4147. case 852: s = "cp852"; break;
  4148. case 857: s = "cp857"; break;
  4149. case 858: s = "cp858"; break;
  4150. case 862: s = "cp862"; break;
  4151. case 866: s = "cp866"; break;
  4152. case 869: s = "cp869"; break;
  4153. case 1250: s = "cp1250"; break;
  4154. case 1251: s = "cp1251"; break;
  4155. case 1252: s = "cp1252"; break;
  4156. case 1253: s = "cp1253"; break;
  4157. case 1254: s = "cp1254"; break;
  4158. case 1255: s = "cp1255"; break;
  4159. case 1256: s = "cp1256"; break;
  4160. case 1257: s = "cp1257"; break;
  4161. case 1258: s = "cp1258"; break;
  4162. }
  4163. #ifdef PCFONTS
  4164. /*
  4165. If the user has loaded a font with SET TERMINAL FONT then we want
  4166. to change the default code page to the font that was loaded.
  4167. */
  4168. if (tt_font != TTF_ROM) {
  4169. for (y = 0; y < ntermfont; y++ ) {
  4170. if (term_font[y].kwval == tt_font) {
  4171. s = term_font[y].kwd;
  4172. break;
  4173. }
  4174. }
  4175. }
  4176. #endif /* PCFONTS */
  4177. #else /* Not K95... */
  4178. s = fcsinfo[fcharset].keyword;
  4179. #endif /* OS2 */
  4180. if ((y = cmkey(
  4181. #ifdef CKOUNI
  4182. txrtab,ntxrtab,
  4183. #else /* CKOUNI */
  4184. ttcstab,ntermc,
  4185. #endif /* CKOUNI */
  4186. "local character-set",s,xxstring)) < 0)
  4187. return(y);
  4188. #ifdef UNICODE
  4189. if (y == TX_UTF8) {
  4190. printf("?UTF8 may not be used as a local character set.\r\n");
  4191. return(-9);
  4192. }
  4193. #endif /* UNICODE */
  4194. #ifdef OS2
  4195. if ((z = cmkey(graphsettab,ngraphset,
  4196. "DEC VT intermediate graphic set","all",xxstring)) < 0)
  4197. return(z);
  4198. #endif /* OS2 */
  4199. if ((eol = cmcfm()) < 0)
  4200. return(eol); /* Confirm the command */
  4201. /* End of command parsing - actions begin */
  4202. setlclcharset(y);
  4203. setremcharset(x,z);
  4204. return(success = 1);
  4205. }
  4206. #endif /* NOCSETS */
  4207. #ifndef NOCSETS
  4208. case XYTLCS: /* SET TERMINAL LOCAL-CHARACTER-SET */
  4209. /* set terminal character-set <local> */
  4210. s = getdcset(); /* Get display character-set name */
  4211. if ((y = cmkey(
  4212. #ifdef CKOUNI
  4213. txrtab,ntxrtab,
  4214. #else /* CKOUNI */
  4215. fcstab,nfilc,
  4216. #endif /* CKOUNI */
  4217. "local character-set",s,xxstring)) < 0)
  4218. return(y);
  4219. #ifdef UNICODE
  4220. if (y == TX_UTF8) {
  4221. printf("?UTF8 may not be used as a local character set.\r\n");
  4222. return(-9);
  4223. }
  4224. #endif /* UNICODE */
  4225. if ((z = cmcfm()) < 0) return(z); /* Confirm the command */
  4226. /* End of command parsing - action begins */
  4227. setlclcharset(y);
  4228. return(success = 1);
  4229. #endif /* NOCSETS */
  4230. #ifndef NOCSETS
  4231. #ifdef UNICODE
  4232. case XYTUNI: /* SET TERMINAL UNICODE */
  4233. return(seton(&tt_unicode));
  4234. #endif /* UNICODE */
  4235. case XYTRCS: /* SET TERMINAL REMOTE-CHARACTER-SET */
  4236. /* set terminal character-set <remote> <Graphic-set> */
  4237. if ((x = cmkey(
  4238. #ifdef CKOUNI
  4239. txrtab, ntxrtab,
  4240. #else /* CKOUNI */
  4241. ttcstab,ntermc,
  4242. #endif /* CKOUNI */
  4243. "remote terminal character-set","",xxstring)) < 0)
  4244. return(x);
  4245. #ifdef UNICODE
  4246. if (x == TX_TRANSP
  4247. #ifdef CKOUNI
  4248. || x == TX_UTF8
  4249. #endif /* CKOUNI */
  4250. ) {
  4251. if ((y = cmcfm()) < 0) /* Confirm the command */
  4252. return(y);
  4253. #ifdef OS2
  4254. if ( isunicode() && x == TX_TRANSP ) {
  4255. /* If we are in unicode display mode then transparent
  4256. * only affects the output direction. We need to know
  4257. * the actual remote character set in order to perform
  4258. * the tcsr -> ucs2 translation for display.
  4259. */
  4260. x = tcsl;
  4261. }
  4262. #endif /* OS2 */
  4263. }
  4264. #else /* UNICODE */
  4265. if (x == FC_TRANSP) {
  4266. if ((y = cmcfm()) < 0) /* Confirm the command */
  4267. return(y);
  4268. }
  4269. #endif /* UNICODE */
  4270. else {
  4271. #ifdef OS2
  4272. if ((z = cmkey(graphsettab,ngraphset,
  4273. "DEC VT intermediate graphic set","all",xxstring)) < 0)
  4274. return(z);
  4275. #endif /* OS2 */
  4276. if ((y = cmcfm()) < 0) /* Confirm the command */
  4277. return(y);
  4278. }
  4279. /* Command parsing ends here */
  4280. setremcharset(x,z);
  4281. return(success = 1);
  4282. #endif /* NOCSETS */
  4283. case XYTEC: /* SET TERMINAL ECHO */
  4284. if ((x = cmkey(rltab,nrlt,"which side echos during CONNECT",
  4285. "remote", xxstring)) < 0) return(x);
  4286. if ((y = cmcfm()) < 0) return(y);
  4287. #ifdef NETCONN
  4288. oldplex = x;
  4289. #endif /* NETCONN */
  4290. duplex = x;
  4291. return(success = 1);
  4292. case XYTESC: /* SET TERM ESC */
  4293. if ((x = cmkey(nabltab,nnabltab,"","enabled",xxstring)) < 0)
  4294. return(x);
  4295. if ((y = cmcfm()) < 0) return(y);
  4296. tt_escape = x;
  4297. return(1);
  4298. case XYTCRD: /* SET TERMINAL CR-DISPLAY */
  4299. if ((x = cmkey(crdtab,2,"", "normal", xxstring)) < 0) return(x);
  4300. if ((y = cmcfm()) < 0) return(y);
  4301. tt_crd = x;
  4302. return(success = 1);
  4303. case XYTLFD: /* SET TERMINAL LF-DISPLAY */
  4304. if ((x = cmkey(crdtab,2,"", "normal", xxstring)) < 0) return(x);
  4305. if ((y = cmcfm()) < 0) return(y);
  4306. tt_lfd = x;
  4307. return(success = 1);
  4308. #ifdef OS2
  4309. case XYTANS: { /* SET TERMINAL ANSWERBACK */
  4310. /*
  4311. NOTE: We let them enable and disable the answerback sequence, but we
  4312. do NOT let them change it, and we definitely do not let the host set it.
  4313. This is a security feature.
  4314. As of 1.1.8 we allow the SET TERM ANSWERBACK MESSAGE <string> to be
  4315. used just as MS-DOS Kermit does. C0 and C1 controls as well as DEL
  4316. are not allowed to be used as characters. They are translated to
  4317. underscore. This may not be set by APC.
  4318. */
  4319. if ((x = cmkey(anbktab,nansbk,"", "off", xxstring)) < 0)
  4320. return(x);
  4321. if (x < 2) {
  4322. if ((y = cmcfm()) < 0)
  4323. return(y);
  4324. tt_answer = x;
  4325. return(success = 1);
  4326. } else if ( x == 2 || x == 3) {
  4327. int len = 0;
  4328. extern int safeanswerbk;
  4329. extern char useranswerbk[];
  4330. if ((y = cmtxt("Answerback extension","",&s,xxstring)) < 0)
  4331. return(y);
  4332. if (apcactive == APC_LOCAL ||
  4333. (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
  4334. return(success = 0);
  4335. len = strlen(s);
  4336. if (x == 2) {
  4337. /* Safe Answerback's don't have C0/C1 chars */
  4338. for (z = 0; z < len; z++) {
  4339. if ((s[z] & 0x7F) <= SP || (s[z] & 0x7F) == DEL)
  4340. useranswerbk[z] = '_';
  4341. else
  4342. useranswerbk[z] = s[z];
  4343. }
  4344. useranswerbk[z] = '\0';
  4345. safeanswerbk = 1 ; /* TRUE */
  4346. } else {
  4347. ckstrncpy(useranswerbk,s,60); /* (see ckocon.c) */
  4348. safeanswerbk = 0; /* FALSE */
  4349. }
  4350. updanswerbk();
  4351. return(success = 1);
  4352. } else
  4353. return(success = 0);
  4354. }
  4355. #endif /* OS2 */
  4356. #ifdef CK_APC
  4357. case XYTAPC:
  4358. if ((y = cmkey(apctab,napctab,
  4359. "application program command execution","",
  4360. xxstring)) < 0)
  4361. return(y);
  4362. if ((x = cmcfm()) < 0)
  4363. return(x);
  4364. if (apcactive == APC_LOCAL ||
  4365. (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
  4366. return(success = 0);
  4367. apcstatus = y;
  4368. return(success = 1);
  4369. #ifdef CK_AUTODL
  4370. case XYTAUTODL: /* AUTODOWNLOAD */
  4371. if ((y = cmkey(adltab,nadltab,"Auto-download options","",
  4372. xxstring)) < 0)
  4373. return(y);
  4374. switch (y) {
  4375. case TAD_ON:
  4376. case TAD_OFF:
  4377. if ((x = cmcfm()) < 0)
  4378. return(x);
  4379. setautodl(y,0);
  4380. break;
  4381. case TAD_ASK:
  4382. if ((x = cmcfm()) < 0)
  4383. return(x);
  4384. setautodl(TAD_ON,1);
  4385. break;
  4386. case TAD_ERR:
  4387. if ((y = cmkey(adlerrtab,nadlerrtab,"","", xxstring)) < 0)
  4388. return(y);
  4389. if ((x = cmcfm()) < 0)
  4390. return(x);
  4391. adl_err = y;
  4392. break;
  4393. #ifdef OS2
  4394. case TAD_K:
  4395. if ((y = cmkey(adlxtab,nadlxtab,"","", xxstring)) < 0)
  4396. return(y);
  4397. switch (y) {
  4398. case TAD_X_C0:
  4399. if ((y = cmkey(adlc0tab,nadlc0tab,"",
  4400. "processed-by-emulator",xxstring)) < 0)
  4401. return(y);
  4402. if ((x = cmcfm()) < 0)
  4403. return(x);
  4404. adl_kc0 = y;
  4405. break;
  4406. case TAD_X_DETECT:
  4407. if ((y = cmkey(adldtab,nadldtab,"","packet",xxstring)) < 0)
  4408. return(y);
  4409. if ((x = cmcfm()) < 0)
  4410. return(x);
  4411. adl_kmode = y;
  4412. break;
  4413. case TAD_X_STR:
  4414. if ((y = cmtxt("Kermit start string","KERMIT READY TO SEND...",
  4415. &s,xxstring)) < 0)
  4416. return(y);
  4417. free(adl_kstr);
  4418. adl_kstr = strdup(s);
  4419. break;
  4420. }
  4421. break;
  4422. case TAD_Z:
  4423. if ((y = cmkey(adlxtab,nadlxtab,"","",xxstring)) < 0)
  4424. return(y);
  4425. switch (y) {
  4426. case TAD_X_C0:
  4427. if ((y = cmkey(adlc0tab,nadlc0tab,"",
  4428. "processed-by-emulator",xxstring)) < 0)
  4429. return(y);
  4430. if ((x = cmcfm()) < 0)
  4431. return(x);
  4432. adl_zc0 = y;
  4433. break;
  4434. case TAD_X_DETECT:
  4435. if ((y = cmkey(adldtab,nadldtab,"","packet",xxstring)) < 0)
  4436. return(y);
  4437. if ((x = cmcfm()) < 0)
  4438. return(x);
  4439. adl_zmode = y;
  4440. break;
  4441. case TAD_X_STR:
  4442. if ((y = cmtxt("","rz\\{13}",&s,xxstring)) < 0)
  4443. return(y);
  4444. free(adl_zstr);
  4445. adl_zstr = strdup(s);
  4446. break;
  4447. }
  4448. break;
  4449. #endif /* OS2 */
  4450. }
  4451. return(success = 1);
  4452. #endif /* CK_AUTODL */
  4453. #endif /* CK_APC */
  4454. #ifdef OS2
  4455. case XYTBEL:
  4456. return(success = setbell());
  4457. case XYTMBEL: /* MARGIN-BELL */
  4458. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  4459. if (y) { /* ON */
  4460. if ((z = cmnum("Column at which to set margin bell",
  4461. "72",10,&x,xxstring)) < 0)
  4462. return(z);
  4463. }
  4464. if ((z = cmcfm()) < 0) return(z);
  4465. marginbell = y;
  4466. marginbellcol = x;
  4467. return(success = 1);
  4468. #endif /* OS2 */
  4469. #ifdef CKTIDLE
  4470. case XYTIDLE: /* IDLE-SEND */
  4471. case XYTITMO: /* IDLE-TIMEOUT */
  4472. if ((z = cmnum("seconds of idle time to wait, or 0 to disable",
  4473. "0",10,&x,xxstring)) < 0)
  4474. return(z);
  4475. if (y == XYTIDLE) {
  4476. if ((y = cmtxt("string to send, may contain kverbs and variables",
  4477. "\\v(newline)",&s,xxstring)) < 0)
  4478. return(y);
  4479. tt_idlesnd_tmo = x; /* (old) */
  4480. tt_idlelimit = x; /* (new) */
  4481. makestr(&tt_idlestr,brstrip(s)); /* (new) */
  4482. tt_idlesnd_str = tt_idlestr; /* (old) */
  4483. tt_idleact = IDLE_OUT; /* (new) */
  4484. } else {
  4485. if ((y = cmcfm()) < 0)
  4486. return(y);
  4487. tt_idlelimit = x;
  4488. }
  4489. #ifdef OS2
  4490. puterror(VTERM);
  4491. #endif /* OS2 */
  4492. return(success = 1);
  4493. case XYTIACT: { /* SET TERM IDLE-ACTION */
  4494. if ((y = cmkey(idlacts,nidlacts,"","",xxstring)) < 0)
  4495. return(y);
  4496. if (y == IDLE_OUT) {
  4497. if ((x = cmtxt("string to send, may contain kverbs and variables"
  4498. , "",&s,xxstring)) < 0)
  4499. return(x);
  4500. makestr(&tt_idlestr,brstrip(s)); /* (new) */
  4501. tt_idlesnd_str = tt_idlestr; /* (old) */
  4502. } else {
  4503. if ((x = cmcfm()) < 0)
  4504. return(x);
  4505. }
  4506. tt_idleact = y;
  4507. return(success = 1);
  4508. }
  4509. #endif /* CKTIDLE */
  4510. case XYTDEB: /* TERMINAL DEBUG */
  4511. y = seton(&x); /* Go parse ON or OFF */
  4512. if (y > 0) /* Command succeeded? */
  4513. setdebses(x);
  4514. return(y);
  4515. #ifdef OS2
  4516. case XYTASCRL: /* SET TERMINAL AUTOSCROLL */
  4517. y = seton(&autoscroll);
  4518. return(y);
  4519. case XYTAPAGE: /* SET TERMINAL AUTOPAGE */
  4520. y = seton(&wy_autopage);
  4521. return(y);
  4522. case XYTROL: /* SET TERMINAL ROLL */
  4523. if ((y = cmkey(rolltab,nroll,"scrollback mode","insert",xxstring))<0)
  4524. return(y);
  4525. if (y == TTR_KEYS) {
  4526. if ((x = cmkey(rollkeytab,nrollkey,"","send",xxstring))<0)
  4527. return(x);
  4528. if ((z = cmcfm()) < 0) return(z);
  4529. tt_rkeys[VTERM] = x;
  4530. } else {
  4531. if ((x = cmcfm()) < 0) return(x);
  4532. tt_roll[VTERM] = y;
  4533. }
  4534. return(success = 1);
  4535. case XYTCTS: /* SET TERMINAL TRANSMIT-TIMEOUT */
  4536. y = cmnum("Maximum seconds to allow CTS off during CONNECT",
  4537. "5",10,&x,xxstring);
  4538. return(setnum(&tt_ctstmo,x,y,10000));
  4539. case XYTCPG: { /* SET TERMINAL CODE-PAGE */
  4540. int i;
  4541. int cp = -1;
  4542. y = cmnum("PC code page to use during terminal emulation",
  4543. ckitoa(os2getcp()),10,&x,xxstring);
  4544. if ((x = setnum(&cp,x,y,11000)) < 0) return(x);
  4545. if (os2setcp(cp) != 1) {
  4546. #ifdef NT
  4547. if (isWin95())
  4548. printf(
  4549. "Sorry, Windows 95 does not support code page switching\n");
  4550. else
  4551. #endif /* NT */
  4552. printf(
  4553. "Sorry, %d is not a valid code page for this system.\n",cp);
  4554. return(-9);
  4555. }
  4556. /* Force the terminal character-sets conversions to be updated */
  4557. for ( i = 0; i < 4; i++ )
  4558. G[i].init = TRUE;
  4559. return(1);
  4560. }
  4561. case XYTPAC: /* SET TERMINAL OUTPUT-PACING */
  4562. y = cmnum(
  4563. "Pause between sending each character during CONNECT, milliseconds",
  4564. "-1",10,&x,xxstring);
  4565. return(setnum(&tt_pacing,x,y,10000));
  4566. #ifdef OS2MOUSE
  4567. case XYTMOU: { /* SET TERMINAL MOUSE */
  4568. int old_mou = tt_mouse;
  4569. if ((x = seton(&tt_mouse)) < 0)
  4570. return(x);
  4571. if (tt_mouse != old_mou)
  4572. if (tt_mouse)
  4573. os2_mouseon();
  4574. else
  4575. os2_mouseoff();
  4576. return(1);
  4577. }
  4578. #endif /* OS2MOUSE */
  4579. #endif /* OS2 */
  4580. case XYTWID: {
  4581. if ((y = cmnum(
  4582. #ifdef OS2
  4583. "number of columns in display window during CONNECT",
  4584. #else
  4585. "number of columns on your screen",
  4586. #endif /* OS2 */
  4587. "80",10,&x,xxstring)) < 0)
  4588. return(y);
  4589. if ((y = cmcfm()) < 0) return(y);
  4590. #ifdef OS2
  4591. return(success = os2_settermwidth(x));
  4592. #else /* Not OS/2 */
  4593. tt_cols = x;
  4594. return(success = 1);
  4595. #endif /* OS2 */
  4596. }
  4597. case XYTHIG:
  4598. if ((y = cmnum(
  4599. #ifdef OS2
  4600. "number of rows in display window during CONNECT, not including status line",
  4601. tt_status[VTERM]?"24":"25",
  4602. #else
  4603. "24","number of rows on your screen",
  4604. #endif /* OS2 */
  4605. 10,&x,xxstring)) < 0)
  4606. return(y);
  4607. if ((y = cmcfm()) < 0) return(y);
  4608. #ifdef OS2
  4609. return (success = os2_settermheight(x));
  4610. #else /* Not OS/2 */
  4611. tt_rows = x;
  4612. return(success = 1);
  4613. #endif /* OS2 */
  4614. #ifdef OS2
  4615. case XYTPRN: { /* Print Mode */
  4616. extern bool xprint, aprint, cprint, uprint;
  4617. if ((y = cmkey(prnmtab,nprnmtab,"","off", xxstring)) < 0) return(y);
  4618. if ((x = cmcfm()) < 0) return(x);
  4619. switch (y) {
  4620. case 0:
  4621. if (cprint || uprint || aprint || xprint)
  4622. printeroff();
  4623. cprint = xprint = uprint = 0;
  4624. setaprint(0);
  4625. break;
  4626. case 1:
  4627. if (!(cprint || uprint || aprint || xprint))
  4628. printeron();
  4629. setaprint(1);
  4630. cprint = xprint = uprint = 0;
  4631. break;
  4632. case 2:
  4633. if (!(cprint || uprint || aprint || xprint))
  4634. printeron();
  4635. cprint = 1;
  4636. setaprint(0);
  4637. xprint = uprint = 0;
  4638. break;
  4639. case 3:
  4640. if (!(cprint || uprint || aprint || xprint))
  4641. printeron();
  4642. uprint = 1;
  4643. setaprint(0);
  4644. xprint = cprint = 0;
  4645. break;
  4646. }
  4647. return(1);
  4648. }
  4649. #else
  4650. #ifdef XPRINT
  4651. case XYTPRN: {
  4652. extern int tt_print;
  4653. if ((x = seton(&tt_print)) < 0)
  4654. return(x);
  4655. return(success = 1);
  4656. }
  4657. #endif /* XPRINT */
  4658. #endif /* OS2 */
  4659. #ifdef OS2
  4660. case XYTSCNM: {
  4661. extern int decscnm, decscnm_usr;
  4662. if ((y = cmkey(normrev,4,"",
  4663. decscnm_usr?"reverse":"normal",
  4664. xxstring)
  4665. ) < 0)
  4666. return(y);
  4667. if ((x = cmcfm()) < 0) return(x);
  4668. decscnm_usr = y;
  4669. if (decscnm != decscnm_usr)
  4670. flipscreen(VTERM);
  4671. return(1);
  4672. }
  4673. case XYTOPTI:
  4674. if ((y = cmkey(onoff,2,"",tt_diff_upd?"on":"off",
  4675. xxstring)) < 0) return(y);
  4676. if ((x = cmcfm()) < 0) return(x);
  4677. tt_diff_upd = y;
  4678. return(1);
  4679. case XYTUPD: {
  4680. int mode, delay;
  4681. if ((mode = cmkey(scrnupd,nscrnupd,"","fast",xxstring)) < 0) {
  4682. return(mode);
  4683. } else {
  4684. y = cmnum(
  4685. "Pause between FAST screen updates in CONNECT mode, milliseconds",
  4686. "100",10,&x,xxstring
  4687. );
  4688. if (x < 0 || x > 1000 ) {
  4689. printf(
  4690. "\n?The update rate must be between 0 and 1000 milliseconds.\n"
  4691. );
  4692. return(success = 0);
  4693. }
  4694. if ((y = cmcfm()) < 0) return(y);
  4695. updmode = tt_updmode = mode;
  4696. return(setnum(&tt_update,x,y,10000));
  4697. }
  4698. }
  4699. case XYTCTRL:
  4700. if ((x = cmkey(termctrl,ntermctrl,"","7",xxstring)) < 0) {
  4701. return(x);
  4702. } else {
  4703. if ((y = cmcfm()) < 0)
  4704. return(y);
  4705. switch ( x ) {
  4706. case 8:
  4707. send_c1 = send_c1_usr = TRUE;
  4708. break;
  4709. case 7:
  4710. default:
  4711. send_c1 = send_c1_usr = FALSE;
  4712. break;
  4713. }
  4714. }
  4715. return(success = TRUE);
  4716. break;
  4717. #ifdef PCFONTS
  4718. case XYTFON:
  4719. if ( !IsOS2FullScreen() ) {
  4720. printf(
  4721. "\n?SET TERMINAL FONT is only supported in Full Screen sessions.\n");
  4722. return(success = FALSE);
  4723. }
  4724. if ((x = cmkey(term_font,ntermfont,"","default",xxstring)) < 0) {
  4725. return(x);
  4726. } else {
  4727. if ((y = cmcfm()) < 0) return(y);
  4728. if ( !os2LoadPCFonts() ) {
  4729. tt_font = x;
  4730. return(success = TRUE);
  4731. } else {
  4732. printf(
  4733. "\n?PCFONTS.DLL is not available in CKERMIT executable directory.\n");
  4734. return(success = FALSE);
  4735. }
  4736. }
  4737. break;
  4738. #else /* PCFONTS */
  4739. #ifdef NT
  4740. #ifdef KUI
  4741. case XYTFON:
  4742. return(setguifont()); /* ckuus3.c */
  4743. #endif /* KUI */
  4744. #endif /* NT */
  4745. #endif /* PCFONTS */
  4746. case XYTVCH: {
  4747. extern int pheight, marginbot, cmd_rows, cmd_cols;
  4748. if ((x = cmkey(tvctab,ntvctab,"",isWin95()?"win95-safe":"enabled",
  4749. xxstring)) < 0)
  4750. return(x);
  4751. if ((y = cmcfm()) < 0) return(y);
  4752. #ifndef KUI
  4753. if (x != tt_modechg) {
  4754. switch (x) {
  4755. case TVC_DIS:
  4756. /* When disabled the heights of all of the virtual screens */
  4757. /* must be equal to the physical height of the console */
  4758. /* window and may not be changed. */
  4759. /* The width of the window may not be altered. */
  4760. tt_modechg = TVC_ENA; /* Temporary */
  4761. if (marginbot > pheight-(tt_status[VTERM]?1:0))
  4762. marginbot = pheight-(tt_status[VTERM]?1:0);
  4763. tt_szchng[VCMD] = 1 ;
  4764. tt_rows[VCMD] = pheight;
  4765. VscrnInit(VCMD);
  4766. SetCols(VCMD);
  4767. cmd_rows = y;
  4768. tt_szchng[VTERM] = 2 ;
  4769. tt_rows[VTERM] = pheight - (tt_status[VTERM]?1:0);
  4770. VscrnInit(VTERM);
  4771. break;
  4772. case TVC_ENA:
  4773. /* When enabled the physical height of the console windows */
  4774. /* should be adjusted to the height of the virtual screen */
  4775. /* The width may be set to anything. */
  4776. /* nothing to do */
  4777. break;
  4778. case TVC_W95:
  4779. /* Win95-safe mode allows the physical height to change */
  4780. /* but restricts it to a width of 80 and a height equal to */
  4781. /* 25, 43, or 50. Must be adjusted now. */
  4782. /* The virtual heights must be equal to the above. */
  4783. if (pheight != 25 && pheight != 43 && pheight != 50) {
  4784. if (pheight < 25)
  4785. y = 25;
  4786. else if (pheight < 43)
  4787. y = 43;
  4788. else
  4789. y = 50;
  4790. } else
  4791. y = pheight;
  4792. tt_modechg = TVC_ENA; /* Temporary */
  4793. tt_szchng[VCMD] = 1;
  4794. tt_rows[VCMD] = y;
  4795. tt_cols[VCMD] = 80;
  4796. VscrnInit(VCMD);
  4797. SetCols(VCMD);
  4798. cmd_rows = y;
  4799. cmd_cols = 80;
  4800. marginbot = y-(tt_status[VTERM]?1:0);
  4801. tt_szchng[VTERM] = 2;
  4802. tt_rows[VTERM] = y - (tt_status[VTERM]?1:0);
  4803. tt_cols[VTERM] = 80;
  4804. VscrnInit(VTERM);
  4805. break;
  4806. }
  4807. tt_modechg = x;
  4808. }
  4809. return(success = 1);
  4810. #else
  4811. return(success = 0);
  4812. #endif /* KUI */
  4813. }
  4814. case XYTSTAT: {
  4815. extern int marginbot;
  4816. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  4817. if ((x = cmcfm()) < 0) return(x);
  4818. if (y != tt_status[VTERM] || y != tt_status_usr[VTERM]) {
  4819. /* Might need to fixup the margins */
  4820. if ( marginbot == VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0) )
  4821. if (y) {
  4822. marginbot--;
  4823. } else {
  4824. marginbot++;
  4825. }
  4826. tt_status_usr[VTERM] = tt_status[VTERM] = y;
  4827. if (y) {
  4828. tt_szchng[VTERM] = 2;
  4829. tt_rows[VTERM]--;
  4830. VscrnInit(VTERM); /* Height set here */
  4831. #ifdef TNCODE
  4832. if (TELOPT_ME(TELOPT_NAWS))
  4833. tn_snaws();
  4834. #endif /* TNCODE */
  4835. #ifdef RLOGCODE
  4836. if (TELOPT_ME(TELOPT_NAWS))
  4837. rlog_naws();
  4838. #endif /* RLOGCODE */
  4839. #ifdef SSHBUILTIN
  4840. if (TELOPT_ME(TELOPT_NAWS))
  4841. ssh_snaws();
  4842. #endif /* SSHBUILTIN */
  4843. } else {
  4844. tt_szchng[VTERM] = 1;
  4845. tt_rows[VTERM]++;
  4846. VscrnInit(VTERM); /* Height set here */
  4847. #ifdef TNCODE
  4848. if (TELOPT_ME(TELOPT_NAWS))
  4849. tn_snaws();
  4850. #endif /* TNCODE */
  4851. #ifdef RLOGCODE
  4852. if (TELOPT_ME(TELOPT_NAWS))
  4853. rlog_naws();
  4854. #endif /* RLOGCODE */
  4855. #ifdef SSHBUILTIN
  4856. if (TELOPT_ME(TELOPT_NAWS))
  4857. ssh_snaws();
  4858. #endif /* SSHBUILTIN */
  4859. }
  4860. }
  4861. return(1);
  4862. }
  4863. #endif /* OS2 */
  4864. #ifdef NT
  4865. case XYTATTBUG:
  4866. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  4867. if ((x = cmcfm()) < 0) return(x);
  4868. tt_attr_bug = y;
  4869. return(1);
  4870. #endif /* NT */
  4871. #ifdef OS2
  4872. case XYTSGRC:
  4873. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  4874. if ((x = cmcfm()) < 0) return(x);
  4875. sgrcolors = y;
  4876. return(1);
  4877. case XYTSEND:
  4878. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  4879. if ((x = cmcfm()) < 0) return(x);
  4880. tt_senddata = y;
  4881. return(1);
  4882. case XYTSEOB:
  4883. if ((y = cmkey(ttyseobtab,2,"","us_cr",xxstring)) < 0) return(y);
  4884. if ((x = cmcfm()) < 0) return(x);
  4885. wy_blockend = y;
  4886. return(1);
  4887. case XYTURLHI: {
  4888. int done = 0, attr = VT_CHAR_ATTR_NORMAL;
  4889. if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
  4890. return(x);
  4891. if (x) {
  4892. z = 0;
  4893. while (!done) {
  4894. if ((y = cmkey(ttyprotab,nprotect,"",
  4895. z?"done":"reverse",xxstring)) < 0)
  4896. return(y);
  4897. switch (y) {
  4898. case TTATTDONE:
  4899. done = TRUE;
  4900. break;
  4901. case TTATTBLI:
  4902. attr |= VT_CHAR_ATTR_BLINK;
  4903. break;
  4904. case TTATTREV:
  4905. attr |= VT_CHAR_ATTR_REVERSE;
  4906. break;
  4907. case TTATTITA:
  4908. attr |= VT_CHAR_ATTR_ITALIC;
  4909. break;
  4910. case TTATTUND:
  4911. attr |= VT_CHAR_ATTR_UNDERLINE;
  4912. break;
  4913. case TTATTBLD:
  4914. attr |= VT_CHAR_ATTR_BOLD;
  4915. break;
  4916. case TTATTDIM:
  4917. attr |= VT_CHAR_ATTR_DIM;
  4918. break;
  4919. case TTATTINV:
  4920. attr |= VT_CHAR_ATTR_INVISIBLE;
  4921. break;
  4922. case TTATTNOR:
  4923. break;
  4924. }
  4925. z = 1; /* One attribute has been chosen */
  4926. }
  4927. }
  4928. if ((z = cmcfm()) < 0) return(z);
  4929. seturlhl(x);
  4930. if (x)
  4931. tt_url_hilite_attr = attr;
  4932. return(1);
  4933. }
  4934. case XYTATTR:
  4935. if ((x = cmkey(ttyattrtab,nattrib,"","underline",xxstring)) < 0)
  4936. return(x);
  4937. switch (x) {
  4938. case TTATTBLI:
  4939. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  4940. if ((x = cmcfm()) < 0) return(x);
  4941. trueblink = y;
  4942. #ifndef KUI
  4943. if ( !trueblink && trueunderline ) {
  4944. trueunderline = 0;
  4945. printf("Warning: Underline being simulated by color.\n");
  4946. }
  4947. #endif /* KUI */
  4948. break;
  4949. case TTATTDIM:
  4950. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  4951. if ((x = cmcfm()) < 0) return(x);
  4952. truedim = y;
  4953. break;
  4954. case TTATTREV:
  4955. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  4956. if ((x = cmcfm()) < 0) return(x);
  4957. truereverse = y;
  4958. break;
  4959. case TTATTUND:
  4960. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  4961. if ((x = cmcfm()) < 0) return(x);
  4962. trueunderline = y;
  4963. #ifndef KUI
  4964. if (!trueblink && trueunderline) {
  4965. trueblink = 1;
  4966. printf("Warning: True blink mode is active.\n");
  4967. }
  4968. #endif /* KUI */
  4969. break;
  4970. case TTATTITA:
  4971. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  4972. if ((x = cmcfm()) < 0) return(x);
  4973. trueitalic = y;
  4974. break;
  4975. case TTATTPRO: { /* Set default Protected Character attribute */
  4976. extern vtattrib WPattrib; /* current WP Mode Attrib */
  4977. extern vtattrib defWPattrib; /* default WP Mode Attrib */
  4978. vtattrib wpa = {0,0,0,0,0,1,0,0,0,0,0}; /* Protected */
  4979. int done = 0;
  4980. x = 0;
  4981. while (!done) {
  4982. if ((y = cmkey(ttyprotab,nprotect,"",
  4983. x?"done":"dim",xxstring)) < 0)
  4984. return(y);
  4985. switch (y) {
  4986. case TTATTNOR:
  4987. break;
  4988. case TTATTBLI: /* Blinking doesn't work */
  4989. wpa.blinking = TRUE;
  4990. break;
  4991. case TTATTREV:
  4992. wpa.reversed = TRUE;
  4993. break;
  4994. case TTATTITA:
  4995. wpa.italic = TRUE;
  4996. break;
  4997. case TTATTUND:
  4998. wpa.underlined = TRUE;
  4999. break;
  5000. case TTATTBLD:
  5001. wpa.bold = TRUE;
  5002. break;
  5003. case TTATTDIM:
  5004. wpa.dim = TRUE;
  5005. break;
  5006. case TTATTINV:
  5007. wpa.invisible = TRUE ;
  5008. break;
  5009. case TTATTDONE:
  5010. done = TRUE;
  5011. break;
  5012. }
  5013. x = 1; /* One attribute has been chosen */
  5014. }
  5015. if ((x = cmcfm()) < 0) return(x);
  5016. WPattrib = defWPattrib = wpa;
  5017. break;
  5018. }
  5019. }
  5020. return(1);
  5021. case XYTKEY: { /* SET TERMINAL KEY */
  5022. int t, x, y;
  5023. int clear = 0, deflt = 0;
  5024. int confirmed = 0;
  5025. int flag = 0;
  5026. int kc = -1; /* Key code */
  5027. int litstr = 0; /* Literal String? */
  5028. char *s = NULL; /* Key binding */
  5029. #ifndef NOKVERBS
  5030. char *p = NULL; /* Worker */
  5031. #endif /* NOKVERBS */
  5032. con_event defevt;
  5033. extern int os2gks;
  5034. extern int mskkeys;
  5035. extern int initvik;
  5036. struct FDB kw,sw,nu,cm;
  5037. defevt.type = error;
  5038. if ((t = cmkey(ttkeytab,nttkey,"","",xxstring)) < 0)
  5039. return(t);
  5040. cmfdbi(&nu, /* First FDB - command switches */
  5041. _CMNUM, /* fcode */
  5042. "/literal, keycode, or action",
  5043. "", /* default */
  5044. "", /* addtl string data */
  5045. 10, /* addtl numeric data 1: radix */
  5046. 0, /* addtl numeric data 2: 0 */
  5047. xxstring, /* Processing function */
  5048. NULL, /* Keyword table */
  5049. &sw /* Pointer to next FDB */
  5050. ); /* */
  5051. cmfdbi(&sw, /* Second FDB - switches */
  5052. _CMKEY, /* fcode */
  5053. "",
  5054. "", /* default */
  5055. "", /* addtl string data */
  5056. nstrmswitab, /* addtl numeric data 1: tbl size */
  5057. 4, /* addtl numeric data 2: 4 = cmswi */
  5058. xxstring, /* Processing function */
  5059. strmswitab, /* Keyword table */
  5060. &kw /* Pointer to next FDB */
  5061. );
  5062. cmfdbi(&kw, /* Third FDB - command switches */
  5063. _CMKEY, /* fcode */
  5064. "/literal, keycode, or action",
  5065. "", /* default */
  5066. "", /* addtl string data */
  5067. nstrmkeytab, /* addtl numeric data 1: tbl size */
  5068. 0, /* addtl numeric data 2 */
  5069. xxstring, /* Processing function */
  5070. strmkeytab, /* Keyword table */
  5071. &cm /* Pointer to next FDB */
  5072. );
  5073. cmfdbi(&cm, /* Final FDB - Confirmation */
  5074. _CMCFM, /* fcode */
  5075. "",
  5076. "", /* default */
  5077. "", /* addtl string data */
  5078. 0, /* addtl numeric data 1: tbl size */
  5079. 0, /* addtl numeric data 2: 4 = cmswi */
  5080. xxstring, /* Processing function */
  5081. NULL, /* Keyword table */
  5082. NULL /* Pointer to next FDB */
  5083. );
  5084. while (kc < 0) {
  5085. x = cmfdb(&nu); /* Parse something */
  5086. if (x < 0)
  5087. return(x);
  5088. switch (cmresult.fcode) {
  5089. case _CMCFM:
  5090. printf(" Press key to be defined: ");
  5091. conbin((char)escape); /* Put terminal in binary mode */
  5092. os2gks = 0; /* Turn off Kverb preprocessing */
  5093. kc = congks(0); /* Get character or scan code */
  5094. os2gks = 1; /* Turn on Kverb preprocessing */
  5095. concb((char)escape); /* Restore terminal to cbreak mode */
  5096. if (kc < 0) { /* Check for error */
  5097. printf("?Error reading key\n");
  5098. return(0);
  5099. }
  5100. shokeycode(kc,t); /* Show current definition */
  5101. flag = 1; /* Remember it's a multiline command */
  5102. break;
  5103. case _CMNUM:
  5104. kc = cmresult.nresult;
  5105. break;
  5106. case _CMKEY:
  5107. if (cmresult.fdbaddr == &sw) { /* Switch */
  5108. if (cmresult.nresult == 0)
  5109. litstr = 1;
  5110. } else if (cmresult.fdbaddr == &kw) { /* Keyword */
  5111. if (cmresult.nresult == 0)
  5112. clear = 1;
  5113. else
  5114. deflt = 1;
  5115. if ((x = cmcfm()) < 0)
  5116. return(x);
  5117. if (clear)
  5118. clearkeymap(t);
  5119. else if (deflt)
  5120. defaultkeymap(t);
  5121. initvik = 1;
  5122. return(1);
  5123. }
  5124. }
  5125. }
  5126. /* Normal SET TERMINAL KEY <terminal> <scancode> <value> command... */
  5127. if (mskkeys)
  5128. kc = msktock(kc);
  5129. if (kc < 0 || kc >= KMSIZE) {
  5130. printf("?key code must be between 0 and %d\n", KMSIZE - 1);
  5131. return(-9);
  5132. }
  5133. if (kc == escape) {
  5134. printf("Sorry, %d is the CONNECT-mode escape character\n",kc);
  5135. return(-9);
  5136. }
  5137. wideresult = -1;
  5138. if (flag) {
  5139. cmsavp(psave,PROMPTL);
  5140. cmsetp(" Enter new definition: ");
  5141. cmini(ckxech);
  5142. }
  5143. def_again:
  5144. if (flag) prompt(NULL);
  5145. if ((y = cmtxt("key definition,\n\
  5146. or Ctrl-C to cancel this command,\n\
  5147. or Enter to restore default definition",
  5148. "",&s,NULL)) < 0) {
  5149. if (flag) /* Handle parse errors */
  5150. goto def_again;
  5151. else
  5152. return(y);
  5153. }
  5154. s = brstrip(s);
  5155. #ifndef NOKVERBS
  5156. p = s; /* Save this place */
  5157. #endif /* NOKVERBS */
  5158. /*
  5159. If the definition included any \Kverbs, quote the backslash so the \Kverb
  5160. will still be in the definition when the key is pressed. We don't do this
  5161. in zzstring(), because \Kverbs are valid only in this context and nowhere
  5162. else.
  5163. We use this code active for all versions that support SET KEY, even if they
  5164. don't support \Kverbs, because otherwise \K would behave differently for
  5165. different versions.
  5166. */
  5167. for (x = 0, y = 0; s[x]; x++, y++) { /* Convert \K to \\K */
  5168. if ((x > 0) &&
  5169. (s[x] == 'K' || s[x] == 'k')
  5170. ) { /* Have K */
  5171. if ((x == 1 && s[x-1] == CMDQ) ||
  5172. (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ)) {
  5173. line[y++] = CMDQ; /* Make it \\K */
  5174. }
  5175. if (x > 1 && s[x-1] == '{' && s[x-2] == CMDQ) {
  5176. line[y-1] = CMDQ; /* Have \{K */
  5177. line[y++] = '{'; /* Make it \\{K */
  5178. }
  5179. }
  5180. line[y] = s[x];
  5181. }
  5182. line[y++] = NUL; /* Terminate */
  5183. s = line + y + 1; /* Point to after it */
  5184. x = LINBUFSIZ - (int) strlen(line) - 1; /* Get remaining space */
  5185. if ((x < (LINBUFSIZ / 2)) ||
  5186. (zzstring(line, &s, &x) < 0)) { /* Expand variables, etc. */
  5187. printf("?Key definition too long\n");
  5188. if (flag) cmsetp(psave);
  5189. return(-9);
  5190. }
  5191. s = line + y + 1; /* Point to result. */
  5192. #ifndef NOKVERBS
  5193. /*
  5194. Special case: see if the definition starts with a \Kverb.
  5195. If it does, point to it with p, otherwise set p to NULL.
  5196. */
  5197. p = s;
  5198. if (*p++ == CMDQ) {
  5199. if (*p == '{') p++;
  5200. p = (*p == 'k' || *p == 'K') ? p + 1 : NULL;
  5201. }
  5202. #endif /* NOKVERBS */
  5203. switch (strlen(s)) { /* Action depends on length */
  5204. case 0: /* Clear individual key def */
  5205. deletekeymap(t,kc);
  5206. break;
  5207. case 1:
  5208. if (!litstr) {
  5209. defevt.type = key; /* Single character */
  5210. defevt.key.scancode = *s;
  5211. break;
  5212. }
  5213. default: /* Character string */
  5214. #ifndef NOKVERBS
  5215. if (p) {
  5216. y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  5217. /* Need exact match */
  5218. debug(F101,"set key kverb lookup",0,y);
  5219. if (y > -1) {
  5220. defevt.type = kverb;
  5221. defevt.kverb.id = y;
  5222. break;
  5223. }
  5224. }
  5225. #endif /* NOKVERBS */
  5226. if (litstr) {
  5227. defevt.type = literal;
  5228. defevt.literal.string = (char *) malloc(strlen(s)+1);
  5229. if (defevt.literal.string)
  5230. strcpy(defevt.literal.string, s); /* safe */
  5231. } else {
  5232. defevt.type = macro;
  5233. defevt.macro.string = (char *) malloc(strlen(s)+1);
  5234. if (defevt.macro.string)
  5235. strcpy(defevt.macro.string, s); /* safe */
  5236. }
  5237. break;
  5238. }
  5239. insertkeymap(t, kc, defevt);
  5240. if (flag)
  5241. cmsetp(psave);
  5242. initvik = 1; /* Update VIK table */
  5243. return(1);
  5244. }
  5245. #ifdef PCTERM
  5246. case XYTPCTERM: /* PCTERM Keyboard Mode */
  5247. if ((x = seton(&tt_pcterm)) < 0) return(x);
  5248. return(success = 1);
  5249. #endif /* PCTERM */
  5250. #endif /* OS2 */
  5251. #ifdef CK_TRIGGER
  5252. case XYTRIGGER:
  5253. if ((y = cmtxt("String to trigger automatic return to command mode",
  5254. "",&s,xxstring)) < 0)
  5255. return(y);
  5256. makelist(s,tt_trigger,TRIGGERS);
  5257. return(1);
  5258. #endif /* CK_TRIGGER */
  5259. #ifdef OS2
  5260. case XYTSAC:
  5261. if ((y = cmnum("ASCII value to use for spacing attributes",
  5262. "32",10,&x,xxstring)) < 0)
  5263. return(y);
  5264. if ((y = cmcfm()) < 0) return(y);
  5265. tt_sac = x;
  5266. return(success = 1);
  5267. case XYTKBDGL: { /* SET TERM KBD-FOLLOWS-GL/GR */
  5268. extern int tt_kb_glgr; /* from ckoco3.c */
  5269. if ((x = seton(&tt_kb_glgr)) < 0)
  5270. return(x);
  5271. return(success = 1);
  5272. }
  5273. #ifndef NOCSETS
  5274. case XYTVTLNG: /* SET TERM DEC-LANGUAGE */
  5275. if ((y = cmkey(vtlangtab,nvtlangtab,"VT language",
  5276. IS97801(tt_type_mode)?"german":"north-american",
  5277. xxstring)) < 0)
  5278. return(y);
  5279. if ((x = cmcfm()) < 0) return(x);
  5280. /* A real VT terminal would use the language to set the */
  5281. /* default keyboard language for both 8-bit multinational */
  5282. /* and 7-bit national modes. For 8-bit mode it would */
  5283. /* set the terminal character-set to the ISO set if it */
  5284. /* is not already set. */
  5285. /* Latin-1 can be replaced by DEC Multinational */
  5286. switch (y) {
  5287. case VTL_NORTH_AM: /* North American */
  5288. /* Multinational: Latin-1 */
  5289. /* National: US_ASCII */
  5290. dec_lang = y;
  5291. dec_nrc = TX_ASCII;
  5292. dec_kbd = TX_8859_1;
  5293. break;
  5294. case VTL_BRITISH :
  5295. /* Multinational: Latin-1 */
  5296. /* National: UK_ASCII */
  5297. dec_lang = y;
  5298. dec_nrc = TX_BRITISH;
  5299. dec_kbd = TX_8859_1;
  5300. break;
  5301. case VTL_FRENCH :
  5302. case VTL_BELGIAN :
  5303. case VTL_CANADIAN:
  5304. /* Multinational: Latin-1 */
  5305. /* National: FR_ASCII */
  5306. dec_lang = y;
  5307. dec_nrc = TX_FRENCH;
  5308. dec_kbd = TX_8859_1;
  5309. break;
  5310. case VTL_FR_CAN :
  5311. /* Multinational: Latin-1 */
  5312. /* National: FC_ASCII */
  5313. dec_lang = y;
  5314. dec_nrc = TX_CN_FRENCH;
  5315. dec_kbd = TX_8859_1;
  5316. break;
  5317. case VTL_DANISH :
  5318. case VTL_NORWEGIA:
  5319. /* Multinational: Latin-1 */
  5320. /* National: NO_ASCII */
  5321. dec_lang = y;
  5322. dec_nrc = TX_NORWEGIAN;
  5323. dec_kbd = TX_8859_1;
  5324. break;
  5325. case VTL_FINNISH :
  5326. /* Multinational: Latin-1 */
  5327. /* National: FI_ASCII */
  5328. dec_lang = y;
  5329. dec_nrc = TX_FINNISH;
  5330. dec_kbd = TX_8859_1;
  5331. break;
  5332. case VTL_GERMAN :
  5333. /* Multinational: Latin-1 */
  5334. /* National: GR_ASCII */
  5335. dec_lang = y;
  5336. dec_nrc = TX_GERMAN;
  5337. dec_kbd = TX_8859_1;
  5338. break;
  5339. case VTL_DUTCH :
  5340. /* Multinational: Latin-1 */
  5341. /* National: DU_ASCII */
  5342. dec_lang = y;
  5343. dec_nrc = TX_DUTCH;
  5344. dec_kbd = TX_8859_1;
  5345. break;
  5346. case VTL_ITALIAN :
  5347. /* Multinational: Latin-1 */
  5348. /* National: IT_ASCII */
  5349. dec_lang = y;
  5350. dec_nrc = TX_ITALIAN;
  5351. dec_kbd = TX_8859_1;
  5352. break;
  5353. case VTL_SW_FR :
  5354. case VTL_SW_GR :
  5355. /* Multinational: Latin-1 */
  5356. /* National: CH_ASCII */
  5357. dec_lang = y;
  5358. dec_nrc = TX_SWISS;
  5359. dec_kbd = TX_8859_1;
  5360. break;
  5361. case VTL_SWEDISH :
  5362. /* Multinational: Latin-1 */
  5363. /* National: SW_ASCII */
  5364. dec_lang = y;
  5365. dec_nrc = TX_SWEDISH;
  5366. dec_kbd = TX_8859_1;
  5367. break;
  5368. case VTL_SPANISH :
  5369. /* Multinational: Latin-1 */
  5370. /* National: SP_ASCII */
  5371. dec_lang = y;
  5372. dec_nrc = TX_SPANISH;
  5373. dec_kbd = TX_8859_1;
  5374. break;
  5375. case VTL_PORTUGES:
  5376. /* Multinational: Latin-1 */
  5377. /* National: Portugese ASCII */
  5378. dec_lang = y;
  5379. dec_nrc = TX_PORTUGUESE;
  5380. dec_kbd = TX_8859_1;
  5381. break;
  5382. case VTL_HEBREW :
  5383. /* Multinational: Latin-Hebrew / DEC-Hebrew */
  5384. /* National: DEC 7-bit Hebrew */
  5385. dec_lang = y;
  5386. dec_nrc = TX_HE7;
  5387. dec_kbd = TX_8859_8;
  5388. break;
  5389. case VTL_GREEK :
  5390. /* Multinational: Latin-Greek / DEC-Greek */
  5391. /* National: DEC Greek NRC */
  5392. /* is ELOT927 equivalent to DEC Greek???? */
  5393. dec_lang = y;
  5394. dec_nrc = TX_ELOT927;
  5395. dec_kbd = TX_8859_7;
  5396. break;
  5397. #ifdef COMMENT
  5398. case VTL_TURK_Q :
  5399. case VTL_TURK_F :
  5400. /* Multinational: Latin-Turkish / DEC-Turkish */
  5401. /* National: DEC 7-bit Turkish */
  5402. break;
  5403. #endif /* COMMENT */
  5404. case VTL_HUNGARIA:
  5405. /* Multinational: Latin-2 */
  5406. /* National: no national mode */
  5407. dec_lang = y;
  5408. dec_nrc = TX_HUNGARIAN;
  5409. dec_kbd = TX_8859_2;
  5410. break;
  5411. case VTL_SLOVAK :
  5412. case VTL_CZECH :
  5413. case VTL_POLISH :
  5414. case VTL_ROMANIAN:
  5415. /* Multinational: Latin-2 */
  5416. /* National: no national mode */
  5417. dec_lang = y;
  5418. dec_nrc = TX_ASCII;
  5419. dec_kbd = TX_8859_2;
  5420. break;
  5421. case VTL_RUSSIAN :
  5422. /* Multinational: Latin-Cyrillic / KOI-8 */
  5423. /* National: DEC Russian NRC */
  5424. dec_lang = y;
  5425. dec_nrc = TX_KOI7;
  5426. dec_kbd = TX_8859_5;
  5427. break;
  5428. case VTL_LATIN_AM:
  5429. /* Multinational: not listed in table */
  5430. /* National: not listed in table */
  5431. dec_lang = y;
  5432. dec_nrc = TX_ASCII;
  5433. dec_kbd = TX_8859_1;
  5434. break;
  5435. #ifdef COMMENT
  5436. case VTL_SCS :
  5437. /* Multinational: Latin-2 */
  5438. /* National: SCS NRC */
  5439. break;
  5440. #endif /* COMMENT */
  5441. default:
  5442. return(success = 0);
  5443. }
  5444. if (IS97801(tt_type_mode)) {
  5445. SNI_bitmode(cmask == 0377 ? 8 : 7);
  5446. }
  5447. return(success = 1);
  5448. #endif /* NOCSETS */
  5449. case XYTVTNRC: { /* SET TERM DEC-NRC-MODE */
  5450. extern int decnrcm_usr, decnrcm; /* from ckoco3.c */
  5451. if ((x = seton(&decnrcm_usr)) < 0)
  5452. return(x);
  5453. decnrcm = decnrcm_usr;
  5454. return(success = 1);
  5455. }
  5456. case XYTSNIPM: { /* SET TERM SNI-PAGEMODE */
  5457. extern int sni_pagemode, sni_pagemode_usr;
  5458. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  5459. if ((x = cmcfm()) < 0) return(x);
  5460. sni_pagemode_usr = sni_pagemode = y;
  5461. return(success = 1);
  5462. }
  5463. case XYTSNISM: { /* SET TERM SNI-SCROLLMODE */
  5464. extern int sni_scroll_mode, sni_scroll_mode_usr;
  5465. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  5466. if ((x = cmcfm()) < 0) return(x);
  5467. sni_scroll_mode_usr = sni_scroll_mode = y;
  5468. return(success = 1);
  5469. }
  5470. case XYTSNICC: { /* SET TERM SNI-CH.CODE */
  5471. extern int sni_chcode_usr;
  5472. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  5473. if ((x = cmcfm()) < 0) return(x);
  5474. sni_chcode_usr = y;
  5475. SNI_chcode(y);
  5476. return(success = 1);
  5477. }
  5478. case XYTSNIFV: { /* SET TERM SNI-FIRMWARE-VERSIONS */
  5479. extern CHAR sni_kbd_firmware[], sni_term_firmware[];
  5480. CHAR kbd[7],term[7];
  5481. if ((x = cmfld("Keyboard Firmware Version",sni_kbd_firmware,
  5482. &s, xxstring)) < 0)
  5483. return(x);
  5484. if ((int)strlen(s) != 6) {
  5485. printf("?Sorry - the firmware version must be 6 digits long\n");
  5486. return(-9);
  5487. }
  5488. for (i = 0; i < 6; i++) {
  5489. if (!isdigit(s[i])) {
  5490. printf("?Sorry - the firmware version can only contain digits [0-9]\n");
  5491. return(-9);
  5492. }
  5493. }
  5494. ckstrncpy(kbd,s,7);
  5495. if ((x = cmfld("Terminal Firmware Version",sni_term_firmware,
  5496. &s, xxstring)) < 0)
  5497. return(x);
  5498. if ((int)strlen(s) != 6) {
  5499. printf("?Sorry - the firmware version must be 6 digits long\n");
  5500. return(-9);
  5501. }
  5502. for (i = 0; i < 6; i++) {
  5503. if (!isdigit(s[i])) {
  5504. printf("?Sorry - the firmware version can only contain digits [0-9]\n");
  5505. return(-9);
  5506. }
  5507. }
  5508. ckstrncpy(term,s,7);
  5509. if ((x = cmcfm()) < 0) return(x);
  5510. ckstrncpy(sni_kbd_firmware,kbd,7);
  5511. ckstrncpy(sni_term_firmware,term,7);
  5512. return(success = 1);
  5513. }
  5514. case XYTLSP: { /* SET TERM LINE-SPACING */
  5515. if ((x = cmfld("Line Spacing","1",&s, xxstring)) < 0)
  5516. return(x);
  5517. if (isfloat(s,0) < 1) { /* (sets floatval) */
  5518. printf("?Integer or floating-point number required\n");
  5519. return(-9);
  5520. }
  5521. if (floatval < 1.0 || floatval > 3.0) {
  5522. printf("?Value must within the range 1.0 and 3.0 (inclusive)\n");
  5523. return(-9);
  5524. }
  5525. if ((x = cmcfm()) < 0) return(x);
  5526. #ifdef KUI
  5527. tt_linespacing[VCMD] = tt_linespacing[VTERM] = floatval;
  5528. return(success = 1);
  5529. #else /* KUI */
  5530. printf("?Sorry, Line-spacing is only supported in K95G.EXE.\n");
  5531. return(success = 0);
  5532. #endif /* KUI */
  5533. }
  5534. #endif /* OS2 */
  5535. default: /* Shouldn't get here. */
  5536. return(-2);
  5537. }
  5538. #endif /* MAC */
  5539. #ifdef COMMENT
  5540. /*
  5541. This was supposed to shut up picky compilers but instead it makes
  5542. most compilers complain about "statement not reached".
  5543. */
  5544. return(-2);
  5545. #endif /* COMMENT */
  5546. #ifdef OS2
  5547. return(-2);
  5548. #endif /* OS2 */
  5549. }
  5550. #ifdef OS2
  5551. int
  5552. settitle(void) {
  5553. extern char usertitle[];
  5554. if ((y = cmtxt("title text","",&s,xxstring)) < 0)
  5555. return(y);
  5556. #ifdef IKSD
  5557. if (inserver) {
  5558. printf("?Sorry, command disabled.\r\n");
  5559. return(success = 0);
  5560. }
  5561. #endif /* IKSD */
  5562. s = brstrip(s);
  5563. ckstrncpy(usertitle,s,64);
  5564. os2settitle("",1);
  5565. return(1);
  5566. }
  5567. static struct keytab dialertab[] = { /* K95 Dialer types */
  5568. "backspace", 0, 0,
  5569. "enter", 1, 0
  5570. };
  5571. static int ndialer = 2;
  5572. int
  5573. setdialer(void) {
  5574. int t, x, y;
  5575. int clear = 0, deflt = 0;
  5576. int kc; /* Key code */
  5577. char *s = NULL; /* Key binding */
  5578. #ifndef NOKVERBS
  5579. char *p = NULL; /* Worker */
  5580. #endif /* NOKVERBS */
  5581. con_event defevt;
  5582. extern int os2gks;
  5583. extern int mskkeys;
  5584. extern int initvik;
  5585. defevt.type = error;
  5586. if (( x = cmkey(dialertab, ndialer,
  5587. "Kermit-95 dialer work-arounds",
  5588. "", xxstring)) < 0 )
  5589. return(x);
  5590. switch (x) {
  5591. case 0: /* Backspace */
  5592. kc = 264;
  5593. break;
  5594. case 1: /* Enter */
  5595. kc = 269;
  5596. break;
  5597. default:
  5598. printf("Illegal value in setdialer()\n");
  5599. return(-9);
  5600. }
  5601. if ((y = cmtxt("Key definition","",&s,xxstring)) < 0)
  5602. return(y);
  5603. #ifdef IKSD
  5604. if (inserver) {
  5605. printf("?Sorry, command disabled.\r\n");
  5606. return(success = 0);
  5607. }
  5608. #endif /* IKSD */
  5609. s = brstrip(s);
  5610. #ifndef NOKVERBS
  5611. p = s; /* Save this place */
  5612. #endif /* NOKVERBS */
  5613. /*
  5614. If the definition included any \Kverbs, quote the backslash so the \Kverb
  5615. will still be in the definition when the key is pressed. We don't do this
  5616. in zzstring(), because \Kverbs are valid only in this context and nowhere
  5617. else.
  5618. We use this code active for all versions that support SET KEY, even if they
  5619. don't support \Kverbs, because otherwise \K would behave differently for
  5620. different versions.
  5621. */
  5622. for (x = 0, y = 0; s[x]; x++, y++) { /* Convert \K to \\K */
  5623. if ((x > 0) &&
  5624. (s[x] == 'K' || s[x] == 'k')
  5625. ) { /* Have K */
  5626. if ((x == 1 && s[x-1] == CMDQ) ||
  5627. (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ)) {
  5628. line[y++] = CMDQ; /* Make it \\K */
  5629. }
  5630. if (x > 1 && s[x-1] == '{' && s[x-2] == CMDQ) {
  5631. line[y-1] = CMDQ; /* Have \{K */
  5632. line[y++] = '{'; /* Make it \\{K */
  5633. }
  5634. }
  5635. line[y] = s[x];
  5636. }
  5637. line[y++] = NUL; /* Terminate */
  5638. s = line + y + 1; /* Point to after it */
  5639. x = LINBUFSIZ - (int) strlen(line) - 1; /* Calculate remaining space */
  5640. if ((x < (LINBUFSIZ / 2)) ||
  5641. (zzstring(line, &s, &x) < 0)) { /* Expand variables, etc. */
  5642. printf("?Key definition too long\n");
  5643. return(-9);
  5644. }
  5645. s = line + y + 1; /* Point to result. */
  5646. #ifndef NOKVERBS
  5647. /*
  5648. Special case: see if the definition starts with a \Kverb.
  5649. If it does, point to it with p, otherwise set p to NULL.
  5650. */
  5651. p = s;
  5652. if (*p++ == CMDQ) {
  5653. if (*p == '{') p++;
  5654. p = (*p == 'k' || *p == 'K') ? p + 1 : NULL;
  5655. }
  5656. #endif /* NOKVERBS */
  5657. /* Clear the definition for SET KEY */
  5658. if (macrotab[kc]) { /* Possibly free old macro from key. */
  5659. free((char *)macrotab[kc]);
  5660. macrotab[kc] = NULL;
  5661. }
  5662. keymap[kc] = (KEY) kc;
  5663. /* Now reprogram the default value for all terminal types */
  5664. /* remember to treat Wyse and Televideo terminals special */
  5665. /* because of their use of Kverbs for Backspace and Enter */
  5666. for (t = 0; t <= TT_MAX; t++) {
  5667. if ( ISDG200(t) && kc == 264) {
  5668. extern char * udkfkeys[] ;
  5669. if (kc == 264) { /* \Kdgbs */
  5670. if (udkfkeys[83])
  5671. free(udkfkeys[83]);
  5672. udkfkeys[83] = strdup(s);
  5673. }
  5674. } else if (ISWYSE(t) || ISTVI(t)) {
  5675. extern char * udkfkeys[] ;
  5676. if (kc == 264) { /* \Kwybs or \Ktvibs */
  5677. if (udkfkeys[32])
  5678. free(udkfkeys[32]);
  5679. udkfkeys[32] = strdup(s);
  5680. }
  5681. if (kc == 269) { /* \Kwyenter and \Kwyreturn */
  5682. if (udkfkeys[39]) /* \Ktvienter and \Ktvireturn */
  5683. free(udkfkeys[39]);
  5684. udkfkeys[39] = strdup(s);
  5685. if (udkfkeys[49])
  5686. free(udkfkeys[49]);
  5687. udkfkeys[49] = strdup(s);
  5688. }
  5689. } else {
  5690. switch (strlen(s)) { /* Action depends on length */
  5691. case 0: /* Clear individual key def */
  5692. deletekeymap(t,kc);
  5693. break;
  5694. case 1:
  5695. defevt.type = key; /* Single character */
  5696. defevt.key.scancode = *s;
  5697. break;
  5698. default: /* Character string */
  5699. #ifndef NOKVERBS
  5700. if (p) {
  5701. y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  5702. /* Exact match req'd */
  5703. debug(F101,"set key kverb lookup",0,y);
  5704. if (y > -1) {
  5705. defevt.type = kverb;
  5706. defevt.kverb.id = y;
  5707. break;
  5708. }
  5709. }
  5710. #endif /* NOKVERBS */
  5711. defevt.type = macro;
  5712. defevt.macro.string = (char *) malloc(strlen(s)+1);
  5713. if (defevt.macro.string)
  5714. strcpy(defevt.macro.string, s); /* safe */
  5715. break;
  5716. }
  5717. insertkeymap( t, kc, defevt ) ;
  5718. initvik = 1; /* Update VIK table */
  5719. }
  5720. }
  5721. return(1);
  5722. }
  5723. #endif /* OS2 */
  5724. #ifdef NT
  5725. int
  5726. setwin95( void ) {
  5727. int x, y, z;
  5728. if (( y = cmkey(win95tab, nwin95,
  5729. "Windows 95 specific work-arounds",
  5730. "keyboard-translation",
  5731. xxstring)) < 0 )
  5732. return (y);
  5733. switch (y) {
  5734. case XYWPOPUP:
  5735. if ((y = cmkey(onoff,2,"popups are used to prompt the user for data",
  5736. "on",xxstring)) < 0)
  5737. return(y);
  5738. if ((x = cmcfm()) < 0) return(x);
  5739. win95_popup = y;
  5740. return(1);
  5741. case XYW8_3:
  5742. if ((y = cmkey(onoff,2,"8.3 FAT file names","off",xxstring)) < 0)
  5743. return(y);
  5744. if ((x = cmcfm()) < 0) return(x);
  5745. win95_8_3 = y;
  5746. return(1);
  5747. case XYWSELECT:
  5748. if ((y = cmkey(onoff,2,"\"select()\" fails on write","off",
  5749. xxstring)) < 0)
  5750. return(y);
  5751. if ((x = cmcfm()) < 0) return(x);
  5752. win95selectbug = y;
  5753. return(1);
  5754. case XYWAGR:
  5755. if ((y = cmkey(onoff,2,"Right-Alt is Alt-Gr","off",xxstring)) < 0)
  5756. return(y);
  5757. if ((x = cmcfm()) < 0) return(x);
  5758. win95altgr = y;
  5759. return(1);
  5760. case XYWOIO:
  5761. if ((y = cmkey(onoff,2,"Use Overlapped I/O","on",xxstring)) < 0)
  5762. return(y);
  5763. if (y) {
  5764. if ((x = cmnum("Maximum number of outstanding I/O requests",
  5765. "10",10,&z,xxstring)) < 0)
  5766. return(x);
  5767. if (z < 1 || z > 7) {
  5768. printf(
  5769. "?Maximum outstanding I/O requests must be between 1 and 7.\n");
  5770. return(-9);
  5771. }
  5772. } else
  5773. z = 1;
  5774. if ((x = cmcfm()) < 0) return(x);
  5775. owwait = !y;
  5776. maxow = maxow_usr = z;
  5777. return(1);
  5778. case XYWKEY:
  5779. #ifndef COMMENT
  5780. printf("\n?\"Keyboard-Translation\" is no longer required.\n");
  5781. return(-9);
  5782. #else /* COMMENT */
  5783. if (( z = cmkey(tcstab, ntcs,
  5784. "Keyboard Character Set",
  5785. "latin1-iso",
  5786. xxstring)) < 0)
  5787. return (z);
  5788. if ((x = cmcfm()) < 0)
  5789. return(x);
  5790. win95kcsi = z;
  5791. win95kl2 = (win95kcsi == TC_2LATIN);
  5792. if (win95kcsi == TC_TRANSP) {
  5793. win95kcs = NULL;
  5794. } else {
  5795. #ifdef UNICODE
  5796. win95kcs = xlr[win95kcsi][tx2fc(tcsl)];
  5797. #else /* UNICODE */
  5798. win95kcs = xlr[win95kcsi][tcsl];
  5799. #endif /* UNICODE */
  5800. }
  5801. return(1);
  5802. #endif /* COMMENT */
  5803. case XYWLUC:
  5804. if ((y = cmkey(onoff,2,"Unicode-to-Lucida-Console substitutions",
  5805. "on",xxstring)) < 0)
  5806. return(y);
  5807. if ((x = cmcfm()) < 0) return(x);
  5808. win95lucida = y;
  5809. return(1);
  5810. case XYWHSL:
  5811. if ((y = cmkey(onoff,2,"Horizontal Scan Line substitutions",
  5812. "on",xxstring)) < 0)
  5813. return(y);
  5814. if ((x = cmcfm()) < 0) return(x);
  5815. win95hsl = y;
  5816. return(1);
  5817. default:
  5818. printf("Illegal value in setwin95()\n");
  5819. return(-9);
  5820. }
  5821. }
  5822. #endif /* NT */
  5823. #ifdef OS2
  5824. int
  5825. setprty (
  5826. #ifdef CK_ANSIC
  5827. void
  5828. #endif /* CK_ANSIC */
  5829. /* setprty */ ) {
  5830. int x, y, z;
  5831. if (( y = cmkey(prtytab, nprty,
  5832. "priority level of terminal and communication threads",
  5833. "foreground-server",
  5834. xxstring)) < 0 )
  5835. return (y);
  5836. if ((x = cmcfm()) < 0)
  5837. return (x);
  5838. #ifdef IKSD
  5839. if (inserver &&
  5840. #ifdef IKSDCONF
  5841. iksdcf
  5842. #else
  5843. 1
  5844. #endif /* IKSDCONF */
  5845. ) {
  5846. if ((y = cmcfm()) < 0) return(y);
  5847. printf("?Sorry, command disabled.\r\n");
  5848. return(success = 0);
  5849. }
  5850. #endif /* IKSD */
  5851. priority = y;
  5852. return(TRUE);
  5853. }
  5854. #endif /* OS2 */
  5855. int
  5856. setbell() {
  5857. int y, x;
  5858. #ifdef OS2
  5859. int z;
  5860. #endif /* OS2 */
  5861. if ((y = cmkey(beltab,nbeltab,
  5862. #ifdef OS2
  5863. "how console and terminal bells should\nbe generated", "audible",
  5864. #else
  5865. "Whether Kermit should ring the terminal bell (beep)", "on",
  5866. #endif /* OS2 */
  5867. xxstring)) < 0)
  5868. return(y);
  5869. #ifdef IKSD
  5870. if (inserver) {
  5871. if ((y = cmcfm()) < 0) return(y);
  5872. printf("?Sorry, command disabled.\r\n");
  5873. return(success = 0);
  5874. }
  5875. #endif /* IKSD */
  5876. switch (y) { /* SET BELL */
  5877. case XYB_NONE:
  5878. #ifdef OS2
  5879. case XYB_VIS:
  5880. #endif /* OS2 */
  5881. if ((x = cmcfm()) < 0)
  5882. return(x);
  5883. #ifdef OS2
  5884. tt_bell = y;
  5885. #else
  5886. tt_bell = 0;
  5887. #endif /* OS2 */
  5888. break;
  5889. case XYB_AUD:
  5890. #ifdef OS2
  5891. if ((x = cmkey(audibletab, naudibletab,
  5892. "how audible console and terminal\nbells should be generated",
  5893. "beep",xxstring))<0)
  5894. return(x);
  5895. if ((z = cmcfm()) < 0)
  5896. return(z);
  5897. tt_bell = y | x;
  5898. #else
  5899. /* This lets C-Kermit accept but ignore trailing K95 keywords */
  5900. if ((x = cmtxt("Confirm with carriage return","",&s,xxstring)) < 0)
  5901. return(x);
  5902. tt_bell = 1;
  5903. #endif /* OS2 */
  5904. break;
  5905. }
  5906. return(1);
  5907. }
  5908. #ifdef OS2MOUSE
  5909. int
  5910. setmou(
  5911. #ifdef CK_ANSIC
  5912. void
  5913. #endif /* CK_ANSIC */
  5914. /* setmou */ ) {
  5915. extern int initvik;
  5916. int button = 0, event = 0;
  5917. char * p;
  5918. if ((y = cmkey(mousetab,nmtab,"","",xxstring)) < 0)
  5919. return(y);
  5920. #ifdef IKSD
  5921. if (inserver) {
  5922. if ((y = cmcfm()) < 0) return(y);
  5923. printf("?Sorry, command disabled.\r\n");
  5924. return(success = 0);
  5925. }
  5926. #endif /* IKSD */
  5927. if (y == XYM_ON) { /* MOUSE ACTIVATION */
  5928. int old_mou = tt_mouse;
  5929. if ((x = seton(&tt_mouse)) < 0)
  5930. return(x);
  5931. if (tt_mouse != old_mou)
  5932. if (tt_mouse)
  5933. os2_mouseon();
  5934. else
  5935. os2_mouseoff();
  5936. return(1);
  5937. }
  5938. if (y == XYM_DEBUG) { /* MOUSE DEBUG */
  5939. extern int MouseDebug;
  5940. if ((x = seton(&MouseDebug)) < 0)
  5941. return(x);
  5942. return(1);
  5943. }
  5944. if (y == XYM_CLEAR) { /* Reset Mouse Defaults */
  5945. if ((x = cmcfm()) < 0) return(x);
  5946. mousemapinit(-1,-1);
  5947. initvik = 1; /* Update VIK Table */
  5948. return 1;
  5949. }
  5950. if (y != XYM_BUTTON) { /* Shouldn't happen. */
  5951. printf("Internal parsing error\n");
  5952. return(-9);
  5953. }
  5954. /* MOUSE EVENT ... */
  5955. if ((button = cmkey(mousebuttontab,nmbtab,
  5956. "Button number","1",
  5957. xxstring)) < 0)
  5958. return(button);
  5959. if ((y = cmkey(mousemodtab,nmmtab,
  5960. "Keyboard modifier","none",
  5961. xxstring)) < 0)
  5962. return(y);
  5963. event |= y; /* OR in the bits */
  5964. if ((y = cmkey(mclicktab,nmctab,"","click",xxstring)) < 0)
  5965. return(y);
  5966. /* Two bits are assigned, if neither are set then it is button one */
  5967. event |= y; /* OR in the bit */
  5968. wideresult = -1;
  5969. if ((y = cmtxt("definition,\n\
  5970. or Ctrl-C to cancel this command,\n\
  5971. or Enter to restore default definition",
  5972. "",&s,NULL)) < 0) {
  5973. return(y);
  5974. }
  5975. s = brstrip(s);
  5976. p = s; /* Save this place */
  5977. /*
  5978. If the definition included any \Kverbs, quote the backslash so the \Kverb
  5979. will still be in the definition when the key is pressed. We don't do this
  5980. in zzstring(), because \Kverbs are valid only in this context and nowhere
  5981. else. This code copied from SET KEY, q.v. for addt'l commentary.
  5982. */
  5983. for (x = 0, y = 0; s[x]; x++, y++) { /* Convert \K to \\K */
  5984. if ((x > 0) &&
  5985. (s[x] == 'K' || s[x] == 'k')
  5986. ) { /* Have K */
  5987. if ((x == 1 && s[x-1] == CMDQ) ||
  5988. (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ)) {
  5989. line[y++] = CMDQ; /* Make it \\K */
  5990. }
  5991. if (x > 1 && s[x-1] == '{' && s[x-2] == CMDQ) {
  5992. line[y-1] = CMDQ; /* Have \{K */
  5993. line[y++] = '{'; /* Make it \\{K */
  5994. }
  5995. }
  5996. line[y] = s[x];
  5997. }
  5998. line[y++] = NUL; /* Terminate */
  5999. s = line + y + 1; /* Point to after it */
  6000. x = LINBUFSIZ - (int) strlen(line) - 1; /* Calculate remaining space */
  6001. if ((x < (LINBUFSIZ / 2)) ||
  6002. (zzstring(line, &s, &x) < 0)) { /* Expand variables, etc. */
  6003. printf("?Key definition too long\n");
  6004. return(-9);
  6005. }
  6006. s = line + y + 1; /* Point to result. */
  6007. #ifndef NOKVERBS
  6008. /*
  6009. Special case: see if the definition starts with a \Kverb.
  6010. If it does, point to it with p, otherwise set p to NULL.
  6011. */
  6012. p = s;
  6013. if (*p++ == CMDQ) {
  6014. if (*p == '{') p++;
  6015. p = (*p == 'k' || *p == 'K') ? p + 1 : NULL;
  6016. }
  6017. #else
  6018. p = NULL;
  6019. #endif /* NOKVERBS */
  6020. /* free the old definition if necessary */
  6021. if (mousemap[button][event].type == macro) {
  6022. free( mousemap[button][event].macro.string);
  6023. mousemap[button][event].macro.string = NULL;
  6024. }
  6025. switch (strlen(s)) { /* Action depends on length */
  6026. case 0: /* Reset to default binding */
  6027. mousemapinit( button, event );
  6028. break;
  6029. case 1: /* Single character */
  6030. mousemap[button][event].type = key;
  6031. mousemap[button][event].key.scancode = *s;
  6032. break;
  6033. default: /* Character string */
  6034. #ifndef NOKVERBS
  6035. if (p) {
  6036. y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  6037. debug(F101,"set mouse kverb lookup",0,y); /* need exact match */
  6038. if (y > -1) {
  6039. /* Assign the kverb to the event */
  6040. mousemap[button][event].type = kverb;
  6041. mousemap[button][event].kverb.id = F_KVERB | y;
  6042. break;
  6043. }
  6044. }
  6045. #endif /* NOKVERBS */
  6046. /* Otherwise, it's a macro, so assign the macro to the event */
  6047. mousemap[button][event].type = macro;
  6048. mousemap[button][event].macro.string = (MACRO) malloc(strlen(s)+1);
  6049. if (mousemap[button][event].macro.string)
  6050. strcpy((char *) mousemap[button][event].macro.string, s); /* safe */
  6051. break;
  6052. }
  6053. initvik = 1; /* Update VIK Table */
  6054. if ( (button == XYM_B3) && (mousebuttoncount() < 3) && !quiet )
  6055. {
  6056. printf("?Warning: this machine does not have a three button mouse.\n");
  6057. return(0);
  6058. }
  6059. return(1);
  6060. }
  6061. #endif /* OS2MOUSE */
  6062. #endif /* NOLOCAL */
  6063. #ifndef NOXFER
  6064. int /* SET SEND/RECEIVE */
  6065. setsr(xx, rmsflg) int xx; int rmsflg; {
  6066. if (xx == XYRECV)
  6067. ckstrncpy(line,"Parameter for inbound packets",LINBUFSIZ);
  6068. else
  6069. ckstrncpy(line,"Parameter for outbound packets",LINBUFSIZ);
  6070. if (rmsflg) {
  6071. if ((y = cmkey(rsrtab,nrsrtab,line,"",xxstring)) < 0) {
  6072. if (y == -3) {
  6073. printf("?Remote receive parameter required\n");
  6074. return(-9);
  6075. } else return(y);
  6076. }
  6077. } else {
  6078. if ((y = cmkey(srtab,nsrtab,line,"",xxstring)) < 0) return(y);
  6079. }
  6080. switch (y) {
  6081. case XYQCTL: /* CONTROL-PREFIX */
  6082. if ((x = cmnum("ASCII value of control prefix","",10,&y,xxstring)) < 0)
  6083. return(x);
  6084. if ((x = cmcfm()) < 0) return(x);
  6085. if ((y > 32 && y < 63) || (y > 95 && y < 127)) {
  6086. if (xx == XYRECV)
  6087. ctlq = (CHAR) y; /* RECEIVE prefix, use with caution! */
  6088. else
  6089. myctlq = (CHAR) y; /* SEND prefix, OK to change */
  6090. return(success = 1);
  6091. } else {
  6092. printf("?Illegal value for prefix character\n");
  6093. return(-9);
  6094. }
  6095. case XYEOL:
  6096. if ((y = setcc("13",&z)) < 0)
  6097. return(y);
  6098. if (z > 31) {
  6099. printf("Sorry, the legal values are 0-31\n");
  6100. return(-9);
  6101. }
  6102. if (xx == XYRECV)
  6103. eol = (CHAR) z;
  6104. else
  6105. seol = (CHAR) z;
  6106. return(success = y);
  6107. case XYLEN:
  6108. y = cmnum("Maximum number of characters in a packet","90",10,&x,
  6109. xxstring);
  6110. if (xx == XYRECV) { /* Receive... */
  6111. if ((y = setnum(&z,x,y,maxrps)) < 0)
  6112. return(y);
  6113. if (protocol != PROTO_K) {
  6114. printf("?Sorry, this command does not apply to %s protocol.\n",
  6115. ptab[protocol].p_name
  6116. );
  6117. printf("Use SET SEND PACKET-LENGTH for XYZMODEM\n");
  6118. return(-9);
  6119. }
  6120. if (z < 10) {
  6121. printf("Sorry, 10 is the minimum\n");
  6122. return(-9);
  6123. }
  6124. if (rmsflg) {
  6125. sstate = setgen('S', "401", ckitoa(z), "");
  6126. return((int) sstate);
  6127. } else {
  6128. if (protocol == PROTO_K) {
  6129. if (z > MAXRP) z = MAXRP;
  6130. y = adjpkl(z,wslotr,bigrbsiz);
  6131. if (y != z) {
  6132. urpsiz = y;
  6133. if (!xcmdsrc)
  6134. if (msgflg) printf(
  6135. " Adjusting receive packet-length to %d for %d window slots\n",
  6136. y, wslotr);
  6137. }
  6138. urpsiz = y;
  6139. ptab[protocol].rpktlen = urpsiz;
  6140. rpsiz = (y > 94) ? 94 : y;
  6141. } else {
  6142. #ifdef CK_XYZ
  6143. if ((protocol == PROTO_X || protocol == PROTO_XC) &&
  6144. z != 128 && z != 1024) {
  6145. printf("Sorry, bad packet length for XMODEM.\n");
  6146. printf("Please use 128 or 1024.\n");
  6147. return(-9);
  6148. }
  6149. #endif /* CK_XYZ */
  6150. urpsiz = rpsiz = z;
  6151. }
  6152. }
  6153. } else { /* Send... */
  6154. if ((y = setnum(&z,x,y,maxsps)) < 0)
  6155. return(y);
  6156. if (z < 10) {
  6157. printf("Sorry, 10 is the minimum\n");
  6158. return(-9);
  6159. }
  6160. if (protocol == PROTO_K) {
  6161. if (z > MAXSP) z = MAXSP;
  6162. spsiz = z; /* Set it */
  6163. y = adjpkl(spsiz,wslotr,bigsbsiz);
  6164. if (y != spsiz && !xcmdsrc)
  6165. if (msgflg)
  6166. printf("Adjusting packet size to %d for %d window slots\n",
  6167. y,wslotr);
  6168. } else
  6169. y = z;
  6170. #ifdef CK_XYZ
  6171. if ((protocol == PROTO_X || protocol == PROTO_XC) &&
  6172. z != 128 && z != 1024) {
  6173. printf("Sorry, bad packet length for XMODEM.\n");
  6174. printf("Please use 128 or 1024.\n");
  6175. return(-9);
  6176. }
  6177. #endif /* CK_XYZ */
  6178. spsiz = spmax = spsizr = y; /* Set it and flag that it was set */
  6179. spsizf = 1; /* to allow overriding Send-Init. */
  6180. ptab[protocol].spktflg = spsizf;
  6181. ptab[protocol].spktlen = spsiz;
  6182. }
  6183. if (pflag && protocol == PROTO_K && !xcmdsrc) {
  6184. if (z > 94 && !reliable && msgflg) {
  6185. /* printf("Extended-length packets requested.\n"); */
  6186. if (bctr < 2 && z > 200) printf("\
  6187. Remember to SET BLOCK 2 or 3 for long packets.\n");
  6188. }
  6189. if (speed <= 0L) speed = ttgspd();
  6190. #ifdef COMMENT
  6191. /*
  6192. Kermit does this now itself.
  6193. */
  6194. if (speed <= 0L && z > 200 && msgflg) {
  6195. printf("\
  6196. Make sure your timeout interval is long enough for %d-byte packets.\n",z);
  6197. }
  6198. #endif /* COMMENT */
  6199. }
  6200. return(success = y);
  6201. case XYMARK:
  6202. #ifdef DOOMSDAY
  6203. /*
  6204. Printable start-of-packet works for UNIX and VMS only!
  6205. */
  6206. x_ifnum = 1;
  6207. y = cmnum("Code for packet-start character","1",10,&x,xxstring);
  6208. x_ifnum = 0;
  6209. if ((y = setnum(&z,x,y,126)) < 0) return(y);
  6210. #else
  6211. if ((y = setcc("1",&z)) < 0)
  6212. return(y);
  6213. #endif /* DOOMSDAY */
  6214. if (xx == XYRECV)
  6215. stchr = (CHAR) z;
  6216. else {
  6217. mystch = (CHAR) z;
  6218. #ifdef IKS_OPTION
  6219. /* If IKS negotiation in use */
  6220. if (TELOPT_U(TELOPT_KERMIT) || TELOPT_ME(TELOPT_KERMIT))
  6221. tn_siks(KERMIT_SOP); /* Report change to other side */
  6222. #endif /* IKS_OPTION */
  6223. }
  6224. return(success = y);
  6225. case XYNPAD: /* PADDING */
  6226. y = cmnum("How many padding characters for inbound packets","0",10,&x,
  6227. xxstring);
  6228. if ((y = setnum(&z,x,y,94)) < 0) return(y);
  6229. if (xx == XYRECV)
  6230. mypadn = (CHAR) z;
  6231. else
  6232. npad = (CHAR) z;
  6233. return(success = y);
  6234. case XYPADC: /* PAD-CHARACTER */
  6235. if ((y = setcc("0",&z)) < 0) return(y);
  6236. if (xx == XYRECV) mypadc = z; else padch = z;
  6237. return(success = y);
  6238. case XYTIMO: /* TIMEOUT */
  6239. if (xx == XYRECV) {
  6240. y = cmnum("Packet timeout interval",ckitoa(URTIME),10,&x,xxstring);
  6241. if ((y = setnum(&z,x,y,94)) < 0) return(y);
  6242. if (rmsflg) { /* REMOTE SET RECEIVE TIMEOUT */
  6243. sstate = setgen('S', "402", ckitoa(z), "");
  6244. return((int) sstate);
  6245. } else { /* SET RECEIVE TIMEOUT */
  6246. pkttim = z; /* Value to put in my negotiation */
  6247. } /* packet for other Kermit to use */
  6248. } else { /* SET SEND TIMEOUT */
  6249. #ifdef CK_TIMERS
  6250. extern int rttflg, mintime, maxtime;
  6251. int tmin = 0, tmax = 0;
  6252. #endif /* CK_TIMERS */
  6253. y = cmnum("Packet timeout interval",ckitoa(DMYTIM),10,&x,xxstring);
  6254. if (y == -3) { /* They cancelled a previous */
  6255. x = DMYTIM; /* SET SEND command, so restore */
  6256. timef = 0; /* and turn off the override flag */
  6257. y = cmcfm();
  6258. }
  6259. #ifdef CK_TIMERS
  6260. if (y < 0) return(y);
  6261. if (x < 0) {
  6262. printf("?Out of range - %d\n",x);
  6263. return(-9);
  6264. }
  6265. if ((z = cmkey(timotab,2,"","dynamic",xxstring)) < 0) return(z);
  6266. if (z) {
  6267. if ((y = cmnum("Minimum timeout to allow",
  6268. "1",10,&tmin,xxstring)) < 0)
  6269. return(y);
  6270. if (tmin < 1) {
  6271. printf("?Out of range - %d\n",tmin);
  6272. return(-9);
  6273. }
  6274. if ((y = cmnum("Maximum timeout to allow",
  6275. "0",10,&tmax,xxstring)) < 0)
  6276. return(y);
  6277. /* 0 means let Kermit choose, < 0 means no maximum */
  6278. }
  6279. if ((y = cmcfm()) < 0)
  6280. return(y);
  6281. rttflg = z; /* Round-trip timer flag */
  6282. z = x;
  6283. #else
  6284. if ((y = setnum(&z,x,y,94)) < 0)
  6285. return(y);
  6286. #endif /* CK_TIMERS */
  6287. timef = 1; /* Turn on the override flag */
  6288. timint = rtimo = z; /* Override value for me to use */
  6289. #ifdef CK_TIMERS
  6290. if (rttflg) { /* Lower and upper bounds */
  6291. mintime = tmin;
  6292. maxtime = tmax;
  6293. }
  6294. #endif /* CK_TIMERS */
  6295. }
  6296. return(success = 1);
  6297. case XYFPATH: /* PATHNAMES */
  6298. if (xx == XYRECV) {
  6299. y = cmkey(rpathtab,nrpathtab,"","auto",xxstring);
  6300. } else {
  6301. y = cmkey(pathtab,npathtab,"","off",xxstring);
  6302. }
  6303. if (y < 0) return(y);
  6304. if ((x = cmcfm()) < 0) return(x);
  6305. if (xx == XYRECV) { /* SET RECEIVE PATHNAMES */
  6306. fnrpath = y;
  6307. ptab[protocol].fnrp = fnrpath;
  6308. } else { /* SET SEND PATHNAMES */
  6309. fnspath = y;
  6310. ptab[protocol].fnsp = fnspath;
  6311. }
  6312. return(success = 1); /* Note: 0 = ON, 1 = OFF */
  6313. /* In other words, ON = leave pathnames ON, OFF = take them off. */
  6314. case XYPAUS: /* SET SEND/RECEIVE PAUSE */
  6315. y = cmnum("Milliseconds to pause between packets","0",10,&x,xxstring);
  6316. if ((y = setnum(&z,x,y,15000)) < 0)
  6317. return(y);
  6318. pktpaus = z;
  6319. return(success = 1);
  6320. #ifdef CKXXCHAR /* SET SEND/RECEIVE IGNORE/DOUBLE */
  6321. case XYIGN:
  6322. case XYDBL: {
  6323. int i, zz;
  6324. short *p;
  6325. extern short dblt[];
  6326. extern int dblflag, ignflag;
  6327. /* Make space for a temporary copy of the ignore/double table */
  6328. zz = y;
  6329. #ifdef COMMENT
  6330. if (zz == XYIGN && xx == XYSEND) {
  6331. blah blah who cares
  6332. }
  6333. if (zz == XYDBL && xx == XYRECV) {
  6334. blah blah
  6335. }
  6336. #endif /* COMMENT */
  6337. p = (short *)malloc(256 * sizeof(short));
  6338. if (!p) {
  6339. printf("?Internal error - malloc failure\n");
  6340. return(-9);
  6341. }
  6342. for (i = 0; i < 256; i++) p[i] = dblt[i]; /* Copy current table */
  6343. while (1) { /* Collect a list of numbers */
  6344. #ifndef NOSPL
  6345. x_ifnum = 1; /* Turn off complaints from eval() */
  6346. #endif /* NOSPL */
  6347. if ((x = cmnum(zz == XYDBL ?
  6348. "Character to double" :
  6349. "Character to ignore",
  6350. "",10,&y,xxstring
  6351. )) < 0) {
  6352. #ifndef NOSPL
  6353. x_ifnum = 0;
  6354. #endif /* NOSPL */
  6355. if (x == -3) /* Done */
  6356. break;
  6357. if (x == -2) {
  6358. if (p) { free(p); p = NULL; }
  6359. debug(F110,"SET S/R DOUBLE/IGNORE atmbuf",atmbuf,0);
  6360. if (!ckstrcmp(atmbuf,"none",4,0) ||
  6361. !ckstrcmp(atmbuf,"non",3,0) ||
  6362. !ckstrcmp(atmbuf,"no",2,0) ||
  6363. !ckstrcmp(atmbuf,"n",1,0)) {
  6364. if ((x = cmcfm()) < 0) /* Get confirmation */
  6365. return(x);
  6366. for (y = 0; y < 256; y++)
  6367. dblt[y] &= (zz == XYDBL) ? 1 : 2;
  6368. if (zz == XYDBL) dblflag = 0;
  6369. if (zz == XYIGN) ignflag = 0;
  6370. return(success = 1);
  6371. } else {
  6372. printf(
  6373. "?Please specify a number or the word NONE\n");
  6374. return(-9);
  6375. }
  6376. } else {
  6377. free(p);
  6378. p = NULL;
  6379. return(x);
  6380. }
  6381. }
  6382. #ifndef NOSPL
  6383. x_ifnum = 0;
  6384. #endif /* NOSPL */
  6385. if (y < 0 || y > 255) {
  6386. printf("?Please enter a character code in range 0-255\n");
  6387. free(p);
  6388. p = NULL;
  6389. return(-9);
  6390. }
  6391. p[y] |= (zz == XYDBL) ? 2 : 1;
  6392. if (zz == XYDBL) dblflag = 1;
  6393. if (zz == XYIGN) ignflag = 1;
  6394. } /* End of while loop */
  6395. if ((x = cmcfm()) < 0) return(x);
  6396. /*
  6397. Get here only if they have made no mistakes. Copy temporary table back to
  6398. permanent one, then free temporary table and return successfully.
  6399. */
  6400. if (p) {
  6401. for (i = 0; i < 256; i++) dblt[i] = p[i];
  6402. free(p);
  6403. p = NULL;
  6404. }
  6405. return(success = 1);
  6406. }
  6407. #endif /* CKXXCHAR */
  6408. #ifdef PIPESEND
  6409. case XYFLTR: { /* SET { SEND, RECEIVE } FILTER */
  6410. if ((y = cmtxt((xx == XYSEND) ?
  6411. "Filter program for sending files -\n\
  6412. use \\v(filename) to substitute filename" :
  6413. "Filter program for receiving files -\n\
  6414. use \\v(filename) to substitute filename",
  6415. "",&s,NULL)) < 0)
  6416. return(y);
  6417. if (!*s) { /* Removing a filter... */
  6418. if (xx == XYSEND && sndfilter) {
  6419. makestr(&g_sfilter,NULL);
  6420. makestr(&sndfilter,NULL);
  6421. } else if (rcvfilter) {
  6422. makestr(&g_rfilter,NULL);
  6423. makestr(&rcvfilter,NULL);
  6424. }
  6425. return(success = 1);
  6426. } /* Adding a filter... */
  6427. s = brstrip(s); /* Strip any braces */
  6428. y = strlen(s);
  6429. if (xx == XYSEND) { /* For SEND filter... */
  6430. for (x = 0; x < y; x++) { /* make sure they included "\v(...)" */
  6431. if (s[x] != '\\') continue;
  6432. if (s[x+1] == 'v') break;
  6433. }
  6434. if (x == y) {
  6435. printf(
  6436. "?Filter must contain a replacement variable for filename.\n"
  6437. );
  6438. return(-9);
  6439. }
  6440. }
  6441. if (xx == XYSEND) {
  6442. makestr(&sndfilter,s);
  6443. makestr(&g_sfilter,s);
  6444. } else {
  6445. makestr(&rcvfilter,s);
  6446. makestr(&g_rfilter,s);
  6447. }
  6448. return(success = 1);
  6449. }
  6450. #endif /* PIPESEND */
  6451. case XYINIL:
  6452. y = cmnum("Max length for protocol init string","-1",10,&x,xxstring);
  6453. if ((y = setnum(&z,x,y,-1)) < 0)
  6454. return(y);
  6455. if (xx == XYSEND)
  6456. sprmlen = z;
  6457. else
  6458. rprmlen = z;
  6459. return(success = 1);
  6460. case 993: {
  6461. extern int sendipkts;
  6462. if (xx == XYSEND) {
  6463. if ((x = seton(&sendipkts)) < 0)
  6464. return(x);
  6465. }
  6466. return(1);
  6467. }
  6468. #ifdef CK_PERMS
  6469. case 994:
  6470. switch(xx) {
  6471. case XYSEND:
  6472. if ((x = seton(&atlpro)) < 0) return(x);
  6473. atgpro = atlpro;
  6474. return(1);
  6475. case XYRECV:
  6476. if ((x = seton(&atlpri)) < 0) return(x);
  6477. atgpri = atlpri;
  6478. return(1);
  6479. default:
  6480. return(-2);
  6481. }
  6482. #endif /* CK_PERMS */
  6483. #ifndef NOCSETS
  6484. case XYCSET: { /* CHARACTER-SET-SELECTION */
  6485. extern struct keytab xfrmtab[];
  6486. extern int r_cset, s_cset;
  6487. if ((y = cmkey(xfrmtab,2,"","automatic",xxstring)) < 0)
  6488. return(y);
  6489. if ((x = cmcfm()) < 0)
  6490. return(x);
  6491. if (xx == XYSEND)
  6492. s_cset = y;
  6493. else
  6494. r_cset = y;
  6495. return(success = 1);
  6496. }
  6497. #endif /* NOCSETS */
  6498. case XYBUP:
  6499. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0)
  6500. return(y);
  6501. if ((x = cmcfm()) < 0) return(x);
  6502. if (xx == XYSEND) {
  6503. extern int skipbup;
  6504. skipbup = (y == 0) ? 1 : 0;
  6505. return(success = 1);
  6506. } else {
  6507. printf(
  6508. "?Please use SET FILE COLLISION to choose the desired action\n");
  6509. return(-9);
  6510. }
  6511. case XYMOVE:
  6512. #ifdef COMMENT
  6513. y = cmdir("Directory to move file(s) to after successful transfer",
  6514. "",&s,xxstring);
  6515. #else
  6516. y = cmtxt("Directory to move file(s) to after successful transfer",
  6517. "",&s,xxstring);
  6518. #endif /* COMMENT */
  6519. if (y < 0 && y != -3)
  6520. return(y);
  6521. ckstrncpy(line,s,LINBUFSIZ);
  6522. s = brstrip(line);
  6523. #ifdef COMMENT
  6524. /* Only needed for cmdir() */
  6525. if ((x = cmcfm()) < 0)
  6526. return(x);
  6527. #endif /* COMMENT */
  6528. /* Check directory existence if absolute */
  6529. /* THIS MEANS IT CAN'T INCLUDE ANY DEFERRED VARIABLES! */
  6530. if (s) if (*s) {
  6531. if (isabsolute(s) && !isdir(s)) {
  6532. printf("?Directory does not exist - %s\n",s);
  6533. return(-9);
  6534. }
  6535. }
  6536. if (xx == XYSEND) {
  6537. if (*s) {
  6538. #ifdef COMMENT
  6539. /* Allow it to be relative */
  6540. zfnqfp(s,LINBUFSIZ,line);
  6541. #endif /* COMMENT */
  6542. makestr(&snd_move,line);
  6543. makestr(&g_snd_move,line);
  6544. } else {
  6545. makestr(&snd_move,NULL);
  6546. makestr(&g_snd_move,NULL);
  6547. }
  6548. } else {
  6549. if (*s) {
  6550. #ifdef COMMENT
  6551. /* Allow it to be relative */
  6552. zfnqfp(s,LINBUFSIZ,line);
  6553. #endif /* COMMENT */
  6554. makestr(&rcv_move,line);
  6555. makestr(&g_rcv_move,line);
  6556. } else {
  6557. makestr(&rcv_move,NULL);
  6558. makestr(&g_rcv_move,NULL);
  6559. }
  6560. }
  6561. return(success = 1);
  6562. case XYRENAME:
  6563. y = cmtxt("Template to rename file(s) to after successful transfer",
  6564. "",&s,NULL); /* NOTE: no xxstring */
  6565. if (y < 0 && y != -3) /* Evaluation is deferred */
  6566. return(y);
  6567. ckstrncpy(line,s,LINBUFSIZ);
  6568. s = brstrip(line);
  6569. if ((x = cmcfm()) < 0)
  6570. return(x);
  6571. if (xx == XYSEND) {
  6572. if (*s) {
  6573. makestr(&snd_rename,s);
  6574. makestr(&g_snd_rename,s);
  6575. } else {
  6576. makestr(&snd_rename,NULL);
  6577. makestr(&g_snd_rename,NULL);
  6578. }
  6579. } else {
  6580. if (*s) {
  6581. makestr(&rcv_rename,s);
  6582. makestr(&g_rcv_rename,s);
  6583. } else {
  6584. makestr(&rcv_rename,NULL);
  6585. makestr(&g_rcv_rename,NULL);
  6586. }
  6587. }
  6588. return(success = 1);
  6589. #ifdef VMS
  6590. case 887: /* VERSION-NUMBERS */
  6591. if (xx == XYSEND) {
  6592. extern int vmssversions;
  6593. return(seton(&vmssversions));
  6594. } else {
  6595. extern int vmsrversions;
  6596. return(seton(&vmsrversions));
  6597. }
  6598. #endif /* VMS */
  6599. default:
  6600. return(-2);
  6601. } /* End of SET SEND/RECEIVE... */
  6602. }
  6603. #endif /* NOXFER */
  6604. #ifndef NOXMIT
  6605. int
  6606. setxmit() {
  6607. if ((y = cmkey(xmitab,nxmit,"","",xxstring)) < 0) return(y);
  6608. switch (y) {
  6609. case XMITE: /* EOF */
  6610. y = cmtxt("Characters to send at end of file,\n\
  6611. Use backslash codes for control characters","",&s,xxstring);
  6612. if (y < 0) return(y);
  6613. if ((int)strlen(s) > XMBUFL) {
  6614. printf("?Too many characters, %d maximum\n",XMBUFL);
  6615. return(-2);
  6616. }
  6617. ckstrncpy(xmitbuf,s,XMBUFL);
  6618. return(success = 1);
  6619. case XMITF: /* Fill */
  6620. y = cmnum("Numeric code for blank-line fill character","0",10,&x,
  6621. xxstring);
  6622. if ((y = setnum(&z,x,y,127)) < 0) return(y);
  6623. xmitf = z;
  6624. return(success = 1);
  6625. case XMITL: /* Linefeed */
  6626. return(seton(&xmitl));
  6627. case XMITS: /* Locking-Shift */
  6628. return(seton(&xmits));
  6629. case XMITP: /* Prompt */
  6630. y = cmnum("Numeric code for host's prompt character, 0 for none",
  6631. "10",10,&x,xxstring);
  6632. if ((y = setnum(&z,x,y,127)) < 0) return(y);
  6633. xmitp = z;
  6634. return(success = 1);
  6635. case XMITX: /* Echo */
  6636. return(seton(&xmitx));
  6637. case XMITW: /* Pause */
  6638. y = cmnum("Number of milliseconds to pause between binary characters\n\
  6639. or text lines during transmission","0",10,&x,xxstring);
  6640. if ((y = setnum(&z,x,y,1000)) < 0) return(y);
  6641. xmitw = z;
  6642. return(success = 1);
  6643. case XMITT: /* Timeout */
  6644. y = cmnum("Seconds to wait for each character to echo",
  6645. "1",10,&x,xxstring);
  6646. if ((y = setnum(&z,x,y,1000)) < 0) return(y);
  6647. xmitt = z;
  6648. return(success = 1);
  6649. default:
  6650. return(-2);
  6651. }
  6652. }
  6653. #endif /* NOXMIT */
  6654. #ifndef NOXFER
  6655. /* D O R M T -- Do a remote command */
  6656. VOID
  6657. rmsg() {
  6658. if (pflag && !quiet && fdispla != XYFD_N)
  6659. printf(
  6660. #ifdef CK_NEED_SIG
  6661. " Type your escape character, %s, followed by X or E to cancel.\n",
  6662. dbchr(escape)
  6663. #else
  6664. " Press the X or E key to cancel.\n"
  6665. #endif /* CK_NEED_SIG */
  6666. );
  6667. }
  6668. static int xzcmd = 0; /* Global copy of REMOTE cmd index */
  6669. /* R E M C F M -- Confirm a REMOTE command */
  6670. /*
  6671. Like cmcfm(), but allows for a redirection indicator on the end,
  6672. like "> filename" or "| command". Returns what cmcfm() would have
  6673. returned: -1 if reparse needed, etc etc blah blah. On success,
  6674. returns 1 with:
  6675. char * remdest containing the name of the file or command.
  6676. int remfile set to 1 if there is to be any redirection.
  6677. int remappd set to 1 if output file is to be appended to.
  6678. int rempipe set to 1 if remdest is a command, 0 if it is a file.
  6679. */
  6680. static int
  6681. remcfm() {
  6682. int x = 0;
  6683. char *s;
  6684. char *helptxt = "> filename, | command,\n\
  6685. or type carriage return to confirm the command";
  6686. char c;
  6687. remfile = 0;
  6688. rempipe = 0;
  6689. remappd = 0;
  6690. if ((x = cmtxt(helptxt,"",&s,xxstring)) < 0) {
  6691. return(x);
  6692. }
  6693. if (remdest) {
  6694. free(remdest);
  6695. remdest = NULL;
  6696. }
  6697. debug(F101,"remcfm local","",local);
  6698. debug(F110,"remcfm s",s,0);
  6699. debug(F101,"remcfm cmd","",xzcmd);
  6700. /*
  6701. This check was added in C-Kermit 6.0 or 7.0 but it turns out to be
  6702. unhelpful in the situation where the remote is running a script that sends
  6703. REMOTE commands to the local workstation. What happens is, the local
  6704. server executes the command and sends the result back as screen text, which
  6705. is indicated by using an X packet instead of an F packet as the file
  6706. header. There are two parts to this: executing the command under control
  6707. of the remote Kermit, which is desirable (and in fact some big applications
  6708. depend on it, and therefore never installed any new C-Kermit versions after
  6709. 5A), and displaying the result. Commenting out the check allows the
  6710. command to be executed, but the result is still sent back to the remote in
  6711. a file transfer, where it vanishes into the ether. Actually it's on the
  6712. communication connection, mixed in with the packets. Pretty amazing that
  6713. the file transfer still works, right?
  6714. */
  6715. #ifdef COMMENT
  6716. if (!*s) { /* No redirection indicator */
  6717. if (!local &&
  6718. (xzcmd == XZDIR || xzcmd == XZTYP ||
  6719. xzcmd == XZXIT || xzcmd == XZSPA ||
  6720. xzcmd == XZHLP || xzcmd == XZPWD ||
  6721. xzcmd == XZLGI || xzcmd == XZLGO ||
  6722. xzcmd == XZWHO || xzcmd == XZHOS)) {
  6723. printf("?\"%s\" has no effect in remote mode\n",cmdbuf);
  6724. return(-9);
  6725. } else
  6726. return(1);
  6727. }
  6728. #endif /* COMMENT */
  6729. if (!s) s = ""; /* 2014-11-03 */
  6730. if (!*s) return(1); /* 2014-11-03 */
  6731. c = *s; /* We have something */
  6732. if (c != '>' && c != '|') { /* Is it > or | ? */
  6733. printf("?Not confirmed\n"); /* No */
  6734. return(-9);
  6735. }
  6736. s++; /* See what follows */
  6737. if (c == '>' && *s == '>') { /* Allow for ">>" too */
  6738. s++;
  6739. remappd = 1; /* Append to output file */
  6740. }
  6741. while (*s == SP || *s == HT) s++; /* Strip intervening whitespace */
  6742. if (!*s) {
  6743. printf("?%s missing\n", c == '>' ? "Filename" : "Command");
  6744. return(-9);
  6745. }
  6746. if (c == '>' && zchko(s) < 0) { /* Check accessibility */
  6747. printf("?Access denied - %s\n", s);
  6748. return(-9);
  6749. }
  6750. remfile = 1; /* Set global results */
  6751. rempipe = (c == '|');
  6752. if (rempipe
  6753. #ifndef NOPUSH
  6754. && nopush
  6755. #endif /* NOPUSH */
  6756. ) {
  6757. printf("?Sorry, access to external commands is disabled.\n");
  6758. return(-9);
  6759. }
  6760. makestr(&remdest,s);
  6761. #ifndef NODEBUG
  6762. if (deblog) {
  6763. debug(F101,"remcfm remfile","",remfile);
  6764. debug(F101,"remcfm remappd","",remappd);
  6765. debug(F101,"remcfm rempipe","",rempipe);
  6766. debug(F110,"remcfm remdest",remdest, 0);
  6767. }
  6768. #endif /* NODEBUG */
  6769. return(1);
  6770. }
  6771. /* R E M T X T -- Like remcfm()... */
  6772. /*
  6773. ... but for REMOTE commands that end with cmtxt().
  6774. Here we must decipher braces to discover whether the trailing
  6775. redirection indicator is intended for local use, or to be sent out
  6776. to the server, as in:
  6777. remote host blah blah > file This end
  6778. remote host { blah blah } > file This end
  6779. remote host { blah blah > file } That end
  6780. remote host { blah blah > file } > file Both ends
  6781. Pipes too:
  6782. remote host blah blah | cmd This end
  6783. remote host { blah blah } | cmd This end
  6784. remote host { blah blah | cmd } That end
  6785. remote host { blah blah | cmd } | cmd Both ends
  6786. Or both:
  6787. remote host blah blah | cmd > file This end, etc etc...
  6788. Note: this really only makes sense for REMOTE HOST, but why be picky?
  6789. Call after calling cmtxt(), with pointer to string that cmtxt() parsed,
  6790. as in "remtxt(&s);".
  6791. Returns:
  6792. 1 on success with braces & redirection things removed & pointer updated,
  6793. -9 on failure (bad indirection), after printing error message.
  6794. */
  6795. int
  6796. remtxt(p) char ** p; {
  6797. int i, x, bpos, ppos;
  6798. char c, *s, *q;
  6799. remfile = 0; /* Initialize global results */
  6800. rempipe = 0;
  6801. remappd = 0;
  6802. if (remdest) {
  6803. free(remdest);
  6804. remdest = NULL;
  6805. }
  6806. s = *p;
  6807. if (!s) /* No redirection indicator */
  6808. s = "";
  6809. #ifdef COMMENT
  6810. if (!*s) { /* Ditto */
  6811. if (!local &&
  6812. (xzcmd == XZDIR || xzcmd == XZTYP ||
  6813. xzcmd == XZXIT || xzcmd == XZSPA ||
  6814. xzcmd == XZHLP || xzcmd == XZPWD ||
  6815. xzcmd == XZLGI || xzcmd == XZLGO ||
  6816. xzcmd == XZWHO || xzcmd == XZHOS)) {
  6817. printf("?\"%s\" has no effect in remote mode\n",cmdbuf);
  6818. if (hints) {
  6819. printf("Hint: Try again with an output redirector.\n");
  6820. }
  6821. return(-9);
  6822. } else
  6823. return(1);
  6824. }
  6825. #endif /* COMMENT */
  6826. bpos = -1; /* Position of > (bracket) */
  6827. ppos = -1; /* Position of | (pipe) */
  6828. x = strlen(s); /* Length of cmtxt() string */
  6829. for (i = x-1; i >= 0; i--) { /* Search right to left. */
  6830. c = s[i];
  6831. if (c == '}') /* Break on first right brace */
  6832. break; /* Don't look at contents of braces */
  6833. else if (c == '>') /* Record position of > */
  6834. bpos = i;
  6835. else if (c == '|') /* and of | */
  6836. ppos = i;
  6837. }
  6838. if (bpos < 0 && ppos < 0) { /* No redirectors. */
  6839. #ifdef COMMENT
  6840. if (!local &&
  6841. (xzcmd == XZDIR || xzcmd == XZTYP ||
  6842. xzcmd == XZXIT || xzcmd == XZSPA ||
  6843. xzcmd == XZHLP || xzcmd == XZPWD ||
  6844. xzcmd == XZLGI || xzcmd == XZLGO ||
  6845. xzcmd == XZWHO || xzcmd == XZHOS)) {
  6846. printf("?\"%s\" has no effect in remote mode\n",cmdbuf);
  6847. if (hints) {
  6848. printf("Hint: Try again with an output redirector.\n");
  6849. }
  6850. return(-9);
  6851. }
  6852. #endif /* COMMENT */
  6853. s = brstrip(s); /* Remove outer braces if any. */
  6854. *p = s; /* Point to result */
  6855. return(1); /* and return. */
  6856. }
  6857. remfile = 1; /* It's | or > */
  6858. i = -1; /* Get leftmost symbol */
  6859. if (bpos > -1) /* Bracket */
  6860. i = bpos;
  6861. if (ppos > -1 && (ppos < bpos || bpos < 0)) { /* or pipe */
  6862. i = ppos;
  6863. rempipe = 1;
  6864. }
  6865. if (rempipe
  6866. #ifndef NOPUSH
  6867. && nopush
  6868. #endif /* NOPUSH */
  6869. ) {
  6870. printf("?Sorry, access to external commands is disabled.\n");
  6871. return(-9);
  6872. }
  6873. c = s[i]; /* Copy of symbol */
  6874. if (c == '>' && s[i+1] == '>') /* ">>" for append? */
  6875. remappd = 1; /* It's not just a flag it's a number */
  6876. q = s + i + 1 + remappd; /* Point past symbol in string */
  6877. while (*q == SP || *q == HT) q++; /* and any intervening whitespace */
  6878. if (!*q) {
  6879. printf("?%s missing\n", c == '>' ? "Filename" : "Command");
  6880. return(-9);
  6881. }
  6882. if (c == '>' && zchko(q) < 0) { /* (Doesn't work for | cmd > file) */
  6883. printf("?Access denied - %s\n", q);
  6884. return(-9);
  6885. }
  6886. makestr(&remdest,q); /* Create the destination string */
  6887. q = s + i - 1; /* Point before symbol */
  6888. while (q > s && (*q == SP || *q == HT)) /* Strip trailing whitespace */
  6889. q--;
  6890. *(q+1) = NUL; /* Terminate the string. */
  6891. s = brstrip(s); /* Remove any braces */
  6892. *p = s; /* Set return value */
  6893. #ifndef NODEBUG
  6894. if (deblog) {
  6895. debug(F101,"remtxt remfile","",remfile);
  6896. debug(F101,"remtxt remappd","",remappd);
  6897. debug(F101,"remtxt rempipe","",rempipe);
  6898. debug(F110,"remtxt remdest",remdest, 0);
  6899. debug(F110,"remtxt command",s,0);
  6900. }
  6901. #endif /* NODEBUG */
  6902. return(1);
  6903. }
  6904. int
  6905. plogin(xx) int xx; {
  6906. char *p1 = NULL, *p2 = NULL, *p3 = NULL;
  6907. int psaved = 0, rc = 0;
  6908. #ifdef CK_RECALL
  6909. extern int on_recall; /* around Password prompting */
  6910. #endif /* CK_RECALL */
  6911. debug(F101,"plogin local","",local);
  6912. if (!local || (network && ttchk() < 0)) {
  6913. printf("?No connection\n");
  6914. return(-9);
  6915. }
  6916. if ((x = cmfld("User ID","",&s,xxstring)) < 0) { /* Get User ID */
  6917. if (x != -3) return(x);
  6918. }
  6919. y = strlen(s);
  6920. if (y > 0) {
  6921. if ((p1 = malloc(y + 1)) == NULL) {
  6922. printf("?Internal error: malloc\n");
  6923. rc = -9;
  6924. goto XZXLGI;
  6925. } else
  6926. strcpy(p1,s); /* safe */
  6927. if ((rc = cmfld("Password","",&s,xxstring)) < 0)
  6928. if (rc != -3) goto XZXLGI;
  6929. y = strlen(s);
  6930. if (y > 0) {
  6931. if ((p2 = malloc(y + 1)) == NULL) {
  6932. printf("?Internal error: malloc\n");
  6933. rc = -9;
  6934. goto XZXLGI;
  6935. } else
  6936. strcpy(p2,s); /* safe */
  6937. if ((rc = cmfld("Account","",&s,xxstring)) < 0)
  6938. if (rc != -3) goto XZXLGI;
  6939. y = strlen(s);
  6940. if (y > 0) {
  6941. if ((p3 = malloc(y + 1)) == NULL) {
  6942. printf("?Internal error: malloc\n");
  6943. rc = -9;
  6944. goto XZXLGI;
  6945. } else
  6946. strcpy(p3,s); /* safe */
  6947. }
  6948. }
  6949. }
  6950. if ((rc = remtxt(&s)) < 0) /* Confirm & handle redirectors */
  6951. goto XZXLGI;
  6952. if (!p1) { /* No Userid specified... */
  6953. debok = 0; /* Don't log this */
  6954. /* Prompt for username, password, and account */
  6955. #ifdef CK_RECALL
  6956. on_recall = 0;
  6957. #endif /* CK_RECALL */
  6958. cmsavp(psave,PROMPTL); /* Save old prompt */
  6959. psaved = 1;
  6960. debug(F110,"REMOTE LOGIN saved",psave,0);
  6961. cmsetp("Username: "); /* Make new prompt */
  6962. concb((char)escape); /* Put console in cbreak mode */
  6963. cmini(1);
  6964. prompt(xxstring);
  6965. rc = -9;
  6966. for (x = -1; x < 0; ) { /* Prompt till they answer */
  6967. cmres(); /* Reset the parser */
  6968. x = cmtxt("","",&s,NULL); /* Get a literal line of text */
  6969. }
  6970. y = strlen(s);
  6971. if (y < 1) {
  6972. printf("?Canceled\n");
  6973. goto XZXLGI;
  6974. }
  6975. if ((p1 = malloc(y + 1)) == NULL) {
  6976. printf("?Internal error: malloc\n");
  6977. goto XZXLGI;
  6978. } else
  6979. strcpy(p1,s); /* safe */
  6980. cmsetp("Password: "); /* Make new prompt */
  6981. concb((char)escape); /* Put console in cbreak mode */
  6982. cmini(0); /* No echo */
  6983. prompt(xxstring);
  6984. debok = 0;
  6985. for (x = -1; x < 0 && x != -3; ) { /* Get answer */
  6986. cmres(); /* Reset the parser */
  6987. x = cmtxt("","",&s,NULL); /* Get literal line of text */
  6988. }
  6989. if ((p2 = malloc((int)strlen(s) + 1)) == NULL) {
  6990. printf("?Internal error: malloc\n");
  6991. goto XZXLGI;
  6992. } else
  6993. strcpy(p2,s); /* safe */
  6994. printf("\r\n");
  6995. if ((rc = cmcfm()) < 0)
  6996. goto XZXLGI;
  6997. }
  6998. sstate = setgen('I',p1,p2,p3); /* Get here with at least user ID */
  6999. rc = 0;
  7000. XZXLGI: /* Common exit point */
  7001. if (psaved)
  7002. cmsetp(psave); /* Restore original prompt */
  7003. if (p3) { free(p3); p3 = NULL; } /* Free malloc'd storage */
  7004. if (p2) { free(p2); p2 = NULL; }
  7005. if (p1) { free(p1); p1 = NULL; }
  7006. if (rc > -1) {
  7007. if (local && rc > -1) /* If local, flush tty input buffer */
  7008. ttflui();
  7009. }
  7010. return(rc);
  7011. }
  7012. #ifdef OS2
  7013. #ifndef NOLOCAL
  7014. int
  7015. dormt(xx) int xx; {
  7016. int rc = 0;
  7017. extern int term_io;
  7018. int term_io_sav = term_io;
  7019. #ifdef NEWFTP
  7020. extern int ftpget, ftpisopen();
  7021. if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  7022. return(doftprmt(xx,0));
  7023. #endif /* NEWFTP */
  7024. term_io = 0;
  7025. rc = xxdormt(xx);
  7026. term_io = term_io_sav;
  7027. return rc;
  7028. }
  7029. int
  7030. xxdormt(xx) int xx;
  7031. #else /* NOLOCAL */
  7032. int
  7033. dormt(xx) int xx;
  7034. #endif /* NOLOCAL */
  7035. #else /* OS2 */
  7036. int
  7037. dormt(xx) int xx;
  7038. #endif /* OS2 */
  7039. { /* REMOTE commands */
  7040. int x, y, retcode;
  7041. char *s, sbuf[50], *s2;
  7042. #ifdef NEWFTP
  7043. extern int ftpget, ftpisopen();
  7044. if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  7045. return(doftprmt(xx,0));
  7046. #endif /* NEWFTP */
  7047. remfile = 0; /* Clear these */
  7048. rempipe = 0;
  7049. remappd = 0;
  7050. debug(F101,"XXX xxdormt xx","",xx);
  7051. if (xx < 0) return(xx); /* REMOTE what? */
  7052. xzcmd = xx; /* Make global copy of arg */
  7053. if (xx == XZSET) { /* REMOTE SET */
  7054. if ((y = cmkey(rmstab,nrms,"","",xxstring)) < 0) {
  7055. if (y == -3) {
  7056. printf("?Parameter name required\n");
  7057. return(-9);
  7058. } else return(y);
  7059. }
  7060. return(doprm(y,1));
  7061. }
  7062. switch (xx) { /* Others... */
  7063. case XZCDU:
  7064. if ((x = cmcfm()) < 0) return(x);
  7065. printf("?Sorry, REMOTE CDUP not supported yet\n");
  7066. return(-9);
  7067. case XZCWD: /* CWD (CD) */
  7068. if ((x = cmtxt("Remote directory name","",&s,xxstring)) < 0)
  7069. return(x);
  7070. if ((x = remtxt(&s)) < 0)
  7071. return(x);
  7072. debug(F111,"XZCWD: ",s,x);
  7073. *sbuf = NUL;
  7074. s2 = sbuf;
  7075. /*
  7076. The following is commented out because since the disappearance of the
  7077. DECSYSTEM-20 from the planet, no known computer requires a password for
  7078. changing directory.
  7079. */
  7080. #ifdef DIRPWDPR
  7081. if (*s != NUL) { /* If directory name given, */
  7082. /* get password on separate line. */
  7083. if (tlevel > -1) { /* From take file... */
  7084. if (fgets(sbuf,50,tfile[tlevel]) == NULL)
  7085. fatal("take file ends prematurely in 'remote cwd'");
  7086. debug(F110," pswd from take file",s2,0);
  7087. for (x = (int)strlen(sbuf);
  7088. x > 0 && (sbuf[x-1] == NL || sbuf[x-1] == CR);
  7089. x--)
  7090. sbuf[x-1] = '\0';
  7091. } else { /* From terminal... */
  7092. printf(" Password: "); /* get a password */
  7093. #ifdef IKSD
  7094. if (!local && inserver) {
  7095. x = coninc(0);
  7096. } else
  7097. #endif /* IKSD */
  7098. #ifdef OS2
  7099. x = is_a_tty(0) ? coninc(0) : /* with no echo ... */
  7100. getchar();
  7101. #else /* OS2 */
  7102. x = getchar();
  7103. #endif /* OS2 */
  7104. while ((x != NL) && (x != CR)) {
  7105. if ((x &= 0177) == '?') {
  7106. printf("? Password of remote directory\n Password: ");
  7107. s2 = sbuf;
  7108. *sbuf = NUL;
  7109. } else if (x == ESC) /* Mini command line editor... */
  7110. bleep(BP_WARN);
  7111. else if (x == BS || x == 0177)
  7112. s2--;
  7113. else if (x == 025) { /* Ctrl-U */
  7114. s2 = sbuf;
  7115. *sbuf = NUL;
  7116. } else
  7117. *s2++ = x;
  7118. /* Get the next character */
  7119. #ifdef IKSD
  7120. if (!local && inserver) {
  7121. x = coninc(0);
  7122. } else
  7123. #endif /* IKSD */
  7124. #ifdef OS2
  7125. x = is_a_tty(0) ? coninc(0) : /* with no echo ... */
  7126. getchar();
  7127. #else /* OS2 */
  7128. x = getchar();
  7129. #endif /* OS2 */
  7130. }
  7131. *s2 = NUL;
  7132. putchar('\n');
  7133. }
  7134. s2 = sbuf;
  7135. } else s2 = "";
  7136. #endif /* DIRPWDPR */
  7137. debug(F110," password",s2,0);
  7138. rcdactive = 1;
  7139. sstate = setgen('C',s,s2,"");
  7140. retcode = 0;
  7141. break;
  7142. case XZDEL: /* Delete */
  7143. if ((x = cmtxt("Name of remote file(s) to delete",
  7144. "",&s,xxstring)) < 0) {
  7145. if (x == -3) {
  7146. printf("?Name of remote file(s) required\n");
  7147. return(-9);
  7148. } else return(x);
  7149. }
  7150. if ((x = remtxt(&s)) < 0)
  7151. return(x);
  7152. if (local) ttflui(); /* If local, flush tty input buffer */
  7153. retcode = sstate = rfilop(s,'E');
  7154. break;
  7155. case XZDIR: /* Directory */
  7156. if ((x = cmtxt("Remote directory or file specification","",&s,
  7157. xxstring)) < 0)
  7158. return(x);
  7159. if ((x = remtxt(&s)) < 0)
  7160. return(x);
  7161. if (local) ttflui(); /* If local, flush tty input buffer */
  7162. rmsg();
  7163. retcode = sstate = setgen('D',s,"","");
  7164. break;
  7165. case XZHLP: /* Help */
  7166. if ((x = remcfm()) < 0) return(x);
  7167. sstate = setgen('H',"","","");
  7168. retcode = 0;
  7169. break;
  7170. case XZHOS: /* Host */
  7171. if ((x = cmtxt("Command for remote system","",&s,xxstring)) < 0)
  7172. return(x);
  7173. if ((x = remtxt(&s)) < 0)
  7174. return(x);
  7175. if ((y = (int)strlen(s)) < 1)
  7176. return(x);
  7177. ckstrncpy(line,s,LINBUFSIZ);
  7178. cmarg = line;
  7179. rmsg();
  7180. retcode = sstate = 'c';
  7181. break;
  7182. #ifndef NOFRILLS
  7183. case XZKER:
  7184. if ((x = cmtxt("Command for remote Kermit","",&s,xxstring)) < 0)
  7185. return(x);
  7186. if ((x = remtxt(&s)) < 0)
  7187. return(x);
  7188. if ((int)strlen(s) < 1) {
  7189. if (x == -3) {
  7190. printf("?Remote Kermit command required\n");
  7191. return(-9);
  7192. } else return(x);
  7193. }
  7194. ckstrncpy(line,s,LINBUFSIZ);
  7195. cmarg = line;
  7196. retcode = sstate = 'k';
  7197. rmsg();
  7198. break;
  7199. case XZLGI: /* Login */
  7200. rcdactive = 1; /* Suppress "Logged in" msg if quiet */
  7201. return(plogin(XXREM));
  7202. case XZLGO: { /* Logout */
  7203. extern int bye_active;
  7204. if ((x = remcfm()) < 0) return(x);
  7205. sstate = setgen('I',"","","");
  7206. retcode = 0;
  7207. bye_active = 1; /* Close connection when done */
  7208. break;
  7209. }
  7210. case XZPRI: /* Print */
  7211. if (!atdiso || !atcapr) { /* Disposition attribute off? */
  7212. printf("?Disposition Attribute is Off\n");
  7213. return(-2);
  7214. }
  7215. cmarg = "";
  7216. cmarg2 = "";
  7217. if ((x = cmifi("Local file(s) to print on remote printer","",&s,&y,
  7218. xxstring)) < 0) {
  7219. if (x == -3) {
  7220. printf("?Name of local file(s) required\n");
  7221. return(-9);
  7222. }
  7223. return(x);
  7224. }
  7225. ckstrncpy(line,s,LINBUFSIZ); /* Make a safe copy of filename */
  7226. *optbuf = NUL; /* Wipe out any old options */
  7227. if ((x = cmtxt("Options for remote print command","",&s,xxstring)) < 0)
  7228. return(x);
  7229. if ((x = remtxt(&s)) < 0)
  7230. return(x);
  7231. if ((int)strlen(optbuf) > 94) { /* Make sure this is legal */
  7232. printf("?Option string too long\n");
  7233. return(-9);
  7234. }
  7235. ckstrncpy(optbuf,s,OPTBUFLEN); /* Make a safe copy of options */
  7236. nfils = -1; /* Expand file list internally */
  7237. cmarg = line; /* Point to file list. */
  7238. rprintf = 1; /* REMOTE PRINT modifier for SEND */
  7239. sstate = 's'; /* Set start state to SEND */
  7240. if (local) displa = 1;
  7241. retcode = 0;
  7242. break;
  7243. #endif /* NOFRILLS */
  7244. case XZSPA: /* Space */
  7245. if ((x = cmtxt("Confirm, or remote directory name",
  7246. "",&s,xxstring)) < 0)
  7247. return(x);
  7248. if ((x = remtxt(&s)) < 0)
  7249. return(x);
  7250. retcode = sstate = setgen('U',s,"","");
  7251. break;
  7252. case XZMSG: /* Message */
  7253. if ((x = cmtxt("Short text message for server","",&s,xxstring)) < 0)
  7254. return(x);
  7255. if ((x = remtxt(&s)) < 0)
  7256. return(x);
  7257. retcode = sstate = setgen('M',s,"","");
  7258. break;
  7259. #ifndef NOFRILLS
  7260. case XZTYP: /* Type */
  7261. if ((x = cmtxt("Remote file specification","",&s,xxstring)) < 0)
  7262. return(x);
  7263. if ((int)strlen(s) < 1) {
  7264. printf("?Remote filename required\n");
  7265. return(-9);
  7266. }
  7267. if ((x = remtxt(&s)) < 0)
  7268. return(x);
  7269. rmsg();
  7270. retcode = sstate = rfilop(s,'T');
  7271. break;
  7272. #endif /* NOFRILLS */
  7273. #ifndef NOFRILLS
  7274. case XZWHO:
  7275. if ((x = cmtxt("Remote user name, or carriage return",
  7276. "",&s,xxstring)) < 0)
  7277. return(x);
  7278. if ((x = remtxt(&s)) < 0)
  7279. return(x);
  7280. retcode = sstate = setgen('W',s,"","");
  7281. break;
  7282. #endif /* NOFRILLS */
  7283. case XZPWD: /* PWD */
  7284. if ((x = remcfm()) < 0) return(x);
  7285. sstate = setgen('A',"","","");
  7286. retcode = 0;
  7287. break;
  7288. #ifndef NOSPL
  7289. case XZQUE: { /* Query */
  7290. char buf[2];
  7291. extern char querybuf[], * qbufp;
  7292. extern int qbufn;
  7293. if ((y = cmkey(vartyp,nvartyp,"","",xxstring)) < 0)
  7294. return(y);
  7295. if ((x = cmtxt(y == 'F' ? "Remote function invocation" :
  7296. ('K' ? "Remote variable name or function":
  7297. "Remote variable name"),
  7298. "",
  7299. &s,
  7300. (y == 'K') ? xxstring : NULL
  7301. )) < 0) /* Don't evaluate */
  7302. return(x);
  7303. if ((x = remtxt(&s)) < 0)
  7304. return(x);
  7305. query = 1; /* QUERY is active */
  7306. qbufp = querybuf; /* Initialize query response buffer */
  7307. qbufn = 0;
  7308. querybuf[0] = NUL;
  7309. buf[0] = (char) (y & 127);
  7310. buf[1] = NUL;
  7311. retcode = sstate = setgen('V',"Q",(char *)buf,s);
  7312. break;
  7313. }
  7314. case XZASG: { /* Assign */
  7315. char buf[VNAML];
  7316. if ((y = cmfld("Remote variable name","",&s,NULL)) < 0) /* No eval */
  7317. return(y);
  7318. if ((int)strlen(s) >= VNAML) {
  7319. printf("?Too long\n");
  7320. return(-9);
  7321. }
  7322. ckstrncpy(buf,s,VNAML);
  7323. if ((x = cmtxt("Assignment for remote variable",
  7324. "",&s,xxstring)) < 0) /* Evaluate this one */
  7325. return(x);
  7326. if ((x = remtxt(&s)) < 0)
  7327. return(x);
  7328. #ifdef COMMENT
  7329. /*
  7330. Server commands can't be long packets. In principle there's no reason
  7331. why they shouldn't be, except that we don't know at this point if the
  7332. server is capable of accepting long packets because we haven't started
  7333. the protocol yet. In practice, allowing a long packet here breaks a lot
  7334. of assumptions, causes buffer overruns and crashes, etc. To be fixed
  7335. later. (But since this is commented out, evidently I fixed it later...)
  7336. */
  7337. if ((int)strlen(s) > 85) { /* Allow for encoding expansion */
  7338. printf("?Sorry, value is too long - 85 characters max\n");
  7339. return(-9);
  7340. }
  7341. #endif /* COMMENT */
  7342. retcode = sstate = setgen('V',"S",(char *)buf,s);
  7343. break;
  7344. }
  7345. #endif /* NOSPL */
  7346. case XZCPY: { /* COPY */
  7347. char buf[TMPBUFSIZ];
  7348. buf[TMPBUFSIZ-1] = '\0';
  7349. if ((x = cmfld("Name of remote file to copy","",&s,xxstring)) < 0) {
  7350. if (x == -3) {
  7351. printf("?Name of remote file required\n");
  7352. return(-9);
  7353. }
  7354. else
  7355. return(x);
  7356. }
  7357. ckstrncpy(buf,s,TMPBUFSIZ);
  7358. if ((x = cmfld("Name of remote destination file or directory",
  7359. "",&s, xxstring)) < 0) {
  7360. if (x == -3) {
  7361. printf("?Name of remote file or directory required\n");
  7362. return(-9);
  7363. } else return(x);
  7364. }
  7365. ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  7366. if ((x = remcfm()) < 0)
  7367. return(x);
  7368. if (local) ttflui(); /* If local, flush tty input buffer */
  7369. retcode = sstate = setgen('K',buf,tmpbuf,"");
  7370. break;
  7371. }
  7372. case XZREN: { /* Rename */
  7373. char buf[TMPBUFSIZ];
  7374. buf[TMPBUFSIZ-1] = '\0';
  7375. if ((x = cmfld("Name of remote file to rename",
  7376. "",&s,xxstring)) < 0) {
  7377. if (x == -3) {
  7378. printf("?Name of remote file required\n");
  7379. return(-9);
  7380. } else return(x);
  7381. }
  7382. ckstrncpy(buf,s,TMPBUFSIZ);
  7383. if ((x = cmfld("New name of remote file","",&s, xxstring)) < 0) {
  7384. if (x == -3) {
  7385. printf("?Name of remote file required\n");
  7386. return(-9);
  7387. } else return(x);
  7388. }
  7389. ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  7390. if ((x = remcfm()) < 0)
  7391. return(x);
  7392. if (local) ttflui(); /* If local, flush device buffer */
  7393. retcode = sstate = setgen('R',buf,tmpbuf,"");
  7394. break;
  7395. }
  7396. case XZMKD: /* mkdir */
  7397. case XZRMD: /* rmdir */
  7398. if ((x = cmtxt((xx == XZMKD) ?
  7399. "Name of remote directory to create" :
  7400. "Name of remote directory to delete",
  7401. "",
  7402. &s,
  7403. xxstring
  7404. )) < 0) {
  7405. if (x == -3) {
  7406. printf("?Name required\n");
  7407. return(-9);
  7408. } else return(x);
  7409. }
  7410. if ((x = remtxt(&s)) < 0)
  7411. return(x);
  7412. if (local) ttflui(); /* If local, flush tty input buffer */
  7413. retcode = sstate = rfilop(s, (char)(xx == XZMKD ? 'm' : 'd'));
  7414. break;
  7415. case XZXIT: /* Exit */
  7416. if ((x = remcfm()) < 0) return(x);
  7417. sstate = setgen('X',"","","");
  7418. retcode = 0;
  7419. break;
  7420. default:
  7421. if ((x = remcfm()) < 0) return(x);
  7422. printf("?Not implemented - %s\n",cmdbuf);
  7423. return(-2);
  7424. }
  7425. if (local && retcode > -1) /* If local, flush tty input buffer */
  7426. ttflui();
  7427. return(retcode);
  7428. }
  7429. /* R F I L O P -- Remote File Operation */
  7430. CHAR
  7431. #ifdef CK_ANSIC
  7432. rfilop(char * s, char t)
  7433. #else
  7434. rfilop(s,t) char *s, t;
  7435. #endif /* CK_ANSIC */
  7436. /* rfilop */ {
  7437. if (*s == NUL) {
  7438. printf("?File specification required\n");
  7439. return((CHAR) 0);
  7440. }
  7441. debug(F111,"rfilop",s,t);
  7442. return(setgen(t,s,"",""));
  7443. }
  7444. #endif /* NOXFER */
  7445. #ifdef ANYX25
  7446. int
  7447. setx25() {
  7448. if ((y = cmkey(x25tab,nx25,"X.25 call options","",xxstring)) < 0)
  7449. return(y);
  7450. switch (y) {
  7451. case XYUDAT:
  7452. if ((z = cmkey(onoff,2,"X.25 call user data","",xxstring))
  7453. < 0) return(z);
  7454. if (z == 0) {
  7455. if ((z = cmcfm()) < 0) return(z);
  7456. cudata = 0; /* disable call user data */
  7457. return (success = 1);
  7458. }
  7459. if ((x = cmtxt("X.25 call user data string","",&s,xxstring)) < 0)
  7460. return(x);
  7461. if ((int)strlen(s) == 0) {
  7462. return (-3);
  7463. } else if ((int)strlen(s) > MAXCUDATA) {
  7464. printf("?The length must be > 0 and <= %d\n",MAXCUDATA);
  7465. return(-2);
  7466. }
  7467. if ((y = cmcfm()) < 0) return(y);
  7468. ckstrncpy(udata,s,MAXCUDATA);
  7469. cudata = 1; /* X.25 call user data specified */
  7470. return (success = 1);
  7471. case XYCLOS:
  7472. if ((z = cmkey(onoff,2,"X.25 closed user group call","",xxstring))
  7473. < 0) return(z);
  7474. if (z == 0) {
  7475. if ((z = cmcfm()) < 0) return(z);
  7476. closgr = -1; /* disable closed user group */
  7477. return (success = 1);
  7478. }
  7479. if ((y = cmnum("0 <= cug index >= 99","",10,&x,xxstring)) < 0)
  7480. return(y);
  7481. if (x < 0 || x > 99) {
  7482. printf("?The choices are 0 <= cug index >= 99\n");
  7483. return(-2);
  7484. }
  7485. if ((y = cmcfm()) < 0) return(y);
  7486. closgr = x; /* closed user group selected */
  7487. return (success = 1);
  7488. case XYREVC:
  7489. if((z = cmkey(onoff,2,"X.25 reverse charge call","",xxstring)) < 0)
  7490. return(z);
  7491. if ((x = cmcfm()) < 0) return(x);
  7492. revcall = z;
  7493. return (success = 1);
  7494. }
  7495. }
  7496. #ifndef IBMX25
  7497. int
  7498. setpadp() {
  7499. if ((y = cmkey(padx3tab,npadx3,"PAD X.3 parameter name","",xxstring)) < 0)
  7500. return(y);
  7501. x = y;
  7502. switch (x) {
  7503. case PAD_BREAK_CHARACTER:
  7504. if ((y = cmnum("PAD break character value","",10,&z,xxstring)) < 0)
  7505. return(y);
  7506. if ((y = cmcfm()) < 0) return(y);
  7507. break;
  7508. case PAD_ESCAPE:
  7509. if ((y = cmnum("PAD escape","",10,&z,xxstring)) < 0) return(y);
  7510. if (z != 0 && z != 1) {
  7511. printf("?The choices are 0 or 1\n");
  7512. return(-2);
  7513. }
  7514. if ((y = cmcfm()) < 0) return(y);
  7515. break;
  7516. case PAD_ECHO:
  7517. if ((y = cmnum("PAD echo","",10,&z,xxstring)) < 0) return(y);
  7518. if (z != 0 && z != 1) {
  7519. printf("?The choices are 0 or 1\n");
  7520. return(-2);
  7521. }
  7522. if ((y = cmcfm()) < 0) return(y);
  7523. break;
  7524. case PAD_DATA_FORWARD_CHAR:
  7525. if ((y = cmnum("PAD data forward char","",10,&z,xxstring)) < 0)
  7526. return(y);
  7527. if (z != 0 && z != 2) {
  7528. printf("?The choices are 0 or 2\n");
  7529. return(-2);
  7530. }
  7531. if ((y = cmcfm()) < 0) return(y);
  7532. break;
  7533. case PAD_DATA_FORWARD_TIMEOUT:
  7534. if ((y = cmnum("PAD data forward timeout","",10,&z,xxstring)) < 0)
  7535. return(y);
  7536. if (z < 0 || z > 255) {
  7537. printf("?The choices are 0 or 1 <= timeout <= 255\n");
  7538. return(-2);
  7539. }
  7540. if ((y = cmcfm()) < 0) return(y);
  7541. break;
  7542. case PAD_FLOW_CONTROL_BY_PAD:
  7543. if ((y = cmnum("PAD pad flow control","",10,&z,xxstring)) < 0)
  7544. return(y);
  7545. if (z != 0 && z != 1) {
  7546. printf("?The choices are 0 or 1\n");
  7547. return(-2);
  7548. }
  7549. if ((y = cmcfm()) < 0) return(y);
  7550. break;
  7551. case PAD_SUPPRESSION_OF_SIGNALS:
  7552. if ((y = cmnum("PAD service","",10,&z,xxstring)) < 0) return(y);
  7553. if (z != 0 && z != 1) {
  7554. printf("?The choices are 0 or 1\n");
  7555. return(-2);
  7556. }
  7557. if ((y = cmcfm()) < 0) return(y);
  7558. break;
  7559. case PAD_BREAK_ACTION:
  7560. if ((y = cmnum("PAD break action","",10,&z,xxstring)) < 0) return(y);
  7561. if (z != 0 && z != 1 && z != 2 && z != 5 && z != 8 && z != 21) {
  7562. printf("?The choices are 0, 1, 2, 5, 8 or 21\n");
  7563. return(-2);
  7564. }
  7565. if ((y = cmcfm()) < 0) return(y);
  7566. break;
  7567. case PAD_SUPPRESSION_OF_DATA:
  7568. if ((y = cmnum("PAD data delivery","",10,&z,xxstring)) < 0) return(y);
  7569. if (z != 0 && z != 1) {
  7570. printf("?The choices are 0 or 1\n");
  7571. return(-2);
  7572. }
  7573. if ((y = cmcfm()) < 0) return(y);
  7574. break;
  7575. case PAD_PADDING_AFTER_CR:
  7576. if ((y = cmnum("PAD crpad","",10,&z,xxstring)) < 0) return(y);
  7577. if (z < 0 || z > 7) {
  7578. printf("?The choices are 0 or 1 <= crpad <= 7\n");
  7579. return(-2);
  7580. }
  7581. if ((y = cmcfm()) < 0) return(y);
  7582. break;
  7583. case PAD_LINE_FOLDING:
  7584. if ((y = cmnum("PAD linefold","",10,&z,xxstring)) < 0) return(y);
  7585. if (z < 0 || z > 255) {
  7586. printf("?The choices are 0 or 1 <= linefold <= 255\n");
  7587. return(-2);
  7588. }
  7589. if ((y = cmcfm()) < 0) return(y);
  7590. break;
  7591. case PAD_LINE_SPEED:
  7592. if ((y = cmnum("PAD baudrate","",10,&z,xxstring)) < 0) return(y);
  7593. if (z < 0 || z > 18) {
  7594. printf("?The choices are 0 <= baudrate <= 18\n");
  7595. return(-2);
  7596. }
  7597. if ((y = cmcfm()) < 0) return(y);
  7598. break;
  7599. case PAD_FLOW_CONTROL_BY_USER:
  7600. if ((y = cmnum("PAD terminal flow control","",10,&z,xxstring)) < 0)
  7601. return(y);
  7602. if (z != 0 && z != 1) {
  7603. printf("?The choices are 0 or 1\n");
  7604. return(-2);
  7605. }
  7606. if ((y = cmcfm()) < 0) return(y);
  7607. break;
  7608. case PAD_LF_AFTER_CR:
  7609. if ((y = cmnum("PAD crpad","",10,&z,xxstring)) < 0) return(y);
  7610. if (z < 0 || z == 3 || z > 7) {
  7611. printf("?The choices are 0, 1, 2, 4, 5, 6 or 7\n");
  7612. return(-2);
  7613. }
  7614. if ((y = cmcfm()) < 0) return(y);
  7615. break;
  7616. case PAD_PADDING_AFTER_LF:
  7617. if ((y = cmnum("PAD lfpad","",10,&z,xxstring)) < 0) return(y);
  7618. if (z < 0 || z > 7) {
  7619. printf("?The choices are 0 or 1 <= lfpad <= 7\n");
  7620. return(-2);
  7621. }
  7622. if ((y = cmcfm()) < 0) return(y);
  7623. break;
  7624. case PAD_EDITING:
  7625. if ((y = cmnum("PAD edit control","",10,&z,xxstring)) < 0) return(y);
  7626. if (z != 0 && z != 1) {
  7627. printf("?The choices are 0 or 1\n");
  7628. return(-2);
  7629. }
  7630. if ((y = cmcfm()) < 0) return(y);
  7631. break;
  7632. case PAD_CHAR_DELETE_CHAR:
  7633. if ((y = cmnum("PAD char delete char","",10,&z,xxstring)) < 0)
  7634. return(y);
  7635. if (z < 0 || z > 127) {
  7636. printf("?The choices are 0 or 1 <= chardelete <= 127\n");
  7637. return(-2);
  7638. }
  7639. if ((y = cmcfm()) < 0) return(y);
  7640. break;
  7641. case PAD_BUFFER_DELETE_CHAR:
  7642. if ((y = cmnum("PAD buffer delete char","",10,&z,xxstring)) < 0)
  7643. return(y);
  7644. if (z < 0 || z > 127) {
  7645. printf("?The choices are 0 or 1 <= bufferdelete <= 127\n");
  7646. return(-2);
  7647. }
  7648. if ((y = cmcfm()) < 0) return(y);
  7649. break;
  7650. case PAD_BUFFER_DISPLAY_CHAR:
  7651. if ((y = cmnum("PAD display line char","",10,&z,xxstring)) < 0)
  7652. return(y);
  7653. if (z < 0 || z > 127) {
  7654. printf("?The choices are 0 or 1 <= displayline <= 127\n");
  7655. return(-2);
  7656. }
  7657. if ((y = cmcfm()) < 0) return(y);
  7658. break;
  7659. }
  7660. padparms[x] = z;
  7661. return(success = 1);
  7662. }
  7663. #endif /* IBMX25 */
  7664. #endif /* ANYX25 */
  7665. #ifndef NOXFER
  7666. int
  7667. setat(rmsflg) int rmsflg; {
  7668. int xx;
  7669. if ((y = cmkey(attrtab,natr,"File Attribute packets","",xxstring)) < 0)
  7670. return(y);
  7671. if (y == AT_XALL) { /* ATTRIBUTES ALL ON or ALL OFF */
  7672. if ((z = seton(&xx)) < 0) return(z);
  7673. if (rmsflg) {
  7674. printf("Sorry, command not available\n");
  7675. return(-9);
  7676. } else {
  7677. atenci = xx; /* Encoding in */
  7678. atenco = xx; /* Encoding out */
  7679. atdati = xx; /* Date in */
  7680. atdato = xx; /* Date out */
  7681. atdisi = xx; /* Disposition in/out */
  7682. atdiso = xx;
  7683. atleni = xx; /* Length in/out (both kinds) */
  7684. atleno = xx;
  7685. atblki = xx; /* Blocksize in/out */
  7686. atblko = xx;
  7687. attypi = xx; /* File type in/out */
  7688. attypo = xx;
  7689. atsidi = xx; /* System ID in/out */
  7690. atsido = xx;
  7691. atsysi = xx; /* System-dependent params in/out */
  7692. atsyso = xx;
  7693. #ifdef CK_PERMS /* Protection */
  7694. atlpri = xx; /* Local in */
  7695. atlpro = xx; /* Local out */
  7696. atgpri = xx; /* Generic in */
  7697. atgpro = xx; /* Generic out */
  7698. #endif /* CK_PERMS */
  7699. #ifdef STRATUS
  7700. atfrmi = xx; /* Format in/out */
  7701. atfrmo = xx;
  7702. atcrei = xx; /* Creator id in/out */
  7703. atcreo = xx;
  7704. atacti = xx; /* Account in/out */
  7705. atacto = xx;
  7706. #endif /* STRATUS */
  7707. }
  7708. return(z);
  7709. } else if (y == AT_ALLY || y == AT_ALLN) { /* ATTRIBUTES ON or OFF */
  7710. if ((x = cmcfm()) < 0) return(x);
  7711. atcapr = (y == AT_ALLY) ? 1 : 0;
  7712. if (rmsflg) {
  7713. sstate = setgen('S', "132", atcapr ? "1" : "0", "");
  7714. return((int) sstate);
  7715. } else return(success = 1);
  7716. }
  7717. /* Otherwise, it's an individual attribute that wants turning off/on */
  7718. if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
  7719. if ((x = cmcfm()) < 0) return(x);
  7720. /* There are better ways to do this... */
  7721. /* The real problem is that we're not separating the in and out cases */
  7722. /* and so we have to arbitrarily pick the "in" case, i.e tell the remote */
  7723. /* server to ignore incoming attributes of the specified type, rather */
  7724. /* than telling it not to send them. The protocol does not (yet) define */
  7725. /* codes for "in-and-out-at-the-same-time". */
  7726. switch (y) {
  7727. #ifdef CK_PERMS
  7728. /* We're lumping local and generic protection together for now... */
  7729. case AT_LPRO:
  7730. case AT_GPRO:
  7731. if (rmsflg) {
  7732. sstate = setgen('S', "143", z ? "1" : "0", "");
  7733. return((int) sstate);
  7734. }
  7735. atlpri = atlpro = atgpri = atgpro = z; break;
  7736. #endif /* CK_PERMS */
  7737. case AT_DISP:
  7738. if (rmsflg) {
  7739. sstate = setgen('S', "142", z ? "1" : "0", "");
  7740. return((int) sstate);
  7741. }
  7742. atdisi = atdiso = z; break;
  7743. case AT_ENCO:
  7744. if (rmsflg) {
  7745. sstate = setgen('S', "141", z ? "1" : "0", "");
  7746. return((int) sstate);
  7747. }
  7748. atenci = atenco = z; break;
  7749. case AT_DATE:
  7750. if (rmsflg) {
  7751. sstate = setgen('S', "135", z ? "1" : "0", "");
  7752. return((int) sstate);
  7753. }
  7754. atdati = atdato = z; break;
  7755. case AT_LENB:
  7756. case AT_LENK:
  7757. if (rmsflg) {
  7758. sstate = setgen('S', "133", z ? "1" : "0", "");
  7759. return((int) sstate);
  7760. }
  7761. atleni = atleno = z; break;
  7762. case AT_BLKS:
  7763. if (rmsflg) {
  7764. sstate = setgen('S', "139", z ? "1" : "0", "");
  7765. return((int) sstate);
  7766. }
  7767. atblki = atblko = z; break;
  7768. case AT_FTYP:
  7769. if (rmsflg) {
  7770. sstate = setgen('S', "134", z ? "1" : "0", "");
  7771. return((int) sstate);
  7772. }
  7773. attypi = attypo = z; break;
  7774. #ifdef STRATUS
  7775. case AT_CREA:
  7776. if (rmsflg) {
  7777. sstate = setgen('S', "136", z ? "1" : "0", "");
  7778. return((int) sstate);
  7779. }
  7780. atcrei = atcreo = z; break;
  7781. case AT_ACCT:
  7782. if (rmsflg) {
  7783. sstate = setgen('S', "137", z ? "1" : "0", "");
  7784. return((int) sstate);
  7785. }
  7786. atacti = atacto = z; break;
  7787. #endif /* STRATUS */
  7788. case AT_SYSI:
  7789. if (rmsflg) {
  7790. sstate = setgen('S', "145", z ? "1" : "0", "");
  7791. return((int) sstate);
  7792. }
  7793. atsidi = atsido = z; break;
  7794. case AT_RECF:
  7795. if (rmsflg) {
  7796. sstate = setgen('S', "146", z ? "1" : "0", "");
  7797. return((int) sstate);
  7798. }
  7799. atfrmi = atfrmo = z; break;
  7800. case AT_SYSP:
  7801. if (rmsflg) {
  7802. sstate = setgen('S', "147", z ? "1" : "0", "");
  7803. return((int) sstate);
  7804. }
  7805. atsysi = atsyso = z; break;
  7806. default:
  7807. printf("?Not available\n");
  7808. return(-2);
  7809. }
  7810. return(1);
  7811. }
  7812. #endif /* NOXFER */
  7813. #ifndef NOSPL
  7814. int
  7815. setinp() {
  7816. if ((y = cmkey(inptab,ninp,"","",xxstring)) < 0) return(y);
  7817. switch (y) {
  7818. #ifdef OS2
  7819. case IN_PAC: /* SET INPUT PACING */
  7820. z = cmnum("milliseconds","0",10,&x,xxstring);
  7821. return(setnum(&tt_inpacing,x,z,1000));
  7822. case IN_TRM: /* SET INPUT TERMINAL */
  7823. return(seton(&interm));
  7824. #endif /* OS2 */
  7825. case IN_DEF: /* SET INPUT DEFAULT-TIMEOUT */
  7826. z = cmnum("Positive number","",10,&x,xxstring);
  7827. return(setnum(&indef,x,z,94));
  7828. #ifdef CKFLOAT
  7829. case IN_SCA: /* SET INPUT SCALE-FACTOR */
  7830. if ((x = cmfld("Number such as 2 or 0.5","1.0",&s, xxstring)) < 0)
  7831. return(x);
  7832. if (isfloat(s,0)) { /* A floating-point number? */
  7833. extern char * inpscale;
  7834. inscale = floatval; /* Yes, get its value */
  7835. makestr(&inpscale,s); /* Save it as \v(inscale) */
  7836. return(success = 1);
  7837. } else {
  7838. return(-2);
  7839. }
  7840. #endif /* CKFLOAT */
  7841. case IN_TIM: /* SET INPUT TIMEOUT-ACTION */
  7842. if ((z = cmkey(intimt,2,"","",xxstring)) < 0) return(z);
  7843. if ((x = cmcfm()) < 0) return(x);
  7844. intime[cmdlvl] = z;
  7845. return(success = 1);
  7846. case IN_CAS: /* SET INPUT CASE */
  7847. if ((z = cmkey(incast,2,"","",xxstring)) < 0) return(z);
  7848. if ((x = cmcfm()) < 0) return(x);
  7849. inpcas[cmdlvl] = z;
  7850. return(success = 1);
  7851. case IN_ECH: /* SET INPUT ECHO */
  7852. return(seton(&inecho));
  7853. case IN_SIL: /* SET INPUT SILENCE */
  7854. z = cmnum("Seconds of inactivity before INPUT fails","",10,&x,
  7855. xxstring);
  7856. return(setnum(&insilence,x,z,-1));
  7857. case IN_BUF: /* SET INPUT BUFFER-SIZE */
  7858. if ((z = cmnum("Number of bytes in INPUT buffer",
  7859. ckitoa(INPBUFSIZ),10,&x, xxstring)) < 0)
  7860. return(z);
  7861. if ((y = cmcfm()) < 0) return(y);
  7862. inbufsize = 0;
  7863. if (inpbuf) {
  7864. free(inpbuf);
  7865. inpbuf = NULL;
  7866. inpbp = NULL;
  7867. }
  7868. if (!(s = (char *)malloc(x + 1)))
  7869. return(0);
  7870. inpbuf = s;
  7871. inpbp = s;
  7872. inbufsize = x;
  7873. for (x = 0; x <= inbufsize; x++)
  7874. inpbuf[x] = NUL;
  7875. return(success = 1);
  7876. #ifdef CK_AUTODL
  7877. case IN_ADL: /* AUTODOWNLOAD */
  7878. return(seton(&inautodl));
  7879. #endif /* CK_AUTODL */
  7880. case IN_CAN: /* SET INPUT INTERRUPTS */
  7881. return(seton(&inintr));
  7882. }
  7883. return(0);
  7884. }
  7885. #endif /* NOSPL */
  7886. #ifdef NETCONN
  7887. VOID
  7888. ndreset() {
  7889. #ifndef NODIAL /* This depends on DIAL... */
  7890. int i=0, j=0;
  7891. if (!ndinited) /* Don't free garbage... */
  7892. return;
  7893. for (i = 0; i < nhcount; i++) { /* Clean out previous list */
  7894. if (nh_p[i])
  7895. free(nh_p[i]);
  7896. nh_p[i] = NULL;
  7897. if (nh_p2[i])
  7898. free(nh_p2[i]);
  7899. nh_p2[i] = NULL;
  7900. for (j = 0; j < 4; j++) {
  7901. if (nh_px[j][i])
  7902. free(nh_px[j][i]);
  7903. nh_px[j][i] = NULL;
  7904. }
  7905. }
  7906. #endif /* NODIAL */
  7907. }
  7908. VOID
  7909. ndinit() { /* Net directory pointers */
  7910. #ifndef NODIAL /* This depends on DIAL... */
  7911. int i, j;
  7912. if (ndinited++) /* Don't do this more than once. */
  7913. return;
  7914. for (i = 0; i < MAXDDIR; i++) { /* Init all pointers to NULL */
  7915. netdir[i] = NULL;
  7916. }
  7917. for (i = 0; i < MAXDNUMS; i++) {
  7918. nh_p[i] = NULL;
  7919. nh_p2[i] = NULL;
  7920. for (j = 0; j < 4; j++)
  7921. nh_px[j][i] = NULL;
  7922. }
  7923. #endif /* NODIAL */
  7924. }
  7925. #ifndef NODIAL
  7926. #ifdef NETCONN
  7927. VOID /* Get net defaults from environment */
  7928. getnetenv() {
  7929. char *p = NULL;
  7930. makestr(&p,getenv("K_NET_DIRECTORY")); /* Dialing directories */
  7931. if (p) {
  7932. int i;
  7933. xwords(p,MAXDDIR,netdir,0);
  7934. for (i = 0; i < MAXDDIR; i++) { /* Fill in any gaps... */
  7935. if (!netdir[i+1])
  7936. break;
  7937. else
  7938. netdir[i] = netdir[i+1];
  7939. debug(F111,"netdir[i]",netdir[i],i);
  7940. }
  7941. nnetdir = i;
  7942. }
  7943. }
  7944. #endif /* NETCONN */
  7945. #endif /* NODIAL */
  7946. int
  7947. #ifdef CK_ANSIC
  7948. lunet(char *s) /* s = name to look up */
  7949. #else
  7950. lunet(s) char *s;
  7951. #endif /* CK_ANSIC */
  7952. /* lunet */ {
  7953. #ifndef NODIAL /* This depends on DIAL... */
  7954. int n, n1, t, dd = 0;
  7955. int ambiguous = 0;
  7956. FILE * f;
  7957. char *line = NULL;
  7958. extern int dialdpy;
  7959. int netdpy = dialdpy;
  7960. char *info[8];
  7961. nhcount = 0; /* Set this before returning */
  7962. if (!s || nnetdir < 1) /* Validate arguments */
  7963. return(-1);
  7964. if (isdigit(*s) || *s == '*' || *s == '.')
  7965. return(0);
  7966. if ((n1 = (int) strlen(s)) < 1) /* Length of string to look up */
  7967. return(-1);
  7968. if (!(line = malloc(1024))) /* Allocate input buffer */
  7969. return(-1);
  7970. lu_again:
  7971. f = NULL; /* Network directory file descriptor */
  7972. t = nhcount = 0; /* Match count */
  7973. dd = 0; /* Directory counter */
  7974. dirline = 0;
  7975. while (1) { /* We make one pass */
  7976. if (!f) { /* Directory not open */
  7977. if (dd >= nnetdir) /* No directories left? */
  7978. break; /* Done. */
  7979. if ((f = fopen(netdir[dd],"r")) == NULL) { /* Open it */
  7980. perror(netdir[dd]); /* Can't, print message saying why */
  7981. dd++;
  7982. continue; /* But go on to next one. */
  7983. }
  7984. if (netdpy)
  7985. printf("Opening %s...\n",netdir[dd]);
  7986. dd++;
  7987. }
  7988. line[0] = NUL;
  7989. if (getnct(line,1023,f,1) < 0) { /* Read a line */
  7990. if (f) { /* f can be clobbered! */
  7991. fclose(f); /* Close the file */
  7992. f = NULL; /* Indicate next one needs opening */
  7993. }
  7994. continue;
  7995. }
  7996. if (!line[0]) /* Empty line */
  7997. continue;
  7998. xwords(line,7,info,0); /* Parse it */
  7999. if (!info[1] || !info[2] || !info[3]) /* Required fields */
  8000. continue;
  8001. if (*info[1] == ';') /* Full-line comment */
  8002. continue;
  8003. if ((n = (int) strlen(info[1])) < 1) /* Length of name-tag */
  8004. continue;
  8005. if (n < n1) /* Search name is longer */
  8006. continue; /* Can't possibly match */
  8007. if (ambiguous && n != n1)
  8008. continue;
  8009. if (ckstrcmp(s,info[1],n1,0)) /* Compare using length of */
  8010. continue; /* search string s. */
  8011. /* Have a match */
  8012. makestr(&(nh_p[nhcount]), info[3]); /* address */
  8013. makestr(&(nh_p2[nhcount]),info[2]); /* net type */
  8014. makestr(&(nh_px[0][nhcount]),info[4]); /* net-specific stuff... */
  8015. makestr(&(nh_px[1][nhcount]),info[5]);
  8016. makestr(&(nh_px[2][nhcount]),info[6]);
  8017. makestr(&(nh_px[3][nhcount]),info[7]);
  8018. nhcount++; /* Count this match */
  8019. if (nhcount > MAXDNUMS) { /* Watch out for too many */
  8020. printf("Warning: %d matches found, %d max\n",
  8021. nhcount,
  8022. MAXDNUMS
  8023. );
  8024. nhcount = MAXDNUMS;
  8025. break;
  8026. }
  8027. if (nhcount == 1) { /* First one - save entry name */
  8028. if (n_name) { /* Free the one from before if any */
  8029. free(n_name);
  8030. n_name = NULL;
  8031. }
  8032. if (!(n_name = (char *)malloc(n + 1))) { /* Allocate new storage */
  8033. printf("?memory allocation error - lunet:3\n");
  8034. if (line) {
  8035. free(line);
  8036. line = NULL;
  8037. }
  8038. nhcount = 0;
  8039. return(-1);
  8040. }
  8041. t = n; /* Remember its length */
  8042. strcpy(n_name,info[1]); /* safe */
  8043. } else { /* Second or subsequent one */
  8044. if ((int) strlen(info[1]) == t) /* Lengths compare */
  8045. if (!ckstrcmp(n_name,info[1],t,0)) /* Caseless compare OK */
  8046. continue;
  8047. /* Name given by user matches entries with different names */
  8048. if (ambiguous) /* Been here before */