ckuus3.c 441 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764
  1. #ifdef SSHTEST
  2. #define SSHBUILTIN
  3. #endif /* SSHTEST */
  4. #include "ckcsym.h" /* Symbol definitions */
  5. /* C K U U S 3 -- "User Interface" for C-Kermit, part 3 */
  6. /*
  7. Authors:
  8. Frank da Cruz <fdc@columbia.edu>,
  9. The Kermit Project, New York City
  10. Jeffrey E Altman <jaltman@secure-endpoints.com>
  11. Secure Endpoints Inc., New York City
  12. Copyright (C) 1985, 2016,
  13. Trustees of Columbia University in the City of New York.
  14. All rights reserved. See the C-Kermit COPYING.TXT file or the
  15. copyright text in the ckcmai.c module for disclaimer and permissions.
  16. */
  17. /* SET command (but much material has been split off into ckuus7.c). */
  18. /*
  19. Kermit-specific includes.
  20. Definitions here supersede those from system include files.
  21. */
  22. #include "ckcdeb.h" /* Debugging & compiler things */
  23. #include "ckcasc.h" /* ASCII character symbols */
  24. #include "ckcker.h" /* Kermit application definitions */
  25. #include "ckcxla.h" /* Character set translation */
  26. #include "ckcnet.h" /* Network symbols */
  27. char pwbuf[PWBUFL+1] = { NUL, NUL };
  28. int pwflg = 0;
  29. int pwcrypt = 0;
  30. #ifndef NOICP
  31. #ifdef CK_AUTHENTICATION
  32. #include "ckuath.h"
  33. #endif /* CK_AUTHENTICATION */
  34. #ifdef CK_SSL
  35. #include "ck_ssl.h"
  36. #endif /* CK_SSL */
  37. #include "ckuusr.h" /* User interface symbols */
  38. #ifdef OS2
  39. #include "ckcuni.h"
  40. #ifdef SSHBUILTIN
  41. #include "ckossh.h"
  42. #endif /* SSHBUILTIN */
  43. #ifdef CK_NETBIOS
  44. #include <os2.h>
  45. #ifdef COMMENT /* Would you believe */
  46. #undef COMMENT /* <os2.h> defines this ? */
  47. #endif /* COMMENT */
  48. #include "ckonbi.h"
  49. extern UCHAR NetBiosAdapter;
  50. #endif /* CK_NETBIOS */
  51. #include "ckocon.h"
  52. #include "ckokey.h"
  53. #ifndef NOTERM
  54. extern unsigned char colorcmd; /* Command-screen colors */
  55. extern struct keytab ttyclrtab[];
  56. extern int nclrs;
  57. extern int tt_cols[], tt_rows[], tt_szchng[], tt_status[];
  58. #endif /* NOTERM */
  59. _PROTOTYP(int setprty, (void));
  60. extern char startupdir[], exedir[];
  61. extern int tt_modechg;
  62. #ifdef NT
  63. #include <windows.h>
  64. #include <tapi.h>
  65. #include "ckntap.h" /* Microsoft TAPI */
  66. #endif /* NT */
  67. #endif /* OS2 */
  68. #ifndef OS2
  69. extern char * exedir;
  70. #endif /* OS2 */
  71. #ifdef CK_RECALL
  72. extern int cm_retry;
  73. #endif /* CK_RECALL */
  74. #ifdef NEWFTP
  75. extern int ftpisopen();
  76. #endif /* NEWFTP */
  77. extern int cmdint;
  78. extern int srvidl;
  79. #ifdef CKFLOAT
  80. extern CKFLOAT floatval; /* (see isfloat()) */
  81. #endif /* CKFLOAT */
  82. #ifndef NOPUSH
  83. #ifndef NOFRILLS
  84. #ifdef VMS
  85. char editor[CKMAXPATH + 1] = "edit";
  86. #else
  87. char editor[CKMAXPATH + 1] = { NUL, NUL };
  88. #endif /* VMS */
  89. char editopts[128] = { NUL, NUL };
  90. char editfile[CKMAXPATH + 1] = { NUL, NUL };
  91. #ifdef BROWSER
  92. char browser[CKMAXPATH + 1] = { NUL, NUL };
  93. char browsopts[128] = { NUL, NUL };
  94. char browsurl[4096] = { NUL, NUL };
  95. #endif /* BROWSER */
  96. #endif /* NOFRILLS */
  97. #endif /* NOPUSH */
  98. #ifndef NOFRILLS
  99. #ifndef NORENAME
  100. _PROTOTYP(int setrename, (void));
  101. #endif /* NORENAME */
  102. #endif /* NOFRILLS */
  103. /* Variables */
  104. int exitmsg = 1;
  105. int cmd_quoting = 1;
  106. int cmd_err = 1;
  107. extern int hints, xcmdsrc;
  108. #ifdef CK_KERBEROS
  109. char * k4pwprompt = NULL; /* Kerberos 4 password prompt */
  110. char * k4prprompt = NULL; /* Kerberos 4 principal prompt */
  111. char * k5pwprompt = NULL; /* Kerberos 5 password prompt */
  112. char * k5prprompt = NULL; /* Kerberos 5 principal prompt */
  113. #endif /* CK_KERBEROS */
  114. #ifdef CK_SRP
  115. char * srppwprompt = NULL;
  116. #endif /* CK_SRP */
  117. extern char * ckprompt, * ikprompt; /* Default prompt */
  118. extern xx_strp xxstring;
  119. extern char * cdmsgfile[], * cdmsgstr;
  120. extern int
  121. local, server, success, dest, sleepcan, inserver, flow, autoflow, binary,
  122. parity, escape, what, turn, duplex, backgrd, hwparity, stopbits, turnch,
  123. mdmtyp, network, quiet, nettype, carrier, debses, debtim, cdtimo, nlangs,
  124. bgset, pflag, msgflg, cmdmsk, xsuspend, techo, pacing, xitwarn, xitsta,
  125. outesc, cmd_cols, cmd_rows, ckxech, xaskmore, haveline, didsetlin, isguest,
  126. mdmsav, clearrq, saveask, debmsg;
  127. extern int reliable, setreliable, matchdot, matchfifo, dir_dots;
  128. #ifndef NOSERVER
  129. extern int en_pri;
  130. #endif /* NOSERVER */
  131. #ifdef IKSDCONF
  132. extern int iksdcf;
  133. #endif /* IKSDCONF */
  134. #ifdef TCPSOCKET
  135. extern int tn_exit;
  136. #endif /* TCPSOCKET */
  137. #ifdef TNCODE
  138. char * tn_pr_uid = NULL;
  139. #endif /* TNCODE */
  140. extern int exitonclose;
  141. #ifndef NOKVERBS
  142. extern int nkverbs;
  143. extern struct keytab kverbs[];
  144. #endif /* NOKVERBS */
  145. extern int ttnproto; /* Network protocol */
  146. extern char *ccntab[]; /* Names of control chars */
  147. #ifdef CK_APC
  148. extern int apcactive, apcstatus;
  149. #endif /* CK_APC */
  150. #ifndef NOSCRIPT
  151. extern int secho; /* Whether SCRIPT cmd should echo */
  152. #endif /* NOSCRIPT */
  153. #ifdef DCMDBUF
  154. extern char *atmbuf, *atxbuf;
  155. #else
  156. extern char atmbuf[], atxbuf[];
  157. #endif /* DCMDBUF */
  158. extern int cmflgs;
  159. extern char psave[];
  160. extern char uidbuf[];
  161. extern int sl_uid_saved;
  162. int DeleteStartupFile = 0;
  163. extern int cmdlvl; /* Overall command level */
  164. #ifndef NOSPL
  165. _PROTOTYP( static int parsdir, (int) );
  166. char prmbuf[PWBUFL+1] = { NUL, NUL };
  167. int fndiags = 1; /* Function diagnostics on/off */
  168. int fnerror = 1; /* Function error treatment */
  169. #ifdef DCMDBUF
  170. extern int *count, *takerr, *merror, *inpcas;
  171. #else
  172. extern int count[], takerr[], merror[], inpcas[];
  173. #endif /* DCMDBUF */
  174. extern int mecho; /* Macro echo */
  175. extern long ck_alarm;
  176. extern char alrm_date[], alrm_time[];
  177. #else
  178. extern int takerr[];
  179. #endif /* NOSPL */
  180. extern int x_ifnum;
  181. extern int bigsbsiz, bigrbsiz; /* Packet buffers */
  182. extern long speed; /* Terminal speed */
  183. extern char ttname[]; /* Communication device name */
  184. extern char myhost[] ;
  185. extern char inidir[]; /* Ini File directory */
  186. #ifndef NOSETKEY
  187. extern KEY *keymap; /* Character map for SET KEY (1:1) */
  188. extern MACRO *macrotab; /* Macro map for SET KEY (1:string) */
  189. #endif /* NOSETKEY */
  190. #ifdef OS2
  191. int wideresult; /* For wide OS/2 scan codes/cmnum() */
  192. #endif /* OS2 */
  193. #ifndef NOLOCAL
  194. #ifdef OS2
  195. extern int tt_scrsize[]; /* Scrollback buffer Sizes */
  196. #endif /* OS2 */
  197. #endif /* NOLOCAL */
  198. /* Printer settings */
  199. extern char * printername; /* NULL if printer not redirected */
  200. extern int printpipe;
  201. extern int noprinter;
  202. #ifdef PRINTSWI
  203. int printtimo = 0;
  204. char * printterm = NULL;
  205. char * printsep = NULL;
  206. int printertype = 0;
  207. #ifdef BPRINT
  208. int printbidi = 0; /* SET BPRINTER (bidirectional) */
  209. long pportspeed = 0L; /* Bidirection printer port speed, */
  210. int pportparity = 0; /* parity, */
  211. int pportflow = FLO_KEEP; /* and flow control */
  212. #endif /* BPRINT */
  213. #ifdef OS2
  214. extern int txt2ps; /* Text2PS conversion? */
  215. extern int ps_width, ps_length; /* Text2PS dimensions */
  216. #endif /* OS2 */
  217. #endif /* PRINTSWI */
  218. #ifdef OS2
  219. extern int tcp_avail; /* Nonzero if TCP/IP is available */
  220. #ifdef DECNET
  221. extern int dnet_avail; /* Ditto for DECnet */
  222. #endif /* DECNET */
  223. #ifdef SUPERLAT
  224. extern int slat_avail;
  225. #endif /* SUPERLAT */
  226. #endif /* OS2 */
  227. static struct keytab logintab[] = {
  228. { "password", LOGI_PSW, CM_INV },
  229. { "prompt", LOGI_PRM, CM_INV },
  230. { "userid", LOGI_UID, 0 }
  231. };
  232. #ifndef NOCSETS
  233. /* system-independent character sets, defined in ckcxla.[ch] */
  234. extern struct csinfo tcsinfo[];
  235. extern struct langinfo langs[];
  236. /* Other character-set related variables */
  237. extern int tcharset, tslevel, language;
  238. #endif /* NOCSETS */
  239. /* File-transfer variable declarations */
  240. #ifndef NOXFER
  241. #ifdef CK_AUTODL
  242. extern int cmdadl;
  243. #endif /* CK_AUTODL */
  244. #ifndef NOSERVER
  245. extern int ngetpath;
  246. extern char * getpath[];
  247. #endif /* NOSERVER */
  248. extern struct ck_p ptab[];
  249. extern CHAR sstate; /* Protocol start state */
  250. extern CHAR myctlq; /* Control-character prefix */
  251. extern CHAR myrptq; /* Repeat-count prefix */
  252. extern int protocol, size, spsiz, spmax, urpsiz, srvtim, srvcdmsg, slostart,
  253. srvdis, xfermode, ckdelay, keep, maxtry, unkcs, bctr, bctf, ebqflg, swcapr,
  254. wslotr, lscapr, lscapu, spsizr, rptena, rptmin, docrc, xfrcan, xfrchr,
  255. xfrnum, xfrbel, xfrint, srvping, g_xfermode, xfrxla;
  256. #ifdef PIPESEND
  257. extern int usepipes;
  258. #endif /* PIPESEND */
  259. #ifdef CKXXCHAR /* DOUBLE / IGNORE char table */
  260. extern int dblflag, ignflag, dblchar;
  261. extern short dblt[];
  262. #endif /* CKXXCHAR */
  263. #ifdef CK_SPEED
  264. extern short ctlp[]; /* Control-prefix table */
  265. extern int prefixing;
  266. static struct keytab pfxtab[] = {
  267. "all", PX_ALL, 0,
  268. "cautious", PX_CAU, 0,
  269. "minimal", PX_WIL, 0,
  270. "none", PX_NON, 0
  271. };
  272. #endif /* CK_SPEED */
  273. #endif /* NOXFER */
  274. /* Declarations from cmd package */
  275. #ifdef DCMDBUF
  276. extern char *cmdbuf; /* Command buffer */
  277. extern char *line;
  278. extern char *tmpbuf;
  279. #else
  280. extern char cmdbuf[]; /* Command buffer */
  281. extern char line[]; /* Character buffer for anything */
  282. extern char tmpbuf[];
  283. #endif /* DCMDBUF */
  284. /* From main ckuser module... */
  285. extern char *tp, *lp; /* Temporary buffer */
  286. extern int tlevel; /* Take Command file level */
  287. #ifndef NOLOCAL
  288. extern int sessft; /* Session-log file type */
  289. extern int slogts; /* Session-log timestamps on/off */
  290. extern int slognul; /* Lines null-terminated */
  291. #endif /* NOLOCAL */
  292. char * tempdir = NULL; /* Temporary directory */
  293. #ifdef VMS
  294. int vms_msgs = 1; /* SET MESSAGES */
  295. extern int batch;
  296. #endif /* VMS */
  297. /* Keyword tables for SET commands */
  298. #ifdef CK_SPEED
  299. struct keytab ctltab[] = {
  300. "prefixed", 1, 0, /* Note, the values are important. */
  301. "unprefixed", 0, 0
  302. };
  303. #endif /* CK_SPEED */
  304. static struct keytab oldnew[] = {
  305. "new", 0, 0,
  306. "old", 1, 0
  307. };
  308. #define MCH_FIFO 1
  309. #define MCH_DOTF 2
  310. struct keytab matchtab[] = {
  311. { "dotfile", MCH_DOTF, 0 },
  312. { "fifo", MCH_FIFO, 0 }
  313. };
  314. int nmatchtab = (sizeof(matchtab) / sizeof(struct keytab));
  315. #ifndef NOSPL
  316. static struct keytab functab[] = {
  317. "diagnostics", FUNC_DI, 0,
  318. "error", FUNC_ER, 0
  319. };
  320. static int nfunctab = (sizeof(functab) / sizeof(struct keytab));
  321. struct keytab outptab[] = { /* SET OUTPUT parameters */
  322. "pacing", 0, 0, /* only one so far... */
  323. "special-escapes", 1, 0
  324. };
  325. int noutptab = (sizeof(outptab) / sizeof(struct keytab)); /* How many */
  326. #endif /* NOSPL */
  327. struct keytab chktab[] = { /* Block check types */
  328. "1", 1, 0, /* 1 = 6-bit checksum */
  329. "2", 2, 0, /* 2 = 12-bit checksum */
  330. "3", 3, 0, /* 3 = 16-bit CRC */
  331. "4", 4, 0, /* Same as B */
  332. "5", 5, 0, /* Same as F */
  333. "blank-free-2", 4, CM_INV, /* B = 12-bit checksum, no blanks */
  334. "force-3", 5, CM_INV /* F = Force CRC on ALL packets */
  335. };
  336. static int nchkt = (sizeof(chktab) / sizeof(struct keytab));
  337. struct keytab rpttab[] = { /* SET REPEAT */
  338. "counts", 0, 0, /* On or Off */
  339. #ifdef COMMENT
  340. "minimum", 1, 0, /* Threshhold */
  341. #endif /* COMMENT */
  342. "prefix", 2, 0 /* Repeat-prefix character value */
  343. };
  344. #ifndef NOLOCAL
  345. /* For SET [ MODEM ] CARRIER, and also for SET DIAL CONNECT */
  346. struct keytab crrtab[] = {
  347. "automatic", CAR_AUT, 0, /* 2 */
  348. "off", CAR_OFF, 0, /* 0 */
  349. "on", CAR_ON, 0 /* 1 */
  350. };
  351. int ncrr = 3;
  352. #endif /* NOLOCAL */
  353. struct keytab ooatab[] = { /* On/Off/Auto table */
  354. "automatic", SET_AUTO, 0, /* 2 */
  355. "off", SET_OFF, 0, /* 0 */
  356. "on", SET_ON, 0 /* 1 */
  357. };
  358. struct keytab ooetab[] = { /* On/Off/Stderr table 2010/03/12 */
  359. "off", SET_OFF, 0, /* for SET DEBUG MESSAGES */
  360. "on", SET_ON, 0, /* 2013-03-13 and SET EXIT MESSAGE */
  361. "s", 2, CM_ABR|CM_INV,
  362. "st", 2, CM_ABR|CM_INV,
  363. "std", 2, CM_ABR|CM_INV,
  364. "stderr", 2, 0,
  365. "stdout", SET_ON, CM_INV
  366. };
  367. static int nooetab = (sizeof(ooetab) / sizeof(struct keytab));
  368. struct keytab ooktab[] = { /* On/Off/Ask table */
  369. "ask", 2, 0, /* 2 */
  370. "off", SET_OFF, 0, /* 0 */
  371. "on", SET_ON, 0 /* 1 */
  372. };
  373. struct keytab qvtab[] = { /* Quiet/Verbose table */
  374. "quiet", 1, 0,
  375. "verbose", 0, 0
  376. };
  377. int nqvt = 2;
  378. /* For SET DEBUG */
  379. #define DEB_OFF 0
  380. #define DEB_ON 1
  381. #define DEB_SES 2
  382. #define DEB_TIM 3
  383. #define DEB_LEN 4
  384. #define DEB_MSG 5
  385. struct keytab dbgtab[] = {
  386. "linelength", DEB_LEN, CM_INV,
  387. "m", DEB_MSG, CM_ABR|CM_INV,
  388. "message", DEB_MSG, 0,
  389. "msg", DEB_MSG, CM_INV,
  390. "off", DEB_OFF, 0,
  391. "on", DEB_ON, 0,
  392. "session", DEB_SES, 0,
  393. "timestamps", DEB_TIM, 0
  394. };
  395. int ndbg = (sizeof(dbgtab) / sizeof(struct keytab));
  396. #ifndef NOLOCAL
  397. /* Transmission speeds */
  398. #ifdef TTSPDLIST /* Speed table constructed at runtime . . . */
  399. struct keytab * spdtab = NULL;
  400. int nspd = 0;
  401. #else
  402. /*
  403. Note, the values are encoded in cps rather than bps because 19200 and higher
  404. are too big for some ints. All but 75bps are multiples of ten. Result of
  405. lookup in this table must be multiplied by 10 to get actual speed in bps.
  406. If this number is 70, it must be changed to 75. If it is 888, this means
  407. 75/1200 split speed.
  408. The values are generic, rather than specific to UNIX. We can't use B75,
  409. B1200, B9600, etc, because non-UNIX versions of C-Kermit will not
  410. necessarily have these symbols defined. The BPS_xxx symbols are
  411. Kermit-specific, and are defined in ckcdeb.h or on the CC command line.
  412. Like all other keytabs, this one must be in "alphabetical" order,
  413. rather than numeric order.
  414. */
  415. struct keytab spdtab[] = {
  416. "0", 0, CM_INV,
  417. "110", 11, 0,
  418. #ifdef BPS_115K
  419. "115200",11520, 0,
  420. #endif /* BPS_115K */
  421. "1200", 120, 0,
  422. #ifdef BPS_134
  423. "134.5", 134, 0,
  424. #endif /* BPS_134 */
  425. #ifdef BPS_14K
  426. "14400", 1440, 0,
  427. #endif /* BPS_14K */
  428. #ifdef BPS_150
  429. "150", 15, 0,
  430. #endif /* BPS_150 */
  431. #ifdef BPS_1800
  432. "1800", 180, 0,
  433. #endif /* BPS_150 */
  434. #ifdef BPS_19K
  435. "19200", 1920, 0,
  436. #endif /* BPS_19K */
  437. #ifdef BPS_200
  438. "200", 20, 0,
  439. #endif /* BPS_200 */
  440. #ifdef BPS_230K
  441. "230400", 23040, 0,
  442. #endif /* BPS_230K */
  443. "2400", 240, 0,
  444. #ifdef BPS_28K
  445. "28800", 2880, 0,
  446. #endif /* BPS_28K */
  447. "300", 30, 0,
  448. #ifdef BPS_3600
  449. "3600", 360, 0,
  450. #endif /* BPS_3600 */
  451. #ifdef BPS_38K
  452. "38400", 3840, 0,
  453. #endif /* BPS_38K */
  454. #ifdef BPS_460K
  455. "460800", 46080, 0, /* Need 32 bits for this... */
  456. #endif /* BPS_460K */
  457. "4800", 480, 0,
  458. #ifdef BPS_50
  459. "50", 5, 0,
  460. #endif /* BPS_50 */
  461. #ifdef BPS_57K
  462. "57600", 5760, 0,
  463. #endif /* BPS_57K */
  464. "600", 60, 0,
  465. #ifdef BPS_7200
  466. "7200", 720, 0,
  467. #endif /* BPS_7200 */
  468. #ifdef BPS_75
  469. "75", 7, 0,
  470. #endif /* BPS_75 */
  471. #ifdef BPS_7512
  472. "75/1200",888, 0, /* Code "888" for split speed */
  473. #endif /* BPS_7512 */
  474. #ifdef BPS_76K
  475. "76800", 7680, 0,
  476. #endif /* BPS_76K */
  477. #ifdef BPS_921K
  478. "921600", 92160,0, /* Need 32 bits for this... */
  479. #endif /* BPS_921K */
  480. "9600", 960, 0
  481. "1500000", 150000, 0
  482. };
  483. int nspd = (sizeof(spdtab) / sizeof(struct keytab)); /* How many speeds */
  484. #endif /* TTSPDLIST */
  485. #ifdef TN_COMPORT
  486. struct keytab tnspdtab[] = { /* RFC 2217 TELNET COMPORT Option */
  487. "115200", 11520, 0, /* (add any other defined speeds) */
  488. "1200", 120, 0,
  489. "14400", 1440, 0,
  490. "19200", 1920, 0,
  491. "230400", 23040, 0,
  492. "2400", 240, 0,
  493. "28800", 2880, 0,
  494. "300", 30, 0,
  495. "38400", 3840, 0,
  496. "460800", 46080, 0,
  497. "4800", 480, 0,
  498. "57600", 5760, 0,
  499. "600", 60, 0,
  500. "9600", 960, 0,
  501. "1500000", 150000, 0
  502. };
  503. int ntnspd = (sizeof(tnspdtab) / sizeof(struct keytab)); /* How many speeds */
  504. #endif /* TN_COMPORT */
  505. #endif /* NOLOCAL */
  506. #ifndef NOCSETS
  507. extern struct keytab lngtab[]; /* Languages for SET LANGUAGE */
  508. extern int nlng;
  509. #endif /* NOCSETS */
  510. #ifndef NOLOCAL
  511. /* Duplex keyword table */
  512. struct keytab dpxtab[] = {
  513. "full", 0, 0,
  514. "half", 1, 0
  515. };
  516. #endif /* NOLOCAL */
  517. /* Flow Control */
  518. struct keytab cxtypesw[] = {
  519. #ifdef DECNET
  520. "/decnet", CXT_DECNET, 0,
  521. #endif /* DECNET */
  522. "/direct-serial", CXT_DIRECT, 0,
  523. #ifdef DECNET
  524. "/lat", CXT_LAT, 0,
  525. #else
  526. #ifdef SUPERLAT
  527. "/lat", CXT_LAT, 0,
  528. #endif /* SUPERLAT */
  529. #endif /* DECNET */
  530. "/modem", CXT_MODEM, 0,
  531. #ifdef NPIPE
  532. "/named-pipe", CXT_NPIPE, 0,
  533. #endif /* NPIPE */
  534. #ifdef NETBIOS
  535. "/netbios", CXT_NETBIOS, 0,
  536. #endif /* NETBIOS */
  537. "/remote", CXT_REMOTE, 0,
  538. #ifdef TCPSOCKET
  539. "/tcpip", CXT_TCPIP, 0,
  540. #endif /* TCPSOCKET */
  541. #ifdef ANYX25
  542. "/x.25", CXT_X25, 0,
  543. #endif /* ANYX25 */
  544. "", 0, 0
  545. };
  546. int ncxtypesw = (sizeof(cxtypesw) / sizeof(struct keytab));
  547. #ifdef TN_COMPORT
  548. struct keytab tnflotab[] = { /* SET FLOW-CONTROL keyword table */
  549. "dtr/cd", FLO_DTRC, 0, /* for RFC 2217 Telnet COMPORT */
  550. "dtr/cts", FLO_DTRT, 0,
  551. "keep", FLO_KEEP, 0,
  552. "none", FLO_NONE, 0,
  553. "rts/cts", FLO_RTSC, 0,
  554. "xon/xoff", FLO_XONX, 0
  555. };
  556. int ntnflo = (sizeof(tnflotab) / sizeof(struct keytab));
  557. #endif /* TN_COMPORT */
  558. struct keytab flotab[] = { /* SET FLOW-CONTROL keyword table */
  559. "automatic", FLO_AUTO, CM_INV, /* Not needed any more */
  560. #ifdef CK_DTRCD
  561. "dtr/cd", FLO_DTRC, 0,
  562. #endif /* CK_DTRCD */
  563. #ifdef CK_DTRCTS
  564. "dtr/cts", FLO_DTRT, 0,
  565. #endif /* CK_DTRCTS */
  566. "keep", FLO_KEEP, 0,
  567. "none", FLO_NONE, 0,
  568. #ifdef CK_RTSCTS
  569. "rts/cts", FLO_RTSC, 0,
  570. #endif /* CK_RTSCTS */
  571. #ifndef Plan9
  572. "xon/xoff", FLO_XONX, 0,
  573. #endif /* Plan9 */
  574. "", 0, 0
  575. };
  576. int nflo = (sizeof(flotab) / sizeof(struct keytab)) - 1;
  577. /* Handshake characters */
  578. struct keytab hshtab[] = {
  579. "bell", 007, 0,
  580. "code", 998, 0,
  581. "cr", 015, 0,
  582. "esc", 033, 0,
  583. "lf", 012, 0,
  584. "none", 999, 0, /* (can't use negative numbers) */
  585. "xoff", 023, 0,
  586. "xon", 021, 0
  587. };
  588. int nhsh = (sizeof(hshtab) / sizeof(struct keytab));
  589. #ifndef NOLOCAL
  590. static struct keytab sfttab[] = { /* File types for SET SESSION-LOG */
  591. "ascii", XYFT_T, CM_INV,
  592. "binary", XYFT_B, 0,
  593. "debug", XYFT_D, 0,
  594. "null-padded-lines", 998, 0,
  595. "text", XYFT_T, 0,
  596. "timestamped-text", 999, 0
  597. };
  598. static int nsfttab = (sizeof(sfttab) / sizeof(struct keytab));
  599. #endif /* NOLOCAL */
  600. #ifndef NODIAL
  601. #ifdef NETCONN /* Networks directory depends */
  602. int nnetdir = 0; /* on DIAL code -- fix later... */
  603. char *netdir[MAXDDIR+2];
  604. #endif /* NETCONN */
  605. _PROTOTYP( static int setdial, (int) );
  606. _PROTOTYP( static int setdcd, (void) );
  607. _PROTOTYP( static int cklogin, (void) );
  608. #ifndef MINIDIAL
  609. #ifdef OLDTBCODE
  610. extern int tbmodel; /* Telebit model ID */
  611. #endif /* OLDTBCODE */
  612. #endif /* MINIDIAL */
  613. extern MDMINF *modemp[]; /* Pointers to modem info structs */
  614. extern struct keytab mdmtab[]; /* Modem types (in module ckudia.c) */
  615. extern int nmdm; /* Number of them */
  616. _PROTOTYP(static int dialstr,(char **, char *));
  617. extern int dialhng, dialtmo, dialksp, dialdpy, dialmhu, dialec, dialdc;
  618. extern int dialrtr, dialint, dialudt, dialsrt, dialrstr, mdmwaitd;
  619. extern int mdmspd, dialfc, dialmth, dialesc, dialfld, dialidt, dialpace;
  620. extern int mdmspk, mdmvol, dialtest;
  621. int dialcvt = 2; /* DIAL CONVERT-DIRECTORY */
  622. int dialcnf = 0; /* DIAL CONFIRMATION */
  623. int dialcon = 2; /* DIAL CONNECT */
  624. int dialcq = 0; /* DIAL CONNECT AUTO quiet/verbose */
  625. extern long dialmax, dialcapas;
  626. int usermdm = 0;
  627. extern int ndialdir;
  628. extern char *dialini, *dialmstr, *dialmprmt, *dialdir[], *dialcmd, *dialnpr,
  629. *dialdcon, *dialdcoff, *dialecon, *dialecoff, *dialhcmd, *dialx3,
  630. *dialhwfc, *dialswfc, *dialnofc, *dialtone, *dialpulse, *dialname, *diallac;
  631. extern char *diallcc, *dialixp, *dialixs, *dialldp, *diallds, *dialtfp,
  632. *dialpxi, *dialpxo, *dialsfx, *dialaaon, *dialaaoff;
  633. extern char *diallcp, *diallcs, *dialini2, *dialmac;
  634. extern char *dialspoff, *dialspon, *dialvol1, *dialvol2, *dialvol3;
  635. char *dialtocc[MAXTPCC] = { NULL, NULL };
  636. int ndialtocc = 0;
  637. char *dialpucc[MAXTPCC] = { NULL, NULL };
  638. int ndialpucc = 0;
  639. char *dialtfc[MAXTOLLFREE] = {
  640. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
  641. };
  642. int ntollfree = 0;
  643. char *dialpxx[MAXPBXEXCH] = {
  644. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
  645. };
  646. int ndialpxx = 0;
  647. char *diallcac[MAXLOCALAC] = {
  648. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  649. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  650. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  651. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
  652. };
  653. int nlocalac = 0;
  654. static struct keytab drstrtab[] = {
  655. "international", 5, 0,
  656. "local", 2, 0,
  657. "long-distance", 4, 0,
  658. "none", 6, 0
  659. };
  660. static struct keytab dcnvtab[] = {
  661. "ask", 2, 0,
  662. "off", 0, 0,
  663. "on", 1, 0
  664. };
  665. struct keytab setmdm[] = {
  666. "capabilities", XYDCAP, 0,
  667. "carrier-watch", XYDMCD, 0,
  668. "command", XYDSTR, 0,
  669. "compression", XYDDC, CM_INV,
  670. "data-compression", XYDDC, 0,
  671. "dial-command", XYDDIA, 0,
  672. "error-correction", XYDEC, 0,
  673. "escape-character", XYDESC, 0,
  674. "flow-control", XYDFC, 0,
  675. "hangup-method", XYDMHU, 0,
  676. #ifndef NOXFER
  677. "kermit-spoof", XYDKSP, 0,
  678. #endif /* NOXFER */
  679. "maximum-speed", XYDMAX, 0,
  680. "name", XYDNAM, 0,
  681. "speaker", XYDSPK, 0,
  682. "speed-matching", XYDSPD, 0,
  683. "type", XYDTYP, 0,
  684. "volume", XYDVOL, 0
  685. };
  686. int nsetmdm = (sizeof(setmdm) / sizeof(struct keytab));
  687. struct keytab voltab[] = {
  688. "high", 3, 0,
  689. "low", 1, 0,
  690. "medium", 2, 0
  691. };
  692. struct keytab mdmcap[] = {
  693. "at-commands", CKD_AT, 0,
  694. "compression", CKD_DC, 0,
  695. "dc", CKD_DC, CM_INV,
  696. "ec", CKD_EC, CM_INV,
  697. "error-correction", CKD_EC, 0,
  698. "hardware-flow", CKD_HW, 0,
  699. "hwfc", CKD_HW, CM_INV,
  700. "itu", CKD_V25, CM_INV,
  701. "kermit-spoof", CKD_KS, 0,
  702. "ks", CKD_KS, CM_INV,
  703. "sb", CKD_SB, CM_INV,
  704. "software-flow", CKD_SW, 0,
  705. "speed-buffering", CKD_SB, 0,
  706. "swfc", CKD_SW, CM_INV,
  707. "tb", CKD_TB, CM_INV,
  708. "telebit", CKD_TB, 0,
  709. "v25bis-commands", CKD_V25, 0
  710. };
  711. int nmdmcap = (sizeof(mdmcap) / sizeof(struct keytab));
  712. #ifdef COMMENT /* SET ANSWER not implemented yet */
  713. static struct keytab answertab[] = {
  714. { "caller-id", XYA_CID, 0 };
  715. { "rings", XYA_RNG, 0 };
  716. { "", 0, 0 }
  717. };
  718. static int nanswertab = (sizeof(answertab) / sizeof(struct keytab)) - 1;
  719. #endif /* COMMENT */
  720. struct keytab dialtab[] = { /* SET DIAL table */
  721. "area-code", XYDLAC, 0, /* Also still includes items */
  722. "compression", XYDDC, CM_INV, /* that were moved to SET MODEM, */
  723. "confirmation", XYDCNF, 0, /* but they are CM_INVisible... */
  724. "connect", XYDCON, 0,
  725. "convert-directory",XYDCVT, 0,
  726. "country-code", XYDLCC, 0,
  727. "dial-command", XYDDIA, CM_INV,
  728. "directory", XYDDIR, 0,
  729. "display", XYDDPY, 0,
  730. "escape-character", XYDESC, CM_INV,
  731. "error-correction", XYDEC, CM_INV,
  732. "flow-control", XYDFC, CM_INV,
  733. "force-long-distance", XYDFLD, 0,
  734. "hangup", XYDHUP, 0,
  735. "ignore-dialtone", XYDIDT, 0,
  736. "interval", XYDINT, 0,
  737. "in", XYDINI, CM_INV|CM_ABR,
  738. "init-string", XYDINI, CM_INV,
  739. "intl-prefix", XYDIXP, 0,
  740. "intl-suffix", XYDIXS, 0,
  741. #ifndef NOXFER
  742. "kermit-spoof", XYDKSP, CM_INV,
  743. #endif /* NOXFER */
  744. "lc-area-codes", XYDLLAC, 0,
  745. "lc-prefix", XYDLCP, 0,
  746. "lc-suffix", XYDLCS, 0,
  747. "ld-prefix", XYDLDP, 0,
  748. "ld-suffix", XYDLDS, 0,
  749. "local-area-code", XYDLAC, CM_INV,
  750. "local-prefix", XYDLCP, CM_INV,
  751. "local-suffix", XYDLCS, CM_INV,
  752. "m", XYDMTH, CM_INV|CM_ABR,
  753. #ifndef NOSPL
  754. "macro", XYDMAC, 0, /* 195 */
  755. #endif /* NOSPL */
  756. #ifdef MDMHUP
  757. "me", XYDMTH, CM_INV|CM_ABR,
  758. #endif /* MDMHUP */
  759. "method", XYDMTH, 0,
  760. "mnp-enable", XYDMNP, CM_INV, /* obsolete but still accepted */
  761. #ifdef MDMHUP
  762. "modem-hangup", XYDMHU, CM_INV,
  763. #endif /* MDMHUP */
  764. "pacing", XYDPAC, 0,
  765. "pbx-exchange", XYDPXX, 0,
  766. "pbx-inside-prefix",XYDPXI, 0,
  767. "pbx-outside-prefix",XYDPXO, 0,
  768. "prefix", XYDNPR, 0,
  769. "pulse-countries", XYDPUCC, 0,
  770. "restrict", XYDRSTR, 0,
  771. "retries", XYDRTM, 0,
  772. "sort", XYDSRT, 0,
  773. "speed-matching", XYDSPD, CM_INV,
  774. "string", XYDSTR, CM_INV,
  775. "suffix", XYDSFX, 0,
  776. "test", XYDTEST, 0,
  777. "timeout", XYDTMO, 0,
  778. "tf-area-code", XYDTFC, CM_INV,
  779. "tf-prefix", XYDTFP, CM_INV,
  780. "toll-free-area-code",XYDTFC,0,
  781. "toll-free-prefix", XYDTFP, 0,
  782. "tone-countries", XYDTOCC, 0
  783. };
  784. int ndial = (sizeof(dialtab) / sizeof(struct keytab));
  785. #ifdef MDMHUP
  786. struct keytab mdmhang[] = {
  787. "dtr", 0, 0,
  788. "modem-command", 1, 0,
  789. "rs232-signal", 0, 0,
  790. "v24-signal", 0, CM_INV
  791. };
  792. #endif /* MDMHUP */
  793. static struct keytab mdmcmd[] = {
  794. "autoanswer", XYDS_AN, 0, /* autoanswer */
  795. "compression", XYDS_DC, 0, /* data compression */
  796. "dial-mode-prompt", XYDS_MP, 0, /* dial mode prompt */
  797. "dial-mode-string", XYDS_MS, 0, /* dial mode string */
  798. "error-correction", XYDS_EC, 0, /* error correction */
  799. "hangup-command", XYDS_HU, 0, /* hangup command */
  800. "hardware-flow", XYDS_HW, 0, /* hwfc */
  801. "ignore-dialtone", XYDS_ID, 0, /* ignore dialtone */
  802. "init-string", XYDS_IN, 0, /* init string */
  803. "no-flow-control", XYDS_NF, 0, /* no flow control */
  804. "predial-init", XYDS_I2, 0, /* last-minute setup commands */
  805. "pulse", XYDS_DP, 0, /* pulse */
  806. "software-flow", XYDS_SW, 0, /* swfc */
  807. "speaker", XYDS_SP, 0, /* Speaker */
  808. "tone", XYDS_DT, 0, /* tone */
  809. "volume", XYDS_VO, 0 /* Volume */
  810. };
  811. static int nmdmcmd = (sizeof(mdmcmd) / sizeof(struct keytab));
  812. struct keytab dial_fc[] = {
  813. "auto", FLO_AUTO, 0,
  814. "none", FLO_NONE, 0,
  815. "rts/cts", FLO_RTSC, 0,
  816. "xon/xoff", FLO_XONX, 0
  817. };
  818. struct keytab dial_m[] = { /* DIAL METHOD */
  819. "auto", XYDM_A, 0,
  820. "default", XYDM_D, 0,
  821. "pulse", XYDM_P, 0,
  822. "tone", XYDM_T, 0
  823. };
  824. int ndial_m = (sizeof(dial_m)/sizeof(struct keytab));
  825. #endif /* NODIAL */
  826. #ifdef CK_TAPI
  827. struct keytab tapitab[] = { /* Top-Level Microsoft TAPI */
  828. "configure-line", XYTAPI_CFG, 0,
  829. "dialing-properties", XYTAPI_DIAL, 0
  830. };
  831. int ntapitab = (sizeof(tapitab)/sizeof(struct keytab));
  832. struct keytab settapitab[] = { /* SET Microsoft TAPI */
  833. "inactivity-timeout", XYTAPI_INA, 0,
  834. "line", XYTAPI_LIN, 0,
  835. "location", XYTAPI_LOC, 0,
  836. "manual-dialing", XYTAPI_MAN, 0,
  837. "modem-dialing", XYTAPI_PASS, 0,
  838. "modem-lights", XYTAPI_LGHT, 0,
  839. "phone-number-conversions", XYTAPI_CON, 0,
  840. "port", XYTAPI_LIN, CM_INV,
  841. "post-dial-terminal", XYTAPI_PST, 0,
  842. "pre-dial-terminal", XYTAPI_PRE, 0,
  843. "use-windows-configuration", XYTAPI_USE, 0,
  844. "wait-for-credit-card-tone", XYTAPI_BNG, 0
  845. };
  846. int nsettapitab = (sizeof(settapitab)/sizeof(struct keytab));
  847. struct keytab * tapiloctab = NULL; /* Microsoft TAPI Locations */
  848. int ntapiloc = 0;
  849. extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
  850. extern int ntapiline;
  851. extern int tttapi; /* TAPI in use */
  852. extern int tapipass; /* TAPI Passthrough mode */
  853. extern int tapiconv; /* TAPI Conversion mode */
  854. extern int tapilights;
  855. extern int tapipreterm;
  856. extern int tapipostterm;
  857. extern int tapimanual;
  858. extern int tapiinactivity;
  859. extern int tapibong;
  860. extern int tapiusecfg;
  861. #endif /* CK_TAPI */
  862. #ifndef NOPUSH
  863. extern int nopush;
  864. extern int wildena;
  865. #ifdef UNIX
  866. struct keytab wildtab[] = { /* SET WILDCARD-EXPANSION */
  867. #ifdef UNIX
  868. "kermit", WILD_KER, 0, /* By Kermit */
  869. #endif /* UNIX */
  870. "off", WILD_OFF, 0, /* Disabled */
  871. "on", WILD_ON, 0, /* Enabled */
  872. #ifdef UNIX
  873. "shell", WILD_SHE, 0, /* By Shell */
  874. #endif /* UNIX */
  875. "", 0, 0
  876. };
  877. int nwild = (sizeof(wildtab) / sizeof(struct keytab)) - 1;
  878. struct keytab wdottab[] = { /* cont'd */
  879. "/match-dot-files", 1, 0,
  880. "/no-match-dot-files", 0, 0
  881. };
  882. extern int wildxpand;
  883. #endif /* UNIX */
  884. #endif /* NOPUSH */
  885. #ifdef NETCONN
  886. extern struct keytab netcmd[], netkey[];
  887. extern int nnets, nnetkey;
  888. #ifdef TCPSOCKET
  889. extern struct keytab tcpopt[];
  890. extern int ntcpopt;
  891. #endif /* TCPSOCKET */
  892. #ifdef NPIPE
  893. char pipename[PIPENAML+1] = { NUL, NUL };
  894. #endif /* NPIPE */
  895. #ifdef CK_NETBIOS
  896. extern unsigned char NetBiosName[];
  897. #endif /* CK_NETBIOS */
  898. #endif /* NETCONN */
  899. #ifdef ANYX25
  900. struct keytab x25tab[] = {
  901. "call-user-data", XYUDAT, 0,
  902. "closed-user-group", XYCLOS, 0,
  903. "reverse-charge", XYREVC, 0
  904. };
  905. int nx25 = (sizeof(x25tab) / sizeof(struct keytab));
  906. #ifndef IBMX25
  907. struct keytab padx3tab[] = {
  908. "break-action", PAD_BREAK_ACTION, 0,
  909. "break-character", PAD_BREAK_CHARACTER, 0,
  910. "character-delete", PAD_CHAR_DELETE_CHAR, 0,
  911. "cr-padding", PAD_PADDING_AFTER_CR, 0,
  912. "discard-output", PAD_SUPPRESSION_OF_DATA, 0,
  913. "echo", PAD_ECHO, 0,
  914. "editing", PAD_EDITING, 0,
  915. "escape", PAD_ESCAPE, 0,
  916. "forward", PAD_DATA_FORWARD_CHAR, 0,
  917. "lf-padding", PAD_PADDING_AFTER_LF, 0,
  918. "lf-insert", PAD_LF_AFTER_CR, 0,
  919. "line-delete", PAD_BUFFER_DELETE_CHAR, 0,
  920. "line-display", PAD_BUFFER_DISPLAY_CHAR, 0,
  921. "line-fold", PAD_LINE_FOLDING, 0,
  922. "pad-flow-control", PAD_FLOW_CONTROL_BY_PAD, 0,
  923. "service-signals", PAD_SUPPRESSION_OF_SIGNALS, 0,
  924. "timeout", PAD_DATA_FORWARD_TIMEOUT, 0,
  925. /* Speed is read-only */
  926. "transmission-rate", PAD_LINE_SPEED, 0,
  927. "user-flow-control", PAD_FLOW_CONTROL_BY_USER, 0
  928. };
  929. int npadx3 = (sizeof(padx3tab) / sizeof(struct keytab));
  930. #endif /* IBMX25 */
  931. #endif /* ANYX25 */
  932. #ifdef TLOG
  933. static struct keytab vbtab[] = {
  934. "brief", 0, 0,
  935. #ifdef OS2ORUNIX
  936. "ftp", 2, 0,
  937. #else
  938. #ifdef VMS
  939. "ftp", 2, 0,
  940. #endif /* def VMS */
  941. #endif /* OS2ORUNIX */
  942. "verbose", 1, 0
  943. };
  944. int nvb = (sizeof(vbtab) / sizeof(struct keytab));
  945. #endif /* TLOG */
  946. #ifdef CKSYSLOG
  947. static struct keytab syslogtab[] = {
  948. "all", SYSLG_CX, 0,
  949. "commands", SYSLG_CM, 0,
  950. "connection", SYSLG_AC, 0,
  951. "debug", SYSLG_DB, 0,
  952. "dial", SYSLG_DI, 0,
  953. "file-access", SYSLG_FA, 0,
  954. "file-create", SYSLG_FC, 0,
  955. "login", SYSLG_LI, 0,
  956. "none", SYSLG_NO, 0,
  957. "protocol", SYSLG_PR, 0
  958. };
  959. int nsyslog = (sizeof(syslogtab) / sizeof(struct keytab));
  960. #endif /* CKSYSLOG */
  961. /* Parity keyword table */
  962. struct keytab partbl[] = {
  963. "even", 'e', 0,
  964. #ifdef HWPARITY
  965. "hardware",'H', 0,
  966. #endif /* HWPARITY */
  967. "mark", 'm', 0,
  968. "none", 0 , 0,
  969. "odd", 'o', 0,
  970. "space", 's', 0
  971. };
  972. int npar = (sizeof(partbl) / sizeof(struct keytab));
  973. #ifdef HWPARITY
  974. struct keytab hwpartbl[] = {
  975. /* Add mark and space if needed and possible */
  976. "even", 'e', 0,
  977. #ifdef OS2
  978. "mark", 'm', 0,
  979. #endif /* OS2 */
  980. "odd", 'o', 0,
  981. #ifdef OS2
  982. "space", 's', 0,
  983. #endif /* OS2 */
  984. "", 0, 0
  985. };
  986. int nhwpar = (sizeof(hwpartbl) / sizeof(struct keytab)) - 1;
  987. #endif /* HWPARITY */
  988. /* On/Off table */
  989. struct keytab onoff[] = {
  990. "off", 0, 0,
  991. "on", 1, 0
  992. };
  993. #define XYCD_M 0 /* CD MESSAGE */
  994. #define XYCD_P 1 /* CD PATH */
  995. #define XYCD_H 2 /* CD HOME */
  996. struct keytab cdtab[] = {
  997. "home", XYCD_H, 0,
  998. "message", XYCD_M, 0,
  999. "path", XYCD_P, 0
  1000. };
  1001. int ncdtab = (sizeof(cdtab) / sizeof(struct keytab));
  1002. struct keytab cdmsg[] = {
  1003. "file", 2, 0,
  1004. "off", 0, 0,
  1005. "on", 1, 0
  1006. };
  1007. int ncdmsg = (sizeof(cdmsg) / sizeof(struct keytab));
  1008. static
  1009. struct keytab xittab[] = { /* SET EXIT */
  1010. "hangup", 3, 0, /* ...HANGUP */
  1011. "message", 4, 0, /* ...MESSAGE */
  1012. "on-disconnect", 2, 0, /* ...ON-DISCONNECT */
  1013. "status", 0, 0, /* ...STATUS */
  1014. "warning", 1, 0 /* ...WARNING */
  1015. };
  1016. int nexit = (sizeof(xittab) / sizeof(struct keytab));
  1017. struct keytab xitwtab[] = { /* SET EXIT WARNING */
  1018. "always", 2, 0, /* even when not connected */
  1019. "off", 0, 0, /* no warning */
  1020. "on", 1, 0 /* when connected */
  1021. };
  1022. int nexitw = (sizeof(xitwtab) / sizeof(struct keytab));
  1023. struct keytab rltab[] = {
  1024. "local", 1, 0, /* ECHO values */
  1025. "off", 0, CM_INV,
  1026. "on", 1, CM_INV,
  1027. "remote", 0, 0
  1028. };
  1029. int nrlt = (sizeof(rltab) / sizeof(struct keytab));
  1030. /* Incomplete File Disposition table */
  1031. struct keytab ifdtab[] = {
  1032. "discard", SET_OFF, 0,
  1033. "keep", SET_ON, 0
  1034. };
  1035. struct keytab ifdatab[] = {
  1036. "auto", SET_AUTO, 0,
  1037. "discard", SET_OFF, 0,
  1038. "keep", SET_ON, 0
  1039. };
  1040. char * ifdnam[] = { "discard", "keep", "auto" };
  1041. /* SET TAKE parameters table */
  1042. static
  1043. struct keytab taktab[] = {
  1044. "echo", 0, 0,
  1045. "error", 1, 0,
  1046. "off", 2, CM_INV, /* For compatibility */
  1047. "on", 3, CM_INV /* with MS-DOS Kermit... */
  1048. };
  1049. #ifndef NOSPL
  1050. #ifdef COMMENT
  1051. /* not used */
  1052. static
  1053. struct keytab suftab[] = { /* (what to do with) STARTUP-FILE */
  1054. "delete", 1, 0,
  1055. "keep", 0, 0
  1056. };
  1057. #endif /* COMMENT */
  1058. /* SET MACRO parameters table */
  1059. static
  1060. struct keytab smactab[] = {
  1061. "echo", 0, 0,
  1062. "error", 1, 0
  1063. };
  1064. #endif /* NOSPL */
  1065. #ifndef NOSCRIPT
  1066. static
  1067. struct keytab scrtab[] = {
  1068. "echo", 0, 0
  1069. };
  1070. #endif /* NOSCRIPT */
  1071. /* SET COMMAND table */
  1072. /* SET COMMAND items... */
  1073. #define SCMD_BSZ 0 /* BYTESIZE */
  1074. #define SCMD_RCL 1 /* RECALL */
  1075. #define SCMD_RTR 2 /* RETRY */
  1076. #define SCMD_QUO 3 /* QUOTING */
  1077. #define SCMD_COL 4 /* COLOR */
  1078. #define SCMD_HIG 5 /* HEIGHT */
  1079. #define SCMD_WID 6 /* WIDTH */
  1080. #define SCMD_CUR 7 /* CURSOR-POSITION */
  1081. #define SCMD_SCR 8 /* SCROLLBACK */
  1082. #define SCMD_MOR 9 /* MORE-PROMPTING */
  1083. #define SCMD_INT 10 /* INTERRUPTION */
  1084. #define SCMD_ADL 11 /* AUTODOWNLOAD */
  1085. #define SCMD_STA 12 /* STATUSLINE */
  1086. #define SCMD_DBQ 13 /* DOUBLEQUOTING */
  1087. #define SCMD_CBR 14 /* CBREAK */
  1088. #define SCMD_BFL 15 /* BUFFER-SIZE (not used) */
  1089. #define SCMD_ERR 16 /* ERROR */
  1090. #define SCMD_VAR 17 /* VARIABLE-EVALUATION */
  1091. static struct keytab scmdtab[] = {
  1092. #ifdef CK_AUTODL
  1093. "autodownload", SCMD_ADL, 0,
  1094. #endif /* CK_AUTODL */
  1095. #ifdef COMMENT
  1096. /*
  1097. To implement this requires that we change CMDBL and ATMBL
  1098. from compile-time symbols to runtime variables. Not a big deal,
  1099. but not trivial either.
  1100. */
  1101. "buffer-size", SCMD_BFL, 0,
  1102. #endif /* COMMENT */
  1103. "bytesize", SCMD_BSZ, 0,
  1104. "cbreak", SCMD_CBR, CM_INV,
  1105. #ifdef OS2
  1106. "color", SCMD_COL, 0,
  1107. "cursor-position", SCMD_CUR, 0,
  1108. #endif /* OS2 */
  1109. #ifdef DOUBLEQUOTING
  1110. "doublequoting", SCMD_DBQ, 0,
  1111. #endif /* DOUBLEQUOTING */
  1112. "error-display", SCMD_ERR, 0,
  1113. "height", SCMD_HIG, 0,
  1114. "interruption", SCMD_INT, 0,
  1115. "more-prompting", SCMD_MOR, 0,
  1116. "quoting", SCMD_QUO, 0,
  1117. #ifdef CK_RECALL
  1118. "recall-buffer-size", SCMD_RCL, 0,
  1119. #endif /* CK_RECALL */
  1120. #ifdef CK_RECALL
  1121. "retry", SCMD_RTR, 0,
  1122. #endif /* CK_RECALL */
  1123. #ifdef OS2
  1124. #ifdef ONETERMUPD
  1125. "scrollback", SCMD_SCR, 0,
  1126. "statusline", SCMD_STA, 0,
  1127. #endif /* ONETERMUPD */
  1128. #endif /* OS2 */
  1129. "variable-evaluation", SCMD_VAR,0,
  1130. "width", SCMD_WID, 0
  1131. };
  1132. static int nbytt = (sizeof(scmdtab) / sizeof(struct keytab));
  1133. #ifndef NOSERVER
  1134. /* Server parameters table */
  1135. static struct keytab srvtab[] = {
  1136. "cd-message", XYSERC, 0,
  1137. "display", XYSERD, 0,
  1138. "get-path", XYSERP, 0,
  1139. "idle-timeout", XYSERI, 0,
  1140. "keepalive", XYSERK, 0,
  1141. "login", XYSERL, 0,
  1142. "timeout", XYSERT, 0
  1143. };
  1144. static int nsrvt = (sizeof(srvtab) / sizeof(struct keytab));
  1145. #endif /* NOSERVER */
  1146. static struct keytab sleeptab[] = { /* SET SLEEP table */
  1147. "cancellation", 0, 0
  1148. };
  1149. static struct keytab tstab[] = { /* SET TRANSFER/XFER table */
  1150. "bell", XYX_BEL, 0,
  1151. #ifdef XFRCAN
  1152. "cancellation", XYX_CAN, 0,
  1153. #endif /* XFRCAN */
  1154. #ifndef NOCSETS
  1155. "character-set", XYX_CSE, 0,
  1156. #endif /* NOCSETS */
  1157. #ifndef NOSPL
  1158. "crc-calculation", XYX_CRC, 0,
  1159. #endif /* NOSPL */
  1160. "display", XYX_DIS, 0,
  1161. "interruption", XYX_INT, 0,
  1162. "locking-shift", XYX_LSH, 0,
  1163. "message", XYX_MSG, 0,
  1164. "mode", XYX_MOD, 0,
  1165. "msg", XYX_MSG, CM_INV,
  1166. #ifdef PIPESEND
  1167. "pipes", XYX_PIP, 0,
  1168. #endif /* PIPESEND */
  1169. #ifdef CK_XYZ
  1170. "protocol", XYX_PRO, 0,
  1171. #endif /* CK_XYZ */
  1172. "report", XYX_RPT, 0,
  1173. "slow-start", XYX_SLO, 0,
  1174. #ifndef NOCSETS
  1175. "translation", XYX_XLA, 0,
  1176. #else
  1177. "translation", XYX_XLA, CM_INV,
  1178. #endif /* NOCSETS */
  1179. "xlation", XYX_XLA, CM_INV,
  1180. "", 0, 0
  1181. };
  1182. static int nts = (sizeof(tstab) / sizeof(struct keytab)) - 1;
  1183. static struct keytab rtstab[] = { /* REMOTE SET TRANSFER/XFER table */
  1184. #ifndef NOCSETS
  1185. "character-set", XYX_CSE, 0,
  1186. #endif /* NOCSETS */
  1187. "mode", XYX_MOD, 0
  1188. };
  1189. static int nrts = (sizeof(rtstab) / sizeof(struct keytab));
  1190. struct keytab xfrmtab[] = { /* TRANSFER MODE table */
  1191. "automatic", XMODE_A, 0,
  1192. "manual", XMODE_M, 0
  1193. };
  1194. #ifdef LOCUS
  1195. extern int locus, autolocus;
  1196. static struct keytab locustab[] = {
  1197. #ifdef KUI
  1198. { "ask", 3, 0 }, /* Presently implemented in GUI only */
  1199. #endif /* KUI */
  1200. { "auto", 2, 0 },
  1201. { "local", 1, 0 },
  1202. { "remote", 0, 0 }
  1203. };
  1204. static int nlocustab = (sizeof(locustab) / sizeof(struct keytab));
  1205. #endif /* LOCUS */
  1206. #ifndef NOCSETS
  1207. /* SET TRANSFER CHARACTER-SET table */
  1208. extern struct keytab tcstab[];
  1209. extern int ntcs;
  1210. #endif /* NOCSETS */
  1211. /* SET TRANSFER LOCKING-SHIFT table */
  1212. struct keytab lstab[] = {
  1213. "forced", 2, 0,
  1214. "off", 0, 0,
  1215. "on", 1, 0
  1216. };
  1217. int nls = (sizeof(lstab) / sizeof(struct keytab));
  1218. /* SET TELNET tables */
  1219. #ifdef TNCODE
  1220. extern int tn_nlm, tn_b_nlm, tn_b_meu, tn_b_ume, tn_b_xfer, tn_sb_bug;
  1221. extern int tn_no_encrypt_xfer, tn_auth_krb5_des_bug;
  1222. extern int tn_wait_flg, tn_duplex, tn_delay_sb, tn_sfu;
  1223. extern int sl_tn_saved;
  1224. extern int tn_infinite;
  1225. extern int tn_rem_echo;
  1226. extern int tn_deb;
  1227. extern int tn_auth_how;
  1228. extern int tn_auth_enc;
  1229. #ifdef CK_FORWARD_X
  1230. extern char * tn_fwdx_xauthority;
  1231. #endif /* CK_FORWARD_X */
  1232. #ifdef CK_AUTHENTICATION
  1233. static struct keytab setauth[] = {
  1234. #ifdef CK_KERBEROS
  1235. "k4", AUTH_KRB4, CM_INV,
  1236. "k5", AUTH_KRB5, CM_INV,
  1237. "kerberos4", AUTH_KRB4, 0,
  1238. "kerberos5", AUTH_KRB5, 0,
  1239. "kerberos_iv",AUTH_KRB4, CM_INV,
  1240. "kerberos_v", AUTH_KRB5, CM_INV,
  1241. "krb4", AUTH_KRB4, CM_INV,
  1242. "krb5", AUTH_KRB5, CM_INV,
  1243. #endif /* CK_KERBEROS */
  1244. #ifdef CK_SRP
  1245. "srp", AUTH_SRP, 0,
  1246. #endif /* CK_SRP */
  1247. #ifdef CK_SSL
  1248. "ssl", AUTH_SSL, 0,
  1249. "tls", AUTH_TLS, 0,
  1250. #endif /* CK_SSL */
  1251. "", 0, 0
  1252. };
  1253. static int nsetauth = sizeof(setauth)/sizeof(struct keytab) - 1;
  1254. #ifdef CK_KERBEROS
  1255. extern char * krb5_d_principal; /* Default principal */
  1256. extern char * krb5_d_instance;
  1257. extern char * krb5_d_realm; /* Default realm */
  1258. extern char * krb5_d_cc; /* Default credentials cache */
  1259. extern char * krb5_d_srv; /* Default service name */
  1260. extern int krb5_d_lifetime; /* Default lifetime */
  1261. extern int krb5_d_forwardable;
  1262. extern int krb5_d_proxiable;
  1263. extern int krb5_d_renewable;
  1264. extern int krb5_autoget;
  1265. extern int krb5_autodel;
  1266. extern int krb5_d_getk4;
  1267. extern int krb5_checkaddrs; /* Check TGT Addrs */
  1268. extern int krb5_d_no_addresses;
  1269. extern char * krb5_d_addrs[];
  1270. extern char * k5_keytab; /* Keytab file */
  1271. extern struct krb4_init_data krb4_init;
  1272. extern char * krb4_d_principal; /* Default principal */
  1273. extern char * krb4_d_realm; /* Default realm */
  1274. extern char * krb4_d_srv; /* Default service name */
  1275. extern int krb4_d_lifetime; /* Default lifetime */
  1276. extern int krb4_d_preauth;
  1277. extern char * krb4_d_instance;
  1278. extern int krb4_autoget;
  1279. extern int krb4_autodel;
  1280. extern int krb4_checkaddrs; /* Check TGT Addrs */
  1281. extern char * k4_keytab; /* Keytab file */
  1282. #ifdef KRB4
  1283. extern int k4debug;
  1284. #endif /* KRB4 */
  1285. static struct keytab krbver[] = {
  1286. "4", 4, 0,
  1287. "5", 5, 0,
  1288. "iv", 4, CM_INV,
  1289. "v", 5, CM_INV
  1290. };
  1291. static int nkrbver = sizeof(krbver)/sizeof(struct keytab);
  1292. static struct keytab kdestab[] = {
  1293. "never", KRB_DEL_NO, 0,
  1294. "no", KRB_DEL_NO, CM_INV,
  1295. "on-close", KRB_DEL_CL, 0,
  1296. "on-exit", KRB_DEL_EX, 0
  1297. };
  1298. static int nkdestab = sizeof(kdestab)/sizeof(struct keytab);
  1299. static struct keytab k4tab[] = {
  1300. "autodel", XYKRBDEL, CM_INV,
  1301. "autodestroy", XYKRBDEL, 0,
  1302. "autoget", XYKRBGET, 0,
  1303. "check-address", XYKRBADR, 0,
  1304. "debug", XYKRBDBG, CM_INV,
  1305. "instance", XYKRBINS, 0,
  1306. "keytab", XYKRBKTB, 0,
  1307. "lifetime", XYKRBLIF, 0,
  1308. "preauth", XYKRBPRE, 0,
  1309. "principal", XYKRBPR, 0,
  1310. "prompt", XYKRBPRM, 0,
  1311. "realm", XYKRBRL, 0,
  1312. "service-name", XYKRBSRV, 0
  1313. };
  1314. static int nk4tab = sizeof(k4tab)/sizeof(struct keytab);
  1315. static struct keytab k5tab[] = {
  1316. "addresses", XYKRBADD, 0,
  1317. "autodelete", XYKRBDEL, CM_INV,
  1318. "autodestroy", XYKRBDEL, 0,
  1319. "autoget", XYKRBGET, 0,
  1320. "cc", XYKRBCC, CM_INV,
  1321. "check-address", XYKRBADR, 0,
  1322. "credentials-cache", XYKRBCC, 0,
  1323. "forwardable", XYKRBFWD, 0,
  1324. "get-k4-tgt", XYKRBK5K4,0,
  1325. "instance", XYKRBINS, 0,
  1326. "keytab", XYKRBKTB, 0,
  1327. "lifetime", XYKRBLIF, 0,
  1328. "no-addresses", XYKRBNAD, 0,
  1329. "principal", XYKRBPR, 0,
  1330. "prompt", XYKRBPRM, 0,
  1331. "proxiable", XYKRBPRX, 0,
  1332. "realm", XYKRBRL, 0,
  1333. "renewable", XYKRBRNW, 0,
  1334. "service-name", XYKRBSRV, 0
  1335. };
  1336. static int nk5tab = sizeof(k5tab)/sizeof(struct keytab);
  1337. #define KRB_PW_PRM 1
  1338. #define KRB_PR_PRM 2
  1339. static struct keytab krbprmtab[] = {
  1340. "password", KRB_PW_PRM, 0,
  1341. "principal", KRB_PR_PRM, 0
  1342. };
  1343. #endif /* CK_KERBEROS */
  1344. #ifdef CK_SRP
  1345. static struct keytab srptab[] = {
  1346. "prompt", XYSRPPRM, 0
  1347. };
  1348. static int nsrptab = sizeof(srptab)/sizeof(struct keytab);
  1349. #define SRP_PW_PRM 1
  1350. static struct keytab srpprmtab[] = {
  1351. "password", SRP_PW_PRM, 0
  1352. };
  1353. #endif /* CK_SRP */
  1354. #ifdef CK_SSL
  1355. static struct keytab ssltab[] = {
  1356. "certs-ok", XYSSLCOK, CM_INV,
  1357. "cipher-list", XYSSLCL, 0,
  1358. "crl-dir", XYSSLCRLD, 0,
  1359. "crl-file", XYSSLCRL, 0,
  1360. "debug", XYSSLDBG, 0,
  1361. "dh-key-file", XYSSLDKFL, CM_INV,
  1362. "dh-param-file", XYSSLDPFL, 0,
  1363. "dsa-cert-chain-file", XYSSLDCCF, 0,
  1364. "dsa-cert-file", XYSSLDCFL, 0,
  1365. "dsa-key-file", XYSSLDKFL, 0,
  1366. "dummy", XYSSLDUM, CM_INV,
  1367. "only", XYSSLON, CM_INV,
  1368. "random-file", XYSSLRND, 0,
  1369. "rsa-cert-chain-file", XYSSLRCCF, 0,
  1370. "rsa-cert-file", XYSSLRCFL, 0,
  1371. "rsa-key-file", XYSSLRKFL, 0,
  1372. "verbose", XYSSLVRB, 0,
  1373. "verify", XYSSLVRF, 0,
  1374. "verify-dir", XYSSLVRFD, 0,
  1375. "verify-file", XYSSLVRFF, 0
  1376. };
  1377. static int nssltab = sizeof(ssltab)/sizeof(struct keytab);
  1378. static struct keytab sslvertab[] = {
  1379. "fail-if-no-peer-cert", SSL_VERIFY_PEER |
  1380. SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0,
  1381. "no", SSL_VERIFY_NONE, 0,
  1382. "none", SSL_VERIFY_NONE, CM_INV,
  1383. "off", SSL_VERIFY_NONE, CM_INV,
  1384. "on", SSL_VERIFY_PEER, CM_INV,
  1385. "peer-cert", SSL_VERIFY_PEER, 0
  1386. };
  1387. static int nsslvertab = sizeof(sslvertab)/sizeof(struct keytab);
  1388. #endif /* CK_SSL */
  1389. #endif /* CK_AUTHENTICATION */
  1390. #ifdef CK_ENCRYPTION
  1391. int cx_type = CX_AUTO;
  1392. extern int sl_cx_type;
  1393. #endif /* CK_ENCRYPTION */
  1394. extern char *tcp_address;
  1395. #ifndef NOHTTP
  1396. extern char * tcp_http_proxy;
  1397. extern char * tcp_http_proxy_user;
  1398. extern char * tcp_http_proxy_pwd;
  1399. extern char * tcp_http_proxy_agent;
  1400. #endif /* NOHTTP */
  1401. #ifdef NT
  1402. #ifdef CK_SOCKS
  1403. extern char *tcp_socks_svr;
  1404. extern char *tcp_socks_user;
  1405. #ifdef CK_SOCKS_NS
  1406. extern char *tcp_socks_ns;
  1407. #endif /* CK_SOCKS_NS */
  1408. #endif /* CK_SOCKS */
  1409. #endif /* NT */
  1410. #define UPW_USER 1
  1411. #define UPW_PASS 2
  1412. #define UPW_AGENT 3
  1413. static struct keytab userpass[] = {
  1414. { "/agent", UPW_AGENT, CM_ARG },
  1415. { "/password", UPW_PASS, CM_ARG },
  1416. { "/user", UPW_USER, CM_ARG },
  1417. };
  1418. static int nuserpass = sizeof(userpass)/sizeof(struct keytab);
  1419. static struct keytab tnnegtab[] = { /* TELNET NEGOTIATION table */
  1420. "accepted", TN_NG_AC, 0,
  1421. "refused", TN_NG_RF, 0,
  1422. "req", TN_NG_RQ, CM_INV|CM_ABR,
  1423. "requ", TN_NG_RQ, CM_INV|CM_ABR,
  1424. "reque", TN_NG_RQ, CM_INV|CM_ABR,
  1425. "reques", TN_NG_RQ, CM_INV|CM_ABR,
  1426. "request", TN_NG_RQ, CM_INV|CM_ABR,
  1427. "requeste", TN_NG_RQ, CM_INV|CM_ABR,
  1428. "requested", TN_NG_RQ, 0,
  1429. "required", TN_NG_MU, 0
  1430. };
  1431. static int ntnnegtab = sizeof(tnnegtab)/sizeof(struct keytab);
  1432. #ifdef CK_ENCRYPTION
  1433. static struct keytab typkwd[] = {
  1434. "/type", 0, CM_ARG
  1435. };
  1436. static struct keytab tnenctab[] = { /* TELNET ENCRYPTION table */
  1437. "accepted", TN_NG_AC, CM_INV,
  1438. "refused", TN_NG_RF, CM_INV,
  1439. "req", TN_NG_RQ, CM_INV|CM_ABR,
  1440. "requ", TN_NG_RQ, CM_INV|CM_ABR,
  1441. "reque", TN_NG_RQ, CM_INV|CM_ABR,
  1442. "reques", TN_NG_RQ, CM_INV|CM_ABR,
  1443. "request", TN_NG_RQ, CM_INV|CM_ABR,
  1444. "requeste", TN_NG_RQ, CM_INV|CM_ABR,
  1445. "requested", TN_NG_RQ, CM_INV,
  1446. "required", TN_NG_MU, CM_INV,
  1447. "start", TN_EN_START, CM_INV,
  1448. "stop", TN_EN_STOP, CM_INV,
  1449. "type", TN_EN_TYP, 0
  1450. };
  1451. static int ntnenc = sizeof(tnenctab)/sizeof(struct keytab) ;
  1452. #endif /* CK_ENCRYPTION */
  1453. #ifdef CK_FORWARD_X
  1454. static struct keytab tnfwdxtab[] = { /* TELNET FORWARD-X table */
  1455. "no-encryption", 1, CM_INV,
  1456. "xauthority-file", 0, 0
  1457. };
  1458. static int ntnfwdx = sizeof(tnfwdxtab)/sizeof(struct keytab) ;
  1459. #endif /* CK_FORWARD_X */
  1460. static struct keytab tnbugtab[] = { /* TELNET BUG table */
  1461. "auth-krb5-des", 4, 0,
  1462. "binary-me-means-u-too", 0, 0,
  1463. "binary-u-means-me-too", 1, 0,
  1464. "infinite-loop-check", 2, 0,
  1465. "sb-implies-will-do", 3, 0
  1466. };
  1467. #ifdef CK_ENVIRONMENT
  1468. static struct keytab tnenvtab[] = { /* TELNET ENVIRONMENT table */
  1469. "acct", TN_ENV_ACCT, 0,
  1470. "display", TN_ENV_DISP, 0,
  1471. "job", TN_ENV_JOB, 0,
  1472. "location", TN_ENV_LOC, 0,
  1473. "off", TN_ENV_OFF, CM_INV,
  1474. "on", TN_ENV_ON, CM_INV,
  1475. "printer", TN_ENV_PRNT, 0,
  1476. "systemtype",TN_ENV_SYS, 0,
  1477. "user", TN_ENV_USR, 0,
  1478. "uservar", TN_ENV_UVAR, 0,
  1479. "", 0, 0
  1480. };
  1481. static int ntnenv = sizeof(tnenvtab)/sizeof(struct keytab) - 1;
  1482. #endif /* CK_ENVIRONMENT */
  1483. #ifdef CK_AUTHENTICATION
  1484. static struct keytab tnauthtab[] = { /* TELNET AUTHENTICATION table */
  1485. "accepted", TN_NG_AC, CM_INV,
  1486. "encrypt-flag", TN_AU_ENC, 0,
  1487. "forwarding", TN_AU_FWD, 0,
  1488. "how-flag", TN_AU_HOW, 0,
  1489. "refused", TN_NG_RF, CM_INV,
  1490. "req", TN_NG_RQ, CM_INV|CM_ABR,
  1491. "requ", TN_NG_RQ, CM_INV|CM_ABR,
  1492. "reque", TN_NG_RQ, CM_INV|CM_ABR,
  1493. "reques", TN_NG_RQ, CM_INV|CM_ABR,
  1494. "request", TN_NG_RQ, CM_INV|CM_ABR,
  1495. "requeste", TN_NG_RQ, CM_INV|CM_ABR,
  1496. "requested", TN_NG_RQ, CM_INV,
  1497. "required", TN_NG_MU, CM_INV,
  1498. "type", TN_AU_TYP, 0
  1499. };
  1500. static int ntnauth = sizeof(tnauthtab)/sizeof(struct keytab) ;
  1501. struct keytab autyptab[] = { /* TELNET AUTHENTICATION TYPE table */
  1502. "automatic", AUTH_AUTO, 0,
  1503. #ifdef CK_KERBEROS
  1504. "k4", AUTH_KRB4, CM_INV,
  1505. "k5", AUTH_KRB5, CM_INV,
  1506. "kerberos4", AUTH_KRB4, 0,
  1507. "kerberos5", AUTH_KRB5, 0,
  1508. "kerberos_iv",AUTH_KRB4, CM_INV,
  1509. "kerberos_v", AUTH_KRB5, CM_INV,
  1510. "krb4", AUTH_KRB4, CM_INV,
  1511. "krb5", AUTH_KRB5, CM_INV,
  1512. #endif /* CK_KERBEROS */
  1513. "none", AUTH_NONE, 0,
  1514. #ifdef NT
  1515. "ntlm", AUTH_NTLM, 0,
  1516. #endif /* NT */
  1517. #ifdef CK_SRP
  1518. "srp", AUTH_SRP, 0,
  1519. #endif /* CK_SRP */
  1520. #ifdef CK_SSL
  1521. "ssl", AUTH_SSL, 0,
  1522. #endif /* CK_SSL */
  1523. "", 0, 0
  1524. };
  1525. int nautyp = sizeof(autyptab)/sizeof(struct keytab) - 1;
  1526. struct keytab auhowtab[] = { /* TELNET AUTHENTICATION HOW table */
  1527. "any", TN_AUTH_HOW_ANY, 0,
  1528. "mutual", TN_AUTH_HOW_MUTUAL, 0,
  1529. "one-way", TN_AUTH_HOW_ONE_WAY, 0,
  1530. "", 0, 0
  1531. };
  1532. int nauhow = sizeof(auhowtab)/sizeof(struct keytab) - 1;
  1533. struct keytab auenctab[] = { /* TELNET AUTHENTICATION ENCRYPT table */
  1534. "any", TN_AUTH_ENC_ANY, 0,
  1535. "none", TN_AUTH_ENC_NONE, 0,
  1536. "telopt", TN_AUTH_ENC_TELOPT, 0,
  1537. #ifdef CK_SSL
  1538. "tls", TN_AUTH_ENC_TLS, 0,
  1539. #endif /* CK_SSL */
  1540. "", 0, 0
  1541. };
  1542. int nauenc = sizeof(auenctab)/sizeof(struct keytab) - 1;
  1543. #endif /* CK_AUTHENTICATION */
  1544. #define TN_NL_BIN 3
  1545. #define TN_NL_NVT 4
  1546. static struct keytab tn_nlmtab[] = { /* TELNET NEWLINE-MODE table */
  1547. "binary-mode", TN_NL_BIN, 0, /* Binary mode */
  1548. "nvt", TN_NL_NVT, 0, /* NVT mode */
  1549. "off", TNL_CRNUL, CM_INV, /* CR-NUL (TELNET spec) */
  1550. "on", TNL_CRLF, CM_INV, /* CR-LF (TELNET spec) */
  1551. "raw", TNL_CR, CM_INV /* CR only (out of spec) */
  1552. };
  1553. static int ntn_nlm = (sizeof(tn_nlmtab) / sizeof(struct keytab));
  1554. static struct keytab tnlmtab[] = { /* TELNET NEWLINE-MODE table */
  1555. "cr", TNL_CR, CM_INV, /* CR only (out of spec) */
  1556. "cr-lf", TNL_CRLF, CM_INV, /* CR-LF (TELNET spec) */
  1557. "cr-nul", TNL_CRNUL, CM_INV, /* CR-NUL (TELNET spec) */
  1558. "lf", TNL_LF, CM_INV, /* LF instead of CR-LF */
  1559. "off", TNL_CRNUL, 0, /* CR-NUL (TELNET spec) */
  1560. "on", TNL_CRLF, 0, /* CR-LF (TELNET spec) */
  1561. "raw", TNL_CR, 0 /* CR only (out of spec) */
  1562. };
  1563. static int ntnlm = (sizeof(tnlmtab) / sizeof(struct keytab));
  1564. struct keytab tntab[] = {
  1565. #ifdef CK_AUTHENTICATION
  1566. "authentication", CK_TN_AU, 0,
  1567. #endif /* CK_AUTHENTICATION */
  1568. "b", CK_TN_BM, CM_INV|CM_ABR,
  1569. "bi", CK_TN_BM, CM_INV|CM_ABR,
  1570. "bin", CK_TN_BM, CM_INV|CM_ABR,
  1571. "bina", CK_TN_BM, CM_INV|CM_ABR,
  1572. "binar", CK_TN_BM, CM_INV|CM_ABR,
  1573. "binary", CK_TN_BM, CM_INV|CM_ABR,
  1574. "binary-", CK_TN_BM, CM_INV|CM_ABR,
  1575. "binary-mode", CK_TN_BM, CM_INV,
  1576. "binary-transfer-mode", CK_TN_XF, 0,
  1577. "binary-xfer-mode", CK_TN_XF, CM_INV,
  1578. "bug", CK_TN_BUG, 0,
  1579. "debug", CK_TN_DB, 0,
  1580. "delay-sb", CK_TN_DL, 0,
  1581. "echo", CK_TN_EC, 0,
  1582. #ifdef CK_ENCRYPTION
  1583. "encryption", CK_TN_ENC, 0,
  1584. #endif /* CK_ENCRYPTION */
  1585. #ifdef CK_ENVIRONMENT
  1586. "environment", CK_TN_ENV, 0,
  1587. #endif /* CK_ENVIRONMENT */
  1588. #ifdef CK_FORWARD_X
  1589. "forward-x", CK_TN_FX, 0,
  1590. #endif /* CK_FORWARD_X */
  1591. #ifdef IKS_OPTION
  1592. "kermit", CK_TN_IKS, CM_INV,
  1593. #endif /* IKS_OPTION */
  1594. #ifdef CK_SNDLOC
  1595. "location", CK_TN_LOC, 0,
  1596. #endif /* CK_SNDLOC */
  1597. #ifdef CK_NAWS
  1598. "naws", CK_TN_NAWS, CM_INV,
  1599. #endif /* CK_NAWS */
  1600. "newline-mode", CK_TN_NL, 0,
  1601. "no-encrypt-during-xfer", CK_TN_NE, CM_INV,
  1602. "prompt-for-userid",CK_TN_PUID,0,
  1603. "remote-echo", CK_TN_RE, 0,
  1604. #ifdef CK_SSL
  1605. "start-tls", CK_TN_TLS, CM_INV,
  1606. #endif /* CK_SSL */
  1607. #ifdef NT
  1608. "sfu-compatibility", CK_TN_SFU, 0,
  1609. #else
  1610. "sfu-compatibility", CK_TN_SFU, CM_INV,
  1611. #endif /* NT */
  1612. "terminal-type", CK_TN_TT, 0,
  1613. "wait-for-negotiations", CK_TN_WAIT, 0,
  1614. #ifdef CK_ENVIRONMENT
  1615. "xdisplay-location",CK_TN_XD, CM_INV,
  1616. #endif /* CK_ENVIRONMENT */
  1617. "", 0, 0
  1618. };
  1619. int ntn = (sizeof(tntab) / sizeof(struct keytab)) - 1;
  1620. struct keytab tnopttab[] = {
  1621. #ifdef CK_AUTHENTICATION
  1622. "authentication", CK_TN_AU, 0,
  1623. #else
  1624. "authentication", CK_TN_AU, CM_INV,
  1625. #endif /* CK_AUTHENTICATION */
  1626. "binary-mode", CK_TN_BM, 0,
  1627. #ifdef TN_COMPORT
  1628. "c", CK_TN_CPC, CM_INV|CM_ABR,
  1629. "co", CK_TN_CPC, CM_INV|CM_ABR,
  1630. "com", CK_TN_CPC, CM_INV|CM_ABR,
  1631. "com-port-control",CK_TN_CPC, 0,
  1632. "comport-control", CK_TN_CPC, CM_INV,
  1633. #else /* TN_COMPORT */
  1634. "com-port-control",CK_TN_CPC, CM_INV,
  1635. "comport-control", CK_TN_CPC, CM_INV,
  1636. #endif /* TN_COMPORT */
  1637. "echo", CK_TN_EC, 0,
  1638. #ifdef CK_ENCRYPTION
  1639. "encryption", CK_TN_ENC, 0,
  1640. #else
  1641. "encryption", CK_TN_ENC, CM_INV,
  1642. #endif /* CK_ENCRYPTION */
  1643. #ifdef CK_FORWARD_X
  1644. "forward-x", CK_TN_FX, 0,
  1645. #else /* CK_FORWARD_X */
  1646. "forward-x", CK_TN_FX, CM_INV,
  1647. #endif /* CK_FORWARD_X */
  1648. "ibm-sak", CK_TN_SAK, CM_INV,
  1649. #ifdef IKS_OPTION
  1650. "kermit", CK_TN_IKS, 0,
  1651. #else
  1652. "kermit", CK_TN_IKS, CM_INV,
  1653. #endif /* IKS_OPTION */
  1654. "lflow", CK_TN_FLW, CM_INV,
  1655. "logout", CK_TN_LOG, 0,
  1656. #ifdef CK_NAWS
  1657. "naws", CK_TN_NAWS, 0,
  1658. #else
  1659. "naws", CK_TN_NAWS, CM_INV,
  1660. #endif /* CK_NAWS */
  1661. #ifdef CK_ENVIRONMENT
  1662. "new-environment", CK_TN_ENV, 0,
  1663. #else
  1664. "new-environment", CK_TN_ENV, CM_INV,
  1665. #endif /* CK_ENVIRONMENT */
  1666. "pragma-heartbeat",CK_TN_PHR, CM_INV,
  1667. "pragma-logon", CK_TN_PLG, CM_INV,
  1668. "pragma-sspi", CK_TN_PSP, CM_INV,
  1669. "sak", CK_TN_SAK, CM_INV,
  1670. #ifdef CK_SNDLOC
  1671. "send-location", CK_TN_LOC, 0,
  1672. #else
  1673. "send-location", CK_TN_LOC, CM_INV,
  1674. #endif /* CK_SNDLOC */
  1675. "sga", CK_TN_SGA, CM_INV|CM_ABR,
  1676. #ifdef CK_SSL
  1677. "start-tls", CK_TN_TLS, 0,
  1678. #else
  1679. "start-tls", CK_TN_TLS, CM_INV,
  1680. #endif /* CK_SSL */
  1681. "suppress-go-aheads", CK_TN_SGA, 0,
  1682. "terminal-type", CK_TN_TT, 0,
  1683. "ttype", CK_TN_TT, CM_INV|CM_ABR,
  1684. #ifdef CK_ENVIRONMENT
  1685. "xdisplay-location", CK_TN_XD, 0,
  1686. #else
  1687. "xdisplay-location", CK_TN_XD, CM_INV,
  1688. #endif /* CK_ENVIRONMENT */
  1689. "", 0, 0
  1690. };
  1691. int ntnopt = (sizeof(tnopttab) / sizeof(struct keytab)) - 1;
  1692. struct keytab tnoptsw[] = {
  1693. "/client", CK_TN_CLIENT, 0,
  1694. "/server", CK_TN_SERVER, 0
  1695. };
  1696. int ntnoptsw = (sizeof(tnoptsw) / sizeof(struct keytab));
  1697. #endif /* TNCODE */
  1698. struct keytab ftrtab[] = { /* Feature table */
  1699. #ifndef NOCSETS /* 0 = we have it, 1 = we don't */
  1700. "character-sets", 0, 0,
  1701. #else
  1702. "character-sets", 1, 0,
  1703. #endif /* NOCSETS */
  1704. #ifndef NOCYRIL
  1705. "cyrillic", 0, 0,
  1706. #else
  1707. "cyrillic", 1, 0,
  1708. #endif /* NOCYRIL */
  1709. #ifndef NOLOGDIAL
  1710. "cx-log", 0, 0,
  1711. #else
  1712. "cx-log", 1, 0,
  1713. #endif /* NOLOGDIAL */
  1714. #ifndef NODEBUG
  1715. "debug", 0, 0,
  1716. #else
  1717. "debug", 1, 0,
  1718. #endif /* NODEBUG */
  1719. #ifndef NODIAL
  1720. "dial", 0, 0,
  1721. #else
  1722. "dial", 1, 0,
  1723. #endif /* NODIAL */
  1724. #ifdef DYNAMIC
  1725. "dynamic-memory", 0, 0,
  1726. #else
  1727. "dynamic-memory", 1, 0,
  1728. #endif /* DYNAMIC */
  1729. #ifndef NOXFER
  1730. "file-transfer", 0, 0,
  1731. #else
  1732. "file-transfer", 1, 0,
  1733. #endif /* NOXFER */
  1734. #ifdef XXFWD
  1735. "forward", 0, 0,
  1736. #else
  1737. "forward", 1, 0,
  1738. #endif /* XXFWD */
  1739. #ifdef NEWFTP
  1740. "ftp", 0, 0,
  1741. #else
  1742. "ftp", 1, 0,
  1743. #endif /* NEWFTP */
  1744. #ifdef CK_CURSES
  1745. "fullscreen-display", 0, 0,
  1746. #else
  1747. "fullscreen-display", 1, 0,
  1748. #endif /* CK_CURSES */
  1749. #ifdef GREEK
  1750. "greek", 0, 0,
  1751. #else
  1752. "greek", 1, 0,
  1753. #endif /* GREEK */
  1754. #ifdef HEBREW
  1755. "hebrew", 0, 0,
  1756. #else
  1757. "hebrew", 1, 0,
  1758. #endif /* HEBREW */
  1759. #ifndef NOHELP
  1760. "help", 0, 0,
  1761. #else
  1762. "help", 1, 0,
  1763. #endif /* NOHELP */
  1764. #ifndef NOIKSD
  1765. "iksd", 0, 0,
  1766. #else
  1767. "iksd", 1, 0,
  1768. #endif /* NOIKSD */
  1769. #ifndef NOSPL
  1770. "if-command", 0, 0,
  1771. #else
  1772. "if-command", 1, 0,
  1773. #endif /* NOSPL */
  1774. #ifndef NOJC
  1775. #ifdef UNIX
  1776. "job-control", 0, 0,
  1777. #else
  1778. "job-control", 1, 0,
  1779. #endif /* UNIX */
  1780. #else
  1781. "job-control", 1, 0,
  1782. #endif /* NOJC */
  1783. #ifdef KANJI
  1784. "kanji", 0, 0,
  1785. #else
  1786. "kanji", 1, 0,
  1787. #endif /* KANJI */
  1788. #ifndef NOXFER
  1789. "kermit", 0, 0,
  1790. #else
  1791. "kermit", 1, 0,
  1792. #endif /* NOXFER */
  1793. #ifdef CK_KERBEROS
  1794. "kerberos", 0, 0,
  1795. #else
  1796. "kerberos", 1, 0,
  1797. #endif /* CK_KERBEROS */
  1798. #ifndef NOCSETS
  1799. "latin1", 0, 0,
  1800. #else
  1801. "latin1", 1, 0,
  1802. #endif /* NOCSETS */
  1803. #ifdef LATIN2
  1804. "latin2", 0, 0,
  1805. #else
  1806. "latin2", 1, 0,
  1807. #endif /* LATIN2 */
  1808. #ifdef CKLEARN
  1809. "learned-scripts", 0, 0,
  1810. #else
  1811. "learned-scripts", 1, 0,
  1812. #endif /* CKLEARN */
  1813. #ifdef HAVE_LOCALE
  1814. "locale", 0, 0,
  1815. #else
  1816. "locale", 1, 0,
  1817. #endif /* HAVE_LOCALE */
  1818. #ifndef NOLOCAL
  1819. "making-connections", 0, 0,
  1820. #else
  1821. "making-connections", 1, 0,
  1822. #endif /* NOLOCAL */
  1823. #ifdef NETCONN
  1824. "network", 0, 0,
  1825. #else
  1826. "network", 1, 0,
  1827. #endif /* NETCONN */
  1828. #ifdef NT
  1829. #ifdef CK_AUTHENTICATION
  1830. "ntlm", 1, 0,
  1831. #else /* CK_AUTHENTICATION */
  1832. "ntlm", 0, 0,
  1833. #endif /* CK_AUTHENTICATION */
  1834. #else /* NT */
  1835. "ntlm", 0, 0,
  1836. #endif /* NT */
  1837. #ifdef PIPESEND
  1838. "pipes", 0, 0,
  1839. #else
  1840. #ifdef NETCMD
  1841. "pipes", 0, 0,
  1842. #endif /* NETCMD */
  1843. #endif /* PIPESEND */
  1844. #ifndef PIPESEND
  1845. #ifndef NETCMD
  1846. "pipes", 1, 0,
  1847. #endif /* PIPESEND */
  1848. #endif /* NETCMD */
  1849. #ifdef NETPTY
  1850. "pty", 0, 0,
  1851. #else
  1852. "pty", 1, 0,
  1853. #endif /* NETPTY */
  1854. #ifndef NOPUSH
  1855. "push", 0, 0,
  1856. #else
  1857. "push", 1, 0,
  1858. #endif /* PUSH */
  1859. #ifdef CK_REDIR
  1860. "redirect", 0, 0,
  1861. #else
  1862. "redirect", 1, 0,
  1863. #endif /* CK_REDIR */
  1864. #ifdef CK_RTSCTS
  1865. "rts/cts", 0, 0,
  1866. #else
  1867. "rts/cts", 1, 0,
  1868. #endif /* RTS/CTS */
  1869. #ifndef NOSCRIPT
  1870. "script-command", 0, 0,
  1871. #else
  1872. "script-command", 1, 0,
  1873. #endif /* NOSCRIPT */
  1874. #ifndef NOSERVER
  1875. "server-mode", 0, 0,
  1876. #else
  1877. "server-mode", 1, 0,
  1878. #endif /* NOSERVER */
  1879. #ifndef NOSEXP
  1880. "sexpression", 0, 0,
  1881. #else
  1882. "sexpression", 1, 0,
  1883. #endif /* NOSEXP */
  1884. #ifdef SFTP_BUILTIN
  1885. "sftp", 1, 0,
  1886. #else
  1887. "sftp", 0, 0,
  1888. #endif /* SFTP_BUILTIN */
  1889. #ifndef NOSHOW
  1890. "show-command", 0, 0,
  1891. #else
  1892. "show-command", 1, 0,
  1893. #endif /* NOSHOW */
  1894. #ifdef CK_SRP
  1895. "srp", 0, 0,
  1896. #else
  1897. "srp", 1, 0,
  1898. #endif /* CK_SRP */
  1899. #ifdef SSHBUILTIN
  1900. "ssh", 0, 0,
  1901. #else /* SSHBUILTIN */
  1902. "ssh", 1, 0,
  1903. #endif /* SSHBUILTIN */
  1904. #ifdef CK_SSL
  1905. "ssl/tls", 0, 0,
  1906. #else
  1907. "ssl/tls", 1, 0,
  1908. #endif /* CK_SSL */
  1909. #ifndef NOXMIT
  1910. "transmit", 0, 0,
  1911. #else
  1912. "transmit", 1, 0,
  1913. #endif /* NOXMIT */
  1914. #ifdef UNICODE
  1915. "unicode", 0, 0,
  1916. #else
  1917. "unicode", 1, 0,
  1918. #endif /* UNICODE */
  1919. #ifdef CK_XYZ
  1920. "xyzmodem", 0, 0,
  1921. #else
  1922. "xyzmodem", 1, 0,
  1923. #endif /* CK_XYZ */
  1924. "", 0, 0
  1925. };
  1926. int nftr = (sizeof(ftrtab) / sizeof(struct keytab)) - 1;
  1927. struct keytab desttab[] = { /* SET DESTINATION */
  1928. #ifdef CALIBRATE
  1929. "calibrate", DEST_N, CM_INV,
  1930. #endif /* CALIBRATE */
  1931. "disk", DEST_D, 0,
  1932. #ifdef CALIBRATE
  1933. "nowhere", DEST_N, 0,
  1934. #endif /* CALIBRATE */
  1935. "printer", DEST_P, 0,
  1936. "screen", DEST_S, 0
  1937. };
  1938. int ndests = (sizeof(desttab) / sizeof(struct keytab));
  1939. #ifndef NOSPL /* Used only with script programming items... */
  1940. #ifndef NOSERVER /* This is just to avoid some */
  1941. #define CK_PARSDIR /* "statement not reached" */
  1942. #else /* complaints... */
  1943. #ifndef NODIAL
  1944. #define CK_PARSDIR
  1945. #endif /* NODIAL */
  1946. #endif /* NOSERVER */
  1947. /*
  1948. cx == 0 means dial directory
  1949. cx == 1 means network directory
  1950. cx == 2 means a directory path list
  1951. */
  1952. static int
  1953. parsdir(cx) int cx; {
  1954. int i, x, y, dd; /* Workers */
  1955. int nxdir;
  1956. char *s;
  1957. char ** xdir;
  1958. char *pp[MAXGETPATH]; /* Temporary name pointers */
  1959. #ifdef ZFNQFP
  1960. struct zfnfp * fnp;
  1961. #ifdef OS2
  1962. char * env;
  1963. char dirpath[4096];
  1964. #else /* OS2 */
  1965. char dirpath[1024]; /* For fully qualified filenames */
  1966. #endif /* OS2 */
  1967. #endif /* ZFNQFP */
  1968. int max = 0; /* Maximum number of things to parse */
  1969. char c;
  1970. #ifndef NODIAL
  1971. if (cx == 0) { /* Dialing */
  1972. nxdir = ndialdir;
  1973. xdir = dialdir;
  1974. max = MAXDDIR;
  1975. } else
  1976. #ifdef NETCONN
  1977. if (cx == 1) { /* Network */
  1978. nxdir = nnetdir;
  1979. xdir = netdir;
  1980. max = MAXDDIR;
  1981. } else
  1982. #endif /* NETCONN */
  1983. #endif /* NODIAL */
  1984. #ifndef NOSERVER
  1985. if (cx == 2) { /* GET path */
  1986. nxdir = ngetpath;
  1987. xdir = getpath;
  1988. max = MAXGETPATH;
  1989. } else /* Called with invalid function code */
  1990. #endif /* NOSERVER */
  1991. return(-2);
  1992. for (i = 0; i < MAXGETPATH; i++) /* Init these. */
  1993. pp[i] = NULL;
  1994. #ifdef CK_PARSDIR
  1995. dd = 0; /* Temporary name counter */
  1996. while (1) {
  1997. if (cx != 2) { /* Dialing or Network Directory */
  1998. #ifdef OS2
  1999. int len;
  2000. char * appdata0 = NULL, * appdata1 = NULL;
  2001. #ifdef NT
  2002. env = getenv("K95PHONES");
  2003. makestr(&appdata0,(char *)GetAppData(0));
  2004. makestr(&appdata1,(char *)GetAppData(1));
  2005. #else /* NT */
  2006. env = getenv("K2PHONES");
  2007. #endif /* NT */
  2008. if (!env)
  2009. env = getenv("K95PHONES");
  2010. if (!env)
  2011. env = "";
  2012. dirpath[0] = '\0';
  2013. len = strlen(env) + 2*strlen(startupdir) + 2*strlen(inidir)
  2014. + (appdata0?2*strlen(appdata0):0)
  2015. + (appdata1?2*strlen(appdata1):0)
  2016. + 2*strlen(zhome()) + 2*strlen(exedir) + 8*strlen("PHONES/")
  2017. + 12;
  2018. if (len < 4096) /* SAFE */
  2019. sprintf(dirpath,
  2020. "%s%s%s;%s%s;%s%s%s%s%s%s%s%s%s;%s%s;%s;%s%s",
  2021. /* Semicolon-separated path list */
  2022. env,
  2023. (env[0] && env[strlen(env)-1] == ';') ? "" : ";",
  2024. startupdir,
  2025. startupdir, "PHONES/",
  2026. appdata1 ? appdata1 : "",
  2027. appdata1 ? "Kermit 95;" : "",
  2028. appdata1 ? appdata1 : "",
  2029. appdata1 ? "Kermit 95/PHONES/;" : "",
  2030. appdata0 ? appdata0 : "",
  2031. appdata0 ? "Kermit 95;" : "",
  2032. appdata0 ? appdata0 : "",
  2033. appdata0 ? "Kermit 95/PHONES/;" : "",
  2034. inidir,
  2035. inidir, "PHONES/",
  2036. zhome(),
  2037. zhome(), "PHONES/",
  2038. exedir,
  2039. exedir, "PHONES/"
  2040. );
  2041. #ifdef NT
  2042. makestr(&appdata0,NULL);
  2043. makestr(&appdata1,NULL);
  2044. #endif /* NT */
  2045. #else
  2046. #ifdef UNIX
  2047. y = 1024;
  2048. s = dirpath;
  2049. zzstring("\\v(home)",&s,&y);
  2050. #endif /* UNIX */
  2051. #endif /* OS2 */
  2052. y = cmifip(
  2053. "Names of one or more directory files, separated by spaces",
  2054. "",&s,&x,0,
  2055. #ifdef OS2ORUNIX
  2056. dirpath,
  2057. #else
  2058. NULL,
  2059. #endif /* OS2ORUNIX */
  2060. xxstring
  2061. );
  2062. } else { /* List of directory names */
  2063. x = 0;
  2064. y = cmdir("Directory name","",&s,xxstring);
  2065. }
  2066. if (y < 0) {
  2067. if (y == -3) { /* EOL or user typed <CR> */
  2068. if ((y = cmcfm()) < 0) return(y);
  2069. for (i = 0; i < max; i++) { /* Clear these */
  2070. if (i < nxdir && xdir[i]) {
  2071. free(xdir[i]);
  2072. }
  2073. xdir[i] = (i < dd) ? pp[i] : NULL;
  2074. }
  2075. #ifndef NODIAL
  2076. if (cx == 0)
  2077. ndialdir = dd;
  2078. #ifdef NETCONN
  2079. if (cx == 1)
  2080. nnetdir = dd;
  2081. #endif /* NETCONN */
  2082. #endif /* NODIAL */
  2083. #ifndef NOSERVER
  2084. if (cx == 2)
  2085. ngetpath = dd;
  2086. #endif /* NOSERVER */
  2087. return(success = 1);
  2088. } else { /* Parse error */
  2089. for (i = 0; i < dd; i++) { /* Free temp storage */
  2090. if (pp[i]) free(pp[i]); /* but don't change */
  2091. pp[i] = NULL; /* anything else */
  2092. }
  2093. return(y);
  2094. }
  2095. }
  2096. if (x) {
  2097. printf("?Wildcards not allowed\n");
  2098. return(-9);
  2099. }
  2100. #ifdef CK_TMPDIR
  2101. if (cx == 2 && !isdir(s)) {
  2102. printf("?Not a directory - %s\n", s);
  2103. return(-9);
  2104. }
  2105. #endif /* CK_TMPDIR */
  2106. #ifdef ZFNQFP
  2107. if (cx < 2) {
  2108. if (!isabsolute(s)) { /* If not relative get full path */
  2109. if ((fnp = zfnqfp(s,TMPBUFSIZ - 1,tmpbuf))) {
  2110. if (fnp->fpath)
  2111. if ((int) strlen(fnp->fpath) > 0)
  2112. s = fnp->fpath;
  2113. }
  2114. }
  2115. }
  2116. #endif /* ZFNQFP */
  2117. c = NUL;
  2118. x = strlen(s);
  2119. if (x > 0) /* Get last char */
  2120. c = s[x-1];
  2121. debug(F000,"parsdir s",s,c);
  2122. if ((pp[dd] = malloc(strlen(s)+2)) == NULL) {
  2123. printf("?Internal error - malloc\n");
  2124. for (i = 0; i < dd; i++) { /* Free temp storage */
  2125. if (pp[i]) free(pp[i]);
  2126. pp[i] = NULL;
  2127. }
  2128. return(-9);
  2129. } else { /* Have storage for name */
  2130. strcpy(pp[dd],s); /* Copy string into new storage */
  2131. debug(F111,"parsdir pp[dd] 1",pp[dd],dd);
  2132. #ifndef NOXFER
  2133. if (cx == 2) { /* If we are parsing directories */
  2134. char dirsep[2];
  2135. extern int myindex; /* Append directory separator if */
  2136. extern struct sysdata sysidlist[]; /* it is missing... */
  2137. debug(F101,"parsdir myindex","",myindex);
  2138. if (myindex > -1)
  2139. if (sysidlist[myindex].sid_unixlike)
  2140. if (c != sysidlist[myindex].sid_dirsep) {
  2141. dirsep[0] = sysidlist[myindex].sid_dirsep;
  2142. dirsep[1] = NUL;
  2143. strcat(pp[dd], (char *) dirsep); /* safe */
  2144. }
  2145. }
  2146. #endif /* NOXFER */
  2147. debug(F111,"parsdir pp[dd] 2",pp[dd],dd);
  2148. if (++dd > max) {
  2149. printf("?Too many directories - %d max\n", max);
  2150. for (i = 0; i < dd; i++) { /* Free temp storage */
  2151. if (pp[i]) free(pp[i]);
  2152. pp[i] = NULL;
  2153. }
  2154. }
  2155. }
  2156. }
  2157. #endif /* CK_PARSDIR */
  2158. }
  2159. #endif /* NOSPL */
  2160. #ifndef NOSERVER
  2161. static int
  2162. cklogin() {
  2163. int x;
  2164. char * s;
  2165. char username[LOGINLEN+1];
  2166. char password[LOGINLEN+1];
  2167. char account[LOGINLEN+1];
  2168. extern char * x_user, * x_passwd, * x_acct;
  2169. extern int x_login, x_logged;
  2170. username[0] = NUL;
  2171. password[0] = NUL;
  2172. account[0] = NUL;
  2173. x = cmfld("username", "", &s, xxstring);
  2174. if (x != -3) {
  2175. if (x < 0)
  2176. return(x);
  2177. if ((int)strlen(s) > LOGINLEN) {
  2178. printf("\"%s\" - too long, %d max\n", s, LOGINLEN);
  2179. return(-9);
  2180. }
  2181. ckstrncpy(username,s,LOGINLEN+1);
  2182. x = cmfld("password", "", &s, xxstring);
  2183. if (x != -3) {
  2184. if (x < 0)
  2185. return(x);
  2186. if ((int)strlen(s) > LOGINLEN) {
  2187. printf("\"%s\" - too long, %d max\n", s, LOGINLEN);
  2188. return(-9);
  2189. }
  2190. ckstrncpy(password,s,LOGINLEN+1);
  2191. x = cmfld("account", "", &s, xxstring);
  2192. if (x != -3) {
  2193. if (x < 0)
  2194. return(x);
  2195. if ((int)strlen(s) > LOGINLEN) {
  2196. printf("\"%s\" - too long, %d max\n", s, LOGINLEN);
  2197. return(-9);
  2198. }
  2199. ckstrncpy(account,s,LOGINLEN+1);
  2200. if ((x = cmcfm()) < 0)
  2201. return(x);
  2202. }
  2203. }
  2204. }
  2205. makestr(&x_user,username);
  2206. makestr(&x_passwd,password);
  2207. makestr(&x_acct,account);
  2208. x_login = (x_user) ? 1 : 0;
  2209. x_logged = 0;
  2210. return(1);
  2211. }
  2212. #endif /* NOSERVER */
  2213. #ifndef NOLOCAL
  2214. static int
  2215. setdcd() {
  2216. int x, y, z = 0;
  2217. if ((y = cmkey(crrtab,ncrr,"","automatic",xxstring)) < 0) return(y);
  2218. if (y == CAR_ON) {
  2219. x = cmnum("Carrier wait timeout, seconds","0",10,&z,xxstring);
  2220. if (x < 0) return(x);
  2221. }
  2222. if ((x = cmcfm()) < 0) return(x);
  2223. carrier = ttscarr(y);
  2224. cdtimo = z;
  2225. return(1);
  2226. }
  2227. #endif /* NOLOCAL */
  2228. extern struct keytab yesno[];
  2229. extern int nyesno;
  2230. /* g e t y e s n o */
  2231. static struct keytab q0yesno[] = { /* Yes/No/Quit keyword table */
  2232. "no", 0, 0,
  2233. "ok", 1, 0,
  2234. "yes", 1, 0
  2235. };
  2236. static int nq0yesno = (sizeof(q0yesno) / sizeof(struct keytab));
  2237. static struct keytab q1yesno[] = { /* Yes/No/Quit keyword table */
  2238. "no", 0, 0,
  2239. "ok", 1, 0,
  2240. "quit", 2, 0,
  2241. "yes", 1, 0
  2242. };
  2243. static int nq1yesno = (sizeof(q1yesno) / sizeof(struct keytab));
  2244. static struct keytab q2yesno[] = { /* Yes/No/Quit keyword table */
  2245. "go", 3, 0,
  2246. "no", 0, 0,
  2247. "ok", 1, 0,
  2248. "yes", 1, 0
  2249. };
  2250. static int nq2yesno = (sizeof(q2yesno) / sizeof(struct keytab));
  2251. static struct keytab q3yesno[] = { /* Yes/No/Quit keyword table */
  2252. "go", 3, 0,
  2253. "no", 0, 0,
  2254. "ok", 1, 0,
  2255. "quit", 2, 0,
  2256. "yes", 1, 0
  2257. };
  2258. static int nq3yesno = (sizeof(q3yesno) / sizeof(struct keytab));
  2259. /* Ask question, get yes/no answer */
  2260. int
  2261. getyesno(msg, flags) char * msg; int flags; {
  2262. #ifdef CK_RECALL
  2263. extern int on_recall; /* around Password prompting */
  2264. #endif /* CK_RECALL */
  2265. int y, z;
  2266. #ifndef NOLOCAL
  2267. #ifdef OS2
  2268. extern BYTE vmode;
  2269. extern int win95_popup, startflags;
  2270. int vmode_sav = vmode;
  2271. #endif /* OS2 */
  2272. #endif /* NOLOCAL */
  2273. #ifdef CK_APC
  2274. if ( apcactive != APC_INACTIVE && (apcstatus & APC_NOINP) ) {
  2275. return(success = 0);
  2276. }
  2277. #endif /* CK_APC */
  2278. #ifndef NOLOCAL
  2279. #ifdef OS2
  2280. #ifdef COMMENT
  2281. if (win95_popup && !(startflags & 96)
  2282. #ifdef IKSD
  2283. && !inserver
  2284. #endif /* IKSD */
  2285. )
  2286. return(popup_readyesno(vmode,NULL,msg,flags));
  2287. #endif /* COMMENT */
  2288. if (vmode == VTERM) {
  2289. vmode = VCMD;
  2290. VscrnIsDirty(VTERM);
  2291. VscrnIsDirty(VCMD);
  2292. }
  2293. #endif /* OS2 */
  2294. #endif /* NOLOCAL */
  2295. #ifdef VMS
  2296. /*
  2297. In VMS, whenever a TAKE file or macro is active, we restore the
  2298. original console modes so Ctrl-C/Ctrl-Y can work. But here we
  2299. go interactive again, so we have to temporarily put them back.
  2300. */
  2301. if (!xcmdsrc)
  2302. concb((char)escape);
  2303. #endif /* VMS */
  2304. #ifdef CK_RECALL
  2305. on_recall = 0;
  2306. #endif /* CK_RECALL */
  2307. cmsavp(psave,PROMPTL); /* Save old prompt */
  2308. cmsetp(msg); /* Make new prompt */
  2309. z = 0; /* Initialize answer to No. */
  2310. cmini(ckxech); /* Initialize parser. */
  2311. do {
  2312. prompt(NULL); /* Issue prompt. */
  2313. switch (flags) {
  2314. case 0: y = cmkey(q0yesno,nq0yesno,"","",NULL); break;
  2315. case 1: y = cmkey(q1yesno,nq1yesno,"","",NULL); break;
  2316. case 2: y = cmkey(q2yesno,nq2yesno,"","",NULL); break;
  2317. default: y = cmkey(q3yesno,nq3yesno,"","",NULL);
  2318. }
  2319. if (y < 0) {
  2320. if (y == -4) { /* EOF */
  2321. z = y;
  2322. break;
  2323. } else if (y == -3) /* No answer? */
  2324. printf(" Please respond; type '?' to see valid answers.\n");
  2325. cmini(ckxech);
  2326. } else {
  2327. z = y; /* Save answer */
  2328. y = cmcfm(); /* Get confirmation */
  2329. }
  2330. } while (y < 0); /* Continue till done */
  2331. cmsetp(psave); /* Restore real prompt */
  2332. #ifdef VMS
  2333. if (cmdlvl > 0) /* In VMS and not at top level, */
  2334. conres(); /* restore console again. */
  2335. #endif /* VMS */
  2336. #ifndef NOLOCAL
  2337. #ifdef OS2
  2338. if (vmode != vmode_sav) {
  2339. vmode = VTERM;
  2340. VscrnIsDirty(VCMD);
  2341. VscrnIsDirty(VTERM);
  2342. }
  2343. #endif /* OS2 */
  2344. #endif /* NOLOCAL */
  2345. return(z);
  2346. }
  2347. #ifdef KUI
  2348. extern HWND hwndConsole;
  2349. _PROTOTYP(int gui_txt_dialog,(char *,char *,int,char *,int,char *,int));
  2350. _PROTOTYP(int gui_mtxt_dialog,(char *,int,struct txtbox []));
  2351. _PROTOTYP(int gui_position,(int, int));
  2352. _PROTOTYP(int gui_resize_mode,(int));
  2353. _PROTOTYP(int gui_win_run_mode,(int));
  2354. _PROTOTYP(int gui_saveas_dialog,(char *,char *, int, char *, char *, int));
  2355. extern int gui_dialog;
  2356. #endif /* KUI */
  2357. /* u q _ o k -- User Query, get Yes/No or OK Cancel */
  2358. /*
  2359. Call with:
  2360. preface: Explanatory text to print, or NULL.
  2361. prompt: Prompt.
  2362. mask: Bitmask for legal responses: 1 = OK or Yes; 2 = No or Cancel.
  2363. help: Help text (array of strings or NULL) [not used by parser].
  2364. dflt: Default response (1 or 2) [not used by parser].
  2365. Returns:
  2366. -1: Invalid argument(s).
  2367. 0: User said No or Cancel.
  2368. 1 User said Yes or OK.
  2369. Notes:
  2370. preface and prompt should not include final line terminator but may
  2371. include embedded ones. Help text is in case GUI dialog needs a Help
  2372. button; final element of help-string array is "". dflt is used by GUI
  2373. to highlight the default response button.
  2374. */
  2375. int
  2376. #ifdef CK_ANSIC
  2377. uq_ok(char * preface, char * prompt, int mask,char ** help, int dflt)
  2378. #else /* CK_ANSIC */
  2379. uq_ok(preface,prompt,mask,help,dflt)
  2380. char * preface, * prompt, ** help;
  2381. int mask, dflt;
  2382. #endif /* CK_ANSIC */
  2383. /* uq_ok */ {
  2384. int rc, len;
  2385. char * text=NULL;
  2386. if (!prompt)
  2387. return(-1);
  2388. if ((mask & 3) == 1) { /* OK (GUI only) */
  2389. #ifdef KUI
  2390. if ( gui_dialog ) {
  2391. /* This one is for popup help, alerts, etc */
  2392. if (preface) {
  2393. len = strlen(preface) + strlen(prompt) + 4;
  2394. text = (char *)malloc(len);
  2395. ckmakmsg(text,len,preface,"\n",prompt,NULL);
  2396. }
  2397. rc = MessageBox(hwndConsole,
  2398. text ? text : prompt,
  2399. prompt,
  2400. MB_OK | MB_ICONINFORMATION | MB_TASKMODAL);
  2401. ShowWindowAsync(hwndConsole,SW_SHOWNORMAL);
  2402. SetForegroundWindow(hwndConsole);
  2403. if (text)
  2404. free(text);
  2405. if (!rc)
  2406. return(-1);
  2407. else
  2408. return(1);
  2409. } else
  2410. #endif /* KUI */
  2411. {
  2412. if (preface) /* Just display the text, if any */
  2413. printf("%s\n",preface);
  2414. if (prompt)
  2415. printf("%s\n",prompt);
  2416. return(1);
  2417. }
  2418. } else if ((mask & 3) == 3) { /* Yes/No or OK/Cancel */
  2419. #ifdef KUI
  2420. if ( gui_dialog ) {
  2421. if (preface) {
  2422. len = strlen(preface) + strlen(prompt) + 4;
  2423. text = (char *)malloc(len);
  2424. ckmakmsg(text,len,preface,"\n",prompt,NULL);
  2425. }
  2426. rc = MessageBox(hwndConsole,
  2427. text ? text : prompt,
  2428. prompt,
  2429. MB_YESNO | MB_ICONINFORMATION | MB_TASKMODAL |
  2430. (dflt == 2 ? MB_DEFBUTTON2 : MB_DEFBUTTON1));
  2431. ShowWindowAsync(hwndConsole,SW_SHOWNORMAL);
  2432. SetForegroundWindow(hwndConsole);
  2433. if (text)
  2434. free(text);
  2435. if (!rc)
  2436. return(-1);
  2437. else if (rc == IDNO || rc == IDCANCEL)
  2438. return(0);
  2439. else
  2440. return(1);
  2441. } else
  2442. #endif /* KUI */
  2443. {
  2444. if (preface)
  2445. printf("%s\n",preface);
  2446. return(getyesno(prompt,0));
  2447. }
  2448. } else {
  2449. printf("?Internal error: uq_ok()\n");
  2450. return(-1);
  2451. }
  2452. }
  2453. /* u q _ t x t -- User Query, get single text response */
  2454. /*
  2455. Call with:
  2456. preface: Explanatory text to print, or NULL.
  2457. prompt: Prompt.
  2458. echo: 0 = don't echo; 1 = echo; 2 = echo with asterisks.
  2459. help: Help text (array of strings or NULL) [not used by parser].
  2460. buf: Pointer to result buffer.
  2461. buflen: Length of result buffer.
  2462. dflt: Default response text or NULL [not used by parser].
  2463. timer: Optional Timeout
  2464. Returns:
  2465. 0: User said No or Cancel.
  2466. 1 User said Yes or OK.
  2467. Notes:
  2468. preface, prompt, and help as for uq_ok().
  2469. */
  2470. int
  2471. #ifdef CK_ANSIC
  2472. uq_txt(char * preface, char * prompt, int echo, char ** help, char * buf,
  2473. int buflen, char *dflt, int timer)
  2474. #else /* CK_ANSIC */
  2475. uq_txt(preface,prompt,echo,help,buf,buflen,dflt,timer)
  2476. char * preface, * prompt, ** help, * buf, * dflt;
  2477. int buflen, echo, timer;
  2478. #endif /* CK_ANSIC */
  2479. {
  2480. #ifndef NOLOCAL
  2481. #ifdef OS2
  2482. extern BYTE vmode;
  2483. extern int startflags;
  2484. extern int win95_popup;
  2485. #endif /* OS2 */
  2486. #endif /* NOLOCAL */
  2487. int rc;
  2488. if (buflen < 1 || !buf)
  2489. return(0);
  2490. #ifdef KUI
  2491. if ( gui_dialog ) {
  2492. rc = gui_txt_dialog(preface,prompt,echo,buf,buflen,dflt,timer);
  2493. if ( rc > -1 )
  2494. return(rc);
  2495. /* Otherwise, the dialog could not be created. Fallback to text mode */
  2496. }
  2497. #endif /* KUI */
  2498. #ifndef NOLOCAL
  2499. #ifdef OS2
  2500. if (win95_popup && !(startflags & 96)
  2501. #ifdef IKSD
  2502. && !inserver
  2503. #endif /* IKSD */
  2504. ) {
  2505. debok = 0; /* Don't log */
  2506. if (echo == 1)
  2507. popup_readtext(vmode,preface,prompt,buf,buflen,0);
  2508. else
  2509. popup_readpass(vmode,preface,prompt,buf,buflen,0);
  2510. debok = 1;
  2511. return(1);
  2512. }
  2513. #endif /* OS2 */
  2514. #endif /* NOLOCAL */
  2515. if (preface)
  2516. printf("%s\n",preface);
  2517. if (echo == 1)
  2518. readtext(prompt,buf,buflen);
  2519. else
  2520. readpass(prompt,buf,buflen);
  2521. return(1); /* (no buttons in parser) */
  2522. }
  2523. /* u q _ m t x t -- User Query, get multiple text responses */
  2524. /*
  2525. Call with:
  2526. preface: Explanatory text to print, or NULL.
  2527. help: Help text (array of strings or NULL) [not used by parser].
  2528. n: Number of responses wanted.
  2529. field: Array of struct txtbox, one element per field, see ckuusr.h.
  2530. Returns:
  2531. 0: User said No or Cancel.
  2532. 1 User said Yes or OK.
  2533. Notes:
  2534. preface and help as for uq_ok().
  2535. */
  2536. int
  2537. #ifdef CK_ANSIC
  2538. uq_mtxt(char * preface,char **help, int n, struct txtbox field[])
  2539. #else /* CK_ANSIC */
  2540. uq_mtxt(preface,help,n,field)
  2541. char * preface; char ** help; int n; struct txtbox field[];
  2542. #endif /* CK_ANSIC */
  2543. {
  2544. #ifndef NOLOCAL
  2545. #ifdef OS2
  2546. extern BYTE vmode;
  2547. extern int startflags;
  2548. extern int win95_popup;
  2549. #endif /* OS2 */
  2550. #endif /* NOLOCAL */
  2551. int i, rc;
  2552. if (n < 1 || !field)
  2553. return(0);
  2554. #ifdef KUI
  2555. if ( gui_dialog ) {
  2556. rc = gui_mtxt_dialog(preface, n, field);
  2557. if ( rc > -1 )
  2558. return(rc);
  2559. /* Otherwise, the dialog could not be created. Fallback to text mode */
  2560. }
  2561. #endif /* KUI */
  2562. #ifndef NOLOCAL
  2563. #ifdef OS2
  2564. if (win95_popup && !(startflags & 96)
  2565. #ifdef IKSD
  2566. && !inserver
  2567. #endif /* IKSD */
  2568. ) {
  2569. debok = 0; /* Don't log */
  2570. for (i = 0; i < n; i++) {
  2571. if (field[i].t_echo == 1)
  2572. popup_readtext(vmode,preface,field[i].t_lbl,field[i].t_buf,field[i].t_len,0);
  2573. else
  2574. popup_readpass(vmode,preface,field[i].t_lbl,field[i].t_buf,field[i].t_len,0);
  2575. }
  2576. debok = 1;
  2577. return(1);
  2578. }
  2579. #endif /* OS2 */
  2580. #endif /* NOLOCAL */
  2581. if (preface)
  2582. printf("%s\n",preface);
  2583. for (i = 0; i < n; i++) {
  2584. if (field[i].t_echo == 1)
  2585. readtext(field[i].t_lbl,field[i].t_buf,field[i].t_len);
  2586. else
  2587. readpass(field[i].t_lbl,field[i].t_buf,field[i].t_len);
  2588. }
  2589. return(1);
  2590. }
  2591. /* u q _ f i l e -- User Query, get file or directory name */
  2592. /*
  2593. Call with:
  2594. preface: Explanatory text to print, or NULL.
  2595. prompt: Prompt string.
  2596. fc: Function code:
  2597. 1 = input (existing) file
  2598. 2 = existing directory
  2599. 3 = create new output file
  2600. 4 = output file allowing append access
  2601. help: Help text (array of strings or NULL) [not used by parser].
  2602. dflt: Default response.
  2603. result: Pointer to result buffer.
  2604. rlength: Length of result buffer.
  2605. Returns:
  2606. -1: Invalid argument, result too long, or other error.
  2607. 0: User Canceled.
  2608. 1: OK, with file/pathname copied to result buffer.
  2609. 2: Like 1, but for output file that is to be appended to.
  2610. Notes:
  2611. 1. preface and prompt should not include final line terminator but may
  2612. include embedded ones. Help text is in case GUI dialog needs a Help
  2613. button; final element of help-string array is "".
  2614. 2. The default might be a filename, a directory name, a relative
  2615. pathname, or an absolute pathname. This routine must convert it into
  2616. into a fully qualified (absolute) pathname so the user knows exactly
  2617. where the file is to be found or stored. In addition, the Windows
  2618. version of this routine must separate the directory part from the
  2619. name part, so it can display the given directory in the file dialog,
  2620. and put name in the filename box to be edited, replaced, or
  2621. accepted.
  2622. 3. When called with FC 4, the Windows version should include "New" and
  2623. "Append" buttons in the dialog. so the user can say whether the file
  2624. should overwrite any file of the same name, or be appended to it.
  2625. */
  2626. int
  2627. #ifdef CK_ANSIC
  2628. uq_file(char * preface, char * fprompt, int fc, char ** help,
  2629. char * dflt, char * result, int rlength)
  2630. #else /* CK_ANSIC */
  2631. uq_file(preface,fprompt,fc,help,dflt,result,rlength)
  2632. char * preface, * fprompt, ** help, * dflt, * result;
  2633. int fc, rlength;
  2634. #endif /* CK_ANSIC */
  2635. /* uq_file */ {
  2636. int rc = -1, x, y, z;
  2637. char * s, * p, * fullpath;
  2638. char filebuf[CKMAXPATH+1];
  2639. #ifdef CK_RECALL
  2640. extern int on_recall;
  2641. #endif /* CK_RECALL */
  2642. #ifdef KUI
  2643. if ( gui_dialog ) {
  2644. rc = gui_saveas_dialog(preface,fprompt,fc,dflt,result,rlength);
  2645. return rc;
  2646. }
  2647. #endif /* KUI */
  2648. #ifdef CK_RECALL
  2649. on_recall = 0;
  2650. #endif /* CK_RECALL */
  2651. if (preface) /* If prefatory text given... */
  2652. printf("%s\n",preface); /* display it. */
  2653. cmsavp(psave,PROMPTL); /* Save old prompt */
  2654. /* We get the full pathname of the proposed output file just so */
  2655. /* we can show it to the user but we don't use it ourselves. */
  2656. p = NULL; /* Build new prompt */
  2657. if (!dflt) dflt = "";
  2658. if (*dflt) /* Have default filename */
  2659. zfnqfp(dflt,CKMAXPATH+1,filebuf); /* Get full path */
  2660. else
  2661. ckmakmsg(filebuf,CKMAXPATH+1,zgtdir(),"newfile",NULL,NULL);
  2662. fullpath = filebuf;
  2663. x = strlen(fullpath);
  2664. /* If no prompt given, build one that shows the proposed full pathname. */
  2665. if (!fprompt) fprompt = "";
  2666. if (!*fprompt) fprompt = x ? " Filename" : " Filename: ";
  2667. y = strlen(fprompt);
  2668. if (x > 0) { /* Have default pathname? */
  2669. p = (char *)malloc(x + y + 7); /* Get temp storage */
  2670. if (p) { /* Build prompt */
  2671. ckmakmsg(p,x+y+7,fprompt," [",fullpath,"]: ");
  2672. fprompt = p;
  2673. }
  2674. }
  2675. cmsetp(fprompt); /* Make new prompt */
  2676. if (p) free(p); /* Free temp storage */
  2677. cmini(ckxech); /* Initialize parser. */
  2678. x = -1;
  2679. do {
  2680. prompt(NULL); /* Issue prompt. */
  2681. switch (fc) { /* Parse depends on function code */
  2682. case 1: /* Input file */
  2683. x = cmifi("Name of existing file",dflt,&s,&y,xxstring);
  2684. rc = 1;
  2685. break;
  2686. case 2: /* Directory */
  2687. x = cmdir("Directory name",dflt,&s,xxstring);
  2688. rc = 1;
  2689. break;
  2690. case 3: /* New output file */
  2691. /* Fall thru... */
  2692. case 4: /* Output file - Append allowed */
  2693. x = cmofi("Output file specification",dflt,&s,xxstring);
  2694. rc = (fc == 4) ? 1 : 2;
  2695. break;
  2696. default: /* Bad function code */
  2697. goto x_uq_file;
  2698. }
  2699. if (x < 0) { /* Parse error */
  2700. filebuf[0] = NUL;
  2701. if (x == -4) { /* EOF */
  2702. break;
  2703. } else if (x == -3) /* No answer? */
  2704. printf(fc == 2 ?
  2705. " Please enter a directory name.\n" :
  2706. " Please enter a filename.\n"
  2707. );
  2708. cmini(ckxech);
  2709. } else {
  2710. z = strlen(s);
  2711. if (z > rlength || ckstrncpy(filebuf,brstrip(s),CKMAXPATH+1) < z) {
  2712. printf("?Name too long\n");
  2713. x = -9;
  2714. } else
  2715. x = cmcfm(); /* Get confirmation */
  2716. }
  2717. if (fc == 1 && x > -1 && y > 0) {
  2718. printf("?Wildcards not allowed\n");
  2719. x = -9;
  2720. }
  2721. } while (x < 0); /* Continue till done */
  2722. x_uq_file:
  2723. if (x < 0)
  2724. rc = -1;
  2725. cmsetp(psave); /* Restore real prompt */
  2726. if (rc > 0)
  2727. ckstrncpy(result,filebuf,rlength);
  2728. return(rc);
  2729. }
  2730. #ifdef CK_PERMS
  2731. #ifdef UNIX
  2732. _PROTOTYP( int zsetperm, (char *, int));
  2733. /* CHMOD command for UNIX only */
  2734. #define CHM_DIR 0
  2735. #define CHM_DOT 1
  2736. #define CHM_FIL 2
  2737. #define CHM_LIS 3
  2738. #define CHM_NOL 4
  2739. #define CHM_QUI 5
  2740. #define CHM_REC 6
  2741. #define CHM_VRB 7
  2742. #define CHM_PAG 8
  2743. #define CHM_NOP 9
  2744. #define CHM_TYP 10
  2745. #define CHM_SIM 11
  2746. static struct keytab uchmodsw[] = {
  2747. "/directories", CHM_DIR, 0,
  2748. "/dotfiles", CHM_DOT, 0,
  2749. "/files", CHM_FIL, 0,
  2750. "/list", CHM_LIS, 0,
  2751. "/nolist", CHM_NOL, 0,
  2752. "/nopage", CHM_NOP, 0,
  2753. "/page", CHM_PAG, 0,
  2754. "/quiet", CHM_QUI, CM_INV,
  2755. "/recursive", CHM_REC, 0,
  2756. "/simulate", CHM_SIM, 0,
  2757. "/type", CHM_TYP, CM_ARG,
  2758. "/verbose", CHM_VRB, CM_INV,
  2759. };
  2760. static int nchmodsw = (sizeof(uchmodsw) / sizeof(struct keytab));
  2761. int
  2762. douchmod() {
  2763. extern int recursive, nscanfile, diractive;
  2764. #ifdef CK_TTGWSIZ
  2765. extern int tt_rows, tt_cols;
  2766. int n = 0;
  2767. #endif /* CK_TTGWSIZ */
  2768. int i, files = 1, t1 = 1, t2 = 0, x, y, z, verbose = 0, rc = 1, paging;
  2769. int xmode = -1, fs = 0, getval = 0, simulate = 0, wild = 0;
  2770. char c, * s;
  2771. struct FDB sw, nu;
  2772. if (xaskmore < 0) {
  2773. #ifdef CK_TTGWSIZ
  2774. xaskmore = 1;
  2775. #else
  2776. xaskmore = 0;
  2777. #endif /* CK_TTGWSIZ */
  2778. }
  2779. paging = xaskmore;
  2780. cmfdbi(&sw, /* First FDB - command switches */
  2781. _CMKEY, /* fcode */
  2782. "Octal file permission code, or switch",
  2783. "", /* default */
  2784. "", /* addtl string data */
  2785. nchmodsw, /* addtl numeric data 1: tbl size */
  2786. 4, /* addtl numeric data 2: 4 = cmswi */
  2787. xxstring, /* Processing function */
  2788. uchmodsw, /* Keyword table */
  2789. &nu /* Pointer to next FDB */
  2790. );
  2791. cmfdbi(&nu,
  2792. _CMNUM, /* Number */
  2793. "", /* Help message */
  2794. "", /* Default */
  2795. "", /* N/A */
  2796. 8, /* Radix = 8 */
  2797. 0, /* N/A */
  2798. xxstring, /* Processing function */
  2799. NULL, /* N/A */
  2800. NULL /* Next */
  2801. );
  2802. while (1) {
  2803. if ((x = cmfdb(&sw)) < 0) {
  2804. if (x == -3) {
  2805. x = -9;
  2806. printf("?Filename required\n");
  2807. }
  2808. return(x);
  2809. }
  2810. if (cmresult.fcode != _CMKEY)
  2811. break;
  2812. c = cmgbrk();
  2813. getval = (c == ':' || c == '=');
  2814. if (getval && !(cmgkwflgs() & CM_ARG)) {
  2815. printf("?This switch does not take an argument\n");
  2816. return(-9);
  2817. }
  2818. if (!getval && (cmgkwflgs() & CM_ARG)) {
  2819. printf("?This switch requires an argument\n");
  2820. return(-9);
  2821. }
  2822. switch (cmresult.nresult) {
  2823. case CHM_DIR:
  2824. t1 = 1;
  2825. t2 = 1;
  2826. break;
  2827. case CHM_DOT:
  2828. matchdot = 1;
  2829. break;
  2830. case CHM_FIL:
  2831. t1 = 0;
  2832. t2 = 0;
  2833. break;
  2834. case CHM_LIS:
  2835. case CHM_VRB:
  2836. verbose = 1;
  2837. break;
  2838. case CHM_NOL:
  2839. case CHM_QUI:
  2840. verbose = 0;
  2841. break;
  2842. case CHM_REC:
  2843. recursive = 1;
  2844. break;
  2845. case CHM_PAG:
  2846. verbose = 1;
  2847. paging = 1;
  2848. break;
  2849. case CHM_NOP:
  2850. paging = 0;
  2851. break;
  2852. case CHM_SIM:
  2853. simulate = 1;
  2854. break;
  2855. case CHM_TYP: {
  2856. extern struct keytab txtbin[];
  2857. if ((x = cmkey(txtbin,3,"","",xxstring)) < 0)
  2858. return(x);
  2859. if (x == 2) { /* ALL */
  2860. xmode = -1;
  2861. } else { /* TEXT or BINARY only */
  2862. xmode = x;
  2863. fs = 1;
  2864. }
  2865. break;
  2866. }
  2867. }
  2868. }
  2869. z = cmresult.nresult;
  2870. x = cmifi2("File specification","",&s,&wild,t1,NULL,xxstring,t2);
  2871. if (x < 0) {
  2872. if (x == -3) {
  2873. printf("?A file specification is required\n");
  2874. return(-9);
  2875. } else
  2876. return(x);
  2877. }
  2878. ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  2879. s = tmpbuf;
  2880. if ((x = cmcfm()) < 0)
  2881. return(x);
  2882. #ifdef ZXREWIND
  2883. if (wild) files = zxrewind();
  2884. #else
  2885. if (wild) files = nzxpand(s,0);
  2886. #endif /* ZXREWIND */
  2887. if (paging > -1)
  2888. xaskmore = paging;
  2889. #ifdef CK_TTGWSIZ
  2890. if (verbose && paging) {
  2891. #ifdef OS2
  2892. ttgcwsz();
  2893. #else /* OS2 */
  2894. if (ttgwsiz() > 0) {
  2895. if (tt_rows > 0 && tt_cols > 0) {
  2896. cmd_rows = tt_rows;
  2897. cmd_cols = tt_cols;
  2898. }
  2899. }
  2900. #endif /* OS2 */
  2901. }
  2902. #endif /* CK_TTGWSIZ */
  2903. for (i = 0; i < files; i++) {
  2904. if (files == 1 && wild == 0) { /* For "chmod 777 ." */
  2905. ckstrncpy(line,s,LINBUFSIZ);
  2906. } else {
  2907. x = znext(line);
  2908. if (x < 1) {
  2909. if (i == 0) {
  2910. printf("?No files match - \"%s\"\n",line);
  2911. return(-9);
  2912. }
  2913. return(1);
  2914. }
  2915. }
  2916. if (fs) {
  2917. #ifdef VMSORUNIX
  2918. /* If /TYPE:TEXT or BINARY given, skip directories and links */
  2919. /* since they are neither text nor binary. */
  2920. extern int zgfs_dir, zgfs_link;
  2921. zgetfs(line);
  2922. if (zgfs_dir || zgfs_link)
  2923. continue;
  2924. #else
  2925. if (zchki(line) < 0)
  2926. continue;
  2927. #endif /* VMSORUNIX */
  2928. /* Regular file, scan it */
  2929. switch (scanfile(line,&y,nscanfile)) {
  2930. case FT_BIN:
  2931. if (xmode != 1)
  2932. continue;
  2933. break;
  2934. case FT_TEXT:
  2935. case FT_7BIT:
  2936. case FT_8BIT:
  2937. #ifdef UNICODE
  2938. case FT_UTF8:
  2939. case FT_UCS2:
  2940. #endif /* UNICODE */
  2941. if (xmode != 0)
  2942. continue;
  2943. }
  2944. }
  2945. if (simulate) {
  2946. #ifdef UNIX
  2947. extern int zchkod; /* Unidentified Flying */
  2948. int xx = zchkod; /* API Extension... */
  2949. zchkod = 1;
  2950. #endif /* UNIX */
  2951. if (zchko(line) < 0)
  2952. printf("%s - Access denied\n",line);
  2953. else
  2954. printf("%s - OK\n",line);
  2955. #ifdef UNIX
  2956. zchkod = xx;
  2957. #endif /* UNIX */
  2958. } else {
  2959. if (zsetperm(line,z) < 1) {
  2960. if (verbose || files < 2) {
  2961. printf("%s: %s\n",line,ck_errstr());
  2962. }
  2963. rc = 0;
  2964. } else if (verbose) {
  2965. printf("%s %s\n",ziperm(line),line);
  2966. }
  2967. }
  2968. #ifdef CK_TTGWSIZ
  2969. if (verbose && paging) { /* Pause at end of screen */
  2970. if (cmd_rows > 0 && cmd_cols > 0) {
  2971. if (++n > cmd_rows - 3) {
  2972. if (!askmore())
  2973. break;
  2974. else
  2975. n = 0;
  2976. }
  2977. }
  2978. }
  2979. #endif /* CK_TTGWSIZ */
  2980. }
  2981. return(success = rc);
  2982. }
  2983. #endif /* UNIX */
  2984. #endif /* CK_PERMS */
  2985. #ifndef NOSPL /* S-Expressions */
  2986. #ifndef NOSEXP
  2987. struct keytab sexptab[] = {
  2988. "depth-limit", 1, 0,
  2989. "echo-result", 0, 0,
  2990. "truncate-all-results", 2
  2991. };
  2992. static int sexpmaxdep = 1000; /* Maximum depth */
  2993. #define xxfloat(s,x) \
  2994. ((isdigit(*s)||(*s=='-')||(*s=='+')||(*s=='.')||(*s=='\040'))?isfloat(s,x):0)
  2995. #define SX_ADD 1 /* Symbols for built-in operators */
  2996. #define SX_SUB 2
  2997. #define SX_MUL 3
  2998. #define SX_DIV 4
  2999. #define SX_POW 5
  3000. #define SX_SET 6
  3001. #define SX_MOD 7
  3002. #define SX_EVA 8
  3003. #define SX_EXP 9
  3004. #define SX_AEQ 10
  3005. #define SX_ALT 11
  3006. #define SX_AGT 12
  3007. #define SX_ALE 13
  3008. #define SX_AGE 14
  3009. #define SX_MIN 15
  3010. #define SX_MAX 16
  3011. #define SX_SQR 17
  3012. #define SX_FLR 18
  3013. #define SX_CEI 19
  3014. #define SX_TRU 20
  3015. #define SX_ABS 21
  3016. #define SX_ROU 22
  3017. #define SX_LET 23
  3018. #define SX_LGN 24
  3019. #define SX_LGX 25
  3020. #define SX_FLO 26
  3021. #define SX_IFC 27
  3022. #define SX_NOT 28
  3023. #define SX_NEQ 29
  3024. #define SX_AND 30
  3025. #define SX_LOR 31
  3026. #define SX_SIN 32
  3027. #define SX_COS 33
  3028. #define SX_TAN 34
  3029. #define SX_BWA 35
  3030. #define SX_BWO 36
  3031. #define SX_BWX 37
  3032. #define SX_BWN 38
  3033. #define SX_XOR 39
  3034. #define SX_INC 40
  3035. #define SX_DEC 41
  3036. #define SX_QUO 42
  3037. #define SX_STR 43
  3038. #define SX_ECH 44
  3039. #define SX_UNQ 45
  3040. /* Operator flags */
  3041. #define SXF_PRE 256 /* Predicate */
  3042. #define SXF_ONE 512 /* Requires one arg */
  3043. #define SXF_TWO 1024 /* Requires two args or more */
  3044. #define SXF_FLO 2048 /* Coerce to floating-point */
  3045. /* Built-in constants */
  3046. #define SXC_NIL 1 /* NIL */
  3047. #define SXC_PI 2 /* PI */
  3048. #define SXC_T 3 /* T */
  3049. /*
  3050. This is an xlookup() table and so need not be in "alhabetical" order.
  3051. Therefore entries are arranged to minimize search for most common
  3052. operators.
  3053. */
  3054. static struct keytab sexpops[] = { /* Built-in operators */
  3055. "setq", SX_SET, 0, /* Global assignment */
  3056. "+", SX_ADD, 0, /* Simple arithmetic */
  3057. "-", SX_SUB, 0,
  3058. "*", SX_MUL, 0,
  3059. "/", SX_DIV, SXF_TWO,
  3060. "^", SX_POW, SXF_TWO,
  3061. "if", SX_IFC, SXF_TWO, /* IF */
  3062. "let", SX_LET, 0, /* Local assignment */
  3063. "not", SX_NOT, SXF_ONE, /* NOT */
  3064. "mod", SX_MOD, SXF_TWO, /* Modulus */
  3065. "<", SX_ALT, SXF_PRE, /* Comparisons */
  3066. ">", SX_AGT, SXF_PRE,
  3067. "<=", SX_ALE, SXF_PRE,
  3068. "=", SX_AEQ, SXF_PRE,
  3069. ">=", SX_AGE, SXF_PRE,
  3070. "!=", SX_NEQ, SXF_PRE,
  3071. "++", SX_INC, SXF_ONE|SXF_TWO, /* Increment */
  3072. "--", SX_DEC, SXF_ONE|SXF_TWO, /* Decrement */
  3073. "**", SX_POW, SXF_TWO, /* Common synonyms */
  3074. "==", SX_AEQ, SXF_PRE,
  3075. "!", SX_NOT, SXF_ONE,
  3076. ".", SX_EVA, 0,
  3077. "and", SX_AND, 0, /* Logical operators */
  3078. "or", SX_LOR, 0,
  3079. "xor", SX_XOR, SXF_TWO,
  3080. "max", SX_MAX, SXF_ONE|SXF_TWO, /* Max and min */
  3081. "min", SX_MIN, SXF_ONE|SXF_TWO,
  3082. "%", SX_MOD, SXF_TWO, /* More synonyms */
  3083. "||", SX_LOR, 0,
  3084. "&&", SX_AND, 0,
  3085. "quote", SX_QUO, SXF_ONE, /* String operators */
  3086. "string", SX_STR, SXF_ONE,
  3087. "unquote", SX_UNQ, SXF_ONE,
  3088. "eval", SX_EVA, 0, /* Assorted commands */
  3089. "abs", SX_ABS, SXF_ONE,
  3090. "truncate",SX_TRU, SXF_ONE|SXF_FLO,
  3091. "round", SX_ROU, SXF_ONE|SXF_TWO|SXF_FLO,
  3092. "ceiling", SX_CEI, SXF_ONE|SXF_FLO,
  3093. "floor", SX_FLR, SXF_ONE|SXF_FLO,
  3094. "float", SX_FLO, SXF_ONE|SXF_FLO,
  3095. "echo", SX_ECH, 0,
  3096. #ifdef FNFLOAT
  3097. "sqrt", SX_SQR, SXF_ONE|SXF_FLO, /* Floating point functions */
  3098. "exp", SX_EXP, SXF_ONE|SXF_FLO,
  3099. "sin", SX_SIN, SXF_ONE|SXF_FLO,
  3100. "cos", SX_COS, SXF_ONE|SXF_FLO,
  3101. "tan", SX_TAN, SXF_ONE|SXF_FLO,
  3102. "log", SX_LGN, SXF_ONE|SXF_FLO,
  3103. "log10", SX_LGX, SXF_ONE|SXF_FLO,
  3104. #endif /* FNFLOAT */
  3105. "#", SX_BWX, SXF_TWO, /* Bitwise operators */
  3106. "&", SX_BWA, 0,
  3107. "|", SX_BWO, 0,
  3108. "~", SX_BWN, SXF_ONE,
  3109. "", 0, 0 /* (end) */
  3110. };
  3111. static int nsexpops = (sizeof(sexpops) / sizeof(struct keytab)) - 1;
  3112. static struct keytab sexpconsts[] = { /* Built-in constants */
  3113. "nil", SXC_NIL, 0, /* NIL (false) */
  3114. "pi", SXC_PI, 0, /* Pi (3.1415926...) */
  3115. "t", SXC_T, 0, /* T (true) */
  3116. "", 0, 0
  3117. };
  3118. static int nsexpconsts = (sizeof(sexpconsts) / sizeof(struct keytab)) - 1;
  3119. int sexprc = 0; /* S-Expression error flag */
  3120. int sexppv = -1; /* Predicate value */
  3121. static int sexptrunc = 0; /* Flag to force all results to int */
  3122. #define SXMLEN 64 /* Macro arg list initial length */
  3123. #include <math.h> /* Floating-point functions */
  3124. _PROTOTYP( char * fpformat, (CKFLOAT, int, int) );
  3125. _PROTOTYP( CKFLOAT ckround, (CKFLOAT, int, char *, int) );
  3126. extern char math_pi[]; /* Value of Pi */
  3127. extern int sexpecho; /* SET SEXPRESSION ECHO value */
  3128. extern char * sexpval; /* Last top-level S-Expression value */
  3129. extern char * lastsexp; /* Last S-Expression */
  3130. int sexprmax = 0; /* Longest result (for stats) */
  3131. int sexpdmax = 0; /* Max depth reached (for stats) */
  3132. int sexpdep = 0; /* dosexp() recursion depth */
  3133. static int * sxrlen = NULL; /* Result stack string sizes */
  3134. static char ** sxresult = NULL; /* Result stack */
  3135. /* s h o s e x p -- Show S-Expression info */
  3136. VOID
  3137. shosexp() {
  3138. printf("\n");
  3139. printf(" sexpression echo-result: %s\n",showooa(sexpecho));
  3140. printf(" sexpression depth-limit: %d\n",sexpmaxdep);
  3141. printf("\n");
  3142. printf(" maximum depth reached: %d\n",sexpdmax);
  3143. printf(" longest result returned: %d\n",sexprmax);
  3144. printf("\n");
  3145. printf(" truncate all results: %s\n",showoff(sexptrunc));
  3146. printf("\n");
  3147. printf(" last sexpression: %s\n",lastsexp ? lastsexp : "(none)");
  3148. printf(" last value: %s\n",sexpval ? sexpval : "(none)");
  3149. printf("\n");
  3150. }
  3151. static char *
  3152. sexpdebug(s) char * s; {
  3153. /* For debugging -- includes recursion depth in each debug entry */
  3154. static char buf[64];
  3155. ckmakmsg(buf,64,"dosexp[",ckitoa(sexpdep),"] ",s);
  3156. return((char *)buf);
  3157. }
  3158. /* d o s e x p -- S-Expression Reader */
  3159. /* Returns value as string (empty, numeric, or non-numeric) */
  3160. static char sxroundbuf[32]; /* For ROUND result */
  3161. char *
  3162. dosexp(s) char *s; { /* s = S-Expression */
  3163. extern struct mtab *mactab; /* Macro table */
  3164. extern int maclvl, nmac;
  3165. extern char *mrval[];
  3166. extern int makestrlen; /* (see makestr()) */
  3167. struct stringarray * q = NULL; /* cksplit() return type */
  3168. char * p[SEXPMAX+1], ** p2; /* List items (must be on stack) */
  3169. char * line = NULL; /* For building macro argument list */
  3170. int nosplit = 0;
  3171. int linelen = 0;
  3172. int linepos = 0;
  3173. int quote = 0; /* LISP quote flag */
  3174. char * s2; /* Workers */
  3175. int kw, kwflags, mx = 0, x = 0;
  3176. int not = 0, truncate = 0, builtin = 0;
  3177. int fpflag = 0, quit = 0, macro = 0;
  3178. CK_OFF_T result = 0, i, j, k, n = 0;
  3179. CKFLOAT fpj, fpresult = 0.0; /* Floating-point results */
  3180. int pflag = 0; /* Have predicate */
  3181. int presult = 0; /* Predicate result */
  3182. int mustfree = 0; /* If we malloc'd we must free */
  3183. sexppv = -1; /* Predicate value */
  3184. s2 = ""; /* Default return value */
  3185. debug(F111,sexpdebug("entry 1"),s,sexprc);
  3186. if (++sexpdep > sexpmaxdep) { /* Keep track of depth */
  3187. printf("?S-Expression depth limit exceeded: %d\n",sexpmaxdep);
  3188. sexprc++;
  3189. debug(F111,sexpdebug("max depth exceeded"),s,sexprc);
  3190. }
  3191. if (sexpdep > sexpdmax) /* For stats */
  3192. sexpdmax = sexpdep;
  3193. if (sexprc) /* Error, quit all levels */
  3194. goto xdosexp; /* Always goto common exit point */
  3195. debug(F111,sexpdebug("entry 2"),s,sexprc);
  3196. if (!s) s = ""; /* Null or empty arg */
  3197. while (*s == SP) s++; /* Strip leading spaces */
  3198. if (!*s) /* so empty result */
  3199. goto xdosexp;
  3200. /*
  3201. Allocate result stack upon first use, or after it has been resized with
  3202. SET SEXP DEPTH-LIMIT.
  3203. */
  3204. if (!sxresult) {
  3205. sxresult = (char **)malloc(sexpmaxdep * sizeof(char *));
  3206. if (!sxresult) {
  3207. printf("?Memory allocation failure - \"%s\"\n", s);
  3208. sexprc++;
  3209. goto xdosexp;
  3210. }
  3211. sxrlen = (int *)malloc(sexpmaxdep * sizeof(int));
  3212. if (!sxrlen) {
  3213. printf("?Memory allocation failure - \"%s\"\n", s);
  3214. sexprc++;
  3215. goto xdosexp;
  3216. }
  3217. for (i = 0; i < sexpmaxdep; i++) {
  3218. sxresult[i] = NULL; /* Result pointers */
  3219. sxrlen[i] = 0; /* Buffer sizes */
  3220. }
  3221. }
  3222. s2 = s; /* s2 is the result pointer */
  3223. k = 0; /* Length accumulator */
  3224. if (s[0] == '(') { /* Starts with open paren? */
  3225. while (*s2++) k++; /* Get length */
  3226. if (s[k-1] == ')') { /* Strip outer parens if any */
  3227. s[k-1] = NUL;
  3228. s++;
  3229. k -= 2;
  3230. while (*s == SP) { /* Strip leading spaces from result */
  3231. s++;
  3232. k--;
  3233. }
  3234. while (k > 0 && s[k-1] == SP) { /* And trailing spaces. */
  3235. s[k-1] = NUL;
  3236. k--;
  3237. }
  3238. }
  3239. if (!*s) { /* If nothing remains */
  3240. s2 = ""; /* return empty result. */
  3241. goto xdosexp;
  3242. }
  3243. }
  3244. /* Break result up into "words" (an SEXP counts as a word) */
  3245. for (i = 0; i < SEXPMAX+1; i++ ) { /* Clear the operands */
  3246. p[i] = NULL;
  3247. }
  3248. if (!*(s+1) || !*(s+2)) { /* No need to call cksplit() */
  3249. n = 1; /* if it's one or two chars. */
  3250. p[1] = s; /* No need to malloc this either. */
  3251. nosplit = 1;
  3252. debug(F101,sexpdebug("nosplit"),"",n);
  3253. if (s[0] == '(') { /* () empty */
  3254. s2 = "";
  3255. goto xdosexp;
  3256. }
  3257. } else {
  3258. nosplit = 0;
  3259. q = cksplit(1,SEXPMAX,s,NULL,"\\%[]&$+-/=*^_@!{}/<>|.#~'`:;?",8,39,0,0);
  3260. if (!q)
  3261. goto xdosexp;
  3262. n = q->a_size; /* Number of items */
  3263. // printf("XXX cksplit=%d\n",n);
  3264. debug(F101,sexpdebug("split"),"",n);
  3265. if (n < 0 || n > SEXPMAX) { /* Check for too many */
  3266. printf("?Too many operands: max = %d\n",SEXPMAX);
  3267. sexprc++;
  3268. goto xdosexp;
  3269. }
  3270. if (n == 0) /* None, result is NULL, done. */
  3271. goto xdosexp;
  3272. if (n == 1 && s[0] == '(') { /* One but it's another SEXP */
  3273. // printf("XXX s.00=[%s]\n",s);
  3274. s2 = dosexp(s);
  3275. // printf("XXX s2.00=[%s]\n",s2);
  3276. goto xdosexp;
  3277. }
  3278. if (n == 1 && s[0] == '\047') { /* One but it's a string constant */
  3279. int x = (int) strlen(s);
  3280. s2 = s;
  3281. if (s2[1] == '(' && s2[x-1] == ')') { /* '(string) */
  3282. s2[x-1] = NUL;
  3283. s2 += 2;
  3284. // printf("XXX s2.2=[%s]\n",s2);
  3285. }
  3286. goto xdosexp;
  3287. }
  3288. /* More than one */
  3289. p2 = q->a_head; /* Point to result array. */
  3290. for (i = 1; i <= n; i++) { /* We must copy it because */
  3291. p[i] = NULL; /* recursive calls to dosexp() */
  3292. if (p2[i]) /* write over the same array */
  3293. makestr(&(p[i]),p2[i]);
  3294. }
  3295. if (s[0] == '(') { /* Operator is an S-Expression */
  3296. // printf("XXX p[1]=[%s] s=[%s]\n",p[1],s);
  3297. s2 = dosexp(p[1]); /* Replace it by its value */
  3298. // printf("XXX s2.1=[%s]\n",s2);
  3299. if (s2[0] == '\047') { /* LISP string literal */
  3300. int x = (int) strlen(s2);
  3301. if (s2[1] == '(' && s2[x-1] == ')') { /* '(string) */
  3302. s2[x-1] = NUL;
  3303. s2 += 2;
  3304. printf("XXX s2.2=[%s]\n",s2);
  3305. }
  3306. }
  3307. makestr(&(p[1]),s2);
  3308. }
  3309. mustfree++; /* Remember to free it */
  3310. }
  3311. debug(F110,sexpdebug("head"),p[1],0);
  3312. if (n == 1 && p[1]) {
  3313. if (*(p[1]) == '\047') { /* Apostrophe = LISP quote character */
  3314. s2 = p[1];
  3315. goto xdosexp;
  3316. }
  3317. }
  3318. /*
  3319. This section sidesteps xlookup() of the most common operators.
  3320. It's not necessary but it speeds up SEXP-heavy loops by about 10%.
  3321. */
  3322. kwflags = 0;
  3323. if (n > 0) { /* Look up the operator */
  3324. s2 = p[1]; /* Prelookup optimization... */
  3325. if (!s2)
  3326. s2 = "";
  3327. if (!*s2)
  3328. goto xdosexp;
  3329. kw = 0;
  3330. x = 0;
  3331. if (isdigit(*s2)) { /* Digit */
  3332. x = -2;
  3333. } else if (isalpha(*s2) && !*(s2+1)) { /* Single letter */
  3334. x = -1;
  3335. } else if (*s2 == 's' || *s2 == 'S') { /* SETQ */
  3336. s2++;
  3337. if (*s2 == 'e' || *s2 == 'E') {
  3338. s2++;
  3339. if (*s2 == 't' || *s2 == 'T') {
  3340. s2++;
  3341. if (*s2 == 'q' || *s2 == 'Q') {
  3342. if (!*(s2+1)) {
  3343. x = SX_SET;
  3344. kwflags = 0;
  3345. builtin = 1;
  3346. }
  3347. }
  3348. }
  3349. }
  3350. }
  3351. if (!x) {
  3352. if (!*(s2+1)) { /* Common single-character ops */
  3353. if (*s2 == '+') {
  3354. x = SX_ADD;
  3355. kwflags = 0;
  3356. builtin = 1;
  3357. } else if (*s2 == '-') {
  3358. x = SX_SUB;
  3359. kwflags = 0;
  3360. builtin = 1;
  3361. } else if (*s2 == '*') {
  3362. x = SX_MUL;
  3363. kwflags = 0;
  3364. builtin = 1;
  3365. } else if (*s2 == '/') {
  3366. x = SX_DIV;
  3367. kwflags = SXF_TWO;
  3368. builtin = 1;
  3369. }
  3370. }
  3371. if (!x) { /* None of the above, look it up */
  3372. x = xlookup(sexpops,p[1],nsexpops,&kw);
  3373. if (x > 0) {
  3374. kwflags = sexpops[kw].flgs;
  3375. builtin = 1;
  3376. }
  3377. }
  3378. }
  3379. }
  3380. /* If none of the above, check built-in constants */
  3381. if (x == -1) {
  3382. x = xlookup(sexpconsts,p[1],nsexpconsts,&kw);
  3383. if (x > 0) {
  3384. switch (x) {
  3385. case SXC_NIL:
  3386. s2 = "";
  3387. goto xdosexp;
  3388. case SXC_PI:
  3389. s2 = math_pi;
  3390. goto xdosexp;
  3391. case SXC_T:
  3392. s2 = "1";
  3393. goto xdosexp;
  3394. }
  3395. }
  3396. }
  3397. if (n == 1) { /* Not an expression */
  3398. if (builtin) { /* Built-in operand? */
  3399. switch (x) { /* Operators with default values */
  3400. case SX_EVA:
  3401. s2 = "";
  3402. goto xdosexp;
  3403. case SX_MUL: /* (*) */
  3404. s2 = sexpval ? sexpval : "1";
  3405. goto xdosexp;
  3406. case SX_AND: /* (AND) */
  3407. case SX_BWA: /* Bitwise (&) */
  3408. result++;
  3409. case SX_LOR: /* (OR) */
  3410. case SX_BWO: /* Bitwise (|) */
  3411. case SX_ADD: /* (+) */
  3412. case SX_SUB: /* (-) */
  3413. s2 = result ? "1" : "0";
  3414. goto xdosexp;
  3415. }
  3416. } else { /* Not a built-in operand */
  3417. char * p1;
  3418. p1 = p[1];
  3419. while (*p1 == SP) p1++;
  3420. if (!isalpha(*p1)) {
  3421. if (xxfloat(p1,0) > 0) { /* Is it a number? */
  3422. s2 = p1;
  3423. while (*s2 == '+') s2++;
  3424. } else if (*p1 == '(') { /* An S-Expression? */
  3425. #ifdef COMMENT
  3426. s2 = dosexp(s2);
  3427. #else
  3428. s2 = dosexp(p1);
  3429. #endif /* COMMENT */
  3430. }
  3431. goto xdosexp;
  3432. } else if (x < 1) { /* Is it a variable? */
  3433. j = mxlook(mactab,p[1],nmac); /* Look it up */
  3434. debug(F111,sexpdebug("n==1 mxlook"),p[1],j);
  3435. s2 = (j > -1) ? mactab[j].mval : "";
  3436. if (!s2) s2 = "";
  3437. if (xxfloat(s2,0) > 0) /* Macro value is a number */
  3438. goto xdosexp;
  3439. if (j > -1) { /* It's a macro */
  3440. mx = j;
  3441. x = j; /* whose definition is not numeric */
  3442. if (*s2 == '(') { /* Is it an S-Expression? */
  3443. /* We have to allocate memory on the stack */
  3444. /* to call ourselves recursively on it */
  3445. /* otherwise we'll wipe out the macro definition */
  3446. char * s3 = NULL;
  3447. /* int k = 0; */
  3448. s3 = s2;
  3449. while (*s3++) k++;
  3450. s3 = (char *)malloc(k + 4);
  3451. if (s3) {
  3452. strcpy(s3,s2); /* SAFE */
  3453. s2 = dosexp(s3); /* Evaluate it */
  3454. free(s3);
  3455. } else {
  3456. printf("?Memory allocation failure - \"%s\"\n",s2);
  3457. sexprc++;
  3458. }
  3459. goto xdosexp;
  3460. }
  3461. if (*s2 == '\047') {
  3462. s2++;
  3463. #ifdef COMMENT
  3464. /* Dumps core if petty optimization was taken */
  3465. makestr(&(p[1]),s2);
  3466. #else
  3467. if (!nosplit && p[1]) free(p[1]);
  3468. p[1] = (char *)malloc((int)strlen(s2) + 1);
  3469. #endif /* COMMENT */
  3470. s2 = p[1];
  3471. if (!s2) s2 = "";
  3472. if (*s2 == '(') {
  3473. if (s2[makestrlen-1] == ')') {
  3474. s2[makestrlen-1] = NUL;
  3475. s2++;
  3476. }
  3477. }
  3478. debug(F110,sexpdebug("'A"),s2,0);
  3479. goto xdosexp;
  3480. }
  3481. macro++; /* Not an S-Expression */
  3482. } else {
  3483. printf("?Not defined - \"%s\"\n", p[1]);
  3484. sexprc++;
  3485. goto xdosexp;
  3486. }
  3487. }
  3488. }
  3489. } else if (x < 1 && !macro) { /* n > 1 and not a built-in operator */
  3490. x = mxlook(mactab,p[1],nmac); /* See if it's a macro */
  3491. debug(F111,sexpdebug("n!=1 mxlook"),p[1],x);
  3492. if (x < 0) {
  3493. printf("?Invalid operand - \"%s\"\n",p[1]);
  3494. sexprc++;
  3495. s2 = NULL; /* Bad operator, no result */
  3496. goto xdosexp;
  3497. }
  3498. mx = x;
  3499. macro++;
  3500. }
  3501. if (builtin) { /* Built-in operator... */
  3502. if (kwflags) {
  3503. int flgs;
  3504. if ((flgs = (kwflags & (SXF_ONE|SXF_TWO)))) {
  3505. switch (flgs) {
  3506. case (SXF_ONE|SXF_TWO):
  3507. if (n < 2) {
  3508. printf("?Too few operands - \"%s\"\n",s);
  3509. sexprc++;
  3510. goto xdosexp;
  3511. }
  3512. break;
  3513. case SXF_TWO:
  3514. if (n < 3) {
  3515. printf("?Too few operands - \"%s\"\n",s);
  3516. sexprc++;
  3517. goto xdosexp;
  3518. }
  3519. break;
  3520. case SXF_ONE:
  3521. if (n != 2) {
  3522. printf("?Too %s operands - \"%s\"\n",
  3523. (n > 2) ? "many" : "few", s);
  3524. sexprc++;
  3525. goto xdosexp;
  3526. }
  3527. }
  3528. }
  3529. if (kwflags & SXF_PRE) { /* Predicate? */
  3530. if (n < 2) {
  3531. printf("?Too few operands - \"%s\"\n",s);
  3532. sexprc++;
  3533. goto xdosexp;
  3534. }
  3535. pflag = 1;
  3536. presult = 1;
  3537. }
  3538. if (kwflags & SXF_FLO) /* Operator requires floating point */
  3539. fpflag++; /* Force it */
  3540. if (x == SX_ROU) { /* ROUND can have 1 or 2 arguments */
  3541. if (n < 2 || n > 3) {
  3542. printf("?Too %s operands - \"%s\"\n",
  3543. (n > 3) ? "many" : "few", s);
  3544. sexprc++;
  3545. goto xdosexp;
  3546. }
  3547. }
  3548. if (x == SX_ROU) {
  3549. /* But they are not "cumulative" like other SEXP args */
  3550. /* So this case is handled specially */
  3551. char buf1[32], buf2[32];
  3552. float r;
  3553. char * s0, * s1;
  3554. char * q0, * q1;
  3555. s0 = p[2];
  3556. if (!s0) s0 = "";
  3557. if (!*s0) s0 = "0";
  3558. q0 = dosexp(s0);
  3559. ckstrncpy(buf1,q0,32);
  3560. q0 = buf1;
  3561. s1 = p[3];
  3562. if (!s1) s1 = "";
  3563. if (!*s1) s1 = "0";
  3564. q1 = dosexp(s1);
  3565. if (!q1) q1 = "";
  3566. if (!*q1) q1 = "0";
  3567. ckstrncpy(buf2,q1,32);
  3568. q1 = buf2;
  3569. r = ckround(atof(q0),(int)(atof(q1)),sxroundbuf,31);
  3570. s2 = sxroundbuf;
  3571. sexprc = 0;
  3572. goto xdosexp;
  3573. }
  3574. }
  3575. if (x == SX_SET || x == SX_LET || /* Assignment is special */
  3576. x == SX_INC || x == SX_DEC) {
  3577. int rc;
  3578. char c, * m, * s3;
  3579. if (n == 1) {
  3580. s2 = "";
  3581. goto xdosexp;
  3582. }
  3583. s2 = NULL;
  3584. for (i = 1; i < n; i += 2) { /* Loop thru operand pairs */
  3585. rc = 0;
  3586. s3 = p[i+1];
  3587. c = *s3;
  3588. debug(F110,sexpdebug("target p"),s3,0);
  3589. /* Make sure target doesn't have multiple words */
  3590. while (*s3) { if (*s3 < '!') { rc = 1; break; }; s3++; }
  3591. s3 = p[i+1];
  3592. if (rc) { /* If it does it must have been */
  3593. char * s4; /* an SEXP so evaluate it */
  3594. s3 = dosexp(s3);
  3595. s4 = s3;
  3596. rc = 0;
  3597. while (*s4) { if (*s4 < '!') { rc = 1; break; }; s4++; }
  3598. if (rc == 0) makestr(&(p[i+1]),s3);
  3599. }
  3600. /* And that it's not a number, etc. */
  3601. if (rc > 0 || isdigit(c) || c == '(') {
  3602. printf("?Invalid assignment - \"%s\"\n",s);
  3603. sexprc++;
  3604. goto xdosexp;
  3605. } else if (isalpha(c)) {
  3606. rc = xlookup(sexpconsts,s3,nsexpconsts,NULL);
  3607. if (rc > 0) {
  3608. printf("?Assignment to constant - \"%s\"\n",s);
  3609. sexprc++;
  3610. goto xdosexp;
  3611. }
  3612. }
  3613. /* If ++ or --, get current value of variable */
  3614. if (x == SX_INC || x == SX_DEC) {
  3615. int ok = 1;
  3616. char buf[32];
  3617. if (c == CMDQ) { /* A backslash variable */
  3618. int n = 32;
  3619. char * s = buf;
  3620. buf[0] = NUL;
  3621. if (zzstring(s3,&s,&n) < 0 || !buf[0])
  3622. ok = 0;
  3623. s2 = buf;
  3624. } else { /* A macro */
  3625. if ((k = mxlook(mactab,s3,nmac)) < 0)
  3626. ok = 0;
  3627. else
  3628. s2 = mactab[k].mval;
  3629. }
  3630. if (!ok) {
  3631. printf("?Not defined - \"%s\"\n",p[i+1]);
  3632. sexprc++;
  3633. goto xdosexp;
  3634. }
  3635. if (!s2) s2 = "";
  3636. k = xxfloat(s2,0);
  3637. if (k < 1) {
  3638. printf("?Not numeric - \"%s\"\n",p[i+1]);
  3639. sexprc++;
  3640. goto xdosexp;
  3641. }
  3642. while (*s2 == '+') s2++;
  3643. result = ckatofs(s2);
  3644. fpresult = floatval;
  3645. if (k > 1 || fpresult != result)
  3646. fpflag++;
  3647. }
  3648. if (n < i+2) { /* Variable with no value */
  3649. s2 = "";
  3650. if (x == SX_SET || x == SX_LET) {
  3651. delmac(p[i+1],1); /* Delete the variable */
  3652. break;
  3653. } else {
  3654. s2 = "1";
  3655. }
  3656. } else { /* Variable with value */
  3657. k = xxfloat(p[i+2],0); /* Is it a number? */
  3658. if (k > 0) {
  3659. s2 = p[i+2];
  3660. while (*s2 == '+') s2++;
  3661. } else {
  3662. s2 = dosexp(p[i+2]); /* Have value, evaluate it */
  3663. if (sexprc) goto xdosexp;
  3664. if (!s2) s2 = "";
  3665. if (!*s2 && (x == SX_INC || x == SX_DEC))
  3666. continue;
  3667. }
  3668. }
  3669. if (x == SX_INC || x == SX_DEC) {
  3670. k = xxfloat(s2,0);
  3671. if (k < 1) {
  3672. printf("?Not numeric - \"%s\"\n",s2);
  3673. sexprc++;
  3674. goto xdosexp;
  3675. }
  3676. while (*s2 == '+') s2++;
  3677. j = ckatofs(s2);
  3678. if (k > 1) {
  3679. fpj = floatval;
  3680. fpflag++;
  3681. } else {
  3682. fpj = (CKFLOAT)j;
  3683. }
  3684. if (x == SX_INC) {
  3685. result += j;
  3686. fpresult += fpj;
  3687. } else if (x == SX_DEC) {
  3688. result -= j;
  3689. fpresult -= fpj;
  3690. }
  3691. #ifdef FNFLOAT
  3692. if (result != fpresult) fpflag++;
  3693. #endif /* FNFLOAT */
  3694. s2 = (fpflag && !sexptrunc) ?
  3695. fpformat(fpresult,0,0) : ckfstoa(result);
  3696. }
  3697. if (x == SX_LET && cmdlvl > 0) /* LET makes var local */
  3698. addlocal(p[i+1]);
  3699. if ((rc = addmac(p[i+1],s2)) < 0) { /* Add the value */
  3700. switch (rc) {
  3701. case -3: m = "Array not declared"; break;
  3702. case -2: m = "Subscript out of range"; break;
  3703. case -4: m = "Out of memory"; break;
  3704. default: m = "Error creating variable";
  3705. }
  3706. printf("?%s - \"%s\"\n",m,s);
  3707. sexprc++;
  3708. goto xdosexp;
  3709. }
  3710. if (s2) result = ckatofs(s2);
  3711. }
  3712. goto xdosexp;
  3713. } else if (x == SX_IFC) { /* Conditional expression */
  3714. int true = 0;
  3715. if (n > 4) {
  3716. printf("?Too many operands: IF - \"%s\"\n",s);
  3717. sexprc++;
  3718. goto xdosexp;
  3719. }
  3720. s2 = dosexp(p[2]);
  3721. if (sexprc) goto xdosexp;
  3722. if (s2) {
  3723. j = ckatofs(s2);
  3724. if (xxfloat(s2,0) == 2) {
  3725. fpflag++;
  3726. fpresult = (CKFLOAT)result;
  3727. fpj = floatval;
  3728. } else {
  3729. fpj = atof(s2);
  3730. }
  3731. true = ((fpj != 0.0) ? 1 : 0);
  3732. }
  3733. if (!true && n < 4) {
  3734. s2 = NULL;
  3735. } else {
  3736. s2 = dosexp(true ? p[3] : p[4]);
  3737. if (sexprc) goto xdosexp;
  3738. j = s2 ? ckatofs(s2) : 0;
  3739. if (xxfloat(s2,0) == 2) {
  3740. fpflag++;
  3741. fpresult = (CKFLOAT)result;
  3742. fpj = floatval;
  3743. } else {
  3744. fpj = s2 ? atof(s2) : 0.0;
  3745. }
  3746. fpresult = fpj;
  3747. result = j;
  3748. }
  3749. goto xdosexp;
  3750. } else if (x == SX_QUO) {
  3751. int k, xx;
  3752. xx = strlen(p[2]);
  3753. p[3] = (char *)malloc(xx+4);
  3754. s2 = p[3];
  3755. ckmakmsg(p[3],xx+4,"'(",p[2],")",NULL);
  3756. n++;
  3757. goto xdosexp;
  3758. } else if (x == SX_UNQ) { /* UNQUOTE */
  3759. int k, xx = 0;
  3760. s2 = p[2];
  3761. if (!s2) s2 = "";
  3762. xx = strlen(s2);
  3763. // printf("XXX ENTRY: %s, len=%d\n",s2,xx);
  3764. if (xx = 0) /* Null or empty arg */
  3765. goto xdosexp;
  3766. /* Case 0 - number */
  3767. if (isfloat(s2,0))
  3768. goto xdosexp;
  3769. /* Case 2 - S-expression that evaluates to a quoted string */
  3770. if (s2[0] == '(' && s2[xx-1] == ')') {
  3771. // printf("XXX SEXP: %s\n",p[2]);
  3772. s2 = dosexp(s2);
  3773. // printf("XXX SEXP EVALUATED: %s\n",p[2]);
  3774. } else if (s2[0] != '\047') {
  3775. /* Case 3 - Variable */
  3776. // printf("XXX MACRO NAME: %s\n",p[2]);
  3777. if ((k = mxlook(mactab,p[2],nmac)) >= 0) {
  3778. s2 = mactab[k].mval;
  3779. // printf("XXX MACRO VALUE: %s\n",s2);
  3780. } else {
  3781. // printf("XXX UNDEFINED MACRO: %s\n",p[2]);
  3782. s2 = "";
  3783. }
  3784. }
  3785. /* If result is a quoted string, unquote it */
  3786. // printf("XXX BEFORE UNQUOTING: %s\n",s2);
  3787. xx = strlen(s2);
  3788. if (s2[0] == '\047' && s2[1] == '(' && s2[xx-1] == ')') {
  3789. // printf("XXX HAVE QUOTED STRING: %s\n",s2);
  3790. s2[xx-1] = NUL;
  3791. s2 += 2;
  3792. }
  3793. // printf("XXX RESULT: %s\n",s2);
  3794. goto xdosexp;
  3795. } else if (x == SX_STR) {
  3796. int xx;
  3797. s2 = dosexp(p[2]);
  3798. if (sexprc) goto xdosexp;
  3799. xx = strlen(s2);
  3800. p[3] = (char *)malloc(xx+4);
  3801. ckmakmsg(p[3],xx+4,"'(",s2,")",NULL);
  3802. s2 = p[3];
  3803. n++;
  3804. goto xdosexp;
  3805. }
  3806. }
  3807. /* Arithmetic operator or macro - Loop thru operands */
  3808. quit = 0; /* Short-circuit flag. */
  3809. if (macro && n > 1) { /* If operator is a macro */
  3810. if (!line) { /* allocate local buffer for */
  3811. line = (char *)malloc(SXMLEN); /* the evaluated argument list. */
  3812. if (!line) {
  3813. printf("?Memory allocation failure - \"%s\"\n",p[1]);
  3814. sexprc++;
  3815. goto xdosexp;
  3816. }
  3817. linelen = SXMLEN;
  3818. /* debug(F101,"dosexp macro arg buffer","",linelen); */
  3819. }
  3820. linepos = 0;
  3821. line[linepos] = NUL;
  3822. }
  3823. for (i = 1; ((i < n) && !sexprc && !quit); i++) { /* Loop thru operands */
  3824. quote = 0;
  3825. s2 = p[i+1]; /* Get operand */
  3826. if (!s2) s2 = "";
  3827. #ifdef COMMENT
  3828. if (*s2 == '\047') { /* Is it quoted? */
  3829. debug(F110,sexpdebug("'B"),s2,0);
  3830. s2++; /* Space past the quote */
  3831. quote++;
  3832. if (*s2 == '(') { /* Quoted S-Expression? */
  3833. char c4, * s4 = s2+1; /* Strip outer parens */
  3834. while ((c4 = *s4++)) {
  3835. if (c4 == ')' && !*s4) {
  3836. s2++;
  3837. *(s4-1) = NUL;
  3838. break;
  3839. }
  3840. }
  3841. }
  3842. debug(F110,sexpdebug("'C"),s2,0);
  3843. } else { /* Not quoted */
  3844. s2 = dosexp(p[i+1]); /* evaluate it */
  3845. if (sexprc) goto xdosexp;
  3846. if (!s2) s2 = "";
  3847. if (!macro && x == SX_EVA)
  3848. continue;
  3849. }
  3850. #else
  3851. if (*s2 != '\047') { /* Not quoted */
  3852. // printf("XXX UNQUOTED ARG %s\n",s2);
  3853. if (x == SX_ECH && (k = mxlook(mactab,s2,nmac)) > -1) {
  3854. s2 = mactab[k].mval;
  3855. // printf("XXX MACRO DEF %s\n",s2);
  3856. } else {
  3857. s2 = dosexp(s2); /* No, evaluate it */
  3858. // printf("XXX SEXP VALUE %s\n",s2);
  3859. }
  3860. if (sexprc && x != SX_ECH)
  3861. goto xdosexp;
  3862. if (!s2) s2 = "";
  3863. if (!macro && x == SX_EVA)
  3864. continue;
  3865. if (x == SX_ECH) { /* ECHO */
  3866. printf("%s ",s2);
  3867. if (i == n-1) printf("\n");
  3868. continue;
  3869. }
  3870. }
  3871. if (*s2 == '\047') { /* Is result quoted? */
  3872. debug(F110,sexpdebug("'B"),s2,0);
  3873. s2++; /* Space past the quote */
  3874. quote++;
  3875. if (*s2 == '(') { /* Quoted S-Expression? */
  3876. char c4, * s4 = s2+1; /* Strip outer parens */
  3877. while ((c4 = *s4++)) {
  3878. if (c4 == ')' && !*s4) {
  3879. s2++;
  3880. *(s4-1) = NUL;
  3881. break;
  3882. }
  3883. }
  3884. }
  3885. debug(F110,sexpdebug("'C"),s2,0);
  3886. if (x == SX_ECH) { /* ECHO */
  3887. printf("%s ",s2);
  3888. if (i == n-1) printf("\n");
  3889. continue;
  3890. }
  3891. }
  3892. #endif /* COMMENT */
  3893. if (macro) {
  3894. debug(F111,sexpdebug("macro arg"),s2,i);
  3895. if (!*s2) quote++;
  3896. if (!quote) {
  3897. register char c4, * s4 = s2;
  3898. while ((c4 = *s4++)) if (c4 == SP) { quote++; break; }
  3899. }
  3900. if (quote) line[linepos++] = '{';
  3901. while ((line[linepos++] = *s2++)) {
  3902. if (linepos > linelen - 3) {
  3903. char * tmp = NULL;
  3904. line[linepos] = NUL;
  3905. linelen += SXMLEN;
  3906. tmp = (char *) malloc(linelen);
  3907. if (!tmp) {
  3908. printf("?Memory re-allocation failure - \"%s...\"\n",
  3909. line);
  3910. sexprc++;
  3911. goto xdosexp;
  3912. }
  3913. strcpy(tmp,line);
  3914. free(line);
  3915. line = tmp;
  3916. }
  3917. }
  3918. linepos--; /* Back up over NUL */
  3919. if (quote)
  3920. line[linepos++] = '}'; /* End quote group */
  3921. line[linepos++] = SP; /* add a space */
  3922. line[linepos] = NUL; /* and a NUL */
  3923. continue;
  3924. }
  3925. if (!quote) { /* Built-in operator... */
  3926. s2 = dosexp(s2);
  3927. if (sexprc) goto xdosexp;
  3928. if (!s2) s2 = "";
  3929. }
  3930. if (x == SX_EVA)
  3931. continue;
  3932. if (!*s2) {
  3933. /* An empty value is not a legal number */
  3934. /* but it is a legal truth value */
  3935. if (x != SX_AND && x != SX_LOR && x != SX_NOT) {
  3936. printf("?Not Numeric - \"%s\"\n",p[i+1]);
  3937. sexprc++;
  3938. goto xdosexp;
  3939. }
  3940. j = 0;
  3941. fpj = 0.0;
  3942. } else {
  3943. j = ckatofs(s2);
  3944. /* Switch to floating-point upon encountering any f.p. arg */
  3945. /* OR... if integer is too big */
  3946. if (!fpflag) if (xxfloat(s2,0) == 2)
  3947. fpflag++;
  3948. fpj = atof(s2);
  3949. }
  3950. if (i == 1) { /* Initial result is first operand */
  3951. result = (n == 2 && x == SX_SUB) ? 0-j : j;
  3952. fpresult = (n == 2 && x == SX_SUB) ? -fpj : fpj;
  3953. if ((x == SX_AND && result == 0) || /* Short circuit */
  3954. (x == SX_LOR && result != 0))
  3955. quit++;
  3956. if (!(kwflags & SXF_ONE)) /* Command w/single arg */
  3957. continue;
  3958. }
  3959. if (x == SX_MOD || x == SX_DIV) {
  3960. if (!result)
  3961. fpflag++;
  3962. if (!fpj) {
  3963. printf("?Divide by zero - \"%s\"\n",cmdbuf);
  3964. sexprc++;
  3965. goto xdosexp;
  3966. }
  3967. }
  3968. switch (x) { /* Accumulate result */
  3969. case SX_EVA: /* EVAL */
  3970. result = j;
  3971. fpresult = fpj;
  3972. break;
  3973. case SX_ADD: /* + */
  3974. result += j;
  3975. fpresult += fpj;
  3976. #ifdef FNFLOAT
  3977. if (result != fpresult)
  3978. fpflag++;
  3979. #endif /* FNFLOAT */
  3980. break;
  3981. case SX_SUB: /* - */
  3982. result -= j;
  3983. fpresult -= fpj;
  3984. #ifdef FNFLOAT
  3985. if (result != fpresult)
  3986. fpflag++;
  3987. #endif /* FNFLOAT */
  3988. break;
  3989. case SX_MUL: /* * */
  3990. result *= j;
  3991. fpresult *= fpj;
  3992. #ifdef FNFLOAT
  3993. if (result != fpresult)
  3994. fpflag++;
  3995. #endif /* FNFLOAT */
  3996. break;
  3997. case SX_AND: /* AND */
  3998. result = result && j;
  3999. if (!result) quit++;
  4000. fpresult = fpresult && fpj;
  4001. break;
  4002. case SX_LOR: /* OR */
  4003. result = result || j;
  4004. if (!result) quit++;
  4005. fpresult = fpresult || fpj;
  4006. break;
  4007. case SX_MOD: /* Modulus */
  4008. result = result % j;
  4009. #ifdef FNFLOAT
  4010. fpresult = (CKFLOAT)fmod(fpresult,fpj);
  4011. if (result != fpresult)
  4012. fpflag++;
  4013. #else
  4014. fpresult = result;
  4015. #endif /* FNFLOAT */
  4016. break;
  4017. case SX_DIV: /* / */
  4018. if (j) {
  4019. result /= j;
  4020. fpresult /= fpj;
  4021. #ifdef FNFLOAT
  4022. if (result != fpresult)
  4023. fpflag++;
  4024. #endif /* FNFLOAT */
  4025. } else {
  4026. fpresult /= fpj;
  4027. result = fpj;
  4028. #ifdef FNFLOAT
  4029. fpflag++;
  4030. #endif /* FNFLOAT */
  4031. }
  4032. break;
  4033. case SX_AEQ: /* Test for equality */
  4034. if (fpflag) {
  4035. if (fpresult != fpj)
  4036. presult = 0;
  4037. } else {
  4038. if (result != j)
  4039. presult = 0;
  4040. }
  4041. break;
  4042. case SX_NEQ: /* Test for ineqality */
  4043. if (fpflag) {
  4044. if (fpresult == fpj)
  4045. presult = 0;
  4046. } else {
  4047. if (result == j)
  4048. presult = 0;
  4049. }
  4050. break;
  4051. case SX_ALE: /* Arithmetic less-equal */
  4052. if (fpflag) {
  4053. if (fpj < fpresult)
  4054. presult = 0;
  4055. fpresult = fpj;
  4056. } else {
  4057. if (j < result)
  4058. presult = 0;
  4059. result = j;
  4060. }
  4061. break;
  4062. case SX_ALT: /* Arithmetic less-than */
  4063. if (fpflag) {
  4064. if (fpj <= fpresult)
  4065. presult = 0;
  4066. fpresult = fpj;
  4067. } else {
  4068. if (j <= result)
  4069. presult = 0;
  4070. result = j;
  4071. }
  4072. break;
  4073. case SX_AGT: /* Arithmetic greater-than */
  4074. if (fpflag) {
  4075. if (fpj >= fpresult)
  4076. presult = 0;
  4077. fpresult = fpj;
  4078. } else {
  4079. if (j >= result)
  4080. presult = 0;
  4081. result = j;
  4082. }
  4083. break;
  4084. case SX_AGE: /* Arithmetic greater-equal */
  4085. if (fpflag) {
  4086. if (fpj > fpresult)
  4087. presult = 0;
  4088. fpresult = fpj;
  4089. } else {
  4090. if (j > result)
  4091. presult = 0;
  4092. result = j;
  4093. }
  4094. break;
  4095. case SX_POW: /* Raise to power */
  4096. #ifdef FNFLOAT
  4097. {
  4098. double dummy;
  4099. if (!fpj) {
  4100. fpresult = 1.0;
  4101. } else if ((!fpresult && fpj <= 0.0)) {
  4102. printf("?Divide by zero - \"%s\"\n",cmdbuf);
  4103. sexprc++;
  4104. goto xdosexp;
  4105. } else if (fpresult < 0.0 && modf(fpj,&dummy)) {
  4106. printf("?Domain error - \"%s\"\n",cmdbuf);
  4107. sexprc++;
  4108. goto xdosexp;
  4109. } else {
  4110. fpresult = (CKFLOAT)pow(fpresult,fpj);
  4111. }
  4112. }
  4113. #endif /* FNFLOAT */
  4114. if (j == 0) {
  4115. result = 1;
  4116. } else {
  4117. CK_OFF_T z, sign = 0;
  4118. if (j < 0) {
  4119. if (result == 0) {
  4120. printf("?Divide by zero - \"%s\"\n",cmdbuf);
  4121. sexprc++;
  4122. goto xdosexp;
  4123. }
  4124. j = 0 - j;
  4125. sign++;
  4126. }
  4127. z = result;
  4128. while (--j > 0)
  4129. result *= z;
  4130. if (sign)
  4131. result = 1 / result;
  4132. }
  4133. #ifdef FNFLOAT
  4134. if (result != fpresult)
  4135. fpflag++;
  4136. #endif /* FNFLOAT */
  4137. break;
  4138. #ifdef FNFLOAT
  4139. case SX_EXP: /* e to the given power */
  4140. fpresult = (CKFLOAT) exp(fpj);
  4141. break;
  4142. case SX_LGN: /* Natural log */
  4143. case SX_LGX: /* Log base 10 */
  4144. case SX_SQR: /* Square root */
  4145. if (fpj < 0.0) {
  4146. printf("?Argument out of range - \"%s\"\n",cmdbuf);
  4147. sexprc++;
  4148. goto xdosexp;
  4149. }
  4150. if (x == SX_SQR)
  4151. fpresult = (CKFLOAT) sqrt(fpj);
  4152. else if (x == SX_LGN)
  4153. fpresult = (CKFLOAT) log(fpj);
  4154. else
  4155. fpresult = (CKFLOAT) log10(fpj);
  4156. break;
  4157. case SX_SIN: /* sine */
  4158. fpresult = (CKFLOAT) sin(fpj);
  4159. break;
  4160. case SX_COS: /* cosine */
  4161. fpresult = (CKFLOAT) cos(fpj);
  4162. break;
  4163. case SX_TAN: /* tangent */
  4164. fpresult = (CKFLOAT) tan(fpj);
  4165. break;
  4166. #endif /* FNFLOAT */
  4167. case SX_CEI: /* Ceiling */
  4168. if (j != fpj)
  4169. if (fpj > 0.0)
  4170. fpj += 1.0;
  4171. fpresult = fpj;
  4172. fpflag = 1;
  4173. truncate = 1;
  4174. break;
  4175. case SX_FLR: /* Floor */
  4176. if (j != fpj)
  4177. if (fpj < 0.0)
  4178. fpj -= 1.0;
  4179. fpresult = fpj;
  4180. fpflag = 1;
  4181. truncate = 1;
  4182. break;
  4183. case SX_TRU: /* Truncate */
  4184. fpresult = fpj;
  4185. fpflag = 1;
  4186. truncate = 1;
  4187. break;
  4188. case SX_ABS: /* Absolute value */
  4189. result = (j < 0) ? 0 - j : j;
  4190. #ifdef FNFLOAT
  4191. fpresult = (fpj < 0.0) ? 0.0 - fpj : fpj;
  4192. if (result != fpresult)
  4193. fpflag++;
  4194. #endif /* FNFLOAT */
  4195. break;
  4196. case SX_MAX: /* Max */
  4197. if (j != fpj)
  4198. fpflag++;
  4199. if (fpflag) {
  4200. if (fpj > fpresult)
  4201. fpresult = fpj;
  4202. } else
  4203. if (j > result)
  4204. result = j;
  4205. break;
  4206. case SX_MIN: /* Min */
  4207. if (j != fpj)
  4208. fpflag++;
  4209. if (fpflag) {
  4210. if (fpj < fpresult)
  4211. fpresult = fpj;
  4212. } else
  4213. if (j < result)
  4214. result = j;
  4215. break;
  4216. case SX_FLO: /* Float */
  4217. fpflag++;
  4218. fpresult = result;
  4219. fpj = j;
  4220. break;
  4221. case SX_NOT: /* NOT (reverse truth value) */
  4222. fpflag = 0;
  4223. not++;
  4224. break;
  4225. case SX_BWA: /* Bitwise AND */
  4226. fpflag = 0;
  4227. result &= j;
  4228. break;
  4229. case SX_BWO: /* Bitwise OR */
  4230. fpflag = 0;
  4231. result |= j;
  4232. break;
  4233. case SX_BWX: /* Bitwise XOR */
  4234. case SX_XOR: /* Logical XOR */
  4235. if (n > 3) {
  4236. printf("?Too many operands - \"%s\"\n",s);
  4237. sexprc++;
  4238. goto xdosexp;
  4239. }
  4240. fpflag = 0;
  4241. if (x == SX_BWX) {
  4242. result ^= j;
  4243. } else {
  4244. result = (result && !j) || (!result && j);
  4245. if (result) result = 1;
  4246. }
  4247. break;
  4248. case SX_BWN: /* Bitwise Not */
  4249. fpflag = 0;
  4250. result = ~result;
  4251. break;
  4252. default:
  4253. printf("BAD OP [%s]\n",p[1]);
  4254. sexprc++;
  4255. }
  4256. }
  4257. if (!pflag) /* Not a predicate */
  4258. sexppv = -1; /* So unset this */
  4259. /* domacro: */
  4260. if (macro) { /* User-defined macro */
  4261. extern int fsexpflag; /* (see fneval():ckuus4.c) */
  4262. int lookagain = 0; /* Maybe the macro table changed */
  4263. if (mactab[mx].kwd) { /* Check and see */
  4264. if (ckstrcmp(mactab[mx].kwd,p[1],-1,0))
  4265. lookagain++;
  4266. } else
  4267. lookagain++;
  4268. if (lookagain) { /* The table changed */
  4269. mx = mxlook(mactab,p[1],nmac); /* Get the macro's new index */
  4270. debug(F111,sexpdebug("macro moved"),p[1],mx);
  4271. if (mx < 0) { /* Yikes! */
  4272. printf("?Macro disappeared! - \"%s\"\n",p[1]);
  4273. sexprc++;
  4274. goto xdosexp;
  4275. }
  4276. }
  4277. debug(F111,sexpdebug("macro mx"),mactab[mx].kwd,mx);
  4278. if (fsexpflag) { /* If embedded in a function call */
  4279. if (cmpush() > -1) { /* get a new copy of the parsing */
  4280. extern int ifc; /* environment, */
  4281. int k, ifcsav = ifc; /* save the IF state */
  4282. dodo(mx,line,0); /* Set up the macro */
  4283. k = parser(1); /* Call the parser to execute it */
  4284. cmpop(); /* Pop back to previous level */
  4285. ifc = ifcsav; /* restore IF state */
  4286. if (k == 0) /* If no error */
  4287. s2 = mrval[maclvl+1]; /* get return value, if any */
  4288. if (!s2) s2 = "";
  4289. debug(F110,sexpdebug("macro return"),s2,0);
  4290. } else {
  4291. printf("?Resources exhausted - \"%s\"\n",s);
  4292. sexprc++;
  4293. }
  4294. } else { /* Not embedded in a function call */
  4295. dodo(mx,line,0); /* As above but without cmpush/pop() */
  4296. k = parser(1);
  4297. if (k == 0)
  4298. s2 = mrval[maclvl+1];
  4299. if (!s2) s2 = "";
  4300. }
  4301. } else if (pflag) { /* Predicate */
  4302. if (not) presult = presult ? 0 : 1;
  4303. sexppv = presult; /* So set predicate value (0 or 1) */
  4304. s2 = presult ? "1" : "0";
  4305. } else if (fpflag && !sexptrunc) { /* Result is floating-point */
  4306. if (not) fpresult = fpresult ? 0.0 : 1.0;
  4307. s2 = fpformat(fpresult,0,0);
  4308. } else if (x != SX_EVA) {
  4309. if (not) result = result ? 0 : 1;
  4310. s2 = ckfstoa(result);
  4311. }
  4312. /* Common exit point. Always come here to exit. */
  4313. xdosexp:
  4314. if (!s2) s2 = "";
  4315. debug(F111,"xdosexp s2",s2,sexprc);
  4316. // printf("XXX xdosexp s2=[%s]\n",s2);
  4317. if (x == SX_ECH) s2 = "";
  4318. debug(F111,"xdosexp s2 ECHO",s2,sexprc);
  4319. if (!sexprc /* && *s2 */) { /* Have a result */
  4320. char * sx; /* Note -- do this even if result empty */
  4321. char * q2 = s2; int xx = 0;
  4322. if (*s2) {
  4323. while (*q2++) xx++; /* Get length */
  4324. if (xx > sexprmax) /* (stats) */
  4325. sexprmax = xx;
  4326. } else
  4327. xx = 0;
  4328. if (xx > sxrlen[sexpdep] || !sxresult[sexpdep]) {
  4329. int k;
  4330. k = xx + xx / 4;
  4331. if (k < 32) k = 32;
  4332. if (sxresult[sexpdep])
  4333. free(sxresult[sexpdep]);
  4334. if ((sxresult[sexpdep] = (char *)malloc(k))) {
  4335. sxrlen[sexpdep] = k;
  4336. } else {
  4337. printf("?Memory allocation failure - \"%s\"\n",s2);
  4338. sexprc++;
  4339. }
  4340. }
  4341. sx = sxresult[sexpdep]; /* Point to result buffer */
  4342. while ((*sx++ = *s2++)) ; /* copy result. */
  4343. if (fpflag && truncate) { /* Floating point + truncate */
  4344. sx = sxresult[sexpdep]; /* at decimal point */
  4345. for (i = xx - 1; i >= 0; i--) {
  4346. if (sx[i] == '.') {
  4347. sx[i] = NUL;
  4348. if (i == 0) { /* If nothing left */
  4349. sx[0] = '0'; /* put a zero. */
  4350. sx[1] = NUL;
  4351. }
  4352. }
  4353. }
  4354. }
  4355. }
  4356. xxdosexp:
  4357. if (line) /* If macro arg buffer allocated */
  4358. free(line); /* free it. */
  4359. if (mustfree) { /* And free local copy of split list */
  4360. for (i = 1; i <= n; i++) {
  4361. if (p[i]) free(p[i]);
  4362. }
  4363. }
  4364. debug(F111,sexpdebug("exit"),sxresult[sexpdep],sexprc);
  4365. s = sxresult[sexpdep--];
  4366. if (!s) s = "";
  4367. return(s);
  4368. }
  4369. #endif /* NOSEXP */
  4370. #endif /* NOSPL */
  4371. int /* CHECK command */
  4372. dochk() {
  4373. int x, y;
  4374. if ((y = cmkey(ftrtab,nftr,"","",xxstring)) < 0)
  4375. return(y);
  4376. ckstrncpy(line,atmbuf,LINBUFSIZ);
  4377. if ((y = cmcfm()) < 0)
  4378. return(y);
  4379. #ifdef HAVE_LOCALE
  4380. if (!ckstrcmp(line,"locale",(int)strlen(line),0)) {
  4381. extern int nolocale;
  4382. int ok = 0;
  4383. ok = (nolocale ? 0 : 1);
  4384. if (msgflg)
  4385. printf(" locale%s available\n", ok ? "" : " not");
  4386. else if (nolocale && !backgrd)
  4387. printf(" CHECK: locale not available\n");
  4388. return(success = ok);
  4389. }
  4390. #endif /* HAVE_LOCALE */
  4391. #ifndef NOPUSH
  4392. if (!ckstrcmp(line,"push",(int)strlen(line),0)) {
  4393. if (msgflg) /* If at top level... */
  4394. printf(" push%s available\n", nopush ? " not" : "");
  4395. else if (nopush && !backgrd)
  4396. printf(" CHECK: push not available\n");
  4397. return(success = 1 - nopush);
  4398. }
  4399. #endif /* NOPUSH */
  4400. #ifdef PIPESEND
  4401. if (!ckstrcmp(line,"pipes",(int)strlen(line),0)) {
  4402. if (msgflg) /* If at top level... */
  4403. printf(" pipes%s available\n",
  4404. (nopush || protocol != PROTO_K) ? " not" : "");
  4405. else if ((nopush || protocol != PROTO_K) && !backgrd)
  4406. printf(" CHECK: pipes not available\n");
  4407. return(success = 1 - nopush);
  4408. }
  4409. #endif /* PIPESEND */
  4410. y = lookup(ftrtab,line,nftr,&x); /* Look it up */
  4411. debug(F111,"dochk",ftrtab[x].kwd,y);
  4412. if (msgflg) /* If at top level... */
  4413. printf(" %s%s available\n", ftrtab[x].kwd, y ? " not" : "");
  4414. else if (y && !backgrd)
  4415. printf(" CHECK: %s not available\n", ftrtab[x].kwd);
  4416. return(success = 1 - y);
  4417. }
  4418. #ifndef NOLOCAL
  4419. #ifdef CKLOGDIAL
  4420. /* Connection log and elapsed-time reporting */
  4421. extern char cxlogbuf[]; /* Log record buffer */
  4422. extern char diafil[]; /* Log file name */
  4423. extern int dialog, cx_active; /* Flags */
  4424. static long cx_prev = 0L; /* Elapsed time of previous session */
  4425. #endif /* CKLOGDIAL */
  4426. #endif /* NOLOCAL */
  4427. VOID
  4428. dologend() { /* Write record to connection log */
  4429. #ifdef LOCUS
  4430. extern int locus, autolocus;
  4431. #endif /* LOCUS */
  4432. #ifndef NOLOCAL
  4433. #ifdef CKLOGDIAL
  4434. long d1, d2, t1, t2;
  4435. char buf[32], * p;
  4436. #endif /* CKLOGDIAL */
  4437. #endif /* NOLOCAL */
  4438. #ifdef LOCUS
  4439. if (autolocus) {
  4440. int x = locus;
  4441. #ifdef NEWFTP
  4442. debug(F101,"dologend ftpisconnected","",ftpisconnected());
  4443. setlocus(ftpisconnected() ? 0 : 1, 1);
  4444. #else
  4445. setlocus(1,1);
  4446. #endif /* NEWFTP */
  4447. }
  4448. #endif /* LOCUS */
  4449. #ifndef NOLOCAL
  4450. #ifdef CKLOGDIAL
  4451. debug(F101,"dologend dialog","",dialog);
  4452. debug(F101,"dologend cxlogbuf[0]","",cxlogbuf[0]);
  4453. #ifdef CKSYSLOG
  4454. debug(F101,"dologend ckxlogging","",ckxlogging);
  4455. #endif /* CKSYSLOG */
  4456. if (!cx_active || !cxlogbuf[0]) /* No active record */
  4457. return;
  4458. cx_active = 0; /* Record is not active */
  4459. debug(F111,"dologend cxlogbuf 1",cxlogbuf,cx_active);
  4460. d1 = mjd((char *)cxlogbuf); /* Get start date of this session */
  4461. ckstrncpy(buf,ckdate(),31); /* Get current date */
  4462. d2 = mjd(buf); /* Convert them to mjds */
  4463. p = cxlogbuf; /* Get start time */
  4464. p[11] = NUL;
  4465. p[14] = NUL; /* Convert to seconds */
  4466. t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
  4467. p[11] = ':';
  4468. p[14] = ':';
  4469. p = buf; /* Get end time */
  4470. p[11] = NUL;
  4471. p[14] = NUL;
  4472. t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
  4473. t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Compute elapsed time */
  4474. debug(F101,"dologend t2","",t2);
  4475. if (t2 > -1L) {
  4476. cx_prev = t2;
  4477. p = hhmmss(t2);
  4478. debug(F110,"dologend hhmmss",p,0);
  4479. ckstrncat(cxlogbuf,"E=",CXLOGBUFL); /* Append to log record */
  4480. ckstrncat(cxlogbuf,p,CXLOGBUFL);
  4481. debug(F110,"dologend cxlogbuf 2",cxlogbuf,0);
  4482. } else
  4483. cx_prev = 0L;
  4484. debug(F101,"dologend cx_prev","",cx_prev);
  4485. if (dialog) { /* If logging */
  4486. int x;
  4487. x = diaopn(diafil,1,1); /* Open log in append mode */
  4488. debug(F101,"dologend diaopn","",x);
  4489. x = zsoutl(ZDIFIL,cxlogbuf); /* Write the record */
  4490. debug(F101,"dologend zsoutl","",x);
  4491. x = zclose(ZDIFIL); /* Close the log */
  4492. debug(F101,"dologend zclose","",x);
  4493. }
  4494. #ifdef CKSYSLOG
  4495. debug(F101,"dologend ckxlogging","",ckxlogging);
  4496. if (ckxlogging) {
  4497. int x;
  4498. x = ckindex("T=DIAL",cxlogbuf,0,0,1);
  4499. debug(F111,"dologend ckxsyslog",cxlogbuf,ckxsyslog);
  4500. debug(F111,"dologend ckindex","T=DIAL",x);
  4501. if (x > 0) {
  4502. if (ckxsyslog >= SYSLG_DI) {
  4503. debug(F110,"dologend syslog",cxlogbuf+18,0);
  4504. cksyslog(SYSLG_DI,1,"CONNECTION",(char *)(cxlogbuf+18),"");
  4505. } else if (ckxsyslog >= SYSLG_AC) {
  4506. debug(F110,"dologend syslog",cxlogbuf+18,0);
  4507. cksyslog(SYSLG_AC,1,"CONNECTION",(char *)(cxlogbuf+18),"");
  4508. }
  4509. }
  4510. }
  4511. #endif /* CKSYSLOG */
  4512. #endif /* CKLOGDIAL */
  4513. #endif /* NOLOCAL */
  4514. }
  4515. #ifndef NOLOCAL
  4516. #ifdef CKLOGDIAL
  4517. /* D O L O G S H O W -- Show session/connection info */
  4518. /* Call with fc == 1 to show, fc == 0 to only calculate. */
  4519. /* Returns session elapsed time in seconds. */
  4520. /* If no session active, returns elapsed time of previous session, if any, */
  4521. /* otherwise 0 */
  4522. long
  4523. dologshow(fc) int fc; { /* SHOW (current) CONNECTION */
  4524. long d1, d2, t1, t2 = 0, prev;
  4525. char c, buf1[32], buf2[32], * info[32], * p, * s;
  4526. char * xlogbuf, xbuf[CXLOGBUFL+1];
  4527. int i, x = 0, z, ftp = 0, active = 0;
  4528. #ifdef NEWFTP
  4529. extern char ftplogbuf[];
  4530. extern long ftplogprev;
  4531. extern int ftplogactive;
  4532. if (fc & W_FTP) {
  4533. fc &= 63;
  4534. ftp = 1;
  4535. xlogbuf = ftplogbuf;
  4536. prev = ftplogprev;
  4537. active = ftplogactive;
  4538. } else {
  4539. #endif /* NEWFTP */
  4540. ftp = 0;
  4541. xlogbuf = cxlogbuf;
  4542. prev = cx_prev;
  4543. active = cx_active;
  4544. #ifdef NEWFTP
  4545. }
  4546. #endif /* NEWFTP */
  4547. debug(F101,"dologshow local","",local);
  4548. debug(F101,"dologshow ftp","",ftp);
  4549. debug(F111,"dologshow active",xlogbuf,active);
  4550. if (!xlogbuf[0]) {
  4551. if (fc) {
  4552. if (didsetlin || ftp)
  4553. printf(" %s: No record.\n", ftp ? "FTP" : "Kermit");
  4554. else
  4555. printf(" %s: No connection.\n", ftp ? "FTP" : "Kermit");
  4556. }
  4557. return(prev);
  4558. }
  4559. #ifdef NEWFTP
  4560. if (ftp) {
  4561. z = ftpisconnected() ? 1 : -1;
  4562. } else {
  4563. #endif /* NEWFTP */
  4564. if (local) { /* See if we have an open connection */
  4565. z = ttchk();
  4566. debug(F101,"dologshow ttchk","",z);
  4567. z = (z > -1) ? 1 : -2;
  4568. } else {
  4569. z = active ? 1 : -2;
  4570. }
  4571. #ifdef NEWFTP
  4572. }
  4573. #endif /* NEWFTP */
  4574. if (z < 0L) {
  4575. if (!fc)
  4576. return(prev);
  4577. else
  4578. t2 = prev;
  4579. }
  4580. /* Note: NOT ckstrncpy! */
  4581. strncpy(buf1,xlogbuf,17); /* Copy of just the timestamp */
  4582. buf1[17] = NUL; /* Terminate it */
  4583. ckstrncpy(xbuf,xlogbuf+18,CXLOGBUFL); /* Copy that can be poked */
  4584. debug(F111,"dologshow prev",xbuf,prev);
  4585. xwords(xbuf,31,info,1); /* Break up into fields */
  4586. d1 = mjd(buf1); /* Convert start time to MJD */
  4587. ckstrncpy(buf2,ckdate(),31); /* Current date */
  4588. d2 = mjd(buf2); /* Convert to MJD */
  4589. p = buf1; /* Point to start time */
  4590. p[11] = NUL;
  4591. p[14] = NUL; /* Convert to seconds */
  4592. t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
  4593. p[11] = ':';
  4594. p[14] = ':';
  4595. p = buf2; /* Ditto for current time */
  4596. p[11] = NUL;
  4597. p[14] = NUL;
  4598. if (z > -1L) {
  4599. t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
  4600. t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Elapsed time so far */
  4601. }
  4602. if (fc) {
  4603. p = NULL;
  4604. if (t2 > -1L) /* Convert seconds to hh:mm:ss */
  4605. p = hhmmss(t2);
  4606. if (z > -1)
  4607. s = "Active";
  4608. else if (z == -2)
  4609. s = "Closed";
  4610. else
  4611. s = "Unknown";
  4612. printf("\n"); /* Show results */
  4613. printf(" Status: %s\n",s);
  4614. printf(" Opened: %s\n",buf1);
  4615. printf(" User: %s\n",info[1] ? info[1] : "");
  4616. printf(" PID: %s\n",info[2] ? info[2] : "");
  4617. for (i = 3; info[i]; i++) {
  4618. c = info[i][0];
  4619. s = (info[i]) ? info[i]+2 : "";
  4620. switch (c) {
  4621. case 'T': printf(" Type: %s\n", s); break;
  4622. case 'N': printf(" To: %s\n", s); break;
  4623. case 'P': printf(" Port: %s\n", s); break;
  4624. case 'H': printf(" From: %s\n", s); break;
  4625. case 'D': printf(" Device: %s\n", s); break;
  4626. case 'O': printf(" Origin: %s\n", s); break;
  4627. case 'E': break;
  4628. default: printf(" %s\n",info[i] ? info[i] : "");
  4629. }
  4630. }
  4631. if (z < 0L)
  4632. printf(" Elapsed time: %s\n", hhmmss(t2));
  4633. else
  4634. printf(" Elapsed time: %s\n", p ? p : "(unknown)");
  4635. x = 0;
  4636. #ifdef NETCONN
  4637. #ifdef SSHBUILTIN
  4638. if ( IS_SSH() ) x++;
  4639. #endif /* SSHBUILTIN */
  4640. #ifdef CK_ENCRYPTION
  4641. if (ck_tn_encrypting() && ck_tn_decrypting()) x++;
  4642. #endif /* CK_ENCRYPTION */
  4643. #ifdef CK_SSL
  4644. if (tls_active_flag || ssl_active_flag) x++;
  4645. #endif /* CK_SSL */
  4646. #ifdef RLOGCODE
  4647. #ifdef CK_KERBEROS
  4648. #ifdef CK_ENCRYPTION
  4649. if (ttnproto == NP_EK4LOGIN || ttnproto == NP_EK5LOGIN) x++;
  4650. #endif /* CK_ENCRYPTION */
  4651. #endif /* CK_KERBEROS */
  4652. #endif /* RLOGCODE */
  4653. #endif /* NETCONN */
  4654. if (z > 0)
  4655. printf(" Encrypted: %s\n", x ? "Yes" : "No");
  4656. printf(" Log: %s\n", dialog ? diafil : "(none)");
  4657. printf("\n");
  4658. }
  4659. return(t2 > -1L ? t2 : 0L);
  4660. }
  4661. VOID
  4662. dologline() {
  4663. char * p;
  4664. int n, m = 0;
  4665. dologend(); /* Previous session not closed out? */
  4666. cx_active = 1; /* Record is active */
  4667. cx_prev = 0L;
  4668. p = ckdate(); /* Get timestamp */
  4669. n = ckstrncpy(cxlogbuf,p,CXLOGBUFL-1); /* Start record off with it */
  4670. if (!uidbuf[0]) {
  4671. debug(F100,"dologline uidbuf empty","",0);
  4672. #ifdef UNIX /* Who has whoami()... */
  4673. ckstrncpy(uidbuf,(char *)whoami(),UIDBUFLEN);
  4674. #else
  4675. #ifdef STRATUS
  4676. ckstrncpy(uidbuf,(char *)whoami(),UIDBUFLEN);
  4677. #else
  4678. ckstrncpy(uidbuf,"UNKNOWN",UIDBUFLEN);
  4679. #endif /* STRATUS */
  4680. #endif /* UNIX */
  4681. }
  4682. m = strlen(uidbuf) + strlen(myhost) + strlen(ttname) + 32;
  4683. if (n+m < CXLOGBUFL-1) { /* Add serial device info */
  4684. p = cxlogbuf+n;
  4685. sprintf(p," %s %s T=SERIAL H=%s D=%s ", /* SAFE */
  4686. uidbuf,
  4687. ckgetpid(),
  4688. myhost,
  4689. ttname
  4690. );
  4691. } else
  4692. ckstrncpy(cxlogbuf,"LOGLINE BUFFER OVERFLOW",CXLOGBUFL);
  4693. debug(F110,"dologline",cxlogbuf,0);
  4694. }
  4695. #ifdef NETCONN
  4696. VOID
  4697. dolognet() {
  4698. char * p, * s = "NET", * uu = uidbuf;
  4699. char * port = "";
  4700. int n, m, tcp = 0;
  4701. char * h = NULL;
  4702. dologend(); /* Previous session not closed out? */
  4703. cx_prev = 0L;
  4704. cx_active = 1; /* Record is active */
  4705. p = ckdate();
  4706. n = ckstrncpy(cxlogbuf,p,CXLOGBUFL);
  4707. #ifdef TCPSOCKET
  4708. if (nettype == NET_TCPB || nettype == NET_TCPA) {
  4709. tcp++;
  4710. s = "TCP";
  4711. } else if (nettype == NET_SSH) {
  4712. s = "SSH";
  4713. tcp++;
  4714. }
  4715. #endif /* TCPSOCKET */
  4716. #ifdef ANYX25
  4717. if (nettype == NET_SX25 || nettype == NET_VX25 || nettype == NET_IX25)
  4718. s = "X25";
  4719. #endif /* ANYX25 */
  4720. #ifdef DECNET
  4721. if (nettype == NET_DEC)
  4722. s = "DECNET";
  4723. #endif /* DECNET */
  4724. #ifdef SUPERLAT
  4725. if (nettype == NET_SLAT)
  4726. s = "SUPERLAT";
  4727. #endif /* SUPERLAT */
  4728. #ifdef CK_NETBIOS
  4729. if (nettype == NET_BIOS)
  4730. s = "NETBIOS";
  4731. #endif /* CK_NETBIOS */
  4732. if (!uu[0]) {
  4733. debug(F100,"dolognet uidbuf empty","",0);
  4734. #ifdef OS2ORUNIX /* Who has whoami()... */
  4735. uu = (char *)whoami();
  4736. #else
  4737. #ifdef STRATUS
  4738. uu = (char *)whoami();
  4739. #else
  4740. uu = "UNKNOWN";
  4741. #endif /* STRATUS */
  4742. #endif /* UNIX */
  4743. }
  4744. #ifdef TCPSOCKET
  4745. if (tcp) {
  4746. int k;
  4747. makestr(&h,myhost);
  4748. if ((k = ckindex(":",h,0,0,0)) > 0) {
  4749. h[k-1] = NUL;
  4750. port = &h[k];
  4751. } else {
  4752. int svcnum = gettcpport();
  4753. if (svcnum > 0)
  4754. port = ckitoa(svcnum);
  4755. else
  4756. port = "unk";
  4757. }
  4758. }
  4759. #endif /* TCPSOCKET */
  4760. m = strlen(uu) + strlen(myhost) + strlen(ttname) + strlen(s) + 32;
  4761. if (n+m < CXLOGBUFL-1) { /* SAFE */
  4762. p = cxlogbuf+n;
  4763. sprintf(p," %s %s T=%s N=%s H=%s P=%s ",
  4764. uu,
  4765. ckgetpid(),
  4766. s,
  4767. ttname,
  4768. myhost,
  4769. port
  4770. );
  4771. } else
  4772. ckstrncpy(cxlogbuf,"LOGNET BUFFER OVERFLOW",CXLOGBUFL);
  4773. debug(F110,"dolognet cxlogbuf",cxlogbuf,0);
  4774. if (h) makestr(&h,NULL);
  4775. }
  4776. #endif /* NETCONN */
  4777. #endif /* CKLOGDIAL */
  4778. #ifndef NODIAL
  4779. /*
  4780. Parse a DIAL-related string, stripping enclosing braces, if any.
  4781. */
  4782. static int
  4783. dialstr(p,msg) char **p; char *msg; {
  4784. int x;
  4785. char *s;
  4786. if ((x = cmtxt(msg, "", &s, xxstring)) < 0)
  4787. return(x);
  4788. s = brstrip(s); /* Strip braces around. */
  4789. debug(F110,"dialstr",s,0);
  4790. makestr(p,*s?s:NULL);
  4791. return(success = 1);
  4792. }
  4793. VOID
  4794. initmdm(x) int x; {
  4795. MDMINF * p;
  4796. int m;
  4797. mdmtyp = x; /* Set global modem type */
  4798. debug(F101,"initmdm mdmtyp","",mdmtyp);
  4799. debug(F101,"initmdm usermdm","",usermdm);
  4800. if (x < 1) return;
  4801. m = usermdm ? usermdm : mdmtyp;
  4802. p = modemp[m]; /* Point to modem info struct, and */
  4803. /* debug(F101,"initmdm p","",p); */
  4804. if (p) {
  4805. dialec = p->capas & CKD_EC; /* set DIAL ERROR-CORRECTION, */
  4806. dialdc = p->capas & CKD_DC; /* DIAL DATA-COMPRESSION, and */
  4807. mdmspd = p->capas & CKD_SB ? 0 : 1; /* DIAL SPEED-MATCHING from it. */
  4808. dialfc = FLO_AUTO; /* Modem's local flow control.. */
  4809. dialmax = p->max_speed;
  4810. dialcapas = p->capas;
  4811. dialesc = p->esc_char;
  4812. } else if (mdmtyp > 0) {
  4813. printf("WARNING: modem info for \"%s\" not filled in yet\n",
  4814. gmdmtyp()
  4815. );
  4816. }
  4817. /* Reset or set the SET DIAL STRING items ... */
  4818. #ifdef DEBUG
  4819. if (deblog) {
  4820. debug(F110,"initmdm dialini",dialini,0);
  4821. debug(F110,"initmdm dialmstr ",dialmstr,0);
  4822. debug(F110,"initmdm dialmprmt",dialmprmt,0);
  4823. debug(F110,"initmdm dialcmd",dialcmd,0);
  4824. debug(F110,"initmdm dialdcon",dialdcon,0);
  4825. debug(F110,"initmdm dialdcoff",dialdcoff,0);
  4826. debug(F110,"initmdm dialecon",dialecon,0);
  4827. debug(F110,"initmdm dialecoff",dialecoff,0);
  4828. debug(F110,"initmdm dialhcmd",dialhcmd,0);
  4829. debug(F110,"initmdm dialhwfc",dialhwfc,0);
  4830. debug(F110,"initmdm dialswfc",dialswfc,0);
  4831. debug(F110,"initmdm dialnofc",dialnofc,0);
  4832. debug(F110,"initmdm dialtone",dialtone,0);
  4833. debug(F110,"initmdm dialpulse",dialpulse,0);
  4834. debug(F110,"initmdm dialname",dialname,0);
  4835. debug(F110,"initmdm dialaaon",dialaaon,0);
  4836. debug(F110,"initmdm dialaaoff",dialaaoff,0);
  4837. debug(F110,"initmdm dialx3",dialx3,0);
  4838. debug(F110,"initmdm dialspon",dialspon,0);
  4839. debug(F110,"initmdm dialspoff",dialspoff,0);
  4840. debug(F110,"initmdm dialvol1",dialvol1,0);
  4841. debug(F110,"initmdm dialvol2",dialvol2,0);
  4842. debug(F110,"initmdm dialvol3",dialvol3,0);
  4843. debug(F110,"initmdm dialini2",dialini2,0);
  4844. }
  4845. #endif /* DEBUG */
  4846. if (usermdm && p) { /* USER-DEFINED: copy info from specified template */
  4847. makestr(&dialini ,p->wake_str);
  4848. makestr(&dialmstr ,p->dmode_str);
  4849. makestr(&dialmprmt,p->dmode_prompt);
  4850. makestr(&dialcmd ,p->dial_str);
  4851. makestr(&dialdcon ,p->dc_on_str);
  4852. makestr(&dialdcoff,p->dc_off_str);
  4853. makestr(&dialecon ,p->ec_on_str);
  4854. makestr(&dialecoff,p->ec_off_str);
  4855. makestr(&dialhcmd ,p->hup_str);
  4856. makestr(&dialhwfc ,p->hwfc_str);
  4857. makestr(&dialswfc ,p->swfc_str);
  4858. makestr(&dialnofc ,p->nofc_str);
  4859. makestr(&dialtone ,p->tone);
  4860. makestr(&dialpulse,p->pulse);
  4861. makestr(&dialname ,"This space available (use SET MODEM NAME)");
  4862. makestr(&dialaaon ,p->aa_on_str);
  4863. makestr(&dialaaoff,p->aa_off_str);
  4864. makestr(&dialx3 ,p->ignoredt);
  4865. makestr(&dialspon ,p->sp_on_str);
  4866. makestr(&dialspoff,p->sp_off_str);
  4867. makestr(&dialvol1 ,p->vol1_str);
  4868. makestr(&dialvol2 ,p->vol2_str);
  4869. makestr(&dialvol3 ,p->vol3_str);
  4870. makestr(&dialini2 ,p->ini2);
  4871. } else { /* Not user-defined, so wipe out overrides */
  4872. if (dialini) makestr(&dialini,NULL); /* Init-string */
  4873. if (dialmstr) makestr(&dialmstr,NULL); /* Dial-mode-str */
  4874. if (dialmprmt) makestr(&dialmprmt,NULL); /* Dial-mode-pro */
  4875. if (dialcmd) makestr(&dialcmd,NULL); /* Dial-command */
  4876. if (dialdcon) makestr(&dialdcon,NULL); /* DC ON command */
  4877. if (dialdcoff) makestr(&dialdcoff,NULL); /* DC OFF command */
  4878. if (dialecon) makestr(&dialecon,NULL); /* EC ON command */
  4879. if (dialecoff) makestr(&dialecoff,NULL); /* EC OFF command */
  4880. if (dialhcmd) makestr(&dialhcmd,NULL); /* Hangup command */
  4881. if (dialhwfc) makestr(&dialhwfc,NULL); /* Flow control... */
  4882. if (dialswfc) makestr(&dialswfc,NULL); /* */
  4883. if (dialnofc) makestr(&dialnofc,NULL); /* */
  4884. if (dialtone) makestr(&dialtone,NULL); /* Dialing method */
  4885. if (dialpulse) makestr(&dialpulse,NULL); /* */
  4886. if (dialname) makestr(&dialname,NULL); /* Modem name */
  4887. if (dialaaon) makestr(&dialaaon,NULL); /* Autoanswer On */
  4888. if (dialaaoff) makestr(&dialaaoff,NULL); /* Autoanswer Off */
  4889. if (dialx3) makestr(&dialx3,NULL); /* Ignore dialtone */
  4890. if (dialspon) makestr(&dialspon,NULL); /* Speaker On */
  4891. if (dialspoff) makestr(&dialspoff,NULL); /* Speaker Off */
  4892. if (dialvol1) makestr(&dialvol1,NULL); /* Low volume */
  4893. if (dialvol2) makestr(&dialvol2,NULL); /* Medium volume */
  4894. if (dialvol3) makestr(&dialvol3,NULL); /* High volume */
  4895. if (dialini2) makestr(&dialini2,NULL); /* Init string 2 */
  4896. }
  4897. if (autoflow) /* Maybe change flow control */
  4898. setflow();
  4899. #ifndef MINIDIAL
  4900. #ifdef OLDTBCODE
  4901. tbmodel = 0; /* If it's a Telebit, we don't know the model yet */
  4902. #endif /* OLDTBCODE */
  4903. #endif /* MINIDIAL */
  4904. }
  4905. #ifdef COMMENT
  4906. /* Not implemented yet */
  4907. int
  4908. setanswer() {
  4909. int x, y;
  4910. extern int ans_cid, ans_ring;
  4911. if ((x = cmkey(answertab,nanswertab,"","",xxstring)) < 0)
  4912. return(x);
  4913. switch (x) {
  4914. case XYA_CID:
  4915. return(seton(&ans_cid));
  4916. case XYA_RNG:
  4917. y = cmnum("How many rings before answering","1",10,&x,xxstring);
  4918. y = setnum(&ans_rings,x,y,254);
  4919. return(y);
  4920. }
  4921. }
  4922. #endif /* COMMENT */
  4923. int
  4924. setmodem() { /* SET MODEM */
  4925. int x, y, z;
  4926. long zz;
  4927. struct FDB k1, k2;
  4928. extern int mdmset;
  4929. cmfdbi(&k1,_CMKEY,
  4930. "Modem parameter","","",nsetmdm, 0, xxstring, setmdm, &k2);
  4931. cmfdbi(&k2,_CMKEY,"","","",nmdm,0,xxstring,mdmtab,NULL);
  4932. x = cmfdb(&k1);
  4933. if (x < 0) { /* Error */
  4934. if (x == -2 || x == -9)
  4935. printf("?No keywords match: \"%s\"\n",atmbuf);
  4936. return(x);
  4937. }
  4938. y = cmresult.nresult; /* Keyword value */
  4939. if (cmresult.fdbaddr == &k2) { /* Modem-type keyword table */
  4940. if ((x = cmcfm()) < 0)
  4941. return(x);
  4942. usermdm = 0;
  4943. initmdm(cmresult.nresult); /* Set the modem type. */
  4944. return(success = 1); /* Done */
  4945. }
  4946. switch (cmresult.nresult) { /* SET MODEM keyword table. */
  4947. #ifdef MDMHUP
  4948. case XYDMHU: /* DIAL MODEM-HANGUP */
  4949. if ((y = cmkey(mdmhang,4,"how to hang up modem",
  4950. "modem-command", xxstring)) < 0)
  4951. return(y);
  4952. if ((x = cmcfm()) < 0)
  4953. return(x);
  4954. dialmhu = y;
  4955. #ifdef COMMENT
  4956. /* Nope, I fixed it (2001 11 08) */
  4957. #ifdef CK_SCOV5
  4958. if (dialmhu == 0 && !quiet) {
  4959. printf(
  4960. "\n WARNING: RS-232 signal sampling and manipulation do not work\n"
  4961. );
  4962. printf(
  4963. " in the standard SCO OSR5 serial i/o drivers. SET MODEM HANGUP-METHOD\n"
  4964. );
  4965. printf(
  4966. " MODEM-COMMAND is recommended for OSR5.\n\n"
  4967. );
  4968. }
  4969. #endif /* CK_SCOV5 */
  4970. #endif /* COMMENT */
  4971. return(success = 1);
  4972. #endif /* MDMHUP */
  4973. case XYDCAP:
  4974. zz = 0L;
  4975. y = 0;
  4976. while (y != -3) {
  4977. if ((y = cmkey(mdmcap,nmdmcap,
  4978. "capability of modem", "", xxstring)) < 0) {
  4979. if (y == -3)
  4980. break;
  4981. else
  4982. return(y);
  4983. }
  4984. zz |= y;
  4985. }
  4986. if ((x = cmcfm()) < 0)
  4987. return(x);
  4988. dialcapas = zz;
  4989. debug(F101,"setmodem autoflow","",autoflow);
  4990. debug(F101,"setmodem flow 1","",flow);
  4991. if (autoflow) /* Maybe change flow control */
  4992. setflow();
  4993. debug(F101,"setmodem flow 2","",flow);
  4994. mdmspd = zz & CKD_SB ? 0 : 1; /* Set MODEM SPEED-MATCHING from it. */
  4995. return(success = 1);
  4996. case XYDMAX:
  4997. #ifdef TN_COMPORT
  4998. if (network && istncomport())
  4999. x = cmkey(tnspdtab,ntnspd,line,"",xxstring);
  5000. else
  5001. #endif /* TN_COMPORT */
  5002. x = cmkey(spdtab,nspd,line,"",xxstring);
  5003. if (x < 0) {
  5004. if (x == -3) printf("?value required\n");
  5005. return(x);
  5006. }
  5007. if ((y = cmcfm()) < 0) return(y);
  5008. dialmax = (long) x * 10L;
  5009. if (dialmax == 70) dialmax = 75;
  5010. return(success = 1);
  5011. case XYDSTR: /* These moved from SET DIAL */
  5012. case XYDDC:
  5013. case XYDEC:
  5014. case XYDESC:
  5015. case XYDFC:
  5016. case XYDKSP:
  5017. case XYDSPD:
  5018. case XYDDIA:
  5019. return(setdial(x));
  5020. case XYDTYP:
  5021. if ((y = cmkey(mdmtab,nmdm,"modem type","none", xxstring)) < 0)
  5022. return(y);
  5023. if (y == dialudt) { /* User-defined modem type */
  5024. if ((x = cmkey(mdmtab,nmdm,"based on existing modem type",
  5025. "unknown", xxstring)) < 0)
  5026. return(x);
  5027. }
  5028. if ((z = cmcfm()) < 0)
  5029. return(z);
  5030. usermdm = 0;
  5031. usermdm = (y == dialudt) ? x : 0;
  5032. initmdm(y);
  5033. mdmset = (mdmtyp > 0);
  5034. return(success = 1);
  5035. case XYDNAM:
  5036. return(dialstr(&dialname,"Descriptive name for modem"));
  5037. case XYDMCD: /* SET MODEM CARRIER-WATCH */
  5038. return(setdcd());
  5039. case XYDSPK: /* SET MODEM SPEAKER */
  5040. return(seton(&mdmspk));
  5041. case XYDVOL: /* SET MODEM VOLUME */
  5042. if ((x = cmkey(voltab,3,"","medium",xxstring)) < 0)
  5043. return(x);
  5044. if ((y = cmcfm()) < 0)
  5045. return(y);
  5046. mdmvol = x;
  5047. return(success = 1);
  5048. default:
  5049. printf("Unexpected SET MODEM parameter\n");
  5050. return(-9);
  5051. }
  5052. }
  5053. static int /* Set DIAL command options */
  5054. setdial(y) int y; {
  5055. int x = 0, z = 0;
  5056. char *s = NULL;
  5057. if (y < 0)
  5058. if ((y = cmkey(dialtab,ndial,"","",xxstring)) < 0)
  5059. return(y);
  5060. switch (y) {
  5061. case XYDHUP: /* DIAL HANGUP */
  5062. return(seton(&dialhng));
  5063. case XYDINI: /* DIAL INIT-STRING */
  5064. return(dialstr(&dialini,"Modem initialization string"));
  5065. case XYDNPR: /* DIAL PREFIX */
  5066. return(dialstr(&dialnpr,"Telephone number prefix"));
  5067. case XYDDIA: /* DIAL DIAL-COMMAND */
  5068. x = cmtxt("Dialing command for modem,\n\
  5069. include \"%s\" to stand for phone number,\n\
  5070. for example, \"set dial dial-command ATDT%s\\13\"",
  5071. "",
  5072. &s,
  5073. xxstring);
  5074. if (x < 0 && x != -3) /* Handle parse errors */
  5075. return(x);
  5076. s = brstrip(s); /* Strip braces or quotes */
  5077. y = x = strlen(s); /* Get length of text */
  5078. if (y > 0) { /* If there is any text (left), */
  5079. for (x = 0; x < y; x++) { /* make sure they included "%s" */
  5080. if (s[x] != '%') continue;
  5081. if (s[x+1] == 's') break;
  5082. }
  5083. if (x == y) {
  5084. printf(
  5085. "?Dial-command must contain \"%cs\" for phone number.\n",'%');
  5086. return(-9);
  5087. }
  5088. }
  5089. if (dialcmd) { /* Free any previous string. */
  5090. free(dialcmd);
  5091. dialcmd = (char *) 0;
  5092. }
  5093. if (y > 0) {
  5094. dialcmd = malloc(y + 1); /* Allocate space for it */
  5095. if (dialcmd)
  5096. strcpy(dialcmd,s); /* and make a safe copy. */
  5097. }
  5098. return(success = 1);
  5099. #ifndef NOXFER
  5100. case XYDKSP: /* DIAL KERMIT-SPOOF */
  5101. return(seton(&dialksp));
  5102. #endif /* NOXFER */
  5103. case XYDTMO: /* DIAL TIMEOUT */
  5104. y = cmnum("Seconds to wait for call completion","0",10,&x,xxstring);
  5105. if (y < 0) return(y);
  5106. y = cmnum("Kermit/modem timeout differential","10",10,&z,xxstring);
  5107. if (y < 0) return(y);
  5108. if ((y = cmcfm()) < 0)
  5109. return(y);
  5110. dialtmo = x;
  5111. mdmwaitd = z;
  5112. case XYDESC: /* DIAL ESCAPE-CHARACTER */
  5113. y = cmnum("ASCII value of character to escape back to modem",
  5114. "43",10,&x,xxstring);
  5115. y = setnum(&dialesc,x,y,128);
  5116. if (y > -1 && dialesc < 0) /* No escape character */
  5117. dialmhu = 0; /* So no hangup by modem command */
  5118. return(y);
  5119. case XYDDPY: /* DIAL DISPLAY */
  5120. return(seton(&dialdpy));
  5121. case XYDSPD: /* DIAL SPEED-MATCHING */
  5122. /* used to be speed-changing */
  5123. if ((y = seton(&mdmspd)) < 0) return(y);
  5124. #ifdef COMMENT
  5125. mdmspd = 1 - mdmspd; /* so here we reverse the meaning */
  5126. #endif /* COMMENT */
  5127. return(success = 1);
  5128. case XYDMNP: /* DIAL MNP-ENABLE */
  5129. case XYDEC: /* DIAL ERROR-CORRECTION */
  5130. x = seton(&dialec);
  5131. if (x > 0)
  5132. if (!dialec) dialdc = 0; /* OFF also turns off compression */
  5133. return(x);
  5134. case XYDDC: /* DIAL COMPRESSION */
  5135. x = seton(&dialdc);
  5136. if (x > 0)
  5137. if (dialdc) dialec = 1; /* ON also turns on error correction */
  5138. return(x);
  5139. #ifdef MDMHUP
  5140. case XYDMHU: /* DIAL MODEM-HANGUP */
  5141. return(seton(&dialmhu));
  5142. #endif /* MDMHUP */
  5143. #ifndef NOSPL
  5144. case XYDDIR: /* DIAL DIRECTORY (zero or more) */
  5145. return(parsdir(0)); /* 0 means DIAL */
  5146. #endif /* NOSPL */
  5147. case XYDSTR: /* DIAL STRING */
  5148. if ((y = cmkey(mdmcmd,nmdmcmd,"","",xxstring)) < 0) return(y);
  5149. switch (y) {
  5150. case XYDS_AN: /* Autoanswer ON/OFF */
  5151. case XYDS_DC: /* Data compression ON/OFF */
  5152. case XYDS_EC: /* Error correction ON/OFF */
  5153. if ((x = cmkey(onoff,2,"","on",xxstring)) < 0)
  5154. return(x);
  5155. sprintf(tmpbuf,"Modem's command to %sable %s", /* SAFE */
  5156. x ? "en" : "dis",
  5157. (y == XYDS_DC) ? "compression" :
  5158. ((y == XYDS_EC) ? "error-correction" :
  5159. "autoanswer")
  5160. );
  5161. if (x) {
  5162. if (y == XYDS_DC)
  5163. return(dialstr(&dialdcon,tmpbuf));
  5164. else if (y == XYDS_EC)
  5165. return(dialstr(&dialecon,tmpbuf));
  5166. else
  5167. return(dialstr(&dialaaon,tmpbuf));
  5168. } else {
  5169. if (y == XYDS_DC)
  5170. return(dialstr(&dialdcoff,tmpbuf));
  5171. else if (y == XYDS_EC)
  5172. return(dialstr(&dialecoff,tmpbuf));
  5173. else
  5174. return(dialstr(&dialaaoff,tmpbuf));
  5175. }
  5176. case XYDS_HU: /* hangup command */
  5177. return(dialstr(&dialhcmd,"Modem's hangup command"));
  5178. case XYDS_HW: /* hwfc */
  5179. return(dialstr(&dialhwfc,
  5180. "Modem's command to enable hardware flow control"));
  5181. case XYDS_IN: /* init */
  5182. return(dialstr(&dialini,"Modem's initialization string"));
  5183. case XYDS_NF: /* no flow control */
  5184. return(dialstr(&dialnofc,
  5185. "Modem's command to disable local flow control"));
  5186. case XYDS_PX: /* prefix */
  5187. return(dialstr(&dialnpr,"Telephone number prefix for dialing"));
  5188. case XYDS_SW: /* swfc */
  5189. return(dialstr(&dialswfc,
  5190. "Modem's command to enable local software flow control"));
  5191. case XYDS_DT: /* tone dialing */
  5192. return(dialstr(&dialtone,
  5193. "Command to configure modem for tone dialing"));
  5194. case XYDS_DP: /* pulse dialing */
  5195. return(dialstr(&dialpulse,
  5196. "Command to configure modem for pulse dialing"));
  5197. case XYDS_MS: /* dial mode string */
  5198. return(dialstr(&dialmstr,
  5199. "Command to enter dial mode"));
  5200. case XYDS_MP: /* dial mode prompt */
  5201. return(dialstr(&dialmprmt,
  5202. "Modem response upon entering dial mode"));
  5203. case XYDS_SP: /* SPEAKER OFF */
  5204. if ((x = cmkey(onoff,2,"","on",xxstring)) < 0) return(x);
  5205. if (x)
  5206. return(dialstr(&dialspon,"Command to turn modem speaker on"));
  5207. else
  5208. return(dialstr(&dialspoff,"Command to turn modem speaker off"));
  5209. case XYDS_VO: /* VOLUME LOW */
  5210. if ((x = cmkey(voltab,3,"","medium",xxstring)) < 0) return(x);
  5211. switch (x) {
  5212. case 0:
  5213. case 1:
  5214. return(dialstr(&dialvol1,
  5215. "Command for low modem speaker volume"));
  5216. case 2:
  5217. return(dialstr(&dialvol2,
  5218. "Command for medium modem speaker volume"));
  5219. case 3:
  5220. return(dialstr(&dialvol3,
  5221. "Command for high modem speaker volume"));
  5222. default:
  5223. return(-2);
  5224. }
  5225. case XYDS_ID: /* IGNORE-DIALTONE */
  5226. return(dialstr(&dialx3,
  5227. "Command to tell modem to ignore dialtone"));
  5228. case XYDS_I2: /* PREDIAL-INIT */
  5229. return(dialstr(&dialini2,
  5230. "Command to send to modem just prior to dialing"));
  5231. default:
  5232. printf("?Unexpected SET DIAL STRING parameter\n");
  5233. }
  5234. case XYDFC: /* DIAL FLOW-CONTROL */
  5235. if ((y = cmkey(dial_fc,4,"","auto",xxstring)) < 0) return(y);
  5236. if ((x = cmcfm()) < 0) return(x);
  5237. dialfc = y;
  5238. return(success = 1);
  5239. case XYDMTH: { /* DIAL METHOD */
  5240. extern int dialmauto;
  5241. if ((y = cmkey(dial_m,ndial_m,"","default",xxstring)) < 0)
  5242. return(y);
  5243. if ((x = cmcfm()) < 0)
  5244. return(x);
  5245. if (y == XYDM_A) { /* AUTO */
  5246. dialmauto = 1; /* local country code, if known. */
  5247. dialmth = XYDM_D;
  5248. } else {
  5249. dialmauto = 0; /* use the method specified */
  5250. dialmth = y;
  5251. }
  5252. return(success = 1);
  5253. }
  5254. case XYDRTM:
  5255. y = cmnum("Number of times to try dialing a number",
  5256. "1",10,&x,xxstring);
  5257. z = setnum(&dialrtr,x,y,-1);
  5258. if (z > -1 && dialrtr < 0) {
  5259. printf("?Sorry, negative dial retries not valid: %d\n",dialrtr);
  5260. return(-9);
  5261. }
  5262. return(z);
  5263. case XYDINT:
  5264. y = cmnum("Seconds to wait between redial attempts",
  5265. "30",10,&x,xxstring);
  5266. z = setnum(&dialint,x,y,-1);
  5267. if (z > -1 && dialint < 0) {
  5268. printf("?Sorry, negative dial interval not valid: %d\n",dialint);
  5269. return(-9);
  5270. }
  5271. return(z);
  5272. case XYDLAC: /* DIAL AREA-CODE */
  5273. if ((x = dialstr(&diallac,"Area code you are calling from")) < 0)
  5274. return(x);
  5275. if (diallac) {
  5276. if (!rdigits(diallac)) {
  5277. printf("?Sorry, area code must be numeric\n");
  5278. if (*diallac == '(')
  5279. printf("(please omit the parentheses)\n");
  5280. if (*diallac == '/')
  5281. printf("(no slashes, please)\n");
  5282. if (diallac) free(diallac);
  5283. diallac = NULL;
  5284. return(-9);
  5285. }
  5286. }
  5287. return(x);
  5288. case XYDCNF: /* CONFIRMATION */
  5289. return(success = seton(&dialcnf));
  5290. case XYDCVT: /* CONVERT-DIRECTORY */
  5291. if ((y = cmkey(dcnvtab,3,"","ask",xxstring)) < 0)
  5292. return(y);
  5293. if ((x = cmcfm()) < 0)
  5294. return(x);
  5295. dialcvt = y;
  5296. return(success = 1);
  5297. case XYDLCC: /* DIAL COUNTRY-CODE */
  5298. x = dialstr(&diallcc,"Country code you are calling from");
  5299. if (x < 1) return(x);
  5300. if (diallcc) {
  5301. if (!rdigits(diallcc)) {
  5302. printf("?Sorry, country code must be numeric\n");
  5303. if (*diallcc == '+')
  5304. printf("(please omit the plus sign)\n");
  5305. if (diallcc) free(diallcc);
  5306. diallcc = NULL;
  5307. return(-9);
  5308. }
  5309. if (!strcmp(diallcc,"1")) { /* Set defaults for USA and Canada */
  5310. if (!dialldp) /* Long-distance prefix */
  5311. makestr(&dialldp,"1");
  5312. if (!dialixp) /* International dialing prefix */
  5313. makestr(&dialixp,"011");
  5314. if (ntollfree == 0) { /* Toll-free area codes */
  5315. if ((dialtfc[0] = malloc(4))) {
  5316. strcpy(dialtfc[0],"800"); /* 1970-something */
  5317. ntollfree++;
  5318. if ((dialtfc[1] = malloc(4))) {
  5319. strcpy(dialtfc[1],"888"); /* 1996 */
  5320. ntollfree++;
  5321. if ((dialtfc[2] = malloc(4))) {
  5322. strcpy(dialtfc[2],"877"); /* 5 April 1998 */
  5323. ntollfree++;
  5324. if ((dialtfc[3] = malloc(4))) {
  5325. strcpy(dialtfc[3],"866"); /* 2000? */
  5326. ntollfree++;
  5327. }
  5328. }
  5329. }
  5330. }
  5331. }
  5332. if (!dialtfp) /* Toll-free dialing prefix */
  5333. makestr(&dialtfp,"1");
  5334. #ifdef COMMENT
  5335. /* The time for this is past */
  5336. } else if (!strcmp(diallcc,"358") &&
  5337. ((int) strcmp(zzndate(),"19961011") > 0)
  5338. ) { /* Finland */
  5339. if (!dialldp) /* Long-distance prefix */
  5340. makestr(&dialldp,"9");
  5341. if (!dialixp) /* International dialing prefix */
  5342. makestr(&dialixp,"990");
  5343. #endif /* COMMENT */
  5344. } else { /* Everywhere else ... */
  5345. if (!dialldp) {
  5346. if ((dialldp = malloc(4)))
  5347. strcpy(dialldp,"0");
  5348. }
  5349. if (!dialixp) {
  5350. if ((dialixp = malloc(4)))
  5351. strcpy(dialixp,"00");
  5352. }
  5353. }
  5354. if (!strcmp(diallcc,"33")) /* France */
  5355. dialfld = 1; /* Long-distance dialing is forced */
  5356. }
  5357. return(success = 1);
  5358. case XYDIXP: /* DIAL INTL-PREFIX */
  5359. return(dialstr(&dialixp,"International dialing prefix"));
  5360. case XYDIXS: /* DIAL INTL-SUFFIX */
  5361. return(dialstr(&dialixs,"International dialing suffix"));
  5362. case XYDLDP: /* DIAL LD-PREFIX */
  5363. return(dialstr(&dialldp,"Long-distance dialing prefix"));
  5364. case XYDLDS: /* DIAL LD-SUFFIX */
  5365. return(dialstr(&diallds,"Long-distance dialing suffix"));
  5366. case XYDLCP: /* DIAL LC-PREFIX */
  5367. return(dialstr(&diallcp,"Local dialing prefix"));
  5368. case XYDLCS: /* DIAL LC-SUFFIX */
  5369. return(dialstr(&diallcs,"Local dialing suffix"));
  5370. #ifdef COMMENT
  5371. case XYDPXX: /* DIAL PBX-EXCHANGE */
  5372. return(dialstr(&dialpxx,"Exchange of PBX you are calling from"));
  5373. #endif /* COMMENT */
  5374. case XYDPXI: { /* DIAL PBX-INTERNAL-PREFIX */
  5375. #ifdef COMMENT
  5376. return(dialstr(&dialpxi,
  5377. "Internal-call prefix of PBX you are calling from"));
  5378. #else
  5379. int x;
  5380. if ((x = cmtxt("Internal-call prefix of PBX you are calling from",
  5381. "",&s,NULL)) < 0) /* Don't evaluate */
  5382. return(x);
  5383. #ifndef NOSPL
  5384. if (*s) {
  5385. char c, * p = tmpbuf;
  5386. if (*s == '\\') {
  5387. c = *(s+1);
  5388. if (isupper(c)) c = tolower(c);
  5389. if (c != 'f' &&
  5390. ckstrcmp(s,"\\v(d$px)",8,0) &&
  5391. ckstrcmp(s,"\\v(d$pxx)",9,0) &&
  5392. ckstrcmp(s,"\\v(d$p)",7,0)) {
  5393. x = TMPBUFSIZ;
  5394. zzstring(s,&p,&x);
  5395. s = tmpbuf;
  5396. }
  5397. }
  5398. }
  5399. #endif /* NOSPL */
  5400. makestr(&dialpxi,s);
  5401. return(1);
  5402. }
  5403. #endif /* COMMENT */
  5404. case XYDPXO: /* DIAL PBX-OUTSIDE-PREFIX */
  5405. return(dialstr(&dialpxo,
  5406. "Outside-line prefix of PBX you are calling from"));
  5407. case XYDSFX: /* DIAL INTL-SUFFIX */
  5408. return(dialstr(&dialsfx," Telephone number suffix for dialing"));
  5409. case XYDSRT: /* DIAL SORT */
  5410. return(success = seton(&dialsrt));
  5411. case XYDPXX: /* DIAL PBX-EXCHANGE */
  5412. case XYDTFC: { /* DIAL TOLL-FREE-AREA-CODE */
  5413. int n, i; /* (zero or more of them...) */
  5414. char * p[MAXTOLLFREE]; /* Temporary pointers */
  5415. char * m;
  5416. for (n = 0; n < MAXTOLLFREE; n++) {
  5417. if (n == 0) {
  5418. m = (y == XYDTFC) ?
  5419. "Toll-free area code(s) in the country you are calling from"
  5420. : "Exchange(s) of PBX you are calling from";
  5421. } else {
  5422. m = (y == XYDTFC) ?
  5423. "Another toll-free area code"
  5424. : "Another PBX exchange";
  5425. }
  5426. if ((x = cmfld(m,"",&s,xxstring)) < 0)
  5427. break;
  5428. if (s) {
  5429. int k;
  5430. k = (int) strlen(s);
  5431. if (k > 0) {
  5432. if ((p[n] = malloc(k + 1)))
  5433. strcpy(p[n], s); /* safe */
  5434. } else break;
  5435. } else break;
  5436. }
  5437. if (x == -3) { /* Command was successful */
  5438. int m;
  5439. m = (y == XYDTFC) ? ntollfree : ndialpxx;
  5440. if ((x = cmcfm()) < 0)
  5441. return(x);
  5442. x = 1;
  5443. for (i = 0; i < m; i++) { /* Remove old list, if any */
  5444. if (y == XYDTFC)
  5445. makestr(&(dialtfc[i]),NULL);
  5446. else
  5447. makestr(&(dialpxx[i]),NULL);
  5448. }
  5449. if (y == XYDTFC)
  5450. ntollfree = n; /* New count */
  5451. else
  5452. ndialpxx = n;
  5453. for (i = 0; i < n; i++) { /* New list */
  5454. if (y == XYDTFC)
  5455. makestr(&(dialtfc[i]),p[i]);
  5456. else
  5457. makestr(&(dialpxx[i]),p[i]);
  5458. }
  5459. x = 1;
  5460. }
  5461. for (i = 0; i < n; i++)
  5462. if (p[i]) free(p[i]);
  5463. return(x);
  5464. }
  5465. case XYDTFP: /* TOLL-FREE-PREFIX */
  5466. return(dialstr(&dialtfp,
  5467. " Long-distance prefix for toll-free dialing"));
  5468. case XYDCON: /* CONNECT */
  5469. z = -1;
  5470. if ((y = cmkey(crrtab,ncrr,"","auto",xxstring)) < 0) return(y);
  5471. if (y != CAR_OFF) /* AUTO or ON? */
  5472. if ((z = cmkey(qvtab,nqvt,"","verbose",xxstring)) < 0) return(z);
  5473. if ((x = cmcfm()) < 0) return(x);
  5474. if (z > -1)
  5475. dialcq = z;
  5476. dialcon = y;
  5477. return(success = 1);
  5478. case XYDRSTR: /* RESTRICT */
  5479. if ((y = cmkey(drstrtab,4,"","none",xxstring)) < 0) return(y);
  5480. if ((x = cmcfm()) < 0) return(x);
  5481. dialrstr = y;
  5482. return(success = 1);
  5483. case XYDLLAC: { /* Local area-code list */
  5484. int n, i; /* (zero or more of them...) */
  5485. char * p[MAXLOCALAC]; /* Temporary pointers */
  5486. for (n = 0; n < MAXLOCALAC; n++) {
  5487. if ((x = cmfld(
  5488. "Area code to which calls from your area are local",
  5489. "",&s,xxstring)) < 0)
  5490. break;
  5491. if (s) {
  5492. int k;
  5493. k = (int) strlen(s);
  5494. if (k > 0) {
  5495. if ((p[n] = malloc(k + 1)))
  5496. strcpy(p[n], s); /* safe */
  5497. } else break;
  5498. } else break;
  5499. }
  5500. if (x == -3) { /* Command was successful */
  5501. if ((x = cmcfm()) < 0)
  5502. return(x);
  5503. for (i = 0; i < nlocalac; i++) /* Remove old list, if any */
  5504. if (diallcac[i]) {
  5505. free(diallcac[i]);
  5506. diallcac[i] = NULL;
  5507. }
  5508. nlocalac = n; /* New count */
  5509. for (i = 0; i < nlocalac; i++) /* New list */
  5510. diallcac[i] = p[i];
  5511. return(success = 1);
  5512. } else { /* Parse error, undo everything */
  5513. for (i = 0; i < n; i++)
  5514. if (p[i]) free(p[i]);
  5515. return(x);
  5516. }
  5517. }
  5518. case XYDFLD:
  5519. return(success = seton(&dialfld));
  5520. case XYDIDT: /* DIAL IGNORE-DIALTONE */
  5521. return(seton(&dialidt));
  5522. case XYDPAC:
  5523. y = cmnum(
  5524. "Milliseconds to pause between each character sent to dialer",
  5525. "",10,&x,xxstring);
  5526. return(setnum(&dialpace,x,y,9999));
  5527. #ifndef NOSPL
  5528. case XYDMAC:
  5529. if ((x = cmfld("Name of macro to execute just prior to dialing",
  5530. "",&s,xxstring)) < 0) {
  5531. if (x == -3)
  5532. s = NULL;
  5533. else
  5534. return(x);
  5535. }
  5536. if (s) {
  5537. if (!*s) {
  5538. s = NULL;
  5539. } else {
  5540. ckstrncpy(line,s,LINBUFSIZ);
  5541. s = line;
  5542. }
  5543. }
  5544. if ((x = cmcfm()) < 0)
  5545. return(x);
  5546. makestr(&dialmac,s);
  5547. return(success = 1);
  5548. #endif /* NOSPL */
  5549. case XYDPUCC: /* Pulse country codes */
  5550. case XYDTOCC: { /* Tone country codes */
  5551. int n, i;
  5552. char * p[MAXTPCC];
  5553. char * m;
  5554. for (n = 0; n < MAXTPCC; n++) {
  5555. if (n == 0) {
  5556. m = (y == XYDPUCC) ?
  5557. "Country code where Pulse dialing is required"
  5558. : "Country code where Tone dialing is available";
  5559. } else
  5560. m = "Another country code";
  5561. if ((x = cmfld(m,"",&s,xxstring)) < 0)
  5562. break;
  5563. if (s) {
  5564. int k;
  5565. k = (int) strlen(s);
  5566. if (k > 0) {
  5567. if ((p[n] = malloc(k + 1)))
  5568. strcpy(p[n], s); /* safe */
  5569. } else break;
  5570. } else break;
  5571. }
  5572. if (x == -3) { /* Command was successful */
  5573. int m;
  5574. m = (y == XYDPUCC) ? ndialpucc : ndialtocc;
  5575. if ((x = cmcfm()) < 0)
  5576. return(x);
  5577. x = 1;
  5578. for (i = 0; i < m; i++) { /* Remove old list, if any */
  5579. if (y == XYDPUCC)
  5580. makestr(&(dialpucc[i]),NULL);
  5581. else
  5582. makestr(&(dialtocc[i]),NULL);
  5583. }
  5584. if (y == XYDPUCC) {
  5585. ndialpucc = n; /* New count */
  5586. } else {
  5587. ndialtocc = n;
  5588. }
  5589. for (i = 0; i < n; i++) { /* New list */
  5590. if (y == XYDPUCC) {
  5591. makestr(&(dialpucc[i]),p[i]);
  5592. } else {
  5593. makestr(&(dialtocc[i]),p[i]);
  5594. }
  5595. }
  5596. x = 1;
  5597. }
  5598. for (i = 0; i < n; i++)
  5599. if (p[i]) free(p[i]);
  5600. return(x);
  5601. }
  5602. case XYDTEST:
  5603. return(seton(&dialtest));
  5604. default:
  5605. printf("?Unexpected SET DIAL parameter\n");
  5606. return(-9);
  5607. }
  5608. }
  5609. #ifndef NOSHOW
  5610. int /* SHOW MODEM */
  5611. shomodem() {
  5612. MDMINF * p;
  5613. int x, n, mdm;
  5614. char c;
  5615. long zz;
  5616. #ifdef IKSD
  5617. if (inserver) {
  5618. printf("Sorry, command disabled\r\n");
  5619. return(success = 0);
  5620. }
  5621. #endif /* IKSD */
  5622. shmdmlin();
  5623. printf("\n");
  5624. mdm = (mdmtyp > 0) ? mdmtyp : mdmsav;
  5625. p = (mdm > 0) ? modemp[mdm] : NULL;
  5626. if (p) {
  5627. printf(" %s\n\n", dialname ? dialname : p->name);
  5628. printf(" Modem capabilities: ");
  5629. zz = dialcapas ? dialcapas : p->capas;
  5630. if (!zz) {
  5631. printf(" (none)");
  5632. } else {
  5633. if (zz & CKD_AT) printf(" AT");
  5634. if (zz & CKD_V25) printf(" ITU");
  5635. if (zz & CKD_SB) printf(" SB");
  5636. if (zz & CKD_EC) printf(" EC");
  5637. if (zz & CKD_DC) printf(" DC");
  5638. if (zz & CKD_HW) printf(" HWFC");
  5639. if (zz & CKD_SW) printf(" SWFC");
  5640. if (zz & CKD_KS) printf(" KS");
  5641. if (zz & CKD_TB) printf(" TB");
  5642. }
  5643. printf("\n Modem carrier-watch: ");
  5644. if (carrier == CAR_OFF) printf("off\n");
  5645. else if (carrier == CAR_ON) printf("on\n");
  5646. else if (carrier == CAR_AUT) printf("auto\n");
  5647. else printf("unknown\n");
  5648. printf(" Modem maximum-speed: ");
  5649. zz = (dialmax > 0L) ? dialmax : p->max_speed;
  5650. if (zz > 0)
  5651. printf("%ld bps\n", zz);
  5652. else
  5653. printf("(unknown)\n");
  5654. printf(" Modem error-correction: %s\n", dialec ? "on" : "off");
  5655. printf(" Modem compression: %s\n", dialdc ? "on" : "off");
  5656. printf(" Modem speed-matching: %s", mdmspd ? "on" : "off");
  5657. printf(" (interface speed %s)\n", mdmspd ? "changes" : "is locked");
  5658. printf(" Modem flow-control: ");
  5659. if (dialfc == FLO_NONE) printf("none\n");
  5660. else if (dialfc == FLO_XONX) printf("xon/xoff\n");
  5661. else if (dialfc == FLO_RTSC) printf("rts/cts\n");
  5662. else if (dialfc == FLO_AUTO) printf("auto\n");
  5663. printf(" Modem hangup-method: %s\n",
  5664. dialmhu ?
  5665. "modem-command" :
  5666. "rs232-signal"
  5667. );
  5668. printf(" Modem speaker: %s\n", showoff(mdmspk));
  5669. printf(" Modem volume: %s\n",
  5670. (mdmvol == 2) ? "medium" : ((mdmvol <= 1) ? "low" : "high"));
  5671. printf(" Modem kermit-spoof: %s\n", dialksp ? "on" : "off");
  5672. c = (char) (x = (dialesc ? dialesc : p->esc_char));
  5673. printf(" Modem escape-character: %d", x);
  5674. if (isprint(c))
  5675. printf(" (= \"%c\")",c);
  5676. printf(
  5677. "\n\nMODEM COMMANDs (* = set automatically by SET MODEM TYPE):\n\n");
  5678. debug(F110,"show dialini",dialini,0);
  5679. printf(" %c Init-string: ", dialini ? ' ' : '*' );
  5680. shods(dialini ? dialini : p->wake_str);
  5681. printf(" %c Dial-mode-string: ", dialmstr ? ' ' : '*' );
  5682. shods(dialmstr ? dialmstr : p->dmode_str);
  5683. n = local ? 19 : 20;
  5684. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5685. printf(" %c Dial-mode-prompt: ", dialmprmt ? ' ' : '*' );
  5686. shods(dialmprmt ? dialmprmt : p->dmode_prompt);
  5687. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5688. printf(" %c Dial-command: ", dialcmd ? ' ' : '*' );
  5689. shods(dialcmd ? dialcmd : p->dial_str);
  5690. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5691. printf(" %c Compression on: ", dialdcon ? ' ' : '*' );
  5692. if (!dialdcon)
  5693. debug(F110,"dialdcon","(null)",0);
  5694. else
  5695. debug(F110,"dialdcon",dialdcon,0);
  5696. shods(dialdcon ? dialdcon : p->dc_on_str);
  5697. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5698. printf(" %c Compression off: ", dialdcoff ? ' ' : '*' );
  5699. shods(dialdcoff ? dialdcoff : p->dc_off_str);
  5700. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5701. printf(" %c Error-correction on: ", dialecon ? ' ' : '*' );
  5702. shods(dialecon ? dialecon : p->ec_on_str);
  5703. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5704. printf(" %c Error-correction off: ", dialecoff ? ' ' : '*' );
  5705. shods(dialecoff ? dialecoff : p->ec_off_str);
  5706. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5707. printf(" %c Autoanswer on: ", dialaaon ? ' ' : '*' );
  5708. shods(dialaaon ? dialaaon : p->aa_on_str);
  5709. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5710. printf(" %c Autoanswer off: ", dialaaoff ? ' ' : '*' );
  5711. shods(dialaaoff ? dialaaoff : p->aa_off_str);
  5712. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5713. printf(" %c Speaker on: ", dialspon ? ' ' : '*' );
  5714. shods(dialspon ? dialspon : p->sp_on_str);
  5715. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5716. printf(" %c Speaker off: ", dialspoff ? ' ' : '*' );
  5717. shods(dialspoff ? dialspoff : p->sp_off_str);
  5718. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5719. printf(" %c Volume low: ", dialvol1 ? ' ' : '*' );
  5720. shods(dialvol1 ? dialvol1 : p->vol1_str);
  5721. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5722. printf(" %c Volume medium: ", dialvol2 ? ' ' : '*' );
  5723. shods(dialvol2 ? dialvol2 : p->vol2_str);
  5724. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5725. printf(" %c Volume high: ", dialvol3 ? ' ' : '*' );
  5726. shods(dialvol3 ? dialvol3 : p->vol3_str);
  5727. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5728. printf(" %c Hangup-command: ", dialhcmd ? ' ' : '*' );
  5729. shods(dialhcmd ? dialhcmd : p->hup_str);
  5730. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5731. printf(" %c Hardware-flow: ", dialhwfc ? ' ' : '*' );
  5732. shods(dialhwfc ? dialhwfc : p->hwfc_str);
  5733. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5734. printf(" %c Software-flow: ", dialswfc ? ' ' : '*' );
  5735. shods(dialswfc ? dialswfc : p->swfc_str);
  5736. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5737. printf(" %c No-flow-control: ", dialnofc ? ' ' : '*' );
  5738. shods(dialnofc ? dialnofc : p->nofc_str);
  5739. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5740. printf(" %c Pulse: ", dialpulse ? ' ' : '*');
  5741. shods(dialpulse ? dialpulse : p->pulse);
  5742. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5743. printf(" %c Tone: ", dialtone ? ' ' : '*');
  5744. shods(dialtone ? dialtone : p->tone);
  5745. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5746. printf(" %c Ignore-dialtone: ", dialx3 ? ' ' : '*');
  5747. shods(dialx3 ? dialx3 : p->ignoredt);
  5748. if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;
  5749. printf(" %c Predial-init: ", dialini2 ? ' ' : '*');
  5750. shods(dialini2 ? dialini2 : p->ini2);
  5751. if (++n > cmd_rows - 4) if (!askmore()) return(0); else n = 0;
  5752. printf("\n For more info: SHOW DIAL and SHOW COMMUNICATIONS\n");
  5753. } else if (mdm > 0) {
  5754. printf("Modem info for \"%s\" not filled in yet\n", gmdmtyp());
  5755. } else printf(
  5756. " No modem selected, so DIAL and most SET MODEM commands have no effect.\n\
  5757. Use SET MODEM TYPE to select a modem.\n");
  5758. return(success = 1);
  5759. }
  5760. #endif /* NOSHOW */
  5761. #endif /* NODIAL */
  5762. #ifdef CK_TAPI
  5763. int /* TAPI action commands */
  5764. dotapi() {
  5765. int x,y;
  5766. char *s;
  5767. if (!TAPIAvail) {
  5768. printf("\nTAPI is unavailable on this system.\n");
  5769. return(-9);
  5770. }
  5771. if ((y = cmkey(tapitab,ntapitab,"MS TAPI command","",xxstring)) < 0)
  5772. return(y);
  5773. switch (y) {
  5774. case XYTAPI_CFG: { /* TAPI CONFIGURE-LINE */
  5775. extern struct keytab * tapilinetab;
  5776. extern struct keytab * _tapilinetab;
  5777. extern int ntapiline;
  5778. extern int LineDeviceId;
  5779. int lineID=LineDeviceId;
  5780. if (TAPIAvail)
  5781. cktapiBuildLineTable(&tapilinetab, &_tapilinetab, &ntapiline);
  5782. if (tapilinetab && _tapilinetab && ntapiline > 0) {
  5783. int i=0, j = 9999, k = -1;
  5784. if ( LineDeviceId == -1 ) {
  5785. /* Find out what the lowest numbered TAPI device is */
  5786. /* and use it as the default. */
  5787. for (i = 0; i < ntapiline; i++ ) {
  5788. if (tapilinetab[i].kwval < j) {
  5789. k = i;
  5790. }
  5791. }
  5792. } else {
  5793. /* Find the LineDeviceId in the table and use that entry */
  5794. for (i = 0; i < ntapiline; i++ ) {
  5795. if (tapilinetab[i].kwval == LineDeviceId) {
  5796. k = i;
  5797. break;
  5798. }
  5799. }
  5800. }
  5801. if (k >= 0)
  5802. s = _tapilinetab[k].kwd;
  5803. else
  5804. s = "";
  5805. if ((y = cmkey(_tapilinetab,ntapiline,
  5806. "TAPI device name",s,xxstring)) < 0)
  5807. return(y);
  5808. lineID = y;
  5809. }
  5810. if ((x = cmcfm()) < 0) return(x);
  5811. #ifdef IKSD
  5812. if (inserver) {
  5813. printf("Sorry, command disabled\r\n");
  5814. return(success = 0);
  5815. }
  5816. #endif /* ISKD */
  5817. cktapiConfigureLine(lineID);
  5818. break;
  5819. }
  5820. case XYTAPI_DIAL: /* TAPI DIALING-PROPERTIES */
  5821. if ((x = cmcfm()) < 0)
  5822. return(x);
  5823. #ifdef IKSD
  5824. if (inserver) {
  5825. printf("Sorry, command disabled\r\n");
  5826. return(success = 0);
  5827. }
  5828. #endif /* ISKD */
  5829. cktapiDialingProp();
  5830. break;
  5831. }
  5832. return(success = 1);
  5833. }
  5834. static int /* SET TAPI command options */
  5835. settapi() {
  5836. int x, y;
  5837. char *s;
  5838. if (!TAPIAvail) {
  5839. printf("\nTAPI is unavailable on this system.\n");
  5840. return(-9);
  5841. }
  5842. if ((y = cmkey(settapitab,nsettapitab,"MS TAPI option","",xxstring)) < 0)
  5843. return(y);
  5844. switch (y) {
  5845. case XYTAPI_USE:
  5846. return (success = seton(&tapiusecfg));
  5847. case XYTAPI_LGHT:
  5848. return (success = seton(&tapilights));
  5849. case XYTAPI_PRE:
  5850. return (success = seton(&tapipreterm));
  5851. case XYTAPI_PST:
  5852. return (success = seton(&tapipostterm));
  5853. case XYTAPI_INA:
  5854. y = cmnum("seconds of inactivity before auto-disconnect",
  5855. "0",10,&x,xxstring);
  5856. return(setnum(&tapiinactivity,x,y,65535));
  5857. case XYTAPI_BNG:
  5858. y = cmnum("seconds to wait for credit card tone",
  5859. "8",10,&x,xxstring);
  5860. return(setnum(&tapibong,x,y,90));
  5861. case XYTAPI_MAN:
  5862. return (success = seton(&tapimanual));
  5863. case XYTAPI_CON: /* TAPI CONVERSIONS */
  5864. return (success = setonaut(&tapiconv));
  5865. case XYTAPI_LIN: /* TAPI LINE */
  5866. x = setlin(XYTAPI_LIN,1,0);
  5867. if (x > -1) didsetlin++;
  5868. return(x);
  5869. case XYTAPI_PASS: { /* TAPI PASSTHROUGH */
  5870. #ifdef NODIAL
  5871. printf("\n?Modem-dialing not supported\n");
  5872. return(-9);
  5873. #else /* NODIAL */
  5874. /* Passthrough became Modem-dialing which is an antonym */
  5875. success = seton(&tapipass);
  5876. tapipass = !tapipass;
  5877. return (success);
  5878. #endif /* NODIAL */
  5879. }
  5880. case XYTAPI_LOC: { /* TAPI LOCATION */
  5881. extern char tapiloc[];
  5882. extern int tapilocid;
  5883. int i = 0, j = 9999, k = -1;
  5884. cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
  5885. if (!tapiloctab || !ntapiloc) {
  5886. printf("\nNo TAPI Locations are configured for this system\n");
  5887. return(-9);
  5888. }
  5889. if (tapilocid == -1)
  5890. tapilocid = cktapiGetCurrentLocationID();
  5891. /* Find the current tapiloc entry */
  5892. /* and use it as the default. */
  5893. for (k = 0; k < ntapiloc; k++) {
  5894. if (tapiloctab[k].kwval == tapilocid)
  5895. break;
  5896. }
  5897. if (k >= 0 && k < ntapiloc)
  5898. s = tapiloctab[k].kwd;
  5899. else
  5900. s = "";
  5901. if ((y = cmkey(tapiloctab,ntapiloc, "TAPI location",s,xxstring)) < 0)
  5902. return(y);
  5903. if ((x = cmcfm()) < 0)
  5904. return(x);
  5905. #ifdef IKSD
  5906. if (inserver) {
  5907. printf("Sorry, command disabled\r\n");
  5908. return(success = 0);
  5909. }
  5910. #endif /* IKSD */
  5911. cktapiFetchLocationInfoByID( y );
  5912. #ifndef NODIAL
  5913. CopyTapiLocationInfoToKermitDialCmd();
  5914. #endif /* NODIAL */
  5915. }
  5916. break;
  5917. }
  5918. return(success=1);
  5919. }
  5920. #endif /* CK_TAPI */
  5921. #endif /* NOLOCAL */
  5922. #ifndef NOSPL
  5923. /* Method for evaluating \%x and \&x[] variables */
  5924. static struct keytab varevaltab[] = {
  5925. { "recursive", 1, 0 },
  5926. { "simple", 0, 0 }
  5927. };
  5928. static int nvarevaltab = (sizeof(varevaltab) / sizeof(struct keytab));
  5929. int
  5930. setvareval() {
  5931. int x = 0, y = 0;
  5932. extern int vareval;
  5933. #ifdef DCMDBUF
  5934. extern int * xvarev;
  5935. #else
  5936. extern int xvarev[];
  5937. #endif /* DCMDBUF */
  5938. if ((x = cmkey(varevaltab,
  5939. nvarevaltab,
  5940. "Method for evaluating \\%x and \\&x[] variables",
  5941. "",
  5942. xxstring)) < 0)
  5943. return(x);
  5944. if ((y = cmcfm()) < 0)
  5945. return(y);
  5946. xvarev[cmdlvl] = x;
  5947. vareval = x;
  5948. return(success = 1);
  5949. }
  5950. #ifdef CK_ANSIC /* SET ALARM */
  5951. int
  5952. setalarm(long xx)
  5953. #else
  5954. int
  5955. setalarm(xx) long xx;
  5956. #endif /* CK_ANSIC */
  5957. /* setalarm */ {
  5958. #ifdef COMMENT
  5959. int yyyy, mm, dd, x;
  5960. char *s;
  5961. long zz;
  5962. char buf[6];
  5963. #endif /* COMMENT */
  5964. long sec, jd;
  5965. char xbuf[20], * p;
  5966. debug(F101,"setalarm xx","",xx);
  5967. ck_alarm = 0L; /* 0 = no alarm (in case of error) */
  5968. if (xx < 0L) {
  5969. printf("%ld - illegal value, must be 0 or positive\n", xx);
  5970. return(-9);
  5971. }
  5972. if (xx == 0L) { /* CLEAR ALARM */
  5973. alrm_date[0] = NUL;
  5974. alrm_time[0] = NUL;
  5975. return(1);
  5976. }
  5977. #ifdef COMMENT
  5978. x = 8; /* Get current date */
  5979. s = alrm_date;
  5980. if (zzstring("\\v(ndate)",&s,&x) < 0) {
  5981. printf("Internal date error, sorry.\n");
  5982. alrm_date[0] = SP;
  5983. return(-9);
  5984. }
  5985. x = 5; /* Get current time */
  5986. s = alrm_time;
  5987. if (zzstring("\\v(ntime)",&s,&x) < 0) {
  5988. printf("Internal time error, sorry.\n");
  5989. alrm_time[0] = SP;
  5990. return(-9);
  5991. }
  5992. sprintf(buf,"%05ld",atol(alrm_time)); /* SAFE (20) */
  5993. ckstrncpy(alrm_time,buf,8);
  5994. debug(F110,"SET ALARM date (1)",alrm_date,0);
  5995. debug(F110,"SET ALARM time (1)",alrm_time,0);
  5996. if ((zz = atol(alrm_time) + xx) < 0L) {
  5997. printf("Internal time conversion error, sorry.\n");
  5998. return(-9);
  5999. }
  6000. if (zz >= 86400L) { /* Alarm crosses midnight */
  6001. char d[10]; /* Local date buffer */
  6002. int lastday; /* Last day of this month */
  6003. ckstrncpy(d,alrm_date,8); /* We'll have to change the date */
  6004. x = (zz / 86400L); /* How many days after today */
  6005. dd = atoi((char *)(d+6)); /* Parse yyyymmdd */
  6006. d[6] = NUL; /* into yyyy, mm, dd ... */
  6007. mm = atoi((char *)(d+4));
  6008. d[4] = NUL;
  6009. yyyy = atoi((char *)d);
  6010. /* How many days in this month */
  6011. lastday = mdays[mm];
  6012. if (mm == 2 && yyyy % 4 == 0) /* Works thru 2099 AD... */
  6013. lastday++;
  6014. if (dd + x > lastday) { /* Dumb loop */
  6015. int y;
  6016. x -= (mdays[mm] - dd); /* Deduct rest of this month's days */
  6017. /* There's a more elegant way to do this... */
  6018. while (1) {
  6019. mm++; /* Next month */
  6020. if (mm > 12) { /* Wrap around */
  6021. mm = 1; /* Jan, next year */
  6022. yyyy++;
  6023. }
  6024. y = mdays[mm]; /* Days in new month */
  6025. if (mm == 2 && yyyy % 4 == 0) /* Feb in leap year */
  6026. y++; /* Works until 2100 AD */
  6027. if (x - y < 1)
  6028. break;
  6029. x -= y;
  6030. }
  6031. dd = x; /* Day of alarm month */
  6032. } else dd += x;
  6033. sprintf(alrm_date,"%04d%02d%02d",yyyy,mm,dd); /* SAFE (24) */
  6034. zz = zz % 86400L;
  6035. }
  6036. sprintf(alrm_time,"%ld",zz); /* SAFE (24) */
  6037. debug(F110,"SET ALARM date (2)",alrm_date,0);
  6038. debug(F110,"SET ALARM time (2)",alrm_time,0);
  6039. ck_alarm = xx;
  6040. #else
  6041. /* Jul 1998 */
  6042. ckstrncpy(xbuf,ckcvtdate("",1),20); /* Get current date and time */
  6043. p = xbuf;
  6044. ckstrncpy(alrm_date,xbuf,10);
  6045. alrm_date[8] = NUL;
  6046. sec = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);
  6047. debug(F110,"SET ALARM date (1)",alrm_date,0);
  6048. debug(F101,"SET ALARM time (1)","",sec);
  6049. if ((sec += xx) < 0L) {
  6050. printf("Internal time conversion error, sorry.\n");
  6051. return(-9);
  6052. }
  6053. if (sec >= 86400L) { /* Alarm crosses midnight */
  6054. long days;
  6055. days = sec / 86400L;
  6056. jd = mjd(p) + days; /* Get modified Julian date */
  6057. ckstrncpy(alrm_date,mjd2date(jd),10);
  6058. sec %= 86400L;
  6059. }
  6060. sprintf(alrm_time,"%05ld",sec); /* SAFE (24) */
  6061. debug(F110,"SET ALARM date (2)",alrm_date,0);
  6062. debug(F110,"SET ALARM time (2)",alrm_time,0);
  6063. ck_alarm = 1; /* Alarm is set */
  6064. #endif /* COMMENT */
  6065. return(success = 1);
  6066. }
  6067. #endif /* NOSPL */
  6068. #ifndef NOSETKEY
  6069. int
  6070. dosetkey() { /* SET KEY */
  6071. int x, y;
  6072. int flag = 0;
  6073. int kc; /* Key code */
  6074. char *s; /* Key binding */
  6075. #ifndef NOKVERBS
  6076. char *p; /* Worker */
  6077. #endif /* NOKVERBS */
  6078. #ifdef OS2
  6079. extern int os2gks;
  6080. extern int mskkeys;
  6081. extern int initvik;
  6082. #endif /* OS2 */
  6083. x_ifnum = 1;
  6084. y = cmnum("numeric key code, or the word CLEAR,","",10,&kc,xxstring);
  6085. x_ifnum = 0;
  6086. if (y < 0) {
  6087. debug(F111,"SET KEY",atmbuf,y);
  6088. if (y == -2) { /* Not a valid number */
  6089. if ((y = strlen(atmbuf)) < 0) /* Check for SET KEY CLEAR */
  6090. return(-2);
  6091. if (ckstrcmp(atmbuf,"clear",y,0))
  6092. return(-2);
  6093. if ((x = cmcfm()) < 0)
  6094. return(x);
  6095. for (y = 0; y < KMSIZE; y++) {
  6096. keymap[y] = (KEY) y;
  6097. macrotab[y] = NULL;
  6098. }
  6099. #ifdef OS2
  6100. keymapinit(); /* Special OS/2 initializations */
  6101. initvik = 1; /* Update the VIK table */
  6102. #endif /* OS2 */
  6103. return(1);
  6104. } else if (y == -3) { /* SET KEY <Return> */
  6105. printf(" Press key to be defined: "); /* Prompt for a keystroke */
  6106. #ifdef UNIX
  6107. #ifdef NOSETBUF
  6108. fflush(stdout);
  6109. #endif /* NOSETBUF */
  6110. #endif /* UNIX */
  6111. conbin((char)escape); /* Put terminal in binary mode */
  6112. #ifdef OS2
  6113. os2gks = 0; /* Turn off Kverb preprocessing */
  6114. #endif /* OS2 */
  6115. kc = congks(0); /* Get character or scan code */
  6116. #ifdef OS2
  6117. os2gks = 1; /* Turn on Kverb preprocessing */
  6118. #endif /* OS2 */
  6119. concb((char)escape); /* Restore terminal to cbreak mode */
  6120. if (kc < 0) { /* Check for error */
  6121. printf("?Error reading key\n");
  6122. return(0);
  6123. }
  6124. #ifdef OS2
  6125. shokeycode(kc,-1); /* Show current definition */
  6126. #else
  6127. shokeycode(kc); /* Show current definition */
  6128. #endif /* OS2 */
  6129. flag = 1; /* Remember it's a multiline command */
  6130. } else /* Error */
  6131. return(y);
  6132. }
  6133. /* Normal SET KEY <scancode> <value> command... */
  6134. #ifdef OS2
  6135. if (mskkeys)
  6136. kc = msktock(kc);
  6137. #endif /* OS2 */
  6138. if (kc < 0 || kc >= KMSIZE) {
  6139. printf("?key code must be between 0 and %d\n", KMSIZE - 1);
  6140. return(-9);
  6141. }
  6142. if (kc == escape) {
  6143. printf("Sorry, %d is the CONNECT-mode escape character\n",kc);
  6144. return(-9);
  6145. }
  6146. #ifdef OS2
  6147. wideresult = -1;
  6148. #endif /* OS2 */
  6149. if (flag) {
  6150. cmsavp(psave,PROMPTL);
  6151. cmsetp(" Enter new definition: ");
  6152. cmini(ckxech);
  6153. cmflgs = 0;
  6154. prompt(NULL);
  6155. }
  6156. def_again:
  6157. if (flag)
  6158. cmres();
  6159. if ((y = cmtxt("key definition,\n\
  6160. or Ctrl-C to cancel this command,\n\
  6161. or Enter to restore default definition",
  6162. "",&s,NULL)) < 0) {
  6163. if (flag) /* Handle parse errors */
  6164. goto def_again;
  6165. else
  6166. return(y);
  6167. }
  6168. s = brstrip(s);
  6169. #ifndef NOKVERBS
  6170. p = s; /* Save this place */
  6171. #endif /* NOKVERBS */
  6172. /*
  6173. If the definition included any \Kverbs, quote the backslash so the \Kverb
  6174. will still be in the definition when the key is pressed. We don't do this
  6175. in zzstring(), because \Kverbs are valid only in this context and nowhere
  6176. else.
  6177. We use this code active for all versions that support SET KEY, even if they
  6178. don't support \Kverbs, because otherwise \K would behave differently for
  6179. different versions.
  6180. */
  6181. for (x = 0, y = 0; s[x]; x++, y++) { /* Convert \K to \\K */
  6182. if ((x > 0) &&
  6183. (s[x] == 'K' || s[x] == 'k')
  6184. ) { /* Have K */
  6185. if ((x == 1 && s[x-1] == CMDQ) ||
  6186. (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ)) {
  6187. line[y++] = CMDQ; /* Make it \\K */
  6188. }
  6189. if (x > 1 && s[x-1] == '{' && s[x-2] == CMDQ) {
  6190. line[y-1] = CMDQ; /* Have \{K */
  6191. line[y++] = '{'; /* Make it \\{K */
  6192. }
  6193. }
  6194. line[y] = s[x];
  6195. }
  6196. line[y++] = NUL; /* Terminate */
  6197. s = line + y + 1; /* Point to after it */
  6198. x = LINBUFSIZ - (int) strlen(line) - 1; /* Calculate remaining space */
  6199. if ((x < (LINBUFSIZ / 2)) ||
  6200. (zzstring(line, &s, &x) < 0)) { /* Expand variables, etc. */
  6201. printf("?Key definition too long\n");
  6202. if (flag) cmsetp(psave);
  6203. return(-9);
  6204. }
  6205. s = line + y + 1; /* Point to result. */
  6206. #ifndef NOKVERBS
  6207. /*
  6208. Special case: see if the definition starts with a \Kverb.
  6209. If it does, point to it with p, otherwise set p to NULL.
  6210. */
  6211. p = s;
  6212. if (*p++ == CMDQ) {
  6213. if (*p == '{') p++;
  6214. p = (*p == 'k' || *p == 'K') ? p + 1 : NULL;
  6215. }
  6216. #endif /* NOKVERBS */
  6217. if (macrotab[kc]) { /* Possibly free old macro from key. */
  6218. free((char *)macrotab[kc]);
  6219. macrotab[kc] = NULL;
  6220. }
  6221. switch (strlen(s)) { /* Action depends on length */
  6222. case 0: /* Reset to default binding */
  6223. keymap[kc] = (KEY) kc;
  6224. break;
  6225. case 1: /* Single character */
  6226. keymap[kc] = (CHAR) *s;
  6227. break;
  6228. default: /* Character string */
  6229. #ifndef NOKVERBS
  6230. if (p) {
  6231. y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  6232. debug(F101,"set key kverb lookup",0,y); /* exact match required */
  6233. if (y > -1) {
  6234. keymap[kc] = F_KVERB | y;
  6235. break;
  6236. }
  6237. }
  6238. #endif /* NOKVERBS */
  6239. keymap[kc] = (KEY) kc;
  6240. macrotab[kc] = (MACRO) malloc(strlen(s)+1);
  6241. if (macrotab[kc])
  6242. strcpy((char *) macrotab[kc], s); /* safe */
  6243. break;
  6244. }
  6245. if (flag) cmsetp(psave);
  6246. #ifdef OS2
  6247. initvik = 1; /* Update VIK table */
  6248. #endif /* OS2 */
  6249. return(1);
  6250. }
  6251. #endif /* NOSETKEY */
  6252. #ifdef STOPBITS
  6253. struct keytab stoptbl[] = {
  6254. { "1", 1, 0 },
  6255. { "2", 2, 0 }
  6256. };
  6257. #endif /* STOPBITS */
  6258. static struct keytab sertbl[] = {
  6259. { "7E1", 0, 0 },
  6260. { "7E2", 1, 0 },
  6261. { "7M1", 2, 0 },
  6262. { "7M2", 3, 0 },
  6263. { "7O1", 4, 0 },
  6264. { "7O2", 5, 0 },
  6265. { "7S1", 6, 0 },
  6266. { "7S2", 7, 0 },
  6267. #ifdef HWPARITY
  6268. { "8E1", 9, 0 },
  6269. { "8E2", 10, 0 },
  6270. #endif /* HWPARITY */
  6271. { "8N1", 8, 0 },
  6272. #ifdef HWPARITY
  6273. { "8N2", 11, 0 },
  6274. { "8O1", 12, 0 },
  6275. { "8O2", 13, 0 },
  6276. #endif /* HWPARITY */
  6277. { "", 0, 0 }
  6278. };
  6279. static int nsertbl = (sizeof(sertbl) / sizeof(struct keytab)) - 1;
  6280. static char * sernam[] = { /* Keep this in sync with sertbl[] */
  6281. "7E1", "7E2", "7M1", "7M2", "7O1", "7O2", "7S1", "7S2",
  6282. "8N1", "8E1", "8E2", "8N2", "8O1", "8O2"
  6283. };
  6284. static struct keytab optstab[] = { /* SET OPTIONS table */
  6285. #ifndef NOFRILLS
  6286. { "delete", XXDEL, 0}, /* DELETE */
  6287. #endif /* NOFRILLS */
  6288. { "directory", XXDIR, 0}, /* DIRECTORY */
  6289. #ifdef CKPURGE
  6290. { "purge", XXPURGE, 0}, /* PURGE */
  6291. #endif /* CKPURGE */
  6292. { "type", XXTYP, 0}, /* TYPE */
  6293. { "", 0, 0}
  6294. };
  6295. static int noptstab = (sizeof(optstab) / sizeof(struct keytab)) - 1;
  6296. #ifndef NOXFER
  6297. /*
  6298. PROTOCOL SELECTION. Kermit is always available. If CK_XYZ is defined at
  6299. compile time, then the others become selections also. In OS/2 and
  6300. Windows, they are integrated and the various SET commands (e.g. "set file
  6301. type") affect them as they would Kermit. In other OS's (UNIX, VMS, etc),
  6302. they are external protocols which are run via Kermit's REDIRECT mechanism.
  6303. All we do is collect and verify the filenames and pass them along to the
  6304. external protocol.
  6305. */
  6306. struct keytab protos[] = {
  6307. #ifdef CK_XYZ
  6308. "g", PROTO_G, CM_INV,
  6309. #endif /* CK_XYZ */
  6310. "kermit", PROTO_K, 0,
  6311. #ifdef CK_XYZ
  6312. "other", PROTO_O, 0,
  6313. "x", PROTO_X, CM_INV|CM_ABR,
  6314. "xmodem", PROTO_X, 0,
  6315. "xmodem-crc", PROTO_XC, 0,
  6316. "y", PROTO_Y, CM_INV|CM_ABR,
  6317. "ymodem", PROTO_Y, 0,
  6318. "ymodem-g", PROTO_G, 0,
  6319. "zmodem", PROTO_Z, 0
  6320. #endif /* CK_XYZ */
  6321. };
  6322. int nprotos = (sizeof(protos) / sizeof(struct keytab));
  6323. #ifndef XYZ_INTERNAL
  6324. #ifndef NOPUSH
  6325. #define EXP_HANDLER 1
  6326. #define EXP_STDERR 2
  6327. #define EXP_TIMO 3
  6328. static struct keytab extprotab[] = {
  6329. { "handler", EXP_HANDLER, 0 },
  6330. { "redirect-stderr", EXP_STDERR, 0 },
  6331. { "timeout", EXP_TIMO, 0 }
  6332. };
  6333. static int nxtprotab = (sizeof(extprotab) / sizeof(struct keytab));
  6334. #endif /* NOPUSH */
  6335. #endif /* XYZ_INTERNAL */
  6336. #define XPCMDLEN 71
  6337. _PROTOTYP(static int protofield, (char *, char *, char *));
  6338. _PROTOTYP(static int setproto, (void));
  6339. static int
  6340. protofield(current, help, px) char * current, * help, * px; {
  6341. char *s, tmpbuf[XPCMDLEN+1];
  6342. int x;
  6343. if (current) /* Put braces around default */
  6344. ckmakmsg(tmpbuf,TMPBUFSIZ,"{",current,"}",NULL);
  6345. else
  6346. tmpbuf[0] = NUL;
  6347. if ((x = cmfld(help, (char *)tmpbuf, &s, xxstring)) < 0)
  6348. return(x);
  6349. if ((int)strlen(s) > XPCMDLEN) {
  6350. printf("?Sorry - maximum length is %d\n", XPCMDLEN);
  6351. return(-9);
  6352. } else if (*s) {
  6353. strcpy(px,s); /* safe */
  6354. } else {
  6355. px = NULL;
  6356. }
  6357. return(x);
  6358. }
  6359. static int
  6360. setproto() { /* Select a file transfer protocol */
  6361. /* char * s = NULL; */
  6362. int x = 0, y;
  6363. char s1[XPCMDLEN+1], s2[XPCMDLEN+1], s3[XPCMDLEN+1];
  6364. char s4[XPCMDLEN+1], s5[XPCMDLEN+1], s6[XPCMDLEN+1], s7[XPCMDLEN+1];
  6365. char * p1 = s1, * p2 = s2, *p3 = s3;
  6366. char * p4 = s4, * p5 = s5, *p6 = s6, *p7 = s7;
  6367. #ifdef XYZ_INTERNAL
  6368. extern int p_avail;
  6369. #else
  6370. #ifndef CK_REDIR
  6371. x = 1;
  6372. #endif /* CK_REDIR */
  6373. #endif /* XYZ_INTERNAL */
  6374. s1[0] = NUL;
  6375. s2[0] = NUL;
  6376. s3[0] = NUL;
  6377. s4[0] = NUL;
  6378. s5[0] = NUL;
  6379. s6[0] = NUL;
  6380. if ((y = cmkey(protos,nprotos,"","kermit",xxstring)) < 0)
  6381. return(y);
  6382. if (x && y != PROTO_K) {
  6383. printf(
  6384. "?Sorry, REDIRECT capability required for external protocols.\n");
  6385. return(-9);
  6386. }
  6387. if ((x = protofield(ptab[y].h_b_init,
  6388. "Optional command to send to host prior to uploading in binary mode",
  6389. p1)) < 0) {
  6390. if (x == -3) {
  6391. protocol = y; /* Set protocol but don't change */
  6392. return(1); /* anything else */
  6393. } else
  6394. return(x);
  6395. }
  6396. if ((x = protofield(ptab[y].h_t_init,
  6397. "Optional command to send to host prior to uploading in text mode",
  6398. p2)) < 0) {
  6399. if (x == -3)
  6400. goto protoexit;
  6401. else
  6402. return(x);
  6403. }
  6404. if (y == PROTO_K) {
  6405. if ((x = protofield(ptab[y].h_x_init,
  6406. "Optional command to send to host to start Kermit server",
  6407. p3)) < 0) {
  6408. if (x == -3)
  6409. goto protoexit;
  6410. else
  6411. return(x);
  6412. }
  6413. }
  6414. #ifndef XYZ_INTERNAL /* If XYZMODEM are external... */
  6415. if (y != PROTO_K) {
  6416. if ((x = protofield(ptab[y].p_b_scmd,
  6417. "External command to SEND in BINARY mode with this protocol",
  6418. p4)) < 0) {
  6419. if (x == -3)
  6420. goto protoexit;
  6421. else
  6422. return(x);
  6423. }
  6424. if ((x = protofield(ptab[y].p_t_scmd,
  6425. "External command to SEND in TEXT mode with this protocol",
  6426. p5)) < 0) {
  6427. if (x == -3)
  6428. goto protoexit;
  6429. else
  6430. return(x);
  6431. }
  6432. if ((x = protofield(ptab[y].p_b_rcmd,
  6433. "External command to RECEIVE in BINARY mode with this protocol",
  6434. p6)) < 0) {
  6435. if (x == -3)
  6436. goto protoexit;
  6437. else
  6438. return(x);
  6439. }
  6440. if ((x = protofield(ptab[y].p_t_rcmd,
  6441. "External command to RECEIVE in TEXT mode with this protocol",
  6442. p7)) < 0) {
  6443. if (x == -3)
  6444. goto protoexit;
  6445. else
  6446. return(x);
  6447. }
  6448. }
  6449. #endif /* XYZ_INTERNAL */
  6450. if ((x = cmcfm()) < 0) /* Confirm the command */
  6451. return(x);
  6452. protoexit: /* Common exit from this routine */
  6453. #ifdef XYZ_INTERNAL
  6454. if (!p_avail) {
  6455. bleep(BP_WARN);
  6456. printf("\n?X,Y, and Zmodem are unavailable\n");
  6457. return(success = 0);
  6458. }
  6459. #endif /* XYZ_INTERNAL */
  6460. p1 = brstrip(p1);
  6461. p2 = brstrip(p2);
  6462. p3 = brstrip(p3);
  6463. p4 = brstrip(p4);
  6464. p5 = brstrip(p5);
  6465. p6 = brstrip(p6);
  6466. p7 = brstrip(p7);
  6467. initproto(y,p1,p2,p3,p4,p5,p6,p7);
  6468. return(success = 1);
  6469. }
  6470. #ifndef NOPUSH
  6471. #ifndef XYZ_INTERNAL
  6472. #define DEF_EXP_TIMO 12 /* Default timeout for external protocol (seconds) */
  6473. int exp_handler = 0; /* These are exported */
  6474. int exp_timo = DEF_EXP_TIMO;
  6475. int exp_stderr = SET_AUTO;
  6476. VOID
  6477. shoextern() { /* Invoked by SHOW PROTOCOL */
  6478. printf("\n External-protocol handler: %s\n",
  6479. exp_handler ? (exp_handler == 1 ? "pty" : "system") : "automatic");
  6480. #ifdef COMMENT
  6481. printf(" External-protocol redirect-stderr: %s\n", showooa(exp_stderr));
  6482. #endif /* COMMENT */
  6483. printf(" External-protocol timeout: %d (sec)\n", exp_timo);
  6484. }
  6485. static struct keytab setexternhandler[] = {
  6486. { "automatic", 0, 0 },
  6487. { "pty", 1, 0 },
  6488. { "system", 2, 0 }
  6489. };
  6490. int
  6491. setextern() { /* SET EXTERNAL-PROTOCOL */
  6492. int x, y;
  6493. if ((x = cmkey(extprotab,nxtprotab,"","",xxstring)) < 0)
  6494. return(x);
  6495. switch (x) {
  6496. case EXP_HANDLER:
  6497. if ((x = cmkey(setexternhandler,3,"","automatic",xxstring)) < 0)
  6498. return(x);
  6499. if ((y = cmcfm()) < 0)
  6500. return(y);
  6501. exp_handler = x;
  6502. break;
  6503. #ifdef COMMENT
  6504. case EXP_STDERR:
  6505. if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
  6506. return(x);
  6507. if ((y = cmcfm()) < 0)
  6508. return(y);
  6509. exp_stderr = x;
  6510. break;
  6511. #endif /* COMMENT */
  6512. case EXP_TIMO:
  6513. y = cmnum("Inactivity timeout, seconds,",ckitoa(DEF_EXP_TIMO),
  6514. 10,&x,xxstring);
  6515. return(setnum(&exp_timo,x,y,-1));
  6516. }
  6517. return(success = 1);
  6518. }
  6519. #endif /* XYZ_INTERNAL */
  6520. #endif /* NOPUSH */
  6521. int
  6522. setdest() {
  6523. int x, y;
  6524. if ((y = cmkey(desttab,ndests,"","disk",xxstring)) < 0) return(y);
  6525. if ((x = cmcfm()) < 0) return(x);
  6526. dest = y;
  6527. return(1);
  6528. }
  6529. #endif /* NOXFER */
  6530. #ifdef DECNET
  6531. struct keytab dnettab[] = {
  6532. #ifndef OS2ONLY
  6533. "cterm", NP_CTERM, 0,
  6534. #endif /* OS2ONLY */
  6535. "lat", NP_LAT, 0
  6536. };
  6537. int ndnet = (sizeof(dnettab) / sizeof(struct keytab));
  6538. #endif /* DECNET */
  6539. /* S E T P R I N T E R -- SET PRINTER command */
  6540. #ifdef PRINTSWI
  6541. static struct keytab prntab[] = { /* SET PRINTER switches */
  6542. "/bidirectional", PRN_BID, 0,
  6543. #ifdef OS2
  6544. "/character-set", PRN_CS, CM_ARG,
  6545. #endif /* OS2 */
  6546. "/command", PRN_PIP, CM_ARG,
  6547. "/dos-device", PRN_DOS, CM_ARG,
  6548. "/end-of-job-string",PRN_TRM, CM_ARG,
  6549. "/file", PRN_FIL, CM_ARG,
  6550. #ifdef BPRINT
  6551. "/flow-control", PRN_FLO, CM_ARG,
  6552. #endif /* BPRINT */
  6553. "/job-header-file", PRN_SEP, CM_ARG,
  6554. #ifdef OS2
  6555. "/length", PRN_LEN, CM_ARG,
  6556. #endif /* OS2 */
  6557. "/none", PRN_NON, 0,
  6558. #ifdef OS2
  6559. "/nopostscript", PRN_RAW, 0,
  6560. "/nops", PRN_RAW, CM_INV,
  6561. #endif /* OS2 */
  6562. "/output-only", PRN_OUT, 0,
  6563. #ifdef BPRINT
  6564. "/parity", PRN_PAR, CM_ARG,
  6565. #endif /* BPRINT */
  6566. "/pipe", PRN_PIP, CM_ARG|CM_INV,
  6567. #ifdef OS2
  6568. "/postscript", PRN_PS, 0,
  6569. "/ps", PRN_PS, CM_INV,
  6570. #endif /* OS2 */
  6571. "/separator", PRN_SEP, CM_ARG|CM_INV,
  6572. #ifdef BPRINT
  6573. "/speed", PRN_SPD, CM_ARG,
  6574. #endif /* BPRINT */
  6575. "/timeout", PRN_TMO, CM_ARG,
  6576. "/terminator", PRN_TRM, CM_ARG|CM_INV,
  6577. #ifdef OS2
  6578. #ifdef NT
  6579. "/w", PRN_WIN, CM_ARG|CM_ABR|CM_INV,
  6580. "/wi", PRN_WIN, CM_ARG|CM_ABR|CM_INV,
  6581. #endif /* NT */
  6582. "/width", PRN_WID, CM_ARG,
  6583. #endif /* OS2 */
  6584. #ifdef NT
  6585. "/windows-queue", PRN_WIN, CM_ARG,
  6586. #endif /* NT */
  6587. "", 0, 0
  6588. };
  6589. int nprnswi = (sizeof(prntab) / sizeof(struct keytab)) - 1;
  6590. #endif /* PRINTSWI */
  6591. static int
  6592. setprinter(xx) int xx; {
  6593. int x, y;
  6594. char * s;
  6595. char * defname = NULL;
  6596. #ifdef OS2
  6597. extern int prncs;
  6598. #endif /* OS2 */
  6599. #ifdef BPRINT
  6600. char portbuf[64];
  6601. long portspeed = 0L;
  6602. int portparity = 0;
  6603. int portflow = 0;
  6604. #endif /* BPRINT */
  6605. #ifdef PRINTSWI
  6606. int c, i, n, wild, confirmed = 0; /* Workers */
  6607. int getval = 0; /* Whether to get switch value */
  6608. struct stringint pv[PRN_MAX+1]; /* Temporary array for switch values */
  6609. struct FDB sw, of, cm; /* FDBs for each parse function */
  6610. int haveque = 0;
  6611. int typeset = 0;
  6612. #endif /* PRINTSWI */
  6613. #ifdef NT
  6614. struct keytab * printtab = NULL, * _printtab = NULL;
  6615. int nprint = 0, printdef=0;
  6616. #endif /* NT */
  6617. #ifdef OS2
  6618. defname = "PRN"; /* default */
  6619. #else
  6620. #ifdef VMS
  6621. defname = "LPT:";
  6622. #else
  6623. #ifdef UNIX
  6624. defname = "|lpr";
  6625. #endif /* UNIX */
  6626. #endif /* VMS */
  6627. #endif /* OS2 */
  6628. #ifdef PRINTSWI
  6629. #ifdef NT
  6630. haveque = Win32EnumPrt(&printtab,&_printtab,&nprint,&printdef);
  6631. haveque = haveque && nprint;
  6632. #endif /* NT */
  6633. for (i = 0; i <= PRN_MAX; i++) { /* Initialize switch values */
  6634. pv[i].sval = NULL; /* to null pointers */
  6635. pv[i].ival = -1; /* and -1 int values */
  6636. pv[i].wval = (CK_OFF_T)-1; /* and -1 wide values */
  6637. }
  6638. if (xx == XYBDCP) { /* SET BPRINTER == /BIDIRECTIONAL */
  6639. pv[PRN_BID].ival = 1;
  6640. pv[PRN_OUT].ival = 0;
  6641. }
  6642. /* Initialize defaults based upon current printer settings */
  6643. if (printername) {
  6644. defname = printername;
  6645. switch (printertype) {
  6646. case PRT_WIN: pv[PRN_WIN].ival = 1; break;
  6647. case PRT_DOS: pv[PRN_DOS].ival = 1; break;
  6648. case PRT_PIP: pv[PRN_PIP].ival = 1; break;
  6649. case PRT_FIL: pv[PRN_FIL].ival = 1; break;
  6650. case PRT_NON: pv[PRN_NON].ival = 1; break;
  6651. }
  6652. }
  6653. #ifdef BPRINT
  6654. /* only set the BIDI flag if we are bidi */
  6655. if (printbidi)
  6656. pv[PRN_BID].ival = 1;
  6657. /* serial port parameters may be set for non-bidi devices */
  6658. pv[PRN_SPD].ival = pportspeed / 10L;
  6659. pv[PRN_PAR].ival = pportparity;
  6660. pv[PRN_FLO].ival = pportflow;
  6661. #endif /* BPRINT */
  6662. if (printtimo)
  6663. pv[PRN_TMO].ival = printtimo;
  6664. if (printterm) {
  6665. pv[PRN_TRM].ival = 1;
  6666. makestr(&pv[PRN_TRM].sval,printterm);
  6667. }
  6668. if (printsep) {
  6669. pv[PRN_SEP].ival = 1;
  6670. makestr(&pv[PRN_SEP].sval,printsep);
  6671. }
  6672. if (txt2ps) {
  6673. pv[PRN_PS].ival = 1;
  6674. pv[PRN_WID].ival = ps_width;
  6675. pv[PRN_LEN].ival = ps_length;
  6676. } else {
  6677. pv[PRN_RAW].ival = 1;
  6678. }
  6679. /* Set up chained parse functions... */
  6680. cmfdbi(&sw, /* First FDB - command switches */
  6681. _CMKEY, /* fcode */
  6682. "Switch", /* hlpmsg */
  6683. "", /* default */
  6684. "", /* addtl string data */
  6685. nprnswi, /* addtl numeric data 1: tbl size */
  6686. 4, /* addtl numeric data 2: 4 = cmswi */
  6687. xxstring, /* Processing function */
  6688. prntab, /* Keyword table */
  6689. &cm /* Pointer to next FDB */
  6690. );
  6691. cmfdbi(&cm, /* Second fdb for confirmation */
  6692. _CMCFM, /* fcode */
  6693. "", /* hlpmsg */
  6694. "", /* default */
  6695. "", /* addtl string data */
  6696. 0, /* addtl numeric data 1 */
  6697. 0, /* addtl numeric data 2 */
  6698. NULL,
  6699. NULL,
  6700. &of
  6701. );
  6702. cmfdbi(&of, /* Third FDB for printer name */
  6703. _CMOFI, /* fcode */
  6704. "Printer or file name", /* hlpmsg */
  6705. defname, /* default */
  6706. "", /* addtl string data */
  6707. 0, /* addtl numeric data 1: tbl size */
  6708. 0, /* addtl numeric data 2: 4 = cmswi */
  6709. xxstring, /* Processing function */
  6710. NULL, /* Nothing */
  6711. NULL
  6712. );
  6713. while (1) { /* Parse 0 or more switches */
  6714. x = cmfdb(&sw); /* Parse switch or other thing */
  6715. debug(F101,"setprinter cmfdb","",x);
  6716. if (x < 0) /* Error */
  6717. goto xsetprn; /* or reparse needed */
  6718. if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
  6719. break;
  6720. if (cmresult.fdbaddr != &sw) /* Advanced usage :-) */
  6721. break;
  6722. c = cmgbrk(); /* Get break character */
  6723. getval = (c == ':' || c == '='); /* to see how they ended the switch */
  6724. n = cmresult.nresult; /* Numeric result = switch value */
  6725. debug(F101,"setprinter switch","",n);
  6726. switch (n) { /* Process the switch */
  6727. case PRN_PS: /* Text to Postscript */
  6728. pv[PRN_PS].ival = 1;
  6729. pv[PRN_BID].ival = 0;
  6730. pv[PRN_OUT].ival = 1;
  6731. pv[PRN_RAW].ival = 0;
  6732. break;
  6733. case PRN_RAW: /* Non-Postscript */
  6734. pv[PRN_PS].ival = 0;
  6735. pv[PRN_RAW].ival = 1;
  6736. break;
  6737. case PRN_BID: /* Bidirectional */
  6738. pv[PRN_BID].ival = 1;
  6739. pv[PRN_OUT].ival = 0;
  6740. pv[PRN_PS].ival = 0;
  6741. pv[PRN_RAW].ival = 1;
  6742. break;
  6743. case PRN_OUT: /* Output-only */
  6744. pv[PRN_OUT].ival = 1;
  6745. pv[PRN_BID].ival = 0;
  6746. pv[PRN_PS].ival = 0;
  6747. pv[PRN_RAW].ival = 1;
  6748. break;
  6749. case PRN_NON: /* NONE */
  6750. typeset++;
  6751. pv[n].ival = 1;
  6752. pv[PRN_SPD].ival = 0;
  6753. pv[PRN_PAR].ival = 0;
  6754. pv[PRN_FLO].ival = FLO_KEEP;
  6755. break;
  6756. #ifdef UNIX
  6757. case PRN_WIN:
  6758. #endif /* UNIX */
  6759. case PRN_DOS: /* DOS printer name */
  6760. case PRN_FIL: /* Or filename */
  6761. case PRN_PIP:
  6762. typeset++;
  6763. if (pv[n].sval) free(pv[n].sval);
  6764. pv[n].sval = NULL;
  6765. pv[PRN_NON].ival = 0; /* Zero any previous selections */
  6766. pv[PRN_WIN].ival = 0;
  6767. pv[PRN_DOS].ival = 0;
  6768. pv[PRN_FIL].ival = 0;
  6769. pv[PRN_PIP].ival = 0;
  6770. pv[n].ival = 1; /* Flag this one */
  6771. if (!getval) break; /* No value wanted */
  6772. if (n == PRN_FIL) { /* File, check accessibility */
  6773. int wild = 0;
  6774. if ((x = cmiofi("Filename","kermit.prn",&s,&wild,xxstring))< 0)
  6775. if (x == -9) {
  6776. if (zchko(s) < 0) {
  6777. printf("Can't create \"%s\"\n",s);
  6778. return(x);
  6779. }
  6780. } else goto xsetprn;
  6781. if (iswild(s)) {
  6782. printf("?A single file please\n");
  6783. return(-9);
  6784. }
  6785. pv[PRN_SPD].ival = 0;
  6786. pv[PRN_PAR].ival = 0;
  6787. pv[PRN_FLO].ival = FLO_KEEP;
  6788. } else if ((x = cmfld(n == PRN_DOS ? /* Value wanted - parse it */
  6789. "DOS printer device name" : /* Help message */
  6790. (n == PRN_PIP ?
  6791. "Program name" :
  6792. "Filename"),
  6793. n == PRN_DOS ?
  6794. "PRN" : /* Default */
  6795. "",
  6796. &s,
  6797. xxstring
  6798. )) < 0)
  6799. goto xsetprn;
  6800. s = brstrip(s); /* Strip enclosing braces */
  6801. while (*s == SP) /* Strip leading blanks */
  6802. s++;
  6803. if (n == PRN_PIP) { /* If /PIPE: */
  6804. if (*s == '|') { /* strip any extraneous pipe sign */
  6805. s++;
  6806. while (*s == SP)
  6807. s++;
  6808. }
  6809. pv[PRN_SPD].ival = 0;
  6810. pv[PRN_PAR].ival = 0;
  6811. pv[PRN_FLO].ival = FLO_KEEP;
  6812. }
  6813. if ((y = strlen(s)) > 0) /* Anything left? */
  6814. if (pv[n].sval = (char *) malloc(y+1)) /* Yes, keep it */
  6815. strcpy(pv[n].sval,s); /* safe */
  6816. break;
  6817. #ifdef NT
  6818. case PRN_WIN: /* Windows queue name */
  6819. typeset++;
  6820. if (pv[n].sval) free(pv[n].sval);
  6821. pv[n].sval = NULL;
  6822. pv[PRN_NON].ival = 0;
  6823. pv[PRN_DOS].ival = 0;
  6824. pv[PRN_FIL].ival = 0;
  6825. pv[n].ival = 1;
  6826. pv[PRN_SPD].ival = 0;
  6827. pv[PRN_PAR].ival = 0;
  6828. pv[PRN_FLO].ival = FLO_KEEP;
  6829. if (!getval || !haveque)
  6830. break;
  6831. if ((x = cmkey(_printtab,nprint,"Print queue name",
  6832. _printtab[printdef].kwd,xxstring)) < 0) {
  6833. if (x != -2)
  6834. goto xsetprn;
  6835. if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
  6836. s = atmbuf;
  6837. if ((y = strlen(s)) > 0)
  6838. if (pv[n].sval = (char *)malloc(y+1))
  6839. strcpy(pv[n].sval,s); /* safe */
  6840. } else {
  6841. if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
  6842. for (i = 0; i < nprint; i++) {
  6843. if (x == printtab[i].kwval) {
  6844. s = printtab[i].kwd;
  6845. break;
  6846. }
  6847. }
  6848. if ((y = strlen(s)) > 0)
  6849. if (pv[n].sval = (char *)malloc(y+1))
  6850. strcpy(pv[n].sval,s); /* safe */
  6851. }
  6852. break;
  6853. #endif /* NT */
  6854. case PRN_SEP: /* /JOB-HEADER (separator) */
  6855. if (pv[n].sval) free(pv[n].sval);
  6856. pv[n].sval = NULL;
  6857. pv[n].ival = 1;
  6858. if (!getval) break;
  6859. if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0)
  6860. goto xsetprn;
  6861. if (y) {
  6862. printf("?Wildcards not allowed\n");
  6863. x = -9;
  6864. goto xsetprn;
  6865. }
  6866. if ((y = strlen(s)) > 0)
  6867. if (pv[n].sval = (char *) malloc(y+1))
  6868. strcpy(pv[n].sval,s); /* safe */
  6869. break;
  6870. case PRN_TMO: /* /TIMEOUT:number */
  6871. pv[n].ival = 0;
  6872. if (!getval) break;
  6873. if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0)
  6874. goto xsetprn;
  6875. if (y > 999) {
  6876. printf("?Sorry - 999 is the maximum\n");
  6877. x = -9;
  6878. goto xsetprn;
  6879. } else
  6880. pv[n].ival = y;
  6881. break;
  6882. case PRN_TRM: /* /END-OF-JOB:string */
  6883. if (pv[n].sval) free(pv[n].sval);
  6884. pv[n].sval = NULL;
  6885. pv[n].ival = 1;
  6886. if (!getval) break;
  6887. if ((x = cmfld("String (enclose in braces if it contains spaces)",
  6888. "",&s,xxstring)) < 0)
  6889. goto xsetprn;
  6890. s = brstrip(s);
  6891. if ((y = strlen(s)) > 0)
  6892. if (pv[n].sval = (char *) malloc(y+1))
  6893. strcpy(pv[n].sval,s); /* safe */
  6894. break;
  6895. #ifdef BPRINT
  6896. case PRN_FLO:
  6897. if (!getval) break;
  6898. if ((x = cmkey(flotab,nflo,
  6899. "Serial printer-port flow control",
  6900. "rts/cts",xxstring)) < 0)
  6901. goto xsetprn;
  6902. pv[n].ival = x;
  6903. break;
  6904. #ifndef NOLOCAL
  6905. case PRN_SPD:
  6906. if (!getval) break;
  6907. /* TN_COMPORT here too? */
  6908. if ((x = cmkey(spdtab, /* Speed (no default) */
  6909. nspd,
  6910. "Serial printer-port interface speed",
  6911. "9600",
  6912. xxstring)
  6913. ) < 0)
  6914. goto xsetprn;
  6915. pv[n].ival = x;
  6916. break;
  6917. #endif /* NOLOCAL */
  6918. case PRN_PAR:
  6919. pv[n].ival = 0;
  6920. if (!getval) break;
  6921. if ((x = cmkey(partbl,npar,"Serial printer-port parity",
  6922. "none",xxstring)) < 0)
  6923. goto xsetprn;
  6924. pv[n].ival = x;
  6925. break;
  6926. #endif /* BPRINT */
  6927. #ifdef OS2
  6928. case PRN_LEN:
  6929. if (!getval) break;
  6930. if ((x = cmnum("PS page length", "66",10,&y,xxstring)) < 0)
  6931. goto xsetprn;
  6932. pv[n].ival = y;
  6933. break;
  6934. case PRN_WID:
  6935. if (!getval) break;
  6936. if ((x = cmnum("PS page width", "80",10,&y,xxstring)) < 0)
  6937. goto xsetprn;
  6938. pv[n].ival = y;
  6939. break;
  6940. case PRN_CS:
  6941. pv[n].ival = 0;
  6942. if (!getval) break;
  6943. if ((y = cmkey(
  6944. #ifdef CKOUNI
  6945. txrtab,ntxrtab,
  6946. #else /* CKOUNI */
  6947. ttcstab,ntermc,
  6948. #endif /* CKOUNI */
  6949. "auto-print/printscreen character-set",
  6950. "cp437",xxstring)) < 0)
  6951. goto xsetprn;
  6952. pv[n].ival = y;
  6953. break;
  6954. #endif /* OS2 */
  6955. default:
  6956. printf("?Unexpected switch value - %d\n",cmresult.nresult);
  6957. x = -9;
  6958. goto xsetprn;
  6959. }
  6960. }
  6961. line[0] = NUL; /* Initialize printer name value */
  6962. switch (cmresult.fcode) { /* How did we get here? */
  6963. case _CMOFI: /* They typed a filename */
  6964. ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Name */
  6965. wild = cmresult.nresult; /* Wild flag */
  6966. if (!typeset) { /* A printer name without a type */
  6967. pv[PRN_NON].ival = 0; /* is supposed to be treated as */
  6968. pv[PRN_WIN].ival = 0; /* a DOS or Pipe printer. We */
  6969. pv[PRN_FIL].ival = 0; /* clear all the flags and let */
  6970. pv[PRN_PIP].ival = 0; /* the code below dope out the */
  6971. pv[PRN_DOS].ival = 0; /* type. */
  6972. }
  6973. #ifdef NT
  6974. else if (pv[PRN_WIN].ival && lookup(_printtab,line,nprint,&y)) {
  6975. /* invalid Window Queue name */
  6976. printf("?invalid Windows Printer Queue name: \"%s\"\r\n",line);
  6977. x = -9;
  6978. goto xsetprn;
  6979. }
  6980. #endif /* NT */
  6981. if ((x = cmcfm()) < 0) /* Confirm the command */
  6982. goto xsetprn;
  6983. break;
  6984. case _CMCFM: /* They entered the command */
  6985. if (pv[PRN_DOS].ival > 0)
  6986. ckstrncpy(line,pv[PRN_DOS].sval ? pv[PRN_DOS].sval : "",LINBUFSIZ);
  6987. else if (pv[PRN_WIN].ival > 0)
  6988. ckstrncpy(line,pv[PRN_WIN].sval ? pv[PRN_WIN].sval : "",LINBUFSIZ);
  6989. else if (pv[PRN_FIL].ival > 0)
  6990. ckstrncpy(line,pv[PRN_FIL].sval ? pv[PRN_FIL].sval : "",LINBUFSIZ);
  6991. else if (pv[PRN_PIP].ival > 0)
  6992. ckstrncpy(line,pv[PRN_PIP].sval ? pv[PRN_PIP].sval : "",LINBUFSIZ);
  6993. break;
  6994. default: /* By mistake */
  6995. printf("?Unexpected function code: %d\n",cmresult.fcode);
  6996. x = -9;
  6997. goto xsetprn;
  6998. }
  6999. #else /* No PRINTSWI */
  7000. if ((x = cmofi("Printer or file name",defname,&s,xxstring)) < 0)
  7001. return(x);
  7002. if (x > 1) {
  7003. printf("?Directory names not allowed\n");
  7004. return(-9);
  7005. }
  7006. while (*s == SP || *s == HT) s++; /* Trim leading whitespace */
  7007. ckstrncpy(line,s,LINBUFSIZ); /* Make a temporary safe copy */
  7008. if ((x = cmcfm()) < 0) return(x); /* Confirm the command */
  7009. #endif /* PRINTSWI */
  7010. #ifdef IKSD
  7011. if (inserver && (isguest
  7012. #ifndef NOSERVER
  7013. || !ENABLED(en_pri)
  7014. #endif /* NOSERVER */
  7015. )) {
  7016. printf("Sorry, printing disabled\r\n");
  7017. return(success = 0);
  7018. }
  7019. #endif /* ISKD */
  7020. #ifdef PRINTSWI
  7021. #ifdef BPRINT
  7022. if (printbidi) { /* If bidi printing active */
  7023. #ifndef UNIX
  7024. bprtstop(); /* Stop it before proceeding */
  7025. #endif /* UNIX */
  7026. printbidi = 0;
  7027. }
  7028. if (pv[PRN_SPD].ival > 0) {
  7029. portspeed = (long) pv[PRN_SPD].ival * 10L;
  7030. if (portspeed == 70L) portspeed = 75L;
  7031. }
  7032. if (pv[PRN_PAR].ival > 0)
  7033. portparity = pv[PRN_PAR].ival;
  7034. if (pv[PRN_FLO].ival > 0)
  7035. portflow = pv[PRN_FLO].ival;
  7036. #endif /* BPRINT */
  7037. #endif /* PRINTSWI */
  7038. s = line; /* Printer name, if given */
  7039. #ifdef OS2ORUNIX
  7040. #ifdef PRINTSWI
  7041. if (pv[PRN_PIP].ival > 0) { /* /PIPE was given? */
  7042. printpipe = 1;
  7043. noprinter = 0;
  7044. if (*s == '|') { /* It might still have a pipe sign */
  7045. s++; /* if name give later */
  7046. while (*s == SP) /* so remove it and spaces */
  7047. s++;
  7048. }
  7049. } else
  7050. #endif /* PRINTSWI */
  7051. if (*s == '|') { /* Or pipe implied by name? */
  7052. s++; /* Point past pipe sign */
  7053. while (*s == SP) /* Gobble whitespace */
  7054. s++;
  7055. if (*s) {
  7056. printpipe = 1;
  7057. noprinter = 0;
  7058. }
  7059. } else {
  7060. printpipe = 0;
  7061. }
  7062. #ifdef PRINTSWI
  7063. #ifdef BPRINT
  7064. if (printpipe && pv[PRN_BID].ival > 0) {
  7065. printf("?Sorry, pipes not allowed for bidirectional printer\n");
  7066. return(-9);
  7067. }
  7068. #endif /* BPRINT */
  7069. #endif /* PRINTSWI */
  7070. #endif /* OS2ORUNIX */
  7071. #ifdef OS2
  7072. if ( pv[PRN_CS].ival > 0 )
  7073. prncs = pv[PRN_CS].ival;
  7074. if ( pv[PRN_PS].ival > 0 ) {
  7075. txt2ps = 1;
  7076. ps_width = pv[PRN_WID].ival <= 0 ? 80 : pv[PRN_WID].ival;
  7077. ps_length = pv[PRN_LEN].ival <= 0 ? 66 : pv[PRN_LEN].ival;
  7078. }
  7079. #endif /* OS2 */
  7080. y = strlen(s); /* Length of name of new print file */
  7081. if (y > 0
  7082. #ifdef OS2
  7083. && ((y != 3) || (ckstrcmp(s,"PRN",3,0) != 0))
  7084. #endif /* OS2 */
  7085. ) {
  7086. if (printername) { /* Had a print file before? */
  7087. free(printername); /* Remove its name */
  7088. printername = NULL;
  7089. }
  7090. printername = (char *) malloc(y + 1); /* Allocate space for it */
  7091. if (!printername) {
  7092. printf("?Memory allocation failure\n");
  7093. return(-9);
  7094. }
  7095. strcpy(printername,s); /* (safe) Copy new name to new space */
  7096. debug(F110,"printername",printername,0);
  7097. }
  7098. #ifdef PRINTSWI
  7099. /* Set printer type from switches that were given explicitly */
  7100. if (pv[PRN_NON].ival > 0) { /* No printer */
  7101. printertype = PRT_NON;
  7102. noprinter = 1;
  7103. printpipe = 0;
  7104. } else if (pv[PRN_FIL].ival > 0) { /* File */
  7105. printertype = PRT_FIL;
  7106. noprinter = 0;
  7107. printpipe = 0;
  7108. } else if (pv[PRN_PIP].ival > 0) { /* Pipe */
  7109. printertype = PRT_PIP;
  7110. noprinter = 0;
  7111. printpipe = 1;
  7112. } else if (pv[PRN_WIN].ival > 0) { /* Windows print queue */
  7113. printertype = PRT_WIN;
  7114. noprinter = 0;
  7115. printpipe = 0;
  7116. } else if (pv[PRN_DOS].ival > 0) { /* DOS device */
  7117. printertype = PRT_DOS;
  7118. noprinter = 0;
  7119. printpipe = 0;
  7120. } else if (line[0]) { /* Name given without switches */
  7121. noprinter = 0;
  7122. printertype = printpipe ? PRT_PIP : PRT_DOS;
  7123. #ifdef NT
  7124. /* was the command SET PRINTER windows-queue ? */
  7125. y = lookup(_printtab,line,nprint,&x);
  7126. if (y >= 0) {
  7127. printertype = PRT_WIN;
  7128. if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
  7129. if (printername) { /* Had a print file before? */
  7130. free(printername); /* Remove its name */
  7131. printername = NULL;
  7132. }
  7133. pv[PRN_WIN].sval = NULL;
  7134. pv[PRN_WIN].ival = 1;
  7135. s = printtab[x].kwd; /* Get full new name */
  7136. if ((y = strlen(s)) > 0) {
  7137. makestr(&pv[PRN_WIN].sval,s);
  7138. makestr(&printername,s);
  7139. if (!printername) {
  7140. printf("?Memory allocation failure\n");
  7141. return(-9);
  7142. }
  7143. debug(F110,"printername",printername,0);
  7144. }
  7145. } else if ( y == -2 ) {
  7146. /* Ambiguous Print Queue Name */
  7147. printf("?Ambiguous printer name provided.\n");
  7148. return(-9);
  7149. }
  7150. #endif /* NT */
  7151. }
  7152. #ifdef BPRINT
  7153. /* Port parameters may be set for non-bidi mode */
  7154. pportspeed = portspeed; /* Set parameters */
  7155. pportparity = portparity;
  7156. pportflow = portflow;
  7157. if (pv[PRN_BID].ival > 0) { /* Bidirectional */
  7158. #ifdef UNIX
  7159. printbidi = 1; /* (just to test parsing...) */
  7160. #else
  7161. printbidi = bprtstart(); /* Start bidirectional printer */
  7162. #endif /* UNIX */
  7163. return(success = printbidi);
  7164. } else
  7165. printbidi = 0; /* Not BPRINTER, unset flag */
  7166. #endif /* BPRINT */
  7167. if (pv[PRN_TMO].ival > -1) { /* Take care of timeout */
  7168. printtimo = pv[PRN_TMO].ival;
  7169. }
  7170. if (pv[PRN_TRM].ival > 0) { /* Termination string */
  7171. if (printterm) {
  7172. free(printterm);
  7173. printterm = NULL;
  7174. }
  7175. if (pv[PRN_TRM].sval)
  7176. makestr(&printterm,pv[PRN_TRM].sval);
  7177. }
  7178. if (pv[PRN_SEP].ival > 0) { /* and separator file */
  7179. if (printsep) {
  7180. free(printsep);
  7181. printsep = NULL;
  7182. }
  7183. if (pv[PRN_SEP].sval)
  7184. makestr(&printsep,pv[PRN_SEP].sval);
  7185. }
  7186. #endif /* PRINTSWI */
  7187. #ifdef UNIXOROSK
  7188. if (!printpipe
  7189. #ifdef PRINTSWI
  7190. && !noprinter
  7191. #endif /* PRINTSWI */
  7192. ) { /* File - check access */
  7193. if (zchko(s) < 0) {
  7194. printf("?Access denied - %s\n",s);
  7195. x = -9;
  7196. goto xsetprn;
  7197. }
  7198. }
  7199. #endif /* UNIXOROSK */
  7200. x = 1; /* Return code */
  7201. xsetprn: /* Common exit */
  7202. #ifdef PRINTSWI
  7203. for (i = 0; i <= PRN_MAX; i++) { /* Free malloc'd memory */
  7204. if (pv[i].sval)
  7205. free(pv[i].sval);
  7206. }
  7207. #endif /* PRINTSWI */
  7208. success = (x > 0) ? 1 : 0;
  7209. return(x);
  7210. }
  7211. #ifdef ANYSSH
  7212. /* The SET SSH command */
  7213. #define SSH_CMD 1 /* SET SSH COMMAND */
  7214. #ifdef SSHBUILTIN /* Built-in SET SSH options */
  7215. #define SSH_ADD 2 /* Add */
  7216. #define SSH_AFW 3 /* Agent-forwarding */
  7217. #define SSH_CHI 4 /* Check Host IP */
  7218. #define SSH_XFW 5 /* X11-forwarding */
  7219. #define SSH_DYF 6 /* Dynamic forwarding */
  7220. #define SSH_GWP 7 /* Gatewa portgs */
  7221. #define SSH_GSS 8 /* GSSAPI */
  7222. #define SSH_KBD 9 /* KBD Interactive Devices */
  7223. #define SSH_K4 10 /* Kerberos 4 */
  7224. #define SSH_K5 11 /* Kerberos 5 */
  7225. #define SSH_SHK 12 /* Strict Host Key Check */
  7226. #define SSH_V1 13 /* SSH V1 */
  7227. #define SSH_V2 14 /* SSH V2 */
  7228. #define SSH_PRP 15 /* Privd port */
  7229. #define SSH_CMP 16 /* Compression */
  7230. #define SSH_XAL 17 /* X Auth Location */
  7231. #define SSH_SHH 18 /* Quiet */
  7232. #define SSH_VER 19 /* Version */
  7233. #define SSH_VRB 20 /* Verbosity level */
  7234. #define SSH_IDF 21 /* Identity File */
  7235. #define SSH_CFG 22 /* Use OpenSSH Config */
  7236. #define SSH_HBT 23 /* Heartbeat Interval */
  7237. #endif /* SSHBUILTIN */
  7238. static struct keytab sshtab[] = { /* SET SSH command table */
  7239. #ifdef SSHBUILTIN
  7240. { "agent-forwarding", SSH_AFW, 0 },
  7241. { "check-host-ip", SSH_CHI, 0 },
  7242. { "compression", SSH_CMP, 0 },
  7243. { "dynamic-forwarding", SSH_DYF, 0 },
  7244. { "gateway-ports", SSH_GWP, 0 },
  7245. { "gssapi", SSH_GSS, 0 },
  7246. { "heartbeat-interval", SSH_HBT, 0 },
  7247. { "identity-file", SSH_IDF, 0 },
  7248. #ifdef COMMENT
  7249. { "kbd-interactive-devices", SSH_KBD, 0 },
  7250. #endif /* COMMENT */
  7251. { "k4", SSH_K4, CM_INV },
  7252. { "k5", SSH_K5, CM_INV },
  7253. { "kerberos4", SSH_K4, 0 },
  7254. { "kerberos5", SSH_K5, 0 },
  7255. { "krb4", SSH_K4, CM_INV },
  7256. { "krb5", SSH_K5, CM_INV },
  7257. { "privileged-port", SSH_PRP, 0 },
  7258. { "quiet", SSH_SHH, 0 },
  7259. { "strict-host-key-check", SSH_SHK, 0 },
  7260. { "use-openssh-config", SSH_CFG, 0 },
  7261. { "v1", SSH_V1, 0 },
  7262. { "v2", SSH_V2, 0 },
  7263. { "verbose", SSH_VRB, 0 },
  7264. { "version", SSH_VER, 0 },
  7265. { "x11-forwarding", SSH_XFW, 0 },
  7266. { "xauth-location", SSH_XAL, 0 },
  7267. #else
  7268. #ifdef SSHCMD
  7269. { "command", SSH_CMD, 0 },
  7270. #endif /* SSHCMD */
  7271. #endif /* SSHBUILTIN */
  7272. { "", 0, 0 }
  7273. };
  7274. static int nsshtab = (sizeof(sshtab) / sizeof(struct keytab)) - 1;
  7275. #ifdef SSHBUILTIN
  7276. static struct keytab sshver[] = { /* SET SSH VERSION command table */
  7277. { "1", 1, 0 },
  7278. { "2", 2, 0 },
  7279. { "automatic", 0, 0 }
  7280. };
  7281. #define SSHA_CRS 1
  7282. #define SSHA_DSA 2
  7283. #define SSHA_GSS 3
  7284. #define SSHA_HOS 4
  7285. #define SSHA_KBD 5
  7286. #define SSHA_K4 6
  7287. #define SSHA_K5 7
  7288. #define SSHA_PSW 8
  7289. #define SSHA_PK 9
  7290. #define SSHA_SKE 10
  7291. #define SSHA_TIS 11
  7292. #define SSHA_EXT 12
  7293. #define SSHA_SRP 13
  7294. static struct keytab ssh2aut[] = { /* SET SSH V2 AUTH command table */
  7295. { "external-keyx", SSHA_EXT, 0 },
  7296. { "gssapi", SSHA_GSS, 0 },
  7297. { "hostbased", SSHA_HOS, 0 },
  7298. { "keyboard-interactive", SSHA_KBD, 0 },
  7299. { "password", SSHA_PSW, 0 },
  7300. { "publickey", SSHA_PK, 0 },
  7301. { "srp-gex-sha1", SSHA_SRP, 0 },
  7302. { "", 0, 0 }
  7303. };
  7304. static int nssh2aut = (sizeof(ssh2aut) / sizeof(struct keytab)) - 1;
  7305. #define SSHF_LCL 1
  7306. #define SSHF_RMT 2
  7307. static struct keytab addfwd[] = { /* SET SSH ADD command table */
  7308. { "local-port-forward", SSHF_LCL, 0 },
  7309. { "remote-port-forward", SSHF_RMT, 0 },
  7310. { "", 0, 0 }
  7311. };
  7312. static int naddfwd = (sizeof(addfwd) / sizeof(struct keytab)) - 1;
  7313. #define SSH1_CIF 1
  7314. #define SSH1_GNH 2
  7315. #define SSH1_UNH 3
  7316. #define SSH1_K54 4
  7317. #define SSH2_CIF 1
  7318. #define SSH2_GNH 2
  7319. #define SSH2_UNH 3
  7320. #define SSH2_ARK 4
  7321. #define SSH2_HKA 5
  7322. #define SSH2_MAC 6
  7323. #define SSH2_AUT 7
  7324. static struct keytab sshv1tab[] = { /* SET SSH V1 command table */
  7325. { "cipher", SSH1_CIF, 0 },
  7326. { "global-known-hosts-file", SSH1_GNH, 0 },
  7327. { "k5-reuse-k4-messages", SSH1_K54, CM_INV },
  7328. { "user-known-hosts-file", SSH1_UNH, 0 },
  7329. { "", 0, 0 }
  7330. };
  7331. static int nsshv1tab = (sizeof(sshv1tab) / sizeof(struct keytab)) - 1;
  7332. static struct keytab sshv2tab[] = { /* SET SSH V2 command table */
  7333. { "authentication", SSH2_AUT, 0 },
  7334. { "auto-rekey", SSH2_ARK, 0 },
  7335. { "ciphers", SSH2_CIF, 0 },
  7336. { "global-known-hosts-file", SSH2_GNH, 0 },
  7337. { "hostkey-algorithms", SSH2_HKA, 0 },
  7338. { "macs", SSH2_MAC, 0 },
  7339. { "user-known-hosts-file", SSH2_UNH, 0 },
  7340. { "", 0, 0 }
  7341. };
  7342. static int nsshv2tab = (sizeof(sshv2tab) / sizeof(struct keytab)) - 1;
  7343. #define SSHC_3DES 1 /* 3DES */
  7344. #define SSHC_3CBC 2 /* 3DES-CBC */
  7345. #define SSHC_A128 3 /* AES128-CBC */
  7346. #define SSHC_A192 4 /* AES192-CBC */
  7347. #define SSHC_A256 5 /* AES256-CBC */
  7348. #define SSHC_ARC4 6 /* ARCFOUR */
  7349. #define SSHC_FISH 7 /* BLOWFISH */
  7350. #define SSHC_BCBC 9 /* BLOWFISH-CBC */
  7351. #define SSHC_C128 8 /* CAST128-CBC */
  7352. #define SSHC_1DES 10 /* DES */
  7353. static struct keytab ssh1ciphers[] = {
  7354. { "3des", SSHC_3DES, 0 },
  7355. { "blowfish", SSHC_FISH, 0 },
  7356. { "des", SSHC_1DES, 0 },
  7357. { "", 0, 0 }
  7358. };
  7359. static int nssh1ciphers = (sizeof(ssh1ciphers) / sizeof(struct keytab)) - 1;
  7360. static struct keytab ssh2ciphers[] = { /* SET SSH V2 CIPHERS command table */
  7361. { "3des-cbc", SSHC_3DES, 0 },
  7362. { "aes128-cbc", SSHC_A128, 0 },
  7363. { "aes192-cbc", SSHC_A192, 0 },
  7364. { "aes256-cbc", SSHC_A256, 0 },
  7365. { "arcfour", SSHC_ARC4, 0 },
  7366. { "blowfish-cbc", SSHC_FISH, 0 },
  7367. { "cast128-cbc", SSHC_C128, 0 },
  7368. { "rijndael128-cbc", SSHC_A128, 0 },
  7369. { "rijndael192-cbc", SSHC_A192, 0 },
  7370. { "rijndael256-cbc", SSHC_A256, 0 },
  7371. { "", 0, 0 }
  7372. };
  7373. static int nssh2ciphers = (sizeof(ssh2ciphers) / sizeof(struct keytab)) - 1;
  7374. #define SSHM_SHA 1 /* HMAC-SHA1 */
  7375. #define SSHM_SHA_96 2 /* HMAC-SHA1-96 */
  7376. #define SSHM_MD5 3 /* HMAC-MD5 */
  7377. #define SSHM_MD5_96 4 /* HMAC-MD5-96 */
  7378. #define SSHM_RIPE 5 /* HMAC-RIPEMD160 */
  7379. static struct keytab ssh2macs[] = { /* SET SSH V2 MACS command table */
  7380. { "hmac-md5", SSHM_MD5, 0 },
  7381. { "hmac-md5-96", SSHM_MD5_96, 0 },
  7382. { "hmac-ripemd160", SSHM_RIPE, 0 },
  7383. { "hmac-sha1", SSHM_SHA, 0 },
  7384. { "hmac-sha1-96", SSHM_SHA_96, 0 },
  7385. { "", 0, 0 }
  7386. };
  7387. static int nssh2macs = (sizeof(ssh2macs) / sizeof(struct keytab)) - 1;
  7388. static struct keytab tgtpass[] = {
  7389. { "tgt-passing", 1, 0, },
  7390. { "", 0, 0 }
  7391. };
  7392. static int ntgtpass = (sizeof(tgtpass) / sizeof(struct keytab)) - 1;
  7393. static struct keytab gssapitab[] = {
  7394. { "delegate-credentials", 1, 0, },
  7395. { "key-exchange", 2, CM_INV, },
  7396. { "", 0, 0 }
  7397. };
  7398. static int ngssapitab = (sizeof(gssapitab) / sizeof(struct keytab)) - 1;
  7399. #define HKA_RSA 1
  7400. #define HKA_DSS 2
  7401. static struct keytab hkatab[] = {
  7402. { "ssh-dss", HKA_DSS, 0, },
  7403. { "ssh-rsa", HKA_RSA, 0, },
  7404. { "", 0, 0 }
  7405. };
  7406. static int nhkatab = (sizeof(hkatab) / sizeof(struct keytab)) - 1;
  7407. int /* SET SSH variables */
  7408. ssh_afw = 0, /* agent forwarding */
  7409. ssh_xfw = 0, /* x11 forwarding */
  7410. ssh_prp = SET_OFF, /* privileged ports */
  7411. ssh_cmp = 1, /* compression */
  7412. ssh_shh = 0, /* quiet */
  7413. ssh_ver = 0, /* protocol version (auto,1,2) */
  7414. ssh_vrb = 2, /* Report errors */
  7415. ssh_chkip = 0, /* SSH Check Host IP flag */
  7416. ssh_gwp = 0, /* gateway ports */
  7417. ssh_dyf = 0, /* dynamic forwarding */
  7418. ssh_gsd = 0, /* gssapi delegate credentials */
  7419. ssh_k4tgt = 0, /* k4 tgt passing */
  7420. ssh_k5tgt = 0, /* k5 tgt passing */
  7421. ssh_shk = 2, /* Strict host key (no, yes, ask) */
  7422. ssh2_ark = 1, /* Auto re-key */
  7423. ssh_cas = 0, /* command as subsys */
  7424. ssh_cfg = 0, /* use OpenSSH config? */
  7425. ssh_gkx = 1, /* gssapi key exchange */
  7426. ssh_k5_is_k4 = 1, /* some SSH v1 use same codes */
  7427. ssh_hbt = 0, /* heartbeat (seconds) */
  7428. ssh_dummy = 0; /* bottom of list */
  7429. char /* The following are to be malloc'd */
  7430. * ssh1_cif = NULL, /* v1 cipher */
  7431. * ssh2_cif = NULL, /* v2 cipher list */
  7432. * ssh2_mac = NULL, /* v2 mac list */
  7433. * ssh2_auth = NULL, /* v2 authentication list */
  7434. * ssh_hst = NULL, /* hostname */
  7435. * ssh_prt = NULL, /* port/service */
  7436. * ssh_cmd = NULL, /* command to execute */
  7437. * ssh_xal = NULL, /* xauth-location */
  7438. * ssh1_gnh = NULL, /* v1 global known hosts file */
  7439. * ssh1_unh = NULL, /* v1 user known hosts file */
  7440. * ssh2_gnh = NULL, /* v2 global known hosts file */
  7441. * ssh2_unh = NULL, /* v2 user known hosts file */
  7442. * ssh2_hka = NULL, /* Host Key Algorithms */
  7443. * xxx_dummy = NULL;
  7444. char * ssh_idf[32] = { /* Identity file list */
  7445. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  7446. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  7447. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  7448. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
  7449. };
  7450. char * ssh_tmp[32] = { /* Temp identity file list */
  7451. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  7452. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  7453. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  7454. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
  7455. };
  7456. int ssh_idf_n = 0;
  7457. extern int ssh_pf_lcl_n,
  7458. ssh_pf_rmt_n;
  7459. extern struct ssh_pf ssh_pf_lcl[32]; /* Port forwarding structs */
  7460. extern struct ssh_pf ssh_pf_rmt[32]; /* (declared in ckuusr.c) */
  7461. #endif /* SSHBUILTIN */
  7462. #ifdef SFTP_BUILTIN
  7463. static struct keytab sftptab[] = {
  7464. { "end-of-line", XY_SFTP_EOL, 0, },
  7465. { "remote-character-set", XY_SFTP_RCS, 0, },
  7466. { "", 0, 0 }
  7467. };
  7468. static int nsftptab = (sizeof(sftptab) / sizeof(struct keytab)) - 1;
  7469. #endif /* SFTP_BUILTIN */
  7470. VOID
  7471. shossh() {
  7472. #ifdef SSHBUILTIN
  7473. int i, n = 0; /* ADD askmore()! */
  7474. printf("\nSSH is built in:\n\n");
  7475. printf(" ssh host: %s\n",showstring(ssh_hst));
  7476. printf(" ssh port: %s\n",showstring(ssh_prt));
  7477. printf(" ssh command: %s\n",showstring(ssh_cmd));
  7478. printf(" ssh agent-forwarding: %s\n",showoff(ssh_afw));
  7479. printf(" ssh check-host-ip: %s\n",showoff(ssh_chkip));
  7480. printf(" ssh compression: %s\n",showoff(ssh_cmp));
  7481. printf(" ssh dynamic-forwarding: %s\n",showoff(ssh_dyf));
  7482. if (ssh_pf_lcl[0].p1 && ssh_pf_lcl[0].host && ssh_pf_lcl[0].p2) {
  7483. printf(" ssh forward-local-port: %d %s %d\n",
  7484. ssh_pf_lcl[0].p1, ssh_pf_lcl[0].host, ssh_pf_lcl[0].p2);
  7485. for ( n=1;n<ssh_pf_lcl_n;n++ )
  7486. printf(" : %d %s %d\n",
  7487. ssh_pf_lcl[n].p1, ssh_pf_lcl[n].host, ssh_pf_lcl[n].p2);
  7488. } else
  7489. printf(" ssh forward-local-port: (none)\n");
  7490. if (ssh_pf_rmt[0].p1 && ssh_pf_rmt[0].host && ssh_pf_rmt[0].p2) {
  7491. printf(" ssh forward-remote-port: %d %s %d\n",
  7492. ssh_pf_rmt[0].p1, ssh_pf_rmt[0].host, ssh_pf_rmt[0].p2);
  7493. for ( n=1;n<ssh_pf_rmt_n;n++ )
  7494. printf(" : %d %s %d\n",
  7495. ssh_pf_rmt[n].p1, ssh_pf_rmt[n].host, ssh_pf_rmt[n].p2);
  7496. } else
  7497. printf(" ssh forward-remote-port: (none)\n");
  7498. printf(" ssh gateway-ports: %s\n",showoff(ssh_gwp));
  7499. printf(" ssh gssapi delegate-credentials: %s\n",showoff(ssh_gsd));
  7500. printf(" ssh gssapi key-exchange : %s\n",showoff(ssh_gkx));
  7501. printf(" ssh identity-file: %d\n",ssh_idf_n);
  7502. for (i = 0; i < ssh_idf_n; i++)
  7503. printf(" %2d. %s\n",i+1,showstring(ssh_idf[i]));
  7504. printf(" ssh heartbeat interval: %d\n", ssh_hbt);
  7505. printf(" ssh k4 tgt-passing: %s\n",showoff(ssh_k4tgt));
  7506. printf(" ssh k5 tgt-passing: %s\n",showoff(ssh_k5tgt));
  7507. printf(" ssh privileged-port: %s\n",showooa(ssh_prp));
  7508. printf(" ssh quiet: %s\n",showoff(ssh_shh));
  7509. printf(" ssh strict-host-key-check: %d\n",ssh_shk);
  7510. printf(" ssh use-openssh-config: %s\n",showoff(ssh_cfg));
  7511. printf(" ssh verbose: %d\n",ssh_vrb);
  7512. printf(" ssh version: %s\n",
  7513. ssh_ver ? ckitoa(ssh_ver) : "automatic"
  7514. );
  7515. printf(" ssh x11-forwarding: %s\n",showooa(ssh_xfw));
  7516. printf(" ssh xauth-location: %s\n",showstring(ssh_xal));
  7517. printf("\n");
  7518. printf(" ssh v1 cipher: %s\n",showstring(ssh1_cif));
  7519. printf(" ssh v1 global-known-hosts-file: %s\n",showstring(ssh1_gnh));
  7520. printf(" ssh v1 user-known-hosts-file: %s\n",showstring(ssh1_unh));
  7521. printf("\n");
  7522. printf(" ssh v2 authentication: %s\n",showstring(ssh2_auth));
  7523. printf(" ssh v2 auto-rekey: %s\n",showoff(ssh2_ark));
  7524. printf(" ssh v2 ciphers: %s\n",showstring(ssh2_cif));
  7525. printf(" ssh v2 command-as-subsystem: %s\n",showoff(ssh_cas));
  7526. printf(" ssh v2 global-known-hosts-file: %s\n",showstring(ssh2_gnh));
  7527. printf(" ssh v2 hostkey-algorithms: %s\n",showstring(ssh2_hka));
  7528. printf(" ssh v2 mac: %s\n",showstring(ssh2_mac));
  7529. printf(" ssh v2 user-known-hosts-file: %s\n",showstring(ssh2_unh));
  7530. #else
  7531. #ifdef SSHCMD
  7532. extern char * sshcmd, * defsshcmd;
  7533. char * s;
  7534. s = sshcmd ? sshcmd : defsshcmd;
  7535. printf("\n SSH is external.\n\n");
  7536. printf(" ssh command: %s\n",showstring(s));
  7537. #endif /* SSHCMD */
  7538. #endif /* SSHBUILTIN */
  7539. printf("\n");
  7540. }
  7541. static int
  7542. dosetssh() {
  7543. #ifdef SSHCMD
  7544. extern char * sshcmd;
  7545. #endif /* SSHCMD */
  7546. #ifdef SSHBUILTIN
  7547. #ifndef SSHTEST
  7548. extern int sl_ssh_xfw_saved, sl_ssh_ver_saved;
  7549. #endif /* SSHTEST */
  7550. #endif /* SSHBUILTIN */
  7551. int cx, x, y, z;
  7552. char * s;
  7553. if ((cx = cmkey(sshtab,nsshtab,"","command", xxstring)) < 0)
  7554. return(cx);
  7555. switch (cx) {
  7556. #ifdef SSHCMD
  7557. case SSH_CMD: /* Command */
  7558. if ((x = cmtxt("Command to start ssh","ssh -e none",
  7559. &s,xxstring)) < 0)
  7560. return(x);
  7561. makestr(&sshcmd,s);
  7562. return(success = 1);
  7563. #endif /* SSHCMD */
  7564. #ifdef SSHBUILTIN
  7565. case SSH_AFW: /* Agent-forwarding */
  7566. return(success = seton(&ssh_afw));
  7567. case SSH_CHI: /* Check Host IP */
  7568. return(success = seton(&ssh_chkip));
  7569. break;
  7570. case SSH_CMP: /* Compression */
  7571. return(success = seton(&ssh_cmp));
  7572. case SSH_DYF: /* Dynamic Forwarding */
  7573. return(success = seton(&ssh_dyf));
  7574. case SSH_GWP: /* Gateway ports */
  7575. return(success = seton(&ssh_gwp));
  7576. case SSH_GSS: /* GSSAPI */
  7577. if ((y = cmkey(gssapitab,ngssapitab,"","", xxstring)) < 0)
  7578. return(y);
  7579. switch (y) {
  7580. case 1: /* Delegate credentials */
  7581. return(success = seton(&ssh_gsd));
  7582. case 2: /* key-exchange */
  7583. return(success = seton(&ssh_gkx));
  7584. }
  7585. if ((x = cmcfm()) < 0)
  7586. return(x);
  7587. return(success = 0);
  7588. #ifdef COMMENT
  7589. case SSH_KBD: /* Kbd Interactive Devices */
  7590. if ((x = cmcfm()) < 0)
  7591. return(x);
  7592. /* TO BE FILLED IN */
  7593. return(-2);
  7594. #endif /* COMMENT */
  7595. case SSH_K4: /* Kerberos IV */
  7596. case SSH_K5: /* Kerberos V */
  7597. if ((y = cmkey(tgtpass,1,"","tgt-passing", xxstring)) < 0)
  7598. return(y);
  7599. switch (y) {
  7600. case 1:
  7601. return(success = (cx == SSH_K4) ?
  7602. seton(&ssh_k4tgt) : seton(&ssh_k5tgt));
  7603. }
  7604. if ((x = cmcfm()) < 0)
  7605. return(x);
  7606. return(success = 0);
  7607. case SSH_PRP: /* Privd port */
  7608. return(success = seton(&ssh_prp));
  7609. case SSH_SHH: /* Quiet */
  7610. return(success = seton(&ssh_shh));
  7611. case SSH_SHK: /* Strict Host Key Check */
  7612. if ((y = cmkey(ooktab,3,"","", xxstring)) < 0)
  7613. return(y);
  7614. if ((x = cmcfm()) < 0)
  7615. return(x);
  7616. ssh_shk = y;
  7617. return(success = 1);
  7618. case SSH_HBT:
  7619. x = cmnum("Heartbeat interval, seconds","0",10,&z,xxstring);
  7620. if (x < 0) return(x);
  7621. if ((x = cmcfm()) < 0) return(x);
  7622. ssh_hbt = z;
  7623. return(success = 1);
  7624. case SSH_V1: /* SSH V1 */
  7625. if ((y = cmkey(sshv1tab,nsshv1tab,"","", xxstring)) < 0)
  7626. return(y);
  7627. switch (y) {
  7628. case SSH1_K54:
  7629. return(success = seton(&ssh_k5_is_k4));
  7630. case SSH1_CIF: /* Not a list */
  7631. if ((y = cmkey(ssh1ciphers,nssh1ciphers,"","", xxstring)) < 0)
  7632. if (y != -3)
  7633. return(y);
  7634. if ((x = cmcfm()) < 0) return(x);
  7635. if (y == -3) {
  7636. makestr(&ssh1_cif,NULL);
  7637. } else {
  7638. for (x = 0; x < nssh1ciphers; x++)
  7639. if (ssh1ciphers[x].kwval == y)
  7640. break;
  7641. makestr(&ssh1_cif,ssh1ciphers[x].kwd);
  7642. }
  7643. return(1);
  7644. case SSH1_GNH:
  7645. case SSH1_UNH:
  7646. if ((x = cmifi("Filename","",&s,&z,xxstring)) < 0) {
  7647. if (x != -3)
  7648. return(x);
  7649. } else {
  7650. ckstrncpy(line,s,LINBUFSIZ);
  7651. if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  7652. ckstrncpy(line,tmpbuf,LINBUFSIZ);
  7653. }
  7654. s = (x == -3) ? NULL : line;
  7655. if ((x = cmcfm()) < 0)
  7656. return(x);
  7657. switch (y) {
  7658. case SSH1_GNH: makestr(&ssh1_gnh,s); break;
  7659. case SSH1_UNH: makestr(&ssh1_unh,s); break;
  7660. }
  7661. return(1);
  7662. }
  7663. case SSH_V2: /* SSH V2 */
  7664. if ((y = cmkey(sshv2tab,nsshv2tab,"","", xxstring)) < 0)
  7665. return(y);
  7666. switch (y) {
  7667. case SSH2_ARK:
  7668. return(success = seton(&ssh2_ark));
  7669. case SSH2_AUT: { /* Authentication */
  7670. #define TMPCNT 12
  7671. int i, j, tmp[TMPCNT];
  7672. for (i = 0; i < TMPCNT; i++)
  7673. tmp[i] = 0;
  7674. for (i = 0; i < TMPCNT; i++) {
  7675. if ((y = cmkey(ssh2aut,nssh2aut,
  7676. "Authentication method","",xxstring)) < 0) {
  7677. if (y == -3)
  7678. break;
  7679. return(y);
  7680. }
  7681. for (j = 0; j < i; j++) {
  7682. if (tmp[j] == y) {
  7683. printf("\r\n?Choice has already been used.\r\n");
  7684. return(-9);
  7685. }
  7686. }
  7687. tmp[i] = y;
  7688. }
  7689. if ((z = cmcfm()) < 0)
  7690. return(z);
  7691. if (ssh2_auth) {
  7692. free(ssh2_auth);
  7693. ssh2_auth = NULL;
  7694. }
  7695. if (i > 0) {
  7696. int len = 0;
  7697. for (j = 0; j < i; j++) {
  7698. for (x = 0; x < nssh2aut; x++)
  7699. if (ssh2aut[x].kwval == tmp[j] && !ssh2aut[x].flgs)
  7700. break;
  7701. len += strlen(ssh2aut[x].kwd) + 1;
  7702. }
  7703. ssh2_auth = malloc(len);
  7704. ssh2_auth[0] = '\0';
  7705. for (j = 0; j < i; j++) {
  7706. for (x = 0; x < nssh2aut; x++)
  7707. if (ssh2aut[x].kwval == tmp[j] && !ssh2aut[x].flgs)
  7708. break;
  7709. ckstrncat(ssh2_auth,ssh2aut[x].kwd,len);
  7710. if (j < i - 1)
  7711. ckstrncat(ssh2_auth,",",len);
  7712. }
  7713. }
  7714. return(success = 1);
  7715. #undef TMPCNT
  7716. }
  7717. case SSH2_CIF: {
  7718. #define TMPCNT 12
  7719. int i, j, tmp[TMPCNT];
  7720. for (i = 0; i < TMPCNT; i++)
  7721. tmp[i] = 0;
  7722. for (i = 0; i < TMPCNT; i++) {
  7723. if ((y = cmkey(ssh2ciphers,nssh2ciphers,
  7724. "","", xxstring)) < 0) {
  7725. if (y == -3)
  7726. break;
  7727. return(y);
  7728. }
  7729. for (j = 0; j < i; j++) {
  7730. if (tmp[j] == y) {
  7731. printf("\r\n?Choice has already been used.\r\n");
  7732. return(-9);
  7733. }
  7734. }
  7735. tmp[i] = y;
  7736. }
  7737. if ((z = cmcfm()) < 0)
  7738. return(z);
  7739. if (ssh2_cif) {
  7740. free(ssh2_cif);
  7741. ssh2_cif = NULL;
  7742. }
  7743. if (i > 0) {
  7744. int len = 0;
  7745. for (j=0; j < i; j++) {
  7746. for (x = 0; x < nssh2ciphers; x++)
  7747. if (ssh2ciphers[x].kwval == tmp[j] &&
  7748. !ssh2ciphers[x].flgs)
  7749. break;
  7750. len += strlen(ssh2ciphers[x].kwd) + 1;
  7751. }
  7752. ssh2_cif = malloc(len);
  7753. ssh2_cif[0] = '\0';
  7754. for (j = 0; j < i; j++) {
  7755. for (x = 0; x < nssh2ciphers; x++)
  7756. if (ssh2ciphers[x].kwval == tmp[j] && !ssh2ciphers[x].flgs)
  7757. break;
  7758. ckstrncat(ssh2_cif,ssh2ciphers[x].kwd,len);
  7759. if (j < i - 1)
  7760. ckstrncat(ssh2_cif,",",len);
  7761. }
  7762. }
  7763. return(success = 1);
  7764. #undef TMPCNT
  7765. }
  7766. case SSH2_MAC: {
  7767. #define TMPCNT 12
  7768. int i, j, tmp[TMPCNT];
  7769. for (i = 0; i < TMPCNT; i++)
  7770. tmp[i] = 0;
  7771. for (i = 0; i < TMPCNT; i++) {
  7772. if ((y = cmkey(ssh2macs,nssh2macs,"","", xxstring)) < 0) {
  7773. if (y == -3)
  7774. break;
  7775. return(y);
  7776. }
  7777. for (j = 0; j < i; j++) {
  7778. if (tmp[j] == y) {
  7779. printf("\r\n?Choice has already been used.\r\n");
  7780. return(-9);
  7781. }
  7782. }
  7783. tmp[i] = y;
  7784. }
  7785. if ((z = cmcfm()) < 0)
  7786. return(z);
  7787. if (ssh2_mac) {
  7788. free(ssh2_mac);
  7789. ssh2_mac = NULL;
  7790. }
  7791. if (i > 0) {
  7792. int len = 0;
  7793. for (j = 0; j < i; j++) {
  7794. for (x = 0; x < nssh2macs; x++)
  7795. if (ssh2macs[x].kwval == tmp[j] && !ssh2macs[x].flgs)
  7796. break;
  7797. len += strlen(ssh2macs[x].kwd) + 1;
  7798. }
  7799. ssh2_mac = malloc(len);
  7800. ssh2_mac[0] = '\0';
  7801. for (j=0; j < i; j++) {
  7802. for (x = 0; x < nssh2macs; x++)
  7803. if (ssh2macs[x].kwval == tmp[j] && !ssh2macs[x].flgs)
  7804. break;
  7805. ckstrncat(ssh2_mac,ssh2macs[x].kwd,len);
  7806. if (j < i - 1)
  7807. ckstrncat(ssh2_mac,",",len);
  7808. }
  7809. }
  7810. return(success = 1);
  7811. #undef TMPCNT
  7812. }
  7813. case SSH2_HKA: {
  7814. #define TMPCNT 12
  7815. int i, j, tmp[TMPCNT];
  7816. for (i = 0; i < TMPCNT; i++)
  7817. tmp[i] = 0;
  7818. for (i = 0; i < TMPCNT; i++) {
  7819. if ((y = cmkey(hkatab,nhkatab,
  7820. "","", xxstring)) < 0) {
  7821. if (y == -3)
  7822. break;
  7823. return(y);
  7824. }
  7825. for (j = 0; j < i; j++) {
  7826. if (tmp[j] == y) {
  7827. printf("\r\n?Choice has already been used.\r\n");
  7828. return(-9);
  7829. }
  7830. }
  7831. tmp[i] = y;
  7832. }
  7833. if ((z = cmcfm()) < 0)
  7834. return(z);
  7835. if (ssh2_hka) {
  7836. free(ssh2_hka);
  7837. ssh2_hka = NULL;
  7838. }
  7839. if (i > 0) {
  7840. int len = 0;
  7841. for (j=0; j < i; j++) {
  7842. for (x = 0; x < nhkatab; x++)
  7843. if (hkatab[x].kwval == tmp[j] &&
  7844. !hkatab[x].flgs)
  7845. break;
  7846. len += strlen(hkatab[x].kwd) + 1;
  7847. }
  7848. ssh2_hka = malloc(len);
  7849. ssh2_hka[0] = '\0';
  7850. for (j = 0; j < i; j++) {
  7851. for (x = 0; x < nhkatab; x++)
  7852. if (hkatab[x].kwval == tmp[j] && !hkatab[x].flgs)
  7853. break;
  7854. ckstrncat(ssh2_hka,hkatab[x].kwd,len);
  7855. if (j < i - 1)
  7856. ckstrncat(ssh2_hka,",",len);
  7857. }
  7858. }
  7859. return(success = 1);
  7860. #undef TMPCNT
  7861. }
  7862. case SSH2_GNH:
  7863. case SSH2_UNH:
  7864. if ((x = cmifi("Filename","",&s,&z,xxstring)) < 0) {
  7865. if (x != -3)
  7866. return(x);
  7867. } else {
  7868. ckstrncpy(line,s,LINBUFSIZ);
  7869. if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  7870. ckstrncpy(line,tmpbuf,LINBUFSIZ);
  7871. }
  7872. s = (x == -3) ? NULL : line;
  7873. if ((x = cmcfm()) < 0)
  7874. return(x);
  7875. switch (y) {
  7876. case SSH2_GNH: makestr(&ssh2_gnh,s); break;
  7877. case SSH2_UNH: makestr(&ssh2_unh,s); break;
  7878. default: return(success = 0);
  7879. }
  7880. return(success = 1);
  7881. }
  7882. case SSH_VRB: /* Verbosity level */
  7883. y = cmnum("SSH verbosity level, 0-7","2",10,&x,xxstring);
  7884. return(setnum(&ssh_vrb,x,y,7));
  7885. case SSH_VER: /* Version */
  7886. if ((y = cmkey(sshver,3,"","auto", xxstring)) < 0)
  7887. return(y);
  7888. if ((x = cmcfm()) < 0)
  7889. return(x);
  7890. ssh_ver = y; /* 0 == AUTO */
  7891. #ifndef SSHTEST
  7892. sl_ssh_ver_saved = 0;
  7893. #endif /* SSHTEST */
  7894. return(success = 1);
  7895. case SSH_IDF: { /* Identity file */
  7896. int i, n;
  7897. for (i = 0; i < 32; i++) {
  7898. if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0) {
  7899. if (x == -3)
  7900. break;
  7901. return(x);
  7902. }
  7903. if (!zfnqfp(s,LINBUFSIZ,line))
  7904. ckstrncpy(line,s,LINBUFSIZ);
  7905. makestr(&ssh_tmp[i],line);
  7906. }
  7907. n = i;
  7908. if ((x = cmcfm()) < 0) {
  7909. for (i = 0; i < n; i++)
  7910. makestr(&(ssh_tmp[i]),NULL);
  7911. return(x);
  7912. }
  7913. for (i = 0; i < 32; i++) {
  7914. makestr(&(ssh_idf[i]),NULL);
  7915. if (i < n) {
  7916. ssh_idf[i] = ssh_tmp[i];
  7917. ssh_tmp[i] = NULL;
  7918. } else {
  7919. makestr(&(ssh_tmp[i]),NULL);
  7920. }
  7921. }
  7922. ssh_idf_n = n;
  7923. return(success = 1);
  7924. }
  7925. case SSH_XFW: /* X11-forwarding */
  7926. success = seton(&ssh_xfw);
  7927. #ifndef SSHTEST
  7928. if (success)
  7929. sl_ssh_xfw_saved = 0;
  7930. #endif /* SSHTEST */
  7931. return(success);
  7932. case SSH_XAL: /* SSH Xauth Location */
  7933. if ((x = cmifi("Path to executable", "",&s,&y,xxstring)) < 0) {
  7934. if (x != -3)
  7935. return(x);
  7936. } else {
  7937. ckstrncpy(line,s,LINBUFSIZ);
  7938. if (zfnqfp(line,TMPBUFSIZ,tmpbuf))
  7939. ckstrncpy(line,tmpbuf,LINBUFSIZ);
  7940. }
  7941. s = (x == -3) ? NULL : line;
  7942. if ((x = cmcfm()) < 0) return(x);
  7943. makestr(&ssh_xal,s);
  7944. return(success = 1);
  7945. case SSH_CFG: /* Use OpenSSH Config */
  7946. return(success = seton(&ssh_cfg));
  7947. #endif /* SSHBUILTIN */
  7948. default:
  7949. return(-2);
  7950. }
  7951. }
  7952. #endif /* ANYSSH */
  7953. #ifdef SFTP_BUILTIN
  7954. static int
  7955. dosetsftp() {
  7956. int cx, x, y, z;
  7957. char * s;
  7958. if ((cx = cmkey(sftptab,nsftptab,"","", xxstring)) < 0)
  7959. return(cx);
  7960. switch (cx) {
  7961. case XY_SFTP_EOL:
  7962. case XY_SFTP_RCS:
  7963. default:
  7964. return(-2);
  7965. }
  7966. }
  7967. #endif /* SFTP_BUILTIN */
  7968. #ifdef KUI
  7969. #include "ikui.h"
  7970. extern ULONG RGBTable[16];
  7971. #define GUI_RGB 1
  7972. #define GUI_WIN 2
  7973. #define GUI_FON 3
  7974. #define GUI_DIA 4
  7975. #define GUI_TLB 5
  7976. #define GUI_MNB 6
  7977. #define GUI_CLS 7
  7978. #define GUIW_POS 1
  7979. #define GUIW_RES 2
  7980. #define GUIW_RUN 3
  7981. #define GUIWR_NON 0
  7982. #define GUIWR_FON 1
  7983. #define GUIWR_DIM 2
  7984. #define GUIWN_RES 1
  7985. #define GUIWN_MIN 2
  7986. #define GUIWN_MAX 3
  7987. static struct keytab guitab[] = {
  7988. { "close", GUI_CLS, 0 },
  7989. { "dialogs", GUI_DIA, 0 },
  7990. { "font", GUI_FON, 0 },
  7991. { "menubar", GUI_MNB, 0 },
  7992. { "rgbcolor", GUI_RGB, 0 },
  7993. { "toolbar", GUI_TLB, 0 },
  7994. { "window", GUI_WIN, 0 },
  7995. { "", 0, 0}
  7996. };
  7997. static int nguitab = (sizeof(guitab) / sizeof(struct keytab));
  7998. static struct keytab guiwtab[] = {
  7999. { "position", GUIW_POS, 0 },
  8000. { "resize-mode", GUIW_RES, 0 },
  8001. { "run-mode", GUIW_RUN, 0 },
  8002. { "", 0, 0}
  8003. };
  8004. static int nguiwtab = (sizeof(guiwtab) / sizeof(struct keytab));
  8005. static struct keytab guiwrtab[] = {
  8006. { "change-dimensions", GUIWR_DIM, 0 },
  8007. { "none", GUIWR_NON, 0 },
  8008. { "scale-font", GUIWR_FON, 0 },
  8009. { "", 0, 0}
  8010. };
  8011. static int nguiwrtab = (sizeof(guiwrtab) / sizeof(struct keytab));
  8012. static struct keytab guiwntab[] = {
  8013. { "maximize", GUIWN_MAX, 0 },
  8014. { "minimize", GUIWN_MIN, 0 },
  8015. { "restore", GUIWN_RES, 0 },
  8016. { "", 0, 0}
  8017. };
  8018. static int nguiwntab = (sizeof(guiwntab) / sizeof(struct keytab));
  8019. static struct keytab rgbtab[] = {
  8020. { "black", 0, 0 },
  8021. { "blue", 1, 0 },
  8022. { "brown", 6, 0 },
  8023. { "cyan", 3, 0 },
  8024. { "darkgray", 8, 0 },
  8025. { "dgray", 8, CM_INV },
  8026. { "green", 2, 0 },
  8027. { "lblue", 9, CM_INV },
  8028. { "lcyan", 11, CM_INV },
  8029. { "lgreen", 10, CM_INV },
  8030. { "lgray", 7, CM_INV },
  8031. { "lightblue", 9, 0 },
  8032. { "lightcyan", 11, 0 },
  8033. { "lightgreen", 10, 0 },
  8034. { "lightgray", 7, 0 },
  8035. { "lightmagenta", 13, 0 },
  8036. { "lightred", 12, 0 },
  8037. { "lmagenta", 13, CM_INV },
  8038. { "lred", 12, CM_INV },
  8039. { "magenta", 5, 0 },
  8040. { "red", 4, 0 },
  8041. { "white", 15, 0 },
  8042. { "yellow", 14, 0 },
  8043. };
  8044. int nrgb = (sizeof(rgbtab) / sizeof(struct keytab));
  8045. VOID
  8046. shogui() {
  8047. extern gui_dialog;
  8048. extern HWND getHwndKUI();
  8049. unsigned char cmdsav = colorcmd;
  8050. int i, red, green, blue, lines=0;
  8051. char * s;
  8052. printf("GUI paramters:\n");
  8053. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  8054. printf(" Dialogs: %s\n",showoff(gui_dialog));
  8055. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  8056. printf(" Position: %d,%d\n",get_gui_window_pos_x(),
  8057. get_gui_window_pos_y());
  8058. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  8059. printf(" Resolution: %d x %d\n",GetSystemMetrics(SM_CXSCREEN),
  8060. GetSystemMetrics(SM_CYSCREEN));
  8061. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  8062. printf(" Run-mode: %s\n",IsIconic(getHwndKUI()) ? "minimized" :
  8063. IsZoomed(getHwndKUI()) ? "maximized" : "restored");
  8064. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  8065. switch ( get_gui_resize_mode() ) {
  8066. case GUIWR_NON:
  8067. s = "none";
  8068. break;
  8069. case GUIWR_FON:
  8070. s = "scales font";
  8071. break;
  8072. case GUIWR_DIM:
  8073. s= "changes dimensions";
  8074. break;
  8075. }
  8076. printf(" Resize-mode: %s\n",s);
  8077. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  8078. printf("\n");
  8079. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  8080. printf("RGB Color Table:\n");
  8081. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  8082. printf(" Color Red Green Blue\n");
  8083. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  8084. printf(" ------------------------------------------\n");
  8085. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  8086. for (i = 0; i < nrgb; i++) {
  8087. if (!rgbtab[i].flgs) {
  8088. blue = (RGBTable[rgbtab[i].kwval] & 0x00FF0000)>>16;
  8089. green = (RGBTable[rgbtab[i].kwval] & 0x0000FF00)>>8;
  8090. red = (RGBTable[rgbtab[i].kwval] & 0x000000FF);
  8091. printf(" %-18s %3d %3d %3d ",rgbtab[i].kwd,red,green,blue);
  8092. colorcmd = rgbtab[i].kwval << 4;
  8093. printf("********");
  8094. colorcmd = cmdsav;
  8095. printf("\n");
  8096. if (++lines > cmd_rows - 3) {
  8097. if (!askmore())
  8098. return;
  8099. else
  8100. lines = 0;
  8101. }
  8102. }
  8103. }
  8104. printf("\n");
  8105. }
  8106. int
  8107. setrgb() {
  8108. int cx, red = 0, blue = 0, green = 0, z, x;
  8109. if ((cx = cmkey(rgbtab,nrgb,"","",xxstring)) < 0)
  8110. return(cx);
  8111. if ((z = cmnum("Red value, 0-255","",10,&red,xxstring)) < 0)
  8112. return(z);
  8113. if ((z = cmnum("Green value, 0-255","",10,&green,xxstring)) < 0)
  8114. return(z);
  8115. if ((z = cmnum("Blue value, 0-255","",10,&blue,xxstring)) < 0)
  8116. return(z);
  8117. if ((x = cmcfm()) < 0) return(x);
  8118. if (cx > 15 || red > 255 || blue > 255 || green > 255)
  8119. return(-2);
  8120. RGBTable[cx] = (unsigned)(((unsigned)blue << 16) |
  8121. (unsigned)((unsigned)green << 8) |
  8122. (unsigned)red);
  8123. return(success = 1);
  8124. }
  8125. /*
  8126. Set GUI window position: XY coordinates of upper left corner,
  8127. expressed as pixel numbers in the current screen resolution.
  8128. (0,0) means put ourselves in the upper left corner.
  8129. Can we check for out of bounds?
  8130. */
  8131. int
  8132. setguiwin() {
  8133. int cx, x, y, z;
  8134. if ((cx = cmkey(guiwtab,nguiwtab,"","",xxstring)) < 0)
  8135. return(cx);
  8136. switch (cx) {
  8137. case GUIW_POS:
  8138. if ((z = cmnum("X coordinate (pixel number)","",10,&x,xxstring)) < 0)
  8139. return(z);
  8140. if ((z = cmnum("Y coordinate (pixel number)","",10,&y,xxstring)) < 0)
  8141. return(z);
  8142. if ((z = cmcfm()) < 0)
  8143. return(z);
  8144. if (x < 0 || y < 0) {
  8145. printf("?Coordinates must be 0 or greater\n");
  8146. return(-9);
  8147. }
  8148. gui_position(x,y);
  8149. return(success = 1);
  8150. case GUIW_RES:
  8151. if ((x = cmkey(guiwrtab,nguiwrtab,"","",xxstring)) < 0)
  8152. return(x);
  8153. if ((z = cmcfm()) < 0)
  8154. return(z);
  8155. gui_resize_mode(x);
  8156. return(success = 1);
  8157. case GUIW_RUN:
  8158. if ((x = cmkey(guiwntab,nguiwntab,"","",xxstring)) < 0)
  8159. return(x);
  8160. if ((z = cmcfm()) < 0)
  8161. return(z);
  8162. gui_win_run_mode(x);
  8163. return(success = 1);
  8164. default:
  8165. return(-2);
  8166. }
  8167. }
  8168. int
  8169. setguifont() { /* Assumes that CKFLOAT is defined! */
  8170. extern struct keytab * term_font;
  8171. extern struct keytab * _term_font;
  8172. extern int tt_font, tt_font_size, ntermfont;
  8173. int x, y, z;
  8174. char *s;
  8175. if (ntermfont == 0)
  8176. BuildFontTable(&term_font, &_term_font, &ntermfont);
  8177. if (!(term_font && _term_font && ntermfont > 0)) {
  8178. printf("?Internal error: Failure to enumerate fonts\n");
  8179. return(-9);
  8180. }
  8181. if ((x = cmkey(_term_font,ntermfont,"","",xxstring)) < 0)
  8182. return(x);
  8183. if ((z = cmfld("Height of font in points","12",&s,xxstring)) < 0)
  8184. return(z);
  8185. if (isfloat(s,0) < 1) { /* (sets floatval) */
  8186. printf("?Integer or floating-point number required\n");
  8187. return(-9);
  8188. }
  8189. if (floatval < 0.5) {
  8190. printf("?Positive number required\n");
  8191. return(-9);
  8192. }
  8193. if ((z = cmcfm()) < 0)
  8194. return(z);
  8195. tt_font = x; /* Font index */
  8196. tt_font_size = (int)(floatval * 2); /* Font size in half points */
  8197. KuiSetProperty(KUI_TERM_FONT, (long)tt_font, (long)tt_font_size);
  8198. return(success = 1);
  8199. }
  8200. VOID
  8201. setguidialog(x) int x;
  8202. {
  8203. extern int gui_dialog;
  8204. gui_dialog = x;
  8205. KuiSetProperty(KUI_GUI_DIALOGS, (long)x, 0L);
  8206. }
  8207. VOID
  8208. setguimenubar(x) int x;
  8209. {
  8210. KuiSetProperty(KUI_GUI_MENUBAR, (long)x, 0L);
  8211. }
  8212. VOID
  8213. setguitoolbar(x) int x;
  8214. {
  8215. KuiSetProperty(KUI_GUI_TOOLBAR, (long)x, 0L);
  8216. }
  8217. VOID
  8218. setguiclose(x) int x;
  8219. {
  8220. KuiSetProperty(KUI_GUI_CLOSE, (long)x, 0L);
  8221. }
  8222. int
  8223. setgui() {
  8224. int cx, x, rc;
  8225. if ((cx = cmkey(guitab,nguitab,"","",xxstring)) < 0)
  8226. return(cx);
  8227. switch (cx) {
  8228. case GUI_DIA:
  8229. rc = seton(&x);
  8230. if (rc >= 0)
  8231. setguidialog(x);
  8232. return(rc);
  8233. case GUI_FON:
  8234. return(setguifont());
  8235. case GUI_RGB:
  8236. return(setrgb());
  8237. case GUI_WIN:
  8238. return(setguiwin());
  8239. case GUI_TLB:
  8240. rc = seton(&x);
  8241. if (rc >= 0)
  8242. setguitoolbar(x);
  8243. return(rc);
  8244. case GUI_MNB:
  8245. rc = seton(&x);
  8246. if (rc >= 0)
  8247. setguimenubar(x);
  8248. return(rc);
  8249. case GUI_CLS:
  8250. rc = seton(&x);
  8251. if (rc >= 0)
  8252. setguiclose(x);
  8253. return(rc);
  8254. default:
  8255. return(-2);
  8256. }
  8257. }
  8258. #endif /* KUI */
  8259. VOID
  8260. setexitwarn(x) int x;
  8261. {
  8262. xitwarn = x;
  8263. #ifdef KUI
  8264. KuiSetProperty(KUI_EXIT_WARNING, (long)x, 0L);
  8265. #endif /* KUI */
  8266. }
  8267. #ifndef NOLOCAL
  8268. VOID
  8269. setdebses(x) int x; {
  8270. #ifdef OS2
  8271. if ((debses != 0) && (x == 0)) /* It was on and we turned it off? */
  8272. os2debugoff(); /* Fix OS/2 coloration */
  8273. #endif /* OS2 */
  8274. debses = x;
  8275. #ifdef KUI
  8276. KuiSetProperty(KUI_TERM_DEBUG,x,0);
  8277. #endif /* KUI */
  8278. }
  8279. #endif /* NOLOCAL */
  8280. /* D O P R M -- Set a parameter. */
  8281. /*
  8282. Returns:
  8283. -2: illegal input
  8284. -1: reparse needed
  8285. 0: success
  8286. */
  8287. int
  8288. doprm(xx,rmsflg) int xx, rmsflg; {
  8289. int i = 0, x = 0, y = 0, z = 0;
  8290. long zz = 0L;
  8291. char *s = NULL, *p = NULL;
  8292. #ifdef OS2
  8293. char portbuf[64];
  8294. long portspeed = 0L;
  8295. int portparity = 0;
  8296. int portflow = 0;
  8297. #endif /* OS2 */
  8298. #ifndef NOSETKEY
  8299. #ifdef OS2
  8300. if (xx == XYMSK)
  8301. return(setmsk());
  8302. #endif /* OS2 */
  8303. #endif /* NOSETKEY */
  8304. if (xx == XYFLAG) { /* SET FLAG */
  8305. extern int ooflag;
  8306. return(success = seton(&ooflag));
  8307. }
  8308. if (xx == XYPRTR /* SET PRINTER (or BPRINTER) */
  8309. #ifdef BPRINT
  8310. || xx == XYBDCP
  8311. #endif /* BPRINT */
  8312. )
  8313. return(setprinter(xx));
  8314. switch (xx) {
  8315. #ifdef ANYX25 /* SET X25 ... */
  8316. case XYX25:
  8317. return(setx25());
  8318. #ifndef IBMX25
  8319. case XYPAD: /* SET PAD ... */
  8320. return(setpadp());
  8321. #endif /* IBMX25 */
  8322. #endif /* ANYX25 */
  8323. #ifndef NOXFER
  8324. case XYEOL: /* These have all been moved to set send/receive... */
  8325. case XYLEN: /* Let the user know what to do. */
  8326. case XYMARK:
  8327. case XYNPAD:
  8328. case XYPADC:
  8329. case XYTIMO:
  8330. printf("...Use SET SEND or SET RECEIVE instead.\n");
  8331. printf("Type HELP SET SEND or HELP SET RECEIVE for more info.\n");
  8332. return(success = 0);
  8333. case XYATTR: /* File Attribute packets */
  8334. return(setat(rmsflg));
  8335. case XYIFD: /* Incomplete file disposition */
  8336. if ((y = cmkey(ifdatab,3,"","auto",xxstring)) < 0) return(y);
  8337. if ((x = cmcfm()) < 0) return(x);
  8338. if (rmsflg) {
  8339. sstate = setgen('S',
  8340. "310",
  8341. y == 0 ? "0" : (y == 1 ? "1" : "2"),
  8342. ""
  8343. );
  8344. return((int) sstate);
  8345. } else {
  8346. keep = y;
  8347. return(success = 1);
  8348. }
  8349. #endif /* NOXFER */
  8350. case XYMATCH: /* [ REMOTE ] SET MATCH... */
  8351. #ifndef NOXFER
  8352. if ((z = cmkey(matchtab,nmatchtab,"","",xxstring)) < 0)
  8353. return(z);
  8354. if (rmsflg) {
  8355. if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
  8356. if ((x = cmcfm()) < 0) return(x);
  8357. switch (z) {
  8358. case MCH_DOTF:
  8359. return(sstate = setgen('S',"330", y == 0 ? "0" : "1", ""));
  8360. case MCH_FIFO:
  8361. return(sstate = setgen('S',"331", y == 0 ? "0" : "1", ""));
  8362. default:
  8363. return(-2);
  8364. }
  8365. }
  8366. #endif /* NOXFER */
  8367. switch (z) {
  8368. case MCH_FIFO:
  8369. return(success = seton(&matchfifo));
  8370. case MCH_DOTF:
  8371. x = seton(&matchdot);
  8372. if (x < 0) return(x);
  8373. dir_dots = -1;
  8374. return(success = x);
  8375. default:
  8376. return(-2);
  8377. }
  8378. #ifndef NOSPL
  8379. case XYINPU: /* SET INPUT */
  8380. return(setinp());
  8381. #endif /* NOSPL */
  8382. #ifdef NETCONN
  8383. case XYNET: { /* SET NETWORK */
  8384. struct FDB k1, k2;
  8385. cmfdbi(&k1,_CMKEY,"","","",nnetkey, 0, xxstring, netkey, &k2);
  8386. cmfdbi(&k2,_CMKEY,"","","",nnets, 0, xxstring, netcmd, NULL);
  8387. #ifdef OS2 /* Hide network-type keywords for networks not installed */
  8388. for (z = 0; z < nnets; z++) {
  8389. if (netcmd[z].kwval == NET_TCPB && tcp_avail == 0)
  8390. netcmd[z].flgs = CM_INV;
  8391. #ifdef SSHBUILTIN
  8392. if (netcmd[z].kwval == NET_SSH &&
  8393. !ck_ssleay_is_installed())
  8394. netcmd[z].flgs = CM_INV;
  8395. #endif /* SSHBUILTIN */
  8396. #ifdef DECNET
  8397. else if (netcmd[z].kwval == NET_DEC && dnet_avail == 0)
  8398. netcmd[z].flgs = CM_INV;
  8399. #endif /* DECNET */
  8400. #ifdef CK_NETBIOS
  8401. else if (netcmd[z].kwval == NET_BIOS && netbiosAvail == 0)
  8402. netcmd[z].flgs = CM_INV;
  8403. #endif /* CK_NETBIOS */
  8404. #ifdef SUPERLAT
  8405. else if (netcmd[z].kwval == NET_SLAT && slat_avail == 0)
  8406. netcmd[z].flgs = CM_INV;
  8407. #endif /* SUPERLAT */
  8408. }
  8409. if (tcp_avail) /* Default network type */
  8410. ckstrncpy(tmpbuf,"tcp/ip",TMPBUFSIZ);
  8411. #ifdef SSHBUILTIN
  8412. else if ( ck_ssleay_is_installed() )
  8413. ckstrncpy(tmpbuf,"ssh",TMPBUFSIZ);
  8414. #endif /* SSHBUILTIN */
  8415. #ifdef DECNET
  8416. else if (dnet_avail)
  8417. ckstrncpy(tmpbuf,"decnet",TMPBUFSIZ);
  8418. #endif /* DECNET */
  8419. #ifdef SUPERLAT
  8420. else if (slat_avail)
  8421. ckstrncpy(tmpbuf,"superlat",TMPBUFSIZ);
  8422. #endif /* SUPERLAT */
  8423. #ifdef CK_NETBIOS
  8424. else if (netbiosAvail)
  8425. ckstrncpy(tmpbuf,"netbios",TMPBUFSIZ);
  8426. #endif /* CK_NETBIOS */
  8427. else ckstrncpy(tmpbuf,"named-pipe",TMPBUFSIZ);
  8428. #else /* OS2 */
  8429. #ifdef TCPSOCKET
  8430. ckstrncpy(tmpbuf,"tcp/ip",TMPBUFSIZ);
  8431. #else
  8432. #ifdef ANYX25
  8433. ckstrncpy(tmpbuf,"x.25",TMPBUFSIZ);
  8434. #else
  8435. ckstrncpy(tmpbuf,"",TMPBUFSIZ);
  8436. #endif /* ANYX25 */
  8437. #endif /* TCPSOCKET */
  8438. #endif /* OS2 */
  8439. x = cmfdb(&k1);
  8440. if (x < 0) { /* Error */
  8441. if (x == -2 || x == -9)
  8442. printf("?No keywords match: \"%s\"\n",atmbuf);
  8443. return(x);
  8444. }
  8445. z = cmresult.nresult; /* Keyword value */
  8446. if (cmresult.fdbaddr == &k1) { /* Which table? */
  8447. #ifndef NOSPL
  8448. #ifndef NODIAL
  8449. if (z == XYNET_D)
  8450. return(parsdir(1));
  8451. #endif /* NODIAL */
  8452. #endif /* NOSPL */
  8453. if ((z = cmkey(netcmd,nnets,"",tmpbuf,xxstring)) < 0)
  8454. return(z);
  8455. }
  8456. #ifdef NETCMD
  8457. if (z == NET_CMD && nopush) {
  8458. printf("\n?Sorry, access to external commands is disabled\n");
  8459. return(-9);
  8460. }
  8461. #endif /* NETCMD */
  8462. #ifndef NOPUSH
  8463. #ifdef NETPTY
  8464. if (z == NET_PTY && nopush) {
  8465. printf("\n?Sorry, access to external commands is disabled\n");
  8466. return(-9);
  8467. }
  8468. #endif /* NETPTY */
  8469. #endif /* NOPUSH */
  8470. #ifdef OS2
  8471. if (z == NET_TCPB && tcp_avail == 0) {
  8472. printf(
  8473. "\n?Sorry, either TCP/IP is not available on this system or\n\
  8474. necessary DLLs did not load. Use SHOW NETWORK to check network status.\n");
  8475. return(-9);
  8476. #ifdef SSHBUILTIN
  8477. } else if (z == NET_SSH && !ck_ssleay_is_installed()) {
  8478. printf("\n?Sorry, SSH is not available on this system.\n") ;
  8479. return(-9);
  8480. #endif /* SSHBUILTIN */
  8481. #ifdef CK_NETBIOS
  8482. } else if (z == NET_BIOS && netbiosAvail == 0) {
  8483. printf("\n?Sorry, NETBIOS is not available on this system.\n") ;
  8484. return(-9);
  8485. #endif /* CK_NETBIOS */
  8486. #ifdef DECNET
  8487. } else if (z == NET_DEC && dnet_avail == 0) {
  8488. printf("\n?Sorry, DECnet is not available on this system.\n") ;
  8489. return(-9);
  8490. #endif /* DECNET */
  8491. #ifdef SUPERLAT
  8492. } else if (z == NET_SLAT && slat_avail == 0) {
  8493. printf("\n?Sorry, SuperLAT is not available on this system.\n") ;
  8494. return(-9);
  8495. #endif /* SUPERLAT */
  8496. }
  8497. #endif /* OS2 */
  8498. #ifdef NPIPEORBIOS
  8499. if (z == NET_PIPE || /* Named pipe -- also get pipename */
  8500. z == NET_BIOS) { /* NETBIOS -- also get local name */
  8501. char *defnam;
  8502. #ifdef CK_NETBIOS
  8503. char tmpnbnam[NETBIOS_NAME_LEN+1];
  8504. #endif /* CK_NETBIOS */
  8505. /* Construct default name */
  8506. if (z == NET_PIPE) { /* Named pipe */
  8507. defnam = "kermit"; /* Default name is always "kermit" */
  8508. }
  8509. #ifdef CK_NETBIOS
  8510. else { /* NetBIOS */
  8511. if (NetBiosName[0] != SP) { /* If there is already a name, */
  8512. char *p = NULL;
  8513. int n; /* use it as the default. */
  8514. ckstrncpy(tmpnbnam,NetBiosName,NETBIOS_NAME_LEN+1);
  8515. /* convert trailing spaces to NULs */
  8516. p = &tmpnbnam[NETBIOS_NAME_LEN-1];
  8517. while (*p == SP) {
  8518. *p = NUL;
  8519. p--;
  8520. }
  8521. defnam = tmpnbnam;
  8522. } else if (*myhost) /* Otherwise use this PC's host name */
  8523. defnam = (char *) myhost;
  8524. else /* Otherwise use "kermit" */
  8525. defnam = "kermit";
  8526. }
  8527. #endif /* CK_NETBIOS */
  8528. if ((y = cmtxt((z == NET_PIPE) ? "name of named-pipe" :
  8529. "local NETBIOS name",
  8530. defnam, &s, xxstring)) < 0)
  8531. return(y);
  8532. #ifdef NPIPE
  8533. pipename[0] = NUL;
  8534. #endif /* NPIPE */
  8535. if ((y = (int) strlen(s)) < 1) {
  8536. printf("?You must also specify a %s name\n",
  8537. (z == NET_PIPE) ? "pipe" : "local NETBIOS" );
  8538. return(-9);
  8539. }
  8540. #ifdef CK_NETBIOS
  8541. if (z == NET_BIOS) {
  8542. if (!netbiosAvail) {
  8543. printf("?NETBIOS is not available on this system.\n") ;
  8544. return(-9);
  8545. }
  8546. if (y - NETBIOS_NAME_LEN > 0) {
  8547. printf("?NETBIOS name too long, %ld maximum\n",
  8548. NETBIOS_NAME_LEN);
  8549. return(-9);
  8550. } else if ( !strcmp(s,tmpnbnam) ) {
  8551. nettype = z; /* Returning to old connection... */
  8552. return(success = 1); /* Done */
  8553. } else if (strcmp(" ",NetBiosName)) {
  8554. printf("?NETBIOS name already assigned to \"%s\"\n",
  8555. NetBiosName);
  8556. return(-9);
  8557. } else {
  8558. NCB ncb;
  8559. APIRET rc;
  8560. ckstrncpy(NetBiosName,s,16);
  8561. for (x = y; x < NETBIOS_NAME_LEN; x++)
  8562. NetBiosName[x] = SP;
  8563. NetBiosName[NETBIOS_NAME_LEN] = NUL;
  8564. printf("Checking \"%s\" as a unique NetBIOS name...\n",
  8565. NetBiosName);
  8566. rc = NCBAddName( NetbeuiAPI,
  8567. &ncb, NetBiosAdapter, NetBiosName );
  8568. if (rc) {
  8569. printf(
  8570. "?Sorry, \"%s\" is already in use by another NetBIOS node.\n",
  8571. NetBiosName);
  8572. for (x = 0; x < NETBIOS_NAME_LEN; x++)
  8573. NetBiosName[x] = SP;
  8574. return(-9);
  8575. }
  8576. }
  8577. }
  8578. #endif /* CK_NETBIOS */
  8579. #ifdef NPIPE
  8580. if (z == NET_PIPE)
  8581. ckstrncpy(pipename,s,PIPENAML);
  8582. #endif /* NPIPE */
  8583. } else
  8584. #endif /* NPIPEORBIOS */
  8585. #ifdef DECNET
  8586. if (z == NET_DEC) {
  8587. /* Determine if we are using LAT or CTERM */
  8588. if ((y = cmkey(dnettab,
  8589. ndnet,"DECNET protocol","lat",xxstring)) < 0)
  8590. return(y);
  8591. if ((x = cmcfm()) < 0) return(x);
  8592. ttnproto = y;
  8593. } else
  8594. #endif /* DECNET */
  8595. #ifdef NETDLL
  8596. if (z == NET_DLL) {
  8597. /* Find out which DLL they are using */
  8598. char dllname[256]="";
  8599. char * p=NULL;
  8600. if ((x = cmifi("Dynamic load library",
  8601. "",&p,&y,xxstring)) < 0) {
  8602. if (x == -3) {
  8603. printf("?Name of DLL required\n");
  8604. return(-9);
  8605. }
  8606. return(x);
  8607. }
  8608. ckstrncpy(dllname,p,256);
  8609. if ((x = cmcfm()) < 0) return(x);
  8610. if (netdll_load(dllname) < 0) /* Try to load the dll */
  8611. return(success = 0);
  8612. else {
  8613. nettype = z;
  8614. return(success = 1);
  8615. }
  8616. } else
  8617. #endif /*